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, IpAddress linkStateId, IpAddress advertisingRtr) | |
| Create an initialized Global Routing Link State Advertisement. | |
| ~GlobalRoutingLSA () | |
| Destroy an existing Global Routing Link State Advertisement. | |
| uint32_t | AddAttachedRouter (IpAddress addr) |
| Add an attached router to the list in the NetworkLSA. | |
| uint32_t | AddLinkRecord (GlobalRoutingLinkRecord< T > *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. | |
| IpAddress | GetAdvertisingRouter () const |
| Get the Advertising Router as defined by the OSPF spec. | |
| IpAddress | GetAttachedRouter (uint32_t n) const |
| Return an Ipv4Address corresponding to the specified attached router. | |
| GlobalRoutingLinkRecord< T > * | GetLinkRecord (uint32_t n) const |
| Return a pointer to the specified Global Routing Link Record. | |
| IpAddress | 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. | |
| IpMaskOrPrefix | 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 (IpAddress rtr) |
| Set the Advertising Router as defined by the OSPF spec. | |
| void | SetLinkStateId (IpAddress 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 (IpMaskOrPrefix 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 | |
| using | Ip = typename std::conditional_t<IsIpv4, Ipv4, Ipv6> |
| Alias for Ipv4 and Ipv6 classes. | |
| using | IpAddress = typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address> |
| Alias for Ipv4Address and Ipv6Address classes. | |
| using | IpHeader = typename std::conditional_t<IsIpv4, Ipv4Header, Ipv6Header> |
| Alias for Ipv4Header and Ipv6Header classes. | |
| using | IpInterfaceAddress |
| Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes. | |
| using | IpMaskOrPrefix = typename std::conditional_t<IsIpv4, Ipv4Mask, Ipv6Prefix> |
| Alias for Ipv4Mask And Ipv6Prefix. | |
| using | IpRoute = typename std::conditional_t<IsIpv4, Ipv4Route, Ipv6Route> |
| Alias for Ipv4Route and Ipv6Route classes. | |
| using | IpRoutingTableEntry |
| Alias for Ipv4RoutingTableEntry and Ipv6RoutingTableEntry classes. | |
| typedef std::list< IpAddress > | ListOfAttachedRouters_t |
| A convenience typedef to avoid too much writers cramp. | |
| typedef std::list< GlobalRoutingLinkRecord< T > * > | ListOfLinkRecords_t |
| A convenience typedef to avoid too much writers cramp. | |
Private Attributes | |
| IpAddress | 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. | |
| IpAddress | m_linkStateId |
| The Link State ID is defined by the OSPF spec. | |
| LSType | m_lsType |
| The type of the LSA. | |
| IpMaskOrPrefix | 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. | |
Static Private Attributes | |
| static constexpr bool | IsIpv4 = std::is_same_v<Ipv4Manager, T> |
| Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol. | |
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 336 of file global-router-interface.h.
|
private |
Alias for Ipv4 and Ipv6 classes.
Definition at line 344 of file global-router-interface.h.
|
private |
Alias for Ipv4Address and Ipv6Address classes.
Definition at line 347 of file global-router-interface.h.
|
private |
Alias for Ipv4Header and Ipv6Header classes.
Definition at line 353 of file global-router-interface.h.
|
private |
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
Definition at line 356 of file global-router-interface.h.
|
private |
Alias for Ipv4Mask And Ipv6Prefix.
Definition at line 364 of file global-router-interface.h.
|
private |
Alias for Ipv4Route and Ipv6Route classes.
Definition at line 350 of file global-router-interface.h.
|
private |
Alias for Ipv4RoutingTableEntry and Ipv6RoutingTableEntry classes.
Definition at line 360 of file global-router-interface.h.
|
private |
A convenience typedef to avoid too much writers cramp.
Definition at line 663 of file global-router-interface.h.
|
private |
A convenience typedef to avoid too much writers cramp.
Definition at line 641 of file global-router-interface.h.
| enum ns3::GlobalRoutingLSA::LSType |
corresponds to LS type field of RFC 2328 OSPF LSA header
| Enumerator | |
|---|---|
| Unknown | Uninitialized Type. |
| RouterLSA | |
| NetworkLSA | |
| SummaryLSA | |
| SummaryLSA_ASBR | |
| ASExternalLSAs | |
Definition at line 371 of file global-router-interface.h.
| enum ns3::GlobalRoutingLSA::SPFStatus |
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 386 of file global-router-interface.h.
| ns3::GlobalRoutingLSA< T >::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 171 of file global-router-interface.cc.
References GlobalRoutingLSA(), m_linkStateId, m_lsType, and Unknown.
Referenced by GlobalRoutingLSA(), GlobalRoutingLSA(), CopyLinkRecords(), and operator=().
| ns3::GlobalRoutingLSA< T >::GlobalRoutingLSA | ( | GlobalRoutingLSA< T >::SPFStatus | status, |
| IpAddress | linkStateId, | ||
| IpAddress | 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 185 of file global-router-interface.cc.
| ns3::GlobalRoutingLSA< T >::GlobalRoutingLSA | ( | GlobalRoutingLSA< T > & | 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 201 of file global-router-interface.cc.
References GlobalRoutingLSA(), IsEmpty(), m_advertisingRtr, m_linkStateId, m_lsType, m_networkLSANetworkMask, m_node_id, m_status, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
| ns3::GlobalRoutingLSA< T >::~GlobalRoutingLSA | ( | ) |
Destroy an existing Global Routing Link State Advertisement.
Any Global Routing Link Records present in the list are freed.
Definition at line 254 of file global-router-interface.cc.
References ClearLinkRecords(), and NS_LOG_FUNCTION.
| uint32_t ns3::GlobalRoutingLSA< T >::AddAttachedRouter | ( | IpAddress | addr | ) |
Add an attached router to the list in the NetworkLSA.
| addr | The Ipv4Address of the interface on the network link |
Definition at line 395 of file global-router-interface.cc.
References m_attachedRouters, and NS_LOG_FUNCTION.
| uint32_t ns3::GlobalRoutingLSA< T >::AddLinkRecord | ( | GlobalRoutingLinkRecord< T > * | lr | ) |
Add a given Global Routing Link Record to the LSA.
| lr | The Global Routing Link Record to be added. |
Definition at line 281 of file global-router-interface.cc.
References m_linkRecords, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouter< T >::ProcessBridgedBroadcastLink(), ns3::GlobalRouter< T >::ProcessPointToPointLink(), and ns3::GlobalRouter< T >::ProcessSingleBroadcastLink().
| void ns3::GlobalRoutingLSA< T >::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 262 of file global-router-interface.cc.
References m_linkRecords, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ~GlobalRoutingLSA().
| void ns3::GlobalRoutingLSA< T >::CopyLinkRecords | ( | const GlobalRoutingLSA< T > & | 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 232 of file global-router-interface.cc.
References GlobalRoutingLSA(), and NS_LOG_FUNCTION.
| GlobalRoutingLSA< T >::IpAddress ns3::GlobalRoutingLSA< T >::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 355 of file global-router-interface.cc.
References m_advertisingRtr, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl< T >::ProcessASExternals(), and ns3::GlobalRouteManagerImpl< T >::SPFAddASExternal().
| GlobalRoutingLSA< T >::IpAddress ns3::GlobalRoutingLSA< T >::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 412 of file global-router-interface.cc.
References m_attachedRouters, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
| GlobalRoutingLinkRecord< T > * ns3::GlobalRoutingLSA< T >::GetLinkRecord | ( | uint32_t | n | ) | const |
Return a pointer to the specified Global Routing Link Record.
| n | The LSA number desired. |
Definition at line 298 of file global-router-interface.cc.
References m_linkRecords, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl< T >::CheckForStubNode(), ns3::GlobalRouteManagerLSDB< T >::GetLSAByLinkData(), and ns3::GlobalRouteManagerImpl< T >::SPFIntraAddRouter().
| GlobalRoutingLSA< T >::IpAddress ns3::GlobalRoutingLSA< T >::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 339 of file global-router-interface.cc.
References m_linkStateId, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl< T >::CheckForStubNode(), ns3::GlobalRouteManagerImpl< T >::ProcessASExternals(), ns3::GlobalRouteManagerImpl< T >::SPFAddASExternal(), ns3::GlobalRouteManagerImpl< T >::SPFCalculate(), ns3::GlobalRouteManagerImpl< T >::SPFIntraAddRouter(), ns3::GlobalRouteManagerImpl< T >::SPFIntraAddTransit(), ns3::GlobalRouteManagerImpl< T >::SPFNext(), ns3::GlobalRouteManagerImpl< T >::SPFNexthopCalculation(), and ns3::GlobalRouteManagerImpl< T >::SPFProcessStubs().
| GlobalRoutingLSA< T >::LSType ns3::GlobalRoutingLSA< T >::GetLSType | ( | ) | const |
Return the LSType field of the LSA.
Definition at line 323 of file global-router-interface.cc.
References m_lsType, and NS_LOG_FUNCTION.
Referenced by ns3::SPFVertex< T >::SPFVertex(), ns3::GlobalRouteManagerLSDB< T >::Insert(), and ns3::GlobalRouteManagerImpl< T >::SPFNexthopCalculation().
| uint32_t ns3::GlobalRoutingLSA< T >::GetNAttachedRouters | ( | ) | const |
Return the number of attached routers listed in the NetworkLSA.
Definition at line 404 of file global-router-interface.cc.
References m_attachedRouters, and NS_LOG_FUNCTION.
| GlobalRoutingLSA< T >::IpMaskOrPrefix ns3::GlobalRoutingLSA< T >::GetNetworkLSANetworkMask | ( | ) | const |
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
Definition at line 379 of file global-router-interface.cc.
References m_networkLSANetworkMask, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl< T >::SPFAddASExternal(), ns3::GlobalRouteManagerImpl< T >::SPFIntraAddTransit(), and ns3::GlobalRouteManagerImpl< T >::SPFNexthopCalculation().
| uint32_t ns3::GlobalRoutingLSA< T >::GetNLinkRecords | ( | ) | const |
Return the number of Global Routing Link Records in the LSA.
Definition at line 290 of file global-router-interface.cc.
References m_linkRecords, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl< T >::CheckForStubNode(), ns3::GlobalRouteManagerLSDB< T >::GetLSAByLinkData(), ns3::GlobalRouteManagerImpl< T >::SPFIntraAddRouter(), and ns3::GlobalRouteManagerImpl< T >::SPFProcessStubs().
| Ptr< Node > ns3::GlobalRoutingLSA< T >::GetNode | ( | ) | const |
Get the Node pointer of the node that originated this LSA.
Definition at line 437 of file global-router-interface.cc.
References ns3::NodeList::GetNode(), m_node_id, and NS_LOG_FUNCTION.
Referenced by ns3::SPFVertex< T >::SPFVertex(), and ns3::GlobalRouteManagerImpl< T >::CheckForStubNode().
| GlobalRoutingLSA< T >::SPFStatus ns3::GlobalRoutingLSA< T >::GetStatus | ( | ) | const |
Get the SPF status of the advertisement.
Definition at line 387 of file global-router-interface.cc.
References m_status, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl< T >::SPFNext().
| bool ns3::GlobalRoutingLSA< T >::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 315 of file global-router-interface.cc.
References m_linkRecords, and NS_LOG_FUNCTION.
Referenced by GlobalRoutingLSA(), and ns3::GlobalRouter< T >::GetLSA().
| GlobalRoutingLSA< T > & ns3::GlobalRoutingLSA< T >::operator= | ( | const GlobalRoutingLSA< T > & | 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 216 of file global-router-interface.cc.
References GlobalRoutingLSA(), m_advertisingRtr, m_linkStateId, m_lsType, and NS_LOG_FUNCTION.
| void ns3::GlobalRoutingLSA< T >::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 453 of file global-router-interface.cc.
Referenced by ns3::GlobalRoutingLSA< ns3::Ipv4Manager >::SetAdvertisingRouter().
| void ns3::GlobalRoutingLSA< T >::SetAdvertisingRouter | ( | IpAddress | 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 363 of file global-router-interface.cc.
References m_advertisingRtr, and NS_LOG_FUNCTION.
| void ns3::GlobalRoutingLSA< T >::SetLinkStateId | ( | IpAddress | 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 347 of file global-router-interface.cc.
References m_linkStateId, and NS_LOG_FUNCTION.
| void ns3::GlobalRoutingLSA< T >::SetLSType | ( | GlobalRoutingLSA< T >::LSType | typ | ) |
Set the LS type field of the LSA.
| typ | the LS Type. |
Definition at line 331 of file global-router-interface.cc.
References m_lsType, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouter< T >::DiscoverLSAs().
| void ns3::GlobalRoutingLSA< T >::SetNetworkLSANetworkMask | ( | IpMaskOrPrefix | 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 371 of file global-router-interface.cc.
References m_networkLSANetworkMask, and NS_LOG_FUNCTION.
| void ns3::GlobalRoutingLSA< T >::SetNode | ( | Ptr< Node > | node | ) |
Set the Node pointer of the node that originated this LSA.
| node | Node pointer |
Definition at line 445 of file global-router-interface.cc.
References m_node_id, and NS_LOG_FUNCTION.
| void ns3::GlobalRoutingLSA< T >::SetStatus | ( | GlobalRoutingLSA< T >::SPFStatus | status | ) |
Set the SPF status of the advertisement.
| status | SPF status to set |
Definition at line 429 of file global-router-interface.cc.
References m_status, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerLSDB< T >::Initialize(), and ns3::GlobalRouteManagerImpl< T >::SPFNext().
|
staticconstexprprivate |
Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol.
Definition at line 341 of file global-router-interface.h.
|
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 636 of file global-router-interface.h.
Referenced by GlobalRoutingLSA(), GetAdvertisingRouter(), operator=(), 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 673 of file global-router-interface.h.
Referenced by AddAttachedRouter(), GetAttachedRouter(), and GetNAttachedRouters().
|
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 653 of file global-router-interface.h.
Referenced by AddLinkRecord(), ClearLinkRecords(), GetLinkRecord(), GetNLinkRecords(), and IsEmpty().
|
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 627 of file global-router-interface.h.
Referenced by GlobalRoutingLSA(), GlobalRoutingLSA(), GetLinkStateId(), operator=(), and SetLinkStateId().
|
private |
The type of the LSA.
Each LSA type has a separate advertisement format.
Definition at line 619 of file global-router-interface.h.
Referenced by GlobalRoutingLSA(), GlobalRoutingLSA(), GetLSType(), operator=(), and SetLSType().
|
private |
Each Network LSA contains the network mask of the attached network.
Definition at line 658 of file global-router-interface.h.
Referenced by GlobalRoutingLSA(), GetNetworkLSANetworkMask(), and SetNetworkLSANetworkMask().
|
private |
node ID
Definition at line 682 of file global-router-interface.h.
Referenced by GlobalRoutingLSA(), GetNode(), 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 681 of file global-router-interface.h.
Referenced by GlobalRoutingLSA(), GetStatus(), and SetStatus().