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"
47 m_linkData (
"0.0.0.0"),
61 m_linkData (linkData),
62 m_linkType (linkType),
139 m_linkStateId (
"0.0.0.0"),
140 m_advertisingRtr (
"0.0.0.0"),
142 m_networkLSANetworkMask (
"0.0.0.0"),
143 m_attachedRouters (),
156 m_linkStateId (linkStateId),
157 m_advertisingRtr (advertisingRtr),
159 m_networkLSANetworkMask (
"0.0.0.0"),
160 m_attachedRouters (),
168 : m_lsType (lsa.m_lsType), m_linkStateId (lsa.m_linkStateId),
169 m_advertisingRtr (lsa.m_advertisingRtr),
170 m_networkLSANetworkMask (lsa.m_networkLSANetworkMask),
171 m_status (lsa.m_status),
172 m_node_id (lsa.m_node_id)
176 "GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor");
200 for (ListOfLinkRecords_t::const_iterator i = lsa.
m_linkRecords.begin ();
229 for ( ListOfLinkRecords_t::iterator i =
m_linkRecords.begin ();
265 for ( ListOfLinkRecords_t::const_iterator i =
m_linkRecords.begin ();
274 NS_ASSERT_MSG (
false,
"GlobalRoutingLSA::GetLinkRecord (): invalid index");
377 NS_ASSERT_MSG (
false,
"GlobalRoutingLSA::GetAttachedRouter (): invalid index");
407 os <<
"========== Global Routing LSA ==========" << std::endl;
411 os <<
" (GlobalRoutingLSA::RouterLSA)";
415 os <<
" (GlobalRoutingLSA::NetworkLSA)";
419 os <<
" (GlobalRoutingLSA::ASExternalLSA)";
423 os <<
"(Unknown LSType)";
427 os <<
"m_linkStateId = " <<
m_linkStateId <<
" (Router ID)" << std::endl;
428 os <<
"m_advertisingRtr = " <<
m_advertisingRtr <<
" (Router ID)" << std::endl;
432 for ( ListOfLinkRecords_t::const_iterator i =
m_linkRecords.begin ();
438 os <<
"---------- RouterLSA Link Record ----------" << std::endl;
442 os <<
" (GlobalRoutingLinkRecord::PointToPoint)" << 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;
449 os <<
" (GlobalRoutingLinkRecord::TransitNetwork)" << std::endl;
450 os <<
"m_linkId = " << p->
m_linkId <<
" (Designated router for network)" << std::endl;
451 os <<
"m_linkData = " << p->
m_linkData <<
" (This router's IP address)" << std::endl;
452 os <<
"m_metric = " << p->
m_metric << std::endl;
456 os <<
" (GlobalRoutingLinkRecord::StubNetwork)" << std::endl;
457 os <<
"m_linkId = " << p->
m_linkId <<
" (Network number of attached network)" << std::endl;
458 os <<
"m_linkData = " << p->
m_linkData <<
" (Network mask of attached network)" << std::endl;
459 os <<
"m_metric = " << p->
m_metric << std::endl;
463 os <<
" (Unknown LinkType)" << std::endl;
464 os <<
"m_linkId = " << p->
m_linkId << std::endl;
465 os <<
"m_linkData = " << p->
m_linkData << std::endl;
466 os <<
"m_metric = " << p->
m_metric << std::endl;
468 os <<
"---------- End RouterLSA Link Record ----------" << std::endl;
473 os <<
"---------- NetworkLSA Link Record ----------" << std::endl;
478 os <<
"attachedRouter = " << p << std::endl;
480 os <<
"---------- End NetworkLSA Link Record ----------" << std::endl;
484 os <<
"---------- ASExternalLSA Link Record --------" << std::endl;
492 os <<
"========== End Global Routing LSA ==========" << std::endl;
562 for ( ListOfLSAs_t::iterator i =
m_LSAs.begin ();
596 NS_ABORT_MSG_UNLESS (node,
"GlobalRouter::DiscoverLSAs (): GetObject for <Node> interface failed");
614 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::DiscoverLSAs (): GetObject for <Ipv4> interface failed");
638 for (uint32_t i = 0; i < numDevices; ++i)
650 uint32_t interfaceBridge = ipv4Local->GetNInterfaces () + 1;
652 NS_ABORT_MSG_IF (rc,
"GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index");
661 bool isForwarding =
false;
662 for (uint32_t j = 0; j < ipv4Local->GetNInterfaces (); ++j )
664 if (ipv4Local->GetNetDevice (j) == ndLocal && ipv4Local->IsUp (j) &&
665 ipv4Local->IsForwarding (j))
674 NS_LOG_LOGIC (
"Net device " << ndLocal <<
"has no IP interface or is not enabled for forwarding, skipping");
688 if (ndLocal->IsBroadcast () && !ndLocal->IsPointToPoint () )
693 else if (ndLocal->IsPointToPoint () )
700 NS_ASSERT_MSG (0,
"GlobalRouter::DiscoverLSAs (): unknown link type");
713 uint32_t nDesignatedRouters = c.
GetN ();
714 if (nDesignatedRouters > 0)
760 NS_ABORT_MSG_IF (plr == 0,
"GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record");
772 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessSingleBroadcastLink (): GetObject for <Ipv4> interface failed");
775 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
777 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessSingleBroadcastLink(): No interface index associated with device");
779 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
781 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
783 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
784 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
785 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
786 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
812 maskLocalAddr.
Set (maskLocal.
Get ());
839 if (desigRtr !=
"255.255.255.255")
844 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion");
846 if (desigRtr == addrLocal)
867 NS_ASSERT_MSG (nd->IsBridge (),
"GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
881 NS_ABORT_MSG_UNLESS (bnd,
"GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
892 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessBridgedBroadcastLink (): GetObject for <Ipv4> interface failed");
895 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
897 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessBridgedBroadcastLink(): No interface index associated with device");
899 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
901 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
903 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
904 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();;
905 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
906 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
917 bool areTransitNetwork =
false;
920 for (uint32_t i = 0; i < bnd->GetNBridgePorts (); ++i)
931 areTransitNetwork =
true;
946 if (desigRtrTemp !=
"255.255.255.255")
951 "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion");
953 if (desigRtrTemp < desigRtr)
955 desigRtr = desigRtrTemp;
965 NS_ABORT_MSG_IF (plr == 0,
"GlobalRouter::ProcessBridgedBroadcastLink(): Can't alloc link record");
967 if (areTransitNetwork ==
false)
985 maskLocalAddr.
Set (maskLocal.
Get ());
1006 if (desigRtr == addrLocal)
1036 Ptr<Node> nodeLocal = ndLocal->GetNode ();
1039 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1041 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
1043 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessPointToPointLink (): No interface index associated with device");
1045 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
1047 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1049 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
1050 NS_LOG_LOGIC (
"Working with local address " << addrLocal);
1051 uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
1072 Ptr<Node> nodeRemote = ndRemote->GetNode ();
1075 "GlobalRouter::ProcessPointToPointLink(): GetObject for remote <Ipv4> failed");
1091 Ipv4Address rtrIdRemote = rtrRemote->GetRouterId ();
1092 NS_LOG_LOGIC (
"Working with remote router " << rtrIdRemote);
1098 uint32_t interfaceRemote = ipv4Remote->GetNInterfaces () + 1;
1100 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::ProcessPointToPointLinks(): No interface index associated with remote device");
1106 if (ipv4Remote->GetNAddresses (interfaceRemote) > 1)
1108 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1110 Ipv4Address addrRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetLocal ();
1111 Ipv4Mask maskRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetMask ();
1112 NS_LOG_LOGIC (
"Working with remote address " << addrRemote);
1120 if (ipv4Remote->IsUp (interfaceRemote))
1122 NS_LOG_LOGIC (
"Remote side interface " << interfaceRemote <<
" is up-- add a type 1 link");
1125 NS_ABORT_MSG_IF (plr == 0,
"GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1136 NS_ABORT_MSG_IF (plr == 0,
"GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
1150 uint32_t nDesignatedRouters = c.
GetN ();
1152 for (uint32_t i = 0; i < nDesignatedRouters; ++i)
1162 NS_ABORT_MSG_UNLESS (ipv4Local,
"GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
1164 uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
1166 NS_ABORT_MSG_IF (rc ==
false,
"GlobalRouter::BuildNetworkLSAs (): No interface index associated with device");
1168 if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
1170 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1172 Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
1173 Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
1176 NS_ABORT_MSG_IF (pLSA == 0,
"GlobalRouter::BuildNetworkLSAs(): Can't alloc link record");
1191 uint32_t nDevices = ch->GetNDevices ();
1194 for (uint32_t i = 0; i < nDevices; i++)
1198 Ptr<Node> tempNode = tempNd->GetNode ();
1214 uint32_t tempInterface = 0;
1219 if (!tempIpv4->IsUp (tempInterface))
1221 NS_LOG_LOGIC (
"Remote side interface " << tempInterface <<
" not up");
1225 if (tempIpv4->GetNAddresses (tempInterface) > 1)
1227 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1229 Ipv4Address tempAddr = tempIpv4->GetAddress (tempInterface, 0).GetLocal ();
1251 uint32_t nDevices = ch->GetNDevices ();
1254 NS_LOG_LOGIC (
"Looking for designated router off of net device " << ndLocal <<
" on node " <<
1255 ndLocal->GetNode ()->GetId ());
1263 for (uint32_t i = 0; i < nDevices; i++)
1268 Ptr<Node> nodeOther = ndOther->GetNode ();
1270 NS_LOG_LOGIC (
"Examine channel device " << i <<
" on node " << nodeOther->
GetId ());
1278 NS_LOG_LOGIC (
"checking to see if the device is bridged");
1282 NS_LOG_LOGIC (
"Device is bridged by BridgeNetDevice " << bnd);
1293 NS_LOG_LOGIC (
"Checking for router on bridge net device " << bnd);
1302 NS_LOG_LOGIC (
"Found router on bridge net device " << bnd);
1303 if (!ipv4->IsUp (interfaceOther))
1305 NS_LOG_LOGIC (
"Remote side interface " << interfaceOther <<
" not up");
1308 if (ipv4->GetNAddresses (interfaceOther) > 1)
1310 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1312 Ipv4Address addrOther = ipv4->GetAddress (interfaceOther, 0).GetLocal ();
1313 desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
1318 NS_LOG_LOGIC (
"Looking through bridge ports of bridge net device " << bnd);
1319 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
1322 NS_LOG_LOGIC (
"Examining bridge port " << j <<
" device " << ndBridged);
1323 if (ndBridged == ndOther)
1325 NS_LOG_LOGIC (
"That bridge port is me, don't walk backward");
1331 NS_LOG_LOGIC (
"Recursively looking for routers down bridge port " << ndBridged);
1333 desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
1341 Ptr<Node> nodeOther = ndOther->GetNode ();
1356 if (!ipv4->IsUp (interfaceOther))
1358 NS_LOG_LOGIC (
"Remote side interface " << interfaceOther <<
" not up");
1361 NS_LOG_LOGIC (
"Found router on net device " << ndOther);
1362 if (ipv4->GetNAddresses (interfaceOther) > 1)
1364 NS_LOG_WARN (
"Warning, interface has multiple IP addresses; using only the primary one");
1366 Ipv4Address addrOther = ipv4->GetAddress (interfaceOther, 0).GetLocal ();
1367 desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
1393 uint32_t nDevices = ch->GetNDevices ();
1396 NS_LOG_LOGIC (
"Looking for routers off of net device " << nd <<
" on node " << nd->GetNode ()->GetId ());
1402 for (uint32_t i = 0; i < nDevices; i++)
1407 NS_LOG_LOGIC (
"Examine channel device " << i <<
" on node " << ndOther->GetNode ()->GetId ());
1428 NS_LOG_LOGIC (
"Device is bridged by net device " << bnd);
1429 NS_LOG_LOGIC (
"Looking through bridge ports of bridge net device " << bnd);
1430 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
1433 NS_LOG_LOGIC (
"Examining bridge port " << j <<
" device " << ndBridged);
1434 if (ndBridged == ndOther)
1442 NS_LOG_LOGIC (
"Recursively looking for routers on bridge port " << ndBridged);
1445 NS_LOG_LOGIC (
"Found routers on bridge port, return true");
1450 NS_LOG_LOGIC (
"No routers on bridged net device, return false");
1455 Ptr<Node> nodeTemp = ndOther->GetNode ();
1461 NS_LOG_LOGIC (
"Found GlobalRouter interface, return true");
1466 NS_LOG_LOGIC (
"No GlobalRouter interface on device, continue search");
1493 ListOfLSAs_t::const_iterator i =
m_LSAs.begin ();
1496 for (; i !=
m_LSAs.end (); i++, j++)
1578 if ((*i)->GetDestNetwork () == network && (*i)->GetDestNetworkMask () == networkMask)
1580 NS_LOG_LOGIC (
"Withdrawing route to network/mask " << network <<
"/" << networkMask);
1598 NS_ASSERT_MSG (ch->GetNDevices () == 2,
"GlobalRouter::GetAdjacent (): Channel with other than two devices");
1620 "GlobalRouter::GetAdjacent (): Wrong or confused channel?");
1645 for (uint32_t i = 0; i < ipv4->GetNInterfaces (); ++i )
1647 if (ipv4->GetNetDevice (i) == nd)
1649 NS_LOG_LOGIC (
"Device " << nd <<
" has associated ipv4 index " << i);
1655 NS_LOG_LOGIC (
"Device " << nd <<
" has no associated ipv4 index");
1676 for (uint32_t i = 0; i < nDevices; ++i)
1679 NS_LOG_LOGIC (
"Examine device " << i <<
" " << ndTest);
1681 if (ndTest->IsBridge ())
1683 NS_LOG_LOGIC (
"device " << i <<
" is a bridge net device");
1685 NS_ABORT_MSG_UNLESS (bnd,
"GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
1687 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
1689 NS_LOG_LOGIC (
"Examine bridge port " << j <<
" " << bnd->GetBridgePort (j));
1690 if (bnd->GetBridgePort (j) == nd)
1692 NS_LOG_LOGIC (
"Net device " << nd <<
" is bridged by " << bnd);
1698 NS_LOG_LOGIC (
"Net device " << nd <<
" is not bridged");
void SetRoutingProtocol(Ptr< Ipv4GlobalRouting > routing)
Set the specific Global Routing Protocol to be used.
Ipv4Address GetLinkId(void) const
Get the Link ID field of the Global Routing Link Record.
Unused – for future OSPF compatibility.
LSType GetLSType(void) const
Return the LSType field of the LSA.
Ptr< Ipv4GlobalRouting > GetRoutingProtocol(void)
Get the specific Global Routing Protocol used.
GlobalRoutingLinkRecord * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
#define NS_LOG_FUNCTION(parameters)
~GlobalRoutingLSA()
Destroy an existing Global Routing Link State Advertisement.
void SetMetric(uint16_t metric)
Set the Metric Data field of the Global Routing Link Record.
Ipv4Address m_advertisingRtr
The Advertising Router is defined by the OSPF spec.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
static Ptr< Node > GetNode(uint32_t n)
Ipv4RoutingTableEntry * GetInjectedRoute(uint32_t i)
Return the injected route indexed by i.
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
static TypeId GetTypeId(void)
Get the type ID.
bool WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask)
Withdraw a route from the global unicast routing table.
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...
uint32_t DiscoverLSAs(void)
Walk the connected channels, discover the adjacent routers and build the associated number of Global ...
Ipv4Address FindDesignatedRouterForLink(Ptr< NetDevice > ndLocal, bool allowRecursion) const
Finds a designated router.
void SetAdvertisingRouter(Ipv4Address rtr)
Set the Advertising Router as defined by the OSPF spec.
LSType m_lsType
The type of the LSA.
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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.
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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 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.
Ipv4Mask GetNetworkLSANetworkMask(void) const
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
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.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if cond is false.
void ProcessBridgedBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a bridged broadcast link.
Ipv4Address GetAdvertisingRouter(void) const
Get the Advertising Router as defined by the OSPF spec.
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...
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
Record represents a leaf node network.
LSType
corresponds to LS type field of RFC 2328 OSPF LSA header
A single link record for a link state advertisement.
Ptr< Ipv4GlobalRouting > m_routingProtocol
the Ipv4GlobalRouting in use
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
a Link State Advertisement (LSA) for a router, used in global routing.
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.
static Ipv4RoutingTableEntry CreateNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
holds a vector of ns3::NetDevice pointers
LinkType
Enumeration of the possible types of Global Routing Link Records.
Ptr< NetDevice > GetDevice(uint32_t index) const
void SetLSType(LSType typ)
Set the LS type field of the LSA.
Ipv4Address m_linkData
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
void Print(std::ostream &os) const
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records...
void RemoveInjectedRoute(uint32_t i)
Withdraw a route from the global unicast routing table.
SPFStatus GetStatus(void) const
Get the SPF status of the advertisement.
#define NS_LOG_LOGIC(msg)
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.
uint32_t GetNDevices(void) const
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
uint32_t GetNAttachedRouters(void) const
Return the number of attached routers listed in the NetworkLSA.
uint32_t GetNLinkRecords(void) const
Return the number of Global Routing Link Records in the LSA.
void SetLinkType(LinkType linkType)
Set the Link Type field of the Global Routing Link Record.
ListOfLSAs_t m_LSAs
database of GlobalRoutingLSAs
~GlobalRoutingLinkRecord()
Destroy a Global Routing Link Record.
GlobalRoutingLinkRecord()
Construct an empty ("uninitialized") Global Routing Link Record.
An interface aggregated to a node to provide global routing info.
Ipv4Address GetLinkData(void) const
Get the Link Data field of the Global Routing Link Record.
#define NS_ASSERT_MSG(condition, message)
Ipv4Address m_routerId
router ID (its IPv4 address)
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Decide whether or not a given net device is being bridged by a BridgeNetDevice.
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.
uint32_t GetId(void) const
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.
LinkType m_linkType
The type of the Global Routing Link Record.
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
bool AnotherRouterOnLink(Ptr< NetDevice > nd, bool allowRecursion) const
Checks for the presence of another router on the NetDevice.
SPFStatus
Enumeration of the possible values of the status flag in the Routing Link State Advertisements.
uint32_t GetNumLSAs(void) const
Get the Number of Global Routing Link State Advertisements that this router can export.
GlobalRouter()
Create a Global Router class.
Ipv4Address GetRouterId(void) const
Get the Router ID associated with this Global Router.
Ipv4Address GetAttachedRouter(uint32_t n) const
Return an Ipv4Address corresponding to the specified attached router.
Ptr< Node > GetNode(void) const
Get the Node pointer of the node that originated this LSA.
void BuildNetworkLSAs(NetDeviceContainer c)
Build one NetworkLSA for each net device talking to a network that we are the designated router for...
ListOfAttachedRouters_t m_attachedRouters
Each Network LSA contains a list of attached routers.
uint32_t Get(void) const
Get the host-order 32-bit IP mask.
LinkType GetLinkType(void) const
Get the Link Type field of the Global Routing Link Record.
bool IsEmpty(void) const
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Adve...
a base class which provides memory management and object aggregation
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.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if cond is true.
GlobalRoutingLSA()
Create a blank Global Routing Link State Advertisement.
void ProcessPointToPointLink(Ptr< NetDevice > ndLocal, GlobalRoutingLSA *pLSA)
Process a point to point link.
Ptr< T > GetObject(void) const
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.
TypeId SetParent(TypeId tid)
void SetLinkStateId(Ipv4Address addr)
Set the Link State ID is defined by the OSPF spec.
uint16_t GetMetric(void) const
Get the Metric Data field of the Global Routing Link Record.
virtual uint32_t GetNInterfaces(void) const =0
Ipv4Address m_linkId
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
NS_LOG_COMPONENT_DEFINE("GlobalRouter")
Ipv4Address GetLinkStateId(void) const
Get the Link State ID as defined by the OSPF spec.
std::list< Ipv4RoutingTableEntry * >::iterator InjectedRoutesI
Iterator to container of Ipv4RoutingTableEntry.
void ProcessBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a generic broadcast link.