|
INET Framework for OMNeT++/OMNEST
|
LDP (rfc 3036) protocol implementation.
More...
#include <Ldp.h>
|
| virtual Ipv4Address | locateNextHop (Ipv4Address dest) |
| | This method finds next peer in upstream direction. More...
|
| |
| virtual Ipv4Address | findPeerAddrFromInterface (std::string interfaceName) |
| | This method maps the peerIP with the interface name in routing table. More...
|
| |
| std::string | findInterfaceFromPeerAddr (Ipv4Address peerIP) |
| |
| virtual int | findPeer (Ipv4Address peerAddr) |
| | Utility: return peer's index in myPeers table, or -1 if not found. More...
|
| |
| virtual TcpSocket * | getPeerSocket (Ipv4Address peerAddr) |
| | Utility: return socket for given peer. More...
|
| |
| virtual TcpSocket * | findPeerSocket (Ipv4Address peerAddr) |
| | Utility: return socket for given peer, and nullptr if session doesn't exist. More...
|
| |
| virtual void | sendToPeer (Ipv4Address dest, Packet *msg) |
| |
| FecVector::iterator | findFecEntry (FecVector &fecs, Ipv4Address addr, int length) |
| |
| FecBindVector::iterator | findFecEntry (FecBindVector &fecs, int fecid, Ipv4Address peer) |
| |
| virtual void | sendMappingRequest (Ipv4Address dest, Ipv4Address addr, int length) |
| |
| virtual void | sendMapping (int type, Ipv4Address dest, int label, Ipv4Address addr, int length) |
| |
| virtual void | sendNotify (int status, Ipv4Address dest, Ipv4Address addr, int length) |
| |
| virtual void | rebuildFecList () |
| |
| virtual void | updateFecList (Ipv4Address nextHop) |
| |
| virtual void | updateFecListEntry (fec_t oldItem) |
| |
| virtual void | announceLinkChange (int tedlinkindex) |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | initialize (int stage) override |
| |
| virtual void | handleMessageWhenUp (cMessage *msg) override |
| |
| virtual void | sendHelloTo (Ipv4Address dest) |
| |
| virtual void | openTCPConnectionToPeer (int peerIndex) |
| |
| virtual void | processLDPHello (Packet *msg) |
| |
| virtual void | processHelloTimeout (cMessage *msg) |
| |
| virtual void | processLdpPacketFromTcp (Ptr< const LdpPacket > &ldpPacket) |
| |
| virtual void | processLABEL_MAPPING (Ptr< const LdpPacket > &ldpPacket) |
| |
| virtual void | processLABEL_REQUEST (Ptr< const LdpPacket > &ldpPacket) |
| |
| virtual void | processLABEL_RELEASE (Ptr< const LdpPacket > &ldpPacket) |
| |
| virtual void | processLABEL_WITHDRAW (Ptr< const LdpPacket > &ldpPacket) |
| |
| virtual void | processNOTIFICATION (Ptr< const LdpPacket > &ldpPacket, bool rescheduled) |
| |
|
| virtual void | socketDataArrived (TcpSocket *socket) override |
| |
| virtual void | socketAvailable (TcpSocket *socket, TcpAvailableInfo *availableInfo) override |
| |
| virtual void | socketEstablished (TcpSocket *socket) override |
| |
| virtual void | socketPeerClosed (TcpSocket *socket) override |
| |
| virtual void | socketClosed (TcpSocket *socket) override |
| |
| virtual void | socketFailure (TcpSocket *socket, int code) override |
| |
| virtual void | socketStatusArrived (TcpSocket *socket, TcpStatusInfo *status) override |
| |
| virtual void | socketDeleted (TcpSocket *socket) override |
| |
|
| virtual void | socketDataArrived (UdpSocket *socket, Packet *packet) override |
| | Notifies about data arrival, packet ownership is transferred to the callee. More...
|
| |
| virtual void | socketErrorArrived (UdpSocket *socket, Indication *indication) override |
| | Notifies about error indication arrival, indication ownership is transferred to the callee. More...
|
| |
| virtual void | socketClosed (UdpSocket *socket) override |
| | Notifies about socket closed, indication ownership is transferred to the callee. More...
|
| |
| virtual bool | lookupLabel (Packet *ipdatagram, LabelOpVector &outLabel, std::string &outInterface, int &color) override |
| | The packet argument is an input parameter, the rest (outLabel, outInterface, color) are output parameters only. More...
|
| |
| virtual void | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override |
| |
| virtual bool | isInitializeStage (int stage) const override |
| |
| virtual bool | isModuleStartStage (int stage) const override |
| |
| virtual bool | isModuleStopStage (int stage) const override |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | handleMessage (cMessage *msg) override |
| |
| virtual void | handleMessageWhenDown (cMessage *msg) |
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | Perform one stage of a lifecycle operation. More...
|
| |
| virtual State | getInitialOperationalState () const |
| | Returns initial operational state: OPERATING or NOT_OPERATING. More...
|
| |
| virtual void | handleActiveOperationTimeout (cMessage *message) |
| |
| virtual bool | isUp () const |
| | utility functions More...
|
| |
| virtual bool | isDown () const |
| |
| virtual void | setOperationalState (State newState) |
| |
| virtual void | scheduleOperationTimeout (simtime_t timeout) |
| |
| virtual void | setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State) |
| |
| virtual void | delayActiveOperationFinish (simtime_t timeout) |
| |
| virtual void | startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO) |
| |
| virtual void | startActiveOperationExtraTimeOrFinish (simtime_t extraTime) |
| |
| virtual void | finishActiveOperation () |
| |
LDP (rfc 3036) protocol implementation.
◆ FecBindVector
◆ FecVector
◆ PeerVector
◆ PendingVector
◆ Ldp()
◆ ~Ldp()
84 cancelAndDelete(elem.timeout);
◆ announceLinkChange()
| void inet::Ldp::announceLinkChange |
( |
int |
tedlinkindex | ) |
|
|
protectedvirtual |
◆ findFecEntry() [1/2]
858 auto it = fecs.begin();
859 for (; it != fecs.end(); it++) {
860 if ((it->fecid == fecid) && (it->peer == peer))
◆ findFecEntry() [2/2]
◆ findInterfaceFromPeerAddr()
| std::string inet::Ldp::findInterfaceFromPeerAddr |
( |
Ipv4Address |
peerIP | ) |
|
|
protected |
◆ findPeer()
◆ findPeerAddrFromInterface()
| Ipv4Address inet::Ldp::findPeerAddrFromInterface |
( |
std::string |
interfaceName | ) |
|
|
protectedvirtual |
This method maps the peerIP with the interface name in routing table.
It is expected that for MPLS host, entries linked to MPLS peers are available. In case no corresponding peerIP found, a peerIP (not deterministic) will be returned.
796 NetworkInterface *ie =
ift->findInterfaceByName(interfaceName.c_str());
798 return Ipv4Address();
800 const Ipv4Route *anEntry;
802 for (i = 0; i <
rt->getNumRoutes(); i++) {
804 anEntry =
rt->getRoute(i);
805 if (anEntry->getDestination() ==
myPeers[
k].peerIP && anEntry->getInterface() == ie) {
813 for (i = 0; i < (int)
myPeers.size(); i++) {
814 for (
k = 0;
k <
rt->getNumRoutes();
k++) {
815 anEntry =
rt->getRoute(i);
816 if (anEntry->getDestination() ==
myPeers[i].peerIP)
819 if (
k ==
rt->getNumRoutes())
824 return i == (int)
myPeers.size() ? Ipv4Address() :
myPeers[i].peerIP;
Referenced by locateNextHop().
◆ findPeerSocket()
◆ getPeerSocket()
Utility: return socket for given peer.
Throws error if there's no TCP connection
1216 throw cRuntimeError(
"No LDP session to peer %s yet", peerAddr.str().c_str());
Referenced by sendToPeer().
◆ handleCrashOperation()
◆ handleMessageWhenUp()
| void inet::Ldp::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Implements inet::OperationalMixin< cSimpleModule >.
149 EV_INFO <<
"Received: (" << msg->getClassName() <<
")" << msg->getName() <<
"\n";
151 ASSERT(msg->isSelfMessage());
154 EV_INFO <<
"Multicasting LDP Hello to neighboring routers\n";
160 else if (msg->isSelfMessage()) {
161 EV_INFO <<
"Timer " << msg->getName() <<
" expired\n";
162 if (!strcmp(msg->getName(),
"HelloTimeout")) {
166 auto ldpPacket = check_and_cast<Packet *>(msg)->popAtFront<LdpPacket>();
183 auto&
tags = check_and_cast<ITaggedObject *>(msg)->getTags();
184 int socketId =
tags.getTag<SocketInd>()->getSocketId();
186 if (
s.getSocketId() == socketId) {
187 s.processMessage(msg);
191 throw cRuntimeError(
"model error: no socket found for msg '%s' with socketId %d", msg->getName(), socketId);
203 if (
s.second->isOpen())
◆ handleStartOperation()
◆ handleStopOperation()
◆ initialize()
| void inet::Ldp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::OperationalMixin< cSimpleModule >.
103 ift.reference(
this,
"interfaceTableModule",
true);
104 rt.reference(
this,
"routingTableModule",
true);
105 lt.reference(
this,
"libTableModule",
true);
106 tedmod.reference(
this,
"tedModule",
true);
121 for (
int i = 0; i <
ift->getNumInterfaces(); ++i) {
122 NetworkInterface *ie =
ift->getInterface(i);
123 if (ie->isMulticast()) {
125 udpSockets.back().setOutputGate(gate(
"socketOut"));
127 udpSockets.back().setMulticastOutputInterface(ie->getInterfaceId());
132 EV_INFO <<
"Starting to listen on port " <<
LDP_PORT <<
" for incoming LDP sessions\n";
◆ locateNextHop()
This method finds next peer in upstream direction.
782 NetworkInterface *ie =
rt->getInterfaceForDestAddr(dest);
784 return Ipv4Address();
786 std::string iName = ie->getInterfaceName();
◆ lookupLabel()
| bool inet::Ldp::lookupLabel |
( |
Packet * |
packet, |
|
|
LabelOpVector & |
outLabel, |
|
|
std::string & |
outInterface, |
|
|
int & |
color |
|
) |
| |
|
overrideprotectedvirtual |
The packet argument is an input parameter, the rest (outLabel, outInterface, color) are output parameters only.
In subclasses, this function should be implemented to determine the forwarding equivalence class for the Ipv4 datagram passed, and map it to an outLabel and outInterface.
The color parameter (which can be set to an arbitrary value) will only be used for the NAM trace if one will be recorded.
Implements inet::IIngressClassifier.
1222 const auto& ipv4Header = packet->peekAtFront<Ipv4Header>();
1223 Ipv4Address destAddr = ipv4Header->getDestAddress();
1224 int protocol = ipv4Header->getProtocolId();
1234 const auto& udpHeader = packet->peekDataAt<UdpHeader>(ipv4Header->getChunkLength());
1235 if (udpHeader->getDestinationPort() ==
LDP_PORT)
1240 const auto& tcpHeader = packet->peekDataAt<tcp::TcpHeader>(ipv4Header->getChunkLength());
1241 if (tcpHeader->getDestPort() ==
LDP_PORT || tcpHeader->getSrcPort() ==
LDP_PORT)
1248 if (!destAddr.prefixMatches(elem.addr, elem.length))
1251 EV_DETAIL <<
"FEC matched: " << elem << endl;
1258 EV_DETAIL <<
"mapping found, outLabel=" << outLabel <<
", outInterface=" << outInterface << endl;
1262 EV_DETAIL <<
"no mapping for this FEC exists" << endl;
◆ numInitStages()
| virtual int inet::Ldp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ openTCPConnectionToPeer()
| void inet::Ldp::openTCPConnectionToPeer |
( |
int |
peerIndex | ) |
|
|
protectedvirtual |
617 TcpSocket *socket =
new TcpSocket();
618 socket->setOutputGate(gate(
"socketOut"));
619 socket->setCallback(
this);
620 socket->setUserData((
void *)((intptr_t)peerIndex));
621 socket->bind(
rt->getRouterId(), 0);
623 myPeers[peerIndex].socket = socket;
Referenced by processLDPHello().
◆ processHelloTimeout()
| void inet::Ldp::processHelloTimeout |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
494 for (i = 0; i <
myPeers.size(); i++)
500 Ipv4Address peerIP =
myPeers[i].peerIP;
502 EV_INFO <<
"peer=" << peerIP <<
" is gone, removing adjacency" << endl;
504 ASSERT(!
myPeers[i].timeout->isScheduled());
511 EV_INFO <<
"removing (stale) bindings from fecDown for peer=" << peerIP << endl;
514 if (dit->peer != peerIP) {
519 EV_DETAIL <<
"label=" << dit->label << endl;
529 EV_INFO <<
"removing bindings from sent to peer=" << peerIP <<
" from fecUp" << endl;
531 for (
auto uit =
fecUp.begin(); uit !=
fecUp.end();) {
532 if (uit->peer != peerIP) {
537 EV_DETAIL <<
"label=" << uit->label << endl;
542 uit =
fecUp.erase(uit);
545 EV_INFO <<
"updating fecList" << endl;
551 unsigned int index =
tedmod->linkIndex(
rt->getRouterId(), peerIP);
552 tedmod->ted[index].state =
false;
554 tedmod->rebuildRoutingTable();
Referenced by handleMessageWhenUp().
◆ processLABEL_MAPPING()
| void inet::Ldp::processLABEL_MAPPING |
( |
Ptr< const LdpPacket > & |
ldpPacket | ) |
|
|
protectedvirtual |
1138 const auto& packet =
CHK(dynamicPtrCast<const LdpLabelMapping>(ldpPacket));
1139 FecTlv fec = packet->getFec();
1140 int label = packet->getLabel();
1141 Ipv4Address fromIP = packet->getSenderAddress();
1143 EV_INFO <<
"Label mapping label=" << label <<
" received for fec=" << fec <<
" from " << fromIP << endl;
1149 throw cRuntimeError(
"Model error: fec not in fecList");
1153 throw cRuntimeError(
"Model error: found in fecDown");
1158 newItem.fecid = it->fecid;
1159 newItem.peer = fromIP;
1160 newItem.label = label;
1166 if (pit->fecid != it->fecid) {
1171 EV_DETAIL <<
"there's pending request for this FEC from " << pit->peer <<
", sending mapping" << endl;
1178 newItem.fecid = it->fecid;
1179 newItem.peer = pit->peer;
1180 newItem.label =
lt->installLibEntry(-1, inInterface, outLabel, outInterface,
LDP_USER_TRAFFIC);
1181 fecUp.push_back(newItem);
1183 EV_DETAIL <<
"installed LIB entry inLabel=" << newItem.label <<
" inInterface=" << inInterface
1184 <<
" outLabel=" << outLabel <<
" outInterface=" << outInterface << endl;
Referenced by processLdpPacketFromTcp().
◆ processLABEL_RELEASE()
| void inet::Ldp::processLABEL_RELEASE |
( |
Ptr< const LdpPacket > & |
ldpPacket | ) |
|
|
protectedvirtual |
1060 const auto& packet =
CHK(dynamicPtrCast<const LdpLabelMapping>(ldpPacket));
1061 FecTlv fec = packet->getFec();
1062 int label = packet->getLabel();
1063 Ipv4Address fromIP = packet->getSenderAddress();
1065 EV_INFO <<
"Mapping release received for label=" << label <<
" fec=" << fec <<
" from " << fromIP << endl;
1073 EV_INFO <<
"FEC no longer recognized here, ignoring" << endl;
1078 if (uit ==
fecUp.end() || label != uit->label) {
1082 EV_INFO <<
"mapping not found among sent mappings, ignoring" << endl;
1086 EV_DETAIL <<
"removing from LIB table label=" << uit->label << endl;
1087 lt->removeLibEntry(uit->label);
1089 EV_DETAIL <<
"removing label from list of sent mappings" << endl;
Referenced by processLdpPacketFromTcp().
◆ processLABEL_REQUEST()
| void inet::Ldp::processLABEL_REQUEST |
( |
Ptr< const LdpPacket > & |
ldpPacket | ) |
|
|
protectedvirtual |
973 const auto& packet =
CHK(dynamicPtrCast<const LdpLabelRequest>(ldpPacket));
974 FecTlv fec = packet->getFec();
975 Ipv4Address srcAddr = packet->getSenderAddress();
977 EV_INFO <<
"Label Request from LSR " << srcAddr <<
" for FEC " << fec << endl;
981 EV_DETAIL <<
"FEC not recognized, sending back No route message" << endl;
997 ASSERT(uit ==
fecUp.end());
1005 ASSERT(!(ER && dit !=
fecDown.end()));
1007 if (ER || dit !=
fecDown.end()) {
1009 newItem.fecid = it->fecid;
1011 newItem.peer = srcAddr;
1012 fecUp.push_back(newItem);
1013 uit =
fecUp.end() - 1;
1023 uit->label =
lt->installLibEntry(uit->label, inInterface, outLabel, outInterface, 0);
1025 EV_DETAIL <<
"installed (egress) LIB entry inLabel=" << uit->label <<
" inInterface=" << inInterface
1026 <<
" outLabel=" << outLabel <<
" outInterface=" << outInterface << endl;
1033 else if (dit !=
fecDown.end()) {
1036 uit->label =
lt->installLibEntry(uit->label, inInterface, outLabel, outInterface,
LDP_USER_TRAFFIC);
1038 EV_DETAIL <<
"installed LIB entry inLabel=" << uit->label <<
" inInterface=" << inInterface
1039 <<
" outLabel=" << outLabel <<
" outInterface=" << outInterface << endl;
1049 EV_DETAIL <<
"no mapping for this FEC from the downstream router, marking as pending" << endl;
1051 pending_req_t newItem;
1052 newItem.fecid = it->fecid;
1053 newItem.peer = srcAddr;
Referenced by processLdpPacketFromTcp().
◆ processLABEL_WITHDRAW()
| void inet::Ldp::processLABEL_WITHDRAW |
( |
Ptr< const LdpPacket > & |
ldpPacket | ) |
|
|
protectedvirtual |
1095 const auto& ldpLabelMapping =
CHK(dynamicPtrCast<const LdpLabelMapping>(ldpPacket));
1096 FecTlv fec = ldpLabelMapping->getFec();
1097 int label = ldpLabelMapping->getLabel();
1098 Ipv4Address fromIP = ldpLabelMapping->getSenderAddress();
1100 EV_INFO <<
"Mapping withdraw received for label=" << label <<
" fec=" << fec <<
" from " << fromIP << endl;
1108 EV_INFO <<
"matching FEC not found, ignoring withdraw message" << endl;
1114 if (dit ==
fecDown.end() || label != dit->label) {
1115 EV_INFO <<
"matching mapping not found, ignoring withdraw message" << endl;
1120 ASSERT(label == dit->label);
1122 EV_INFO <<
"removing label from list of received mappings" << endl;
1125 EV_INFO <<
"sending back relase message" << endl;
1126 auto reply = makeShared<LdpLabelMapping>(*ldpLabelMapping.get());
1128 auto pk =
new Packet(
"LDP_RELEASE", reply);
Referenced by processLdpPacketFromTcp().
◆ processLDPHello()
| void inet::Ldp::processLDPHello |
( |
Packet * |
msg | ) |
|
|
protectedvirtual |
559 int socketId = msg->getTag<SocketInd>()->getSocketId();
562 const auto& ldpHello = msg->peekAtFront<LdpHello>();
564 Ipv4Address peerAddr = ldpHello->getSenderAddress();
565 int interfaceId = msg->getTag<InterfaceInd>()->getInterfaceId();
568 EV_INFO <<
"Received LDP Hello from " << peerAddr <<
", ";
570 if (peerAddr.isUnspecified() || peerAddr ==
rt->getRouterId()) {
572 EV_INFO <<
"that's myself, ignore\n";
577 unsigned int index =
tedmod->linkIndex(
rt->getRouterId(), peerAddr);
578 if (!
tedmod->ted[index].state) {
579 tedmod->ted[index].state =
true;
580 tedmod->rebuildRoutingTable();
587 EV_DETAIL <<
"already in my peer table, rescheduling timeout" << endl;
595 info.peerIP = peerAddr;
596 info.linkInterface =
ift->getInterfaceById(interfaceId)->getInterfaceName();
597 info.activeRole = peerAddr.getInt() >
rt->getRouterId().getInt();
598 info.socket =
nullptr;
599 info.timeout =
new cMessage(
"HelloTimeout");
600 scheduleAfter(
holdTime, info.timeout);
602 int peerIndex =
myPeers.size() - 1;
604 EV_INFO <<
"added to peer table\n";
605 EV_INFO <<
"We'll be " << (info.activeRole ?
"ACTIVE" :
"PASSIVE") <<
" in this session\n";
609 if (info.activeRole) {
610 EV_INFO <<
"Establishing session with it\n";
Referenced by socketDataArrived().
◆ processLdpPacketFromTcp()
| void inet::Ldp::processLdpPacketFromTcp |
( |
Ptr< const LdpPacket > & |
ldpPacket | ) |
|
|
protectedvirtual |
717 switch (ldpPacket->getType()) {
719 throw cRuntimeError(
"Received LDP HELLO over TCP (should arrive over UDP)");
724 throw cRuntimeError(
"Received LDP ADDRESS message, unsupported in this version");
729 throw cRuntimeError(
"LDP PROC DEBUG: Received LDP ADDRESS_WITHDRAW message, unsupported in this version");
753 throw cRuntimeError(
"LDP PROC DEBUG: Unrecognized LDP Message Type, type is %d", ldpPacket->getType());
Referenced by socketDataArrived().
◆ processNOTIFICATION()
| void inet::Ldp::processNOTIFICATION |
( |
Ptr< const LdpPacket > & |
ldpPacket, |
|
|
bool |
rescheduled |
|
) |
| |
|
protectedvirtual |
920 const auto& packet =
CHK(dynamicPtrCast<const LdpNotify>(ldpPacket));
921 FecTlv fec = packet->getFec();
922 Ipv4Address srcAddr = packet->getSenderAddress();
923 int status = packet->getStatus();
930 EV_INFO <<
"notification retry for peer=" << srcAddr <<
" fec=" << fec <<
" status=" << status << endl;
934 EV_INFO <<
"notification received from=" << srcAddr <<
" fec=" << fec <<
" status=" << status << endl;
939 EV_INFO <<
"route does not exit on that peer" << endl;
943 if (it->nextHop == srcAddr) {
945 EV_DETAIL <<
"we are still interesed in this mapping, we will retry later" << endl;
946 auto pk =
new Packet(0, ldpPacket);
947 scheduleAfter(1.0 , pk);
951 EV_DETAIL <<
"reissuing request" << endl;
957 EV_DETAIL <<
"and we still recognize this FEC, but we use different next hop, forget it" << endl;
960 EV_DETAIL <<
"and we do not recognize this any longer, forget it" << endl;
Referenced by handleMessageWhenUp(), and processLdpPacketFromTcp().
◆ rebuildFecList()
| void inet::Ldp::rebuildFecList |
( |
| ) |
|
|
protectedvirtual |
343 EV_INFO <<
"make list of recognized FECs" << endl;
348 for (
int i = 0; i <
rt->getNumRoutes(); i++) {
351 const Ipv4Route *re =
rt->getRoute(i);
354 if (re->getDestination().isMulticast())
358 Ipv4Address nextHop = (re->getGateway().isUnspecified()) ? re->getDestination() : re->getGateway();
359 ASSERT(!nextHop.isUnspecified());
361 EV_INFO <<
"nextHop <-- " << nextHop << endl;
363 auto it =
findFecEntry(oldList, re->getDestination(), re->getNetmask().getNetmaskLength());
365 if (it == oldList.end()) {
369 newItem.addr = re->getDestination();
370 newItem.length = re->getNetmask().getNetmaskLength();
371 newItem.nextHop = nextHop;
375 else if (it->nextHop != nextHop) {
377 it->nextHop = nextHop;
392 for (
int i = 0; i <
ift->getNumInterfaces(); ++i) {
393 NetworkInterface *ie =
ift->getInterface(i);
399 auto ipv4Data = ie->findProtocolData<Ipv4InterfaceData>();
403 auto it =
findFecEntry(oldList, ipv4Data->getIPAddress(), 32);
404 if (it == oldList.end()) {
407 newItem.addr = ipv4Data->getIPAddress();
409 newItem.nextHop = ipv4Data->getIPAddress();
418 if (oldList.size() > 0) {
419 EV_INFO <<
"there are " << oldList.size() <<
" deprecated FECs, removing them" << endl;
421 for (
auto& elem : oldList) {
422 EV_DETAIL <<
"removing FEC= " << elem << endl;
425 if (_dit.fecid != elem.fecid)
428 EV_DETAIL <<
"sending release label=" << _dit.label <<
" downstream to " << _dit.peer << endl;
433 for (
auto& _uit :
fecUp) {
434 if (_uit.fecid != elem.fecid)
437 EV_DETAIL <<
"sending withdraw label=" << _uit.label <<
" upstream to " << _uit.peer << endl;
441 EV_DETAIL <<
"removing entry inLabel=" << _uit.label <<
" from LIB" << endl;
443 lt->removeLibEntry(_uit.label);
Referenced by initialize(), and receiveSignal().
◆ receiveSignal()
| void inet::Ldp::receiveSignal |
( |
cComponent * |
source, |
|
|
simsignal_t |
signalID, |
|
|
cObject * |
obj, |
|
|
cObject * |
details |
|
) |
| |
|
overrideprotectedvirtual |
1271 Enter_Method(
"%s", cComponent::getSignalName(signalID));
1277 EV_INFO <<
"routing table changed, rebuild list of known FEC" << endl;
◆ sendHelloTo()
465 Packet *pk =
new Packet(
"LDP-Hello");
466 const auto& hello = makeShared<LdpHello>();
468 hello->setType(
HELLO);
469 hello->setSenderAddress(
rt->getRouterId());
471 hello->setHoldTime(SIMTIME_DBL(
holdTime));
474 pk->insertAtBack(hello);
477 if (dest.isMulticast()) {
478 for (
size_t i = 0; i <
udpSockets.size(); ++i) {
479 Packet *msg = (i ==
udpSockets.size() - 1) ? pk : pk->dup();
Referenced by handleMessageWhenUp(), and processLDPHello().
◆ sendMapping()
900 Packet *packet =
new Packet(
"Lb-Mapping");
901 const auto& lmMessage = makeShared<LdpLabelMapping>();
903 lmMessage->setType(
type);
904 lmMessage->setReceiverAddress(dest);
905 lmMessage->setSenderAddress(
rt->getRouterId());
906 lmMessage->setLabel(label);
912 lmMessage->setFec(fec);
913 packet->insertAtBack(lmMessage);
Referenced by processLABEL_MAPPING(), processLABEL_REQUEST(), rebuildFecList(), and updateFecListEntry().
◆ sendMappingRequest()
270 Packet *pk =
new Packet(
"Lb-Req");
271 const auto& requestMsg = makeShared<LdpLabelRequest>();
278 requestMsg->setFec(fec);
280 requestMsg->setReceiverAddress(dest);
281 requestMsg->setSenderAddress(
rt->getRouterId());
282 pk->insertAtBack(requestMsg);
Referenced by processNOTIFICATION(), and updateFecListEntry().
◆ sendNotify()
879 Packet *packet =
new Packet(
"Lb-Notify");
880 const auto& lnMessage = makeShared<LdpNotify>();
884 lnMessage->setReceiverAddress(dest);
885 lnMessage->setSenderAddress(
rt->getRouterId());
891 lnMessage->setFec(fec);
892 packet->insertAtBack(lnMessage);
Referenced by processLABEL_REQUEST().
◆ sendToPeer()
◆ socketAvailable()
Implements inet::TcpSocket::ICallback.
644 TcpSocket *newSocket =
new TcpSocket(availableInfo);
645 newSocket->setOutputGate(gate(
"socketOut"));
650 Ipv4Address peerAddr = newSocket->getRemoteAddress().toIpv4();
653 if (i == -1 ||
myPeers[i].socket) {
660 newSocket->setCallback(
this);
661 newSocket->setUserData((
void *)((intptr_t)i));
663 socketocket->accept(availableInfo->getNewSocketId());
◆ socketClosed() [1/2]
| void inet::Ldp::socketClosed |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
Implements inet::TcpSocket::ICallback.
697 peer_info& peer =
myPeers[(uintptr_t)socket->getUserData()];
698 EV_INFO <<
"TCP connection to peer " << peer.peerIP <<
" closed\n";
◆ socketClosed() [2/2]
| void inet::Ldp::socketClosed |
( |
UdpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived() [1/2]
| void inet::Ldp::socketDataArrived |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
Implements inet::TcpSocket::ReceiveQueueBasedCallback.
668 peer_info& peer =
myPeers[(uintptr_t)socket->getUserData()];
669 EV_INFO <<
"Message arrived over TCP from peer " << peer.peerIP <<
"\n";
671 auto queue = socket->getReceiveQueue();
672 while (queue->has<LdpPacket>()) {
673 auto header = queue->pop<LdpPacket>();
◆ socketDataArrived() [2/2]
◆ socketDeleted()
| virtual void inet::Ldp::socketDeleted |
( |
TcpSocket * |
socket | ) |
|
|
inlineoverrideprotectedvirtual |
◆ socketErrorArrived()
Notifies about error indication arrival, indication ownership is transferred to the callee.
Implements inet::UdpSocket::ICallback.
220 EV_WARN <<
"Ignoring UDP error report " << indication->getName() << endl;
◆ socketEstablished()
| void inet::Ldp::socketEstablished |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
Implements inet::TcpSocket::ICallback.
630 peer_info& peer =
myPeers[(uintptr_t)socket->getUserData()];
631 EV_INFO <<
"TCP connection established with peer " << peer.peerIP <<
"\n";
◆ socketFailure()
| void inet::Ldp::socketFailure |
( |
TcpSocket * |
socket, |
|
|
int |
code |
|
) |
| |
|
overrideprotectedvirtual |
Implements inet::TcpSocket::ICallback.
707 peer_info& peer =
myPeers[(uintptr_t)socket->getUserData()];
708 EV_INFO <<
"TCP connection to peer " << peer.peerIP <<
" broken\n";
◆ socketPeerClosed()
| void inet::Ldp::socketPeerClosed |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
Implements inet::TcpSocket::ICallback.
680 peer_info& peer =
myPeers[(uintptr_t)socket->getUserData()];
681 EV_INFO <<
"Peer " << peer.peerIP <<
" closed TCP connection\n";
◆ socketStatusArrived()
|
|
inlineoverrideprotectedvirtual |
◆ updateFecList()
◆ updateFecListEntry()
| void inet::Ldp::updateFecListEntry |
( |
Ldp::fec_t |
oldItem | ) |
|
|
protectedvirtual |
295 ASSERT(!(ER && dit !=
fecDown.end()));
298 for (
auto uit =
fecUp.begin(); uit !=
fecUp.end();) {
299 if (uit->fecid != oldItem.fecid) {
309 uit->label =
lt->installLibEntry(uit->label, inInterface, outLabel, outInterface,
LDP_USER_TRAFFIC);
311 EV_DETAIL <<
"installed (egress) LIB entry inLabel=" << uit->label <<
" inInterface=" << inInterface
312 <<
" outLabel=" << outLabel <<
" outInterface=" << outInterface << endl;
315 else if (dit !=
fecDown.end()) {
318 uit->label =
lt->installLibEntry(uit->label, inInterface, outLabel, outInterface,
LDP_USER_TRAFFIC);
320 EV_DETAIL <<
"installed LIB entry inLabel=" << uit->label <<
" inInterface=" << inInterface
321 <<
" outLabel=" << outLabel <<
" outInterface=" << outInterface << endl;
326 EV_INFO <<
"sending withdraw message upstream" << endl;
330 uit =
fecUp.erase(uit);
334 if (!ER && dit ==
fecDown.end()) {
336 EV_INFO <<
"sending request message downstream" << endl;
Referenced by processLABEL_WITHDRAW(), rebuildFecList(), and updateFecList().
◆ fecDown
◆ fecList
◆ fecUp
◆ helloInterval
| simtime_t inet::Ldp::helloInterval |
|
protected |
◆ holdTime
| simtime_t inet::Ldp::holdTime |
|
protected |
◆ ift
◆ lt
◆ maxFecid
| int inet::Ldp::maxFecid = 0 |
|
protected |
◆ myPeers
Referenced by findPeer(), findPeerAddrFromInterface(), findPeerSocket(), handleCrashOperation(), handleStopOperation(), initialize(), openTCPConnectionToPeer(), processHelloTimeout(), processLDPHello(), socketAvailable(), socketClosed(), socketDataArrived(), socketEstablished(), socketFailure(), socketPeerClosed(), and ~Ldp().
◆ pending
◆ rt
Referenced by findInterfaceFromPeerAddr(), findPeerAddrFromInterface(), initialize(), locateNextHop(), openTCPConnectionToPeer(), processHelloTimeout(), processLDPHello(), rebuildFecList(), sendHelloTo(), sendMapping(), sendMappingRequest(), and sendNotify().
◆ sendHelloMsg
| cMessage* inet::Ldp::sendHelloMsg = nullptr |
|
protected |
◆ serverSocket
◆ socketMap
◆ tedmod
◆ udpSocket
◆ udpSockets
The documentation for this class was generated from the following files:
void setOutputGate(cGate *toUdp)
Sets the gate on which to send to UDP.
Definition: UdpSocket.h:117
#define CHK(x)
Definition: INETDefs.h:87
virtual void send(Packet *msg) override
Sends data packet.
Definition: TcpSocket.cc:147
@ NO_ROUTE
Definition: LdpPacket_m.h:102
@ LABEL_WITHDRAW
Definition: LdpPacket_m.h:84
virtual void processMessage(cMessage *msg)=0
Examines the message, takes ownership, and updates socket state.
State operationalState
Definition: OperationalMixin.h:23
ModuleRefByPar< LibTable > lt
Definition: Ldp.h:110
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
void sendTo(Packet *msg, L3Address destAddr, int destPort)
Sends a data packet to the given address and port.
Definition: UdpSocket.cc:69
virtual void processLDPHello(Packet *msg)
Definition: Ldp.cc:557
virtual void sendHelloTo(Ipv4Address dest)
Definition: Ldp.cc:463
const B LDP_HEADER_BYTES
Definition: Ldp.h:36
PendingVector pending
Definition: Ldp.h:100
@ IP_PROT_OSPF
Definition: IpProtocolId_m.h:104
virtual TcpSocket * getPeerSocket(Ipv4Address peerAddr)
Utility: return socket for given peer.
Definition: Ldp.cc:1211
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
virtual bool isOpen() const override
Definition: TcpSocket.cc:257
@ NOTIFICATION
Definition: LdpPacket_m.h:76
virtual void destroy() override
Notify the protocol that the owner of ISocket has destroyed the socket.
Definition: UdpSocket.cc:98
void printSignalBanner(simsignal_t signalID, const cObject *obj, const cObject *details)
Utility function.
Definition: Simsignals.cc:126
virtual void sendToPeer(Ipv4Address dest, Packet *msg)
Definition: Ldp.cc:263
TcpSocket serverSocket
Definition: Ldp.h:115
virtual void processHelloTimeout(cMessage *msg)
Definition: Ldp.cc:489
SocketMap socketMap
Definition: Ldp.h:116
void deleteSockets()
Deletes the socket objects.
Definition: SocketMap.cc:44
virtual void processLABEL_REQUEST(Ptr< const LdpPacket > &ldpPacket)
Definition: Ldp.cc:971
ModuleRefByPar< IInterfaceTable > ift
Definition: Ldp.h:108
virtual bool belongsToSocket(cMessage *msg) const override
Returns true if the message belongs to this socket instance (message has a TcpCommand as getControlIn...
Definition: TcpSocket.cc:365
ModuleRefByPar< IIpv4RoutingTable > rt
Definition: Ldp.h:109
virtual void processLABEL_RELEASE(Ptr< const LdpPacket > &ldpPacket)
Definition: Ldp.cc:1058
ISocket * findSocketFor(cMessage *msg)
Finds the socket for the given message.
Definition: SocketMap.cc:19
std::vector< fec_t > FecVector
Definition: Ldp.h:63
virtual void updateFecListEntry(fec_t oldItem)
Definition: Ldp.cc:287
@ LABEL_RELEASE
Definition: LdpPacket_m.h:85
@ IP_PROT_UDP
Definition: IpProtocolId_m.h:97
FecVector::iterator findFecEntry(FecVector &fecs, Ipv4Address addr, int length)
Definition: Ldp.cc:866
void addSocket(ISocket *socket)
Adds the given socket.
Definition: SocketMap.cc:28
value< double, units::s > s
Definition: Units.h:1235
@ ADDRESS_WITHDRAW
Definition: LdpPacket_m.h:81
simsignal_t tedChangedSignal
Definition: Simsignals.cc:38
static const Ipv4Address ALL_ROUTERS_MCAST
224.0.0.2 All routers on a subnet
Definition: Ipv4Address.h:97
virtual void sendNotify(int status, Ipv4Address dest, Ipv4Address addr, int length)
Definition: Ldp.cc:876
virtual void processMessage(cMessage *msg) override
Examines the message, takes ownership, and updates socket state.
Definition: UdpSocket.cc:343
#define LDP_USER_TRAFFIC
Definition: Ldp.h:29
FecBindVector fecDown
Definition: Ldp.h:98
std::map< int, ISocket * > & getMap()
Returns the socket map.
Definition: SocketMap.h:57
std::vector< LabelOp > LabelOpVector
Definition: LibTable.h:32
static LabelOpVector pushLabel(int label)
Definition: LibTable.cc:157
virtual void processLABEL_MAPPING(Ptr< const LdpPacket > &ldpPacket)
Definition: Ldp.cc:1136
static LabelOpVector swapLabel(int label)
Definition: LibTable.cc:167
removed type
Definition: IUdp-gates.txt:7
void listen(bool fork)
Definition: TcpSocket.cc:95
FecVector fecList
Definition: Ldp.h:94
void processMessage(cMessage *msg) override
Examines the message (which should have arrived from TCP), updates socket state, and if there is a ca...
Definition: TcpSocket.cc:281
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
virtual void rebuildFecList()
Definition: Ldp.cc:341
virtual void announceLinkChange(int tedlinkindex)
Definition: Ldp.cc:1282
virtual void close() override
Unbinds the socket.
Definition: UdpSocket.cc:87
simsignal_t routeAddedSignal
Definition: Simsignals.cc:41
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
virtual bool belongsToSocket(cMessage *msg) const override
Returns true if the message belongs to this socket instance (message has a UdpControlInfo as getContr...
Definition: UdpSocket.cc:373
virtual void destroy() override
Destroy the connection.
Definition: TcpSocket.cc:186
virtual void processLABEL_WITHDRAW(Ptr< const LdpPacket > &ldpPacket)
Definition: Ldp.cc:1093
const double k
Definition: Qam1024Modulation.cc:14
PeerVector myPeers
Definition: Ldp.h:103
virtual bool isOpen() const override
Definition: UdpSocket.h:293
@ CONNECTED
Definition: TcpSocket.h:153
#define LDP_HELLO_TRAFFIC
Definition: Ldp.h:28
@ IP_PROT_TCP
Definition: IpProtocolId_m.h:94
@ HELLO
Definition: LdpPacket_m.h:77
virtual void delayActiveOperationFinish(simtime_t timeout)
Definition: OperationalMixinImpl.h:161
virtual TcpSocket * findPeerSocket(Ipv4Address peerAddr)
Utility: return socket for given peer, and nullptr if session doesn't exist.
Definition: Ldp.cc:1202
virtual Ipv4Address findPeerAddrFromInterface(std::string interfaceName)
This method maps the peerIP with the interface name in routing table.
Definition: Ldp.cc:792
virtual void startActiveOperationExtraTimeOrFinish(simtime_t extraTime)
Definition: OperationalMixinImpl.h:179
#define Enter_Method(...)
Definition: SelfDoc.h:71
simsignal_t routeDeletedSignal
Definition: Simsignals.cc:42
* tags
Definition: IUdp-gates.txt:3
virtual void processNOTIFICATION(Ptr< const LdpPacket > &ldpPacket, bool rescheduled)
Definition: Ldp.cc:918
std::vector< UdpSocket > udpSockets
Definition: Ldp.h:114
ModuleRefByPar< Ted > tedmod
Definition: Ldp.h:111
simtime_t holdTime
Definition: Ldp.h:90
virtual void updateFecList(Ipv4Address nextHop)
Definition: Ldp.cc:453
std::string findInterfaceFromPeerAddr(Ipv4Address peerIP)
Definition: Ldp.cc:828
UdpSocket udpSocket
Definition: Ldp.h:113
int maxFecid
Definition: Ldp.h:121
void bind(int localPort)
Bind the socket to a local port number.
Definition: TcpSocket.cc:69
FecBindVector fecUp
Definition: Ldp.h:96
void setOutputGate(cGate *toTcp)
Sets the gate on which to send to TCP.
Definition: TcpSocket.h:242
virtual void sendMapping(int type, Ipv4Address dest, int label, Ipv4Address addr, int length)
Definition: Ldp.cc:897
void close() override
Closes the local end of the connection.
Definition: TcpSocket.cc:161
int getSocketId() const override
Returns the internal socket Id.
Definition: UdpSocket.h:108
virtual int findPeer(Ipv4Address peerAddr)
Utility: return peer's index in myPeers table, or -1 if not found.
Definition: Ldp.cc:1193
cMessage * sendHelloMsg
Definition: Ldp.h:119
static LabelOpVector popLabel()
Definition: LibTable.cc:177
virtual void processLdpPacketFromTcp(Ptr< const LdpPacket > &ldpPacket)
Definition: Ldp.cc:715
INET_API InitStage INITSTAGE_ROUTING_PROTOCOLS
Initialization of routing protocols.
virtual void sendMappingRequest(Ipv4Address dest, Ipv4Address addr, int length)
Definition: Ldp.cc:268
@ ADDRESS
Definition: LdpPacket_m.h:80
virtual void openTCPConnectionToPeer(int peerIndex)
Definition: Ldp.cc:615
@ LABEL_REQUEST
Definition: LdpPacket_m.h:83
@ LABEL_MAPPING
Definition: LdpPacket_m.h:82
simtime_t helloInterval
Definition: Ldp.h:91
bool fecPrefixCompare(const Ldp::fec_t &a, const Ldp::fec_t &b)
Definition: Ldp.cc:36
#define LDP_PORT
Definition: Ldp.h:25