22 #include "ns3/ipv4-route.h"
24 #include "ns3/ipv4-static-routing.h"
38 .SetGroupName (
"Internet")
66 (*rprotoIter).second = 0;
77 <<
", Time: " <<
Now().
As (unit)
78 <<
", Local time: " <<
m_ipv4->GetObject<
Node> ()->GetLocalTime ().As (unit)
79 <<
", Ipv4ListRouting table" << std::endl;
83 *stream->
GetStream () <<
" Priority: " << (*i).first <<
" Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
84 (*i).second->PrintRoutingTable (stream, unit);
96 protocol->Initialize ();
111 NS_LOG_LOGIC (
"Checking protocol " << (*i).second->GetInstanceTypeId () <<
" with priority " << (*i).first);
113 route = (*i).second->RouteOutput (p, header, oif, sockerr);
133 NS_LOG_FUNCTION (
this << p << header << idev << &ucb << &mcb << &lcb << &ecb);
140 uint32_t iif =
m_ipv4->GetInterfaceForDevice (idev);
149 lcb (packetCopy, header, iif);
155 lcb (p, header, iif);
160 if (
m_ipv4->IsForwarding (iif) ==
false)
162 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
172 downstreamLcb = MakeNullCallback<void, Ptr<const Packet>,
const Ipv4Header &, uint32_t > ();
174 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
179 if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, downstreamLcb, ecb))
181 NS_LOG_LOGIC (
"Route found to forward packet in protocol " << (*rprotoIter).second->GetInstanceTypeId ().GetName ());
193 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
198 (*rprotoIter).second->NotifyInterfaceUp (interface);
205 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
210 (*rprotoIter).second->NotifyInterfaceDown (interface);
217 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
222 (*rprotoIter).second->NotifyAddAddress (interface,
address);
229 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
234 (*rprotoIter).second->NotifyRemoveAddress (interface,
address);
242 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
247 (*rprotoIter).second->SetIpv4 (ipv4);
255 NS_LOG_FUNCTION (
this << routingProtocol->GetInstanceTypeId () << priority);
260 routingProtocol->SetIpv4 (
m_ipv4);
277 NS_FATAL_ERROR (
"Ipv4ListRouting::GetRoutingProtocol(): index " << index <<
" out of range");
280 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
285 priority = (*rprotoIter).first;
286 return (*rprotoIter).second;
296 return a.first > b.first;
bool IsMulticast(void) const
a class to store IPv4 address information on an interface
std::pair< int16_t, Ptr< Ipv4RoutingProtocol > > Ipv4RoutingProtocolEntry
Container identifying an IPv4 Routing Protocol entry in the list.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
virtual void NotifyInterfaceUp(uint32_t interface)
virtual void NotifyInterfaceDown(uint32_t interface)
virtual ~Ipv4ListRouting()
virtual void DoInitialize(void)
Initialize() implementation.
Ipv4RoutingProtocolList m_routingProtocols
List of routing protocols.
virtual uint32_t GetNRoutingProtocols(void) const
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
virtual void AddRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
Ptr< Ipv4 > m_ipv4
Ipv4 this protocol is associated with.
static TypeId GetTypeId(void)
Get the type ID of this class.
static bool Compare(const Ipv4RoutingProtocolEntry &a, const Ipv4RoutingProtocolEntry &b)
Compare two routing protocols.
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(uint32_t index, int16_t &priority) const
Return pointer to routing protocol stored at index, with the first protocol (index 0) the highest pri...
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
virtual void DoDispose(void)
Destructor implementation.
Abstract base class for IPv4 routing protocols.
uint32_t GetId(void) const
virtual void DoInitialize(void)
Initialize() implementation.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
SocketErrno
Enumeration of the possible errors returned by a socket.
Unit
The unit to use to interpret a number representing time.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.