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

Vertex used in shortest path first (SPF) computations. See RFC 2328, Section 16. More...

#include <global-route-manager-impl.h>

Public Types

typedef std::pair< Ipv4Address,
int32_t > 
NodeExit_t
 
enum  VertexType { VertexUnknown = 0, VertexRouter, VertexNetwork }
 Enumeration of the possible types of SPFVertex objects. More...
 

Public Member Functions

 SPFVertex ()
 Construct an empty ("uninitialized") SPFVertex (Shortest Path First Vertex). More...
 
 SPFVertex (GlobalRoutingLSA *lsa)
 Construct an initialized SPFVertex (Shortest Path First Vertex). More...
 
 ~SPFVertex ()
 Destroy an SPFVertex (Shortest Path First Vertex). More...
 
uint32_t AddChild (SPFVertex *child)
 Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex. More...
 
void ClearVertexProcessed (void)
 
SPFVertexGetChild (uint32_t n) const
 Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex. More...
 
uint32_t GetDistanceFromRoot (void) const
 Get the distance from the root vertex to "this" SPFVertex object. More...
 
GlobalRoutingLSAGetLSA (void) const
 Get the Global Router Link State Advertisement returned by the Global Router represented by this SPFVertex during the route discovery process. More...
 
uint32_t GetNChildren (void) const
 Get the number of children of "this" SPFVertex. More...
 
uint32_t GetNRootExitDirections () const
 Get the number of exit directions from root for reaching 'this' vertex. More...
 
SPFVertexGetParent (uint32_t i=0) const
 Get a pointer to the SPFVector that is the parent of "this" SPFVertex. More...
 
NodeExit_t GetRootExitDirection (uint32_t i) const
 Obtain a pair indicating the exit direction from the root. More...
 
NodeExit_t GetRootExitDirection () const
 Obtain a pair indicating the exit direction from the root. More...
 
Ipv4Address GetVertexId (void) const
 Get the Vertex ID field of a SPFVertex object. More...
 
VertexType GetVertexType (void) const
 Get the Vertex Type field of a SPFVertex object. More...
 
void InheritAllRootExitDirections (const SPFVertex *vertex)
 Inherit all root exit directions from a given vertex to 'this' vertex. More...
 
bool IsVertexProcessed (void) const
 Check the value of the VertexProcessed flag. More...
 
void MergeParent (const SPFVertex *v)
 Merge the Parent list from the v into this vertex. More...
 
void MergeRootExitDirections (const SPFVertex *vertex)
 Merge into 'this' vertex the list of exit directions from another vertex. More...
 
void SetDistanceFromRoot (uint32_t distance)
 Set the distance from the root vertex to "this" SPFVertex object. More...
 
void SetLSA (GlobalRoutingLSA *lsa)
 Set the Global Router Link State Advertisement returned by the Global Router represented by this SPFVertex during the route discovery process. More...
 
void SetParent (SPFVertex *parent)
 Set the pointer to the SPFVector that is the parent of "this" SPFVertex. More...
 
void SetRootExitDirection (Ipv4Address nextHop, int32_t id=SPF_INFINITY)
 Set the IP address and outgoing interface index that should be used to begin forwarding packets from the root SPFVertex to "this" SPFVertex. More...
 
void SetRootExitDirection (SPFVertex::NodeExit_t exit)
 Set the IP address and outgoing interface index that should be used to begin forwarding packets from the root SPFVertex to "this" SPFVertex. More...
 
void SetVertexId (Ipv4Address id)
 Set the Vertex ID field of a SPFVertex object. More...
 
void SetVertexProcessed (bool value)
 Set the value of the VertexProcessed flag. More...
 
void SetVertexType (VertexType type)
 Set the Vertex Type field of a SPFVertex object. More...
 

Private Types

typedef std::list< NodeExit_t > ListOfNodeExit_t
 
typedef std::list< SPFVertex * > ListOfSPFVertex_t
 

