22 #include "ns3/assert.h" 23 #include "ns3/abort.h" 24 #include "ns3/channel.h" 25 #include "ns3/net-device.h" 27 #include "ns3/node-list.h" 29 #include "ns3/bridge-net-device.h" 48 m_linkData (
"0.0.0.0"),
62 m_linkData (linkData),
63 m_linkType (linkType),
140 m_linkStateId (
"0.0.0.0"),
141 m_advertisingRtr (
"0.0.0.0"),
143 m_networkLSANetworkMask (
"0.0.0.0"),
144 m_attachedRouters (),
157 m_linkStateId (linkStateId),
158 m_advertisingRtr (advertisingRtr),
160 m_networkLSANetworkMask (
"0.0.0.0"),
161 m_attachedRouters (),
169 : m_lsType (lsa.m_lsType), m_linkStateId (lsa.m_linkStateId),
170 m_advertisingRtr (lsa.m_advertisingRtr),
171 m_networkLSANetworkMask (lsa.m_networkLSANetworkMask),
172 m_status (lsa.m_status),
173 m_node_id (lsa.m_node_id)
177 "GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor");
201 for (ListOfLinkRecords_t::const_iterator i = lsa.
m_linkRecords.begin ();
230 for ( ListOfLinkRecords_t::iterator i =
m_linkRecords.begin ();
266 for ( ListOfLinkRecords_t::const_iterator i =
m_linkRecords.begin ();
275 NS_ASSERT_MSG (
false,
"GlobalRoutingLSA::GetLinkRecord (): invalid index");
378 NS_ASSERT_MSG (
false,
"GlobalRoutingLSA::GetAttachedRouter (): invalid index");
408 os <<
"========== Global Routing LSA ==========" << std::endl;
412 os <<
" (GlobalRoutingLSA::RouterLSA)";
416 os <<
" (GlobalRoutingLSA::NetworkLSA)";
420 os <<
" (GlobalRoutingLSA::ASExternalLSA)";
424 os <<
"(Unknown LSType)";
428 os <<
"m_linkStateId = " <<
m_linkStateId <<
" (Router ID)" << std::endl;
429 os <<
"m_advertisingRtr = " <<
m_advertisingRtr <<
" (Router ID)" << std::endl;
433 for ( ListOfLinkRecords_t::const_iterator i =
m_linkRecords.begin ();
439 os <<
"---------- RouterLSA Link Record ----------" << std::endl;
443 os <<
" (GlobalRoutingLinkRecord::PointToPoint)" << std::endl;
444 os <<
"m_linkId = " << p->
m_linkId << std::endl;
445 os <<
"m_linkData = " << p->
m_linkData << std::endl;
446 os <<
"m_metric = " << p->
m_metric << std::endl;
450 os <<
" (GlobalRoutingLinkRecord::TransitNetwork)" << std::endl;
451 os <<
"m_linkId = " << p->
m_linkId <<
" (Designated router for network)" << std::endl;
452 os <<
"m_linkData = " << p->
m_linkData <<
" (This router's IP address)" << std::endl;
453 os <<
"m_metric = " << p->
m_metric << std::endl;
457 os <<
" (GlobalRoutingLinkRecord::StubNetwork)" << std::endl;
458 os <<
"m_linkId = " << p->
m_linkId <<
" (Network number of attached network)" << std::endl;
459 os <<
"m_linkData = " << p->
m_linkData <<
" (Network mask of attached network)" << std::endl;
460 os <<
"m_metric = " << p->
m_metric << std::endl;
464 os <<
" (Unknown LinkType)" << std::endl;
465 os <<
"m_linkId = " << p->
m_linkId << std::endl;
466 os <<
"m_linkData = " << p->
m_linkData << std::endl;
467 os <<
"m_metric = " << p->
m_metric << std::endl;
469 os <<
"---------- End RouterLSA Link Record ----------" << std::endl;
474 os <<
"---------- NetworkLSA Link Record ----------" << std::endl;
479 os <<
"attachedRouter = " << p << std::endl;
481 os <<
"---------- End NetworkLSA Link Record ----------" << std::endl;
485 os <<
"---------- ASExternalLSA Link Record --------" << std::endl;
493 os <<
"========== End Global Routing LSA ==========" << std::endl;
515 .SetGroupName (
"Internet");
563 for ( ListOfLSAs_t::iterator i =
m_LSAs.begin ();
597 NS_ABORT_MSG_UNLESS (node,
"GlobalRouter::DiscoverLSAs (): GetObject for <Node> interface failed");
615 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::DiscoverLSAs (): GetObject for <Ipv4> interface failed");
639 for (uint32_t i = 0; i < numDevices; ++i)
643 if (DynamicCast <LoopbackNetDevice> (ndLocal))
656 uint32_t interfaceBridge = ipv4Local->GetNInterfaces () + 1;
658 NS_ABORT_MSG_IF (rc,
"GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index");
667 bool isForwarding =
false;
668 for (uint32_t j = 0; j < ipv4Local->GetNInterfaces (); ++j )
670 if (ipv4Local->GetNetDevice (j) == ndLocal && ipv4Local->IsUp (j) &&
671 ipv4Local->IsForwarding (j))
680 NS_LOG_LOGIC (
"Net device " << ndLocal <<
"has no IP interface or is not enabled for forwarding, skipping");
694 if (ndLocal->IsBroadcast () && !ndLocal->IsPointToPoint () )
699 else if (ndLocal->IsPointToPoint () )
706 NS_ASSERT_MSG (0,
"GlobalRouter::DiscoverLSAs (): unknown link type");
719 uint32_t nDesignatedRouters = c.
GetN ();
720 if (nDesignatedRouters > 0)
766 NS_ABORT_MSG_IF (
plr == 0,
"GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record");
778 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessSingleBroadcastLink (): GetObject for <Ipv4> interface failed");
781 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
783 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessSingleBroadcastLink(): No interface index associated with device");
785 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
787 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
789 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
790 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
791 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
792 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
819 maskLocalAddr.
Set (maskLocal.
Get ());
820 plr->SetLinkData (maskLocalAddr);
821 plr->SetMetric (metricLocal);
848 if (desigRtr !=
"255.255.255.255")
853 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion");
855 if (desigRtr == addrLocal)
860 plr->SetLinkId (desigRtr);
865 plr->SetLinkData (addrLocal);
866 plr->SetMetric (metricLocal);
876 NS_ASSERT_MSG (nd->IsBridge (),
"GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
890 NS_ABORT_MSG_UNLESS (bnd,
"GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
901 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessBridgedBroadcastLink (): GetObject for <Ipv4> interface failed");
904 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
906 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessBridgedBroadcastLink(): No interface index associated with device");
908 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
910 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
912 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
913 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();;
914 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
915 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
926 bool areTransitNetwork =
false;
929 for (uint32_t i = 0; i < bnd->GetNBridgePorts (); ++i)
941 areTransitNetwork =
true;
957 if (desigRtrTemp !=
"255.255.255.255")
962 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion");
964 if (desigRtrTemp < desigRtr)
966 desigRtr = desigRtrTemp;
976 NS_ABORT_MSG_IF (
plr == 0,
"GlobalRouter::ProcessBridgedBroadcastLink(): Can't alloc link record");
978 if (areTransitNetwork ==
false)
996 maskLocalAddr.
Set (maskLocal.
Get ());
997 plr->SetLinkData (maskLocalAddr);
998 plr->SetMetric (metricLocal);
1017 if (desigRtr == addrLocal)
1022 plr->SetLinkId (desigRtr);
1027 plr->SetLinkData (addrLocal);
1028 plr->SetMetric (metricLocal);
1047 Ptr<Node> nodeLocal = ndLocal->GetNode ();
1050 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1052 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
1054 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessPointToPointLink (): No interface index associated with device");
1056 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
1058 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1060 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
1061 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
1062 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
1083 Ptr<Node> nodeRemote = ndRemote->GetNode ();
1086 "GlobalRouter::ProcessPointToPointLink(): GetObject for remote <Ipv4> failed");
1102 Ipv4Address rtrIdRemote = rtrRemote->GetRouterId ();
1103 NS_LOG_LOGIC (
"Working with remote router " << rtrIdRemote);
1109 uint32_t interfaceRemote = ipv4Remote->GetNInterfaces () + 1;
1111 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessPointToPointLinks(): No interface index associated with remote device");
1117 if (ipv4Remote->GetNAddresses (interfaceRemote) > 1)
1119 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1121 Ipv4Address addrRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetLocal ();
1122 Ipv4Mask maskRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetMask ();
1123 NS_LOG_LOGIC (
"Working with remote address " << addrRemote);
1131 if (ipv4Remote->IsUp (interfaceRemote))
1133 NS_LOG_LOGIC (
"Remote side interface " << interfaceRemote <<
" is up-- add a type 1 link");
1136 NS_ABORT_MSG_IF (
plr == 0,
"GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1138 plr->SetLinkId (rtrIdRemote);
1139 plr->SetLinkData (addrLocal);
1140 plr->SetMetric (metricLocal);
1147 NS_ABORT_MSG_IF (
plr == 0,
"GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1149 plr->SetLinkId (addrRemote);
1151 plr->SetMetric (metricLocal);
1161 uint32_t nDesignatedRouters = c.
GetN ();
1162 NS_LOG_DEBUG (
"Number of designated routers: " << nDesignatedRouters);
1164 for (uint32_t i = 0; i < nDesignatedRouters; ++i)
1174 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1176 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
1178 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::BuildNetworkLSAs (): No interface index associated with device");
1180 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
1182 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1184 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
1185 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
1188 NS_ABORT_MSG_IF (pLSA == 0,
"GlobalRouter::BuildNetworkLSAs(): Can't alloc link record");
1204 std::size_t nDevices = ch->GetNDevices ();
1207 NS_LOG_LOGIC (
"Found " << deviceList.
GetN () <<
" non-bridged devices on channel");
1209 for (uint32_t i = 0; i < deviceList.
GetN (); i++)
1213 if (tempNd == ndLocal)
1215 NS_LOG_LOGIC (
"Adding " << addrLocal <<
" to Network LSA");
1219 Ptr<Node> tempNode = tempNd->GetNode ();
1227 NS_LOG_LOGIC (
"Node " << tempNode->
GetId () <<
" does not have GlobalRouter interface--skipping");
1235 uint32_t tempInterface = 0;
1240 if (!tempIpv4->IsUp (tempInterface))
1242 NS_LOG_LOGIC (
"Remote side interface " << tempInterface <<
" not up");
1246 if (tempIpv4->GetNAddresses (tempInterface) > 1)
1248 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1250 Ipv4Address tempAddr = tempIpv4->GetAddress (tempInterface, 0).GetLocal ();
1251 NS_LOG_LOGIC (
"Adding " << tempAddr <<
" to Network LSA");
1257 NS_LOG_LOGIC (
"Node " << tempNode->
GetId () <<
" device " << tempNd <<
" does not have IPv4 interface; skipping");
1273 for (std::size_t i = 0; i < ch->GetNDevices (); i++)
1276 NS_LOG_LOGIC (
"checking to see if the device " << nd <<
" is bridged");
1280 NS_LOG_LOGIC (
"Device is bridged by BridgeNetDevice " << bnd <<
" with " << bnd->GetNBridgePorts () <<
" ports");
1284 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); j++)
1287 if (bridgedDevice->GetChannel () == ch)
1292 NS_LOG_LOGIC (
"Calling on channel " << bridgedDevice->GetChannel ());
1317 Ptr<Channel> ch = ndLocal->GetChannel ();
1318 uint32_t nDevices = ch->GetNDevices ();
1321 NS_LOG_LOGIC (
"Looking for designated router off of net device " << ndLocal <<
" on node " <<
1322 ndLocal->GetNode ()->GetId ());
1324 Ipv4Address desigRtr (
"255.255.255.255");
1330 for (uint32_t i = 0; i < nDevices; i++)
1332 Ptr<NetDevice> ndOther = ch->GetDevice (i);
1335 Ptr<Node> nodeOther = ndOther->GetNode ();
1337 NS_LOG_LOGIC (
"Examine channel device " << i <<
" on node " << nodeOther->GetId ());
1345 NS_LOG_LOGIC (
"checking to see if the device is bridged");
1349 NS_LOG_LOGIC (
"Device is bridged by BridgeNetDevice " << bnd);
1354 if (ndLocal == ndOther)
1369 NS_LOG_LOGIC (
"Checking for router on bridge net device " << bnd);
1370 Ptr<GlobalRouter> rtr = nodeOther->GetObject<
GlobalRouter> ();
1371 Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> ();
1375 uint32_t interfaceOther = ipv4->GetNInterfaces () + 1;
1378 NS_LOG_LOGIC (
"Found router on bridge net device " << bnd);
1379 if (!ipv4->IsUp (interfaceOther))
1381 NS_LOG_LOGIC (
"Remote side interface " << interfaceOther <<
" not up");
1384 if (ipv4->GetNAddresses (interfaceOther) > 1)
1386 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1388 Ipv4Address addrOther = ipv4->GetAddress (interfaceOther, 0).GetLocal ();
1389 desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
1407 NS_LOG_LOGIC (
"Looking through bridge ports of bridge net device " << bnd);
1408 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
1410 Ptr<NetDevice> ndBridged = bnd->GetBridgePort (j);
1411 NS_LOG_LOGIC (
"Examining bridge port " << j <<
" device " << ndBridged);
1412 if (ndBridged == ndOther)
1414 NS_LOG_LOGIC (
"That bridge port is me, don't walk backward");
1418 NS_LOG_LOGIC (
"Recursively looking for routers down bridge port " << ndBridged);
1420 desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
1427 Ptr<Node> nodeOther = ndOther->GetNode ();
1434 Ptr<GlobalRouter> rtr = nodeOther->GetObject<
GlobalRouter> ();
1435 Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> ();
1439 uint32_t interfaceOther = ipv4->GetNInterfaces () + 1;
1442 if (!ipv4->IsUp (interfaceOther))
1444 NS_LOG_LOGIC (
"Remote side interface " << interfaceOther <<
" not up");
1447 NS_LOG_LOGIC (
"Found router on net device " << ndOther);
1448 if (ipv4->GetNAddresses (interfaceOther) > 1)
1450 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1452 Ipv4Address addrOther = ipv4->GetAddress (interfaceOther, 0).GetLocal ();
1453 desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
1473 Ptr<Channel> ch = nd->GetChannel ();
1479 uint32_t nDevices = ch->GetNDevices ();
1482 NS_LOG_LOGIC (
"Looking for routers off of net device " << nd <<
" on node " << nd->GetNode ()->GetId ());
1488 for (uint32_t i = 0; i < nDevices; i++)
1490 Ptr<NetDevice> ndOther = ch->GetDevice (i);
1493 NS_LOG_LOGIC (
"Examine channel device " << i <<
" on node " << ndOther->GetNode ()->GetId ());
1514 NS_LOG_LOGIC (
"Device is bridged by net device " << bnd);
1529 NS_LOG_LOGIC (
"Looking through bridge ports of bridge net device " << bnd);
1530 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
1532 Ptr<NetDevice> ndBridged = bnd->GetBridgePort (j);
1533 NS_LOG_LOGIC (
"Examining bridge port " << j <<
" device " << ndBridged);
1534 if (ndBridged == ndOther)
1540 NS_LOG_LOGIC (
"Recursively looking for routers on bridge port " << ndBridged);
1543 NS_LOG_LOGIC (
"Found routers on bridge port, return true");
1547 NS_LOG_LOGIC (
"No routers on bridged net device, return false");
1552 Ptr<Node> nodeTemp = ndOther->GetNode ();
1555 Ptr<GlobalRouter> rtr = nodeTemp->GetObject<
GlobalRouter> ();
1558 NS_LOG_LOGIC (
"Found GlobalRouter interface, return true");
1563 NS_LOG_LOGIC (
"No GlobalRouter interface on device, continue search");
1584 NS_ASSERT_MSG (lsa.IsEmpty (),
"GlobalRouter::GetLSA (): Must pass empty LSA");
1590 ListOfLSAs_t::const_iterator i =
m_LSAs.begin ();
1593 for (; i !=
m_LSAs.end (); i++, j++)
1597 GlobalRoutingLSA *p = *i;
1610 Ipv4RoutingTableEntry *route =
new Ipv4RoutingTableEntry ();
1620 Ipv4RoutingTableEntry *
1675 if ((*i)->GetDestNetwork () == network && (*i)->GetDestNetworkMask () == networkMask)
1677 NS_LOG_LOGIC (
"Withdrawing route to network/mask " << network <<
"/" << networkMask);
1695 NS_ASSERT_MSG (ch->GetNDevices () == 2,
"GlobalRouter::GetAdjacent (): Channel with other than two devices");
1699 Ptr<NetDevice> nd1 = ch->GetDevice (0);
1700 Ptr<NetDevice> nd2 = ch->GetDevice (1);
1717 "GlobalRouter::GetAdjacent (): Wrong or confused channel?");
1733 NS_LOG_LOGIC (
"For node " << node->GetId () <<
" for net device " << nd );
1735 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
1738 NS_LOG_LOGIC (
"No Ipv4 interface on node " << node->GetId ());
1742 for (uint32_t i = 0; i < ipv4->GetNInterfaces (); ++i )
1744 if (ipv4->GetNetDevice (i) == nd)
1746 NS_LOG_LOGIC (
"Device " << nd <<
" has associated ipv4 index " << i);
1752 NS_LOG_LOGIC (
"Device " << nd <<
" has no associated ipv4 index");
1759 Ptr<BridgeNetDevice>
1764 Ptr<Node> node = nd->GetNode ();
1765 uint32_t nDevices = node->GetNDevices ();
1773 for (uint32_t i = 0; i < nDevices; ++i)
1775 Ptr<NetDevice> ndTest = node->GetDevice (i);
1776 NS_LOG_LOGIC (
"Examine device " << i <<
" " << ndTest);
1778 if (ndTest->IsBridge ())
1780 NS_LOG_LOGIC (
"device " << i <<
" is a bridge net device");
1781 Ptr<BridgeNetDevice> bnd = ndTest->GetObject<BridgeNetDevice> ();
1782 NS_ABORT_MSG_UNLESS (bnd,
"GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
1784 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
1786 NS_LOG_LOGIC (
"Examine bridge port " << j <<
" " << bnd->GetBridgePort (j));
1787 if (bnd->GetBridgePort (j) == nd)
1789 NS_LOG_LOGIC (
"Net device " << nd <<
" is bridged by " << bnd);
1795 NS_LOG_LOGIC (
"Net device " << nd <<
" is not bridged");
1814 std::vector<Ptr<BridgeNetDevice> >::iterator iter;
1817 if (bridgeNetDevice == *iter)
1819 NS_LOG_LOGIC (
"Bridge " << bridgeNetDevice <<
" has been visited.");
void SetRoutingProtocol(Ptr< Ipv4GlobalRouting > routing)
Set the specific Global Routing Protocol to be used.
void MarkBridgeAsVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, mark a given device as having been visited...
Unused – for future OSPF compatibility.
Ptr< Ipv4GlobalRouting > GetRoutingProtocol(void)
Get the specific Global Routing Protocol used.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
virtual void DoDispose(void)
Destructor implementation.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
~GlobalRoutingLSA()
Destroy an existing Global Routing Link State Advertisement.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
void SetMetric(uint16_t metric)
Set the Metric Data field of the Global Routing Link Record.
uint32_t GetId(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Ipv4Address m_advertisingRtr
The Advertising Router is defined by the OSPF spec.
static Ptr< Node > GetNode(uint32_t n)
a class to represent an Ipv4 address mask
std::list< Ipv4RoutingTableEntry * >::const_iterator InjectedRoutesCI
Const Iterator to container of Ipv4RoutingTableEntry.
uint32_t m_node_id
node ID
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
LinkType GetLinkType(void) const
Get the Link Type field of the Global Routing Link Record.
static TypeId GetTypeId(void)
Get the type ID.
bool WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask)
Withdraw a route from the global unicast routing table.
uint32_t DiscoverLSAs(void)
Walk the connected channels, discover the adjacent routers and build the associated number of Global ...
void SetAdvertisingRouter(Ipv4Address rtr)
Set the Advertising Router as defined by the OSPF spec.
LSType GetLSType(void) const
Return the LSType field of the LSA.
LSType m_lsType
The type of the LSA.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t AddLinkRecord(GlobalRoutingLinkRecord *lr)
Add a given Global Routing Link Record to the LSA.
Ipv4Mask m_networkLSANetworkMask
Each Network LSA contains the network mask of the attached network.
SPFStatus GetStatus(void) const
Get the SPF status of the advertisement.
virtual void DoDispose(void)
Destructor implementation.
void SetLinkId(Ipv4Address addr)
Set the Link ID field of the Global Routing Link Record.
a virtual net device that bridges multiple LAN segments
uint32_t GetNInjectedRoutes(void)
Get the number of injected routes that have been added to the routing table.
void ProcessSingleBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a single broadcast link.
uint32_t AddAttachedRouter(Ipv4Address addr)
Add an attached router to the list in the NetworkLSA.
InjectedRoutes m_injectedRoutes
Routes we are exporting.
void SetLinkData(Ipv4Address addr)
Set the Link Data field of the Global Routing Link Record.
void SetNode(Ptr< Node > node)
Set the Node pointer of the node that originated this LSA.
Ipv4Address FindDesignatedRouterForLink(Ptr< NetDevice > ndLocal) const
Finds a designated router.
uint16_t m_metric
The metric for a given link.
void ClearLinkRecords(void)
Release all of the Global Routing Link Records present in the Global Routing Link State Advertisement...
Ipv4RoutingTableEntry * GetInjectedRoute(uint32_t i)
Return the injected route indexed by i.
Record represents a leaf node network.
LSType
corresponds to LS type field of RFC 2328 OSPF LSA header
Ipv4Mask GetNetworkLSANetworkMask(void) const
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
A single link record for a link state advertisement.
Ptr< Ipv4GlobalRouting > m_routingProtocol
the Ipv4GlobalRouting in use
void Print(std::ostream &os) const
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records...
a Link State Advertisement (LSA) for a router, used in global routing.
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
void InjectRoute(Ipv4Address network, Ipv4Mask networkMask)
Inject a route to be circulated to other routers as an external route.
void ClearLSAs(void)
Clear list of LSAs.
New vertex not yet considered.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void ClearBridgesVisited(void) const
Clear the list of bridges visited on the link.
static Ipv4RoutingTableEntry CreateNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
holds a vector of ns3::NetDevice pointers
bool FindInterfaceForDevice(Ptr< Node > node, Ptr< NetDevice > nd, uint32_t &index) const
Given a node and a net device, find an IPV4 interface index that corresponds to that net device...
GlobalRoutingLinkRecord * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
Ptr< NetDevice > GetAdjacent(Ptr< NetDevice > nd, Ptr< Channel > ch) const
Link through the given channel and find the net device that's on the other end.
Ipv4Address GetRouterId(void) const
Get the Router ID associated with this Global Router.
LinkType
Enumeration of the possible types of Global Routing Link Records.
void SetLSType(LSType typ)
Set the LS type field of the LSA.
uint16_t GetMetric(void) const
Get the Metric Data field of the Global Routing Link Record.
Ipv4Address m_linkData
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
void RemoveInjectedRoute(uint32_t i)
Withdraw a route from the global unicast routing table.
SPFStatus m_status
This is a tristate flag used internally in the SPF computation to mark if an SPFVertex (a data struct...
Access to the IPv4 forwarding table, interfaces, and configuration.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ipv4Address GetLinkData(void) const
Get the Link Data field of the Global Routing Link Record.
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
NetDeviceContainer FindAllNonBridgedDevicesOnLink(Ptr< Channel > ch) const
Return a container of all non-bridged NetDevices on a link.
void SetLinkType(LinkType linkType)
Set the Link Type field of the Global Routing Link Record.
ListOfLSAs_t m_LSAs
database of GlobalRoutingLSAs
void BuildNetworkLSAs(NetDeviceContainer c)
Build one NetworkLSA for each net device talking to a network that we are the designated router for...
~GlobalRoutingLinkRecord()
Destroy a Global Routing Link Record.
Ipv4Address GetLinkId(void) const
Get the Link ID field of the Global Routing Link Record.
std::vector< Ptr< BridgeNetDevice > > m_bridgesVisited
Container of bridges visited.
GlobalRoutingLinkRecord()
Construct an empty ("uninitialized") Global Routing Link Record.
bool BridgeHasAlreadyBeenVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, check whether a given device has already been visi...
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
bool AnotherRouterOnLink(Ptr< NetDevice > nd) const
Checks for the presence of another router on the NetDevice.
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Decide whether or not a given net device is being bridged by a BridgeNetDevice.
An interface aggregated to a node to provide global routing info.
Ipv4Address m_routerId
router ID (its IPv4 address)
Ipv4Address m_linkStateId
The Link State ID is defined by the OSPF spec.
void Set(uint32_t address)
input address is in host order.
Ipv4 addresses are stored in host order in this class.
void CopyLinkRecords(const GlobalRoutingLSA &lsa)
Copy any Global Routing Link Records in a given Global Routing Link State Advertisement to the curren...
GlobalRoutingLSA & operator=(const GlobalRoutingLSA &lsa)
Assignment operator for a Global Routing Link State Advertisement.
bool GetLSA(uint32_t n, GlobalRoutingLSA &lsa) const
Get a Global Routing Link State Advertisements that this router has said that it can export...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
uint32_t Get(void) const
Get the host-order 32-bit IP mask.
Record representing a point to point channel.
void SetNetworkLSANetworkMask(Ipv4Mask mask)
For a Network LSA, set the Network Mask field that precedes the list of attached routers.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
LinkType m_linkType
The type of the Global Routing Link Record.
uint32_t GetNAttachedRouters(void) const
Return the number of attached routers listed in the NetworkLSA.
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
uint32_t GetNLinkRecords(void) const
Return the number of Global Routing Link Records in the LSA.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
SPFStatus
Enumeration of the possible values of the status flag in the Routing Link State Advertisements.
GlobalRouter()
Create a Global Router class.
ListOfAttachedRouters_t m_attachedRouters
Each Network LSA contains a list of attached routers.
void ProcessPointToPointLink(Ptr< NetDevice > ndLocal, GlobalRoutingLSA *pLSA)
Process a point to point link.
Ipv4Address GetLinkStateId(void) const
Get the Link State ID as defined by the OSPF spec.
uint32_t GetNumLSAs(void) const
Get the Number of Global Routing Link State Advertisements that this router can export.
A base class which provides memory management and object aggregation.
Ptr< Node > GetNode(void) const
Get the Node pointer of the node that originated this LSA.
Ipv4Address GetAttachedRouter(uint32_t n) const
Return an Ipv4Address corresponding to the specified attached router.
GlobalRoutingLSA()
Create a blank Global Routing Link State Advertisement.
void ProcessBridgedBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a bridged broadcast link.
ListOfLinkRecords_t m_linkRecords
Each Link State Advertisement contains a number of Link Records that describe the kinds of links that...
a unique identifier for an interface.
Ipv4Address GetAdvertisingRouter(void) const
Get the Advertising Router as defined by the OSPF spec.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetLinkStateId(Ipv4Address addr)
Set the Link State ID is defined by the OSPF spec.
Ipv4Address m_linkId
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
bool IsEmpty(void) const
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Adve...
uint32_t GetNDevices(void) const
std::list< Ipv4RoutingTableEntry * >::iterator InjectedRoutesI
Iterator to container of Ipv4RoutingTableEntry.
void ProcessBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a generic broadcast link.