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"
50 os <<
"(" << exit.first <<
" ," << exit.second <<
")";
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"),
87 m_nextHop (
"0.0.0.0"),
90 m_vertexProcessed (false)
96 m_vertexId (lsa->GetLinkStateId ()),
100 m_nextHop (
"0.0.0.0"),
103 m_vertexProcessed (false)
128 for (ListOfSPFVertex_t::iterator piter =
m_parents.begin ();
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!");
156 if (p == 0)
continue;
244 NS_LOG_LOGIC (
"Index to SPFVertex's parent is out-of-range.");
247 ListOfSPFVertex_t::const_iterator iter =
m_parents.begin ();
295 typedef ListOfNodeExit_t::const_iterator CIter_t;
299 while (i-- > 0) { iter++; }
323 extList.begin (), extList.end ());
337 NS_LOG_WARN (
"x root exit directions in this vertex are going to be discarded");
364 for ( ListOfSPFVertex_t::const_iterator i =
m_children.begin ();
424 LSDBMap_t::iterator i;
445 LSDBMap_t::iterator i;
486 LSDBMap_t::const_iterator i;
489 if (i->first == addr)
504 LSDBMap_t::const_iterator i;
576 for (j = 0; j < nRoutes; j++)
630 uint32_t numLSAs = rtr->DiscoverLSAs ();
633 for (uint32_t j = 0; j < numLSAs; ++j)
640 rtr->GetLSA (j, *lsa);
712 if (rtr && rtr->GetNumLSAs () )
741 uint32_t distance = 0;
742 uint32_t numRecordsInVertex = 0;
756 for (uint32_t i = 0; i < numRecordsInVertex; i++)
772 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
791 else if (l->GetLinkType () ==
874 <<
"return false, but it does now!");
1057 " goes through next hop " << nextHop <<
1058 " via outgoing interface " << outIf <<
1059 " with distance " << distance);
1069 w_lsa->GetNetworkLSANetworkMask () );
1077 " via outgoing interface " << outIf <<
1078 " with distance " << distance);
1106 " goes through next hop " << nextHop <<
1107 " via outgoing interface " << outIf);
1162 bool found_prev_link =
false;
1171 found_prev_link =
true;
1191 if (!found_prev_link)
1193 NS_LOG_LOGIC (
"Skipping links before prev_link found");
1194 found_prev_link =
true;
1271 NS_LOG_WARN (
"all nodes should have at least one transit link:" << root );
1284 NS_LOG_LOGIC (
"TBD: Would have inserted default for transit");
1294 for (uint32_t j = 0; j < nLinkRecords; ++j)
1314 NS_LOG_LOGIC (
"Inserting default route for node " << myRouterId <<
" to next hop " <<
1356 NS_LOG_LOGIC (
"Starting SPFCalculate for node " << root);
1367 NS_LOG_LOGIC (
"SPFCalculate truncated for stub node " << root);
1396 if (candidate.
Size () == 0)
1410 v = candidate.
Pop ();
1496 NS_LOG_LOGIC (
"Processing external for destination " <<
1506 NS_LOG_LOGIC (
"Found advertising router to destination");
1514 NS_LOG_LOGIC (
"Vertex's child " << i <<
" not yet processed, processing...");
1554 for (; i != listEnd; i++)
1574 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1576 if (rtr->GetRouterId () == routerId)
1586 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1587 "QI for <Ipv4> interface failed");
1595 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1596 "Expected valid LSA in SPFVertex* v");
1627 int32_t outIf = exit.second;
1632 " add external network route to " << tempip <<
1633 " using next hop " << nextHop <<
1634 " via interface " << outIf);
1639 " NOT able to add network route to " << tempip <<
1640 " using next hop " << nextHop <<
1641 " since outgoing interface id is negative");
1670 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
1693 "GlobalRouteManagerImpl::SPFIntraAddStub (): Root pointer not set");
1723 for (; i != listEnd; i++)
1745 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1747 if (rtr->GetRouterId () == routerId)
1757 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1758 "QI for <Ipv4> interface failed");
1766 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1767 "Expected valid LSA in SPFVertex* v");
1798 int32_t outIf = exit.second;
1803 " add network route to " << tempip <<
1804 " using next hop " << nextHop <<
1805 " via interface " << outIf);
1810 " NOT able to add network route to " << tempip <<
1811 " using next hop " << nextHop <<
1812 " since outgoing interface id is negative");
1847 for (; i != listEnd; i++)
1862 if (rtr->GetRouterId () == routerId)
1872 "GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
1873 "GetObject for <Ipv4> interface failed");
1879 int32_t
interface = ipv4->GetInterfaceForPrefix (a, amask);
1884 NS_FATAL_ERROR (
"GlobalRouteManagerImpl::FindOutgoingInterfaceId(): "
1885 "Expected an interface associated with address a:" << a);
1894 NS_LOG_LOGIC (
"FindOutgoingInterfaceId():Can't find root node " << routerId);
1920 "GlobalRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set");
1938 for (; i != listEnd; i++)
1960 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1962 if (rtr->GetRouterId () == routerId)
1972 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1973 "GetObject for <Ipv4> interface failed");
1982 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1983 "Expected valid LSA in SPFVertex* v");
1995 " found " << nLinkRecords <<
" link records in LSA " << lsa <<
"with LinkStateId "<< lsa->
GetLinkStateId ());
1996 for (uint32_t j = 0; j < nLinkRecords; ++j)
2033 int32_t outIf = exit.second;
2040 " using next hop " << nextHop <<
2041 " and outgoing interface " << outIf);
2046 " NOT able to add host route to " << lr->
GetLinkData () <<
2047 " using next hop " << nextHop <<
2048 " since outgoing interface id is negative " << outIf);
2065 "GlobalRouteManagerImpl::SPFIntraAddTransit (): Root pointer not set");
2083 for (; i != listEnd; i++)
2105 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
2107 if (rtr->GetRouterId () == routerId)
2117 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2118 "GetObject for <Ipv4> interface failed");
2127 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2128 "Expected valid LSA in SPFVertex* v");
2146 int32_t outIf = exit.second;
2152 " add network route to " << tempip <<
2153 " using next hop " << nextHop <<
2154 " via interface " << outIf);
2159 " NOT able to add network route to " << tempip <<
2160 " using next hop " << nextHop <<
2161 " since outgoing interface id is negative " << outIf);
2182 for (uint32_t i=0;;)
2186 if ((parent = v->
GetParent (i++)) == 0)
break;