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 ();
427 LSDBMap_t::iterator i;
448 LSDBMap_t::iterator i;
491 LSDBMap_t::const_iterator i;
494 if (i->first == addr)
509 LSDBMap_t::const_iterator i;
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 () )
746 uint32_t distance = 0;
747 uint32_t numRecordsInVertex = 0;
761 for (uint32_t i = 0; i < numRecordsInVertex; i++)
778 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
797 else if (l->GetLinkType () ==
881 <<
"return false, but it does now!");
1064 " goes through next hop " << nextHop <<
1065 " via outgoing interface " << outIf <<
1066 " with distance " << distance);
1076 w_lsa->GetNetworkLSANetworkMask () );
1084 " via outgoing interface " << outIf <<
1085 " with distance " << distance);
1113 " goes through next hop " << nextHop <<
1114 " via outgoing interface " << outIf);
1169 bool found_prev_link =
false;
1178 found_prev_link =
true;
1198 if (!found_prev_link)
1200 NS_LOG_LOGIC (
"Skipping links before prev_link found");
1201 found_prev_link =
true;
1278 NS_LOG_WARN (
"all nodes should have at least one transit link:" << root );
1291 NS_LOG_LOGIC (
"TBD: Would have inserted default for transit");
1301 for (uint32_t j = 0; j < nLinkRecords; ++j)
1321 NS_LOG_LOGIC (
"Inserting default route for node " << myRouterId <<
" to next hop " <<
1363 NS_LOG_LOGIC (
"Starting SPFCalculate for node " << root);
1374 NS_LOG_LOGIC (
"SPFCalculate truncated for stub node " << root);
1403 if (candidate.
Size () == 0)
1417 v = candidate.
Pop ();
1503 NS_LOG_LOGIC (
"Processing external for destination " <<
1513 NS_LOG_LOGIC (
"Found advertising router to destination");
1521 NS_LOG_LOGIC (
"Vertex's child " << i <<
" not yet processed, processing...");
1561 for (; i != listEnd; i++)
1581 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1583 if (rtr->GetRouterId () == routerId)
1593 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1594 "QI for <Ipv4> interface failed");
1602 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1603 "Expected valid LSA in SPFVertex* v");
1634 int32_t outIf = exit.second;
1639 " add external network route to " << tempip <<
1640 " using next hop " << nextHop <<
1641 " via interface " << outIf);
1646 " NOT able to add network route to " << tempip <<
1647 " using next hop " << nextHop <<
1648 " since outgoing interface id is negative");
1677 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
1700 "GlobalRouteManagerImpl::SPFIntraAddStub (): Root pointer not set");
1730 for (; i != listEnd; i++)
1752 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1754 if (rtr->GetRouterId () == routerId)
1764 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1765 "QI for <Ipv4> interface failed");
1773 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1774 "Expected valid LSA in SPFVertex* v");
1805 int32_t outIf = exit.second;
1810 " add network route to " << tempip <<
1811 " using next hop " << nextHop <<
1812 " via interface " << outIf);
1817 " NOT able to add network route to " << tempip <<
1818 " using next hop " << nextHop <<
1819 " since outgoing interface id is negative");
1854 for (; i != listEnd; i++)
1869 if (rtr->GetRouterId () == routerId)
1879 "GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
1880 "GetObject for <Ipv4> interface failed");
1886 int32_t
interface = ipv4->GetInterfaceForPrefix (a, amask);
1891 NS_FATAL_ERROR (
"GlobalRouteManagerImpl::FindOutgoingInterfaceId(): "
1892 "Expected an interface associated with address a:" << a);
1901 NS_LOG_LOGIC (
"FindOutgoingInterfaceId():Can't find root node " << routerId);
1927 "GlobalRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set");
1945 for (; i != listEnd; i++)
1967 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1969 if (rtr->GetRouterId () == routerId)
1979 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1980 "GetObject for <Ipv4> interface failed");
1989 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1990 "Expected valid LSA in SPFVertex* v");
2002 " found " << nLinkRecords <<
" link records in LSA " << lsa <<
"with LinkStateId "<< lsa->
GetLinkStateId ());
2003 for (uint32_t j = 0; j < nLinkRecords; ++j)
2040 int32_t outIf = exit.second;
2047 " using next hop " << nextHop <<
2048 " and outgoing interface " << outIf);
2053 " NOT able to add host route to " << lr->
GetLinkData () <<
2054 " using next hop " << nextHop <<
2055 " since outgoing interface id is negative " << outIf);
2072 "GlobalRouteManagerImpl::SPFIntraAddTransit (): Root pointer not set");
2090 for (; i != listEnd; i++)
2112 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
2114 if (rtr->GetRouterId () == routerId)
2124 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2125 "GetObject for <Ipv4> interface failed");
2134 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2135 "Expected valid LSA in SPFVertex* v");
2153 int32_t outIf = exit.second;
2159 " add network route to " << tempip <<
2160 " using next hop " << nextHop <<
2161 " via interface " << outIf);
2166 " NOT able to add network route to " << tempip <<
2167 " using next hop " << nextHop <<
2168 " since outgoing interface id is negative " << outIf);
2189 for (uint32_t i=0;;)
2193 if ((parent = v->
GetParent (i++)) == 0)
break;