remove routing environment, move router interface creation to global-route-manager
This commit is contained in:
@@ -23,8 +23,6 @@
|
||||
|
||||
#include "ns3/composite-trace-resolver.h"
|
||||
#include "ns3/net-device.h"
|
||||
#include "ns3/routing-environment.h"
|
||||
#include "ns3/global-router-interface.h"
|
||||
|
||||
#include "l3-demux.h"
|
||||
#include "ipv4-l4-demux.h"
|
||||
@@ -77,17 +75,6 @@ InternetNode::Construct (void)
|
||||
Object::AddInterface (udpImpl);
|
||||
Object::AddInterface (l3Demux);
|
||||
Object::AddInterface (ipv4L4Demux);
|
||||
//
|
||||
// If static routing has been enabled via bind(), all nodes will have the
|
||||
// capacity to participate in the global static routing scheme. The presence
|
||||
// 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::GlobalRoutingEnabled())
|
||||
{
|
||||
Ptr<GlobalRouter> globalRouter = Create<GlobalRouter> (this);
|
||||
Object::AddInterface (globalRouter);
|
||||
}
|
||||
}
|
||||
|
||||
TraceResolver *
|
||||
|
||||
@@ -291,6 +291,31 @@ GlobalRouteManagerImpl::DebugUseLsdb (GlobalRouteManagerLSDB* lsdb)
|
||||
m_lsdb = lsdb;
|
||||
}
|
||||
|
||||
//
|
||||
// In order to build the routing database, we need at least one of the nodes
|
||||
// to participate as a router. Eventually we expect to provide a mechanism
|
||||
// for selecting a subset of the nodes to participate; for now, we just make
|
||||
// all nodes routers. We do this by walking the list of nodes in the system
|
||||
// and aggregating a Global Router Interface to each of the nodes.
|
||||
//
|
||||
void
|
||||
GlobalRouteManagerImpl::SelectRouterNodes ()
|
||||
{
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SelectRouterNodes ()");
|
||||
|
||||
typedef std::vector < Ptr<Node> >::iterator Iterator;
|
||||
for (Iterator i = NodeList::Begin (); i != NodeList::End (); i++)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
NS_DEBUG ("GlobalRouteManagerImpl::SelectRouterNodes (): "
|
||||
"Adding GlobalRouter interface to node " <<
|
||||
node->GetId ());
|
||||
|
||||
Ptr<GlobalRouter> globalRouter = Create<GlobalRouter> (node);
|
||||
node->AddInterface (globalRouter);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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 GlobalRouter interface.
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
VertexRouter, /**< Vertex representing a router in the topology */
|
||||
VertexNetwork /**< Vertex representing a network in the topology */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Construct an empty ("uninitialized") SPFVertex (Shortest Path First
|
||||
* Vertex).
|
||||
@@ -85,6 +86,7 @@ public:
|
||||
* @see VertexType
|
||||
*/
|
||||
SPFVertex();
|
||||
|
||||
/**
|
||||
* @brief Construct an initialized SPFVertex (Shortest Path First Vertex).
|
||||
*
|
||||
@@ -101,6 +103,7 @@ public:
|
||||
* @param lsa The Link State Advertisement used for finding initial values.
|
||||
*/
|
||||
SPFVertex(GlobalRouterLSA* lsa);
|
||||
|
||||
/**
|
||||
* @brief Destroy an SPFVertex (Shortest Path First Vertex).
|
||||
*
|
||||
@@ -109,6 +112,7 @@ public:
|
||||
* @see SPFVertex::SPFVertex ()
|
||||
*/
|
||||
~SPFVertex();
|
||||
|
||||
/**
|
||||
* @brief Get the Vertex Type field of a SPFVertex object.
|
||||
*
|
||||
@@ -119,6 +123,7 @@ public:
|
||||
* @returns The VertexType of the current SPFVertex object.
|
||||
*/
|
||||
VertexType GetVertexType (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the Vertex Type field of a SPFVertex object.
|
||||
*
|
||||
@@ -129,6 +134,7 @@ public:
|
||||
* @param type The new VertexType for the current SPFVertex object.
|
||||
*/
|
||||
void SetVertexType (VertexType type);
|
||||
|
||||
/**
|
||||
* @brief Get the Vertex ID field of a SPFVertex object.
|
||||
*
|
||||
@@ -143,6 +149,7 @@ public:
|
||||
* @returns The Ipv4Address Vertex ID of the current SPFVertex object.
|
||||
*/
|
||||
Ipv4Address GetVertexId (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the Vertex ID field of a SPFVertex object.
|
||||
*
|
||||
@@ -158,6 +165,7 @@ public:
|
||||
* @param id The new Ipv4Address Vertex ID for the current SPFVertex object.
|
||||
*/
|
||||
void SetVertexId (Ipv4Address id);
|
||||
|
||||
/**
|
||||
* @brief Get the Global Router Link State Advertisement returned by the
|
||||
* Global Router represented by this SPFVertex during the route discovery
|
||||
@@ -170,6 +178,7 @@ public:
|
||||
* by this SPFVertex object.
|
||||
*/
|
||||
GlobalRouterLSA* GetLSA (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the Global Router Link State Advertisement returned by the
|
||||
* Global Router represented by this SPFVertex during the route discovery
|
||||
@@ -184,6 +193,7 @@ public:
|
||||
* @param lsa A pointer to the GlobalRouterLSA.
|
||||
*/
|
||||
void SetLSA (GlobalRouterLSA* lsa);
|
||||
|
||||
/**
|
||||
* @brief Get the distance from the root vertex to "this" SPFVertex object.
|
||||
*
|
||||
@@ -205,6 +215,7 @@ public:
|
||||
* @returns The distance, in hops, from the root SPFVertex to "this" SPFVertex.
|
||||
*/
|
||||
uint32_t GetDistanceFromRoot (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the distance from the root vertex to "this" SPFVertex object.
|
||||
*
|
||||
@@ -224,6 +235,7 @@ public:
|
||||
* SPFVertex.
|
||||
*/
|
||||
void SetDistanceFromRoot (uint32_t distance);
|
||||
|
||||
/**
|
||||
* @brief Get the interface ID that should be used to begin forwarding packets
|
||||
* from the root SPFVertex to "this" SPFVertex.
|
||||
@@ -264,6 +276,7 @@ public:
|
||||
* or network represented by "this" SPFVertex.
|
||||
*/
|
||||
uint32_t GetOutgoingInterfaceId (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the interface ID that should be used to begin forwarding packets
|
||||
* from the root SPFVertex to "this" SPFVertex.
|
||||
@@ -304,6 +317,7 @@ public:
|
||||
* network represented by "this" SPFVertex.
|
||||
*/
|
||||
void SetOutgoingInterfaceId (uint32_t id);
|
||||
|
||||
/**
|
||||
* @brief Get the IP address that should be used to begin forwarding packets
|
||||
* from the root SPFVertex to "this" SPFVertex.
|
||||
@@ -345,6 +359,7 @@ public:
|
||||
* or network represented by "this" SPFVertex.
|
||||
*/
|
||||
Ipv4Address GetNextHop (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the IP address that should be used to begin forwarding packets
|
||||
* from the root SPFVertex to "this" SPFVertex.
|
||||
@@ -386,6 +401,7 @@ public:
|
||||
* or network represented by "this" SPFVertex.
|
||||
*/
|
||||
void SetNextHop (Ipv4Address nextHop);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the SPFVector that is the parent of "this"
|
||||
* SPFVertex.
|
||||
@@ -405,6 +421,7 @@ public:
|
||||
* in the SPF tree.
|
||||
*/
|
||||
SPFVertex* GetParent (void) const;
|
||||
|
||||
/**
|
||||
* @brief Set the pointer to the SPFVector that is the parent of "this"
|
||||
* SPFVertex.
|
||||
@@ -424,6 +441,7 @@ public:
|
||||
* SPFVertex* in the SPF tree.
|
||||
*/
|
||||
void SetParent (SPFVertex* parent);
|
||||
|
||||
/**
|
||||
* @brief Get the number of children of "this" SPFVertex.
|
||||
*
|
||||
@@ -444,6 +462,7 @@ public:
|
||||
* SPF tree).
|
||||
*/
|
||||
uint32_t GetNChildren (void) const;
|
||||
|
||||
/**
|
||||
* @brief Get a borrowed SPFVertex pointer to the specified child of "this"
|
||||
* SPFVertex.
|
||||
@@ -471,6 +490,7 @@ public:
|
||||
* SPF tree).
|
||||
*/
|
||||
SPFVertex* GetChild (uint32_t n) const;
|
||||
|
||||
/**
|
||||
* @brief Get a borrowed SPFVertex pointer to the specified child of "this"
|
||||
* SPFVertex.
|
||||
@@ -509,11 +529,13 @@ private:
|
||||
SPFVertex* m_parent;
|
||||
typedef std::list<SPFVertex*> ListOfSPFVertex_t;
|
||||
ListOfSPFVertex_t m_children;
|
||||
|
||||
/**
|
||||
* @brief The SPFVertex copy construction is disallowed. There's no need for
|
||||
* it and a compiler provided shallow copy would be wrong.
|
||||
*/
|
||||
SPFVertex (SPFVertex& v);
|
||||
|
||||
/**
|
||||
* @brief The SPFVertex copy assignment operator is disallowed. There's no
|
||||
* need for it and a compiler provided shallow copy would be wrong.
|
||||
@@ -544,6 +566,7 @@ public:
|
||||
* this constructor.
|
||||
*/
|
||||
GlobalRouteManagerLSDB ();
|
||||
|
||||
/**
|
||||
* @brief Destroy an empty Global Router Manager Link State Database.
|
||||
*
|
||||
@@ -552,6 +575,7 @@ public:
|
||||
* release any remaining resources.
|
||||
*/
|
||||
~GlobalRouteManagerLSDB ();
|
||||
|
||||
/**
|
||||
* @brief Insert an IP address / Link State Advertisement pair into the Link
|
||||
* State Database.
|
||||
@@ -566,6 +590,7 @@ public:
|
||||
* @param lsa A pointer to the Link State Advertisement for the router.
|
||||
*/
|
||||
void Insert(Ipv4Address addr, GlobalRouterLSA* lsa);
|
||||
|
||||
/**
|
||||
* @brief Look up the Link State Advertisement associated with the given
|
||||
* IP Address.
|
||||
@@ -581,6 +606,7 @@ public:
|
||||
* by the IP address addr.
|
||||
*/
|
||||
GlobalRouterLSA* GetLSA (Ipv4Address addr) const;
|
||||
|
||||
/**
|
||||
* @brief Set all LSA flags to an initialized state, for SPF computation
|
||||
*
|
||||
@@ -604,6 +630,7 @@ private:
|
||||
* need for it and a compiler provided shallow copy would be wrong.
|
||||
*/
|
||||
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.
|
||||
@@ -627,25 +654,36 @@ class GlobalRouteManagerImpl
|
||||
public:
|
||||
GlobalRouteManagerImpl ();
|
||||
virtual ~GlobalRouteManagerImpl ();
|
||||
/**
|
||||
* @brief Select which nodes in the system are to be router nodes and
|
||||
* aggregate the appropriate interfaces onto those nodes.
|
||||
*
|
||||
*/
|
||||
virtual void SelectRouterNodes ();
|
||||
|
||||
/**
|
||||
* @brief Build the routing database by gathering Link State Advertisements
|
||||
* from each node exporting a GlobalRouter interface.
|
||||
*
|
||||
*/
|
||||
virtual void BuildGlobalRoutingDatabase();
|
||||
virtual void BuildGlobalRoutingDatabase ();
|
||||
|
||||
/**
|
||||
* @brief Compute routes using a Dijkstra SPF computation and populate
|
||||
* per-node forwarding tables
|
||||
*/
|
||||
virtual void InitializeRoutes();
|
||||
virtual void InitializeRoutes ();
|
||||
|
||||
/**
|
||||
* @brief Debugging routine; allow client code to supply a pre-built LSDB
|
||||
*/
|
||||
void DebugUseLsdb (GlobalRouteManagerLSDB*);
|
||||
|
||||
/**
|
||||
* @brief Debugging routine; call the core SPF from the unit tests
|
||||
*/
|
||||
void DebugSPFCalculate (Ipv4Address root);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief GlobalRouteManagerImpl copy construction is disallowed.
|
||||
@@ -653,6 +691,7 @@ private:
|
||||
* wrong.
|
||||
*/
|
||||
GlobalRouteManagerImpl (GlobalRouteManagerImpl& srmi);
|
||||
|
||||
/**
|
||||
* @brief Global Route Manager Implementation assignment operator is
|
||||
* disallowed. There's no need for it and a compiler provided shallow copy
|
||||
@@ -666,11 +705,11 @@ private:
|
||||
void SPFNext (SPFVertex*, CandidateQueue&);
|
||||
int SPFNexthopCalculation (SPFVertex* v, SPFVertex* w,
|
||||
GlobalRouterLinkRecord* l, uint32_t distance);
|
||||
void SPFVertexAddParent(SPFVertex* v);
|
||||
GlobalRouterLinkRecord* SPFGetNextLink(SPFVertex* v, SPFVertex* w,
|
||||
void SPFVertexAddParent (SPFVertex* v);
|
||||
GlobalRouterLinkRecord* SPFGetNextLink (SPFVertex* v, SPFVertex* w,
|
||||
GlobalRouterLinkRecord* prev_link);
|
||||
void SPFIntraAddRouter(SPFVertex* v);
|
||||
uint32_t FindOutgoingInterfaceId(Ipv4Address a);
|
||||
void SPFIntraAddRouter (SPFVertex* v);
|
||||
uint32_t FindOutgoingInterfaceId (Ipv4Address a);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -31,22 +31,38 @@ namespace ns3 {
|
||||
void
|
||||
GlobalRouteManager::PopulateRoutingTables ()
|
||||
{
|
||||
SelectRouterNodes ();
|
||||
BuildGlobalRoutingDatabase ();
|
||||
InitializeRoutes ();
|
||||
}
|
||||
|
||||
void
|
||||
GlobalRouteManager::SelectRouterNodes ()
|
||||
{
|
||||
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
SelectRouterNodes ();
|
||||
}
|
||||
|
||||
void
|
||||
GlobalRouteManager::BuildGlobalRoutingDatabase ()
|
||||
{
|
||||
return SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
BuildGlobalRoutingDatabase ();
|
||||
}
|
||||
|
||||
void
|
||||
GlobalRouteManager::InitializeRoutes ()
|
||||
{
|
||||
return SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
SimulationSingleton<GlobalRouteManagerImpl>::Get ()->
|
||||
InitializeRoutes ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GlobalRouteManager::AllocateRouterId ()
|
||||
{
|
||||
static uint32_t routerId = 0;
|
||||
return routerId++;
|
||||
}
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef STATIC_ROUTE_MANAGER_H
|
||||
#ifndef GLOBAL_ROUTE_MANAGER_H
|
||||
#define GLOBAL_ROUTE_MANAGER_H
|
||||
|
||||
namespace ns3 {
|
||||
@@ -45,7 +45,19 @@ public:
|
||||
*/
|
||||
static void PopulateRoutingTables ();
|
||||
|
||||
/**
|
||||
* @brief Allocate a 32-bit router ID from monotonically increasing counter.
|
||||
*/
|
||||
static uint32_t AllocateRouterId ();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Select which nodes in the system are to be router nodes and
|
||||
* aggregate the appropriate interfaces onto those nodes.
|
||||
*
|
||||
*/
|
||||
static void SelectRouterNodes ();
|
||||
|
||||
/**
|
||||
* @brief Build the routing database by gathering Link State Advertisements
|
||||
* from each node exporting a GlobalRouter interface.
|
||||
|
||||
@@ -323,7 +323,7 @@ GlobalRouter::GlobalRouter (Ptr<Node> node)
|
||||
{
|
||||
NS_DEBUG("GlobalRouter::GlobalRouter ()");
|
||||
SetInterfaceId (GlobalRouter::iid);
|
||||
m_routerId.Set(RoutingEnvironment::AllocateRouterId());
|
||||
m_routerId.Set(GlobalRouteManager::AllocateRouterId ());
|
||||
}
|
||||
|
||||
GlobalRouter::~GlobalRouter ()
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/channel.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/routing-environment.h"
|
||||
#include "ns3/global-route-manager.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "ns3/debug.h"
|
||||
#include "ns3/default-value.h"
|
||||
|
||||
#include "routing-environment.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("RoutingEnvironment");
|
||||
|
||||
namespace ns3 {
|
||||
namespace RoutingEnvironment {
|
||||
|
||||
BooleanDefaultValue g_doGlobalRoutingDefaultValue ("DoGlobalRouting",
|
||||
"Enable global global routing", false);
|
||||
|
||||
bool
|
||||
GlobalRoutingEnabled(void)
|
||||
{
|
||||
return g_doGlobalRoutingDefaultValue.GetValue();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
AllocateRouterId(void)
|
||||
{
|
||||
static uint32_t routerId = 0;
|
||||
return routerId++;
|
||||
}
|
||||
|
||||
} // namespace RoutingEnvironment
|
||||
} // namespace ns3
|
||||
@@ -1,44 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef ROUTING_ENVIRONMENT_H
|
||||
#define ROUTING_ENVIRONMENT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
|
||||
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 GlobalRoutingEnabled(void);
|
||||
|
||||
/**
|
||||
* @brief Allocate a 32-bit router ID from monotonically increasing counter.
|
||||
*/
|
||||
uint32_t AllocateRouterId(void);
|
||||
|
||||
} // namespace RoutingEnvironment
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* ROUTING_ENVIRONMENT_H */
|
||||
24
src/routing/global/wscript
Normal file
24
src/routing/global/wscript
Normal file
@@ -0,0 +1,24 @@
|
||||
## -*- 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 = [
|
||||
'global-router-interface.cc',
|
||||
'global-route-manager.cc',
|
||||
'global-route-manager-impl.cc',
|
||||
'candidate-queue.cc',
|
||||
]
|
||||
|
||||
headers = bld.create_obj('ns3header')
|
||||
headers.source = [
|
||||
'global-router-interface.h',
|
||||
'global-route-manager.h',
|
||||
'candidate-queue.h',
|
||||
]
|
||||
Reference in New Issue
Block a user