Private Member Functions

 SPFVertex (SPFVertex &v)
 The SPFVertex copy construction is disallowed. There's no need for it and a compiler provided shallow copy would be wrong.
 
SPFVertexoperator= (SPFVertex &v)
 The SPFVertex copy assignment operator is disallowed. There's no need for it and a compiler provided shallow copy would be wrong.
 

Private Attributes

ListOfSPFVertex_t m_children
 
uint32_t m_distanceFromRoot
 
ListOfNodeExit_t m_ecmpRootExits
 store the multiple root's exits for supporting ECMP
 
GlobalRoutingLSAm_lsa
 
Ipv4Address m_nextHop
 
ListOfSPFVertex_t m_parents
 
int32_t m_rootOif
 
Ipv4Address m_vertexId
 
bool m_vertexProcessed
 
VertexType m_vertexType
 

Friends

std::ostream & operator<< (std::ostream &os, const SPFVertex::ListOfSPFVertex_t &vs)
 

Detailed Description

Vertex used in shortest path first (SPF) computations. See RFC 2328, Section 16.

Each router in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes. Each of these routers in the calculation has an associated SPFVertex.

The "Root" vertex is the SPFVertex representing the router that is having its routing tables set. The SPFVertex objects representing other routers 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 Global Router Link State Advertisement (LSA) that its underlying router has exported. Within these LSAs are 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 records that connect them provide the information required to construct the required routes.

Definition at line 66 of file global-route-manager-impl.h.

Member Enumeration Documentation

Enumeration of the possible types of SPFVertex objects.

Currently we use VertexRouter to identify objects that represent a router in the simulation topology, and VertexNetwork to identify objects that represent a network.

Enumerator
VertexUnknown 

Uninitialized Link Record

VertexRouter 

Vertex representing a router in the topology

VertexNetwork 

Vertex representing a network in the topology

Definition at line 77 of file global-route-manager-impl.h.

Constructor & Destructor Documentation

ns3::SPFVertex::SPFVertex ( )

Construct an empty ("uninitialized") SPFVertex (Shortest Path First Vertex).

The Vertex Type is set to VertexUnknown, the Vertex ID is set to 255.255.255.255, and the distance from root is set to infinity (UINT32_MAX). The referenced Link State Advertisement (LSA) is set to null as is the parent SPFVertex. The outgoing interface index is set to infinity, the next hop address is set to 0.0.0.0 and the list of children of the SPFVertex is initialized to empty.

See Also
VertexType

Definition at line 81 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

ns3::SPFVertex::SPFVertex ( GlobalRoutingLSA lsa)

Construct an initialized SPFVertex (Shortest Path First Vertex).

The Vertex Type is initialized to VertexRouter and the Vertex ID is found from the Link State ID of the Link State Advertisement (LSA) passed as a parameter. The Link State ID is set to the Router ID of the advertising router. The referenced LSA (m_lsa) is set to the given LSA. Other than these members, initialization is as in the default constructor. of the SPFVertex is initialized to empty.

See Also
SPFVertex::SPFVertex ()
VertexType
GlobalRoutingLSA
Parameters
lsaThe Link State Advertisement used for finding initial values.

Definition at line 95 of file global-route-manager-impl.cc.

References ns3::GlobalRoutingLSA::GetLSType(), NS_LOG_FUNCTION, NS_LOG_LOGIC, VertexNetwork, and VertexRouter.

ns3::SPFVertex::~SPFVertex ( )

Destroy an SPFVertex (Shortest Path First Vertex).

The children vertices of the SPFVertex are recursively deleted.

See Also
SPFVertex::SPFVertex ()

Definition at line 119 of file global-route-manager-impl.cc.

References GetVertexId(), m_ecmpRootExits, NS_ASSERT_MSG, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Member Function Documentation

uint32_t ns3::SPFVertex::AddChild ( SPFVertex child)

Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set and is the root of the SPF tree. Each vertex in the SPF tree can have a number of children that represent host or network routes available via that vertex.

