30 #include "ns3/assert.h"
31 #include "ns3/fatal-error.h"
33 #include "ns3/node-list.h"
35 #include "ns3/ipv4-routing-protocol.h"
36 #include "ns3/ipv4-list-routing.h"
37 #include "ns3/mpi-interface.h"
38 #include "global-router-interface.h"
39 #include "global-route-manager-impl.h"
40 #include "candidate-queue.h"
41 #include "ipv4-global-routing.h"
48 operator<< (std::ostream& os,
const SPFVertex::NodeExit_t& exit)
50 os <<
"(" << exit.first <<
" ," << exit.second <<
")";
55 operator<< (std::ostream& os,
const SPFVertex::ListOfSPFVertex_t& vs)
57 typedef SPFVertex::ListOfSPFVertex_t::const_iterator CIter_t;
59 for (CIter_t iter = vs.begin (); iter != vs.end ();)
61 os << (*iter)->m_vertexId;
62 if (++iter != vs.end ())
82 m_vertexType (VertexUnknown),
83 m_vertexId (
"255.255.255.255"),
85 m_distanceFromRoot (SPF_INFINITY),
86 m_rootOif (SPF_INFINITY),
87 m_nextHop (
"0.0.0.0"),
90 m_vertexProcessed (false)
96 m_vertexId (lsa->GetLinkStateId ()),
98 m_distanceFromRoot (SPF_INFINITY),
99 m_rootOif (SPF_INFINITY),
100 m_nextHop (
"0.0.0.0"),
103 m_vertexProcessed (false)
107 if (lsa->
GetLSType () == GlobalRoutingLSA::RouterLSA)
112 else if (lsa->
GetLSType () == GlobalRoutingLSA::NetworkLSA)
128 for (ListOfSPFVertex_t::iterator piter = m_parents.begin ();
129 piter != m_parents.end ();
135 uint32_t orgCount = (*piter)->m_children.size ();
136 (*piter)->m_children.remove (
this);
137 uint32_t newCount = (*piter)->m_children.size ();
138 if (orgCount > newCount)
140 NS_ASSERT_MSG (orgCount > newCount,
"Unable to find the current vertex from its parents --- impossible!");
145 while (m_children.size () > 0)
156 if (p == 0)
continue;
167 NS_LOG_LOGIC (
"Vertex-" << m_vertexId <<
" completed deleted");
216 m_distanceFromRoot = distance;
223 return m_distanceFromRoot;
233 m_parents.push_back (parent);
242 if (m_parents.size () <= i)
244 NS_LOG_LOGIC (
"Index to SPFVertex's parent is out-of-range.");
247 ListOfSPFVertex_t::const_iterator iter = m_parents.begin ();
260 NS_LOG_LOGIC (
"Before merge, list of parents = " << m_parents);
262 m_parents.insert (m_parents.end (),
263 v->m_parents.begin (), v->m_parents.end ());
267 NS_LOG_LOGIC (
"After merge, list of parents = " << m_parents);
291 SPFVertex::NodeExit_t
295 typedef ListOfNodeExit_t::const_iterator CIter_t;
299 while (i-- > 0) { iter++; }
304 SPFVertex::NodeExit_t
323 extList.begin (), extList.end ());
337 NS_LOG_WARN (
"x root exit directions in this vertex are going to be discarded");
355 return m_children.size ();
364 for ( ListOfSPFVertex_t::const_iterator i = m_children.begin ();
365 i != m_children.end ();
381 m_children.push_back (child);
382 return m_children.size ();
389 m_vertexProcessed = value;
396 return m_vertexProcessed;
400 SPFVertex::ClearVertexProcessed (
void)
405 this->
GetChild (i)->ClearVertexProcessed ();
427 LSDBMap_t::iterator i;
428 for (i= m_database.begin (); i!= m_database.end (); i++)
434 for (uint32_t j = 0; j < m_extdatabase.size (); j++)
448 LSDBMap_t::iterator i;
449 for (i= m_database.begin (); i!= m_database.end (); i++)
460 if (lsa->
GetLSType () == GlobalRoutingLSA::ASExternalLSAs)
462 m_extdatabase.push_back (lsa);
466 m_database.insert (LSDBPair_t (addr, lsa));
471 GlobalRouteManagerLSDB::GetExtLSA (uint32_t index)
const
474 return m_extdatabase.at (index);
478 GlobalRouteManagerLSDB::GetNumExtLSAs ()
const
481 return m_extdatabase.size ();
491 LSDBMap_t::const_iterator i;
492 for (i= m_database.begin (); i!= m_database.end (); i++)
494 if (i->first == addr)
509 LSDBMap_t::const_iterator i;
510 for (i= m_database.begin (); i!= m_database.end (); i++)
533 GlobalRouteManagerImpl::GlobalRouteManagerImpl ()
541 GlobalRouteManagerImpl::~GlobalRouteManagerImpl ()
576 uint32_t nRoutes = gr->GetNRoutes ();
577 NS_LOG_LOGIC (
"Deleting " << gr->GetNRoutes ()<<
" routes from node " << node->
GetId ());
581 for (j = 0; j < nRoutes; j++)
635 uint32_t numLSAs = rtr->DiscoverLSAs ();
638 for (uint32_t j = 0; j < numLSAs; ++j)
645 rtr->GetLSA (j, *lsa);
717 if (rtr && rtr->GetNumLSAs () )
719 SPFCalculate (rtr->GetRouterId ());
746 uint32_t distance = 0;
747 uint32_t numRecordsInVertex = 0;
761 for (uint32_t i = 0; i < numRecordsInVertex; i++)
777 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
791 w_lsa = m_lsdb->
GetLSA (l->GetLinkId ());
796 else if (l->GetLinkType () ==
799 w_lsa = m_lsdb->
GetLSA (l->GetLinkId ());
863 w =
new SPFVertex (w_lsa);
864 if (SPFNexthopCalculation (v, w, l, distance))
879 <<
"return false, but it does now!");
898 if (cw->GetDistanceFromRoot () < distance)
905 else if (cw->GetDistanceFromRoot () == distance)
927 w =
new SPFVertex (w_lsa);
928 SPFNexthopCalculation (v, w, l, distance);
929 cw->MergeRootExitDirections (w);
934 SPFVertexAddParent (w);
947 if (SPFNexthopCalculation (v, cw, l, distance))
971 GlobalRouteManagerImpl::SPFNexthopCalculation (
974 GlobalRoutingLinkRecord* l,
1036 GlobalRoutingLinkRecord *linkRemote = 0;
1037 linkRemote = SPFGetNextLink (w, v, linkRemote);
1049 Ipv4Address nextHop = linkRemote->GetLinkData ();
1055 uint32_t outIf = FindOutgoingInterfaceId (l->GetLinkData ());
1057 w->SetRootExitDirection (nextHop, outIf);
1058 w->SetDistanceFromRoot (distance);
1061 v->GetVertexId () <<
" to " << w->GetVertexId () <<
1062 " goes through next hop " << nextHop <<
1063 " via outgoing interface " << outIf <<
1064 " with distance " << distance);
1070 GlobalRoutingLSA* w_lsa = w->GetLSA ();
1071 NS_ASSERT (w_lsa->GetLSType () == GlobalRoutingLSA::NetworkLSA);
1073 uint32_t outIf = FindOutgoingInterfaceId (w_lsa->GetLinkStateId (),
1074 w_lsa->GetNetworkLSANetworkMask () );
1077 w->SetRootExitDirection (nextHop, outIf);
1078 w->SetDistanceFromRoot (distance);
1081 v->GetVertexId () <<
" to network " << w->GetVertexId () <<
1082 " via outgoing interface " << outIf <<
1083 " with distance " << distance);
1090 if (v->GetParent () == m_spfroot)
1097 GlobalRoutingLinkRecord *linkRemote = 0;
1098 while ((linkRemote = SPFGetNextLink (w, v, linkRemote)))
1106 Ipv4Address nextHop = linkRemote->GetLinkData ();
1107 uint32_t outIf = v->GetRootExitDirection ().second;
1108 w->SetRootExitDirection (nextHop, outIf);
1110 v->GetVertexId () <<
" to " << w->GetVertexId () <<
1111 " goes through next hop " << nextHop <<
1112 " via outgoing interface " << outIf);
1117 w->SetRootExitDirection (v->GetRootExitDirection ());
1135 w->InheritAllRootExitDirections (v);
1140 w->SetDistanceFromRoot (distance);
1158 GlobalRoutingLinkRecord*
1159 GlobalRouteManagerImpl::SPFGetNextLink (
1162 GlobalRoutingLinkRecord* prev_link)
1167 bool found_prev_link =
false;
1168 GlobalRoutingLinkRecord* l;
1176 found_prev_link =
true;
1183 for (uint32_t i = 0; i < v->GetLSA ()->GetNLinkRecords (); ++i)
1185 l = v->GetLSA ()->GetLinkRecord (i);
1194 if (l->GetLinkId () == w->GetVertexId ())
1196 if (!found_prev_link)
1198 NS_LOG_LOGIC (
"Skipping links before prev_link found");
1199 found_prev_link =
true;
1204 l->GetLinkId () <<
" linkData = " << l->GetLinkData ());
1240 SPFCalculate (root);
1250 GlobalRouteManagerImpl::CheckForStubNode (
Ipv4Address root)
1276 NS_LOG_WARN (
"all nodes should have at least one transit link:" << root );
1289 NS_LOG_LOGIC (
"TBD: Would have inserted default for transit");
1299 for (uint32_t j = 0; j < nLinkRecords; ++j)
1304 GlobalRoutingLinkRecord *lr = w_lsa->GetLinkRecord (j);
1310 if (lr->GetLinkId () == myRouterId)
1315 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
1317 gr->AddNetworkRouteTo (Ipv4Address (
"0.0.0.0"), Ipv4Mask (
"0.0.0.0"), lr->GetLinkData (),
1318 FindOutgoingInterfaceId (transitLink->
GetLinkData ()));
1319 NS_LOG_LOGIC (
"Inserting default route for node " << myRouterId <<
" to next hop " <<
1320 lr->GetLinkData () <<
" via interface " <<
1321 FindOutgoingInterfaceId (transitLink->
GetLinkData ()));
1332 GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root)
1346 CandidateQueue candidate;
1353 v =
new SPFVertex (m_lsdb->
GetLSA (root));
1361 NS_LOG_LOGIC (
"Starting SPFCalculate for node " << root);
1372 NS_LOG_LOGIC (
"SPFCalculate truncated for stub node " << root);
1393 SPFNext (v, candidate);
1401 if (candidate.Size () == 0)
1415 v = candidate.Pop ();
1429 SPFVertexAddParent (v);
1460 SPFIntraAddRouter (v);
1464 SPFIntraAddTransit (v);
1479 SPFProcessStubs (m_spfroot);
1480 for (uint32_t i = 0; i < m_lsdb->GetNumExtLSAs (); i++)
1482 m_spfroot->ClearVertexProcessed ();
1483 GlobalRoutingLSA *extlsa = m_lsdb->GetExtLSA (i);
1484 NS_LOG_LOGIC (
"Processing External LSA with id " << extlsa->GetLinkStateId ());
1485 ProcessASExternals (m_spfroot, extlsa);
1498 GlobalRouteManagerImpl::ProcessASExternals (SPFVertex* v, GlobalRoutingLSA* extlsa)
1501 NS_LOG_LOGIC (
"Processing external for destination " <<
1502 extlsa->GetLinkStateId () <<
1503 ", for router " << v->GetVertexId () <<
1504 ", advertised by " << extlsa->GetAdvertisingRouter ());
1507 GlobalRoutingLSA *rlsa = v->GetLSA ();
1508 NS_LOG_LOGIC (
"Processing router LSA with id " << rlsa->GetLinkStateId ());
1509 if ((rlsa->GetLinkStateId ()) == (extlsa->GetAdvertisingRouter ()))
1511 NS_LOG_LOGIC (
"Found advertising router to destination");
1512 SPFAddASExternal (extlsa,v);
1515 for (uint32_t i = 0; i < v->GetNChildren (); i++)
1517 if (!v->GetChild (i)->IsVertexProcessed ())
1519 NS_LOG_LOGIC (
"Vertex's child " << i <<
" not yet processed, processing...");
1520 ProcessASExternals (v->GetChild (i), extlsa);
1521 v->GetChild (i)->SetVertexProcessed (
true);
1532 GlobalRouteManagerImpl::SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v)
1536 NS_ASSERT_MSG (m_spfroot,
"GlobalRouteManagerImpl::SPFAddASExternal (): Root pointer not set");
1540 if (v->GetVertexId () == m_spfroot->GetVertexId ())
1543 << v->GetVertexId () <<
"; returning");
1547 << extlsa->GetAdvertisingRouter () <<
"; installing");
1549 Ipv4Address routerId = m_spfroot->GetVertexId ();
1559 for (; i != listEnd; i++)
1561 Ptr<Node> node = *i;
1567 Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter> ();
1571 NS_LOG_LOGIC (
"No GlobalRouter interface on node " << node->GetId ());
1579 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1581 if (rtr->GetRouterId () == routerId)
1583 NS_LOG_LOGIC (
"Setting routes for node " << node->GetId ());
1589 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
1591 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1592 "QI for <Ipv4> interface failed");
1600 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1601 "Expected valid LSA in SPFVertex* v");
1602 Ipv4Mask tempmask = extlsa->GetNetworkLSANetworkMask ();
1603 Ipv4Address tempip = extlsa->GetLinkStateId ();
1604 tempip = tempip.CombineMask (tempmask);
1619 Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
1624 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
1628 for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
1630 SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i);
1631 Ipv4Address nextHop = exit.first;
1632 int32_t outIf = exit.second;
1635 gr->AddASExternalRouteTo (tempip, tempmask, nextHop, outIf);
1636 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
1637 " add external network route to " << tempip <<
1638 " using next hop " << nextHop <<
1639 " via interface " << outIf);
1643 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
1644 " NOT able to add network route to " << tempip <<
1645 " using next hop " << nextHop <<
1646 " since outgoing interface id is negative");
1659 GlobalRouteManagerImpl::SPFProcessStubs (SPFVertex* v)
1662 NS_LOG_LOGIC (
"Processing stubs for " << v->GetVertexId ());
1665 GlobalRoutingLSA *rlsa = v->GetLSA ();
1666 NS_LOG_LOGIC (
"Processing router LSA with id " << rlsa->GetLinkStateId ());
1667 for (uint32_t i = 0; i < rlsa->GetNLinkRecords (); i++)
1670 v->GetVertexId () <<
"'s " <<
1671 v->GetLSA ()->GetNLinkRecords () <<
" link records");
1672 GlobalRoutingLinkRecord *l = v->GetLSA ()->GetLinkRecord (i);
1675 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
1676 SPFIntraAddStub (l, v);
1681 for (uint32_t i = 0; i < v->GetNChildren (); i++)
1683 if (!v->GetChild (i)->IsVertexProcessed ())
1685 SPFProcessStubs (v->GetChild (i));
1686 v->GetChild (i)->SetVertexProcessed (
true);
1693 GlobalRouteManagerImpl::SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex* v)
1698 "GlobalRouteManagerImpl::SPFIntraAddStub (): Root pointer not set");
1705 if (v->GetVertexId () == m_spfroot->GetVertexId ())
1707 NS_LOG_LOGIC (
"Stub is on local host: " << v->GetVertexId () <<
"; returning");
1710 NS_LOG_LOGIC (
"Stub is on remote host: " << v->GetVertexId () <<
"; installing");
1718 Ipv4Address routerId = m_spfroot->GetVertexId ();
1728 for (; i != listEnd; i++)
1730 Ptr<Node> node = *i;
1736 Ptr<GlobalRouter> rtr =
1737 node->GetObject<GlobalRouter> ();
1750 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1752 if (rtr->GetRouterId () == routerId)
1754 NS_LOG_LOGIC (
"Setting routes for node " << node->GetId ());
1760 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
1762 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1763 "QI for <Ipv4> interface failed");
1771 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1772 "Expected valid LSA in SPFVertex* v");
1773 Ipv4Mask tempmask (l->GetLinkData ().Get ());
1774 Ipv4Address tempip = l->GetLinkId ();
1775 tempip = tempip.CombineMask (tempmask);
1790 Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
1795 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
1799 for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
1801 SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i);
1802 Ipv4Address nextHop = exit.first;
1803 int32_t outIf = exit.second;
1806 gr->AddNetworkRouteTo (tempip, tempmask, nextHop, outIf);
1807 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
1808 " add network route to " << tempip <<
1809 " using next hop " << nextHop <<
1810 " via interface " << outIf);
1814 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
1815 " NOT able to add network route to " << tempip <<
1816 " using next hop " << nextHop <<
1817 " since outgoing interface id is negative");
1833 GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a, Ipv4Mask amask)
1844 Ipv4Address routerId = m_spfroot->GetVertexId ();
1852 for (; i != listEnd; i++)
1854 Ptr<Node> node = *i;
1856 Ptr<GlobalRouter> rtr =
1857 node->GetObject<GlobalRouter> ();
1867 if (rtr->GetRouterId () == routerId)
1875 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
1877 "GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
1878 "GetObject for <Ipv4> interface failed");
1884 int32_t
interface = ipv4->GetInterfaceForPrefix (a, amask);
1889 NS_FATAL_ERROR (
"GlobalRouteManagerImpl::FindOutgoingInterfaceId(): "
1890 "Expected an interface associated with address a:" << a);
1899 NS_LOG_LOGIC (
"FindOutgoingInterfaceId():Can't find root node " << routerId);
1920 GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
1925 "GlobalRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set");
1933 Ipv4Address routerId = m_spfroot->GetVertexId ();
1943 for (; i != listEnd; i++)
1945 Ptr<Node> node = *i;
1951 Ptr<GlobalRouter> rtr =
1952 node->GetObject<GlobalRouter> ();
1965 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1967 if (rtr->GetRouterId () == routerId)
1969 NS_LOG_LOGIC (
"Setting routes for node " << node->GetId ());
1975 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
1977 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1978 "GetObject for <Ipv4> interface failed");
1985 GlobalRoutingLSA *lsa = v->GetLSA ();
1987 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1988 "Expected valid LSA in SPFVertex* v");
1990 uint32_t nLinkRecords = lsa->GetNLinkRecords ();
2000 " found " << nLinkRecords <<
" link records in LSA " << lsa <<
"with LinkStateId "<< lsa->GetLinkStateId ());
2001 for (uint32_t j = 0; j < nLinkRecords; ++j)
2006 GlobalRoutingLinkRecord *lr = lsa->GetLinkRecord (j);
2024 Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
2029 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
2034 for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
2036 SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i);
2037 Ipv4Address nextHop = exit.first;
2038 int32_t outIf = exit.second;
2041 gr->AddHostRouteTo (lr->GetLinkData (), nextHop,
2043 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
2044 " adding host route to " << lr->GetLinkData () <<
2045 " using next hop " << nextHop <<
2046 " and outgoing interface " << outIf);
2050 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
2051 " NOT able to add host route to " << lr->GetLinkData () <<
2052 " using next hop " << nextHop <<
2053 " since outgoing interface id is negative " << outIf);
2065 GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v)
2070 "GlobalRouteManagerImpl::SPFIntraAddTransit (): Root pointer not set");
2078 Ipv4Address routerId = m_spfroot->GetVertexId ();
2088 for (; i != listEnd; i++)
2090 Ptr<Node> node = *i;
2096 Ptr<GlobalRouter> rtr =
2097 node->GetObject<GlobalRouter> ();
2110 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
2112 if (rtr->GetRouterId () == routerId)
2114 NS_LOG_LOGIC (
"setting routes for node " << node->GetId ());
2120 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
2122 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2123 "GetObject for <Ipv4> interface failed");
2130 GlobalRoutingLSA *lsa = v->GetLSA ();
2132 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2133 "Expected valid LSA in SPFVertex* v");
2134 Ipv4Mask tempmask = lsa->GetNetworkLSANetworkMask ();
2135 Ipv4Address tempip = lsa->GetLinkStateId ();
2136 tempip = tempip.CombineMask (tempmask);
2137 Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
2142 Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol ();
2147 for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++)
2149 SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i);
2150 Ipv4Address nextHop = exit.first;
2151 int32_t outIf = exit.second;
2155 gr->AddNetworkRouteTo (tempip, tempmask, nextHop, outIf);
2156 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
2157 " add network route to " << tempip <<
2158 " using next hop " << nextHop <<
2159 " via interface " << outIf);
2163 NS_LOG_LOGIC (
"(Route " << i <<
") Node " << node->GetId () <<
2164 " NOT able to add network route to " << tempip <<
2165 " using next hop " << nextHop <<
2166 " since outgoing interface id is negative " << outIf);
2183 GlobalRouteManagerImpl::SPFVertexAddParent (SPFVertex* v)
2187 for (uint32_t i=0;;)
2191 if ((parent = v->GetParent (i++)) == 0)
break;
2192 parent->AddChild (v);
Ipv4Address GetLinkId(void) const
LSType GetLSType(void) const
Return the LSType field of the LSA.
GlobalRoutingLinkRecord * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
#define NS_LOG_FUNCTION(parameters)
GlobalRoutingLSA * GetLSAByLinkData(Ipv4Address addr) const
Look up the Link State Advertisement associated with the given link state ID (address). This is a variation of the GetLSA call to allow the LSA to be found by matching addr with the LinkData field of the TransitNetwork link record.
static uint32_t GetNNodes(void)
virtual void DeleteGlobalRoutes()
Delete all static routes on all nodes that have a GlobalRouterInterface.
void SetParent(SPFVertex *parent)
Set the pointer to the SPFVector that is the parent of "this" SPFVertex.
~SPFVertex()
Destroy an SPFVertex (Shortest Path First Vertex).
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
void InheritAllRootExitDirections(const SPFVertex *vertex)
Inherit all root exit directions from a given vertex to 'this' vertex.
void MergeParent(const SPFVertex *v)
Merge the Parent list from the v into this vertex.
Vertex used in shortest path first (SPF) computations. See RFC 2328, Section 16.
SPFVertex()
Construct an empty ("uninitialized") SPFVertex (Shortest Path First Vertex).
void SetDistanceFromRoot(uint32_t distance)
Set the distance from the root vertex to "this" SPFVertex object.
uint32_t GetSystemId(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
ListOfNodeExit_t m_ecmpRootExits
store the multiple root's exits for supporting ECMP
A single link record for a link state advertisement.
A Candidate Queue used in static routing.
a Link State Advertisement (LSA) for a router, used in global routing.
uint32_t GetNChildren(void) const
Get the number of children of "this" SPFVertex.
void Initialize()
Set all LSA flags to an initialized state, for SPF computation.
~GlobalRouteManagerLSDB()
Destroy an empty Global Router Manager Link State Database.
static Iterator End(void)
void DebugSPFCalculate(Ipv4Address root)
Debugging routine; call the core SPF from the unit tests.
uint32_t GetDistanceFromRoot(void) const
Get the distance from the root vertex to "this" SPFVertex object.
SPFStatus GetStatus(void) const
Get the SPF status of the advertisement.
#define NS_LOG_LOGIC(msg)
virtual void InitializeRoutes()
Compute routes using a Dijkstra SPF computation and populate per-node forwarding tables.
GlobalRoutingLSA * GetLSA(void) const
Get the Global Router Link State Advertisement returned by the Global Router represented by this SPFV...
std::ostream & operator<<(std::ostream &os, const Angles &a)
void Push(SPFVertex *vNew)
Push a Shortest Path First Vertex pointer onto the queue according to the priority scheme...
void SetVertexType(VertexType type)
Set the Vertex Type field of a SPFVertex object.
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
void DebugUseLsdb(GlobalRouteManagerLSDB *)
Debugging routine; allow client code to supply a pre-built LSDB.
void SetLSA(GlobalRoutingLSA *lsa)
Set the Global Router Link State Advertisement returned by the Global Router represented by this SPFV...
void SetRootExitDirection(Ipv4Address 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(Ipv4Address id)
Set the Vertex ID field of a SPFVertex object.
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.
GlobalRoutingLSA * GetLSA(Ipv4Address addr) const
Look up the Link State Advertisement associated with the given link state ID (address).
void Insert(Ipv4Address addr, GlobalRoutingLSA *lsa)
Insert an IP address / Link State Advertisement pair into the Link State Database.
static Ipv4Address GetZero(void)
An interface aggregated to a node to provide global routing info.
void MergeRootExitDirections(const SPFVertex *vertex)
Merge into 'this' vertex the list of exit directions from another vertex.
Ipv4Address GetLinkData(void) const
Get the Link Data field of the Global Routing Link Record.
#define NS_ASSERT_MSG(condition, message)
uint32_t GetNRootExitDirections() const
Get the number of exit directions from root for reaching 'this' vertex.
Ipv4 addresses are stored in host order in this class.
SPFVertex * Find(const Ipv4Address addr) const
Searches the Candidate Queue for a Shortest Path First Vertex pointer that points to a vertex having ...
uint32_t GetId(void) const
static uint32_t GetSystemId()
static Iterator Begin(void)
SPFVertex * GetParent(uint32_t i=0) const
Get a pointer to the SPFVector that is the parent of "this" SPFVertex.
NodeExit_t GetRootExitDirection() const
Obtain a pair indicating the exit direction from the root.
VertexType GetVertexType(void) const
Get the Vertex Type field of a SPFVertex object.
The Link State DataBase (LSDB) of the Global Route Manager.
void SetVertexProcessed(bool value)
Set the value of the VertexProcessed flag.
VertexType
Enumeration of the possible types of SPFVertex objects.
Ipv4Address GetAttachedRouter(uint32_t n) const
Return an Ipv4Address corresponding to the specified attached router.
virtual void BuildGlobalRoutingDatabase()
Build the routing database by gathering Link State Advertisements from each node exporting a GlobalRo...
Ptr< Node > GetNode(void) const
Get the Node pointer of the node that originated this LSA.
void Reorder(void)
Reorders the Candidate Queue according to the priority scheme.
LinkType GetLinkType(void) const
Get the Link Type field of the Global Routing Link Record.
GlobalRouteManagerLSDB()
Construct an empty Global Router Manager Link State Database.
bool IsVertexProcessed(void) const
Check the value of the VertexProcessed flag.
Ptr< T > GetObject(void) const
Ipv4Address GetVertexId(void) const
Get the Vertex ID field of a SPFVertex object.
SPFVertex * GetChild(uint32_t n) const
Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex.
Ipv4Address GetLinkStateId(void) const
Get the Link State ID as defined by the OSPF spec. We always set it to the router ID of the router ma...
uint32_t AddChild(SPFVertex *child)
Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex.