10#ifndef GLOBAL_ROUTER_INTERFACE_H
11#define GLOBAL_ROUTER_INTERFACE_H
21#include "ns3/bridge-net-device.h"
22#include "ns3/channel.h"
23#include "ns3/ipv4-address.h"
24#include "ns3/net-device-container.h"
26#include "ns3/object.h"
52 std::is_same_v<T, Ipv4Manager> || std::is_same_v<T, Ipv6Manager>,
53 "T must be either Ipv4Manager or Ipv6Manager when calling GlobalRoutingLinkRecord");
55 static constexpr bool IsIpv4 = std::is_same_v<Ipv4Manager, T>;
58 using Ip =
typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
61 using IpAddress =
typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
64 using IpRoute =
typename std::conditional_t<IsIpv4, Ipv4Route, Ipv6Route>;
67 using IpHeader =
typename std::conditional_t<IsIpv4, Ipv4Header, Ipv6Header>;
71 typename std::conditional_t<IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress>;
75 typename std::conditional_t<IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry>;
78 using IpMaskOrPrefix =
typename std::conditional_t<IsIpv4, Ipv4Mask, Ipv6Prefix>;
338 static_assert(std::is_same_v<T, Ipv4Manager> || std::is_same_v<T, Ipv6Manager>,
339 "T must be either Ipv4Manager or Ipv6Manager when calling GlobalRoutingLSA");
341 static constexpr bool IsIpv4 = std::is_same_v<Ipv4Manager, T>;
344 using Ip =
typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
347 using IpAddress =
typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
350 using IpRoute =
typename std::conditional_t<IsIpv4, Ipv4Route, Ipv6Route>;
353 using IpHeader =
typename std::conditional_t<IsIpv4, Ipv4Header, Ipv6Header>;
357 typename std::conditional_t<IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress>;
361 typename std::conditional_t<IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry>;
364 using IpMaskOrPrefix =
typename std::conditional_t<IsIpv4, Ipv4Mask, Ipv6Prefix>;
497 void Print(std::ostream& os)
const;
707 static_assert(std::is_same_v<T, Ipv4Manager> || std::is_same_v<T, Ipv6Manager>,
708 "T must be either Ipv4Manager or Ipv6Manager when calling GlobalRouter");
711 static constexpr bool IsIpv4 = std::is_same_v<Ipv4Manager, T>;
714 using Ip =
typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
717 using IpAddress =
typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
720 using IpRoute =
typename std::conditional_t<IsIpv4, Ipv4Route, Ipv6Route>;
723 using IpHeader =
typename std::conditional_t<IsIpv4, Ipv4Header, Ipv6Header>;
727 typename std::conditional_t<IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress>;
731 typename std::conditional_t<IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry>;
734 using IpMaskOrPrefix =
typename std::conditional_t<IsIpv4, Ipv4Mask, Ipv6Prefix>;
738 typename std::conditional_t<IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol>;
1005 typedef std::list<IpRoutingTableEntry*>::const_iterator
1007 typedef std::list<IpRoutingTableEntry*>::iterator
An interface aggregated to a node to provide global routing info.
uint32_t DiscoverLSAs()
Walk the connected channels, discover the adjacent routers and build the associated number of Global ...
Ptr< GlobalRouting< IpRoutingProtocol > > m_routingProtocol
Ptr< NetDevice > GetAdjacent(Ptr< NetDevice > nd, Ptr< Channel > ch) const
Link through the given channel and find the net device that's on the other end.
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
typename std::conditional_t< IsIpv4, Ipv4Route, Ipv6Route > IpRoute
Alias for Ipv4Route and Ipv6Route classes.
IpRoutingTableEntry * GetInjectedRoute(uint32_t i)
Return the injected route indexed by i.
typename std::conditional_t< IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol > IpRoutingProtocol
Alias for Ipv4RoutingProtocol and Ipv6RoutingProtocol classes.
std::vector< Ptr< BridgeNetDevice > > m_bridgesVisited
std::list< IpRoutingTableEntry * >::iterator InjectedRoutesI
Iterator to container of Ipv4RoutingTableEntry.
std::list< IpRoutingTableEntry * > InjectedRoutes
container of Ipv4RoutingTableEntry
static constexpr bool IsIpv4
void ProcessSingleBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA< T > *pLSA, NetDeviceContainer &c)
Process a single broadcast link.
bool BridgeHasAlreadyBeenVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, check whether a given device has already been visi...
bool WithdrawRoute(IpAddress network, IpMaskOrPrefix networkMask)
Withdraw a route from the global unicast routing table.
std::list< IpRoutingTableEntry * >::const_iterator InjectedRoutesCI
Const Iterator to container of Ipv4RoutingTableEntry.
uint32_t GetNumLSAs() const
Get the Number of Global Routing Link State Advertisements that this router can export.
GlobalRouter()
Create a Global Router class.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
void ProcessBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA< T > *pLSA, NetDeviceContainer &c)
Process a generic broadcast link.
bool AnotherRouterOnLink(Ptr< NetDevice > nd) const
Checks for the presence of another router on the NetDevice.
void ProcessBridgedBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA< T > *pLSA, NetDeviceContainer &c)
Process a bridged broadcast link.
uint32_t GetNInjectedRoutes()
Get the number of injected routes that have been added to the routing table.
InjectedRoutes m_injectedRoutes
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Decide whether or not a given net device is being bridged by a BridgeNetDevice.
void ClearBridgesVisited() const
Clear the list of bridges visited on the link.
NetDeviceContainer FindAllNonBridgedDevicesOnLink(Ptr< Channel > ch) const
Return a container of all non-bridged NetDevices on a link.
IpAddress FindDesignatedRouterForLink(Ptr< NetDevice > ndLocal) const
Finds a designated router.
bool GetLSA(uint32_t n, GlobalRoutingLSA< T > &lsa) const
Get a Global Routing Link State Advertisements that this router has said that it can export.
void BuildNetworkLSAs(NetDeviceContainer c)
Build one NetworkLSA for each net device talking to a network that we are the designated router for.
typename std::conditional_t< IsIpv4, Ipv4Mask, Ipv6Prefix > IpMaskOrPrefix
Alias for Ipv4Mask And Ipv6Prefix.
void ClearLSAs()
Clear list of LSAs.
void InjectRoute(IpAddress network, IpMaskOrPrefix networkMask)
Inject a route to be circulated to other routers as an external route.
static TypeId GetTypeId()
Get the type ID.
Ptr< GlobalRouting< IpRoutingProtocol > > GetRoutingProtocol()
Get the specific Global Routing Protocol used.
void SetRoutingProtocol(Ptr< GlobalRouting< IpRoutingProtocol > > routing)
Set the specific Global Routing Protocol to be used.
IpAddress GetRouterId() const
Get the Router ID associated with this Global Router.
void DoDispose() override
Destructor implementation.
GlobalRouter(const GlobalRouter &)=delete
typename std::conditional_t< IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry > IpRoutingTableEntry
Alias for Ipv4RoutingTableEntry and Ipv6RoutingTableEntry classes.
std::list< GlobalRoutingLSA< T > * > ListOfLSAs_t
container for the GlobalRoutingLSAs
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
void RemoveInjectedRoute(uint32_t i)
Withdraw a route from the global unicast routing table.
typename std::conditional_t< IsIpv4, Ipv4Header, Ipv6Header > IpHeader
Alias for Ipv4Header and Ipv6Header classes.
void MarkBridgeAsVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, mark a given device as having been visited.
GlobalRouter & operator=(const GlobalRouter &)=delete
void ProcessPointToPointLink(Ptr< NetDevice > ndLocal, GlobalRoutingLSA< T > *pLSA)
Process a point to point link.
Global routing protocol for IPv4 stacks.
a Link State Advertisement (LSA) for a router, used in global routing.
GlobalRoutingLinkRecord< T > * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
SPFStatus
Enumeration of the possible values of the status flag in the Routing Link State Advertisements.
@ LSA_SPF_CANDIDATE
Vertex is in the SPF candidate queue.
@ LSA_SPF_IN_SPFTREE
Vertex is in the SPF tree.
@ LSA_SPF_NOT_EXPLORED
New vertex not yet considered.
IpAddress m_advertisingRtr
The Advertising Router is defined by the OSPF spec.
void SetLSType(LSType typ)
Set the LS type field of the LSA.
void ClearLinkRecords()
Release all of the Global Routing Link Records present in the Global Routing Link State Advertisement...
SPFStatus GetStatus() const
Get the SPF status of the advertisement.
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
LSType
corresponds to LS type field of RFC 2328 OSPF LSA header
@ Unknown
Uninitialized Type.
void SetNetworkLSANetworkMask(IpMaskOrPrefix mask)
For a Network LSA, set the Network Mask field that precedes the list of attached routers.
void SetAdvertisingRouter(IpAddress rtr)
Set the Advertising Router as defined by the OSPF spec.
uint32_t GetNLinkRecords() const
Return the number of Global Routing Link Records in the LSA.
ListOfLinkRecords_t m_linkRecords
Each Link State Advertisement contains a number of Link Records that describe the kinds of links that...
uint32_t AddLinkRecord(GlobalRoutingLinkRecord< T > *lr)
Add a given Global Routing Link Record to the LSA.
IpAddress GetLinkStateId() const
Get the Link State ID as defined by the OSPF spec.
void SetLinkStateId(IpAddress addr)
Set the Link State ID is defined by the OSPF spec.
typename std::conditional_t< IsIpv4, Ipv4Mask, Ipv6Prefix > IpMaskOrPrefix
Alias for Ipv4Mask And Ipv6Prefix.
Ptr< Node > GetNode() const
Get the Node pointer of the node that originated this LSA.
void Print(std::ostream &os) const
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records...
GlobalRoutingLSA & operator=(const GlobalRoutingLSA &lsa)
Assignment operator for a Global Routing Link State Advertisement.
IpMaskOrPrefix m_networkLSANetworkMask
Each Network LSA contains the network mask of the attached network.
typename std::conditional_t< IsIpv4, Ipv4Route, Ipv6Route > IpRoute
Alias for Ipv4Route and Ipv6Route classes.
LSType GetLSType() const
Return the LSType field of the LSA.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
GlobalRoutingLSA()
Create a blank Global Routing Link State Advertisement.
IpAddress GetAdvertisingRouter() const
Get the Advertising Router as defined by the OSPF spec.
std::list< IpAddress > ListOfAttachedRouters_t
A convenience typedef to avoid too much writers cramp.
uint32_t GetNAttachedRouters() const
Return the number of attached routers listed in the NetworkLSA.
typename std::conditional_t< IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry > IpRoutingTableEntry
Alias for Ipv4RoutingTableEntry and Ipv6RoutingTableEntry classes.
SPFStatus m_status
This is a tristate flag used internally in the SPF computation to mark if an SPFVertex (a data struct...
IpAddress m_linkStateId
The Link State ID is defined by the OSPF spec.
static constexpr bool IsIpv4
Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol.
typename std::conditional_t< IsIpv4, Ipv4Header, Ipv6Header > IpHeader
Alias for Ipv4Header and Ipv6Header classes.
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
ListOfAttachedRouters_t m_attachedRouters
Each Network LSA contains a list of attached routers.
bool IsEmpty() const
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Adve...
~GlobalRoutingLSA()
Destroy an existing Global Routing Link State Advertisement.
std::list< GlobalRoutingLinkRecord< T > * > ListOfLinkRecords_t
A convenience typedef to avoid too much writers cramp.
void CopyLinkRecords(const GlobalRoutingLSA &lsa)
Copy any Global Routing Link Records in a given Global Routing Link State Advertisement to the curren...
void SetNode(Ptr< Node > node)
Set the Node pointer of the node that originated this LSA.
IpMaskOrPrefix GetNetworkLSANetworkMask() const
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
IpAddress GetAttachedRouter(uint32_t n) const
Return an Ipv4Address corresponding to the specified attached router.
uint32_t AddAttachedRouter(IpAddress addr)
Add an attached router to the list in the NetworkLSA.
LSType m_lsType
The type of the LSA.
uint32_t m_node_id
node ID
A single link record for a link state advertisement.
void SetLinkId(IpAddress addr)
Set the Link ID field of the Global Routing Link Record.
static constexpr bool IsIpv4
Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol.
void SetLinkData(IpAddress addr)
Set the Link Data field of the Global Routing Link Record.
typename std::conditional_t< IsIpv4, Ipv4Mask, Ipv6Prefix > IpMaskOrPrefix
Alias for Ipv4Mask And Ipv6Prefix.
IpAddress m_linkId
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
IpAddress GetLinkId() const
Get the Link ID field of the Global Routing Link Record.
~GlobalRoutingLinkRecord()
Destroy a Global Routing Link Record.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
uint16_t GetMetric() const
Get the Metric Data field of the Global Routing Link Record.
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
typename std::conditional_t< IsIpv4, Ipv4Route, Ipv6Route > IpRoute
Alias for Ipv4Route and Ipv6Route classes.
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
LinkType
Enumeration of the possible types of Global Routing Link Records.
@ StubNetwork
Record represents a leaf node network.
@ VirtualLink
Unused – for future OSPF compatibility.
@ Unknown
Uninitialized Link Record.
@ PointToPoint
Record representing a point to point channel.
@ TransitNetwork
Unused – for future OSPF compatibility.
IpAddress m_linkData
m_linkId and m_linkData are defined by OSPF to have different meanings depending on the type of link ...
LinkType m_linkType
The type of the Global Routing Link Record.
void SetMetric(uint16_t metric)
Set the Metric Data field of the Global Routing Link Record.
IpAddress GetLinkData() const
Get the Link Data field of the Global Routing Link Record.
uint16_t m_metric
The metric for a given link.
typename std::conditional_t< IsIpv4, Ipv4Header, Ipv6Header > IpHeader
Alias for Ipv4Header and Ipv6Header classes.
GlobalRoutingLinkRecord()
Construct an empty ("uninitialized") Global Routing Link Record.
IpAddress GetLinkLocData()
Set the Link Local Data field of the Global Routing Link Record.
void SetLinkType(LinkType linkType)
Set the Link Type field of the Global Routing Link Record.
void SetLinkLocData(IpAddress addr)
Set the Link Local Data field of the Global Routing Link Record.
friend class GlobalRoutingLSA
Friend class.
IpAddress m_linkLocData
m_linkLocData is not defined by the OSPF spec.
LinkType GetLinkType() const
Get the Link Type field of the Global Routing Link Record.
typename std::conditional_t< IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry > IpRoutingTableEntry
Alias for Ipv4RoutingTableEntry and Ipv6RoutingTableEntry classes.
holds a vector of ns3::NetDevice pointers
Object()
Caller graph was not generated because of its size.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
GlobalRouter< Ipv4Manager > Ipv4GlobalRouter
Create the typedef Ipv4GlobalRouting with T as Ipv4RoutingProtocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)