rename party
This commit is contained in:
@@ -9,6 +9,9 @@ def build(bld):
|
||||
obj.source = source
|
||||
return obj
|
||||
|
||||
obj = create_ns_prog('simple-p2p', 'simple-p2p.cc', deps=['p2p', 'internet-node'])
|
||||
obj = create_ns_prog('simple-static-routing', 'simple-static-routing.cc', deps=['p2p', 'internet-node', 'routing'])
|
||||
obj = create_ns_prog('simple-p2p', 'simple-p2p.cc',
|
||||
deps=['p2p', 'internet-node'])
|
||||
|
||||
obj = create_ns_prog('simple-global-routing', 'simple-global-routing.cc',
|
||||
deps=['p2p', 'internet-node', 'routing'])
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/routing-environment.h"
|
||||
#include "ns3/static-router.h"
|
||||
#include "ns3/global-router-interface.h"
|
||||
|
||||
#include "l3-demux.h"
|
||||
#include "ipv4-l4-demux.h"
|
||||
@@ -83,10 +83,10 @@ InternetNode::Construct (void)
|
||||
// of the StaticRouter interface tells the route manager that it needs to
|
||||
// ask a given node about any link state records that it may want to advertise.
|
||||
//
|
||||
if (RoutingEnvironment::StaticRoutingEnabled())
|
||||
if (RoutingEnvironment::GlobalRoutingEnabled())
|
||||
{
|
||||
Ptr<StaticRouter> staticRouter = Create<StaticRouter> (this);
|
||||
Object::AddInterface (staticRouter);
|
||||
Ptr<GlobalRouter> globalRouter = Create<GlobalRouter> (this);
|
||||
Object::AddInterface (globalRouter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <list>
|
||||
#include "static-route-manager-impl.h"
|
||||
#include "global-route-manager-impl.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "static-router.h"
|
||||
#include "static-route-manager-impl.h"
|
||||
#include "global-router-interface.h"
|
||||
#include "global-route-manager-impl.h"
|
||||
#include "candidate-queue.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("StaticRouteManager");
|
||||
NS_DEBUG_COMPONENT_DEFINE ("GlobalRouteManager");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -48,7 +48,7 @@ SPFVertex::SPFVertex () :
|
||||
{
|
||||
}
|
||||
|
||||
SPFVertex::SPFVertex (StaticRouterLSA* lsa) :
|
||||
SPFVertex::SPFVertex (GlobalRouterLSA* lsa) :
|
||||
m_vertexType (VertexRouter),
|
||||
m_vertexId (lsa->GetLinkStateId ()),
|
||||
m_lsa (lsa),
|
||||
@@ -99,12 +99,12 @@ SPFVertex::GetVertexId (void) const
|
||||
}
|
||||
|
||||
void
|
||||
SPFVertex::SetLSA (StaticRouterLSA* lsa)
|
||||
SPFVertex::SetLSA (GlobalRouterLSA* lsa)
|
||||
{
|
||||
m_lsa = lsa;
|
||||
}
|
||||
|
||||
StaticRouterLSA*
|
||||
GlobalRouterLSA*
|
||||
SPFVertex::GetLSA (void) const
|
||||
{
|
||||
return m_lsa;
|
||||
@@ -191,56 +191,56 @@ SPFVertex::AddChild (SPFVertex* child)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// StaticRouteManagerLSDB Implementation
|
||||
// GlobalRouteManagerLSDB Implementation
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
StaticRouteManagerLSDB::StaticRouteManagerLSDB ()
|
||||
GlobalRouteManagerLSDB::GlobalRouteManagerLSDB ()
|
||||
:
|
||||
m_database ()
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::StaticRouteManagerLSDB ()");
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::GlobalRouteManagerLSDB ()");
|
||||
}
|
||||
|
||||
StaticRouteManagerLSDB::~StaticRouteManagerLSDB ()
|
||||
GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB ()
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::~StaticRouteManagerLSDB ()");
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB ()");
|
||||
|
||||
LSDBMap_t::iterator i;
|
||||
for (i= m_database.begin (); i!= m_database.end (); i++)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::~StaticRouteManagerLSDB ():free LSA");
|
||||
StaticRouterLSA* temp = i->second;
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB ():free LSA");
|
||||
GlobalRouterLSA* temp = i->second;
|
||||
delete temp;
|
||||
}
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::~StaticRouteManagerLSDB (): clear map");
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB (): clear map");
|
||||
m_database.clear ();
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouteManagerLSDB::Initialize ()
|
||||
GlobalRouteManagerLSDB::Initialize ()
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::Initialize ()");
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::Initialize ()");
|
||||
|
||||
LSDBMap_t::iterator i;
|
||||
for (i= m_database.begin (); i!= m_database.end (); i++)
|
||||
{
|
||||
StaticRouterLSA* temp = i->second;
|
||||
temp->SetStatus (StaticRouterLSA::LSA_SPF_NOT_EXPLORED);
|
||||
GlobalRouterLSA* temp = i->second;
|
||||
temp->SetStatus (GlobalRouterLSA::LSA_SPF_NOT_EXPLORED);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouteManagerLSDB::Insert (Ipv4Address addr, StaticRouterLSA* lsa)
|
||||
GlobalRouteManagerLSDB::Insert (Ipv4Address addr, GlobalRouterLSA* lsa)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::Insert ()");
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::Insert ()");
|
||||
m_database.insert (LSDBPair_t (addr, lsa));
|
||||
}
|
||||
|
||||
StaticRouterLSA*
|
||||
StaticRouteManagerLSDB::GetLSA (Ipv4Address addr) const
|
||||
GlobalRouterLSA*
|
||||
GlobalRouteManagerLSDB::GetLSA (Ipv4Address addr) const
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerLSDB::GetLSA ()");
|
||||
NS_DEBUG ("GlobalRouteManagerLSDB::GetLSA ()");
|
||||
//
|
||||
// Look up an LSA by its address.
|
||||
//
|
||||
@@ -257,21 +257,21 @@ StaticRouteManagerLSDB::GetLSA (Ipv4Address addr) const
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// StaticRouteManagerImpl Implementation
|
||||
// GlobalRouteManagerImpl Implementation
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
StaticRouteManagerImpl::StaticRouteManagerImpl ()
|
||||
GlobalRouteManagerImpl::GlobalRouteManagerImpl ()
|
||||
:
|
||||
m_spfroot (0)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::StaticRoutemanagerImpl ()");
|
||||
m_lsdb = new StaticRouteManagerLSDB ();
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::GlobalRoutemanagerImpl ()");
|
||||
m_lsdb = new GlobalRouteManagerLSDB ();
|
||||
}
|
||||
|
||||
StaticRouteManagerImpl::~StaticRouteManagerImpl ()
|
||||
GlobalRouteManagerImpl::~GlobalRouteManagerImpl ()
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::~StaticRouteManagerImpl ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::~GlobalRouteManagerImpl ()");
|
||||
|
||||
if (m_lsdb)
|
||||
{
|
||||
@@ -280,9 +280,9 @@ StaticRouteManagerImpl::~StaticRouteManagerImpl ()
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouteManagerImpl::DebugUseLsdb (StaticRouteManagerLSDB* lsdb)
|
||||
GlobalRouteManagerImpl::DebugUseLsdb (GlobalRouteManagerLSDB* lsdb)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::DebugUseLsdb ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::DebugUseLsdb ()");
|
||||
|
||||
if (m_lsdb)
|
||||
{
|
||||
@@ -293,7 +293,7 @@ StaticRouteManagerImpl::DebugUseLsdb (StaticRouteManagerLSDB* lsdb)
|
||||
|
||||
//
|
||||
// In order to build the routing database, we need to walk the list of nodes
|
||||
// in the system and look for those that support the StaticRouter interface.
|
||||
// in the system and look for those that support the GlobalRouter interface.
|
||||
// These routers will export a number of Link State Advertisements (LSAs)
|
||||
// that describe the links and networks that are "adjacent" (i.e., that are
|
||||
// on the other side of a point-to-point link). We take these LSAs and put
|
||||
@@ -301,19 +301,19 @@ StaticRouteManagerImpl::DebugUseLsdb (StaticRouteManagerLSDB* lsdb)
|
||||
// ultimately be computed.
|
||||
//
|
||||
void
|
||||
StaticRouteManagerImpl::BuildStaticRoutingDatabase ()
|
||||
GlobalRouteManagerImpl::BuildGlobalRoutingDatabase ()
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::BuildStaticRoutingDatabase()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::BuildGlobalRoutingDatabase()");
|
||||
//
|
||||
// Walk the list of nodes looking for the StaticRouter Interface.
|
||||
// Walk the list of nodes looking for the GlobalRouter Interface.
|
||||
//
|
||||
typedef std::vector < Ptr<Node> >::iterator Iterator;
|
||||
for (Iterator i = NodeList::Begin (); i != NodeList::End (); i++)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
|
||||
Ptr<StaticRouter> rtr =
|
||||
node->QueryInterface<StaticRouter> (StaticRouter::iid);
|
||||
Ptr<GlobalRouter> rtr =
|
||||
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
|
||||
//
|
||||
// Ignore nodes that aren't participating in routing.
|
||||
//
|
||||
@@ -324,7 +324,7 @@ StaticRouteManagerImpl::BuildStaticRoutingDatabase ()
|
||||
//
|
||||
// You must call DiscoverLSAs () before trying to use any routing info or to
|
||||
// update LSAs. DiscoverLSAs () drives the process of discovering routes in
|
||||
// the StaticRouter. Afterward, you may use GetNumLSAs (), which is a very
|
||||
// the GlobalRouter. Afterward, you may use GetNumLSAs (), which is a very
|
||||
// computationally inexpensive call. If you call GetNumLSAs () before calling
|
||||
// DiscoverLSAs () will get zero as the number since no routes have been
|
||||
// found.
|
||||
@@ -334,7 +334,7 @@ StaticRouteManagerImpl::BuildStaticRoutingDatabase ()
|
||||
|
||||
for (uint32_t j = 0; j < numLSAs; ++j)
|
||||
{
|
||||
StaticRouterLSA* lsa = new StaticRouterLSA ();
|
||||
GlobalRouterLSA* lsa = new GlobalRouterLSA ();
|
||||
//
|
||||
// This is the call to actually fetch a Link State Advertisement from the
|
||||
// router.
|
||||
@@ -351,8 +351,8 @@ StaticRouteManagerImpl::BuildStaticRoutingDatabase ()
|
||||
}
|
||||
|
||||
//
|
||||
// For each node that is a static router (which is determined by the presence
|
||||
// of an aggregated StaticRouter interface), run the Dijkstra SPF calculation
|
||||
// For each node that is a global router (which is determined by the presence
|
||||
// of an aggregated GlobalRouter interface), run the Dijkstra SPF calculation
|
||||
// on the database rooted at that router, and populate the node forwarding
|
||||
// tables.
|
||||
//
|
||||
@@ -384,9 +384,9 @@ StaticRouteManagerImpl::BuildStaticRoutingDatabase ()
|
||||
// list becomes empty.
|
||||
//
|
||||
void
|
||||
StaticRouteManagerImpl::InitializeRoutes ()
|
||||
GlobalRouteManagerImpl::InitializeRoutes ()
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::InitializeRoutes ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::InitializeRoutes ()");
|
||||
//
|
||||
// Walk the list of nodes in the system.
|
||||
//
|
||||
@@ -395,13 +395,13 @@ StaticRouteManagerImpl::InitializeRoutes ()
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
//
|
||||
// Look for the StaticRouter interface that indicates that the node is
|
||||
// Look for the GlobalRouter interface that indicates that the node is
|
||||
// participating in routing.
|
||||
//
|
||||
Ptr<StaticRouter> rtr =
|
||||
node->QueryInterface<StaticRouter> (StaticRouter::iid);
|
||||
Ptr<GlobalRouter> rtr =
|
||||
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
|
||||
//
|
||||
// if the node has a static router interface, then run the static routing
|
||||
// if the node has a global router interface, then run the global routing
|
||||
// algorithms.
|
||||
//
|
||||
if (rtr && rtr->GetNumLSAs () )
|
||||
@@ -425,13 +425,13 @@ StaticRouteManagerImpl::InitializeRoutes ()
|
||||
// vertex already on the candidate list, store the new (lower) cost.
|
||||
//
|
||||
void
|
||||
StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
GlobalRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
{
|
||||
SPFVertex* w = 0;
|
||||
StaticRouterLSA* w_lsa = 0;
|
||||
GlobalRouterLSA* w_lsa = 0;
|
||||
uint32_t distance = 0;
|
||||
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFNext ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFNext ()");
|
||||
//
|
||||
// Always true for now, since all our LSAs are RouterLSAs.
|
||||
//
|
||||
@@ -452,8 +452,8 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
// Links to stub networks will be considered in the second stage of the
|
||||
// shortest path calculation.
|
||||
//
|
||||
StaticRouterLinkRecord *l = v->GetLSA ()->GetLinkRecord (i);
|
||||
if (l->GetLinkType () == StaticRouterLinkRecord::StubNetwork)
|
||||
GlobalRouterLinkRecord *l = v->GetLSA ()->GetLinkRecord (i);
|
||||
if (l->GetLinkType () == GlobalRouterLinkRecord::StubNetwork)
|
||||
{
|
||||
NS_DEBUG ("SPFNext: Found a Stub record to " <<
|
||||
l->GetLinkId ());
|
||||
@@ -464,7 +464,7 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
// the vertex W's LSA (router-LSA or network-LSA) in Area A's link state
|
||||
// database.
|
||||
//
|
||||
if (l->GetLinkType () == StaticRouterLinkRecord::PointToPoint)
|
||||
if (l->GetLinkType () == GlobalRouterLinkRecord::PointToPoint)
|
||||
{
|
||||
//
|
||||
// Lookup the link state advertisement of the new link -- we call it <w> in
|
||||
@@ -482,7 +482,7 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
// then we have it covered -- ignore it.
|
||||
//
|
||||
if (w_lsa->GetStatus () ==
|
||||
StaticRouterLSA::LSA_SPF_IN_SPFTREE)
|
||||
GlobalRouterLSA::LSA_SPF_IN_SPFTREE)
|
||||
{
|
||||
NS_DEBUG ("SPFNext: Skipping-> LSA "<<
|
||||
w_lsa->GetLinkStateId () << " already in SPF tree");
|
||||
@@ -502,7 +502,7 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
w_lsa->GetLinkStateId ());
|
||||
|
||||
if (w_lsa->GetStatus () ==
|
||||
StaticRouterLSA::LSA_SPF_NOT_EXPLORED)
|
||||
GlobalRouterLSA::LSA_SPF_NOT_EXPLORED)
|
||||
{
|
||||
//
|
||||
// If we haven't yet considered the link represented by <w> we have to create
|
||||
@@ -518,7 +518,7 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
if (SPFNexthopCalculation (v, w, l, distance))
|
||||
{
|
||||
w_lsa->SetStatus (
|
||||
StaticRouterLSA::LSA_SPF_CANDIDATE);
|
||||
GlobalRouterLSA::LSA_SPF_CANDIDATE);
|
||||
//
|
||||
// Push this new vertex onto the priority queue (ordered by distance from the
|
||||
// root node).
|
||||
@@ -530,7 +530,7 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
}
|
||||
}
|
||||
} else if (w_lsa->GetStatus () ==
|
||||
StaticRouterLSA::LSA_SPF_CANDIDATE)
|
||||
GlobalRouterLSA::LSA_SPF_CANDIDATE)
|
||||
{
|
||||
//
|
||||
// We have already considered the link represented by <w>. What wse have to
|
||||
@@ -589,13 +589,13 @@ StaticRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate)
|
||||
// For now, this is greatly simplified from the quagga code
|
||||
//
|
||||
int
|
||||
StaticRouteManagerImpl::SPFNexthopCalculation (
|
||||
GlobalRouteManagerImpl::SPFNexthopCalculation (
|
||||
SPFVertex* v,
|
||||
SPFVertex* w,
|
||||
StaticRouterLinkRecord* l,
|
||||
GlobalRouterLinkRecord* l,
|
||||
uint32_t distance)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFNexthopCalculation ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFNexthopCalculation ()");
|
||||
//
|
||||
// The vertex m_spfroot is a distinguished vertex representing the node at
|
||||
// the root of the calculations. That is, it is the node for which we are
|
||||
@@ -633,7 +633,7 @@ StaticRouteManagerImpl::SPFNexthopCalculation (
|
||||
{
|
||||
//
|
||||
// In the case of point-to-point links, the link data field (m_linkData) of a
|
||||
// Static Router Link Record contains the local IP address. If we look at the
|
||||
// Global Router Link Record contains the local IP address. If we look at the
|
||||
// link record describing the link from the perspecive of <w> (the remote
|
||||
// node from the viewpoint of <v>) back to the root node, we can discover the
|
||||
// IP address of the router to which <v> is adjacent. This is a distinguished
|
||||
@@ -644,12 +644,12 @@ StaticRouteManagerImpl::SPFNexthopCalculation (
|
||||
// return the link record describing the link from <w> to <v>. Think of it as
|
||||
// SPFGetLink.
|
||||
//
|
||||
StaticRouterLinkRecord *linkRemote = 0;
|
||||
GlobalRouterLinkRecord *linkRemote = 0;
|
||||
linkRemote = SPFGetNextLink (w, v, linkRemote);
|
||||
//
|
||||
// At this point, <l> is the Static Router Link Record describing the point-
|
||||
// At this point, <l> is the Global Router Link Record describing the point-
|
||||
// to point link from <v> to <w> from the perspective of <v>; and <linkRemote>
|
||||
// is the Static Router Link Record describing that same link from the
|
||||
// is the Global Router Link Record describing that same link from the
|
||||
// perspective of <w> (back to <v>). Now we can just copy the next hop
|
||||
// address from the m_linkData member variable.
|
||||
//
|
||||
@@ -702,25 +702,28 @@ StaticRouteManagerImpl::SPFNexthopCalculation (
|
||||
//
|
||||
// This method is derived from quagga ospf_get_next_link ()
|
||||
//
|
||||
// First search the Static Router Link Records of vertex <v> for one
|
||||
// First search the Global Router Link Records of vertex <v> for one
|
||||
// representing a point-to point link to vertex <w>.
|
||||
//
|
||||
// What is done depends on prev_link. Contrary to appearances, prev_link just
|
||||
// acts as a flag here. If prev_link is NULL, we return the first Static
|
||||
// acts as a flag here. If prev_link is NULL, we return the first Global
|
||||
// Router Link Record we find that describes a point-to-point link from <v>
|
||||
// to <w>. If prev_link is not NULL, we return a Static Router Link Record
|
||||
// to <w>. If prev_link is not NULL, we return a Global Router Link Record
|
||||
// representing a possible *second* link from <v> to <w>.
|
||||
//
|
||||
StaticRouterLinkRecord*
|
||||
StaticRouteManagerImpl::SPFGetNextLink (
|
||||
// BUGBUG FIXME: This seems to be a bug. Shouldn't this function look for
|
||||
// any link records after pre_link and not just after the first?
|
||||
//
|
||||
GlobalRouterLinkRecord*
|
||||
GlobalRouteManagerImpl::SPFGetNextLink (
|
||||
SPFVertex* v,
|
||||
SPFVertex* w,
|
||||
StaticRouterLinkRecord* prev_link)
|
||||
GlobalRouterLinkRecord* prev_link)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFGetNextLink ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFGetNextLink ()");
|
||||
|
||||
bool skip = true;
|
||||
StaticRouterLinkRecord* l;
|
||||
GlobalRouterLinkRecord* l;
|
||||
//
|
||||
// If prev_link is 0, we are really looking for the first link, not the next
|
||||
// link.
|
||||
@@ -730,14 +733,14 @@ StaticRouteManagerImpl::SPFGetNextLink (
|
||||
skip = false;
|
||||
}
|
||||
//
|
||||
// Iterate through the Static Router Link Records advertised by the vertex
|
||||
// Iterate through the Global Router Link Records advertised by the vertex
|
||||
// <v> looking for records representing the point-to-point links off of this
|
||||
// vertex.
|
||||
//
|
||||
for (uint32_t i = 0; i < v->GetLSA ()->GetNLinkRecords (); ++i)
|
||||
{
|
||||
l = v->GetLSA ()->GetLinkRecord (i);
|
||||
if (l->GetLinkType () != StaticRouterLinkRecord::PointToPoint)
|
||||
if (l->GetLinkType () != GlobalRouterLinkRecord::PointToPoint)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -768,7 +771,7 @@ StaticRouteManagerImpl::SPFGetNextLink (
|
||||
{
|
||||
//
|
||||
// Skip is true and we've found a link from <v> to <w>. We want the next one.
|
||||
// Setting skip to false gets us the next point-to-point static router link
|
||||
// Setting skip to false gets us the next point-to-point global router link
|
||||
// record in the LSA from <v>.
|
||||
//
|
||||
NS_DEBUG ("SPFGetNextLink: Skipping the found link");
|
||||
@@ -784,17 +787,17 @@ StaticRouteManagerImpl::SPFGetNextLink (
|
||||
// Used for unit tests.
|
||||
//
|
||||
void
|
||||
StaticRouteManagerImpl::DebugSPFCalculate (Ipv4Address root)
|
||||
GlobalRouteManagerImpl::DebugSPFCalculate (Ipv4Address root)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::DebugSPFCalculate ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::DebugSPFCalculate ()");
|
||||
SPFCalculate (root);
|
||||
}
|
||||
|
||||
// quagga ospf_spf_calculate
|
||||
void
|
||||
StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFCalculate (): "
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFCalculate (): "
|
||||
"root = " << root);
|
||||
|
||||
SPFVertex *v;
|
||||
@@ -821,7 +824,7 @@ StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
//
|
||||
m_spfroot= v;
|
||||
v->SetDistanceFromRoot (0);
|
||||
v->GetLSA ()->SetStatus (StaticRouterLSA::LSA_SPF_IN_SPFTREE);
|
||||
v->GetLSA ()->SetStatus (GlobalRouterLSA::LSA_SPF_IN_SPFTREE);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -831,7 +834,7 @@ StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
//
|
||||
// RFC2328 16.1. (2).
|
||||
//
|
||||
// We examine the Static Router Link Records in the Link State
|
||||
// We examine the Global Router Link Records in the Link State
|
||||
// Advertisements of the current vertex. If there are any point-to-point
|
||||
// links to unexplored adjacent vertices we add them to the tree and update
|
||||
// the distance and next hop information on how to get there. We also add
|
||||
@@ -857,7 +860,7 @@ StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
// list in the process).
|
||||
//
|
||||
// Recall that in the previous step, we created SPFVertex structures for each
|
||||
// of the routers found in the Static Router Link Records and added tehm to
|
||||
// of the routers found in the Global Router Link Records and added tehm to
|
||||
// the candidate list.
|
||||
//
|
||||
v = candidate.Pop ();
|
||||
@@ -866,7 +869,7 @@ StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
// Update the status field of the vertex to indicate that it is in the SPF
|
||||
// tree.
|
||||
//
|
||||
v->GetLSA ()->SetStatus (StaticRouterLSA::LSA_SPF_IN_SPFTREE);
|
||||
v->GetLSA ()->SetStatus (GlobalRouterLSA::LSA_SPF_IN_SPFTREE);
|
||||
//
|
||||
// The current vertex has a parent pointer. By calling this rather oddly
|
||||
// named method (blame quagga) we add the current vertex to the list of
|
||||
@@ -893,7 +896,7 @@ StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
// We're going to pop of a pointer to every vertex in the tree except the
|
||||
// root in order of distance from the root. For each of the vertices, we call
|
||||
// SPFIntraAddRouter (). Down in SPFIntraAddRouter, we look at all of the
|
||||
// point-to-point Static Router Link Records (the links to nodes adjacent to
|
||||
// point-to-point Global Router Link Records (the links to nodes adjacent to
|
||||
// the node represented by the vertex). We add a route to the IP address
|
||||
// specified by the m_linkData field of each of those link records. This will
|
||||
// be the *local* IP address associated with the interface attached to the
|
||||
@@ -930,7 +933,7 @@ StaticRouteManagerImpl::SPFCalculate (Ipv4Address root)
|
||||
// Return the interface index corresponding to a given IP address
|
||||
//
|
||||
uint32_t
|
||||
StaticRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a)
|
||||
GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a)
|
||||
{
|
||||
//
|
||||
// We have an IP address <a> and a vertex ID of the root of the SPF tree.
|
||||
@@ -951,10 +954,10 @@ StaticRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
|
||||
Ptr<StaticRouter> rtr =
|
||||
node->QueryInterface<StaticRouter> (StaticRouter::iid);
|
||||
Ptr<GlobalRouter> rtr =
|
||||
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
|
||||
//
|
||||
// If the node doesn't have a StaticRouter interface it can't be the one
|
||||
// If the node doesn't have a GlobalRouter interface it can't be the one
|
||||
// we're interested in.
|
||||
//
|
||||
if (rtr == 0)
|
||||
@@ -972,7 +975,7 @@ StaticRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a)
|
||||
//
|
||||
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG (ipv4,
|
||||
"StaticRouteManagerImpl::FindOutgoingInterfaceId (): "
|
||||
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
|
||||
"QI for <Ipv4> interface failed");
|
||||
//
|
||||
// Look through the interfaces on this node for one that has the IP address
|
||||
@@ -984,7 +987,7 @@ StaticRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a)
|
||||
if (ipv4->GetAddress (i) == a)
|
||||
{
|
||||
NS_DEBUG (
|
||||
"StaticRouteManagerImpl::FindOutgoingInterfaceId (): "
|
||||
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): "
|
||||
"Interface match for " << a);
|
||||
return i;
|
||||
}
|
||||
@@ -1014,12 +1017,12 @@ StaticRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a)
|
||||
// route.
|
||||
//
|
||||
void
|
||||
StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFIntraAddRouter ()");
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFIntraAddRouter ()");
|
||||
|
||||
NS_ASSERT_MSG (m_spfroot,
|
||||
"StaticRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set");
|
||||
"GlobalRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set");
|
||||
//
|
||||
// The root of the Shortest Path First tree is the router to which we are
|
||||
// going to write the actual routing table entries. The vertex corresponding
|
||||
@@ -1029,7 +1032,7 @@ StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
//
|
||||
Ipv4Address routerId = m_spfroot->GetVertexId ();
|
||||
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"Vertex ID = " << routerId);
|
||||
//
|
||||
// We need to walk the list of nodes looking for the one that has the router
|
||||
@@ -1041,17 +1044,17 @@ StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
//
|
||||
// The router ID is accessible through the StaticRouter interface, so we need
|
||||
// to QI for that interface. If there's no StaticRouter interface, the node
|
||||
// The router ID is accessible through the GlobalRouter interface, so we need
|
||||
// to QI for that interface. If there's no GlobalRouter interface, the node
|
||||
// in question cannot be the router we want, so we continue.
|
||||
//
|
||||
Ptr<StaticRouter> rtr =
|
||||
node->QueryInterface<StaticRouter> (StaticRouter::iid);
|
||||
Ptr<GlobalRouter> rtr =
|
||||
node->QueryInterface<GlobalRouter> (GlobalRouter::iid);
|
||||
|
||||
if (rtr == 0)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"No StaticRouter interface on node " << node->GetId ());
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"No GlobalRouter interface on node " << node->GetId ());
|
||||
continue;
|
||||
}
|
||||
//
|
||||
@@ -1059,12 +1062,12 @@ StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
// root of the SPF tree, then this node is the one for which we need to
|
||||
// write the routing tables.
|
||||
//
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"Considering router " << rtr->GetRouterId ());
|
||||
|
||||
if (rtr->GetRouterId () == routerId)
|
||||
{
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"setting routes for node " << node->GetId ());
|
||||
//
|
||||
// Routing information is updated using the Ipv4 interface. We need to QI
|
||||
@@ -1073,17 +1076,17 @@ StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
//
|
||||
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG (ipv4,
|
||||
"StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"QI for <Ipv4> interface failed");
|
||||
//
|
||||
// Get the Static Router Link State Advertisement from the vertex we're
|
||||
// adding the routes to. The LSA will have a number of attached Static Router
|
||||
// Get the Global Router Link State Advertisement from the vertex we're
|
||||
// adding the routes to. The LSA will have a number of attached Global Router
|
||||
// Link Records corresponding to links off of that vertex / node. We're going
|
||||
// to be interested in the records corresponding to point-to-point links.
|
||||
//
|
||||
StaticRouterLSA *lsa = v->GetLSA ();
|
||||
GlobalRouterLSA *lsa = v->GetLSA ();
|
||||
NS_ASSERT_MSG (lsa,
|
||||
"StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
"Expected valid LSA in SPFVertex* v");
|
||||
|
||||
uint32_t nLinkRecords = lsa->GetNLinkRecords ();
|
||||
@@ -1100,13 +1103,13 @@ StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
//
|
||||
// We are only concerned about point-to-point links
|
||||
//
|
||||
StaticRouterLinkRecord *lr = lsa->GetLinkRecord (j);
|
||||
if (lr->GetLinkType () != StaticRouterLinkRecord::PointToPoint)
|
||||
GlobalRouterLinkRecord *lr = lsa->GetLinkRecord (j);
|
||||
if (lr->GetLinkType () != GlobalRouterLinkRecord::PointToPoint)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_DEBUG ("StaticRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SPFIntraAddRouter (): "
|
||||
" Node " << node->GetId () <<
|
||||
" add route to " << lr->GetLinkData () <<
|
||||
" using next hop " << v->GetNextHop () <<
|
||||
@@ -1147,7 +1150,7 @@ StaticRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v)
|
||||
// For now, only one parent (not doing equal-cost multipath)
|
||||
//
|
||||
void
|
||||
StaticRouteManagerImpl::SPFVertexAddParent (SPFVertex* v)
|
||||
GlobalRouteManagerImpl::SPFVertexAddParent (SPFVertex* v)
|
||||
{
|
||||
v->GetParent ()->AddChild (v);
|
||||
}
|
||||
@@ -1166,44 +1169,44 @@ StaticRouteManagerImpl::SPFVertexAddParent (SPFVertex* v)
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class StaticRouterTestNode : public Node
|
||||
class GlobalRouterTestNode : public Node
|
||||
{
|
||||
public:
|
||||
StaticRouterTestNode ();
|
||||
GlobalRouterTestNode ();
|
||||
|
||||
private:
|
||||
virtual void DoAddDevice (Ptr<NetDevice> device) const {};
|
||||
virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
|
||||
};
|
||||
|
||||
StaticRouterTestNode::StaticRouterTestNode ()
|
||||
GlobalRouterTestNode::GlobalRouterTestNode ()
|
||||
{
|
||||
// Ptr<Ipv4L3Protocol> ipv4 = Create<Ipv4L3Protocol> (this);
|
||||
}
|
||||
|
||||
TraceResolver*
|
||||
StaticRouterTestNode::DoCreateTraceResolver (TraceContext const &context)
|
||||
GlobalRouterTestNode::DoCreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
class StaticRouteManagerImplTest : public Test {
|
||||
class GlobalRouteManagerImplTest : public Test {
|
||||
public:
|
||||
StaticRouteManagerImplTest ();
|
||||
virtual ~StaticRouteManagerImplTest ();
|
||||
GlobalRouteManagerImplTest ();
|
||||
virtual ~GlobalRouteManagerImplTest ();
|
||||
virtual bool RunTests (void);
|
||||
};
|
||||
|
||||
StaticRouteManagerImplTest::StaticRouteManagerImplTest ()
|
||||
: Test ("StaticRouteManagerImpl")
|
||||
GlobalRouteManagerImplTest::GlobalRouteManagerImplTest ()
|
||||
: Test ("GlobalRouteManagerImpl")
|
||||
{
|
||||
}
|
||||
|
||||
StaticRouteManagerImplTest::~StaticRouteManagerImplTest ()
|
||||
GlobalRouteManagerImplTest::~GlobalRouteManagerImplTest ()
|
||||
{}
|
||||
|
||||
bool
|
||||
StaticRouteManagerImplTest::RunTests (void)
|
||||
GlobalRouteManagerImplTest::RunTests (void)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
@@ -1246,81 +1249,81 @@ StaticRouteManagerImplTest::RunTests (void)
|
||||
// link2: 10.1.3.1/30, 10.1.3.2/30
|
||||
//
|
||||
// Router 0
|
||||
StaticRouterLinkRecord* lr0 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::PointToPoint,
|
||||
GlobalRouterLinkRecord* lr0 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::PointToPoint,
|
||||
"0.0.0.2", // router ID 0.0.0.2
|
||||
"10.1.1.1", // local ID
|
||||
1); // metric
|
||||
|
||||
StaticRouterLinkRecord* lr1 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::StubNetwork,
|
||||
GlobalRouterLinkRecord* lr1 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::StubNetwork,
|
||||
"10.1.1.1",
|
||||
"255.255.255.252",
|
||||
1);
|
||||
|
||||
StaticRouterLSA* lsa0 = new StaticRouterLSA ();
|
||||
GlobalRouterLSA* lsa0 = new GlobalRouterLSA ();
|
||||
lsa0->SetLinkStateId ("0.0.0.0");
|
||||
lsa0->SetAdvertisingRouter ("0.0.0.0");
|
||||
lsa0->AddLinkRecord (lr0);
|
||||
lsa0->AddLinkRecord (lr1);
|
||||
|
||||
// Router 1
|
||||
StaticRouterLinkRecord* lr2 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::PointToPoint,
|
||||
GlobalRouterLinkRecord* lr2 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::PointToPoint,
|
||||
"0.0.0.2",
|
||||
"10.1.2.1",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr3 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::StubNetwork,
|
||||
GlobalRouterLinkRecord* lr3 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::StubNetwork,
|
||||
"10.1.2.1",
|
||||
"255.255.255.252",
|
||||
1);
|
||||
|
||||
StaticRouterLSA* lsa1 = new StaticRouterLSA ();
|
||||
GlobalRouterLSA* lsa1 = new GlobalRouterLSA ();
|
||||
lsa1->SetLinkStateId ("0.0.0.1");
|
||||
lsa1->SetAdvertisingRouter ("0.0.0.1");
|
||||
lsa1->AddLinkRecord (lr2);
|
||||
lsa1->AddLinkRecord (lr3);
|
||||
|
||||
// Router 2
|
||||
StaticRouterLinkRecord* lr4 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::PointToPoint,
|
||||
GlobalRouterLinkRecord* lr4 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::PointToPoint,
|
||||
"0.0.0.0",
|
||||
"10.1.1.2",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr5 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::StubNetwork,
|
||||
GlobalRouterLinkRecord* lr5 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::StubNetwork,
|
||||
"10.1.1.2",
|
||||
"255.255.255.252",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr6 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::PointToPoint,
|
||||
GlobalRouterLinkRecord* lr6 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::PointToPoint,
|
||||
"0.0.0.1",
|
||||
"10.1.2.2",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr7 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::StubNetwork,
|
||||
GlobalRouterLinkRecord* lr7 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::StubNetwork,
|
||||
"10.1.2.2",
|
||||
"255.255.255.252",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr8 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::PointToPoint,
|
||||
GlobalRouterLinkRecord* lr8 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::PointToPoint,
|
||||
"0.0.0.3",
|
||||
"10.1.3.2",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr9 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::StubNetwork,
|
||||
GlobalRouterLinkRecord* lr9 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::StubNetwork,
|
||||
"10.1.3.2",
|
||||
"255.255.255.252",
|
||||
1);
|
||||
|
||||
StaticRouterLSA* lsa2 = new StaticRouterLSA ();
|
||||
GlobalRouterLSA* lsa2 = new GlobalRouterLSA ();
|
||||
lsa2->SetLinkStateId ("0.0.0.2");
|
||||
lsa2->SetAdvertisingRouter ("0.0.0.2");
|
||||
lsa2->AddLinkRecord (lr4);
|
||||
@@ -1331,26 +1334,26 @@ StaticRouteManagerImplTest::RunTests (void)
|
||||
lsa2->AddLinkRecord (lr9);
|
||||
|
||||
// Router 3
|
||||
StaticRouterLinkRecord* lr10 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::PointToPoint,
|
||||
GlobalRouterLinkRecord* lr10 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::PointToPoint,
|
||||
"0.0.0.2",
|
||||
"10.1.2.1",
|
||||
1);
|
||||
|
||||
StaticRouterLinkRecord* lr11 = new StaticRouterLinkRecord (
|
||||
StaticRouterLinkRecord::StubNetwork,
|
||||
GlobalRouterLinkRecord* lr11 = new GlobalRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::StubNetwork,
|
||||
"10.1.2.1",
|
||||
"255.255.255.252",
|
||||
1);
|
||||
|
||||
StaticRouterLSA* lsa3 = new StaticRouterLSA ();
|
||||
GlobalRouterLSA* lsa3 = new GlobalRouterLSA ();
|
||||
lsa3->SetLinkStateId ("0.0.0.3");
|
||||
lsa3->SetAdvertisingRouter ("0.0.0.3");
|
||||
lsa3->AddLinkRecord (lr10);
|
||||
lsa3->AddLinkRecord (lr11);
|
||||
|
||||
// Test the database
|
||||
StaticRouteManagerLSDB* srmlsdb = new StaticRouteManagerLSDB ();
|
||||
GlobalRouteManagerLSDB* srmlsdb = new GlobalRouteManagerLSDB ();
|
||||
srmlsdb->Insert (lsa0->GetLinkStateId (), lsa0);
|
||||
srmlsdb->Insert (lsa1->GetLinkStateId (), lsa1);
|
||||
srmlsdb->Insert (lsa2->GetLinkStateId (), lsa2);
|
||||
@@ -1358,13 +1361,11 @@ StaticRouteManagerImplTest::RunTests (void)
|
||||
NS_ASSERT (lsa2 == srmlsdb->GetLSA (lsa2->GetLinkStateId ()));
|
||||
|
||||
// next, calculate routes based on the manually created LSDB
|
||||
StaticRouteManagerImpl* srm = new StaticRouteManagerImpl ();
|
||||
GlobalRouteManagerImpl* srm = new GlobalRouteManagerImpl ();
|
||||
srm->DebugUseLsdb (srmlsdb); // manually add in an LSDB
|
||||
// Note-- this will succeed without any nodes in the topology
|
||||
// because the NodeList is empty
|
||||
srm->DebugSPFCalculate (lsa0->GetLinkStateId ()); // node n0
|
||||
|
||||
// XXX here we should do some verification of the routes built
|
||||
|
||||
// This delete clears the srm, which deletes the LSDB, which clears
|
||||
// all of the LSAs, which each destroys the attached LinkRecords.
|
||||
@@ -1374,7 +1375,8 @@ StaticRouteManagerImplTest::RunTests (void)
|
||||
}
|
||||
|
||||
// Instantiate this class for the unit tests
|
||||
static StaticRouteManagerImplTest g_staticRouteManagerTest;
|
||||
// XXX here we should do some verification of the routes built
|
||||
static GlobalRouteManagerImplTest g_globalRouteManagerTest;
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef STATIC_ROUTE_MANAGER_IMPL_H
|
||||
#define STATIC_ROUTE_MANAGER_IMPL_H
|
||||
#ifndef GLOBAL_ROUTE_MANAGER_IMPL_H
|
||||
#define GLOBAL_ROUTE_MANAGER_IMPL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <list>
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "static-router.h"
|
||||
#include "global-router-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -46,9 +46,9 @@ class CandidateQueue;
|
||||
* or networks in the simulation are arranged in the SPF tree. It is this
|
||||
* tree that represents the Shortest Paths to the other networks.
|
||||
*
|
||||
* Each SPFVertex has a pointer to the Static Router Link State Advertisement
|
||||
* Each SPFVertex has a pointer to the Global Router Link State Advertisement
|
||||
* (LSA) that its underlying router has exported. Within these LSAs are
|
||||
* Static Router Link Records that describe the point to point links from the
|
||||
* Global Router Link Records that describe the point to point links from the
|
||||
* underlying router to other nodes (represented by other SPFVertex objects)
|
||||
* in the simulation topology. The combination of the arrangement of the
|
||||
* SPFVertex objects in the SPF tree, along with the details of the link
|
||||
@@ -96,10 +96,10 @@ public:
|
||||
*
|
||||
* @see SPFVertex::SPFVertex ()
|
||||
* @see VertexType
|
||||
* @see StaticRouterLSA
|
||||
* @see GlobalRouterLSA
|
||||
* @param lsa The Link State Advertisement used for finding initial values.
|
||||
*/
|
||||
SPFVertex(StaticRouterLSA* lsa);
|
||||
SPFVertex(GlobalRouterLSA* lsa);
|
||||
/**
|
||||
* @brief Destroy an SPFVertex (Shortest Path First Vertex).
|
||||
*
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
* representing routers, and comes from the Link State Advertisement of a
|
||||
* router aggregated to a node in the simulation. These IDs are allocated
|
||||
* automatically by the routing environment and look like IP addresses
|
||||
* beginning at 0.0.0.0 and monotonically increase as new routers are
|
||||
* beginning at 0.0.0.0 and monotonically increasing as new routers are
|
||||
* instantiated.
|
||||
*
|
||||
* @returns The Ipv4Address Vertex ID of the current SPFVertex object.
|
||||
@@ -158,31 +158,31 @@ public:
|
||||
*/
|
||||
void SetVertexId (Ipv4Address id);
|
||||
/**
|
||||
* @brief Get the Static Router Link State Advertisement returned by the
|
||||
* Static Router represented by this SPFVertex during the route discovery
|
||||
* @brief Get the Global Router Link State Advertisement returned by the
|
||||
* Global Router represented by this SPFVertex during the route discovery
|
||||
* process.
|
||||
*
|
||||
* @see StaticRouter
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::DiscoverLSAs ()
|
||||
* @returns A pointer to the StaticRouterLSA found by the router represented
|
||||
* @see GlobalRouter
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouter::DiscoverLSAs ()
|
||||
* @returns A pointer to the GlobalRouterLSA found by the router represented
|
||||
* by this SPFVertex object.
|
||||
*/
|
||||
StaticRouterLSA* GetLSA (void) const;
|
||||
GlobalRouterLSA* GetLSA (void) const;
|
||||
/**
|
||||
* @brief Set the Static Router Link State Advertisement returned by the
|
||||
* Static Router represented by this SPFVertex during the route discovery
|
||||
* @brief Set the Global Router Link State Advertisement returned by the
|
||||
* Global Router represented by this SPFVertex during the route discovery
|
||||
* process.
|
||||
*
|
||||
* @see SPFVertex::GetLSA ()
|
||||
* @see StaticRouter
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::DiscoverLSAs ()
|
||||
* @see GlobalRouter
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouter::DiscoverLSAs ()
|
||||
* @warning Ownership of the LSA is transferred to the "this" SPFVertex. You
|
||||
* must not delete the LSA after calling this method.
|
||||
* @param lsa A pointer to the StaticRouterLSA.
|
||||
* @param lsa A pointer to the GlobalRouterLSA.
|
||||
*/
|
||||
void SetLSA (StaticRouterLSA* lsa);
|
||||
void SetLSA (GlobalRouterLSA* lsa);
|
||||
/**
|
||||
* @brief Get the distance from the root vertex to "this" SPFVertex object.
|
||||
*
|
||||
@@ -240,11 +240,11 @@ public:
|
||||
* path to "this" vertex.
|
||||
*
|
||||
* When initializing the root SPFVertex, the interface ID is determined by
|
||||
* examining the Static Router Link Records of the Link State Advertisement
|
||||
* generated by the root node's StaticRouter. These interfaces are used to
|
||||
* examining the Global Router Link Records of the Link State Advertisement
|
||||
* generated by the root node's GlobalRouter. These interfaces are used to
|
||||
* forward packets off of the root's network down those links. As other
|
||||
* vertices are discovered which are further away from the root, they will
|
||||
* be accessible down one of the paths begun by a Static Router Link Record.
|
||||
* be accessible down one of the paths begun by a Global Router Link Record.
|
||||
*
|
||||
* To forward packets to these hosts or networks, the root node must begin
|
||||
* the forwarding process by sending the packets to the interface of that
|
||||
@@ -256,9 +256,9 @@ public:
|
||||
* should I use to get a packet to the network or host represented by 'this'
|
||||
* SPFVertex."
|
||||
*
|
||||
* @see StaticRouter
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouterLinkRecord
|
||||
* @see GlobalRouter
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouterLinkRecord
|
||||
* @returns The interface index to use when forwarding packets to the host
|
||||
* or network represented by "this" SPFVertex.
|
||||
*/
|
||||
@@ -280,11 +280,11 @@ public:
|
||||
* path to "this" vertex.
|
||||
*
|
||||
* When initializing the root SPFVertex, the interface ID is determined by
|
||||
* examining the Static Router Link Records of the Link State Advertisement
|
||||
* generated by the root node's StaticRouter. These interfaces are used to
|
||||
* examining the Global Router Link Records of the Link State Advertisement
|
||||
* generated by the root node's GlobalRouter. These interfaces are used to
|
||||
* forward packets off of the root's network down those links. As other
|
||||
* vertices are discovered which are further away from the root, they will
|
||||
* be accessible down one of the paths begun by a Static Router Link Record.
|
||||
* be accessible down one of the paths begun by a Global Router Link Record.
|
||||
*
|
||||
* To forward packets to these hosts or networks, the root node must begin
|
||||
* the forwarding process by sending the packets to the interface of that
|
||||
@@ -296,9 +296,9 @@ public:
|
||||
* interfaces it should use to get a packet to the network or host represented
|
||||
* by "this" SPFVertex.
|
||||
*
|
||||
* @see StaticRouter
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouterLinkRecord
|
||||
* @see GlobalRouter
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouterLinkRecord
|
||||
* @param id The interface index to use when forwarding packets to the host or
|
||||
* network represented by "this" SPFVertex.
|
||||
*/
|
||||
@@ -320,12 +320,12 @@ public:
|
||||
* destination for packets along the path to "this" vertex.
|
||||
*
|
||||
* When initializing the root SPFVertex, the IP address used when forwarding
|
||||
* packets is determined by examining the Static Router Link Records of the
|
||||
* Link State Advertisement generated by the root node's StaticRouter. This
|
||||
* packets is determined by examining the Global Router Link Records of the
|
||||
* Link State Advertisement generated by the root node's GlobalRouter. This
|
||||
* address is used to forward packets off of the root's network down those
|
||||
* links. As other vertices / nodes are discovered which are further away
|
||||
* from the root, they will be accessible down one of the paths via a link
|
||||
* described by one of these Static Router Link Records.
|
||||
* described by one of these Global Router Link Records.
|
||||
*
|
||||
* To forward packets to these hosts or networks, the root node must begin
|
||||
* the forwarding process by sending the packets to a first hop router down
|
||||
@@ -337,9 +337,9 @@ public:
|
||||
* packet to in order to get that packet to the network or host represented
|
||||
* by 'this' SPFVertex."
|
||||
*
|
||||
* @see StaticRouter
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouterLinkRecord
|
||||
* @see GlobalRouter
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouterLinkRecord
|
||||
* @returns The IP address to use when forwarding packets to the host
|
||||
* or network represented by "this" SPFVertex.
|
||||
*/
|
||||
@@ -361,12 +361,12 @@ public:
|
||||
* destination for packets along the path to "this" vertex.
|
||||
*
|
||||
* When initializing the root SPFVertex, the IP address used when forwarding
|
||||
* packets is determined by examining the Static Router Link Records of the
|
||||
* Link State Advertisement generated by the root node's StaticRouter. This
|
||||
* packets is determined by examining the Global Router Link Records of the
|
||||
* Link State Advertisement generated by the root node's GlobalRouter. This
|
||||
* address is used to forward packets off of the root's network down those
|
||||
* links. As other vertices / nodes are discovered which are further away
|
||||
* from the root, they will be accessible down one of the paths via a link
|
||||
* described by one of these Static Router Link Records.
|
||||
* described by one of these Global Router Link Records.
|
||||
*
|
||||
* To forward packets to these hosts or networks, the root node must begin
|
||||
* the forwarding process by sending the packets to a first hop router down
|
||||
@@ -378,9 +378,9 @@ public:
|
||||
* should I send a packet to in order to get that packet to the network or
|
||||
* host represented by 'this' SPFVertex."
|
||||
*
|
||||
* @see StaticRouter
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouterLinkRecord
|
||||
* @see GlobalRouter
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouterLinkRecord
|
||||
* @param nextHop The IP address to use when forwarding packets to the host
|
||||
* or network represented by "this" SPFVertex.
|
||||
*/
|
||||
@@ -501,7 +501,7 @@ public:
|
||||
private:
|
||||
VertexType m_vertexType;
|
||||
Ipv4Address m_vertexId;
|
||||
StaticRouterLSA* m_lsa;
|
||||
GlobalRouterLSA* m_lsa;
|
||||
uint32_t m_distanceFromRoot;
|
||||
uint32_t m_rootOif;
|
||||
Ipv4Address m_nextHop;
|
||||
@@ -521,65 +521,65 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The Link State DataBase (LSDB) of the StaticRouteManager.
|
||||
* @brief The Link State DataBase (LSDB) of the Global Route Manager.
|
||||
*
|
||||
* Each node in the simulation participating in static routing has a
|
||||
* StaticRouter interface. The primary job of this interface is to export
|
||||
* Static Router Link State Advertisements (LSAs). These advertisements in
|
||||
* turn contain a number of Static Router Link Records that describe the
|
||||
* Each node in the simulation participating in global routing has a
|
||||
* GlobalRouter interface. The primary job of this interface is to export
|
||||
* Global Router Link State Advertisements (LSAs). These advertisements in
|
||||
* turn contain a number of Global Router Link Records that describe the
|
||||
* point to point links from the underlying node to other nodes (that will
|
||||
* also export their own LSAs.
|
||||
*
|
||||
* This class implements a searchable database of LSAs gathered from every
|
||||
* router in the simulation.
|
||||
*/
|
||||
class StaticRouteManagerLSDB
|
||||
class GlobalRouteManagerLSDB
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct an empty StaticRoutingManager Link State Database.
|
||||
* @brief Construct an empty Global Router Manager Link State Database.
|
||||
*
|
||||
* The database map composing the Link State Database is initialized in
|
||||
* this constructor.
|
||||
*/
|
||||
StaticRouteManagerLSDB ();
|
||||
GlobalRouteManagerLSDB ();
|
||||
/**
|
||||
* @brief Destroy an empty StaticRoutingManager Link State Database.
|
||||
* @brief Destroy an empty Global Router Manager Link State Database.
|
||||
*
|
||||
* The database map is walked and all of the Link State Advertisements stored
|
||||
* in the database are freed; then the database map itself is clear ()ed to
|
||||
* release any remaining resources.
|
||||
*/
|
||||
~StaticRouteManagerLSDB ();
|
||||
~GlobalRouteManagerLSDB ();
|
||||
/**
|
||||
* @brief Insert an IP address / Link State Advertisement pair into the Link
|
||||
* State Database.
|
||||
*
|
||||
* The IPV4 address and the StaticRouterLSA given as parameters are converted
|
||||
* The IPV4 address and the GlobalRouterLSA given as parameters are converted
|
||||
* to an STL pair and are inserted into the database map.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see GlobalRouterLSA
|
||||
* @see Ipv4Address
|
||||
* @param addr The IP address associated with the LSA. Typically the Router
|
||||
* ID.
|
||||
* @param lsa A pointer to the Link State Advertisement for the router.
|
||||
*/
|
||||
void Insert(Ipv4Address addr, StaticRouterLSA* lsa);
|
||||
void Insert(Ipv4Address addr, GlobalRouterLSA* lsa);
|
||||
/**
|
||||
* @brief Look up the Link State Advertisement associated with the given
|
||||
* IP Address.
|
||||
*
|
||||
* The database map is searched for the given IPV4 address and corresponding
|
||||
* StaticRouterLSA is returned.
|
||||
* GlobalRouterLSA is returned.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see GlobalRouterLSA
|
||||
* @see Ipv4Address
|
||||
* @param addr The IP address associated with the LSA. Typically the Router
|
||||
* ID.
|
||||
* @returns A pointer to the Link State Advertisement for the router specified
|
||||
* by the IP address addr.
|
||||
*/
|
||||
StaticRouterLSA* GetLSA (Ipv4Address addr) const;
|
||||
GlobalRouterLSA* GetLSA (Ipv4Address addr) const;
|
||||
/**
|
||||
* @brief Set all LSA flags to an initialized state, for SPF computation
|
||||
*
|
||||
@@ -588,50 +588,50 @@ public:
|
||||
* prior to each SPF calculation to reset the state of the SPFVertex structures
|
||||
* that will reference the LSAs during the calculation.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see GlobalRouterLSA
|
||||
* @see SPFVertex
|
||||
*/
|
||||
void Initialize ();
|
||||
|
||||
private:
|
||||
typedef std::map<Ipv4Address, StaticRouterLSA*> LSDBMap_t;
|
||||
typedef std::pair<Ipv4Address, StaticRouterLSA*> LSDBPair_t;
|
||||
typedef std::map<Ipv4Address, GlobalRouterLSA*> LSDBMap_t;
|
||||
typedef std::pair<Ipv4Address, GlobalRouterLSA*> LSDBPair_t;
|
||||
|
||||
LSDBMap_t m_database;
|
||||
/**
|
||||
* @brief StaticRouteManagerLSDB copy construction is disallowed. There's no
|
||||
* @brief GlobalRouteManagerLSDB copy construction is disallowed. There's no
|
||||
* need for it and a compiler provided shallow copy would be wrong.
|
||||
*/
|
||||
StaticRouteManagerLSDB (StaticRouteManagerLSDB& lsdb);
|
||||
GlobalRouteManagerLSDB (GlobalRouteManagerLSDB& lsdb);
|
||||
/**
|
||||
* @brief The SPFVertex copy assignment operator is disallowed. There's no
|
||||
* need for it and a compiler provided shallow copy would be wrong.
|
||||
*/
|
||||
StaticRouteManagerLSDB& operator= (StaticRouteManagerLSDB& lsdb);
|
||||
GlobalRouteManagerLSDB& operator= (GlobalRouteManagerLSDB& lsdb);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A global static router
|
||||
* @brief A global router implementation.
|
||||
*
|
||||
* This singleton object can query interface each node in the system
|
||||
* for a StaticRouter interface. For those nodes, it fetches one or
|
||||
* for a GlobalRouter interface. For those nodes, it fetches one or
|
||||
* more Link State Advertisements and stores them in a local database.
|
||||
* Then, it can compute shortest paths on a per-node basis to all routers,
|
||||
* and finally configure each of the node's forwarding tables.
|
||||
*
|
||||
* The design is guided by OSPFv2 RFC 2328 section 16.1.1 and quagga ospfd.
|
||||
*/
|
||||
class StaticRouteManagerImpl
|
||||
class GlobalRouteManagerImpl
|
||||
{
|
||||
public:
|
||||
StaticRouteManagerImpl ();
|
||||
virtual ~StaticRouteManagerImpl ();
|
||||
GlobalRouteManagerImpl ();
|
||||
virtual ~GlobalRouteManagerImpl ();
|
||||
/**
|
||||
* @brief Build the routing database by gathering Link State Advertisements
|
||||
* from each node exporting a StaticRouter interface.
|
||||
* from each node exporting a GlobalRouter interface.
|
||||
*
|
||||
*/
|
||||
virtual void BuildStaticRoutingDatabase();
|
||||
virtual void BuildGlobalRoutingDatabase();
|
||||
/**
|
||||
* @brief Compute routes using a Dijkstra SPF computation and populate
|
||||
* per-node forwarding tables
|
||||
@@ -640,38 +640,38 @@ public:
|
||||
/**
|
||||
* @brief Debugging routine; allow client code to supply a pre-built LSDB
|
||||
*/
|
||||
void DebugUseLsdb (StaticRouteManagerLSDB*);
|
||||
void DebugUseLsdb (GlobalRouteManagerLSDB*);
|
||||
/**
|
||||
* @brief Debugging routine; call the core SPF from the unit tests
|
||||
*/
|
||||
void DebugSPFCalculate (Ipv4Address root);
|
||||
private:
|
||||
/**
|
||||
* @brief StaticRouteManager Implementation copy construction is disallowed.
|
||||
* @brief GlobalRouteManagerImpl copy construction is disallowed.
|
||||
* There's no need for it and a compiler provided shallow copy would be
|
||||
* wrong.
|
||||
*/
|
||||
StaticRouteManagerImpl (StaticRouteManagerImpl& srmi);
|
||||
GlobalRouteManagerImpl (GlobalRouteManagerImpl& srmi);
|
||||
/**
|
||||
* @brief StaticRouteManager Implementation assignment operator is
|
||||
* @brief Global Route Manager Implementation assignment operator is
|
||||
* disallowed. There's no need for it and a compiler provided shallow copy
|
||||
* would be wrong.
|
||||
* would be hopelessly wrong.
|
||||
*/
|
||||
StaticRouteManagerImpl& operator= (StaticRouteManagerImpl& srmi);
|
||||
GlobalRouteManagerImpl& operator= (GlobalRouteManagerImpl& srmi);
|
||||
|
||||
SPFVertex* m_spfroot;
|
||||
StaticRouteManagerLSDB* m_lsdb;
|
||||
GlobalRouteManagerLSDB* m_lsdb;
|
||||
void SPFCalculate (Ipv4Address root);
|
||||
void SPFNext (SPFVertex*, CandidateQueue&);
|
||||
int SPFNexthopCalculation (SPFVertex* v, SPFVertex* w,
|
||||
StaticRouterLinkRecord* l, uint32_t distance);
|
||||
GlobalRouterLinkRecord* l, uint32_t distance);
|
||||
void SPFVertexAddParent(SPFVertex* v);
|
||||
StaticRouterLinkRecord* SPFGetNextLink(SPFVertex* v, SPFVertex* w,
|
||||
StaticRouterLinkRecord* prev_link);
|
||||
GlobalRouterLinkRecord* SPFGetNextLink(SPFVertex* v, SPFVertex* w,
|
||||
GlobalRouterLinkRecord* prev_link);
|
||||
void SPFIntraAddRouter(SPFVertex* v);
|
||||
uint32_t FindOutgoingInterfaceId(Ipv4Address a);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* STATIC_ROUTE_MANAGER_IMPL_H */
|
||||
#endif /* GLOBAL_ROUTE_MANAGER_IMPL_H */
|
||||
@@ -17,35 +17,35 @@
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/simulation-singleton.h"
|
||||
#include "static-route-manager.h"
|
||||
#include "static-route-manager-impl.h"
|
||||
#include "global-route-manager.h"
|
||||
#include "global-route-manager-impl.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// StaticRouteManager Implementation
|
||||
// GlobalRouteManager Implementation
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
StaticRouteManager::PopulateRoutingTables ()
|
||||
GlobalRouteManager::PopulateRoutingTables ()
|
||||
{
|
||||
BuildStaticRoutingDatabase ();
|
||||
BuildGlobalRoutingDatabase ();
|
||||
InitializeRoutes ();
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouteManager::BuildStaticRoutingDatabase ()
|
||||
GlobalRouteManager::BuildGlobalRoutingDatabase ()
|
||||
{
|
||||
return SimulationSingleton<StaticRouteManagerImpl>::Get ()->
|
||||
BuildStaticRoutingDatabase ();
|
||||
return SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
BuildGlobalRoutingDatabase ();
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouteManager::InitializeRoutes ()
|
||||
GlobalRouteManager::InitializeRoutes ()
|
||||
{
|
||||
return SimulationSingleton<StaticRouteManagerImpl>::Get ()->
|
||||
return SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
InitializeRoutes ();
|
||||
}
|
||||
|
||||
@@ -15,60 +15,64 @@
|
||||
*/
|
||||
|
||||
#ifndef STATIC_ROUTE_MANAGER_H
|
||||
#define STATIC_ROUTE_MANAGER_H
|
||||
#define GLOBAL_ROUTE_MANAGER_H
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* @brief A global static router
|
||||
* @brief A global global router
|
||||
*
|
||||
* This singleton object can query interface each node in the system
|
||||
* for a StaticRouter interface. For those nodes, it fetches one or
|
||||
* for a GlobalRouter interface. For those nodes, it fetches one or
|
||||
* more Link State Advertisements and stores them in a local database.
|
||||
* Then, it can compute shortest paths on a per-node basis to all routers,
|
||||
* and finally configure each of the node's forwarding tables.
|
||||
*
|
||||
* The design is guided by OSPFv2 RFC 2328 section 16.1.1 and quagga ospfd.
|
||||
*/
|
||||
class StaticRouteManager
|
||||
class GlobalRouteManager
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Build a routing database and initialize the routing tables of
|
||||
* the nodes in the simulation.
|
||||
*
|
||||
* All this function does is call BuildStaticRoutingDatabase () and
|
||||
* InitializeRoutes ().
|
||||
* All this function does is call BuildGlobalRoutingDatabase () and
|
||||
* InitializeRoutes ().
|
||||
*
|
||||
* @see BuildStaticRoutingDatabase ();
|
||||
* @see BuildGlobalRoutingDatabase ();
|
||||
* @see InitializeRoutes ();
|
||||
*/
|
||||
static void PopulateRoutingTables ();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Build the routing database by gathering Link State Advertisements
|
||||
* from each node exporting a StaticRouter interface.
|
||||
* from each node exporting a GlobalRouter interface.
|
||||
*
|
||||
*/
|
||||
static void BuildStaticRoutingDatabase ();
|
||||
static void BuildGlobalRoutingDatabase ();
|
||||
|
||||
/**
|
||||
* @brief Compute routes using a Dijkstra SPF computation and populate
|
||||
* per-node forwarding tables
|
||||
*/
|
||||
static void InitializeRoutes ();
|
||||
|
||||
/**
|
||||
* @brief Static Route Manager copy construction is disallowed. There's no
|
||||
* @brief Global Route Manager copy construction is disallowed. There's no
|
||||
* need for it and a compiler provided shallow copy would be wrong.
|
||||
*
|
||||
*/
|
||||
StaticRouteManager (StaticRouteManager& srm);
|
||||
GlobalRouteManager (GlobalRouteManager& srm);
|
||||
|
||||
/**
|
||||
* @brief Static Router copy assignment operator is disallowed. There's no
|
||||
* @brief Global Router copy assignment operator is disallowed. There's no
|
||||
* need for it and a compiler provided shallow copy would be wrong.
|
||||
*/
|
||||
StaticRouteManager& operator= (StaticRouteManager& srm);
|
||||
GlobalRouteManager& operator= (GlobalRouteManager& srm);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* STATIC_ROUTE_MANAGER_H */
|
||||
#endif /* GLOBAL_ROUTE_MANAGER_H */
|
||||
@@ -20,29 +20,29 @@
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/internet-node.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "static-router.h"
|
||||
#include "global-router-interface.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("StaticRouter");
|
||||
NS_DEBUG_COMPONENT_DEFINE ("GlobalRouter");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// StaticRouterLinkRecord Implementation
|
||||
// GlobalRouterLinkRecord Implementation
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
StaticRouterLinkRecord::StaticRouterLinkRecord ()
|
||||
GlobalRouterLinkRecord::GlobalRouterLinkRecord ()
|
||||
:
|
||||
m_linkId ("0.0.0.0"),
|
||||
m_linkData ("0.0.0.0"),
|
||||
m_linkType (Unknown),
|
||||
m_metric (0)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::StaticRouterLinkRecord ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::GlobalRouterLinkRecord ()");
|
||||
}
|
||||
|
||||
StaticRouterLinkRecord::StaticRouterLinkRecord (
|
||||
GlobalRouterLinkRecord::GlobalRouterLinkRecord (
|
||||
LinkType linkType,
|
||||
Ipv4Address linkId,
|
||||
Ipv4Address linkData,
|
||||
@@ -53,90 +53,90 @@ StaticRouterLinkRecord::StaticRouterLinkRecord (
|
||||
m_linkType (linkType),
|
||||
m_metric (metric)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::StaticRouterLinkRecord (" <<
|
||||
NS_DEBUG("GlobalRouterLinkRecord::GlobalRouterLinkRecord (" <<
|
||||
linkType << ", " << linkId << ", " << linkData << ", " << metric << ")");
|
||||
}
|
||||
|
||||
StaticRouterLinkRecord::~StaticRouterLinkRecord ()
|
||||
GlobalRouterLinkRecord::~GlobalRouterLinkRecord ()
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::~StaticRouterLinkRecord ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::~GlobalRouterLinkRecord ()");
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
StaticRouterLinkRecord::GetLinkId (void) const
|
||||
GlobalRouterLinkRecord::GetLinkId (void) const
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::GetLinkId ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::GetLinkId ()");
|
||||
return m_linkId;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLinkRecord::SetLinkId (Ipv4Address addr)
|
||||
GlobalRouterLinkRecord::SetLinkId (Ipv4Address addr)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::SetLinkId ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::SetLinkId ()");
|
||||
m_linkId = addr;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
StaticRouterLinkRecord::GetLinkData (void) const
|
||||
GlobalRouterLinkRecord::GetLinkData (void) const
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::GetLinkData ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::GetLinkData ()");
|
||||
return m_linkData;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLinkRecord::SetLinkData (Ipv4Address addr)
|
||||
GlobalRouterLinkRecord::SetLinkData (Ipv4Address addr)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::SetLinkData ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::SetLinkData ()");
|
||||
m_linkData = addr;
|
||||
}
|
||||
|
||||
StaticRouterLinkRecord::LinkType
|
||||
StaticRouterLinkRecord::GetLinkType (void) const
|
||||
GlobalRouterLinkRecord::LinkType
|
||||
GlobalRouterLinkRecord::GetLinkType (void) const
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::GetLinkType ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::GetLinkType ()");
|
||||
return m_linkType;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLinkRecord::SetLinkType (
|
||||
StaticRouterLinkRecord::LinkType linkType)
|
||||
GlobalRouterLinkRecord::SetLinkType (
|
||||
GlobalRouterLinkRecord::LinkType linkType)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::SetLinkType ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::SetLinkType ()");
|
||||
m_linkType = linkType;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
StaticRouterLinkRecord::GetMetric (void) const
|
||||
GlobalRouterLinkRecord::GetMetric (void) const
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::GetMetric ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::GetMetric ()");
|
||||
return m_metric;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLinkRecord::SetMetric (uint32_t metric)
|
||||
GlobalRouterLinkRecord::SetMetric (uint32_t metric)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLinkRecord::SetMetric ()");
|
||||
NS_DEBUG("GlobalRouterLinkRecord::SetMetric ()");
|
||||
m_metric = metric;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// StaticRouterLSA Implementation
|
||||
// GlobalRouterLSA Implementation
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
StaticRouterLSA::StaticRouterLSA()
|
||||
GlobalRouterLSA::GlobalRouterLSA()
|
||||
:
|
||||
m_linkStateId("0.0.0.0"),
|
||||
m_advertisingRtr("0.0.0.0"),
|
||||
m_linkRecords(),
|
||||
m_status(StaticRouterLSA::LSA_SPF_NOT_EXPLORED)
|
||||
m_status(GlobalRouterLSA::LSA_SPF_NOT_EXPLORED)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLSA::StaticRouterLSA ()");
|
||||
NS_DEBUG("GlobalRouterLSA::GlobalRouterLSA ()");
|
||||
}
|
||||
|
||||
StaticRouterLSA::StaticRouterLSA (
|
||||
StaticRouterLSA::SPFStatus status,
|
||||
GlobalRouterLSA::GlobalRouterLSA (
|
||||
GlobalRouterLSA::SPFStatus status,
|
||||
Ipv4Address linkStateId,
|
||||
Ipv4Address advertisingRtr)
|
||||
:
|
||||
@@ -145,21 +145,21 @@ StaticRouterLSA::StaticRouterLSA (
|
||||
m_linkRecords(),
|
||||
m_status(status)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLSA::StaticRouterLSA (" << status << ", " <<
|
||||
NS_DEBUG("GlobalRouterLSA::GlobalRouterLSA (" << status << ", " <<
|
||||
linkStateId << ", " << advertisingRtr << ")");
|
||||
}
|
||||
|
||||
StaticRouterLSA::StaticRouterLSA (StaticRouterLSA& lsa)
|
||||
GlobalRouterLSA::GlobalRouterLSA (GlobalRouterLSA& lsa)
|
||||
: m_linkStateId(lsa.m_linkStateId), m_advertisingRtr(lsa.m_advertisingRtr),
|
||||
m_status(lsa.m_status)
|
||||
{
|
||||
NS_ASSERT_MSG(IsEmpty(),
|
||||
"StaticRouterLSA::StaticRouterLSA (): Non-empty LSA in constructor");
|
||||
"GlobalRouterLSA::GlobalRouterLSA (): Non-empty LSA in constructor");
|
||||
CopyLinkRecords (lsa);
|
||||
}
|
||||
|
||||
StaticRouterLSA&
|
||||
StaticRouterLSA::operator= (const StaticRouterLSA& lsa)
|
||||
GlobalRouterLSA&
|
||||
GlobalRouterLSA::operator= (const GlobalRouterLSA& lsa)
|
||||
{
|
||||
m_linkStateId = lsa.m_linkStateId;
|
||||
m_advertisingRtr = lsa.m_advertisingRtr;
|
||||
@@ -171,14 +171,14 @@ StaticRouterLSA::operator= (const StaticRouterLSA& lsa)
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLSA::CopyLinkRecords (const StaticRouterLSA& lsa)
|
||||
GlobalRouterLSA::CopyLinkRecords (const GlobalRouterLSA& lsa)
|
||||
{
|
||||
for (ListOfLinkRecords_t::const_iterator i = lsa.m_linkRecords.begin ();
|
||||
i != lsa.m_linkRecords.end ();
|
||||
i++)
|
||||
{
|
||||
StaticRouterLinkRecord *pSrc = *i;
|
||||
StaticRouterLinkRecord *pDst = new StaticRouterLinkRecord;
|
||||
GlobalRouterLinkRecord *pSrc = *i;
|
||||
GlobalRouterLinkRecord *pDst = new GlobalRouterLinkRecord;
|
||||
|
||||
pDst->SetLinkType (pSrc->GetLinkType ());
|
||||
pDst->SetLinkId (pSrc->GetLinkId ());
|
||||
@@ -189,46 +189,46 @@ StaticRouterLSA::CopyLinkRecords (const StaticRouterLSA& lsa)
|
||||
}
|
||||
}
|
||||
|
||||
StaticRouterLSA::~StaticRouterLSA()
|
||||
GlobalRouterLSA::~GlobalRouterLSA()
|
||||
{
|
||||
NS_DEBUG("StaticRouterLSA::~StaticRouterLSA ()");
|
||||
NS_DEBUG("GlobalRouterLSA::~GlobalRouterLSA ()");
|
||||
ClearLinkRecords ();
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLSA::ClearLinkRecords(void)
|
||||
GlobalRouterLSA::ClearLinkRecords(void)
|
||||
{
|
||||
for ( ListOfLinkRecords_t::iterator i = m_linkRecords.begin ();
|
||||
i != m_linkRecords.end ();
|
||||
i++)
|
||||
{
|
||||
NS_DEBUG("StaticRouterLSA::ClearLinkRecords (): free link record");
|
||||
NS_DEBUG("GlobalRouterLSA::ClearLinkRecords (): free link record");
|
||||
|
||||
StaticRouterLinkRecord *p = *i;
|
||||
GlobalRouterLinkRecord *p = *i;
|
||||
delete p;
|
||||
p = 0;
|
||||
|
||||
*i = 0;
|
||||
}
|
||||
NS_DEBUG("StaticRouterLSA::ClearLinkRecords(): clear list");
|
||||
NS_DEBUG("GlobalRouterLSA::ClearLinkRecords(): clear list");
|
||||
m_linkRecords.clear();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
StaticRouterLSA::AddLinkRecord (StaticRouterLinkRecord* lr)
|
||||
GlobalRouterLSA::AddLinkRecord (GlobalRouterLinkRecord* lr)
|
||||
{
|
||||
m_linkRecords.push_back (lr);
|
||||
return m_linkRecords.size ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
StaticRouterLSA::GetNLinkRecords (void) const
|
||||
GlobalRouterLSA::GetNLinkRecords (void) const
|
||||
{
|
||||
return m_linkRecords.size ();
|
||||
}
|
||||
|
||||
StaticRouterLinkRecord *
|
||||
StaticRouterLSA::GetLinkRecord (uint32_t n) const
|
||||
GlobalRouterLinkRecord *
|
||||
GlobalRouterLSA::GetLinkRecord (uint32_t n) const
|
||||
{
|
||||
uint32_t j = 0;
|
||||
for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin ();
|
||||
@@ -240,54 +240,54 @@ StaticRouterLSA::GetLinkRecord (uint32_t n) const
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
NS_ASSERT_MSG(false, "StaticRouterLSA::GetLinkRecord (): invalid index");
|
||||
NS_ASSERT_MSG(false, "GlobalRouterLSA::GetLinkRecord (): invalid index");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
StaticRouterLSA::IsEmpty (void) const
|
||||
GlobalRouterLSA::IsEmpty (void) const
|
||||
{
|
||||
return m_linkRecords.size () == 0;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
StaticRouterLSA::GetLinkStateId (void) const
|
||||
GlobalRouterLSA::GetLinkStateId (void) const
|
||||
{
|
||||
return m_linkStateId;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLSA::SetLinkStateId (Ipv4Address addr)
|
||||
GlobalRouterLSA::SetLinkStateId (Ipv4Address addr)
|
||||
{
|
||||
m_linkStateId = addr;
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
StaticRouterLSA::GetAdvertisingRouter (void) const
|
||||
GlobalRouterLSA::GetAdvertisingRouter (void) const
|
||||
{
|
||||
return m_advertisingRtr;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLSA::SetAdvertisingRouter (Ipv4Address addr)
|
||||
GlobalRouterLSA::SetAdvertisingRouter (Ipv4Address addr)
|
||||
{
|
||||
m_advertisingRtr = addr;
|
||||
}
|
||||
|
||||
StaticRouterLSA::SPFStatus
|
||||
StaticRouterLSA::GetStatus (void) const
|
||||
GlobalRouterLSA::SPFStatus
|
||||
GlobalRouterLSA::GetStatus (void) const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLSA::SetStatus (StaticRouterLSA::SPFStatus status)
|
||||
GlobalRouterLSA::SetStatus (GlobalRouterLSA::SPFStatus status)
|
||||
{
|
||||
m_status = status;
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouterLSA::Print (std::ostream &os) const
|
||||
GlobalRouterLSA::Print (std::ostream &os) const
|
||||
{
|
||||
os << "m_linkStateId = " << m_linkStateId << std::endl <<
|
||||
"m_advertisingRtr = " << m_advertisingRtr << std::endl;
|
||||
@@ -296,14 +296,14 @@ StaticRouterLSA::Print (std::ostream &os) const
|
||||
i != m_linkRecords.end ();
|
||||
i++)
|
||||
{
|
||||
StaticRouterLinkRecord *p = *i;
|
||||
GlobalRouterLinkRecord *p = *i;
|
||||
os << "----------" << std::endl;
|
||||
os << "m_linkId = " << p->GetLinkId () << std::endl;
|
||||
os << "m_linkData = " << p->GetLinkData () << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, StaticRouterLSA& lsa)
|
||||
std::ostream& operator<< (std::ostream& os, GlobalRouterLSA& lsa)
|
||||
{
|
||||
lsa.Print (os);
|
||||
return os;
|
||||
@@ -311,50 +311,50 @@ std::ostream& operator<< (std::ostream& os, StaticRouterLSA& lsa)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// StaticRouter Implementation
|
||||
// GlobalRouter Implementation
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const InterfaceId StaticRouter::iid =
|
||||
MakeInterfaceId ("StaticRouter", Object::iid);
|
||||
const InterfaceId GlobalRouter::iid =
|
||||
MakeInterfaceId ("GlobalRouter", Object::iid);
|
||||
|
||||
StaticRouter::StaticRouter (Ptr<Node> node)
|
||||
GlobalRouter::GlobalRouter (Ptr<Node> node)
|
||||
: m_node(node), m_LSAs()
|
||||
{
|
||||
NS_DEBUG("StaticRouter::StaticRouter ()");
|
||||
SetInterfaceId (StaticRouter::iid);
|
||||
NS_DEBUG("GlobalRouter::GlobalRouter ()");
|
||||
SetInterfaceId (GlobalRouter::iid);
|
||||
m_routerId.Set(RoutingEnvironment::AllocateRouterId());
|
||||
}
|
||||
|
||||
StaticRouter::~StaticRouter ()
|
||||
GlobalRouter::~GlobalRouter ()
|
||||
{
|
||||
NS_DEBUG("StaticRouter::~StaticRouter ()");
|
||||
NS_DEBUG("GlobalRouter::~GlobalRouter ()");
|
||||
ClearLSAs();
|
||||
}
|
||||
|
||||
void
|
||||
StaticRouter::ClearLSAs ()
|
||||
GlobalRouter::ClearLSAs ()
|
||||
{
|
||||
NS_DEBUG("StaticRouter::ClearLSAs ()");
|
||||
NS_DEBUG("GlobalRouter::ClearLSAs ()");
|
||||
|
||||
for ( ListOfLSAs_t::iterator i = m_LSAs.begin ();
|
||||
i != m_LSAs.end ();
|
||||
i++)
|
||||
{
|
||||
NS_DEBUG("StaticRouter::ClearLSAs (): free LSA");
|
||||
NS_DEBUG("GlobalRouter::ClearLSAs (): free LSA");
|
||||
|
||||
StaticRouterLSA *p = *i;
|
||||
GlobalRouterLSA *p = *i;
|
||||
delete p;
|
||||
p = 0;
|
||||
|
||||
*i = 0;
|
||||
}
|
||||
NS_DEBUG("StaticRouter::ClearLSAs (): clear list");
|
||||
NS_DEBUG("GlobalRouter::ClearLSAs (): clear list");
|
||||
m_LSAs.clear();
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
StaticRouter::GetRouterId (void) const
|
||||
GlobalRouter::GetRouterId (void) const
|
||||
{
|
||||
return m_routerId;
|
||||
}
|
||||
@@ -364,11 +364,11 @@ StaticRouter::GetRouterId (void) const
|
||||
// Advertisements that reflect them and their associated networks.
|
||||
//
|
||||
uint32_t
|
||||
StaticRouter::DiscoverLSAs (void)
|
||||
GlobalRouter::DiscoverLSAs (void)
|
||||
{
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs ()");
|
||||
NS_DEBUG("GlobalRouter::DiscoverLSAs ()");
|
||||
NS_ASSERT_MSG(m_node,
|
||||
"StaticRouter::DiscoverLSAs (): <Node> interface not set");
|
||||
"GlobalRouter::DiscoverLSAs (): <Node> interface not set");
|
||||
|
||||
ClearLSAs ();
|
||||
//
|
||||
@@ -378,17 +378,17 @@ StaticRouter::DiscoverLSAs (void)
|
||||
//
|
||||
Ptr<Ipv4> ipv4Local = m_node->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG(ipv4Local,
|
||||
"StaticRouter::DiscoverLSAs (): QI for <Ipv4> interface failed");
|
||||
"GlobalRouter::DiscoverLSAs (): QI for <Ipv4> interface failed");
|
||||
//
|
||||
// We are, for now at least, only going to report RouterLSAs in this method.
|
||||
// What this means is that there is going to be one advertisement with some
|
||||
// number of link records. This means that GetNumLSAs will actually always
|
||||
// return exactly one.
|
||||
//
|
||||
StaticRouterLSA *pLSA = new StaticRouterLSA;
|
||||
GlobalRouterLSA *pLSA = new GlobalRouterLSA;
|
||||
pLSA->SetLinkStateId (m_routerId);
|
||||
pLSA->SetAdvertisingRouter (m_routerId);
|
||||
pLSA->SetStatus (StaticRouterLSA::LSA_SPF_NOT_EXPLORED);
|
||||
pLSA->SetStatus (GlobalRouterLSA::LSA_SPF_NOT_EXPLORED);
|
||||
//
|
||||
// We need to ask the node for the number of net devices attached. This isn't
|
||||
// necessarily equal to the number of links to adjacent nodes (other routers)
|
||||
@@ -398,7 +398,7 @@ StaticRouter::DiscoverLSAs (void)
|
||||
// a point-to-point channel.
|
||||
//
|
||||
uint32_t numDevices = m_node->GetNDevices();
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs (): numDevices = " << numDevices);
|
||||
NS_DEBUG("GlobalRouter::DiscoverLSAs (): numDevices = " << numDevices);
|
||||
//
|
||||
// Loop through the devices looking for those connected to a point-to-point
|
||||
// channel.
|
||||
@@ -409,11 +409,11 @@ StaticRouter::DiscoverLSAs (void)
|
||||
|
||||
if (!ndLocal->IsPointToPoint ())
|
||||
{
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs (): non-point-to-point device");
|
||||
NS_DEBUG("GlobalRouter::DiscoverLSAs (): non-point-to-point device");
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs (): Point-to-point device");
|
||||
NS_DEBUG("GlobalRouter::DiscoverLSAs (): Point-to-point device");
|
||||
//
|
||||
// Now, we have to find the Ipv4 interface whose netdevice is the one we
|
||||
// just found. This is still the IP on the local side of the channel. There
|
||||
@@ -442,15 +442,15 @@ StaticRouter::DiscoverLSAs (void)
|
||||
Ptr<Node> nodeRemote = ndRemote->GetNode();
|
||||
Ptr<Ipv4> ipv4Remote = nodeRemote->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG(ipv4Remote,
|
||||
"StaticRouter::DiscoverLSAs (): QI for remote <Ipv4> failed");
|
||||
"GlobalRouter::DiscoverLSAs (): QI for remote <Ipv4> failed");
|
||||
//
|
||||
// Per the OSPF spec, we're going to need the remote router ID, so we might as
|
||||
// well get it now.
|
||||
//
|
||||
Ptr<StaticRouter> srRemote =
|
||||
nodeRemote->QueryInterface<StaticRouter> (StaticRouter::iid);
|
||||
Ptr<GlobalRouter> srRemote =
|
||||
nodeRemote->QueryInterface<GlobalRouter> (GlobalRouter::iid);
|
||||
NS_ASSERT_MSG(srRemote,
|
||||
"StaticRouter::DiscoverLSAs (): QI for remote <StaticRouter> failed");
|
||||
"GlobalRouter::DiscoverLSAs (): QI for remote <GlobalRouter> failed");
|
||||
Ipv4Address rtrIdRemote = srRemote->GetRouterId();
|
||||
NS_DEBUG("Working with remote router " << rtrIdRemote);
|
||||
//
|
||||
@@ -470,15 +470,15 @@ StaticRouter::DiscoverLSAs (void)
|
||||
// link records; the first is a point-to-point record describing the link and
|
||||
// the second is a stub network record with the network number.
|
||||
//
|
||||
StaticRouterLinkRecord *plr = new StaticRouterLinkRecord;
|
||||
plr->SetLinkType (StaticRouterLinkRecord::PointToPoint);
|
||||
GlobalRouterLinkRecord *plr = new GlobalRouterLinkRecord;
|
||||
plr->SetLinkType (GlobalRouterLinkRecord::PointToPoint);
|
||||
plr->SetLinkId (rtrIdRemote);
|
||||
plr->SetLinkData (addrLocal);
|
||||
pLSA->AddLinkRecord(plr);
|
||||
plr = 0;
|
||||
|
||||
plr = new StaticRouterLinkRecord;
|
||||
plr->SetLinkType (StaticRouterLinkRecord::StubNetwork);
|
||||
plr = new GlobalRouterLinkRecord;
|
||||
plr->SetLinkType (GlobalRouterLinkRecord::StubNetwork);
|
||||
plr->SetLinkId (addrRemote);
|
||||
plr->SetLinkData (Ipv4Address(maskRemote.GetHostOrder())); // Frown
|
||||
pLSA->AddLinkRecord(plr);
|
||||
@@ -493,9 +493,9 @@ StaticRouter::DiscoverLSAs (void)
|
||||
}
|
||||
|
||||
uint32_t
|
||||
StaticRouter::GetNumLSAs (void) const
|
||||
GlobalRouter::GetNumLSAs (void) const
|
||||
{
|
||||
NS_DEBUG("StaticRouter::GetNumLSAs ()");
|
||||
NS_DEBUG("GlobalRouter::GetNumLSAs ()");
|
||||
return m_LSAs.size ();
|
||||
}
|
||||
|
||||
@@ -503,9 +503,9 @@ StaticRouter::GetNumLSAs (void) const
|
||||
// Get the nth link state advertisement from this router.
|
||||
//
|
||||
bool
|
||||
StaticRouter::GetLSA (uint32_t n, StaticRouterLSA &lsa) const
|
||||
GlobalRouter::GetLSA (uint32_t n, GlobalRouterLSA &lsa) const
|
||||
{
|
||||
NS_ASSERT_MSG(lsa.IsEmpty(), "StaticRouter::GetLSA (): Must pass empty LSA");
|
||||
NS_ASSERT_MSG(lsa.IsEmpty(), "GlobalRouter::GetLSA (): Must pass empty LSA");
|
||||
//
|
||||
// All of the work was done in GetNumLSAs. All we have to do here is to
|
||||
// walk the list of link state advertisements created there and return the
|
||||
@@ -518,7 +518,7 @@ StaticRouter::GetLSA (uint32_t n, StaticRouterLSA &lsa) const
|
||||
{
|
||||
if (j == n)
|
||||
{
|
||||
StaticRouterLSA *p = *i;
|
||||
GlobalRouterLSA *p = *i;
|
||||
lsa = *p;
|
||||
return true;
|
||||
}
|
||||
@@ -532,7 +532,7 @@ StaticRouter::GetLSA (uint32_t n, StaticRouterLSA &lsa) const
|
||||
// other end. This only makes sense with a point-to-point channel.
|
||||
//
|
||||
Ptr<NetDevice>
|
||||
StaticRouter::GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const
|
||||
GlobalRouter::GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const
|
||||
{
|
||||
//
|
||||
// Double-check that channel agrees with device that it's a point-to-point
|
||||
@@ -541,7 +541,7 @@ StaticRouter::GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const
|
||||
|
||||
uint32_t nDevices = ch->GetNDevices();
|
||||
NS_ASSERT_MSG(nDevices == 2,
|
||||
"StaticRouter::GetAdjacent (): Channel with other than two devices");
|
||||
"GlobalRouter::GetAdjacent (): Channel with other than two devices");
|
||||
//
|
||||
// This is a point to point channel with two endpoints. Get both of them.
|
||||
//
|
||||
@@ -563,7 +563,7 @@ StaticRouter::GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const
|
||||
else
|
||||
{
|
||||
NS_ASSERT_MSG(false,
|
||||
"StaticRouter::GetAdjacent (): Wrong or confused channel?");
|
||||
"GlobalRouter::GetAdjacent (): Wrong or confused channel?");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -573,7 +573,7 @@ StaticRouter::GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const
|
||||
// corresponds to that net device.
|
||||
//
|
||||
uint32_t
|
||||
StaticRouter::FindIfIndexForDevice(Ptr<Node> node, Ptr<NetDevice> nd) const
|
||||
GlobalRouter::FindIfIndexForDevice(Ptr<Node> node, Ptr<NetDevice> nd) const
|
||||
{
|
||||
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
|
||||
NS_ASSERT_MSG(ipv4, "QI for <Ipv4> interface failed");
|
||||
@@ -15,8 +15,8 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef STATIC_ROUTER_H
|
||||
#define STATIC_ROUTER_H
|
||||
#ifndef GLOBAL_ROUTER_H
|
||||
#define GLOBAL_ROUTER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <list>
|
||||
@@ -32,16 +32,16 @@ namespace ns3 {
|
||||
/**
|
||||
* @brief A single link record for a link state advertisement.
|
||||
*
|
||||
* The StaticRouterLinkRecord is modeled after the OSPF link record field of
|
||||
* The GlobalRouterLinkRecord is modeled after the OSPF link record field of
|
||||
* a Link State Advertisement. Right now we will only see two types of link
|
||||
* records corresponding to a stub network and a point-to-point link (channel).
|
||||
*/
|
||||
class StaticRouterLinkRecord
|
||||
class GlobalRouterLinkRecord
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @enum LinkType
|
||||
* @brief Enumeration of the possible types of Static Router Link Records.
|
||||
* @brief Enumeration of the possible types of Global Router Link Records.
|
||||
*
|
||||
* These values are defined in the OSPF spec. We currently only use
|
||||
* PointToPoint and StubNetwork types.
|
||||
@@ -54,15 +54,15 @@ public:
|
||||
VirtualLink /**< Unused -- for future OSPF compatibility */
|
||||
};
|
||||
/**
|
||||
* @brief Construct an empty ("uninitialized") Static Router Link Record.
|
||||
* @brief Construct an empty ("uninitialized") Global Router Link Record.
|
||||
*
|
||||
* The Link ID and Link Data Ipv4 addresses are set to "0.0.0.0";
|
||||
* The Link Type is set to Unknown;
|
||||
* The metric is set to 0.
|
||||
*/
|
||||
StaticRouterLinkRecord ();
|
||||
GlobalRouterLinkRecord ();
|
||||
/**
|
||||
* Construct an initialized Static Router Link Record.
|
||||
* Construct an initialized Global Router Link Record.
|
||||
*
|
||||
* @param linkType The type of link record to construct.
|
||||
* @param linkId The link ID for the record.
|
||||
@@ -72,19 +72,19 @@ public:
|
||||
* @see SetLinkId
|
||||
* @see SetLinkData
|
||||
*/
|
||||
StaticRouterLinkRecord (
|
||||
GlobalRouterLinkRecord (
|
||||
LinkType linkType,
|
||||
Ipv4Address linkId,
|
||||
Ipv4Address linkData,
|
||||
uint32_t metric);
|
||||
/**
|
||||
* @brief Destroy a Static Router Link Record.
|
||||
* @brief Destroy a Global Router Link Record.
|
||||
*
|
||||
* Currently does nothing. Here as a placeholder only.
|
||||
*/
|
||||
~StaticRouterLinkRecord ();
|
||||
~GlobalRouterLinkRecord ();
|
||||
/**
|
||||
* Get the Link ID field of the Static Router Link Record.
|
||||
* Get the Link ID field of the Global Router Link Record.
|
||||
*
|
||||
* For an OSPF type 1 link (PointToPoint) the Link ID will be the Router ID
|
||||
* of the neighboring router.
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
*/
|
||||
Ipv4Address GetLinkId(void) const;
|
||||
/**
|
||||
* @brief Set the Link ID field of the Static Router Link Record.
|
||||
* @brief Set the Link ID field of the Global Router Link Record.
|
||||
*
|
||||
* For an OSPF type 1 link (PointToPoint) the Link ID must be the Router ID
|
||||
* of the neighboring router.
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
*/
|
||||
void SetLinkId(Ipv4Address addr);
|
||||
/**
|
||||
* @brief Get the Link Data field of the Static Router Link Record.
|
||||
* @brief Get the Link Data field of the Global Router Link Record.
|
||||
*
|
||||
* For an OSPF type 1 link (PointToPoint) the Link Data will be the IP
|
||||
* address of the node of the local side of the link.
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
*/
|
||||
Ipv4Address GetLinkData(void) const;
|
||||
/**
|
||||
* @brief Set the Link Data field of the Static Router Link Record.
|
||||
* @brief Set the Link Data field of the Global Router Link Record.
|
||||
*
|
||||
* For an OSPF type 1 link (PointToPoint) the Link Data must be the IP
|
||||
* address of the node of the local side of the link.
|
||||
@@ -132,27 +132,27 @@ public:
|
||||
*/
|
||||
void SetLinkData(Ipv4Address addr);
|
||||
/**
|
||||
* @brief Get the Link Type field of the Static Router Link Record.
|
||||
* @brief Get the Link Type field of the Global Router Link Record.
|
||||
*
|
||||
* The Link Type describes the kind of link a given record represents. The
|
||||
* values are defined by OSPF.
|
||||
*
|
||||
* @see LinkType
|
||||
* @returns The LinkType of the current Static Router Link Record.
|
||||
* @returns The LinkType of the current Global Router Link Record.
|
||||
*/
|
||||
LinkType GetLinkType(void) const;
|
||||
/**
|
||||
* @brief Set the Link Type field of the Static Router Link Record.
|
||||
* @brief Set the Link Type field of the Global Router Link Record.
|
||||
*
|
||||
* The Link Type describes the kind of link a given record represents. The
|
||||
* values are defined by OSPF.
|
||||
*
|
||||
* @see LinkType
|
||||
* @param linkType The new LinkType for the current Static Router Link Record.
|
||||
* @param linkType The new LinkType for the current Global Router Link Record.
|
||||
*/
|
||||
void SetLinkType(LinkType linkType);
|
||||
/**
|
||||
* @brief Get the Metric Data field of the Static Router Link Record.
|
||||
* @brief Get the Metric Data field of the Global Router Link Record.
|
||||
*
|
||||
* The metric is an abstract cost associated with forwarding a packet across
|
||||
* a link. A sum of metrics must have a well-defined meaning. That is, you
|
||||
@@ -160,11 +160,11 @@ public:
|
||||
* two hops relate to the cost of sending a packet); rather you should use
|
||||
* something like delay.
|
||||
*
|
||||
* @returns The metric field of the Static Router Link Record.
|
||||
* @returns The metric field of the Global Router Link Record.
|
||||
*/
|
||||
uint32_t GetMetric(void) const;
|
||||
/**
|
||||
* @brief Set the Metric Data field of the Static Router Link Record.
|
||||
* @brief Set the Metric Data field of the Global Router Link Record.
|
||||
*
|
||||
* The metric is an abstract cost associated with forwarding a packet across
|
||||
* a link. A sum of metrics must have a well-defined meaning. That is, you
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
* two hops relate to the cost of sending a packet); rather you should use
|
||||
* something like delay.
|
||||
*
|
||||
* @param metric The new metric for the current Static Router Link Record.
|
||||
* @param metric The new metric for the current Global Router Link Record.
|
||||
*/
|
||||
void SetMetric(uint32_t metric);
|
||||
|
||||
@@ -199,7 +199,7 @@ private:
|
||||
*/
|
||||
Ipv4Address m_linkData; // for links to RouterLSA,
|
||||
/**
|
||||
* The type of the Static Router Link Record. Defined in the OSPF spec.
|
||||
* The type of the Global Router Link Record. Defined in the OSPF spec.
|
||||
* We currently only use PointToPoint and StubNetwork types.
|
||||
*/
|
||||
LinkType m_linkType;
|
||||
@@ -216,14 +216,14 @@ private:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief a Link State Advertisement (LSA) for a router, used in static
|
||||
* @brief a Link State Advertisement (LSA) for a router, used in global
|
||||
* routing.
|
||||
*
|
||||
* Roughly equivalent to a static incarnation of the OSPF link state header
|
||||
* combined with a list of Link Records. Since it's static, there's
|
||||
* Roughly equivalent to a global incarnation of the OSPF link state header
|
||||
* combined with a list of Link Records. Since it's global, there's
|
||||
* no need for age or sequence number. See RFC 2328, Appendix A.
|
||||
*/
|
||||
class StaticRouterLSA
|
||||
class GlobalRouterLSA
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@@ -237,14 +237,14 @@ public:
|
||||
LSA_SPF_IN_SPFTREE /**< Vertex is in the SPF tree */
|
||||
};
|
||||
/**
|
||||
* @brief Create a blank Static Router Link State Advertisement.
|
||||
* @brief Create a blank Global Router Link State Advertisement.
|
||||
*
|
||||
* On completion Ipv4Address variables initialized to 0.0.0.0 and the
|
||||
* list of Link State Records is empty.
|
||||
*/
|
||||
StaticRouterLSA();
|
||||
GlobalRouterLSA();
|
||||
/**
|
||||
* @brief Create an initialized Static Router Link State Advertisement.
|
||||
* @brief Create an initialized Global Router Link State Advertisement.
|
||||
*
|
||||
* On completion the list of Link State Records is empty.
|
||||
*
|
||||
@@ -252,38 +252,38 @@ public:
|
||||
* @param linkStateId The Ipv4Address for the link state ID field.
|
||||
* @param advertisingRtr The Ipv4Address for the advertising router field.
|
||||
*/
|
||||
StaticRouterLSA(SPFStatus status, Ipv4Address linkStateId,
|
||||
GlobalRouterLSA(SPFStatus status, Ipv4Address linkStateId,
|
||||
Ipv4Address advertisingRtr);
|
||||
/**
|
||||
* @brief Copy constructor for a Static Router Link State Advertisement.
|
||||
* @brief Copy constructor for a Global Router Link State Advertisement.
|
||||
*
|
||||
* Takes a piece of memory and constructs a semantically identical copy of
|
||||
* the given LSA.
|
||||
*
|
||||
* @param lsa The existing LSA to be used as the source.
|
||||
*/
|
||||
StaticRouterLSA (StaticRouterLSA& lsa);
|
||||
GlobalRouterLSA (GlobalRouterLSA& lsa);
|
||||
/**
|
||||
* @brief Destroy an existing Static Router Link State Advertisement.
|
||||
* @brief Destroy an existing Global Router Link State Advertisement.
|
||||
*
|
||||
* Any Static Router Link Records present in the list are freed.
|
||||
* Any Global Router Link Records present in the list are freed.
|
||||
*/
|
||||
~StaticRouterLSA();
|
||||
~GlobalRouterLSA();
|
||||
/**
|
||||
* @brief Assignment operator for a Static Router Link State Advertisement.
|
||||
* @brief Assignment operator for a Global Router Link State Advertisement.
|
||||
*
|
||||
* Takes an existing Static Router Link State Advertisement and overwrites
|
||||
* Takes an existing Global Router Link State Advertisement and overwrites
|
||||
* it to make a semantically identical copy of a given prototype LSA.
|
||||
*
|
||||
* If there are any Static Router Link Records present in the existing
|
||||
* If there are any Global Router Link Records present in the existing
|
||||
* LSA, they are freed before the assignment happens.
|
||||
*
|
||||
* @param lsa The existing LSA to be used as the source.
|
||||
* @returns Reference to the overwritten LSA.
|
||||
*/
|
||||
StaticRouterLSA& operator= (const StaticRouterLSA& lsa);
|
||||
GlobalRouterLSA& operator= (const GlobalRouterLSA& lsa);
|
||||
/**
|
||||
* @brief Copy any Static Router Link Records in a given Static Router Link
|
||||
* @brief Copy any Global Router Link Records in a given Global Router Link
|
||||
* State Advertisement to the current LSA.
|
||||
*
|
||||
* Existing Link Records are not deleted -- this is a concatenation of Link
|
||||
@@ -292,42 +292,42 @@ public:
|
||||
* @see ClearLinkRecords ()
|
||||
* @param lsa The LSA to copy the Link Records from.
|
||||
*/
|
||||
void CopyLinkRecords (const StaticRouterLSA& lsa);
|
||||
void CopyLinkRecords (const GlobalRouterLSA& lsa);
|
||||
/**
|
||||
* @brief Add a given Static Router Link Record to the LSA.
|
||||
* @brief Add a given Global Router Link Record to the LSA.
|
||||
*
|
||||
* @param lr The Static Router Link Record to be added.
|
||||
* @param lr The Global Router Link Record to be added.
|
||||
* @returns The number of link records in the list.
|
||||
*/
|
||||
uint32_t AddLinkRecord (StaticRouterLinkRecord* lr);
|
||||
uint32_t AddLinkRecord (GlobalRouterLinkRecord* lr);
|
||||
/**
|
||||
* @brief Return the number of Static Router Link Records in the LSA.
|
||||
* @brief Return the number of Global Router Link Records in the LSA.
|
||||
*
|
||||
* @returns The number of link records in the list.
|
||||
*/
|
||||
uint32_t GetNLinkRecords (void) const;
|
||||
/**
|
||||
* @brief Return a pointer to the specified Static Router Link Record.
|
||||
* @brief Return a pointer to the specified Global Router Link Record.
|
||||
*
|
||||
* @param n The LSA number desired.
|
||||
* @returns The number of link records in the list.
|
||||
*/
|
||||
StaticRouterLinkRecord* GetLinkRecord (uint32_t n) const;
|
||||
GlobalRouterLinkRecord* GetLinkRecord (uint32_t n) const;
|
||||
/**
|
||||
* @brief Release all of the Static Router Link Records present in the Static
|
||||
* @brief Release all of the Global Router Link Records present in the Global
|
||||
* Router Link State Advertisement and make the list of link records empty.
|
||||
*/
|
||||
void ClearLinkRecords(void);
|
||||
/**
|
||||
* @brief Check to see if the list of Static Router Link Records present in the
|
||||
* Static Router Link State Advertisement is empty.
|
||||
* @brief Check to see if the list of Global Router Link Records present in the
|
||||
* Global Router Link State Advertisement is empty.
|
||||
*
|
||||
* @returns True if the list is empty, false otherwise.
|
||||
*/
|
||||
bool IsEmpty(void) const;
|
||||
/**
|
||||
* @brief Print the contents of the Static Router Link State Advertisement and
|
||||
* any Static Router Link Records present in the list. Quite verbose.
|
||||
* @brief Print the contents of the Global Router Link State Advertisement and
|
||||
* any Global Router Link Records present in the list. Quite verbose.
|
||||
*/
|
||||
void Print (std::ostream &os) const;
|
||||
/**
|
||||
@@ -335,7 +335,7 @@ public:
|
||||
* to the router ID of the router making the advertisement.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @see StaticRouter::GetRouterId ()
|
||||
* @see GlobalRouter::GetRouterId ()
|
||||
* @returns The Ipv4Address stored as the link state ID.
|
||||
*/
|
||||
Ipv4Address GetLinkStateId (void) const;
|
||||
@@ -344,7 +344,7 @@ public:
|
||||
* to the router ID of the router making the advertisement.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @see StaticRouter::GetRouterId ()
|
||||
* @see GlobalRouter::GetRouterId ()
|
||||
*/
|
||||
void SetLinkStateId (Ipv4Address addr);
|
||||
/**
|
||||
@@ -352,7 +352,7 @@ public:
|
||||
* set it to the router ID of the router making the advertisement.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @see StaticRouter::GetRouterId ()
|
||||
* @see GlobalRouter::GetRouterId ()
|
||||
* @returns The Ipv4Address stored as the advetising router.
|
||||
*/
|
||||
Ipv4Address GetAdvertisingRouter (void) const;
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
* set it to the router ID of the router making the advertisement.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @see StaticRouter::GetRouterId ()
|
||||
* @see GlobalRouter::GetRouterId ()
|
||||
*/
|
||||
void SetAdvertisingRouter (Ipv4Address rtr);
|
||||
/**
|
||||
@@ -384,7 +384,7 @@ private:
|
||||
* router ID of the router making the advertisement.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @see StaticRouter::GetRouterId ()
|
||||
* @see GlobalRouter::GetRouterId ()
|
||||
*/
|
||||
Ipv4Address m_linkStateId;
|
||||
/**
|
||||
@@ -392,13 +392,13 @@ private:
|
||||
* the router ID of the router making the advertisement.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @see StaticRouter::GetRouterId ()
|
||||
* @see GlobalRouter::GetRouterId ()
|
||||
*/
|
||||
Ipv4Address m_advertisingRtr;
|
||||
/**
|
||||
* A convenience typedef to avoid too much writers cramp.
|
||||
*/
|
||||
typedef std::list<StaticRouterLinkRecord*> ListOfLinkRecords_t;
|
||||
typedef std::list<GlobalRouterLinkRecord*> ListOfLinkRecords_t;
|
||||
/**
|
||||
* Each Link State Advertisement contains a number of Link Records that
|
||||
* describe the kinds of links that are attached to a given node. We
|
||||
@@ -407,7 +407,7 @@ private:
|
||||
* m_linkRecords is an STL list container to hold the Link Records that have
|
||||
* been discovered and prepared for the advertisement.
|
||||
*
|
||||
* @see StaticRouter::DiscoverLSAs ()
|
||||
* @see GlobalRouter::DiscoverLSAs ()
|
||||
*/
|
||||
ListOfLinkRecords_t m_linkRecords;
|
||||
/**
|
||||
@@ -419,99 +419,99 @@ private:
|
||||
SPFStatus m_status;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, StaticRouterLSA& lsa);
|
||||
std::ostream& operator<< (std::ostream& os, GlobalRouterLSA& lsa);
|
||||
|
||||
/**
|
||||
* @brief An interface aggregated to a node to provide static routing info
|
||||
* @brief An interface aggregated to a node to provide global routing info
|
||||
*
|
||||
* An interface aggregated to a node that provides static routing information
|
||||
* An interface aggregated to a node that provides global routing information
|
||||
* to a global route manager. The presence of the interface indicates that
|
||||
* the node is a router. The interface is the mechanism by which the router
|
||||
* advertises its connections to neighboring routers. We're basically
|
||||
* allowing the route manager to query for link state advertisements.
|
||||
*/
|
||||
class StaticRouter : public Object
|
||||
class GlobalRouter : public Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The Interface ID of the Static Router interface.
|
||||
* @brief The Interface ID of the Global Router interface.
|
||||
*
|
||||
* @see Object::QueryInterface ()
|
||||
*/
|
||||
static const InterfaceId iid;
|
||||
/**
|
||||
* @brief Create a Static Router class and aggregate its interface onto the
|
||||
* @brief Create a Global Router class and aggregate its interface onto the
|
||||
* Node provided.
|
||||
*
|
||||
* @param node The existing Node onto which this router will be aggregated.
|
||||
*/
|
||||
StaticRouter (Ptr<Node> node);
|
||||
GlobalRouter (Ptr<Node> node);
|
||||
/**
|
||||
* @brief Get the Router ID associated with this Static Router.
|
||||
* @brief Get the Router ID associated with this Global Router.
|
||||
*
|
||||
* The Router IDs are allocated in the RoutingEnvironment -- one per Router,
|
||||
* starting at 0.0.0.1 and incrementing with each instantiation of a router.
|
||||
*
|
||||
* @see RoutingEnvironment::AllocateRouterId ()
|
||||
* @returns The Router ID associated with the Static Router.
|
||||
* @returns The Router ID associated with the Global Router.
|
||||
*/
|
||||
Ipv4Address GetRouterId (void) const;
|
||||
/**
|
||||
* @brief Walk the connected channels, discover the adjacent routers and build
|
||||
* the associated number of Static Router Link State Advertisements that
|
||||
* the associated number of Global Router Link State Advertisements that
|
||||
* this router can export.
|
||||
*
|
||||
* This is a fairly expensive operation in that every time it is called
|
||||
* the current list of LSAs is built by walking connected point-to-point
|
||||
* channels and peeking into adjacent IPV4 stacks to get address information.
|
||||
* This is done to allow for limited dymanics of the Static Routing
|
||||
* This is done to allow for limited dymanics of the Global Routing
|
||||
* environment. By that we mean that you can discover new link state
|
||||
* advertisements after a network topology change by calling DiscoverLSAs
|
||||
* and then by reading those advertisements.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::GetLSA ()
|
||||
* @returns The number of Static Router Link State Advertisements.
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouter::GetLSA ()
|
||||
* @returns The number of Global Router Link State Advertisements.
|
||||
*/
|
||||
uint32_t DiscoverLSAs (void);
|
||||
/**
|
||||
* @brief Get the Number of Static Router Link State Advertisements that this
|
||||
* @brief Get the Number of Global Router Link State Advertisements that this
|
||||
* router can export.
|
||||
*
|
||||
* To get meaningful information you must have previously called DiscoverLSAs.
|
||||
* After you know how many LSAs are present in the router, you may call
|
||||
* GetLSA () to retrieve the actual advertisement.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::DiscoverLSAs ()
|
||||
* @see StaticRouter::GetLSA ()
|
||||
* @returns The number of Static Router Link State Advertisements.
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouter::DiscoverLSAs ()
|
||||
* @see GlobalRouter::GetLSA ()
|
||||
* @returns The number of Global Router Link State Advertisements.
|
||||
*/
|
||||
uint32_t GetNumLSAs (void) const;
|
||||
/**
|
||||
* @brief Get a Static Router Link State Advertisements that this router has
|
||||
* @brief Get a Global Router Link State Advertisements that this router has
|
||||
* said that it can export.
|
||||
*
|
||||
* This is a fairly inexpensive expensive operation in that the hard work
|
||||
* was done in GetNumLSAs. We just copy the indicated Static Router Link
|
||||
* State Advertisement into the requested StaticRouterLSA object.
|
||||
* was done in GetNumLSAs. We just copy the indicated Global Router Link
|
||||
* State Advertisement into the requested GlobalRouterLSA object.
|
||||
*
|
||||
* You must call StaticRouter::GetNumLSAs before calling this method in
|
||||
* You must call GlobalRouter::GetNumLSAs before calling this method in
|
||||
* order to discover the adjacent routers and build the advertisements.
|
||||
* GetNumLSAs will return the number of LSAs this router advertises.
|
||||
* The parameter n (requested LSA number) must be in the range 0 to
|
||||
* GetNumLSAs() - 1.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::GetNumLSAs ()
|
||||
* @see GlobalRouterLSA
|
||||
* @see GlobalRouter::GetNumLSAs ()
|
||||
* @param n The index number of the LSA you want to read.
|
||||
* @param lsa The StaticRouterLSA class to receive the LSA information.
|
||||
* @returns The number of Static Router Link State Advertisements.
|
||||
* @param lsa The GlobalRouterLSA class to receive the LSA information.
|
||||
* @returns The number of Global Router Link State Advertisements.
|
||||
*/
|
||||
bool GetLSA (uint32_t n, StaticRouterLSA &lsa) const;
|
||||
bool GetLSA (uint32_t n, GlobalRouterLSA &lsa) const;
|
||||
|
||||
protected:
|
||||
virtual ~StaticRouter ();
|
||||
virtual ~GlobalRouter ();
|
||||
void ClearLSAs (void);
|
||||
|
||||
Ptr<NetDevice> GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const;
|
||||
@@ -519,22 +519,22 @@ protected:
|
||||
|
||||
Ptr<Node> m_node;
|
||||
|
||||
typedef std::list<StaticRouterLSA*> ListOfLSAs_t;
|
||||
typedef std::list<GlobalRouterLSA*> ListOfLSAs_t;
|
||||
ListOfLSAs_t m_LSAs;
|
||||
|
||||
Ipv4Address m_routerId;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Static Router copy construction is disallowed.
|
||||
* @brief Global Router copy construction is disallowed.
|
||||
*/
|
||||
StaticRouter (StaticRouter& sr);
|
||||
GlobalRouter (GlobalRouter& sr);
|
||||
/**
|
||||
* @brief Static Router assignment operator is disallowed.
|
||||
* @brief Global Router assignment operator is disallowed.
|
||||
*/
|
||||
StaticRouter& operator= (StaticRouter& sr);
|
||||
GlobalRouter& operator= (GlobalRouter& sr);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* STATIC_ROUTER_H */
|
||||
#endif /* GLOBAL_ROUTER_H */
|
||||
@@ -26,13 +26,13 @@ NS_DEBUG_COMPONENT_DEFINE ("RoutingEnvironment");
|
||||
namespace ns3 {
|
||||
namespace RoutingEnvironment {
|
||||
|
||||
BooleanDefaultValue g_doStaticRoutingDefaultValue ("DoStaticRouting",
|
||||
"Enable global static routing", false);
|
||||
BooleanDefaultValue g_doGlobalRoutingDefaultValue ("DoGlobalRouting",
|
||||
"Enable global global routing", false);
|
||||
|
||||
bool
|
||||
StaticRoutingEnabled(void)
|
||||
GlobalRoutingEnabled(void)
|
||||
{
|
||||
return g_doStaticRoutingDefaultValue.GetValue();
|
||||
return g_doGlobalRoutingDefaultValue.GetValue();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@@ -23,14 +23,15 @@
|
||||
|
||||
namespace ns3 {
|
||||
namespace RoutingEnvironment {
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function tests the value of the global default value
|
||||
* "DoStaticRouting". This approach puts everything in one compilation
|
||||
* unit, as opposed to explicitly testing the value of the underlying
|
||||
* static variable.
|
||||
*/
|
||||
bool StaticRoutingEnabled(void);
|
||||
bool GlobalRoutingEnabled(void);
|
||||
|
||||
/**
|
||||
* @brief Allocate a 32-bit router ID from monotonically increasing counter.
|
||||
*/
|
||||
@@ -1,26 +0,0 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def configure(conf):
|
||||
conf.env.append_value('NS3_MODULES', 'ns3-routing')
|
||||
|
||||
|
||||
def build(bld):
|
||||
module = bld.create_obj('cpp', 'shlib')
|
||||
module.name = 'ns3-routing'
|
||||
module.target = module.name
|
||||
module.uselib_local = ['ns3-node']
|
||||
module.source = [
|
||||
'routing-environment.cc',
|
||||
'static-router.cc',
|
||||
'static-route-manager.cc',
|
||||
'static-route-manager-impl.cc',
|
||||
'candidate-queue.cc',
|
||||
]
|
||||
|
||||
headers = bld.create_obj('ns3header')
|
||||
headers.source = [
|
||||
'routing-environment.h',
|
||||
'static-router.h',
|
||||
'static-route-manager.h',
|
||||
'candidate-queue.h',
|
||||
]
|
||||
@@ -17,7 +17,7 @@ all_modules = [
|
||||
'internet-node',
|
||||
'devices/p2p',
|
||||
'applications',
|
||||
'routing',
|
||||
'routing/global',
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user