A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::GlobalRouter Class Reference

An interface aggregated to a node to provide global routing info. More...

#include <global-router-interface.h>

+ Inheritance diagram for ns3::GlobalRouter:
+ Collaboration diagram for ns3::GlobalRouter:

Public Member Functions

 GlobalRouter ()
 Create a Global Router class. More...
 
uint32_t DiscoverLSAs (void)
 Walk the connected channels, discover the adjacent routers and build the associated number of Global Routing Link State Advertisements that this router can export. More...
 
Ipv4RoutingTableEntryGetInjectedRoute (uint32_t i)
 Return the injected route indexed by i. More...
 
bool GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const
 Get a Global Routing Link State Advertisements that this router has said that it can export. More...
 
uint32_t GetNInjectedRoutes (void)
 Get the number of injected routes that have been added to the routing table. More...
 
uint32_t GetNumLSAs (void) const
 Get the Number of Global Routing Link State Advertisements that this router can export. More...
 
Ipv4Address GetRouterId (void) const
 Get the Router ID associated with this Global Router. More...
 
Ptr< Ipv4GlobalRoutingGetRoutingProtocol (void)
 Get the specific Global Routing Protocol used. More...
 
void InjectRoute (Ipv4Address network, Ipv4Mask networkMask)
 Inject a route to be circulated to other routers as an external route. More...
 
void RemoveInjectedRoute (uint32_t i)
 Withdraw a route from the global unicast routing table. More...
 
void SetRoutingProtocol (Ptr< Ipv4GlobalRouting > routing)
 Set the specific Global Routing Protocol to be used. More...
 
bool WithdrawRoute (Ipv4Address network, Ipv4Mask networkMask)
 Withdraw a route from the global unicast routing table. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 
virtual ~Object ()
 
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 Run the DoDispose methods of this object and all the objects aggregated to it. More...
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 This method calls the virtual DoInitialize method on all the objects aggregated to this object. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 Noop. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Private Types

typedef std::list
< Ipv4RoutingTableEntry * > 
InjectedRoutes
 container of Ipv4RoutingTableEntry More...
 
typedef std::list
< Ipv4RoutingTableEntry * >
::const_iterator 
InjectedRoutesCI
 Const Iterator to container of Ipv4RoutingTableEntry. More...
 
typedef std::list
< Ipv4RoutingTableEntry * >
::iterator 
InjectedRoutesI
 Iterator to container of Ipv4RoutingTableEntry. More...
 
typedef std::list
< GlobalRoutingLSA * > 
ListOfLSAs_t
 container for the GlobalRoutingLSAs More...
 

Private Member Functions

 GlobalRouter (GlobalRouter &sr)
 Global Router copy construction is disallowed. More...
 
virtual ~GlobalRouter ()
 
bool AnotherRouterOnLink (Ptr< NetDevice > nd, bool allowRecursion) const
 Checks for the presence of another router on the NetDevice. More...
 
void BuildNetworkLSAs (NetDeviceContainer c)
 Build one NetworkLSA for each net device talking to a network that we are the designated router for. More...
 
void ClearLSAs (void)
 Clear list of LSAs. More...
 
virtual void DoDispose (void)
 This method is called by Object::Dispose or by the object's destructor, whichever comes first. More...
 
Ipv4Address FindDesignatedRouterForLink (Ptr< NetDevice > ndLocal, bool allowRecursion) const
 Finds a designated router. More...
 
bool FindInterfaceForDevice (Ptr< Node > node, Ptr< NetDevice > nd, uint32_t &index) const
 Given a node and a net device, find an IPV4 interface index that corresponds to that net device. More...
 
Ptr< NetDeviceGetAdjacent (Ptr< NetDevice > nd, Ptr< Channel > ch) const
 Link through the given channel and find the net device that's on the other end. More...
 
Ptr< BridgeNetDeviceNetDeviceIsBridged (Ptr< NetDevice > nd) const
 Decide whether or not a given net device is being bridged by a BridgeNetDevice. More...
 
GlobalRouteroperator= (GlobalRouter &sr)
 Global Router assignment operator is disallowed. More...
 
