27#include "ns3/assert.h"
28#include "ns3/bridge-net-device.h"
29#include "ns3/channel.h"
31#include "ns3/net-device.h"
32#include "ns3/node-list.h"
49 : m_linkId(
"0.0.0.0"),
50 m_linkData(
"0.0.0.0"),
138 m_linkStateId(
"0.0.0.0"),
139 m_advertisingRtr(
"0.0.0.0"),
141 m_networkLSANetworkMask(
"0.0.0.0"),
153 m_linkStateId(linkStateId),
154 m_advertisingRtr(advertisingRtr),
156 m_networkLSANetworkMask(
"0.0.0.0"),
165 : m_lsType(lsa.m_lsType),
166 m_linkStateId(lsa.m_linkStateId),
167 m_advertisingRtr(lsa.m_advertisingRtr),
168 m_networkLSANetworkMask(lsa.m_networkLSANetworkMask),
169 m_status(lsa.m_status),
170 m_node_id(lsa.m_node_id)
173 NS_ASSERT_MSG(
IsEmpty(),
"GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor");
196 for (ListOfLinkRecords_t::const_iterator i = lsa.
m_linkRecords.begin();
267 NS_ASSERT_MSG(
false,
"GlobalRoutingLSA::GetLinkRecord (): invalid index");
370 NS_ASSERT_MSG(
false,
"GlobalRoutingLSA::GetAttachedRouter (): invalid index");
400 os <<
"========== Global Routing LSA ==========" << std::endl;
404 os <<
" (GlobalRoutingLSA::RouterLSA)";
408 os <<
" (GlobalRoutingLSA::NetworkLSA)";
412 os <<
" (GlobalRoutingLSA::ASExternalLSA)";
416 os <<
"(Unknown LSType)";
420 os <<
"m_linkStateId = " <<
m_linkStateId <<
" (Router ID)" << std::endl;
421 os <<
"m_advertisingRtr = " <<
m_advertisingRtr <<
" (Router ID)" << std::endl;
425 for (ListOfLinkRecords_t::const_iterator i =
m_linkRecords.begin();
431 os <<
"---------- RouterLSA Link Record ----------" << std::endl;
435 os <<
" (GlobalRoutingLinkRecord::PointToPoint)" << std::endl;
436 os <<
"m_linkId = " << p->
m_linkId << std::endl;
437 os <<
"m_linkData = " << p->
m_linkData << std::endl;
438 os <<
"m_metric = " << p->
m_metric << std::endl;
442 os <<
" (GlobalRoutingLinkRecord::TransitNetwork)" << std::endl;
443 os <<
"m_linkId = " << p->
m_linkId <<
" (Designated router for network)"
445 os <<
"m_linkData = " << p->
m_linkData <<
" (This router's IP address)"
447 os <<
"m_metric = " << p->
m_metric << std::endl;
451 os <<
" (GlobalRoutingLinkRecord::StubNetwork)" << std::endl;
452 os <<
"m_linkId = " << p->
m_linkId <<
" (Network number of attached network)"
454 os <<
"m_linkData = " << p->
m_linkData <<
" (Network mask of attached network)"
456 os <<
"m_metric = " << p->
m_metric << std::endl;
460 os <<
" (Unknown LinkType)" << std::endl;
461 os <<
"m_linkId = " << p->
m_linkId << std::endl;
462 os <<
"m_linkData = " << p->
m_linkData << std::endl;
463 os <<
"m_metric = " << p->
m_metric << std::endl;
465 os <<
"---------- End RouterLSA Link Record ----------" << std::endl;
470 os <<
"---------- NetworkLSA Link Record ----------" << std::endl;
477 os <<
"attachedRouter = " << p << std::endl;
479 os <<
"---------- End NetworkLSA Link Record ----------" << std::endl;
483 os <<
"---------- ASExternalLSA Link Record --------" << std::endl;
491 os <<
"========== End Global Routing LSA ==========" << std::endl;
560 for (ListOfLSAs_t::iterator i =
m_LSAs.begin(); i !=
m_LSAs.end(); i++)
593 "GlobalRouter::DiscoverLSAs (): GetObject for <Node> interface failed");
612 "GlobalRouter::DiscoverLSAs (): GetObject for <Ipv4> interface failed");
630 uint32_t numDevices = node->GetNDevices();
636 for (
uint32_t i = 0; i < numDevices; ++i)
640 if (DynamicCast<LoopbackNetDevice>(ndLocal))
652 int32_t ifIndex = ipv4Local->GetInterfaceForDevice(ndLocal);
655 "GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index");
664 int32_t interfaceNumber = ipv4Local->GetInterfaceForDevice(ndLocal);
665 if (interfaceNumber == -1 ||
666 !(ipv4Local->IsUp(interfaceNumber) && ipv4Local->IsForwarding(interfaceNumber)))
670 <<
"has no IP interface or is not enabled for forwarding, skipping");
684 if (ndLocal->IsBroadcast() && !ndLocal->IsPointToPoint())
689 else if (ndLocal->IsPointToPoint())
696 NS_ASSERT_MSG(0,
"GlobalRouter::DiscoverLSAs (): unknown link type");
700 NS_LOG_LOGIC(
"========== LSA for node " << node->GetId() <<
" ==========");
710 if (nDesignatedRouters > 0)
757 "GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record");
771 "GlobalRouter::ProcessSingleBroadcastLink (): GetObject for <Ipv4> interface failed");
773 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice(nd);
775 interfaceLocal == -1,
776 "GlobalRouter::ProcessSingleBroadcastLink(): No interface index associated with device");
778 if (ipv4Local->GetNAddresses(interfaceLocal) > 1)
780 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
782 Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal();
783 Ipv4Mask maskLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetMask();
784 NS_LOG_LOGIC(
"Working with local address " << addrLocal);
785 uint16_t metricLocal = ipv4Local->GetMetric(interfaceLocal);
812 maskLocalAddr.
Set(maskLocal.
Get());
841 if (designatedRtr !=
"255.255.255.255")
846 networkHere == networkThere,
847 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion ("
848 << addrLocal <<
"/" << maskLocal.
GetPrefixLength() <<
", " << designatedRtr
851 if (designatedRtr == addrLocal)
854 NS_LOG_LOGIC(
"Node " << node->GetId() <<
" elected a designated router");
875 "GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
889 NS_ABORT_MSG_UNLESS (bnd,
"GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
900 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessBridgedBroadcastLink (): GetObject for <Ipv4> interface failed");
902 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice (nd);
903 NS_ABORT_MSG_IF (interfaceLocal == -1,
"GlobalRouter::ProcessBridgedBroadcastLink(): No interface index associated with device");
905 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
907 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
909 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
910 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
911 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
912 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
923 bool areTransitNetwork =
false;
926 for (
uint32_t i = 0; i < bnd->GetNBridgePorts (); ++i)
938 areTransitNetwork =
true;
954 if (designatedRtrTemp !=
"255.255.255.255")
959 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion (" <<
963 if (designatedRtrTemp < designatedRtr)
965 designatedRtr = designatedRtrTemp;
975 NS_ABORT_MSG_IF (plr == 0,
"GlobalRouter::ProcessBridgedBroadcastLink(): Can't alloc link record");
977 if (areTransitNetwork ==
false)
995 maskLocalAddr.
Set (maskLocal.
Get ());
1016 if (designatedRtr == addrLocal)
1019 NS_LOG_LOGIC (
"Node " << node->GetId () <<
" elected a designated router");
1046 Ptr<Node> nodeLocal = ndLocal->GetNode();
1051 "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1053 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice(ndLocal);
1055 interfaceLocal == -1,
1056 "GlobalRouter::ProcessPointToPointLink (): No interface index associated with device");
1058 if (ipv4Local->GetNAddresses(interfaceLocal) > 1)
1060 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
1062 Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal();
1063 NS_LOG_LOGIC(
"Working with local address " << addrLocal);
1064 uint16_t metricLocal = ipv4Local->GetMetric(interfaceLocal);
1085 Ptr<Node> nodeRemote = ndRemote->GetNode();
1089 "GlobalRouter::ProcessPointToPointLink(): GetObject for remote <Ipv4> failed");
1105 Ipv4Address rtrIdRemote = rtrRemote->GetRouterId();
1106 NS_LOG_LOGIC(
"Working with remote router " << rtrIdRemote);
1112 int32_t interfaceRemote = ipv4Remote->GetInterfaceForDevice(ndRemote);
1114 "GlobalRouter::ProcessPointToPointLinks(): No interface index associated with "
1121 if (ipv4Remote->GetNAddresses(interfaceRemote) > 1)
1123 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
1125 Ipv4Address addrRemote = ipv4Remote->GetAddress(interfaceRemote, 0).GetLocal();
1126 Ipv4Mask maskRemote = ipv4Remote->GetAddress(interfaceRemote, 0).GetMask();
1127 NS_LOG_LOGIC(
"Working with remote address " << addrRemote);
1135 if (ipv4Remote->IsUp(interfaceRemote))
1137 NS_LOG_LOGIC(
"Remote side interface " << interfaceRemote <<
" is up-- add a type 1 link");
1141 "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1153 "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1168 NS_LOG_DEBUG(
"Number of designated routers: " << nDesignatedRouters);
1170 for (
uint32_t i = 0; i < nDesignatedRouters; ++i)
1182 "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1184 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice(ndLocal);
1186 interfaceLocal == -1,
1187 "GlobalRouter::BuildNetworkLSAs (): No interface index associated with device");
1189 if (ipv4Local->GetNAddresses(interfaceLocal) > 1)
1191 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
1193 Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal();
1194 Ipv4Mask maskLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetMask();
1198 "GlobalRouter::BuildNetworkLSAs(): Can't alloc link record");
1214 std::size_t nDevices = ch->GetNDevices();
1217 NS_LOG_LOGIC(
"Found " << deviceList.
GetN() <<
" non-bridged devices on channel");
1223 if (tempNd == ndLocal)
1225 NS_LOG_LOGIC(
"Adding " << addrLocal <<
" to Network LSA");
1238 <<
" does not have GlobalRouter interface--skipping");
1247 int32_t tempInterface = tempIpv4->GetInterfaceForDevice(tempNd);
1249 if (tempInterface != -1)
1253 if (!tempIpv4->IsUp(tempInterface))
1255 NS_LOG_LOGIC(
"Remote side interface " << tempInterface <<
" not up");
1259 if (tempIpv4->GetNAddresses(tempInterface) > 1)
1261 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the "
1264 Ipv4Address tempAddr = tempIpv4->GetAddress(tempInterface, 0).GetLocal();
1265 NS_LOG_LOGIC(
"Adding " << tempAddr <<
" to Network LSA");
1271 NS_LOG_LOGIC(
"Node " << tempNode->GetId() <<
" device " << tempNd
1272 <<
" does not have IPv4 interface; skipping");
1276 NS_LOG_LOGIC(
"========== LSA for node " << node->GetId() <<
" ==========");
1288 for (std::size_t i = 0; i < ch->GetNDevices(); i++)
1291 NS_LOG_LOGIC(
"checking to see if the device " << nd <<
" is bridged");
1296 << bnd <<
" with " << bnd->GetNBridgePorts() <<
" ports");
1300 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); j++)
1303 if (bridgedDevice->GetChannel() == ch)
1308 NS_LOG_LOGIC(
"Calling on channel " << bridgedDevice->GetChannel());
1334 uint32_t nDevices = ch->GetNDevices();
1337 NS_LOG_LOGIC(
"Looking for designated router off of net device " << ndLocal <<
" on node "
1338 << ndLocal->GetNode()->GetId());
1346 for (
uint32_t i = 0; i < nDevices; i++)
1351 Ptr<Node> nodeOther = ndOther->GetNode();
1353 NS_LOG_LOGIC(
"Examine channel device " << i <<
" on node " << nodeOther->GetId());
1361 NS_LOG_LOGIC(
"checking to see if the device is bridged");
1365 NS_LOG_LOGIC(
"Device is bridged by BridgeNetDevice " << bnd);
1370 if (ndLocal == ndOther)
1385 NS_LOG_LOGIC(
"Checking for router on bridge net device " << bnd);
1390 int32_t interfaceOther = ipv4->GetInterfaceForDevice(bnd);
1391 if (interfaceOther != -1)
1393 NS_LOG_LOGIC(
"Found router on bridge net device " << bnd);
1394 if (!ipv4->IsUp(interfaceOther))
1396 NS_LOG_LOGIC(
"Remote side interface " << interfaceOther <<
" not up");
1399 if (ipv4->GetNAddresses(interfaceOther) > 1)
1401 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the "
1404 Ipv4Address addrOther = ipv4->GetAddress(interfaceOther, 0).GetLocal();
1405 designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr;
1406 NS_LOG_LOGIC(
"designated router now " << designatedRtr);
1423 NS_LOG_LOGIC(
"Looking through bridge ports of bridge net device " << bnd);
1424 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
1427 NS_LOG_LOGIC(
"Examining bridge port " << j <<
" device " << ndBridged);
1428 if (ndBridged == ndOther)
1430 NS_LOG_LOGIC(
"That bridge port is me, don't walk backward");
1434 NS_LOG_LOGIC(
"Recursively looking for routers down bridge port " << ndBridged);
1436 designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr;
1437 NS_LOG_LOGIC(
"designated router now " << designatedRtr);
1443 Ptr<Node> nodeOther = ndOther->GetNode();
1454 int32_t interfaceOther = ipv4->GetInterfaceForDevice(ndOther);
1455 if (interfaceOther != -1)
1457 if (!ipv4->IsUp(interfaceOther))
1459 NS_LOG_LOGIC(
"Remote side interface " << interfaceOther <<
" not up");
1462 NS_LOG_LOGIC(
"Found router on net device " << ndOther);
1463 if (ipv4->GetNAddresses(interfaceOther) > 1)
1465 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the "
1468 Ipv4Address addrOther = ipv4->GetAddress(interfaceOther, 0).GetLocal();
1469 designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr;
1470 NS_LOG_LOGIC(
"designated router now " << designatedRtr);
1475 return designatedRtr;
1495 uint32_t nDevices = ch->GetNDevices();
1498 NS_LOG_LOGIC(
"Looking for routers off of net device " << nd <<
" on node "
1499 << nd->GetNode()->GetId());
1505 for (
uint32_t i = 0; i < nDevices; i++)
1510 NS_LOG_LOGIC(
"Examine channel device " << i <<
" on node " << ndOther->GetNode()->GetId());
1531 NS_LOG_LOGIC(
"Device is bridged by net device " << bnd);
1546 NS_LOG_LOGIC(
"Looking through bridge ports of bridge net device " << bnd);
1547 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
1550 NS_LOG_LOGIC(
"Examining bridge port " << j <<
" device " << ndBridged);
1551 if (ndBridged == ndOther)
1557 NS_LOG_LOGIC(
"Recursively looking for routers on bridge port " << ndBridged);
1560 NS_LOG_LOGIC(
"Found routers on bridge port, return true");
1564 NS_LOG_LOGIC(
"No routers on bridged net device, return false");
1569 Ptr<Node> nodeTemp = ndOther->GetNode();
1575 NS_LOG_LOGIC(
"Found GlobalRouter interface, return true");
1580 NS_LOG_LOGIC(
"No GlobalRouter interface on device, continue search");
1607 ListOfLSAs_t::const_iterator i =
m_LSAs.begin();
1610 for (; i !=
m_LSAs.end(); i++, j++)
1688 if ((*i)->GetDestNetwork() == network && (*i)->GetDestNetworkMask() == networkMask)
1690 NS_LOG_LOGIC(
"Withdrawing route to network/mask " << network <<
"/" << networkMask);
1708 "GlobalRouter::GetAdjacent (): Channel with other than two devices");
1729 NS_ASSERT_MSG(
false,
"GlobalRouter::GetAdjacent (): Wrong or confused channel?");
1743 uint32_t nDevices = node->GetNDevices();
1751 for (
uint32_t i = 0; i < nDevices; ++i)
1756 if (ndTest->IsBridge())
1758 NS_LOG_LOGIC(
"device " << i <<
" is a bridge net device");
1762 "GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
1764 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
1766 NS_LOG_LOGIC(
"Examine bridge port " << j <<
" " << bnd->GetBridgePort(j));
1767 if (bnd->GetBridgePort(j) == nd)
1769 NS_LOG_LOGIC(
"Net device " << nd <<
" is bridged by " << bnd);
1775 NS_LOG_LOGIC(
"Net device " << nd <<
" is not bridged");
1794 std::vector<Ptr<BridgeNetDevice>>::iterator iter;
1797 if (bridgeNetDevice == *iter)
1799 NS_LOG_LOGIC(
"Bridge " << bridgeNetDevice <<
" has been visited.");
a virtual net device that bridges multiple LAN segments
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
An interface aggregated to a node to provide global routing info.
Ipv4Address FindDesignatedRouterForLink(Ptr< NetDevice > ndLocal) const
Finds a designated router.
void MarkBridgeAsVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, mark a given device as having been visited.
Ptr< Ipv4GlobalRouting > m_routingProtocol
the Ipv4GlobalRouting in use
bool GetLSA(uint32_t n, GlobalRoutingLSA &lsa) const
Get a Global Routing Link State Advertisements that this router has said that it can export.
void ProcessSingleBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a single broadcast link.
bool WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask)
Withdraw a route from the global unicast routing table.
NetDeviceContainer FindAllNonBridgedDevicesOnLink(Ptr< Channel > ch) const
Return a container of all non-bridged NetDevices on a link.
bool BridgeHasAlreadyBeenVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, check whether a given device has already been visi...
InjectedRoutes m_injectedRoutes
Routes we are exporting.
void ClearBridgesVisited() const
Clear the list of bridges visited on the link.
void InjectRoute(Ipv4Address network, Ipv4Mask networkMask)
Inject a route to be circulated to other routers as an external route.
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Decide whether or not a given net device is being bridged by a BridgeNetDevice.
Ipv4Address GetRouterId() const
Get the Router ID associated with this Global Router.
uint32_t GetNumLSAs() const
Get the Number of Global Routing Link State Advertisements that this router can export.
ListOfLSAs_t m_LSAs
database of GlobalRoutingLSAs
void ProcessBridgedBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a bridged broadcast link.
GlobalRouter()
Create a Global Router class.
Ipv4RoutingTableEntry * GetInjectedRoute(uint32_t i)
Return the injected route indexed by i.
std::list< Ipv4RoutingTableEntry * >::iterator InjectedRoutesI
Iterator to container of Ipv4RoutingTableEntry.
void ClearLSAs()
Clear list of LSAs.
static TypeId GetTypeId()
Get the type ID.
Ptr< Ipv4GlobalRouting > GetRoutingProtocol()
Get the specific Global Routing Protocol used.
Ipv4Address m_routerId
router ID (its IPv4 address)
void RemoveInjectedRoute(uint32_t i)
Withdraw a route from the global unicast routing table.
bool AnotherRouterOnLink(Ptr< NetDevice > nd) const
Checks for the presence of another router on the NetDevice.
std::list< Ipv4RoutingTableEntry * >::const_iterator InjectedRoutesCI
Const Iterator to container of Ipv4RoutingTableEntry.
void SetRoutingProtocol(Ptr< Ipv4GlobalRouting > routing)
Set the specific Global Routing Protocol to be used.
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.
std::vector< Ptr< BridgeNetDevice > > m_bridgesVisited
Container of bridges visited.
void ProcessPointToPointLink(Ptr< NetDevice > ndLocal, GlobalRoutingLSA *pLSA)
Process a point to point link.
uint32_t DiscoverLSAs()
Walk the connected channels, discover the adjacent routers and build the associated number of Global ...
void DoDispose() override
Destructor implementation.
void ProcessBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a generic broadcast link.
uint32_t GetNInjectedRoutes()
Get the number of injected routes that have been added to the routing table.
void BuildNetworkLSAs(NetDeviceContainer c)
Build one NetworkLSA for each net device talking to a network that we are the designated router for.
a Link State Advertisement (LSA) for a router, used in global routing.
Ipv4Address GetAdvertisingRouter() const
Get the Advertising Router as defined by the OSPF spec.
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
uint32_t m_node_id
node ID
void Print(std::ostream &os) const
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records...
SPFStatus
Enumeration of the possible values of the status flag in the Routing Link State Advertisements.
@ LSA_SPF_NOT_EXPLORED
New vertex not yet considered.
uint32_t GetNAttachedRouters() const
Return the number of attached routers listed in the NetworkLSA.
Ptr< Node > GetNode() const
Get the Node pointer of the node that originated this LSA.
uint32_t AddLinkRecord(GlobalRoutingLinkRecord *lr)
Add a given Global Routing Link Record to the LSA.
LSType
corresponds to LS type field of RFC 2328 OSPF LSA header
SPFStatus GetStatus() const
Get the SPF status of the advertisement.
Ipv4Address m_linkStateId
The Link State ID is defined by the OSPF spec.
bool IsEmpty() const
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Adve...
Ipv4Mask GetNetworkLSANetworkMask() const
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
GlobalRoutingLSA()
Create a blank Global Routing Link State Advertisement.
ListOfLinkRecords_t m_linkRecords
Each Link State Advertisement contains a number of Link Records that describe the kinds of links that...
Ipv4Address GetAttachedRouter(uint32_t n) const
Return an Ipv4Address corresponding to the specified attached router.
void SetNode(Ptr< Node > node)
Set the Node pointer of the node that originated this LSA.
LSType GetLSType() const
Return the LSType field of the LSA.
uint32_t AddAttachedRouter(Ipv4Address addr)
Add an attached router to the list in the NetworkLSA.
uint32_t GetNLinkRecords() const
Return the number of Global Routing Link Records in the LSA.
~GlobalRoutingLSA()
Destroy an existing Global Routing Link State Advertisement.
Ipv4Address m_advertisingRtr
The Advertising Router is defined by the OSPF spec.
void SetLSType(LSType typ)
Set the LS type field of the LSA.
void ClearLinkRecords()
Release all of the Global Routing Link Records present in the Global Routing Link State Advertisement...
void SetAdvertisingRouter(Ipv4Address rtr)
Set the Advertising Router as defined by the OSPF spec.
SPFStatus m_status
This is a tristate flag used internally in the SPF computation to mark if an SPFVertex (a data struct...
LSType m_lsType
The type of the LSA.
ListOfAttachedRouters_t m_attachedRouters
Each Network LSA contains a list of attached routers.
GlobalRoutingLinkRecord * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
void SetNetworkLSANetworkMask(Ipv4Mask mask)
For a Network LSA, set the Network Mask field that precedes the list of attached routers.
Ipv4Mask m_networkLSANetworkMask
Each Network LSA contains the network mask of the attached network.
void CopyLinkRecords(const GlobalRoutingLSA &lsa)
Copy any Global Routing Link Records in a given Global Routing Link State Advertisement to the curren...
void SetLinkStateId(Ipv4Address addr)
Set the Link State ID is defined by the OSPF spec.
GlobalRoutingLSA & operator=(const GlobalRoutingLSA &lsa)
Assignment operator for a Global Routing Link State Advertisement.
Ipv4Address GetLinkStateId() const
Get the Link State ID as defined by the OSPF spec.
A single link record for a link state advertisement.
LinkType m_linkType
The type of the Global Routing Link Record.
LinkType GetLinkType() const
Get the Link Type field of the Global Routing Link Record.
void SetMetric(uint16_t metric)
Set the Metric Data field of the Global Routing Link Record.
void SetLinkId(Ipv4Address addr)
Set the Link ID field of the Global Routing Link Record.
Ipv4Address m_linkId
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
Ipv4Address GetLinkId() const
Get the Link ID 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 ...
uint16_t GetMetric() const
Get the Metric Data field of the Global Routing Link Record.
void SetLinkData(Ipv4Address addr)
Set the Link Data field of the Global Routing Link Record.
Ipv4Address GetLinkData() const
Get the Link Data field of the Global Routing Link Record.
LinkType
Enumeration of the possible types of Global Routing Link Records.
@ StubNetwork
Record represents a leaf node network.
@ PointToPoint
Record representing a point to point channel.
@ TransitNetwork
Unused – for future OSPF compatibility
uint16_t m_metric
The metric for a given link.
GlobalRoutingLinkRecord()
Construct an empty ("uninitialized") Global Routing Link Record.
void SetLinkType(LinkType linkType)
Set the Link Type field of the Global Routing Link Record.
~GlobalRoutingLinkRecord()
Destroy a Global Routing Link Record.
Ipv4 addresses are stored in host order in this class.
void Set(uint32_t address)
input address is in host order.
Ipv4Address CombineMask(const Ipv4Mask &mask) const
Combine this address with a network mask.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to represent an Ipv4 address mask
uint16_t GetPrefixLength() const
uint32_t Get() const
Get the host-order 32-bit IP mask.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
static Ipv4RoutingTableEntry CreateNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
static Ptr< Node > GetNode(uint32_t n)
A base class which provides memory management and object aggregation.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)