|
INET Framework for OMNeT++/OMNEST
|
Implements the MPLS protocol; see the NED file for more info.
More...
#include <Mpls.h>
Implements the MPLS protocol; see the NED file for more info.
◆ doStackOps()
162 unsigned int n = outLabel.size();
164 EV_INFO <<
"doStackOps: " << outLabel << endl;
166 for (
unsigned int i = 0; i < n; i++) {
167 switch (outLabel[i].optcode) {
169 auto mplsHeader = makeShared<MplsHeader>();
170 mplsHeader->setLabel(outLabel[i].label);
175 auto mplsHeader = makeShared<MplsHeader>();
176 mplsHeader->setLabel(outLabel[i].label);
185 throw cRuntimeError(
"Unknown MPLS OptCode %d", outLabel[i].optcode);
Referenced by processMplsPacketFromL2(), and tryLabelAndForwardIpv4Datagram().
◆ handleMessage()
| void inet::Mpls::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
46 Packet *pk = check_and_cast<Packet *>(msg);
47 if (msg->getArrivalGate()->isName(
"ifIn")) {
48 EV_INFO <<
"Processing message from L2: " << pk << endl;
51 else if (msg->getArrivalGate()->isName(
"netwIn")) {
52 EV_INFO <<
"Processing message from L3: " << pk << endl;
56 throw cRuntimeError(
"unexpected message: %s", msg->getName());
◆ handleRegisterInterface()
| void inet::Mpls::handleRegisterInterface |
( |
const NetworkInterface & |
interface, |
|
|
cGate * |
in, |
|
|
cGate * |
out |
|
) |
| |
|
overrideprotectedvirtual |
◆ handleRegisterProtocol()
Reimplemented from inet::DefaultProtocolRegistrationListener.
320 if (!strcmp(
"ifIn",
g->getName()))
322 else if (!strcmp(
"ifOut",
g->getName()))
324 else if (!strcmp(
"netwOut",
g->getName()))
326 else if (!strcmp(
"netwIn",
g->getName()))
329 throw cRuntimeError(
"Unknown gate: %s",
g->getName());
◆ handleRegisterService()
Reimplemented from inet::DefaultProtocolRegistrationListener.
305 if (!strcmp(
"ifOut",
g->getName()))
307 else if (!strcmp(
"ifIn",
g->getName()))
309 else if (!strcmp(
"netwOut",
g->getName()))
311 else if (!strcmp(
"netwIn",
g->getName()))
314 throw cRuntimeError(
"Unknown gate: %s",
g->getName());
◆ initialize()
| void inet::Mpls::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
29 cSimpleModule::initialize(stage);
34 lt.reference(
this,
"libTableModule",
true);
35 ift.reference(
this,
"interfaceTableModule",
true);
36 pct.reference(
this,
"classifierModule",
true);
◆ labelAndForwardIpv4Datagram()
| void inet::Mpls::labelAndForwardIpv4Datagram |
( |
Packet * |
ipdatagram | ) |
|
|
protectedvirtual |
129 EV_INFO <<
"FEC not resolved, doing regular L3 routing" << endl;
Referenced by processPacketFromL3().
◆ numInitStages()
| virtual int inet::Mpls::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ popLabel()
| void inet::Mpls::popLabel |
( |
Packet * |
packet | ) |
|
|
protected |
154 auto oldMplsHeader = packet->popAtFront<MplsHeader>();
155 if (oldMplsHeader->getS()) {
Referenced by doStackOps().
◆ processMplsPacketFromL2()
| void inet::Mpls::processMplsPacketFromL2 |
( |
Packet * |
mplsPacket | ) |
|
|
protectedvirtual |
214 int incomingInterfaceId = packet->getTag<InterfaceInd>()->getInterfaceId();
215 NetworkInterface *ie =
ift->getInterfaceById(incomingInterfaceId);
216 std::string incomingInterfaceName = ie->getInterfaceName();
217 const auto& mplsHeader = packet->peekAtFront<MplsHeader>();
219 EV_INFO <<
"Received " << packet <<
" from L2, label=" << mplsHeader->getLabel() <<
" inInterface=" << incomingInterfaceName << endl;
221 if (mplsHeader->getLabel() == (uint32_t)-1) {
224 EV_INFO <<
": decapsulating and sending up\n";
225 packet->popAtFront<MplsHeader>();
232 std::string outInterface;
235 bool found =
lt->resolveLabel(incomingInterfaceName, mplsHeader->getLabel(), outLabel, outInterface, color);
237 EV_INFO <<
"discarding packet, incoming label not resolved" << endl;
243 NetworkInterface *outgoingInterface =
CHK(
ift->findInterfaceByName(outInterface.c_str()));
249 EV_INFO <<
"forwarding packet to " << outInterface << endl;
251 if (packet->hasPar(
"color")) {
252 packet->par(
"color") = color;
255 packet->addPar(
"color") = color;
260 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(outgoingInterface->getInterfaceId());
267 EV_INFO <<
"decapsulating Ipv4 datagram" << endl;
270 if (outgoingInterface) {
273 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(outgoingInterface->getInterfaceId());
Referenced by processPacketFromL2().
◆ processPacketFromL2()
| void inet::Mpls::processPacketFromL2 |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
206 throw cRuntimeError(
"Unknown message received");
Referenced by handleMessage().
◆ processPacketFromL3()
| void inet::Mpls::processPacketFromL3 |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
71 const auto& ipHeader = msg->peekAtFront<Ipv4Header>();
75 const auto& seg = msg->peekDataAt<TcpHeader>(ipHeader->getChunkLength());
77 ASSERT(!msg->hasPar(
"color"));
83 if (!msg->hasPar(
"color"))
Referenced by handleMessage().
◆ pushLabel()
| void inet::Mpls::pushLabel |
( |
Packet * |
packet, |
|
|
Ptr< MplsHeader > & |
newMplsHeader |
|
) |
| |
|
protected |
138 packet->insertAtFront(newMplsHeader);
Referenced by doStackOps().
◆ sendToL2()
| void inet::Mpls::sendToL2 |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
◆ sendToL3()
| void inet::Mpls::sendToL3 |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
◆ swapLabel()
| void inet::Mpls::swapLabel |
( |
Packet * |
packet, |
|
|
Ptr< MplsHeader > & |
newMplsHeader |
|
) |
| |
|
protected |
146 auto oldMplsHeader = packet->removeAtFront<MplsHeader>();
147 newMplsHeader->setS(oldMplsHeader->getS());
148 packet->insertAtFront(newMplsHeader);
Referenced by doStackOps().
◆ tryLabelAndForwardIpv4Datagram()
| bool inet::Mpls::tryLabelAndForwardIpv4Datagram |
( |
Packet * |
ipdatagram | ) |
|
|
protectedvirtual |
93 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
96 std::string outInterface;
99 if (!
pct->lookupLabel(packet, outLabel, outInterface, color)) {
100 EV_WARN <<
"no mapping exists for this packet" << endl;
103 int outInterfaceId =
CHK(
ift->findInterfaceByName(outInterface.c_str()))->getInterfaceId();
105 ASSERT(outLabel.size() > 0);
109 EV_INFO <<
"forwarding packet to " << outInterface << endl;
111 packet->addPar(
"color") = color;
115 packet->addTagIfAbsent<
InterfaceReq>()->setInterfaceId(outInterfaceId);
Referenced by labelAndForwardIpv4Datagram(), and processPacketFromL2().
◆ delay1
| simtime_t inet::Mpls::delay1 |
|
protected |
◆ ift
◆ lt
◆ pct
The documentation for this class was generated from the following files:
#define CHK(x)
Definition: INETDefs.h:87
virtual void processPacketFromL3(Packet *msg)
Definition: Mpls.cc:60
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
static const Protocol ipv4
Definition: Protocol.h:93
@ IP_PROT_ICMP
Definition: IpProtocolId_m.h:91
ModuleRefByPar< IInterfaceTable > ift
Definition: Mpls.h:38
#define ICMP_TRAFFIC
Definition: Mpls.cc:23
void pushLabel(Packet *packet, Ptr< MplsHeader > &newMplsHeader)
Definition: Mpls.cc:134
removed InterfaceReq
Definition: IUdp-gates.txt:11
ModuleRefByPar< LibTable > lt
Definition: Mpls.h:37
virtual void doStackOps(Packet *packet, const LabelOpVector &outLabel)
Definition: Mpls.cc:160
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
INET_API InitStage INITSTAGE_NETWORK_LAYER
Initialization of network layer protocols.
void registerService(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a service primitive (SDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:14
virtual void labelAndForwardIpv4Datagram(Packet *ipdatagram)
Definition: Mpls.cc:121
@ SWAP_OPER
Definition: LibTable.h:22
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
milli< kg >::type g
Definition: Units.h:1071
#define LDP_TRAFFIC
Definition: Ldp.h:27
void swapLabel(Packet *packet, Ptr< MplsHeader > &newMplsHeader)
Definition: Mpls.cc:142
static const Protocol mpls
Definition: Protocol.h:101
std::vector< LabelOp > LabelOpVector
Definition: LibTable.h:32
virtual bool tryLabelAndForwardIpv4Datagram(Packet *ipdatagram)
Definition: Mpls.cc:91
virtual void processMplsPacketFromL2(Packet *mplsPacket)
Definition: Mpls.cc:212
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
@ IP_PROT_TCP
Definition: IpProtocolId_m.h:94
#define Enter_Method(...)
Definition: SelfDoc.h:71
@ POP_OPER
Definition: LibTable.h:23
int getId() const
Definition: Protocol.h:37
void registerInterface(const NetworkInterface &interface, cGate *in, cGate *out)
Definition: IInterfaceRegistrationListener.cc:12
ModuleRefByPar< IIngressClassifier > pct
Definition: Mpls.h:39
void popLabel(Packet *packet)
Definition: Mpls.cc:151
void registerProtocol(const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive)
Registers a protocol primitive (PDU processing) at the given gate.
Definition: IProtocolRegistrationListener.cc:83
@ PUSH_OPER
Definition: LibTable.h:21
virtual void sendToL2(Packet *msg)
Definition: Mpls.cc:282
virtual void sendToL3(Packet *msg)
Definition: Mpls.cc:289
virtual void processPacketFromL2(Packet *msg)
Definition: Mpls.cc:191
#define LDP_PORT
Definition: Ldp.h:25