This method the number of children of "this" SPFVertex (which reside in the SPF tree.

See Also
SPFVertex::GetNChildren
Warning
Ownership of the pointer added to the children of "this" SPFVertex is transferred to the "this" SPFVertex. You must not delete the (now) child SPFVertex after calling this method.
Parameters
childA pointer to the SPFVertex (which resides in the SPF tree) to be added to the list of children of "this" SPFVertex.
Returns
The number of children of "this" SPFVertex after the addition of the new child.

Definition at line 378 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

SPFVertex * ns3::SPFVertex::GetChild ( uint32_t  n) const

Get a borrowed SPFVertex pointer to the specified child of "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set and is the root of the SPF tree. Each vertex in the SPF tree can have a number of children that represent host or network routes available via that vertex.

This method the number of children of "this" SPFVertex (which reside in the SPF tree.

See Also
SPFVertex::GetNChildren
Parameters
nThe index (from 0 to the number of children minus 1) of the child SPFVertex to return.
Warning
The pointer returned by GetChild () is a borrowed pointer. You do not have any ownership of the underlying object and must not delete that object.
Returns
A pointer to the specified child SPFVertex (which resides in the SPF tree).

Definition at line 359 of file global-route-manager-impl.cc.

References NS_ASSERT_MSG, and NS_LOG_FUNCTION.

uint32_t ns3::SPFVertex::GetDistanceFromRoot ( void  ) const

Get the distance from the root vertex to "this" SPFVertex object.

Each router in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes. Each of these routers in the calculation has an associated SPFVertex.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set. The "this" SPFVertex is the vertex to which a route is being calculated from the root. The distance from the root that we're asking for is the number of hops from the root vertex to the vertex in question.

The distance is calculated during route discovery and is stored in a member variable. This method simply fetches that value.

Returns
The distance, in hops, from the root SPFVertex to "this" SPFVertex.

Definition at line 220 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::CandidateQueue::CompareSPFVertex().

GlobalRoutingLSA * ns3::SPFVertex::GetLSA ( void  ) const

Get the Global Router Link State Advertisement returned by the Global Router represented by this SPFVertex during the route discovery process.

See Also
GlobalRouter
GlobalRoutingLSA
GlobalRouter::DiscoverLSAs ()
Returns
A pointer to the GlobalRoutingLSA found by the router represented by this SPFVertex object.

Definition at line 206 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

uint32_t ns3::SPFVertex::GetNChildren ( void  ) const

Get the number of children of "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set and is the root of the SPF tree. Each vertex in the SPF tree can have a number of children that represent host or network routes available via that vertex.

This method returns the number of children of "this" SPFVertex (which reside in the SPF tree).

Returns
The number of children of "this" SPFVertex (which reside in the SPF tree).

Definition at line 352 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

uint32_t ns3::SPFVertex::GetNRootExitDirections ( ) const

Get the number of exit directions from root for reaching 'this' vertex.

Returns
The number of exit directions from root

Definition at line 345 of file global-route-manager-impl.cc.

References m_ecmpRootExits, and NS_LOG_FUNCTION.

SPFVertex * ns3::SPFVertex::GetParent ( uint32_t  i = 0) const

Get a pointer to the SPFVector that is the parent of "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set and is the root of the SPF tree.

This method returns a pointer to the parent node of "this" SPFVertex (both of which reside in that SPF tree).

Parameters
iThe index to one of the parents
Returns
A pointer to the SPFVertex that is the parent of "this" SPFVertex in the SPF tree.

Definition at line 237 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION, and NS_LOG_LOGIC.

SPFVertex::NodeExit_t ns3::SPFVertex::GetRootExitDirection ( uint32_t  i) const

Obtain a pair indicating the exit direction from the root.

Parameters
iAn index to a pair
Returns
A pair of next-hop-IP and outgoing-interface-index for indicating an exit direction from the root. It is 0 if the index 'i' is out-of-range

Definition at line 292 of file global-route-manager-impl.cc.

References m_ecmpRootExits, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

SPFVertex::NodeExit_t ns3::SPFVertex::GetRootExitDirection ( ) const

Obtain a pair indicating the exit direction from the root.

This method assumes there is only a single exit direction from the root. Error occur if this assumption is invalid.

Returns
The pair of next-hop-IP and outgoing-interface-index for reaching 'this' vertex from the root

Definition at line 305 of file global-route-manager-impl.cc.

References m_ecmpRootExits, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Ipv4Address ns3::SPFVertex::GetVertexId ( void  ) const

Get the Vertex ID field of a SPFVertex object.

The Vertex ID uniquely identifies the simulation object a given SPFVertex represents. Typically, this is the Router ID for SPFVertex objects 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 increasing as new routers are instantiated.

Returns
The Ipv4Address Vertex ID of the current SPFVertex object.

Definition at line 192 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::CandidateQueue::Find(), and ~SPFVertex().

SPFVertex::VertexType ns3::SPFVertex::GetVertexType ( void  ) const

Get the Vertex Type field of a SPFVertex object.

The Vertex Type describes the kind of simulation object a given SPFVertex represents.

See Also
VertexType
Returns
The VertexType of the current SPFVertex object.

Definition at line 178 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::CandidateQueue::CompareSPFVertex().

void ns3::SPFVertex::InheritAllRootExitDirections ( const SPFVertex vertex)

Inherit all root exit directions from a given vertex to 'this' vertex.

Parameters
vertexThe vertex from which all root exit directions are to be inherited

After the call of this method, the original root exit directions in 'this' vertex are all lost.

Definition at line 329 of file global-route-manager-impl.cc.

References m_ecmpRootExits, NS_LOG_FUNCTION, and NS_LOG_WARN.

bool ns3::SPFVertex::IsVertexProcessed ( void  ) const

Check the value of the VertexProcessed flag.

Flag to note whether vertex has been processed in stage two of SPF computation

Returns
value of underlying flag

Definition at line 393 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

void ns3::SPFVertex::MergeParent ( const SPFVertex v)

Merge the Parent list from the v into this vertex.

Parameters
vThe vertex from which its list of Parent is read and then merged into the list of Parent of this vertex. Note that the list in v remains intact

Definition at line 256 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION, and NS_LOG_LOGIC.

void ns3::SPFVertex::MergeRootExitDirections ( const SPFVertex vertex)

Merge into 'this' vertex the list of exit directions from another vertex.

This merge is necessary when ECMP are found.

Parameters
vertexFrom which the list of exit directions are obtain and are merged into 'this' vertex

Definition at line 314 of file global-route-manager-impl.cc.

References m_ecmpRootExits, and NS_LOG_FUNCTION.

void ns3::SPFVertex::SetDistanceFromRoot ( uint32_t  distance)

Set the distance from the root vertex to "this" SPFVertex object.

Each router in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes. Each of these routers in the calculation has an associated SPFVertex.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set. The "this" SPFVertex is the vertex to which a route is being calculated from the root. The distance from the root that we're asking for is the number of hops from the root vertex to the vertex in question.

Parameters
distanceThe distance, in hops, from the root SPFVertex to "this" SPFVertex.

Definition at line 213 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

Referenced by GlobalRouteManagerImplTestCase::DoRun().

void ns3::SPFVertex::SetLSA ( GlobalRoutingLSA lsa)

Set the Global Router Link State Advertisement returned by the Global Router represented by this SPFVertex during the route discovery process.

See Also
SPFVertex::GetLSA ()
GlobalRouter
GlobalRoutingLSA
GlobalRouter::DiscoverLSAs ()
Warning
Ownership of the LSA is transferred to the "this" SPFVertex. You must not delete the LSA after calling this method.
Parameters
lsaA pointer to the GlobalRoutingLSA.

Definition at line 199 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

void ns3::SPFVertex::SetParent ( SPFVertex parent)

Set the pointer to the SPFVector that is the parent of "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set and is the root of the SPF tree.

This method sets the parent pointer of "this" SPFVertex (both of which reside in that SPF tree).

Parameters
parentA pointer to the SPFVertex that is the parent of "this" SPFVertex* in the SPF tree.

Definition at line 227 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

void ns3::SPFVertex::SetRootExitDirection ( Ipv4Address  nextHop,
int32_t  id = SPF_INFINITY 
)

Set the IP address and outgoing interface index that should be used to begin forwarding packets from the root SPFVertex to "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set. The "this" SPFVertex is the vertex that represents the host or network to which a route is being calculated from the root. The IP address that we're asking for is the address on the remote side of a link off of the root node that should be used as the 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 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 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 an interface. This means that the first hop address and interface ID must be the same for all downstream SPFVertices. We call this "inheriting" the interface and next hop.

In this method we are telling the root node which exit direction it should send should I send a packet to the network or host represented by 'this' SPFVertex.

See Also
GlobalRouter
GlobalRoutingLSA
GlobalRoutingLinkRecord
Parameters
nextHopThe IP address to use when forwarding packets to the host or network represented by "this" SPFVertex.
idThe interface index to use when forwarding packets to the host or network represented by "this" SPFVertex.

Definition at line 271 of file global-route-manager-impl.cc.

References m_ecmpRootExits, and NS_LOG_FUNCTION.

Referenced by SetRootExitDirection().

void ns3::SPFVertex::SetRootExitDirection ( SPFVertex::NodeExit_t  exit)

Set the IP address and outgoing interface index that should be used to begin forwarding packets from the root SPFVertex to "this" SPFVertex.

Each router node in the simulation is associated with an SPFVertex object. When calculating routes, each of these routers is, in turn, chosen as the "root" of the calculation and routes to all of the other routers are eventually saved in the routing tables of each of the chosen nodes.

The "Root" vertex is then the SPFVertex representing the router that is having its routing tables set. The "this" SPFVertex is the vertex that represents the host or network to which a route is being calculated from the root. The IP address that we're asking for is the address on the remote side of a link off of the root node that should be used as the 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 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 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 an interface. This means that the first hop address and interface ID must be the same for all downstream SPFVertices. We call this "inheriting" the interface and next hop.

In this method we are telling the root node which exit direction it should send should I send a packet to the network or host represented by 'this' SPFVertex.

See Also
GlobalRouter
GlobalRoutingLSA
GlobalRoutingLinkRecord
Parameters
exitThe pair of next-hop-IP and outgoing-interface-index to use when forwarding packets to the host or network represented by "this" SPFVertex.

Definition at line 285 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION, and SetRootExitDirection().

void ns3::SPFVertex::SetVertexId ( Ipv4Address  id)

Set the Vertex ID field of a SPFVertex object.

The Vertex ID uniquely identifies the simulation object a given SPFVertex represents. Typically, this is the Router ID for SPFVertex objects 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 instantiated. This method is an explicit override of the automatically generated value.

Parameters
idThe new Ipv4Address Vertex ID for the current SPFVertex object.

Definition at line 185 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

void ns3::SPFVertex::SetVertexProcessed ( bool  value)

Set the value of the VertexProcessed flag.

Flag to note whether vertex has been processed in stage two of SPF computation

Parameters
valueboolean value to set the flag

Definition at line 386 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.

void ns3::SPFVertex::SetVertexType ( SPFVertex::VertexType  type)

Set the Vertex Type field of a SPFVertex object.

The Vertex Type describes the kind of simulation object a given SPFVertex represents.

See Also
VertexType
Parameters
typeThe new VertexType for the current SPFVertex object.

Definition at line 171 of file global-route-manager-impl.cc.

References NS_LOG_FUNCTION.


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