void ProcessBridgedBroadcastLink (Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
 Process a bridged broadcast link. More...
 
void ProcessBroadcastLink (Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
 Process a generic broadcast link. More...
 
void ProcessPointToPointLink (Ptr< NetDevice > ndLocal, GlobalRoutingLSA *pLSA)
 Process a point to point link. More...
 
void ProcessSingleBroadcastLink (Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
 Process a single broadcast link. More...
 

Private Attributes

InjectedRoutes m_injectedRoutes
 Routes we are exporting. More...
 
ListOfLSAs_t m_LSAs
 database of GlobalRoutingLSAs More...
 
Ipv4Address m_routerId
 router ID (its IPv4 address) More...
 
Ptr< Ipv4GlobalRoutingm_routingProtocol
 the Ipv4GlobalRouting in use More...
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 This method is called only once by Object::Initialize. More...
 
virtual void NotifyNewAggregate (void)
 This method is invoked whenever two sets of objects are aggregated together. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 This method is invoked once all member attributes have been initialized. More...
 

Detailed Description

An interface aggregated to a node to provide global routing info.

Doxygen introspection did not find any typical Config paths.

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.


No Attributes are defined for this type.
No TraceSources are defined for this type.

Definition at line 583 of file global-router-interface.h.

Member Typedef Documentation

Const Iterator to container of Ipv4RoutingTableEntry.

Definition at line 846 of file global-router-interface.h.

Iterator to container of Ipv4RoutingTableEntry.

Definition at line 847 of file global-router-interface.h.

container for the GlobalRoutingLSAs

Definition at line 839 of file global-router-interface.h.

Constructor & Destructor Documentation

ns3::GlobalRouter::GlobalRouter ( )

Create a Global Router class.

Definition at line 517 of file global-router-interface.cc.

References ns3::GlobalRouteManager::AllocateRouterId(), m_routerId, NS_LOG_FUNCTION, and ns3::Ipv4Address::Set().

+ Here is the call graph for this function:

ns3::GlobalRouter::~GlobalRouter ( )
privatevirtual

Definition at line 524 of file global-router-interface.cc.

References ClearLSAs(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

ns3::GlobalRouter::GlobalRouter ( GlobalRouter sr)
private

Global Router copy construction is disallowed.

Member Function Documentation

bool ns3::GlobalRouter::AnotherRouterOnLink ( Ptr< NetDevice nd,
bool  allowRecursion 
) const
private

Checks for the presence of another router on the NetDevice.

Given a node and an attached net device, take a look off in the channel to which the net device is attached and look for a node on the other side that has a GlobalRouter interface aggregated. Life gets more complicated when there is a bridged net device on the other side.

Parameters
ndNetDevice to scan
allowRecursionRecursively look for routers down bridge port
Returns
true if a router is found

Definition at line 1382 of file global-router-interface.cc.

References ns3::Object::GetObject(), NetDeviceIsBridged(), NS_ASSERT, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by ProcessBridgedBroadcastLink(), and ProcessSingleBroadcastLink().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::GlobalRouter::ClearLSAs ( void  )
private

Clear list of LSAs.

Definition at line 558 of file global-router-interface.cc.

References m_LSAs, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by DiscoverLSAs(), and ~GlobalRouter().

+ Here is the caller graph for this function:

uint32_t ns3::GlobalRouter::DiscoverLSAs ( void  )

Walk the connected channels, discover the adjacent routers and build the associated number of Global Routing 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 dynamics 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 also
GlobalRoutingLSA
GlobalRouter::GetLSA ()
Returns
The number of Global Routing Link State Advertisements.

Definition at line 591 of file global-router-interface.cc.

References ns3::GlobalRoutingLSA::ASExternalLSAs, BuildNetworkLSAs(), ClearLSAs(), FindInterfaceForDevice(), ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::NetDeviceContainer::GetN(), ns3::Node::GetNDevices(), ns3::Object::GetObject(), ns3::GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED, m_injectedRoutes, m_LSAs, m_routerId, NetDeviceIsBridged(), NS_ABORT_MSG_IF, NS_ABORT_MSG_UNLESS, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ProcessBroadcastLink(), ProcessPointToPointLink(), ns3::GlobalRoutingLSA::RouterLSA, ns3::GlobalRoutingLSA::SetAdvertisingRouter(), ns3::GlobalRoutingLSA::SetLinkStateId(), ns3::GlobalRoutingLSA::SetLSType(), ns3::GlobalRoutingLSA::SetNetworkLSANetworkMask(), ns3::GlobalRoutingLSA::SetNode(), and ns3::GlobalRoutingLSA::SetStatus().

+ Here is the call graph for this function:

void ns3::GlobalRouter::DoDispose ( void  )
privatevirtual

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

It is safe to call GetObject from within this method.

Reimplemented from ns3::Object.

Definition at line 544 of file global-router-interface.cc.

References ns3::Object::DoDispose(), m_injectedRoutes, m_routingProtocol, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Ipv4Address ns3::GlobalRouter::FindDesignatedRouterForLink ( Ptr< NetDevice ndLocal,
bool  allowRecursion 
) const
private

Finds a designated router.

Given a local net device, we need to walk the channel to which the net device is attached and look for nodes with GlobalRouter interfaces on them (one of them will be us). Of these, the router with the lowest IP address on the net device connecting to the channel becomes the designated router for the link.

Parameters
ndLocallocal NetDevice to scan
allowRecursionRecursively look for routers down bridge port
Returns
the IP address of the designated router

Definition at line 1245 of file global-router-interface.cc.

References FindInterfaceForDevice(), ns3::Node::GetId(), ns3::Ipv4::GetNInterfaces(), ns3::Object::GetObject(), NetDeviceIsBridged(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, and NS_LOG_WARN.

Referenced by ProcessBridgedBroadcastLink(), and ProcessSingleBroadcastLink().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::GlobalRouter::FindInterfaceForDevice ( Ptr< Node node,
Ptr< NetDevice nd,
uint32_t &  index 
) const
private

Given a node and a net device, find an IPV4 interface index that corresponds to that net device.

This function may fail for various reasons. If a node does not have an internet stack (for example if it is a bridge) we won't have an IPv4 at all. If the node does have a stack, but the net device in question is bridged, there will not be an interface associated directly with the device.

Parameters
nodethe node
ndoutgoing NetDevice
indexthe IPV4 interface index
Returns
true on success

Definition at line 1632 of file global-router-interface.cc.

References ns3::Node::GetId(), ns3::Object::GetObject(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by BuildNetworkLSAs(), DiscoverLSAs(), FindDesignatedRouterForLink(), ProcessBridgedBroadcastLink(), ProcessPointToPointLink(), and ProcessSingleBroadcastLink().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ptr< NetDevice > ns3::GlobalRouter::GetAdjacent ( Ptr< NetDevice nd,
Ptr< Channel ch 
) const
private

Link through the given channel and find the net device that's on the other end.

This only makes sense with a point-to-point channel.

Parameters
ndoutgoing NetDevice
chchannel
Returns
the NetDevice on the other end

Definition at line 1594 of file global-router-interface.cc.

References NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Referenced by ProcessPointToPointLink().

+ Here is the caller graph for this function:

Ipv4RoutingTableEntry * ns3::GlobalRouter::GetInjectedRoute ( uint32_t  i)

Return the injected route indexed by i.

Parameters
ithe index of the route
Returns
a pointer to that Ipv4RoutingTableEntry is returned

Definition at line 1523 of file global-router-interface.cc.

References m_injectedRoutes, NS_ASSERT, and NS_LOG_FUNCTION.

bool ns3::GlobalRouter::GetLSA ( uint32_t  n,
GlobalRoutingLSA lsa 
) const

Get a Global Routing 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 Global Routing Link State Advertisement into the requested GlobalRoutingLSA object.

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 also
GlobalRoutingLSA
GlobalRouting::GetNumLSAs ()
Parameters
nThe index number of the LSA you want to read.
lsaThe GlobalRoutingLSA class to receive the LSA information.
Returns
The number of Global Router Link State Advertisements.

Definition at line 1483 of file global-router-interface.cc.

References ns3::GlobalRoutingLSA::IsEmpty(), m_LSAs, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

uint32_t ns3::GlobalRouter::GetNInjectedRoutes ( void  )

Get the number of injected routes that have been added to the routing table.

Returns
number of injected routes

Definition at line 1546 of file global-router-interface.cc.

References m_injectedRoutes, and NS_LOG_FUNCTION.

uint32_t ns3::GlobalRouter::GetNumLSAs ( void  ) const

Get the Number of Global Routing 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 also
GlobalRouterLSA
GlobalRouting::DiscoverLSAs ()
GlobalRouting::GetLSA ()
Returns
The number of Global Routing Link State Advertisements.

Definition at line 1473 of file global-router-interface.cc.

References m_LSAs, and NS_LOG_FUNCTION.

Ipv4Address ns3::GlobalRouter::GetRouterId ( void  ) const

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 also
RoutingEnvironment::AllocateRouterId ()
Returns
The Router ID associated with the Global Router.

Definition at line 578 of file global-router-interface.cc.

References m_routerId, and NS_LOG_FUNCTION.

Ptr< Ipv4GlobalRouting > ns3::GlobalRouter::GetRoutingProtocol ( void  )

Get the specific Global Routing Protocol used.

Returns
the routing protocol

Definition at line 537 of file global-router-interface.cc.

References m_routingProtocol, and NS_LOG_FUNCTION.

TypeId ns3::GlobalRouter::GetTypeId ( void  )
static

Get the type ID.

Returns
the object TypeId

Definition at line 510 of file global-router-interface.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

void ns3::GlobalRouter::InjectRoute ( Ipv4Address  network,
Ipv4Mask  networkMask 
)

Inject a route to be circulated to other routers as an external route.

Parameters
networkThe Network to inject
networkMaskThe Network Mask to inject

Definition at line 1509 of file global-router-interface.cc.

References ns3::Ipv4RoutingTableEntry::CreateNetworkRouteTo(), m_injectedRoutes, and NS_LOG_FUNCTION.

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ptr< BridgeNetDevice > ns3::GlobalRouter::NetDeviceIsBridged ( Ptr< NetDevice nd) const
private

Decide whether or not a given net device is being bridged by a BridgeNetDevice.

Parameters
ndthe NetDevice
Returns
the BridgeNetDevice smart pointer or null if not found

Definition at line 1662 of file global-router-interface.cc.

References ns3::Node::GetDevice(), ns3::Node::GetNDevices(), NS_ABORT_MSG_UNLESS, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by AnotherRouterOnLink(), DiscoverLSAs(), and FindDesignatedRouterForLink().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GlobalRouter& ns3::GlobalRouter::operator= ( GlobalRouter sr)
private

Global Router assignment operator is disallowed.

void ns3::GlobalRouter::ProcessBroadcastLink ( Ptr< NetDevice nd,
GlobalRoutingLSA pLSA,
NetDeviceContainer c 
)
private

Process a generic broadcast link.

Parameters
ndthe NetDevice
pLSAthe Global LSA
cthe returned NetDevice container

Definition at line 739 of file global-router-interface.cc.

References NS_LOG_FUNCTION, ProcessBridgedBroadcastLink(), and ProcessSingleBroadcastLink().

Referenced by DiscoverLSAs().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::GlobalRouter::RemoveInjectedRoute ( uint32_t  i)

Withdraw a route from the global unicast routing table.

Calling this function will cause all indexed routes numbered above index i to have their index decremented. For instance, it is possible to remove N injected routes by calling RemoveInjectedRoute (0) N times.

Parameters
iThe index (into the injected routing list) of the route to remove.
See also
GlobalRouter::WithdrawRoute ()

Definition at line 1553 of file global-router-interface.cc.

References m_injectedRoutes, NS_ASSERT, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

void ns3::GlobalRouter::SetRoutingProtocol ( Ptr< Ipv4GlobalRouting routing)

Set the specific Global Routing Protocol to be used.

Parameters
routingthe routing protocol

Definition at line 531 of file global-router-interface.cc.

References m_routingProtocol, and NS_LOG_FUNCTION.

bool ns3::GlobalRouter::WithdrawRoute ( Ipv4Address  network,
Ipv4Mask  networkMask 
)

Withdraw a route from the global unicast routing table.

Parameters
networkThe Network to withdraw
networkMaskThe Network Mask to withdraw
Returns
whether the operation succeeded (will return false if no such route)
See also
GlobalRouter::RemoveInjectedRoute ()

Definition at line 1572 of file global-router-interface.cc.

References m_injectedRoutes, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Member Data Documentation

InjectedRoutes ns3::GlobalRouter::m_injectedRoutes
private
ListOfLSAs_t ns3::GlobalRouter::m_LSAs
private

database of GlobalRoutingLSAs

Definition at line 840 of file global-router-interface.h.

Referenced by BuildNetworkLSAs(), ClearLSAs(), DiscoverLSAs(), GetLSA(), and GetNumLSAs().

Ipv4Address ns3::GlobalRouter::m_routerId
private

router ID (its IPv4 address)

Definition at line 842 of file global-router-interface.h.

Referenced by BuildNetworkLSAs(), DiscoverLSAs(), GetRouterId(), and GlobalRouter().

Ptr<Ipv4GlobalRouting> ns3::GlobalRouter::m_routingProtocol
private

the Ipv4GlobalRouting in use

Definition at line 843 of file global-router-interface.h.

Referenced by DoDispose(), GetRoutingProtocol(), and SetRoutingProtocol().


The documentation for this class was generated from the following files: