23#include "ns3/assert.h"
24#include "ns3/boolean.h"
25#include "ns3/config.h"
26#include "ns3/fatal-error.h"
28#include "ns3/node-list.h"
29#include "ns3/simulator.h"
51operator<<(std::ostream& os,
const std::pair<Ipv4Address, int>& exit)
53 os <<
"(" << exit.first <<
", " << exit.second <<
")";
65operator<<(std::ostream& os,
const std::pair<Ipv6Address, int>& exit)
67 os <<
"(" << exit.first <<
", " << exit.second <<
")";
132 uint32_t orgCount = (*piter)->m_children.size();
133 (*piter)->m_children.remove(
this);
134 uint32_t newCount = (*piter)->m_children.size();
137 "Unable to find the current vertex from its parents --- impossible!");
254 NS_LOG_LOGIC(
"Index to SPFVertex's parent is out-of-range.");
300 SetRootExitDirection(exit.first, exit.second);
310 "Index out-of-range when accessing SPFVertex::m_ecmpRootExits!");
327 "Assumed there is at most one exit from the root to this vertex");
356 NS_LOG_WARN(
"x root exit directions in this vertex are going to be discarded");
430 this->
GetChild(i)->ClearVertexProcessed();
528 if (i->first == addr)
612 uint32_t nRoutes = gr->GetNRoutes();
613 NS_LOG_LOGIC(
"Deleting " << gr->GetNRoutes() <<
" routes from node " << node->GetId());
617 for (j = 0; j < nRoutes; j++)
619 NS_LOG_LOGIC(
"Deleting global route " << j <<
" from node " << node->GetId());
622 NS_LOG_LOGIC(
"Deleted " << j <<
" global routes from node " << node->GetId());
675 for (
uint32_t j = 0; j < numLSAs; ++j)
682 rtr->GetLSA(j, *lsa);
687 m_lsdb->Insert(lsa->GetLinkStateId(), lsa);
746 if (node->GetSystemId() != systemId)
755 if (rtr && rtr->GetNumLSAs())
757 SPFCalculate(rtr->GetRouterId());
794 numRecordsInVertex =
v->GetLSA()->GetNLinkRecords();
798 numRecordsInVertex =
v->GetLSA()->GetNAttachedRouters();
802 for (
uint32_t i = 0; i < numRecordsInVertex; i++)
807 NS_LOG_LOGIC(
"Examining link " << i <<
" of " <<
v->GetVertexId() <<
"'s "
808 <<
v->GetLSA()->GetNLinkRecords() <<
" link records");
814 l =
v->GetLSA()->GetLinkRecord(i);
834 NS_LOG_LOGIC(
"Found a P2P record from " <<
v->GetVertexId() <<
" to "
841 NS_LOG_LOGIC(
"Found a Transit record from " <<
v->GetVertexId() <<
" to "
852 w_lsa =
m_lsdb->GetLSAByLinkData(
v->GetLSA()->GetAttachedRouter(i));
857 NS_LOG_LOGIC(
"Found a Network LSA from " <<
v->GetVertexId() <<
" to "
883 distance =
v->GetDistanceFromRoot() + l->
GetMetric();
887 distance =
v->GetDistanceFromRoot();
912 <<
", parent vertexId: " <<
v->GetVertexId()
917 NS_ASSERT_MSG(0,
"SPFNexthopCalculation never return false, but it does now!");
1010template <
typename T>
1117 <<
" goes through next hop " << nextHop
1118 <<
" via outgoing interface " << outIf
1119 <<
" with distance " << distance);
1131 IpAddress nextHop = IpAddress::GetZero();
1136 <<
" via outgoing interface " << outIf
1137 <<
" with distance " << distance);
1169 uint32_t outIf =
v->GetRootExitDirection().second;
1172 <<
" goes through next hop " << nextHop
1173 <<
" via outgoing interface " << outIf);
1220template <
typename T>
1230 bool found_prev_link =
false;
1236 if (prev_link ==
nullptr)
1239 found_prev_link =
true;
1246 for (
uint32_t i = 0; i <
v->GetLSA()->GetNLinkRecords(); ++i)
1248 l =
v->GetLSA()->GetLinkRecord(i);
1259 if (!found_prev_link)
1262 found_prev_link =
true;
1300template <
typename T>
1315template <
typename T>
1339 NS_LOG_WARN(
"all nodes should have at least one transit link:" << root);
1352 NS_LOG_LOGIC(
"TBD: Would have inserted default for transit");
1362 for (
uint32_t j = 0; j < nLinkRecords; ++j)
1377 rlsa->
GetNode()->template GetObject<GlobalRouter<IpManager>>();
1383 gr->AddNetworkRouteTo(IpAddress::GetZero(),
1384 IpMaskOrPrefix::GetZero(),
1388 << myRouterId <<
" to next hop " << lr->
GetLinkData()
1389 <<
" via interface "
1394 gr->AddNetworkRouteTo(
1395 IpAddress::GetZero(),
1396 IpMaskOrPrefix::GetZero(),
1401 <<
" via interface "
1414template <
typename T>
1443 v->SetDistanceFromRoot(0);
1445 NS_LOG_LOGIC(
"Starting SPFCalculate for node " << root);
1456 NS_LOG_LOGIC(
"SPFCalculate truncated for stub node " << root);
1485 if (candidate.
Size() == 0)
1499 v = candidate.
Pop();
1580template <
typename T>
1594 NS_LOG_LOGIC(
"Found advertising router to destination");
1598 for (
uint32_t i = 0; i <
v->GetNChildren(); i++)
1600 if (!
v->GetChild(i)->IsVertexProcessed())
1602 NS_LOG_LOGIC(
"Vertex's child " << i <<
" not yet processed, processing...");
1604 v->GetChild(i)->SetVertexProcessed(
true);
1614template <
typename T>
1624 if (
v->GetVertexId() ==
m_spfroot->GetVertexId())
1626 NS_LOG_LOGIC(
"External is on local host: " <<
v->GetVertexId() <<
"; returning");
1652 NS_ASSERT_MSG(router,
"No GlobalRouter interface on SPF root node " << node->GetId());
1658 if (router->GetRouterId() ==
routerId)
1660 NS_LOG_LOGIC(
"Setting routes for node " << node->GetId());
1668 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1669 "QI for <Ipv4> interface failed");
1677 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1678 "Expected valid LSA in SPFVertex* v");
1684 tempip = tempip.CombineMask(tempmask);
1688 tempip = tempip.CombinePrefix(tempmask);
1706 NS_ASSERT_MSG(router,
"No GlobalRouter interface on node " << node->GetId());
1712 for (
uint32_t i = 0; i <
v->GetNRootExitDirections(); i++)
1719 gr->AddASExternalRouteTo(tempip, tempmask, nextHop, outIf);
1720 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
1721 <<
" add external network route to " << tempip
1722 <<
" using next hop " << nextHop <<
" via interface "
1727 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
1728 <<
" NOT able to add network route to " << tempip
1729 <<
" using next hop " << nextHop
1730 <<
" since outgoing interface id is negative");
1736 NS_FATAL_ERROR(
"SPFIntraAddRouter(): routerId and vertex ID do not match");
1743template <
typename T>
1755 NS_LOG_LOGIC(
"Examining link " << i <<
" of " <<
v->GetVertexId() <<
"'s "
1756 <<
v->GetLSA()->GetNLinkRecords() <<
" link records");
1766 for (
uint32_t i = 0; i <
v->GetNChildren(); i++)
1768 if (!
v->GetChild(i)->IsVertexProcessed())
1771 v->GetChild(i)->SetVertexProcessed(
true);
1778template <
typename T>
1791 if (
v->GetVertexId() ==
m_spfroot->GetVertexId())
1793 NS_LOG_LOGIC(
"Stub is on local host: " <<
v->GetVertexId() <<
"; returning");
1796 NS_LOG_LOGIC(
"Stub is on remote host: " <<
v->GetVertexId() <<
"; installing");
1823 NS_ASSERT_MSG(router,
"No GlobalRouter interface on node " << node->GetId());
1829 if (
routerId == router->GetRouterId())
1831 NS_LOG_LOGIC(
"Setting routes for node " << node->GetId());
1839 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1840 "QI for <Ipv4> interface failed");
1848 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1849 "Expected valid LSA in SPFVertex* v");
1866 tempip = tempip.CombineMask(tempmask);
1870 tempip = tempip.CombinePrefix(tempmask);
1892 for (
uint32_t i = 0; i <
v->GetNRootExitDirections(); i++)
1899 gr->AddNetworkRouteTo(tempip, tempmask, nextHop, outIf);
1900 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
1901 <<
" add network route to " << tempip <<
" using next hop "
1902 << nextHop <<
" via interface " << outIf);
1906 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
1907 <<
" NOT able to add network route to " << tempip
1908 <<
" using next hop " << nextHop
1909 <<
" since outgoing interface id is negative");
1915 NS_LOG_ERROR(
"SPFIntraAddStub(): routerId and vertex ID do not match");
1926template <
typename T>
1955 NS_ASSERT_MSG(rtr,
"No GlobalRouter interface on node " << node->GetId());
1961 if (rtr->GetRouterId() ==
routerId)
1971 "GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
1972 "GetObject for <Ipv4> interface failed");
1978 int32_t interface = ip->GetInterfaceForPrefix(a, amask);
1983 NS_FATAL_ERROR (
"GlobalRouteManagerImpl::FindOutgoingInterfaceId(): "
1984 "Expected an interface associated with address a:" << a);
1990 NS_FATAL_ERROR(
"SPFIntraAddRouter(): routerId and vertex ID do not match");
2011template <
typename T>
2045 NS_ASSERT_MSG(rtr,
"No GlobalRouter interface on node " << node->GetId());
2052 if (rtr->GetRouterId() ==
routerId)
2054 NS_LOG_LOGIC(
"Setting routes for node " << node->GetId());
2062 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
2063 "GetObject for <Ipv4> interface failed");
2072 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
2073 "Expected valid LSA in SPFVertex* v");
2084 NS_LOG_LOGIC(
" Node " << node->GetId() <<
" found " << nLinkRecords
2085 <<
" link records in LSA " << lsa <<
"with LinkStateId "
2087 for (
uint32_t j = 0; j < nLinkRecords; ++j)
2120 for (
uint32_t i = 0; i <
v->GetNRootExitDirections(); i++)
2129 gr->AddHostRouteTo(lr->
GetLinkData(), nextHop, outIf);
2130 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
2132 <<
" using next hop " << nextHop
2133 <<
" and outgoing interface " << outIf);
2137 NS_LOG_LOGIC(
"The Link Data field of the link record is zero, This link "
2138 "Record is for an interface with no globalUnicast address, "
2139 "not adding a hostroute to it");
2145 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
2146 <<
" NOT able to add host route to " << lr->
GetLinkData()
2147 <<
" using next hop " << nextHop
2148 <<
" since outgoing interface id is negative " << outIf);
2158 NS_FATAL_ERROR(
"SPFIntraAddRouter(): routerId and vertex ID do not match");
2161template <
typename T>
2195 NS_ASSERT_MSG(rtr,
"No GlobalRouter interface on node " << node->GetId());
2202 if (rtr->GetRouterId() ==
routerId)
2204 NS_LOG_LOGIC(
"setting routes for node " << node->GetId());
2212 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2213 "GetObject for <Ipv4> interface failed");
2222 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2223 "Expected valid LSA in SPFVertex* v");
2228 tempip = tempip.CombineMask(tempmask);
2232 tempip = tempip.CombinePrefix(tempmask);
2240 for (
uint32_t i = 0; i <
v->GetNRootExitDirections(); i++)
2248 gr->AddNetworkRouteTo(tempip, tempmask, nextHop, outIf);
2249 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
2250 <<
" add network route to " << tempip <<
" using next hop "
2251 << nextHop <<
" via interface " << outIf);
2255 NS_LOG_LOGIC(
"(Route " << i <<
") Node " << node->GetId()
2256 <<
" NOT able to add network route to " << tempip
2257 <<
" using next hop " << nextHop
2258 <<
" since outgoing interface id is negative " << outIf);
2267 NS_FATAL_ERROR(
"SPFIntraAddTransit(): routerId and vertex ID do not match");
2280template <
typename T>
2290 if ((parent =
v->GetParent(i++)) ==
nullptr)
2298template <
typename T>
2313 int32_t interface = ip->GetInterfaceForAddress(address);
2322template <
typename T>
2332 NS_ASSERT_MSG(ip,
"Ip not found on destination node " << dest->GetId());
2334 uint32_t numInterfaces = ip->GetNInterfaces();
2336 for (
uint32_t i = 0; i < numInterfaces; i++)
2338 uint32_t numAddresses = ip->GetNAddresses(i);
2339 for (
uint32_t j = 0; j < numAddresses; j++)
2345 localAddr = addr.GetLocal();
2349 localAddr = addr.GetAddress();
2351 if (localAddr != IpAddress::GetLoopback())
2353 PrintRoute(sourceNode, localAddr, stream, nodeIdLookup, unit);
2359 NS_ABORT_MSG(
"No IP address associated with destination Node");
2362template <
typename T>
2371 return globalRouting;
2380 for (
uint32_t i = 0; i <
list->GetNRoutingProtocols(); i++)
2382 int16_t priority = 0;
2386 return globalRouting;
2393template <
typename T>
2397 for (
uint32_t i = 0; i < ip->GetNInterfaces(); i++)
2399 for (
uint32_t j = 0; j < ip->GetNAddresses(i); j++)
2401 auto addr = ip->GetAddress(i, j);
2405 localAddr = addr.GetLocal();
2409 localAddr = addr.GetAddress();
2411 if (dest == localAddr)
2421template <
typename T>
2425 uint32_t numInter = ip->GetNInterfaces();
2428 NS_ABORT_MSG(
"No interfaces associated with source Node");
2432 for (
uint32_t i = 0; i < numInter; i++)
2434 if (ip->GetNAddresses(i) > 0)
2440 NS_ABORT_MSG(
"No IP address associated with source Node");
2444template <
typename T>
2449 uint32_t numInterfaces = ipCurrentNode->GetNInterfaces();
2450 for (
uint32_t i = 0; i < numInterfaces; i++)
2452 uint32_t numAddresses = ipCurrentNode->GetNAddresses(i);
2453 for (
uint32_t j = 0; j < numAddresses; j++)
2460 if (mask.IsMatch(dest, senderAddr.GetLocal()))
2469 if (prefix.IsMatch(dest, senderAddr.GetAddress()))
2480template <
typename T>
2494 NS_ABORT_MSG(
"Destination node not found for IP address: " << dest);
2499 Ptr<Ip> ip = sourceNode->GetObject<
Ip>();
2501 NS_ABORT_MSG_IF(!ip,
"No Ip object found on source node " << sourceNode->GetId());
2506 NS_ABORT_MSG(
"No IP address associated with source Node");
2515 NS_ABORT_MSG(
"No global routing protocol found on source node " << sourceNode->GetId());
2520 std::ostream* os = stream->GetStream();
2524 *os <<
", " << hopsRemaining <<
" hops Max." << std::endl;
2529 NS_LOG_DEBUG(
"PrintRoute: Source and Destination are on the same Node "
2530 << sourceNode->GetId());
2531 *os <<
"Source and Destination are on the same Node";
2532 *os << std::endl << std::endl;
2537 if (!globalRouting->LookupGlobal(dest))
2539 *os <<
"There is no path from Node " << sourceNode->GetId() <<
" to Node "
2540 << destNode->GetId() <<
"." << std::endl
2548 std::list<Ptr<Node>> visitedNodes;
2549 visitedNodes.push_back(currentNode);
2550 while (currentNode != destNode)
2558 Ptr<Ip> ipCurrentNode = currentNode->GetObject<
Ip>();
2569 IpAddress gatewayAddress = gateway->GetGateway();
2573 if (gatewayAddress == IpAddress::GetZero())
2580 *os <<
"Error: Did not find any addresses for " << dest <<
" From "
2581 << currentNode->GetId() << std::endl;
2586 currentNode = destNode;
2593 if (nextNode == currentNode)
2595 *os <<
"Invalid route: Next hop points back to the current node (Node "
2596 << currentNode->GetId() <<
").\n";
2597 NS_LOG_WARN(
"Invalid route: Next hop points back to the current node.");
2602 if (std::find(visitedNodes.begin(), visitedNodes.end(), nextNode) != visitedNodes.end())
2604 *os <<
"Loop detected! Node " << nextNode->GetId() <<
" revisited.\n\n";
2608 visitedNodes.push_back(nextNode);
2612 uint32_t interfaceIndex = ipCurrentNode->GetInterfaceForDevice(outdevice);
2613 currentNodeIp = ipL3->SourceAddressSelection(interfaceIndex, gatewayAddress);
2616 std::ostringstream addr;
2617 std::ostringstream node;
2618 if (nextNode != destNode)
2620 node <<
"(Node " << nextNode->GetId() <<
")";
2621 addr << gatewayAddress;
2622 *os << std::right << std::setw(2) << currHop++ <<
" " << addr.str();
2625 *os <<
" " << node.str();
2633 node <<
"(Node " << destNode->GetId() <<
")";
2635 *os << std::right << std::setw(2) << currHop++ <<
" " << addr.str();
2638 *os <<
" " << node.str();
2642 currentNode = nextNode;
2643 currentNodeIp = gatewayAddress;
2649template <
typename T>
2664 ip->SetAttribute(
"StrongEndSystemModel",
BooleanValue(
false));
2667 for (
uint32_t i = 0; i < ip->GetNInterfaces(); i++)
2669 ip->SetForwarding(i,
true);
AttributeValue implementation for Boolean.
A Candidate Queue used in routing calculations.
void Push(SPFVertex< T > *vNew)
Push a Shortest Path First Vertex pointer onto the queue according to the priority scheme.
SPFVertex< T > * Find(const IpAddress addr) const
Searches the Candidate Queue for a Shortest Path First Vertex pointer that points to a vertex having ...
SPFVertex< T > * Pop()
Pop the Shortest Path First Vertex pointer at the top of the queue.
uint32_t Size() const
Return the number of Shortest Path First Vertex pointers presently stored in the Candidate Queue.
void Reorder()
Reorders the Candidate Queue according to the priority scheme.
A global router implementation.
void SPFProcessStubs(SPFVertex< T > *v)
Process Stub nodes.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
int32_t FindOutgoingInterfaceId(IpAddress a, IpMaskOrPrefix amask=IpMaskOrPrefix::GetOnes())
Return the interface number corresponding to a given IP address and mask.
void SPFIntraAddTransit(SPFVertex< T > *v)
Add a transit to the routing tables.
typename std::conditional_t< IsIpv4, Ipv4L3Protocol, Ipv6L3Protocol > IpL3Protocol
Alias for Ipv4l3Protocol and Ipv6l3Protocol classes.
void SPFIntraAddStub(GlobalRoutingLinkRecord< IpManager > *l, SPFVertex< T > *v)
Add a stub to the routing tables.
void DebugSPFCalculate(IpAddress root)
Debugging routine; call the core SPF from the unit tests.
virtual void BuildGlobalRoutingDatabase()
Build the routing database by gathering Link State Advertisements from each node exporting a GlobalRo...
void PrintRoute(Ptr< Node > sourceNode, Ptr< Node > dest, Ptr< OutputStreamWrapper > stream, bool nodeIdLookup, Time::Unit unit)
prints the path from this node to the destination node at a particular time.
GlobalRoutingLinkRecord< IpManager > * SPFGetNextLink(SPFVertex< T > *v, SPFVertex< T > *w, GlobalRoutingLinkRecord< IpManager > *prev_link)
Search for a link between two vertices.
void SPFCalculate(IpAddress root)
Calculate the shortest path first (SPF) tree.
void SPFNext(SPFVertex< T > *v, CandidateQueue< T > &candidate)
Examine the links in v's LSA and update the list of candidates with any vertices not already on the l...
void InitializeRouters()
initialize all nodes as routers.
int SPFNexthopCalculation(SPFVertex< T > *v, SPFVertex< T > *w, GlobalRoutingLinkRecord< IpManager > *l, uint32_t distance)
Calculate nexthop from root through V (parent) to vertex W (destination) with given distance from roo...
virtual void InitializeRoutes()
Compute routes using a Dijkstra SPF computation and populate per-node forwarding tables.
Ptr< Node > GetNodeByIp(const IpAddress &source)
given IP it iterates through the node list to find the node associated with the ip
virtual void DeleteGlobalRoutes()
Delete all static routes on all nodes that have a GlobalRouterInterface.
GlobalRouteManagerLSDB< IpManager > * m_lsdb
the Link State DataBase (LSDB) of the Global Route Manager
void SPFVertexAddParent(SPFVertex< T > *v)
Adds a vertex to the list of children in each of its parents.
void SPFIntraAddRouter(SPFVertex< T > *v)
Add a host route to the routing tables.
SPFVertex< T > * m_spfroot
the root node
void DebugUseLsdb(GlobalRouteManagerLSDB< T > *lsdb)
Debugging routine; allow client code to supply a pre-built LSDB.
void SPFAddASExternal(GlobalRoutingLSA< IpManager > *extlsa, SPFVertex< T > *v)
Add an external route to the routing tables.
static constexpr bool IsIpv4
Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol.
virtual ~GlobalRouteManagerImpl()
bool CheckForStubNode(IpAddress root)
Test if a node is a stub, from an OSPF sense.
typename std::conditional_t< IsIpv4, Ipv4Mask, Ipv6Prefix > IpMaskOrPrefix
Alias for Ipv4Mask And Ipv6Prefix.
bool ValidateSourceNodeHasIpAddress(Ptr< Ip > ip)
Is used by PrintRoute() to check if the source node has an ipv4 address.
Ptr< IpGlobalRouting > GetGlobalRoutingForNode(Ptr< Node > node)
Is used by PrintRoute() to get the global routing protocol associated with it or returns nullptr if n...
bool IsOnSameSubnet(Ptr< Ip > ipCurrentNode, IpAddress dest)
Is used by PrintRoute() to check if the destination is on the same subnet as the source node.
bool IsLocalDelivery(Ptr< Ip > ip, IpAddress dest)
Is used by PrintRoute() to check if the destination is on the source node itself.
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
void ProcessASExternals(SPFVertex< T > *v, GlobalRoutingLSA< IpManager > *extlsa)
Process Autonomous Systems (AS) External LSA.
The Link State DataBase (LSDB) of the Global Route Manager.
std::pair< IpAddress, GlobalRoutingLSA< IpManager > * > LSDBPair_t
pair of IPv4 addresses / Link State Advertisements
GlobalRoutingLSA< IpManager > * GetLSA(IpAddress addr) const
Look up the Link State Advertisement associated with the given link state ID (address).
~GlobalRouteManagerLSDB()
Destroy an empty Global Router Manager Link State Database.
GlobalRoutingLSA< IpManager > * GetExtLSA(uint32_t index) const
Look up the External Link State Advertisement associated with the given index.
uint32_t GetNumExtLSAs() const
Get the number of External Link State Advertisements.
void Initialize()
Set all LSA flags to an initialized state, for SPF computation.
GlobalRoutingLSA< IpManager > * GetLSAByLinkData(IpAddress addr) const
Look up the Link State Advertisement associated with the given link state ID (address).
LSDBMap_t m_database
database of IPv4 addresses / Link State Advertisements
std::vector< GlobalRoutingLSA< IpManager > * > m_extdatabase
database of External Link State Advertisements
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
GlobalRouteManagerLSDB()
Construct an empty Global Router Manager Link State Database.
void Insert(IpAddress addr, GlobalRoutingLSA< IpManager > *lsa)
Insert an IP address / Link State Advertisement pair into the Link State Database.
An interface aggregated to a node to provide global routing info.
a Link State Advertisement (LSA) for a router, used in global routing.
GlobalRoutingLinkRecord< T > * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
@ LSA_SPF_CANDIDATE
Vertex is in the SPF candidate queue.
@ LSA_SPF_IN_SPFTREE
Vertex is in the SPF tree.
@ LSA_SPF_NOT_EXPLORED
New vertex not yet considered.
SPFStatus GetStatus() const
Get the SPF status of the advertisement.
uint32_t GetNLinkRecords() const
Return the number of Global Routing Link Records in the LSA.
IpAddress GetLinkStateId() const
Get the Link State ID as defined by the OSPF spec.
Ptr< Node > GetNode() const
Get the Node pointer of the node that originated this LSA.
LSType GetLSType() const
Return the LSType field of the LSA.
IpAddress GetAdvertisingRouter() const
Get the Advertising Router as defined by the OSPF spec.
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
IpMaskOrPrefix GetNetworkLSANetworkMask() 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.
IpAddress GetLinkId() const
Get the Link ID field of the Global Routing Link Record.
uint16_t GetMetric() const
Get the Metric Data field of the Global Routing Link Record.
@ StubNetwork
Record represents a leaf node network.
@ PointToPoint
Record representing a point to point channel.
@ TransitNetwork
Unused – for future OSPF compatibility.
IpAddress GetLinkData() const
Get the Link Data field of the Global Routing Link Record.
IpAddress GetLinkLocData()
Set the Link Local Data field of the Global Routing Link Record.
LinkType GetLinkType() const
Get the Link Type field of the Global Routing Link Record.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to represent an Ipv4 address mask
Describes an IPv6 prefix.
static uint32_t GetNNodes()
Smart pointer class similar to boost::intrusive_ptr.
Vertex used in shortest path first (SPF) computations.
bool m_vertexProcessed
Flag to note whether vertex has been processed in stage two of SPF computation.
VertexType m_vertexType
Vertex type.
SPFVertex * GetParent(uint32_t i=0) const
Get a pointer to the SPFVector that is the parent of "this" SPFVertex.
SPFVertex()
Construct an empty ("uninitialized") SPFVertex (Shortest Path First Vertex).
IpAddress GetVertexId() const
Get the Vertex ID field of a SPFVertex object.
SPFVertex< T > * GetChild(uint32_t n) const
Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex.
~SPFVertex()
Destroy an SPFVertex (Shortest Path First Vertex).
uint32_t m_distanceFromRoot
Distance from root node.
VertexType
Enumeration of the possible types of SPFVertex objects.
@ VertexNetwork
Vertex representing a network in the topology.
@ VertexUnknown
Uninitialized Link Record.
@ VertexRouter
Vertex representing a router in the topology.
void InheritAllRootExitDirections(const SPFVertex< T > *vertex)
Inherit all root exit directions from a given vertex to 'this' vertex.
GlobalRoutingLSA< IpManager > * m_lsa
Link State Advertisement.
void SetRootExitDirection(IpAddress nextHop, int32_t id=SPF_INFINITY)
Set the IP address and outgoing interface index that should be used to begin forwarding packets from ...
void SetVertexId(IpAddress id)
Set the Vertex ID field of a SPFVertex object.
uint32_t GetDistanceFromRoot() const
Get the distance from the root vertex to "this" SPFVertex object.
IpAddress m_nextHop
next hop
bool IsVertexProcessed() const
Check the value of the VertexProcessed flag.
void SetDistanceFromRoot(uint32_t distance)
Set the distance from the root vertex to "this" SPFVertex object.
ListOfNodeExit_t m_ecmpRootExits
store the multiple root's exits for supporting ECMP
Ptr< Node > m_node
node pointer corresponding to the this Vertex
void SetVertexType(VertexType type)
Set the Vertex Type field of a SPFVertex object.
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
uint32_t AddChild(SPFVertex< T > *child)
Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex.
uint32_t GetNChildren() const
Get the number of children of "this" SPFVertex.
int32_t m_rootOif
root Output Interface
uint32_t GetNRootExitDirections() const
Get the number of exit directions from root for reaching 'this' vertex.
void SetLSA(GlobalRoutingLSA< IpManager > *lsa)
Set the Global Router Link State Advertisement returned by the Global Router represented by this SPFV...
void MergeParent(const SPFVertex< T > *v)
Merge the Parent list from the v into this vertex.
GlobalRoutingLSA< T > * GetLSA() const
Get the Global Router Link State Advertisement returned by the Global Router represented by this SPFV...
void MergeRootExitDirections(const SPFVertex< T > *vertex)
Merge into 'this' vertex the list of exit directions from another vertex.
void SetVertexProcessed(bool value)
Set the value of the VertexProcessed flag.
std::list< NodeExit_t > ListOfNodeExit_t
container of Exit nodes
VertexType GetVertexType() const
Get the Vertex Type field of a SPFVertex object.
void ClearVertexProcessed()
Clear the value of the VertexProcessed flag.
IpAddress m_vertexId
Vertex ID.
NodeExit_t GetRootExitDirection(uint32_t i) const
Obtain a pair indicating the exit direction from the root.
NodeExit_t GetRootExitDirection() const
Obtain a pair indicating the exit direction from the root.
std::pair< IpAddress, int32_t > NodeExit_t
IPv4 / interface container for exit nodes.
void SetParent(SPFVertex< T > *parent)
Set the pointer to the SPFVector that is the parent of "this" SPFVertex.
ListOfSPFVertex_t m_parents
parent list
Ptr< Node > GetNode() const
Get the node pointer corresponding to this Vertex.
ListOfSPFVertex_t m_children
Children list.
static uint32_t GetSystemId()
Get the system id of this simulator.
Unit
The unit to use to interpret a number representing time.
#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_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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_NOARGS()
Output the name of the function.
#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_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GlobalRouteManager< T >::routerId
Router ID counter.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
const uint32_t SPF_INFINITY
"infinite" distance between nodes