a Link State Advertisement (LSA) for a router, used in global routing. More...
#include "global-router-interface.h"
Public Types | |
enum | LSType { Unknown = 0 , RouterLSA , NetworkLSA , SummaryLSA , SummaryLSA_ASBR , ASExternalLSAs } |
corresponds to LS type field of RFC 2328 OSPF LSA header More... | |
enum | SPFStatus { LSA_SPF_NOT_EXPLORED = 0 , LSA_SPF_CANDIDATE , LSA_SPF_IN_SPFTREE } |
Enumeration of the possible values of the status flag in the Routing Link State Advertisements. More... | |
Public Member Functions | |
GlobalRoutingLSA () | |
Create a blank Global Routing Link State Advertisement. | |
GlobalRoutingLSA (GlobalRoutingLSA &lsa) | |
Copy constructor for a Global Routing Link State Advertisement. | |
GlobalRoutingLSA (SPFStatus status, Ipv4Address linkStateId, Ipv4Address advertisingRtr) | |
Create an initialized Global Routing Link State Advertisement. | |
~GlobalRoutingLSA () | |
Destroy an existing Global Routing Link State Advertisement. | |
uint32_t | AddAttachedRouter (Ipv4Address addr) |
Add an attached router to the list in the NetworkLSA. | |
uint32_t | AddLinkRecord (GlobalRoutingLinkRecord *lr) |
Add a given Global Routing Link Record to the LSA. | |
void | ClearLinkRecords () |
Release all of the Global Routing Link Records present in the Global Routing Link State Advertisement and make the list of link records empty. | |
void | CopyLinkRecords (const GlobalRoutingLSA &lsa) |
Copy any Global Routing Link Records in a given Global Routing Link State Advertisement to the current LSA. | |
Ipv4Address | GetAdvertisingRouter () const |
Get the Advertising Router as defined by the OSPF spec. | |
Ipv4Address | GetAttachedRouter (uint32_t n) const |
Return an Ipv4Address corresponding to the specified attached router. | |
GlobalRoutingLinkRecord * | GetLinkRecord (uint32_t n) const |
Return a pointer to the specified Global Routing Link Record. | |
Ipv4Address | GetLinkStateId () const |
Get the Link State ID as defined by the OSPF spec. | |
LSType | GetLSType () const |
Return the LSType field of the LSA. | |
uint32_t | GetNAttachedRouters () const |
Return the number of attached routers listed in the NetworkLSA. | |
Ipv4Mask | GetNetworkLSANetworkMask () const |
For a Network LSA, get the Network Mask field that precedes the list of attached routers. | |
uint32_t | GetNLinkRecords () const |
Return the number of Global Routing Link Records in the LSA. | |
Ptr< Node > | GetNode () const |
Get the Node pointer of the node that originated this LSA. | |
SPFStatus | GetStatus () const |
Get the SPF status of the advertisement. | |
bool | IsEmpty () const |
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Advertisement is empty. | |
GlobalRoutingLSA & | operator= (const GlobalRoutingLSA &lsa) |
Assignment operator for a Global Routing Link State Advertisement. | |
void | Print (std::ostream &os) const |
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records present in the list. | |
void | SetAdvertisingRouter (Ipv4Address rtr) |
Set the Advertising Router as defined by the OSPF spec. | |
void | SetLinkStateId (Ipv4Address addr) |
Set the Link State ID is defined by the OSPF spec. | |
void | SetLSType (LSType typ) |
Set the LS type field of the LSA. | |
void | SetNetworkLSANetworkMask (Ipv4Mask mask) |
For a Network LSA, set the Network Mask field that precedes the list of attached routers. | |
void | SetNode (Ptr< Node > node) |
Set the Node pointer of the node that originated this LSA. | |
void | SetStatus (SPFStatus status) |
Set the SPF status of the advertisement. | |
Private Types | |
typedef std::list< Ipv4Address > | ListOfAttachedRouters_t |
A convenience typedef to avoid too much writers cramp. | |
typedef std::list< GlobalRoutingLinkRecord * > | ListOfLinkRecords_t |
A convenience typedef to avoid too much writers cramp. | |
Private Attributes | |
Ipv4Address | m_advertisingRtr |
The Advertising Router is defined by the OSPF spec. | |
ListOfAttachedRouters_t | m_attachedRouters |
Each Network LSA contains a list of attached routers. | |
ListOfLinkRecords_t | m_linkRecords |
Each Link State Advertisement contains a number of Link Records that describe the kinds of links that are attached to a given node. | |
Ipv4Address | m_linkStateId |
The Link State ID is defined by the OSPF spec. | |
LSType | m_lsType |
The type of the LSA. | |
Ipv4Mask | m_networkLSANetworkMask |
Each Network LSA contains the network mask of the attached network. | |
uint32_t | m_node_id |
node ID | |
SPFStatus | m_status |
This is a tristate flag used internally in the SPF computation to mark if an SPFVertex (a data structure representing a vertex in the SPF tree – a router) is new, is a candidate for a shortest path, or is in its proper position in the tree. | |
a Link State Advertisement (LSA) for a router, used in global routing.
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.
Definition at line 245 of file global-router-interface.h.
|
private |
A convenience typedef to avoid too much writers cramp.
Definition at line 544 of file global-router-interface.h.
|
private |
A convenience typedef to avoid too much writers cramp.
Definition at line 522 of file global-router-interface.h.
corresponds to LS type field of RFC 2328 OSPF LSA header
Enumerator | |
---|---|
Unknown | Uninitialized Type. |
RouterLSA | |
NetworkLSA | |
SummaryLSA | |
SummaryLSA_ASBR | |
ASExternalLSAs |
Definition at line 252 of file global-router-interface.h.
Enumeration of the possible values of the status flag in the Routing Link State Advertisements.
Enumerator | |
---|---|
LSA_SPF_NOT_EXPLORED | New vertex not yet considered. |
LSA_SPF_CANDIDATE | Vertex is in the SPF candidate queue. |
LSA_SPF_IN_SPFTREE | Vertex is in the SPF tree. |
Definition at line 267 of file global-router-interface.h.
ns3::GlobalRoutingLSA::GlobalRoutingLSA | ( | ) |
Create a blank Global Routing Link State Advertisement.
On completion Ipv4Address variables initialized to 0.0.0.0 and the list of Link State Records is empty.
Definition at line 125 of file global-router-interface.cc.
References NS_LOG_FUNCTION.
ns3::GlobalRoutingLSA::GlobalRoutingLSA | ( | GlobalRoutingLSA::SPFStatus | status, |
Ipv4Address | linkStateId, | ||
Ipv4Address | advertisingRtr ) |
Create an initialized Global Routing Link State Advertisement.
On completion the list of Link State Records is empty.
status | The status to of the new LSA. |
linkStateId | The Ipv4Address for the link state ID field. |
advertisingRtr | The Ipv4Address for the advertising router field. |
Definition at line 138 of file global-router-interface.cc.
References NS_LOG_FUNCTION.
ns3::GlobalRoutingLSA::GlobalRoutingLSA | ( | GlobalRoutingLSA & | lsa | ) |
Copy constructor for a Global Routing Link State Advertisement.
Takes a piece of memory and constructs a semantically identical copy of the given LSA.
lsa | The existing LSA to be used as the source. |
Definition at line 153 of file global-router-interface.cc.
References CopyLinkRecords(), IsEmpty(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.
ns3::GlobalRoutingLSA::~GlobalRoutingLSA | ( | ) |
Destroy an existing Global Routing Link State Advertisement.
Any Global Routing Link Records present in the list are freed.
Definition at line 202 of file global-router-interface.cc.
References ClearLinkRecords(), and NS_LOG_FUNCTION.
uint32_t ns3::GlobalRoutingLSA::AddAttachedRouter | ( | Ipv4Address | addr | ) |
Add an attached router to the list in the NetworkLSA.
addr | The Ipv4Address of the interface on the network link |
Definition at line 328 of file global-router-interface.cc.
References m_attachedRouters, and NS_LOG_FUNCTION.
uint32_t ns3::GlobalRoutingLSA::AddLinkRecord | ( | GlobalRoutingLinkRecord * | lr | ) |
Add a given Global Routing Link Record to the LSA.
lr | The Global Routing Link Record to be added. |
Definition at line 227 of file global-router-interface.cc.
References m_linkRecords, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouter::ProcessBridgedBroadcastLink(), ns3::GlobalRouter::ProcessPointToPointLink(), and ns3::GlobalRouter::ProcessSingleBroadcastLink().
void ns3::GlobalRoutingLSA::ClearLinkRecords | ( | ) |
Release all of the Global Routing Link Records present in the Global Routing Link State Advertisement and make the list of link records empty.
Definition at line 209 of file global-router-interface.cc.
References m_linkRecords, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ~GlobalRoutingLSA(), and operator=().
void ns3::GlobalRoutingLSA::CopyLinkRecords | ( | const GlobalRoutingLSA & | lsa | ) |
Copy any Global Routing Link Records in a given Global Routing Link State Advertisement to the current LSA.
Existing Link Records are not deleted – this is a concatenation of Link Records.
lsa | The LSA to copy the Link Records from. |
Definition at line 182 of file global-router-interface.cc.
References ns3::GlobalRoutingLinkRecord::GetLinkData(), ns3::GlobalRoutingLinkRecord::GetLinkId(), ns3::GlobalRoutingLinkRecord::GetLinkType(), ns3::GlobalRoutingLinkRecord::GetMetric(), m_attachedRouters, m_linkRecords, NS_LOG_FUNCTION, and ns3::GlobalRoutingLinkRecord::SetLinkType().
Referenced by GlobalRoutingLSA(), and operator=().
Ipv4Address ns3::GlobalRoutingLSA::GetAdvertisingRouter | ( | ) | const |
Get the Advertising Router as defined by the OSPF spec.
We always set it to the router ID of the router making the advertisement.
Definition at line 293 of file global-router-interface.cc.
References m_advertisingRtr, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::ProcessASExternals(), and ns3::GlobalRouteManagerImpl::SPFAddASExternal().
Ipv4Address ns3::GlobalRoutingLSA::GetAttachedRouter | ( | uint32_t | n | ) | const |
Return an Ipv4Address corresponding to the specified attached router.
n | The attached router number desired (number in the list). |
Definition at line 343 of file global-router-interface.cc.
References m_attachedRouters, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::SPFNext().
GlobalRoutingLinkRecord * ns3::GlobalRoutingLSA::GetLinkRecord | ( | uint32_t | n | ) | const |
Return a pointer to the specified Global Routing Link Record.
n | The LSA number desired. |
Definition at line 242 of file global-router-interface.cc.
References m_linkRecords, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::CheckForStubNode(), ns3::GlobalRouteManagerLSDB::GetLSAByLinkData(), ns3::GlobalRouteManagerImpl::SPFGetNextLink(), ns3::GlobalRouteManagerImpl::SPFIntraAddRouter(), ns3::GlobalRouteManagerImpl::SPFNext(), and ns3::GlobalRouteManagerImpl::SPFProcessStubs().
Ipv4Address ns3::GlobalRoutingLSA::GetLinkStateId | ( | ) | const |
Get the Link State ID as defined by the OSPF spec.
We always set it to the router ID of the router making the advertisement.
Definition at line 279 of file global-router-interface.cc.
References m_linkStateId, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::CheckForStubNode(), ns3::GlobalRouteManagerImpl::ProcessASExternals(), ns3::GlobalRouteManagerImpl::SPFAddASExternal(), ns3::GlobalRouteManagerImpl::SPFCalculate(), ns3::GlobalRouteManagerImpl::SPFIntraAddRouter(), ns3::GlobalRouteManagerImpl::SPFIntraAddTransit(), ns3::GlobalRouteManagerImpl::SPFNext(), ns3::GlobalRouteManagerImpl::SPFNexthopCalculation(), and ns3::GlobalRouteManagerImpl::SPFProcessStubs().
GlobalRoutingLSA::LSType ns3::GlobalRoutingLSA::GetLSType | ( | ) | const |
Return the LSType field of the LSA.
Definition at line 265 of file global-router-interface.cc.
References m_lsType, and NS_LOG_FUNCTION.
Referenced by ns3::SPFVertex::SPFVertex(), ns3::GlobalRouteManagerLSDB::Insert(), ns3::GlobalRouteManagerImpl::SPFNext(), and ns3::GlobalRouteManagerImpl::SPFNexthopCalculation().
uint32_t ns3::GlobalRoutingLSA::GetNAttachedRouters | ( | ) | const |
Return the number of attached routers listed in the NetworkLSA.
Definition at line 336 of file global-router-interface.cc.
References m_attachedRouters, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::SPFNext().
Ipv4Mask ns3::GlobalRoutingLSA::GetNetworkLSANetworkMask | ( | ) | const |
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
Definition at line 314 of file global-router-interface.cc.
References m_networkLSANetworkMask, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::SPFAddASExternal(), ns3::GlobalRouteManagerImpl::SPFIntraAddTransit(), and ns3::GlobalRouteManagerImpl::SPFNexthopCalculation().
uint32_t ns3::GlobalRoutingLSA::GetNLinkRecords | ( | ) | const |
Return the number of Global Routing Link Records in the LSA.
Definition at line 235 of file global-router-interface.cc.
References m_linkRecords, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::CheckForStubNode(), ns3::GlobalRouteManagerLSDB::GetLSAByLinkData(), ns3::GlobalRouteManagerImpl::SPFIntraAddRouter(), ns3::GlobalRouteManagerImpl::SPFNext(), and ns3::GlobalRouteManagerImpl::SPFProcessStubs().
Get the Node pointer of the node that originated this LSA.
Definition at line 366 of file global-router-interface.cc.
References ns3::NodeList::GetNode(), m_node_id, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::CheckForStubNode().
GlobalRoutingLSA::SPFStatus ns3::GlobalRoutingLSA::GetStatus | ( | ) | const |
Get the SPF status of the advertisement.
Definition at line 321 of file global-router-interface.cc.
References m_status, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::SPFNext().
bool ns3::GlobalRoutingLSA::IsEmpty | ( | ) | const |
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Advertisement is empty.
Definition at line 258 of file global-router-interface.cc.
References m_linkRecords, and NS_LOG_FUNCTION.
Referenced by GlobalRoutingLSA(), and ns3::GlobalRouter::GetLSA().
GlobalRoutingLSA & ns3::GlobalRoutingLSA::operator= | ( | const GlobalRoutingLSA & | lsa | ) |
Assignment operator for a Global Routing Link State Advertisement.
Takes an existing Global Routing Link State Advertisement and overwrites it to make a semantically identical copy of a given prototype LSA.
If there are any Global Routing Link Records present in the existing LSA, they are freed before the assignment happens.
lsa | The existing LSA to be used as the source. |
Definition at line 167 of file global-router-interface.cc.
References ClearLinkRecords(), CopyLinkRecords(), m_advertisingRtr, m_linkStateId, m_lsType, m_networkLSANetworkMask, m_node_id, m_status, and NS_LOG_FUNCTION.
void ns3::GlobalRoutingLSA::Print | ( | std::ostream & | os | ) | const |
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records present in the list.
Quite verbose.
os | the output stream |
Definition at line 380 of file global-router-interface.cc.
References ASExternalLSAs, m_advertisingRtr, m_attachedRouters, ns3::GlobalRoutingLinkRecord::m_linkData, ns3::GlobalRoutingLinkRecord::m_linkId, m_linkRecords, m_linkStateId, ns3::GlobalRoutingLinkRecord::m_linkType, m_lsType, ns3::GlobalRoutingLinkRecord::m_metric, m_networkLSANetworkMask, NetworkLSA, NS_ASSERT_MSG, NS_LOG_FUNCTION, ns3::GlobalRoutingLinkRecord::PointToPoint, RouterLSA, ns3::GlobalRoutingLinkRecord::StubNetwork, and ns3::GlobalRoutingLinkRecord::TransitNetwork.
Referenced by ns3::operator<<().
void ns3::GlobalRoutingLSA::SetAdvertisingRouter | ( | Ipv4Address | rtr | ) |
Set the Advertising Router as defined by the OSPF spec.
We always set it to the router ID of the router making the advertisement.
rtr | ID of the router making advertisement |
Definition at line 300 of file global-router-interface.cc.
References m_advertisingRtr, and NS_LOG_FUNCTION.
void ns3::GlobalRoutingLSA::SetLinkStateId | ( | Ipv4Address | addr | ) |
Set the Link State ID is defined by the OSPF spec.
We always set it to the router ID of the router making the advertisement.
addr | IPv4 address which will act as ID |
Definition at line 286 of file global-router-interface.cc.
References m_linkStateId, and NS_LOG_FUNCTION.
void ns3::GlobalRoutingLSA::SetLSType | ( | GlobalRoutingLSA::LSType | typ | ) |
Set the LS type field of the LSA.
typ | the LS Type. |
Definition at line 272 of file global-router-interface.cc.
References m_lsType, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouter::DiscoverLSAs().
void ns3::GlobalRoutingLSA::SetNetworkLSANetworkMask | ( | Ipv4Mask | mask | ) |
For a Network LSA, set the Network Mask field that precedes the list of attached routers.
mask | the Network Mask field. |
Definition at line 307 of file global-router-interface.cc.
References m_networkLSANetworkMask, and NS_LOG_FUNCTION.
Set the Node pointer of the node that originated this LSA.
node | Node pointer |
Definition at line 373 of file global-router-interface.cc.
References m_node_id, and NS_LOG_FUNCTION.
void ns3::GlobalRoutingLSA::SetStatus | ( | GlobalRoutingLSA::SPFStatus | status | ) |
Set the SPF status of the advertisement.
status | SPF status to set |
Definition at line 359 of file global-router-interface.cc.
References m_status, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerLSDB::Initialize(), ns3::GlobalRouteManagerImpl::SPFCalculate(), and ns3::GlobalRouteManagerImpl::SPFNext().
|
private |
The Advertising Router is defined by the OSPF spec.
We always set it to the router ID of the router making the advertisement.
Definition at line 517 of file global-router-interface.h.
Referenced by GetAdvertisingRouter(), operator=(), Print(), and SetAdvertisingRouter().
|
private |
Each Network LSA contains a list of attached routers.
m_attachedRouters is an STL list container to hold the addresses that have been discovered and prepared for the advertisement.
Definition at line 554 of file global-router-interface.h.
Referenced by AddAttachedRouter(), CopyLinkRecords(), GetAttachedRouter(), GetNAttachedRouters(), and Print().
|
private |
Each Link State Advertisement contains a number of Link Records that describe the kinds of links that are attached to a given node.
We consider PointToPoint and StubNetwork links.
m_linkRecords is an STL list container to hold the Link Records that have been discovered and prepared for the advertisement.
Definition at line 534 of file global-router-interface.h.
Referenced by AddLinkRecord(), ClearLinkRecords(), CopyLinkRecords(), GetLinkRecord(), GetNLinkRecords(), IsEmpty(), and Print().
|
private |
The Link State ID is defined by the OSPF spec.
We always set it to the router ID of the router making the advertisement.
Definition at line 508 of file global-router-interface.h.
Referenced by GetLinkStateId(), operator=(), Print(), and SetLinkStateId().
|
private |
The type of the LSA.
Each LSA type has a separate advertisement format.
Definition at line 500 of file global-router-interface.h.
Referenced by GetLSType(), operator=(), Print(), and SetLSType().
|
private |
Each Network LSA contains the network mask of the attached network.
Definition at line 539 of file global-router-interface.h.
Referenced by GetNetworkLSANetworkMask(), operator=(), Print(), and SetNetworkLSANetworkMask().
|
private |
node ID
Definition at line 563 of file global-router-interface.h.
Referenced by GetNode(), operator=(), and SetNode().
|
private |
This is a tristate flag used internally in the SPF computation to mark if an SPFVertex (a data structure representing a vertex in the SPF tree – a router) is new, is a candidate for a shortest path, or is in its proper position in the tree.
Definition at line 562 of file global-router-interface.h.
Referenced by GetStatus(), operator=(), and SetStatus().