16#include "ns3/assert.h"
17#include "ns3/bridge-net-device.h"
18#include "ns3/channel.h"
20#include "ns3/net-device.h"
21#include "ns3/node-list.h"
38 : m_linkId(
"0.0.0.0"),
39 m_linkData(
"0.0.0.0"),
127 m_linkStateId(
"0.0.0.0"),
128 m_advertisingRtr(
"0.0.0.0"),
130 m_networkLSANetworkMask(
"0.0.0.0"),
142 m_linkStateId(linkStateId),
143 m_advertisingRtr(advertisingRtr),
145 m_networkLSANetworkMask(
"0.0.0.0"),
154 : m_lsType(lsa.m_lsType),
155 m_linkStateId(lsa.m_linkStateId),
156 m_advertisingRtr(lsa.m_advertisingRtr),
157 m_networkLSANetworkMask(lsa.m_networkLSANetworkMask),
158 m_status(lsa.m_status),
159 m_node_id(lsa.m_node_id)
162 NS_ASSERT_MSG(
IsEmpty(),
"GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor");
253 NS_ASSERT_MSG(
false,
"GlobalRoutingLSA::GetLinkRecord (): invalid index");
354 NS_ASSERT_MSG(
false,
"GlobalRoutingLSA::GetAttachedRouter (): invalid index");
384 os <<
"========== Global Routing LSA ==========" << std::endl;
388 os <<
" (GlobalRoutingLSA::RouterLSA)";
392 os <<
" (GlobalRoutingLSA::NetworkLSA)";
396 os <<
" (GlobalRoutingLSA::ASExternalLSA)";
400 os <<
"(Unknown LSType)";
404 os <<
"m_linkStateId = " <<
m_linkStateId <<
" (Router ID)" << std::endl;
405 os <<
"m_advertisingRtr = " <<
m_advertisingRtr <<
" (Router ID)" << std::endl;
413 os <<
"---------- RouterLSA Link Record ----------" << std::endl;
417 os <<
" (GlobalRoutingLinkRecord::PointToPoint)" << std::endl;
418 os <<
"m_linkId = " << p->
m_linkId << std::endl;
419 os <<
"m_linkData = " << p->
m_linkData << std::endl;
420 os <<
"m_metric = " << p->
m_metric << std::endl;
424 os <<
" (GlobalRoutingLinkRecord::TransitNetwork)" << std::endl;
425 os <<
"m_linkId = " << p->
m_linkId <<
" (Designated router for network)"
427 os <<
"m_linkData = " << p->
m_linkData <<
" (This router's IP address)"
429 os <<
"m_metric = " << p->
m_metric << std::endl;
433 os <<
" (GlobalRoutingLinkRecord::StubNetwork)" << std::endl;
434 os <<
"m_linkId = " << p->
m_linkId <<
" (Network number of attached network)"
436 os <<
"m_linkData = " << p->
m_linkData <<
" (Network mask of attached network)"
438 os <<
"m_metric = " << p->
m_metric << std::endl;
442 os <<
" (Unknown LinkType)" << std::endl;
443 os <<
"m_linkId = " << p->
m_linkId << std::endl;
444 os <<
"m_linkData = " << p->
m_linkData << std::endl;
445 os <<
"m_metric = " << p->
m_metric << std::endl;
447 os <<
"---------- End RouterLSA Link Record ----------" << std::endl;
452 os <<
"---------- NetworkLSA Link Record ----------" << std::endl;
457 os <<
"attachedRouter = " << p << std::endl;
459 os <<
"---------- End NetworkLSA Link Record ----------" << std::endl;
463 os <<
"---------- ASExternalLSA Link Record --------" << std::endl;
471 os <<
"========== End Global Routing LSA ==========" << std::endl;
573 "GlobalRouter::DiscoverLSAs (): GetObject for <Node> interface failed");
592 "GlobalRouter::DiscoverLSAs (): GetObject for <Ipv4> interface failed");
610 uint32_t numDevices = node->GetNDevices();
616 for (
uint32_t i = 0; i < numDevices; ++i)
632 int32_t ifIndex = ipv4Local->GetInterfaceForDevice(ndLocal);
635 "GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index");
644 int32_t interfaceNumber = ipv4Local->GetInterfaceForDevice(ndLocal);
645 if (interfaceNumber == -1 ||
646 !(ipv4Local->IsUp(interfaceNumber) && ipv4Local->IsForwarding(interfaceNumber)))
650 <<
"has no IP interface or is not enabled for forwarding, skipping");
664 if (ndLocal->IsBroadcast() && !ndLocal->IsPointToPoint())
669 else if (ndLocal->IsPointToPoint())
676 NS_ASSERT_MSG(0,
"GlobalRouter::DiscoverLSAs (): unknown link type");
680 NS_LOG_LOGIC(
"========== LSA for node " << node->GetId() <<
" ==========");
690 if (nDesignatedRouters > 0)
704 pLSA->SetLinkStateId((*i)->GetDestNetwork());
706 pLSA->SetNetworkLSANetworkMask((*i)->GetDestNetworkMask());
737 "GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record");
751 "GlobalRouter::ProcessSingleBroadcastLink (): GetObject for <Ipv4> interface failed");
753 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice(nd);
755 interfaceLocal == -1,
756 "GlobalRouter::ProcessSingleBroadcastLink(): No interface index associated with device");
758 if (ipv4Local->GetNAddresses(interfaceLocal) > 1)
760 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
762 Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal();
763 Ipv4Mask maskLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetMask();
764 NS_LOG_LOGIC(
"Working with local address " << addrLocal);
765 uint16_t metricLocal = ipv4Local->GetMetric(interfaceLocal);
792 maskLocalAddr.
Set(maskLocal.
Get());
793 plr->SetLinkData(maskLocalAddr);
794 plr->SetMetric(metricLocal);
821 if (designatedRtr !=
"255.255.255.255")
826 networkHere == networkThere,
827 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion ("
828 << addrLocal <<
"/" << maskLocal.
GetPrefixLength() <<
", " << designatedRtr
831 if (designatedRtr == addrLocal)
834 NS_LOG_LOGIC(
"Node " << node->GetId() <<
" elected a designated router");
836 plr->SetLinkId(designatedRtr);
841 plr->SetLinkData(addrLocal);
842 plr->SetMetric(metricLocal);
855 "GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
869 NS_ABORT_MSG_UNLESS (bnd,
"GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
880 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessBridgedBroadcastLink (): GetObject for <Ipv4> interface failed");
882 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice (nd);
883 NS_ABORT_MSG_IF (interfaceLocal == -1,
"GlobalRouter::ProcessBridgedBroadcastLink(): No interface index associated with device");
885 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
887 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
889 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
890 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
891 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
892 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
903 bool areTransitNetwork =
false;
906 for (
uint32_t i = 0; i < bnd->GetNBridgePorts (); ++i)
918 areTransitNetwork =
true;
934 if (designatedRtrTemp !=
"255.255.255.255")
939 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion (" <<
943 if (designatedRtrTemp < designatedRtr)
945 designatedRtr = designatedRtrTemp;
955 NS_ABORT_MSG_IF (plr == 0,
"GlobalRouter::ProcessBridgedBroadcastLink(): Can't alloc link record");
957 if (areTransitNetwork ==
false)
975 maskLocalAddr.
Set (maskLocal.
Get ());
996 if (designatedRtr == addrLocal)
999 NS_LOG_LOGIC (
"Node " << node->GetId () <<
" elected a designated router");
1026 Ptr<Node> nodeLocal = ndLocal->GetNode();
1031 "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1033 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice(ndLocal);
1035 interfaceLocal == -1,
1036 "GlobalRouter::ProcessPointToPointLink (): No interface index associated with device");
1038 if (ipv4Local->GetNAddresses(interfaceLocal) > 1)
1040 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
1042 Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal();
1043 NS_LOG_LOGIC(
"Working with local address " << addrLocal);
1044 uint16_t metricLocal = ipv4Local->GetMetric(interfaceLocal);
1065 Ptr<Node> nodeRemote = ndRemote->GetNode();
1069 "GlobalRouter::ProcessPointToPointLink(): GetObject for remote <Ipv4> failed");
1085 Ipv4Address rtrIdRemote = rtrRemote->GetRouterId();
1086 NS_LOG_LOGIC(
"Working with remote router " << rtrIdRemote);
1092 int32_t interfaceRemote = ipv4Remote->GetInterfaceForDevice(ndRemote);
1094 "GlobalRouter::ProcessPointToPointLinks(): No interface index associated with "
1101 if (ipv4Remote->GetNAddresses(interfaceRemote) > 1)
1103 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
1105 Ipv4Address addrRemote = ipv4Remote->GetAddress(interfaceRemote, 0).GetLocal();
1106 Ipv4Mask maskRemote = ipv4Remote->GetAddress(interfaceRemote, 0).GetMask();
1107 NS_LOG_LOGIC(
"Working with remote address " << addrRemote);
1115 if (ipv4Remote->IsUp(interfaceRemote))
1117 NS_LOG_LOGIC(
"Remote side interface " << interfaceRemote <<
" is up-- add a type 1 link");
1121 "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1133 "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1148 NS_LOG_DEBUG(
"Number of designated routers: " << nDesignatedRouters);
1150 for (
uint32_t i = 0; i < nDesignatedRouters; ++i)
1162 "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1164 int32_t interfaceLocal = ipv4Local->GetInterfaceForDevice(ndLocal);
1166 interfaceLocal == -1,
1167 "GlobalRouter::BuildNetworkLSAs (): No interface index associated with device");
1169 if (ipv4Local->GetNAddresses(interfaceLocal) > 1)
1171 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the primary one");
1173 Ipv4Address addrLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetLocal();
1174 Ipv4Mask maskLocal = ipv4Local->GetAddress(interfaceLocal, 0).GetMask();
1178 "GlobalRouter::BuildNetworkLSAs(): Can't alloc link record");
1181 pLSA->SetLinkStateId(addrLocal);
1183 pLSA->SetNetworkLSANetworkMask(maskLocal);
1185 pLSA->SetNode(node);
1194 std::size_t nDevices = ch->GetNDevices();
1197 NS_LOG_LOGIC(
"Found " << deviceList.
GetN() <<
" non-bridged devices on channel");
1203 if (tempNd == ndLocal)
1205 NS_LOG_LOGIC(
"Adding " << addrLocal <<
" to Network LSA");
1206 pLSA->AddAttachedRouter(addrLocal);
1218 <<
" does not have GlobalRouter interface--skipping");
1227 int32_t tempInterface = tempIpv4->GetInterfaceForDevice(tempNd);
1229 if (tempInterface != -1)
1233 if (!tempIpv4->IsUp(tempInterface))
1235 NS_LOG_LOGIC(
"Remote side interface " << tempInterface <<
" not up");
1239 if (tempIpv4->GetNAddresses(tempInterface) > 1)
1241 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the "
1244 Ipv4Address tempAddr = tempIpv4->GetAddress(tempInterface, 0).GetLocal();
1245 NS_LOG_LOGIC(
"Adding " << tempAddr <<
" to Network LSA");
1246 pLSA->AddAttachedRouter(tempAddr);
1251 NS_LOG_LOGIC(
"Node " << tempNode->GetId() <<
" device " << tempNd
1252 <<
" does not have IPv4 interface; skipping");
1256 NS_LOG_LOGIC(
"========== LSA for node " << node->GetId() <<
" ==========");
1268 for (std::size_t i = 0; i < ch->GetNDevices(); i++)
1271 NS_LOG_LOGIC(
"checking to see if the device " << nd <<
" is bridged");
1276 << bnd <<
" with " << bnd->GetNBridgePorts() <<
" ports");
1280 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); j++)
1283 if (bridgedDevice->GetChannel() == ch)
1288 NS_LOG_LOGIC(
"Calling on channel " << bridgedDevice->GetChannel());
1314 uint32_t nDevices = ch->GetNDevices();
1317 NS_LOG_LOGIC(
"Looking for designated router off of net device " << ndLocal <<
" on node "
1318 << ndLocal->GetNode()->GetId());
1326 for (
uint32_t i = 0; i < nDevices; i++)
1331 Ptr<Node> nodeOther = ndOther->GetNode();
1333 NS_LOG_LOGIC(
"Examine channel device " << i <<
" on node " << nodeOther->GetId());
1341 NS_LOG_LOGIC(
"checking to see if the device is bridged");
1345 NS_LOG_LOGIC(
"Device is bridged by BridgeNetDevice " << bnd);
1350 if (ndLocal == ndOther)
1365 NS_LOG_LOGIC(
"Checking for router on bridge net device " << bnd);
1370 int32_t interfaceOther = ipv4->GetInterfaceForDevice(bnd);
1371 if (interfaceOther != -1)
1373 NS_LOG_LOGIC(
"Found router on bridge net device " << bnd);
1374 if (!ipv4->IsUp(interfaceOther))
1376 NS_LOG_LOGIC(
"Remote side interface " << interfaceOther <<
" not up");
1379 if (ipv4->GetNAddresses(interfaceOther) > 1)
1381 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the "
1384 Ipv4Address addrOther = ipv4->GetAddress(interfaceOther, 0).GetLocal();
1385 designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr;
1386 NS_LOG_LOGIC(
"designated router now " << designatedRtr);
1403 NS_LOG_LOGIC(
"Looking through bridge ports of bridge net device " << bnd);
1404 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
1407 NS_LOG_LOGIC(
"Examining bridge port " << j <<
" device " << ndBridged);
1408 if (ndBridged == ndOther)
1410 NS_LOG_LOGIC(
"That bridge port is me, don't walk backward");
1414 NS_LOG_LOGIC(
"Recursively looking for routers down bridge port " << ndBridged);
1416 designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr;
1417 NS_LOG_LOGIC(
"designated router now " << designatedRtr);
1423 Ptr<Node> nodeOther = ndOther->GetNode();
1434 int32_t interfaceOther = ipv4->GetInterfaceForDevice(ndOther);
1435 if (interfaceOther != -1)
1437 if (!ipv4->IsUp(interfaceOther))
1439 NS_LOG_LOGIC(
"Remote side interface " << interfaceOther <<
" not up");
1442 NS_LOG_LOGIC(
"Found router on net device " << ndOther);
1443 if (ipv4->GetNAddresses(interfaceOther) > 1)
1445 NS_LOG_WARN(
"Warning, interface has multiple IP addresses; using only the "
1448 Ipv4Address addrOther = ipv4->GetAddress(interfaceOther, 0).GetLocal();
1449 designatedRtr = addrOther < designatedRtr ? addrOther : designatedRtr;
1450 NS_LOG_LOGIC(
"designated router now " << designatedRtr);
1455 return designatedRtr;
1475 uint32_t nDevices = ch->GetNDevices();
1478 NS_LOG_LOGIC(
"Looking for routers off of net device " << nd <<
" on node "
1479 << nd->GetNode()->GetId());
1485 for (
uint32_t i = 0; i < nDevices; i++)
1490 NS_LOG_LOGIC(
"Examine channel device " << i <<
" on node " << ndOther->GetNode()->GetId());
1511 NS_LOG_LOGIC(
"Device is bridged by net device " << bnd);
1526 NS_LOG_LOGIC(
"Looking through bridge ports of bridge net device " << bnd);
1527 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
1530 NS_LOG_LOGIC(
"Examining bridge port " << j <<
" device " << ndBridged);
1531 if (ndBridged == ndOther)
1537 NS_LOG_LOGIC(
"Recursively looking for routers on bridge port " << ndBridged);
1540 NS_LOG_LOGIC(
"Found routers on bridge port, return true");
1544 NS_LOG_LOGIC(
"No routers on bridged net device, return false");
1549 Ptr<Node> nodeTemp = ndOther->GetNode();
1555 NS_LOG_LOGIC(
"Found GlobalRouter interface, return true");
1560 NS_LOG_LOGIC(
"No GlobalRouter interface on device, continue search");
1590 for (; i !=
m_LSAs.end(); i++, j++)
1668 if ((*i)->GetDestNetwork() == network && (*i)->GetDestNetworkMask() == networkMask)
1670 NS_LOG_LOGIC(
"Withdrawing route to network/mask " << network <<
"/" << networkMask);
1688 "GlobalRouter::GetAdjacent (): Channel with other than two devices");
1709 NS_ASSERT_MSG(
false,
"GlobalRouter::GetAdjacent (): Wrong or confused channel?");
1723 uint32_t nDevices = node->GetNDevices();
1731 for (
uint32_t i = 0; i < nDevices; ++i)
1736 if (ndTest->IsBridge())
1738 NS_LOG_LOGIC(
"device " << i <<
" is a bridge net device");
1742 "GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
1744 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
1746 NS_LOG_LOGIC(
"Examine bridge port " << j <<
" " << bnd->GetBridgePort(j));
1747 if (bnd->GetBridgePort(j) == nd)
1749 NS_LOG_LOGIC(
"Net device " << nd <<
" is bridged by " << bnd);
1755 NS_LOG_LOGIC(
"Net device " << nd <<
" is not bridged");
1776 if (bridgeNetDevice == *iter)
1778 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.
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.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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)
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.