|
INET Framework for OMNeT++/OMNEST
|
#include <BgpRouter.h>
|
| class | BgpSession |
| |
| virtual void | socketDataArrived (TcpSocket *socket) override |
| |
| virtual void | socketDataArrived (TcpSocket *socket, Packet *packet, bool urgent) override |
| | Notifies about data arrival, packet ownership is transferred to the callee. More...
|
| |
| 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 |
| |
| void | getScheduleAt (simtime_t t, cMessage *msg) |
| |
| void | getCancelAndDelete (cMessage *msg) |
| |
| cMessage * | getCancelEvent (cMessage *msg) |
| |
| IIpv4RoutingTable * | getIPRoutingTable () |
| |
| std::vector< BgpRoutingTableEntry * > | getBGPRoutingTable () |
| |
| void | listenConnectionFromPeer (SessionId sessionID) |
| | active listenSocket for a given session (used by fsm) More...
|
| |
| void | openTCPConnectionToPeer (SessionId sessionID) |
| | active TcpConnection for a given session (used by fsm) More...
|
| |
| void | updateSendProcess (const unsigned char decisionProcessResult, SessionId sessionIndex, BgpRoutingTableEntry *entry) |
| | RFC 4271, 9.2 : Update-Send Process / Sent or not new UPDATE messages to its peers. More...
|
| |
| SessionId | findNextSession (BgpSessionType type, bool startSession=false) |
| | find the next SessionId compared to his type and start this session if boolean is true More...
|
| |
| void | processChunks (const BgpHeader &ptrHdr) |
| |
| void | processMessage (const BgpOpenMessage &msg) |
| |
| void | processMessage (const BgpKeepAliveMessage &msg) |
| |
| void | processMessage (const BgpUpdateMessage &msg) |
| |
| bool | deleteBGPRoutingEntry (BgpRoutingTableEntry *entry) |
| |
| unsigned char | decisionProcess (const BgpUpdateMessage &msg, BgpRoutingTableEntry *entry, SessionId sessionIndex) |
| | RFC 4271: 9.1. More...
|
| |
| bool | tieBreakingProcess (BgpRoutingTableEntry *oldEntry, BgpRoutingTableEntry *entry) |
| | RFC 4271: 9.1.2.2 Breaking Ties used when BGP speaker may have several routes to the same destination that have the same degree of preference. More...
|
| |
| bool | isInASList (std::vector< AsId > ASList, BgpRoutingTableEntry *entry) |
| |
| unsigned long | isInTable (std::vector< BgpRoutingTableEntry * > rtTable, BgpRoutingTableEntry *entry) |
| |
| bool | ospfExist (IIpv4RoutingTable *rtTable) |
| |
| int | checkExternalRoute (const Ipv4Route *ospfRoute) |
| |
| unsigned char | asLoopDetection (BgpRoutingTableEntry *entry, AsId myAS) |
| |
| int | isInRoutingTable (IIpv4RoutingTable *rtTable, Ipv4Address addr) |
| |
| SessionId | findIdFromPeerAddr (std::map< SessionId, BgpSession * > sessions, Ipv4Address peerAddr) |
| |
| SessionId | findIdFromSocketConnId (std::map< SessionId, BgpSession * > sessions, int connId) |
| |
| bool | isRouteExcluded (const Ipv4Route &rtEntry) |
| |
| bool | isDefaultRoute (const Ipv4Route *entry) const |
| |
| bool | isReachable (const Ipv4Address addr) const |
| |
◆ RoutingTableEntryVector
◆ BgpRouter()
◆ ~BgpRouter()
| inet::bgp::BgpRouter::~BgpRouter |
( |
| ) |
|
|
virtual |
◆ addToAdvertiseList()
| void inet::bgp::BgpRouter::addToAdvertiseList |
( |
Ipv4Address |
address | ) |
|
170 bool routeFound =
false;
171 const Ipv4Route *rtEntry =
nullptr;
174 if (rtEntry->getDestination() == address) {
180 throw cRuntimeError(
"Network address '%s' is not found in the routing table of %s", address.str(
false).c_str(),
bgpModule->getOwner()->getFullName());
183 [&] (
const Ipv4Address
m) ->
bool { return m == address; });
185 throw cRuntimeError(
"Network address '%s' is already added to the advertised list of %s", address.str(
false).c_str(),
bgpModule->getOwner()->getFullName());
188 BgpRoutingTableEntry *BGPEntry =
new BgpRoutingTableEntry(rtEntry);
190 BGPEntry->setPathType(
IGP);
191 BGPEntry->setLocalPreference(
bgpModule->par(
"localPreference").intValue());
Referenced by inet::bgp::BgpConfigReader::loadASConfig().
◆ addToAsList()
| void inet::bgp::BgpRouter::addToAsList |
( |
std::string |
nodeName, |
|
|
AsId |
id |
|
) |
| |
◆ addToPrefixList()
◆ addWatches()
| void inet::bgp::BgpRouter::addWatches |
( |
| ) |
|
◆ asLoopDetection()
520 for (
unsigned int i = 1; i < entry->getASCount(); i++) {
521 if (myAS == entry->getAS(i))
Referenced by processMessage().
◆ checkExternalRoute()
| int inet::bgp::BgpRouter::checkExternalRoute |
( |
const Ipv4Route * |
ospfRoute | ) |
|
|
inlineprivate |
◆ createEbgpSession()
| SessionId inet::bgp::BgpRouter::createEbgpSession |
( |
const char * |
peerAddr, |
|
|
SessionInfo & |
externalInfo |
|
) |
| |
108 info.myAddr = externalInfo.myAddr;
109 info.checkConnection = externalInfo.checkConnection;
110 info.ebgpMultihop = externalInfo.ebgpMultihop;
112 info.sessionType =
EGP;
115 info.peerAddr.
set(peerAddr);
117 if (!info.linkIntf) {
118 if (info.checkConnection)
119 throw cRuntimeError(
"BGP Error: External BGP neighbor at address %s is not directly connected to BGP router %s", peerAddr,
bgpModule->getOwner()->getFullName());
123 ASSERT(info.linkIntf);
124 info.sessionID = info.peerAddr.getInt() + info.linkIntf->getProtocolData<Ipv4InterfaceData>()->getIPAddress().getInt();
128 newSessionId = info.sessionID;
131 newSession->setInfo(info);
Referenced by inet::bgp::BgpConfigReader::loadEbgpSessionConfig().
◆ createIbgpSession()
| SessionId inet::bgp::BgpRouter::createIbgpSession |
( |
const char * |
peerAddr | ) |
|
◆ decisionProcess()
RFC 4271: 9.1.
: Decision Process used when an UPDATE message is received As matches, routes are sent or not to UpdateSentProcess The result can be ROUTE_DESTINATION_CHANGED, NEW_ROUTE_ADDED or 0 if no routingTable modification
539 entry->setPathType(msg.getPathAttributeList(0).getOrigin().getValue());
540 entry->setGateway(msg.getPathAttributeList(0).getNextHop().getValue());
541 if (msg.getPathAttributeList(0).getLocalPrefArraySize() != 0)
542 entry->setLocalPreference(msg.getPathAttributeList(0).getLocalPref(0).getValue());
544 for (
size_t i = 0; i < msg.getPathAttributesArraySize(); i++) {
545 switch (msg.getPathAttributes(i)->getTypeCode()) {
547 auto attr = check_and_cast<const BgpUpdatePathAttributesOrigin *>(msg.getPathAttributes(i));
548 entry->setPathType(attr->getValue());
552 auto attr = check_and_cast<const BgpUpdatePathAttributesNextHop *>(msg.getPathAttributes(i));
553 entry->setGateway(attr->getValue());
557 auto attr = check_and_cast<const BgpUpdatePathAttributesLocalPref *>(msg.getPathAttributes(i));
558 entry->setLocalPreference(attr->getValue());
570 entry->setIBgpLearned(
true);
580 if (BGPindex != (
unsigned long)-1) {
586 entry->setInterface(
_BGPSessions[sessionIndex]->getLinkIntf());
601 BgpRoutingTableEntry *BGPEntry =
new BgpRoutingTableEntry(oldEntry);
603 BGPEntry->setPathType(
IGP);
605 BGPEntry->setIBgpLearned(
true);
606 BGPEntry->setLocalPreference(entry->getLocalPreference());
622 entry->setInterface(
_BGPSessions[sessionIndex]->getLinkIntf());
628 entry->setInterface(
_BGPSessions[sessionIndex]->getLinkIntf());
639 NetworkInterface *ie = entry->getInterface();
641 throw cRuntimeError(
"Model error: interface entry is nullptr");
642 ospfv2::Ipv4AddressRange OSPFnetAddr;
643 OSPFnetAddr.address = entry->getDestination();
644 OSPFnetAddr.mask = entry->getNetmask();
646 throw cRuntimeError(
"Cannot find the OSPF module on router %s",
bgpModule->getFullName());
Referenced by processMessage().
◆ deleteBGPRoutingEntry()
784 if (((*it)->getDestination().getInt() & (*it)->getNetmask().getInt()) ==
785 (entry->getDestination().getInt() & entry->getNetmask().getInt()))
Referenced by tieBreakingProcess().
◆ findIdFromPeerAddr()
884 for (
auto& session : sessions) {
885 if ((session).second->getPeerAddr().equals(peerAddr))
886 return (session).first;
Referenced by processMessageFromTCP().
◆ findIdFromSocketConnId()
◆ findNextSession()
find the next SessionId compared to his type and start this session if boolean is true
864 if ((elem).second->getType() ==
type && !(elem).second->isEstablished()) {
865 sessionID = (elem).first;
869 if (startSession ==
true &&
type ==
IGP && sessionID !=
static_cast<SessionId>(-1)) {
873 if (linkIntf ==
nullptr)
874 throw cRuntimeError(
"No configuration interface for peer address: %s",
_BGPSessions[sessionID]->getPeerAddr().str().c_str());
Referenced by inet::bgp::BgpSession::findAndStartNextSession(), and socketEstablished().
◆ getAsId()
| AsId inet::bgp::BgpRouter::getAsId |
( |
| ) |
|
|
inline |
◆ getBGPRoutingTable()
◆ getCancelAndDelete()
| void inet::bgp::BgpRouter::getCancelAndDelete |
( |
cMessage * |
msg | ) |
|
|
inlineprotected |
◆ getCancelEvent()
| cMessage* inet::bgp::BgpRouter::getCancelEvent |
( |
cMessage * |
msg | ) |
|
|
inlineprotected |
◆ getInternalAddress()
| Ipv4Address inet::bgp::BgpRouter::getInternalAddress |
( |
| ) |
|
|
inline |
◆ getIPRoutingTable()
◆ getNumBgpSessions()
| int inet::bgp::BgpRouter::getNumBgpSessions |
( |
| ) |
|
|
inline |
◆ getNumEgpSessions()
| int inet::bgp::BgpRouter::getNumEgpSessions |
( |
| ) |
|
|
inline |
◆ getNumIgpSessions()
| int inet::bgp::BgpRouter::getNumIgpSessions |
( |
| ) |
|
|
inline |
◆ getRedistributeInternal()
| bool inet::bgp::BgpRouter::getRedistributeInternal |
( |
| ) |
|
|
inline |
◆ getRedistributeOspf()
| bool inet::bgp::BgpRouter::getRedistributeOspf |
( |
| ) |
|
|
inline |
◆ getRedistributeRip()
| bool inet::bgp::BgpRouter::getRedistributeRip |
( |
| ) |
|
|
inline |
◆ getRouterId()
| RouterId inet::bgp::BgpRouter::getRouterId |
( |
| ) |
|
|
inline |
◆ getScheduleAt()
| void inet::bgp::BgpRouter::getScheduleAt |
( |
simtime_t |
t, |
|
|
cMessage * |
msg |
|
) |
| |
|
inlineprotected |
◆ isDefaultRoute()
| bool inet::bgp::BgpRouter::isDefaultRoute |
( |
const Ipv4Route * |
entry | ) |
const |
|
private |
◆ isExternalAddress()
| bool inet::bgp::BgpRouter::isExternalAddress |
( |
const Ipv4Route & |
rtEntry | ) |
|
1066 if (session.second->getType() ==
EGP) {
1068 if (exIntf == rtEntry.getInterface())
Referenced by isRouteExcluded().
◆ isInASList()
838 for (
auto& elem : ASList) {
839 for (
unsigned int i = 0; i < entry->getASCount(); i++) {
840 if ((elem) == entry->getAS(i)) {
Referenced by decisionProcess(), and updateSendProcess().
◆ isInRoutingTable()
798 for (
int i = 0; i < rtTable->getNumRoutes(); i++) {
799 const Ipv4Route *entry = rtTable->getRoute(i);
Referenced by decisionProcess().
◆ isInTable()
824 for (
unsigned long i = 0; i < rtTable.size(); i++) {
825 BgpRoutingTableEntry *entryCur = rtTable[i];
826 if ((entry->getDestination().getInt() & entry->getNetmask().getInt()) ==
827 (entryCur->getDestination().getInt() & entryCur->getNetmask().getInt()))
Referenced by decisionProcess(), and updateSendProcess().
◆ isReachable()
| bool inet::bgp::BgpRouter::isReachable |
( |
const Ipv4Address |
addr | ) |
const |
|
private |
1085 if (addr.isUnspecified())
1091 if (addr.doAnd(route->getNetmask()) == route->getDestination().doAnd(route->getNetmask()))
Referenced by decisionProcess(), and updateSendProcess().
◆ isRouteExcluded()
| bool inet::bgp::BgpRouter::isRouteExcluded |
( |
const Ipv4Route & |
rtEntry | ) |
|
|
private |
1013 auto entry =
static_cast<const ospfv2::Ospfv2RoutingTableEntry *
>(&rtEntry);
1032 if (externalType == 1) {
1039 if (externalType == 2) {
1051 if (rtEntry.getInterface()->isLoopback())
Referenced by inet::bgp::BgpSession::isRouteExcluded().
◆ listenConnectionFromPeer()
| void inet::bgp::BgpRouter::listenConnectionFromPeer |
( |
SessionId |
sessionID | ) |
|
|
protected |
active listenSocket for a given session (used by fsm)
313 _BGPSessions[sessionID]->getSocketListen()->renewSocket();
319 NetworkInterface *intf =
_BGPSessions[sessionID]->getLinkIntf();
321 Ipv4Address localAddr = intf->getProtocolData<Ipv4InterfaceData>()->getIPAddress();
329 EV_DEBUG <<
"Start listening to incoming TCP connections on "
330 <<
_BGPSessions[sessionID]->getSocketListen()->getLocalAddress()
333 <<
" to peer " <<
_BGPSessions[sessionID]->getPeerAddr() << std::endl;
Referenced by inet::bgp::BgpSession::listenConnectionFromPeer().
◆ openTCPConnectionToPeer()
| void inet::bgp::BgpRouter::openTCPConnectionToPeer |
( |
SessionId |
sessionID | ) |
|
|
protected |
active TcpConnection for a given session (used by fsm)
339 EV_DEBUG <<
"Opening a TCP connection to "
341 <<
":" << (int)
TCP_PORT << std::endl;
343 TcpSocket *socket =
_BGPSessions[sessionID]->getSocket();
347 socket->renewSocket();
349 socket->setCallback(
this);
350 socket->setUserData((
void *)(uintptr_t)sessionID);
351 socket->setOutputGate(
bgpModule->gate(
"socketOut"));
353 NetworkInterface *intfEntry =
_BGPSessions[sessionID]->getLinkIntf();
354 if (intfEntry ==
nullptr)
355 throw cRuntimeError(
"No configuration interface for external peer address: %s",
_BGPSessions[sessionID]->getPeerAddr().str().c_str());
356 socket->bind(intfEntry->getProtocolData<Ipv4InterfaceData>()->getIPAddress(), 0);
358 int ebgpMH =
_BGPSessions[sessionID]->getEbgpMultihop();
360 socket->setTimeToLive(ebgpMH);
361 else if (ebgpMH == 1)
362 socket->setTimeToLive(1);
364 throw cRuntimeError(
"ebgpMultihop should be >=1");
367 NetworkInterface *intfEntry =
_BGPSessions[sessionID]->getLinkIntf();
370 if (intfEntry ==
nullptr)
371 throw cRuntimeError(
"No configuration interface for internal peer address: %s",
_BGPSessions[sessionID]->getPeerAddr().str().c_str());
374 throw cRuntimeError(
"Internal address is not specified for router %s",
bgpModule->getOwner()->getFullName());
Referenced by inet::bgp::BgpSession::openTCPConnectionToPeer().
◆ ospfExist()
851 for (
int i = 0; i < rtTable->getNumRoutes(); i++) {
852 if (rtTable->getRoute(i)->getSourceType() ==
IRoute::OSPF) {
Referenced by decisionProcess().
◆ printKeepAliveMessage()
◆ printOpenMessage()
| void inet::bgp::BgpRouter::printOpenMessage |
( |
const BgpOpenMessage & |
msg | ) |
|
893 EV_INFO <<
" My AS: " << openMsg.getMyAS() <<
"\n";
894 EV_INFO <<
" Hold time: " << openMsg.getHoldTime() <<
"s \n";
895 EV_INFO <<
" BGP Id: " << openMsg.getBGPIdentifier() <<
"\n";
896 if (openMsg.getOptionalParameterArraySize() == 0)
897 EV_INFO <<
" Optional parameters: empty \n";
898 for (uint32_t i = 0; i < openMsg.getOptionalParameterArraySize(); i++) {
899 auto optParam = openMsg.getOptionalParameter(i);
900 ASSERT(optParam !=
nullptr);
901 EV_INFO <<
" Optional parameter " << i + 1 <<
": \n";
902 EV_INFO <<
" Parameter type: " << optParam->getParameterType() <<
"\n";
903 EV_INFO <<
" Parameter length: " << optParam->getParameterValueLength() <<
"\n";
Referenced by processMessage(), and inet::bgp::BgpSession::sendOpenMessage().
◆ printSessionSummary()
| void inet::bgp::BgpRouter::printSessionSummary |
( |
| ) |
|
37 EV_DEBUG <<
"summary of BGP sessions: \n";
42 EV_DEBUG <<
" IGP session to internal peer '" << session->getPeerAddr().str(
false)
43 <<
"' starts at " << session->getStartEventTime() <<
"s \n";
46 EV_DEBUG <<
" EGP session to external peer '" << session->getPeerAddr().str(
false)
47 <<
"' starts at " << session->getStartEventTime() <<
"s \n";
50 EV_DEBUG <<
" Unknown session to peer '" << session->getPeerAddr().str(
false)
51 <<
"' starts at " << session->getStartEventTime() <<
"s \n";
Referenced by inet::bgp::Bgp::createBgpRouter().
◆ printUpdateMessage()
909 if (updateMsg.getWithdrawnRoutesArraySize() == 0)
910 EV_INFO <<
" Withdrawn routes: empty \n";
911 for (uint32_t i = 0; i < updateMsg.getWithdrawnRoutesArraySize(); i++) {
912 const BgpUpdateWithdrawnRoutes& withdrwan = updateMsg.getWithdrawnRoutes(i);
913 EV_INFO <<
" Withdrawn route " << i + 1 <<
": \n";
914 EV_INFO <<
" length: " << (int)withdrwan.length <<
"\n";
915 EV_INFO <<
" prefix: " << withdrwan.prefix <<
"\n";
917 if (updateMsg.getPathAttributesArraySize() == 0)
918 EV_INFO <<
" Path attribute: empty \n";
919 for (uint32_t i = 0; i < updateMsg.getPathAttributesArraySize(); i++) {
920 EV_INFO <<
" Path attribute " << i + 1 <<
": [len:" << updateMsg.getPathAttributes(i)->getLength() <<
"]\n";
921 switch (updateMsg.getPathAttributes(i)->getTypeCode()) {
923 auto& attr = *check_and_cast<const BgpUpdatePathAttributesOrigin *>(updateMsg.getPathAttributes(i));
928 auto& asPath = *check_and_cast<const BgpUpdatePathAttributesAsPath *>(updateMsg.getPathAttributes(i));
929 EV_INFO <<
" AS_PATH:";
930 for (uint32_t
k = 0;
k < asPath.getValueArraySize();
k++) {
931 const BgpAsPathSegment& asPathVal = asPath.getValue(
k);
932 for (uint32_t n = 0; n < asPathVal.getAsValueArraySize(); n++) {
933 EV_INFO <<
" " << asPathVal.getAsValue(n);
940 auto& attr = *check_and_cast<const BgpUpdatePathAttributesNextHop *>(updateMsg.getPathAttributes(i));
941 EV_INFO <<
" NEXT_HOP: " << attr.getValue().str(
false) <<
"\n";
945 auto& attr = *check_and_cast<const BgpUpdatePathAttributesLocalPref *>(updateMsg.getPathAttributes(i));
946 EV_INFO <<
" LOCAL_PREF: " << attr.getValue() <<
"\n";
950 auto& attr = *check_and_cast<const BgpUpdatePathAttributesAtomicAggregate *>(updateMsg.getPathAttributes(i));
952 EV_INFO <<
" ATOMIC_AGGREGATE" <<
"\n";
956 auto& attr = *check_and_cast<const BgpUpdatePathAttributesAggregator *>(updateMsg.getPathAttributes(i));
957 EV_INFO <<
" AGGREGATOR: " << attr.getAsNumber() <<
", " << attr.getBgpSpeaker() <<
"\n";
961 auto& attr = *check_and_cast<const BgpUpdatePathAttributesMultiExitDisc *>(updateMsg.getPathAttributes(i));
962 EV_INFO <<
" MULTI_EXIT_DISC: " << attr.getValue() <<
"\n";
968 if (updateMsg.getNLRIArraySize() > 0) {
969 auto NLRI_Base = updateMsg.getNLRI(0);
970 EV_INFO <<
" Network Layer Reachability Information (NLRI): \n";
971 EV_INFO <<
" NLRI length: " << (int)NLRI_Base.length <<
"\n";
972 EV_INFO <<
" NLRI prefix: " << NLRI_Base.prefix <<
"\n";
Referenced by processMessage(), and inet::bgp::BgpSession::sendUpdateMessage().
◆ processChunks()
| void inet::bgp::BgpRouter::processChunks |
( |
const BgpHeader & |
ptrHdr | ) |
|
|
private |
438 switch (ptrHdr.getType()) {
444 processMessage(*check_and_cast<const BgpKeepAliveMessage *>(&ptrHdr));
448 processMessage(*check_and_cast<const BgpUpdateMessage *>(&ptrHdr));
452 throw cRuntimeError(
"Invalid BGP message type %d", ptrHdr.getType());
Referenced by socketDataArrived().
◆ processMessage() [1/3]
469 EV_INFO <<
"Processing BGP Keep Alive message from "
470 << session->getPeerAddr().str(
false)
471 <<
" with contents: \n";
473 session->getFSM()->KeepAliveMsgEvent();
◆ processMessage() [2/3]
| void inet::bgp::BgpRouter::processMessage |
( |
const BgpOpenMessage & |
msg | ) |
|
|
private |
459 EV_INFO <<
"Processing BGP OPEN message from "
460 << session->getPeerAddr().str(
false)
461 <<
" with contents: \n";
463 session->getFSM()->OpenMsgEvent();
Referenced by processChunks().
◆ processMessage() [3/3]
479 EV_INFO <<
"Processing BGP Update message from "
480 << session->getPeerAddr().str(
false)
481 <<
" with contents: \n";
483 session->getFSM()->UpdateMsgEvent();
485 BgpRoutingTableEntry *entry =
new BgpRoutingTableEntry();
486 entry->setLocalPreference(
bgpModule->par(
"localPreference").intValue());
487 entry->setDestination(msg.getNLRI(0).prefix);
491 entry->setNetmask(netMask);
493 for (
size_t i = 0; i < msg.getPathAttributesArraySize(); i++) {
495 auto& asPath = *check_and_cast<const BgpUpdatePathAttributesAsPath *>(msg.getPathAttributes(i));
496 for (uint32_t
k = 0;
k < asPath.getValueArraySize();
k++) {
497 const BgpAsPathSegment& asPathVal = asPath.getValue(
k);
498 for (uint32_t n = 0; n < asPathVal.getAsValueArraySize(); n++) {
499 entry->addAS(asPathVal.getAsValue(n));
511 if (decisionProcessResult != 0)
◆ processMessageFromTCP()
| void inet::bgp::BgpRouter::processMessageFromTCP |
( |
cMessage * |
msg | ) |
|
283 socket =
new TcpSocket(msg);
284 socket->setOutputGate(
bgpModule->gate(
"socketOut"));
285 Ipv4Address peerAddr = socket->getRemoteAddress().toIpv4();
295 socket->setCallback(
this);
296 socket->setUserData((
void *)(uintptr_t)i);
304 socket->processMessage(msg);
Referenced by inet::bgp::Bgp::handleMessage().
◆ recordStatistics()
| void inet::bgp::BgpRouter::recordStatistics |
( |
| ) |
|
71 (elem).second->getStatistics(statTab);
73 bgpModule->recordScalar(
"OPENMsgSent", statTab[0]);
74 bgpModule->recordScalar(
"OPENMsgRecv", statTab[1]);
75 bgpModule->recordScalar(
"KeepAliveMsgSent", statTab[2]);
76 bgpModule->recordScalar(
"KeepAliveMsgRcv", statTab[3]);
77 bgpModule->recordScalar(
"UpdateMsgSent", statTab[4]);
78 bgpModule->recordScalar(
"UpdateMsgRcv", statTab[5]);
Referenced by inet::bgp::Bgp::finish().
◆ setAsId()
| void inet::bgp::BgpRouter::setAsId |
( |
AsId |
myAsId | ) |
|
|
inline |
◆ setDefaultConfig()
| void inet::bgp::BgpRouter::setDefaultConfig |
( |
| ) |
|
160 bool nextHopSelf =
bgpModule->par(
"nextHopSelf").boolValue();
161 int localPreference =
bgpModule->par(
"localPreference").intValue();
163 session.second->setNextHopSelf(nextHopSelf);
164 session.second->setLocalPreference(localPreference);
Referenced by inet::bgp::BgpConfigReader::loadASConfig().
◆ setInternalAddress()
| void inet::bgp::BgpRouter::setInternalAddress |
( |
Ipv4Address |
x | ) |
|
|
inline |
◆ setLocalPreference()
| void inet::bgp::BgpRouter::setLocalPreference |
( |
Ipv4Address |
peer, |
|
|
int |
localPref |
|
) |
| |
244 if (session.second->getPeerAddr() == peer) {
246 session.second->setLocalPreference(localPref);
251 throw cRuntimeError(
"Neighbor address '%s' cannot be found in BGP router %s", peer.str(
false).c_str(),
bgpModule->getOwner()->getFullName());
Referenced by inet::bgp::BgpConfigReader::loadASConfig().
◆ setNextHopSelf()
| void inet::bgp::BgpRouter::setNextHopSelf |
( |
Ipv4Address |
peer, |
|
|
bool |
nextHopSelf |
|
) |
| |
230 if (session.second->getPeerAddr() == peer) {
232 session.second->setNextHopSelf(nextHopSelf);
237 throw cRuntimeError(
"Neighbor address '%s' cannot be found in BGP router %s", peer.str(
false).c_str(),
bgpModule->getOwner()->getFullName());
Referenced by inet::bgp::BgpConfigReader::loadASConfig().
◆ setRedistributeInternal()
| void inet::bgp::BgpRouter::setRedistributeInternal |
( |
bool |
x | ) |
|
|
inline |
◆ setRedistributeOspf()
| void inet::bgp::BgpRouter::setRedistributeOspf |
( |
std::string |
x | ) |
|
262 std::vector<std::string> tokens = cStringTokenizer(str.c_str()).asVector();
264 for (
auto& Ospfv2RouteType : tokens) {
265 std::transform(Ospfv2RouteType.begin(), Ospfv2RouteType.end(), Ospfv2RouteType.begin(), ::tolower);
266 if (Ospfv2RouteType ==
"o")
268 else if (Ospfv2RouteType ==
"ia")
270 else if (Ospfv2RouteType ==
"e1")
272 else if (Ospfv2RouteType ==
"e2")
275 throw cRuntimeError(
"Unknown OSPF redistribute type '%s' in BGP router %s", Ospfv2RouteType.c_str(),
bgpModule->getOwner()->getFullName());
Referenced by inet::bgp::BgpConfigReader::loadASConfig(), and setDefaultConfig().
◆ setRedistributeRip()
| void inet::bgp::BgpRouter::setRedistributeRip |
( |
bool |
x | ) |
|
|
inline |
◆ setSocketListen()
| void inet::bgp::BgpRouter::setSocketListen |
( |
SessionId |
id | ) |
|
◆ setTimer()
| void inet::bgp::BgpRouter::setTimer |
( |
SessionId |
id, |
|
|
simtime_t * |
delayTab |
|
) |
| |
◆ socketAvailable()
|
|
inlineoverrideprotectedvirtual |
◆ socketClosed()
| virtual void inet::bgp::BgpRouter::socketClosed |
( |
TcpSocket * |
socket | ) |
|
|
inlineoverrideprotectedvirtual |
◆ socketDataArrived() [1/2]
| void inet::bgp::BgpRouter::socketDataArrived |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived() [2/2]
| void inet::bgp::BgpRouter::socketDataArrived |
( |
TcpSocket * |
socket, |
|
|
Packet * |
packet, |
|
|
bool |
urgent |
|
) |
| |
|
overrideprotectedvirtual |
Notifies about data arrival, packet ownership is transferred to the callee.
Reimplemented from inet::TcpSocket::ReceiveQueueBasedCallback.
431 ReceiveQueueBasedCallback::socketDataArrived(socket, packet, urgent);
◆ socketDeleted()
| virtual void inet::bgp::BgpRouter::socketDeleted |
( |
TcpSocket * |
socket | ) |
|
|
inlineoverrideprotectedvirtual |
◆ socketEstablished()
| void inet::bgp::BgpRouter::socketEstablished |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketFailure()
| void inet::bgp::BgpRouter::socketFailure |
( |
TcpSocket * |
socket, |
|
|
int |
code |
|
) |
| |
|
overrideprotectedvirtual |
◆ socketPeerClosed()
| virtual void inet::bgp::BgpRouter::socketPeerClosed |
( |
TcpSocket * |
socket | ) |
|
|
inlineoverrideprotectedvirtual |
◆ socketStatusArrived()
|
|
inlineoverrideprotectedvirtual |
◆ tieBreakingProcess()
RFC 4271: 9.1.2.2 Breaking Ties used when BGP speaker may have several routes to the same destination that have the same degree of preference.
- Returns
- bool, true if this process changed the route, false else
655 if (entry->getLocalPreference() > oldEntry->getLocalPreference()) {
663 if (entry->getASCount() < oldEntry->getASCount()) {
670 if (entry->getPathType() < oldEntry->getPathType()) {
Referenced by decisionProcess().
◆ updateSendProcess()
RFC 4271, 9.2 : Update-Send Process / Sent or not new UPDATE messages to its peers.
689 !(elem).second->isEstablished())
702 if (entry->isIBgpLearned() && sType ==
IGP && elem.second->getType() ==
IGP) {
703 EV_INFO <<
"BGP Split Horizon: prevent advertisement of network "
704 << entry->getDestination() <<
"\\" << entry->getNetmask();
708 if ((sType ==
IGP && (elem).second->getType() ==
EGP) ||
714 std::vector<BgpUpdatePathAttributes *> content;
716 unsigned int nbAS = entry->getASCount();
717 auto asPath =
new BgpUpdatePathAttributesAsPath();
718 content.push_back(asPath);
719 asPath->setValueArraySize(1);
721 asPath->getValueForUpdate(0).setLength(0);
722 if ((elem).second->getType() ==
EGP) {
724 if (entry->getAS(0) !=
myAsId) {
725 asPath->getValueForUpdate(0).setAsValueArraySize(nbAS + 1);
726 asPath->getValueForUpdate(0).setLength(nbAS + 1);
727 asPath->getValueForUpdate(0).setAsValue(0,
myAsId);
728 for (
unsigned int j = 1; j < nbAS + 1; j++)
729 asPath->getValueForUpdate(0).setAsValue(j, entry->getAS(j - 1));
732 asPath->getValueForUpdate(0).setAsValueArraySize(nbAS);
733 asPath->getValueForUpdate(0).setLength(nbAS);
734 for (
unsigned int j = 0; j < nbAS; j++)
735 asPath->getValueForUpdate(0).setAsValue(j, entry->getAS(j));
739 else if ((elem).second->getType() ==
IGP) {
740 asPath->getValueForUpdate(0).setAsValueArraySize(nbAS);
741 asPath->getValueForUpdate(0).setLength(nbAS);
742 for (
unsigned int j = 0; j < nbAS; j++)
743 asPath->getValueForUpdate(0).setAsValue(j, entry->getAS(j));
745 auto localPref =
new BgpUpdatePathAttributesLocalPref();
746 content.push_back(localPref);
747 localPref->setLength(4);
748 localPref->setValue(
_BGPSessions[sessionIndex]->getLocalPreference());
750 asPath->setLength(2 + 2 * asPath->getValue(0).getAsValueArraySize());
752 auto nextHopAttr =
new BgpUpdatePathAttributesNextHop;
753 content.push_back(nextHopAttr);
755 NetworkInterface *iftEntry = (elem).second->getLinkIntf();
756 nextHopAttr->setValue(iftEntry->getProtocolData<Ipv4InterfaceData>()->getIPAddress());
759 nextHopAttr->setValue(entry->getGateway());
761 auto originAttr =
new BgpUpdatePathAttributesOrigin;
762 content.push_back(originAttr);
765 Ipv4Address netMask = entry->getNetmask();
766 NLRI.prefix = entry->getDestination().doAnd(netMask);
767 NLRI.length = (
unsigned char)netMask.getNetmaskLength();
769 (elem).second->sendUpdateMessage(content, NLRI);
Referenced by processMessage(), and inet::bgp::BgpSession::updateSendProcess().
◆ BgpSession
◆ _ASListIN
| std::vector<AsId> inet::bgp::BgpRouter::_ASListIN |
|
private |
◆ _ASListOUT
| std::vector<AsId> inet::bgp::BgpRouter::_ASListOUT |
|
private |
◆ _BGPSessions
Referenced by addWatches(), createEbgpSession(), createIbgpSession(), decisionProcess(), findNextSession(), isExternalAddress(), listenConnectionFromPeer(), openTCPConnectionToPeer(), printSessionSummary(), processMessage(), processMessageFromTCP(), recordStatistics(), setDefaultConfig(), setLocalPreference(), setNextHopSelf(), setSocketListen(), setTimer(), socketDataArrived(), socketEstablished(), socketFailure(), updateSendProcess(), and ~BgpRouter().
◆ _currSessionId
| SessionId inet::bgp::BgpRouter::_currSessionId = 0 |
|
private |
◆ _prefixListIN
◆ _prefixListINOUT
◆ _prefixListOUT
◆ _socketMap
◆ advertiseList
| std::vector<Ipv4Address> inet::bgp::BgpRouter::advertiseList |
|
private |
◆ bgpModule
| cSimpleModule* inet::bgp::BgpRouter::bgpModule = nullptr |
|
private |
Referenced by addToAdvertiseList(), BgpRouter(), createEbgpSession(), decisionProcess(), listenConnectionFromPeer(), openTCPConnectionToPeer(), processMessage(), processMessageFromTCP(), recordStatistics(), setDefaultConfig(), setLocalPreference(), setNextHopSelf(), and setRedistributeOspf().
◆ bgpRoutingTable
◆ ift
◆ internalAddress
◆ myAsId
| AsId inet::bgp::BgpRouter::myAsId = 0 |
|
private |
◆ numEgpSessions
| uint32_t inet::bgp::BgpRouter::numEgpSessions = 0 |
|
private |
◆ numIgpSessions
| uint32_t inet::bgp::BgpRouter::numIgpSessions = 0 |
|
private |
◆ ospfModule
◆ redistributeInternal
| bool inet::bgp::BgpRouter::redistributeInternal = false |
|
private |
◆ redistributeOspf
| bool inet::bgp::BgpRouter::redistributeOspf = false |
|
private |
◆ redistributeOspfType
◆ redistributeRip
| bool inet::bgp::BgpRouter::redistributeRip = false |
|
private |
◆ rt
The documentation for this class was generated from the following files:
void processChunks(const BgpHeader &ptrHdr)
Definition: BgpRouter.cc:436
unsigned long SessionId
Definition: BgpCommon.h:52
@ EGP
Definition: BgpCommon_m.h:57
const unsigned char ASLOOP_DETECTED
Definition: BgpCommon.h:36
bool isReachable(const Ipv4Address addr) const
Definition: BgpRouter.cc:1083
@ ORIGIN
Definition: BgpHeader_m.h:425
IIpv4RoutingTable * rt
Definition: BgpRouter.h:30
virtual Ipv4Address getRouterId() const =0
Returns routerId.
SourceType getSourceType() const override
Source of route.
Definition: Ipv4Route.h:89
@ RIP
managed by the given routing protocol
Definition: IRoute.h:34
@ LISTENING
Definition: TcpSocket.h:153
redistributeOspfType_t redistributeOspfType
Definition: BgpRouter.h:43
ospfv2::Ospfv2 * ospfModule
Definition: BgpRouter.h:32
@ MANUAL
manually added static route
Definition: IRoute.h:29
static const std::string getTypeString(BgpSessionType sessionType)
Definition: BgpSession.cc:205
@ NOT_BOUND
Definition: TcpSocket.h:153
const unsigned char ASLOOP_NO_DETECTED
Definition: BgpCommon.h:35
void setRedistributeOspf(std::string x)
Definition: BgpRouter.cc:254
bool ospfExist(IIpv4RoutingTable *rtTable)
Definition: BgpRouter.cc:849
RoutingTableEntryVector _prefixListOUT
Definition: BgpRouter.h:55
@ ATOMIC_AGGREGATE
Definition: BgpHeader_m.h:430
std::map< SessionId, BgpSession * > _BGPSessions
Definition: BgpRouter.h:46
std::vector< Ipv4Address > advertiseList
Definition: BgpRouter.h:53
virtual NetworkInterface * getInterfaceForDestAddr(const Ipv4Address &dest) const =0
Convenience function based on findBestMatchingRoute().
bool intraArea
Definition: BgpRouter.h:39
bool externalType1
Definition: BgpRouter.h:40
void setRedistributeInternal(bool x)
Definition: BgpRouter.h:74
const unsigned char NEW_SESSION_ESTABLISHED
Definition: BgpCommon.h:34
RoutingTableEntryVector _prefixListINOUT
Definition: BgpRouter.h:56
SessionId findIdFromSocketConnId(std::map< SessionId, BgpSession * > sessions, int connId)
Definition: BgpRouter.cc:810
@ BGP
managed by the given routing protocol
Definition: IRoute.h:36
az accept haszálja pcb új connId
Definition: lwip_tcp.txt:42
friend class BgpSession
Definition: BgpRouter.h:114
bool redistributeInternal
Definition: BgpRouter.h:34
int checkExternalRoute(const Ipv4Route *ospfRoute)
Definition: BgpRouter.h:166
@ dBGPInternal
Definition: IRoute.h:73
void printUpdateMessage(const BgpUpdateMessage &msg)
Definition: BgpRouter.cc:907
@ AS_SEQUENCE
Definition: BgpCommon_m.h:76
bool isInASList(std::vector< AsId > ASList, BgpRoutingTableEntry *entry)
Definition: BgpRouter.cc:836
ISocket * findSocketFor(cMessage *msg)
Finds the socket for the given message.
Definition: SocketMap.cc:19
unsigned long isInTable(std::vector< BgpRoutingTableEntry * > rtTable, BgpRoutingTableEntry *entry)
Definition: BgpRouter.cc:822
static const Ipv4Address ALLONES_ADDRESS
255.255.255.255
Definition: Ipv4Address.h:94
bool tieBreakingProcess(BgpRoutingTableEntry *oldEntry, BgpRoutingTableEntry *entry)
RFC 4271: 9.1.2.2 Breaking Ties used when BGP speaker may have several routes to the same destination...
Definition: BgpRouter.cc:653
@ IGP
Definition: BgpCommon_m.h:56
@ NEXT_HOP
Definition: BgpHeader_m.h:427
void addSocket(ISocket *socket)
Adds the given socket.
Definition: SocketMap.cc:28
uint32_t numIgpSessions
Definition: BgpRouter.h:48
bool isExternalAddress(const Ipv4Route &rtEntry)
Definition: BgpRouter.cc:1063
virtual Ipv4Route * getRoute(int k) const override=0
Returns the kth route.
void setRedistributeRip(bool x)
Definition: BgpRouter.h:76
int checkExternalRoute(const Ipv4Address &route)
Checks if the route is in OSPF external LSA Table.
Definition: Ospfv2.cc:176
@ OSPF
managed by the given routing protocol
Definition: IRoute.h:35
static bool maskedAddrAreEqual(const Ipv4Address &addr1, const Ipv4Address &addr2, const Ipv4Address &netmask)
Test if the masked addresses (ie the mask is applied to addr1 and addr2) are equal.
Definition: Ipv4Address.cc:249
bool deleteBGPRoutingEntry(BgpRoutingTableEntry *entry)
Definition: BgpRouter.cc:779
@ INTERAREA
Definition: Ospfv2RoutingTableEntry.h:27
static Ipv4Address makeNetmask(int length)
Creates and returns a netmask with the given length.
Definition: Ipv4Address.h:329
RoutingTableEntryVector bgpRoutingTable
Definition: BgpRouter.h:52
cSimpleModule * bgpModule
Definition: BgpRouter.h:31
uint32_t numEgpSessions
Definition: BgpRouter.h:47
removed type
Definition: IUdp-gates.txt:7
SessionId findNextSession(BgpSessionType type, bool startSession=false)
find the next SessionId compared to his type and start this session if boolean is true
Definition: BgpRouter.cc:860
RoutingTableEntryVector _prefixListIN
Definition: BgpRouter.h:54
@ AS_PATH
Definition: BgpHeader_m.h:426
void set(uint32_t ip)
name Setting the address
Definition: Ipv4Address.h:142
virtual bool deleteRoute(Ipv4Route *entry)=0
Deletes the given route from the routing table.
void processMessage(const BgpOpenMessage &msg)
Definition: BgpRouter.cc:456
virtual int getNumRoutes() const =0
Returns the total number of unicast routes.
void insertExternalRoute(int ifIndex, const Ipv4AddressRange &netAddr)
Insert a route learn by BGP in OSPF routingTable as an external route.
Definition: Ospfv2.cc:159
virtual void addRoute(Ipv4Route *entry)=0
Adds a route to the routing table.
const double k
Definition: Qam1024Modulation.cc:14
@ LOCAL_PREF
Definition: BgpHeader_m.h:429
AsId myAsId
Definition: BgpRouter.h:33
@ dBGPExternal
Definition: IRoute.h:64
SocketMap _socketMap
Definition: BgpRouter.h:44
const unsigned char ROUTE_DESTINATION_CHANGED
Definition: BgpCommon.h:32
SessionId findIdFromPeerAddr(std::map< SessionId, BgpSession * > sessions, Ipv4Address peerAddr)
Definition: BgpRouter.cc:882
static const Ipv4Address UNSPECIFIED_ADDRESS
0.0.0.0
Definition: Ipv4Address.h:91
const unsigned char NEW_ROUTE_ADDED
Definition: BgpCommon.h:33
bool interArea
Definition: BgpRouter.h:38
const unsigned char NB_STATS
Definition: BgpCommon.h:28
@ AGGREGATOR
Definition: BgpHeader_m.h:431
@ CLOSED
Definition: TcpSocket.h:153
@ dUnknown
Definition: IRoute.h:77
@ BGP_KEEPALIVE
Definition: BgpHeader_m.h:151
bool redistributeOspf
Definition: BgpRouter.h:36
@ BGP_OPEN
Definition: BgpHeader_m.h:148
void printOpenMessage(const BgpOpenMessage &msg)
Definition: BgpRouter.cc:891
void updateSendProcess(const unsigned char decisionProcessResult, SessionId sessionIndex, BgpRoutingTableEntry *entry)
RFC 4271, 9.2 : Update-Send Process / Sent or not new UPDATE messages to its peers.
Definition: BgpRouter.cc:678
int isInRoutingTable(IIpv4RoutingTable *rtTable, Ipv4Address addr)
Definition: BgpRouter.cc:796
BgpSessionType
Enum generated from inet/routing/bgpv4/BgpCommon.msg:12 by opp_msgtool.
Definition: BgpCommon_m.h:55
@ MULTI_EXIT_DISC
Definition: BgpHeader_m.h:428
const unsigned char TCP_PORT
Definition: BgpCommon.h:21
bool isDefaultRoute(const Ipv4Route *entry) const
Definition: BgpRouter.cc:1076
bool redistributeRip
Definition: BgpRouter.h:35
value< double, units::m > m
Definition: Units.h:1233
void addWatch()
Definition: SocketMap.cc:51
std::vector< AsId > _ASListOUT
Definition: BgpRouter.h:58
@ INTRAAREA
Definition: Ospfv2RoutingTableEntry.h:26
void printKeepAliveMessage(const BgpKeepAliveMessage &msg)
Definition: BgpRouter.cc:981
unsigned char decisionProcess(const BgpUpdateMessage &msg, BgpRoutingTableEntry *entry, SessionId sessionIndex)
RFC 4271: 9.1.
Definition: BgpRouter.cc:528
Ipv4Address internalAddress
Definition: BgpRouter.h:49
SessionId _currSessionId
Definition: BgpRouter.h:45
unsigned char asLoopDetection(BgpRoutingTableEntry *entry, AsId myAS)
Definition: BgpRouter.cc:518
ISocket * removeSocket(ISocket *socket)
Removes the given socket.
Definition: SocketMap.cc:34
std::vector< AsId > _ASListIN
Definition: BgpRouter.h:57
bool externalType2
Definition: BgpRouter.h:41
@ IFACENETMASK
comes from an interface's netmask
Definition: IRoute.h:30
IInterfaceTable * ift
Definition: BgpRouter.h:29
@ BGP_UPDATE
Definition: BgpHeader_m.h:149