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++)
777 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
796 else if (l->GetLinkType () ==
879 <<
"return false, but it does now!");
1062 " goes through next hop " << nextHop <<
1063 " via outgoing interface " << outIf <<
1064 " with distance " << distance);
1074 w_lsa->GetNetworkLSANetworkMask () );
1082 " via outgoing interface " << outIf <<
1083 " with distance " << distance);
1111 " goes through next hop " << nextHop <<
1112 " via outgoing interface " << outIf);
1167 bool found_prev_link =
false;
1176 found_prev_link =
true;
1196 if (!found_prev_link)
1198 NS_LOG_LOGIC (
"Skipping links before prev_link found");
1199 found_prev_link =
true;
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)
1319 NS_LOG_LOGIC (
"Inserting default route for node " << myRouterId <<
" to next hop " <<
1361 NS_LOG_LOGIC (
"Starting SPFCalculate for node " << root);
1372 NS_LOG_LOGIC (
"SPFCalculate truncated for stub node " << root);
1401 if (candidate.
Size () == 0)
1415 v = candidate.
Pop ();
1501 NS_LOG_LOGIC (
"Processing external for destination " <<
1511 NS_LOG_LOGIC (
"Found advertising router to destination");
1519 NS_LOG_LOGIC (
"Vertex's child " << i <<
" not yet processed, processing...");
1559 for (; i != listEnd; i++)
1579 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1581 if (rtr->GetRouterId () == routerId)
1591 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1592 "QI for <Ipv4> interface failed");
1600 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1601 "Expected valid LSA in SPFVertex* v");
1632 int32_t outIf = exit.second;
1637 " add external network route to " << tempip <<
1638 " using next hop " << nextHop <<
1639 " via interface " << outIf);
1644 " NOT able to add network route to " << tempip <<
1645 " using next hop " << nextHop <<
1646 " since outgoing interface id is negative");
1675 NS_LOG_LOGIC (
"Found a Stub record to " << l->GetLinkId ());
1698 "GlobalRouteManagerImpl::SPFIntraAddStub (): Root pointer not set");
1728 for (; i != listEnd; i++)
1750 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1752 if (rtr->GetRouterId () == routerId)
1762 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1763 "QI for <Ipv4> interface failed");
1771 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1772 "Expected valid LSA in SPFVertex* v");
1803 int32_t outIf = exit.second;
1808 " add network route to " << tempip <<
1809 " using next hop " << nextHop <<
1810 " via interface " << outIf);
1815 " NOT able to add network route to " << tempip <<
1816 " using next hop " << nextHop <<
1817 " since outgoing interface id is negative");
1852 for (; i != listEnd; i++)
1867 if (rtr->GetRouterId () == routerId)
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);
1925 "GlobalRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set");
1943 for (; i != listEnd; i++)
1965 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
1967 if (rtr->GetRouterId () == routerId)
1977 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1978 "GetObject for <Ipv4> interface failed");
1987 "GlobalRouteManagerImpl::SPFIntraAddRouter (): "
1988 "Expected valid LSA in SPFVertex* v");
2000 " found " << nLinkRecords <<
" link records in LSA " << lsa <<
"with LinkStateId "<< lsa->
GetLinkStateId ());
2001 for (uint32_t j = 0; j < nLinkRecords; ++j)
2038 int32_t outIf = exit.second;
2045 " using next hop " << nextHop <<
2046 " and outgoing interface " << outIf);
2051 " NOT able to add host route to " << lr->
GetLinkData () <<
2052 " using next hop " << nextHop <<
2053 " since outgoing interface id is negative " << outIf);
2070 "GlobalRouteManagerImpl::SPFIntraAddTransit (): Root pointer not set");
2088 for (; i != listEnd; i++)
2110 NS_LOG_LOGIC (
"Considering router " << rtr->GetRouterId ());
2112 if (rtr->GetRouterId () == routerId)
2122 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2123 "GetObject for <Ipv4> interface failed");
2132 "GlobalRouteManagerImpl::SPFIntraAddTransit (): "
2133 "Expected valid LSA in SPFVertex* v");
2151 int32_t outIf = exit.second;
2157 " add network route to " << tempip <<
2158 " using next hop " << nextHop <<
2159 " via interface " << outIf);
2164 " NOT able to add network route to " << tempip <<
2165 " using next hop " << nextHop <<
2166 " since outgoing interface id is negative " << outIf);
2187 for (uint32_t i=0;;)
2191 if ((parent = v->
GetParent (i++)) == 0)
break;