78#ifndef GLOBAL_ROUTING_H
79#define GLOBAL_ROUTING_H
89#include "ns3/ipv4-address.h"
90#include "ns3/ipv6-address.h"
92#include "ns3/random-variable-stream.h"
139class GlobalRouting :
public std::enable_if_t<std::is_same_v<Ipv4RoutingProtocol, T> ||
140 std::is_same_v<Ipv6RoutingProtocol, T>,
147 static constexpr bool IsIpv4 = std::is_same_v<Ipv4RoutingProtocol, T>;
149 using Ip =
typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
151 using IpAddress =
typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
154 typename std::conditional_t<IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol>;
157 using IpHeader =
typename std::conditional_t<IsIpv4, Ipv4Header, Ipv6Header>;
160 using IpRoute =
typename std::conditional_t<IsIpv4, Ipv4Route, Ipv6Route>;
163 using IpMaskOrPrefix =
typename std::conditional_t<IsIpv4, Ipv4Mask, Ipv6Prefix>;
167 typename std::conditional_t<IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry>;
170 using IpManager =
typename std::conditional_t<IsIpv4, Ipv4Manager, Ipv6Manager>;
174 typename std::conditional_t<IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress>;
225 typedef typename std::conditional_t<IsIpv4, UnicastForwardCallbackv4, UnicastForwardCallbackv6>
242 typename std::conditional_t<IsIpv4, MulticastForwardCallbackv4, MulticastForwardCallbackv6>
A global router implementation.
Global routing protocol for IPv4 stacks.
Ptr< IpRoute > LookupGlobal(IpAddress dest, Ptr< NetDevice > oif=nullptr)
Lookup in the forwarding table for destination.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
friend class GlobalRouteManagerImpl
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
void NotifyRemoveAddress(uint32_t interface, IpInterfaceAddress address)
static TypeId GetTypeId()
Get the type ID.
void AddHostRouteTo(IpAddress dest, IpAddress nextHop, uint32_t interface)
Add a host route to the global routing table.
typename std::conditional_t< IsIpv4, Ipv4Manager, Ipv6Manager > IpManager
virtual void SetIpv6(Ptr< Ip > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
uint32_t GetNRoutes() const
Get the number of individual unicast routes that have been added to the routing table.
ASExternalRoutes m_ASexternalRoutes
std::conditional_t< IsIpv4, MulticastForwardCallbackv4, MulticastForwardCallbackv6 > MulticastForwardCallback
void NotifyInterfaceDown(uint32_t interface)
virtual void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify a new route.
std::list< IpRoutingTableEntry * > NetworkRoutes
Callback< void, Ptr< const NetDevice >, Ptr< IpRoute >, Ptr< const Packet >, const IpHeader & > UnicastForwardCallbackv6
std::list< IpRoutingTableEntry * >::const_iterator HostRoutesCI
Callback< void, Ptr< const Packet >, const IpHeader &, uint32_t > LocalDeliverCallback
void NotifyAddAddress(uint32_t interface, IpInterfaceAddress address)
typename std::conditional_t< IsIpv4, Ipv4Header, Ipv6Header > IpHeader
void NotifyInterfaceUp(uint32_t interface)
void AddHostRouteTo(IpAddress dest, uint32_t interface)
Add a host route to the global routing table.
void AddNetworkRouteTo(IpAddress network, IpMaskOrPrefix networkMask, uint32_t interface)
Add a network route to the global routing table.
std::list< IpRoutingTableEntry * >::iterator NetworkRoutesI
typename std::conditional_t< IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol > IpRoutingProtocol
std::list< IpRoutingTableEntry * >::iterator HostRoutesI
Ptr< UniformRandomVariable > m_rand
std::list< IpRoutingTableEntry * >::const_iterator ASExternalRoutesCI
typename std::conditional_t< IsIpv4, Ipv4Mask, Ipv6Prefix > IpMaskOrPrefix
virtual void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify route removing.
bool RouteInput(Ptr< const Packet > p, const IpHeader &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb)
Route an input packet (to be forwarded or locally delivered).
static constexpr bool IsIpv4
Callback< void, Ptr< IpRoute >, Ptr< const Packet >, const IpHeader & > UnicastForwardCallbackv4
std::list< IpRoutingTableEntry * > ASExternalRoutes
std::conditional_t< IsIpv4, UnicastForwardCallbackv4, UnicastForwardCallbackv6 > UnicastForwardCallback
typename std::conditional_t< IsIpv4, Ipv4RoutingTableEntry, Ipv6RoutingTableEntry > IpRoutingTableEntry
Callback< void, Ptr< Ipv4MulticastRoute >, Ptr< const Packet >, const IpHeader & > MulticastForwardCallbackv4
std::list< IpRoutingTableEntry * > HostRoutes
Callback< void, Ptr< const NetDevice >, Ptr< Ipv6MulticastRoute >, Ptr< const Packet >, const IpHeader & > MulticastForwardCallbackv6
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void RemoveRoute(uint32_t i)
Remove a route from the global unicast routing table.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
GlobalRouting()
Construct an empty Ipv4GlobalRouting routing protocol,.
Callback< void, Ptr< const Packet >, const IpHeader &, Socket::SocketErrno > ErrorCallback
Ptr< IpRoute > RouteOutput(Ptr< Packet > p, const IpHeader &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
void AddNetworkRouteTo(IpAddress network, IpMaskOrPrefix networkMask, IpAddress nextHop, uint32_t interface)
Add a network route to the global routing table.
virtual void SetIpv4(Ptr< Ip > ipv4)
Typically, invoked directly or indirectly from ns3::Ipv4::SetRoutingProtocol.
std::list< IpRoutingTableEntry * >::iterator ASExternalRoutesI
bool m_respondToInterfaceEvents
typename std::conditional_t< IsIpv4, Ipv4Route, Ipv6Route > IpRoute
NetworkRoutes m_networkRoutes
void AddASExternalRouteTo(IpAddress network, IpMaskOrPrefix networkMask, IpAddress nextHop, uint32_t interface)
Add an external route to the global routing table.
std::list< IpRoutingTableEntry * >::const_iterator NetworkRoutesCI
IpRoutingTableEntry * GetRoute(uint32_t i) const
Get a route from the global unicast routing table.
Ipv4 addresses are stored in host order in this class.
The IPv4 representation of a network interface.
A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Describes an IPv6 address.
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Describes an IPv6 prefix.
Network layer to device interface.
Smart pointer class similar to boost::intrusive_ptr.
SocketErrno
Enumeration of the possible errors returned by a socket.
Unit
The unit to use to interpret a number representing time.
a unique identifier for an interface.
GlobalRouting< Ipv4RoutingProtocol > Ipv4GlobalRouting
Create the typedef Ipv4GlobalRouting with T as Ipv4RoutingProtocol.
GlobalRouting< Ipv6RoutingProtocol > Ipv6GlobalRouting
Create the typedef Ipv6GlobalRouting with T as Ipv6RoutingProtocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.