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: " << 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;
virtual void DoInitialize(void)
Initialize() implementation.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t GetId(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
virtual void DoInitialize(void)
Initialize() implementation.
virtual void AddRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static TypeId GetTypeId(void)
Get the type ID of this class.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
SocketErrno
Enumeration of the possible errors returned by a socket.
Ptr< Ipv4 > m_ipv4
Ipv4 this protocol is associated with.
bool IsMulticast(void) const
static bool Compare(const Ipv4RoutingProtocolEntry &a, const Ipv4RoutingProtocolEntry &b)
Compare two routing protocols.
virtual ~Ipv4ListRouting()
std::pair< int16_t, Ptr< Ipv4RoutingProtocol > > Ipv4RoutingProtocolEntry
Container identifying an IPv4 Routing Protocol entry in the list.
Unit
The unit to use to interpret a number representing time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
virtual void DoDispose(void)
Destructor implementation.
virtual void NotifyInterfaceUp(uint32_t interface)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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 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.
a class to store IPv4 address information on an interface
Ipv4RoutingProtocolList m_routingProtocols
List of routing protocols.
virtual void NotifyInterfaceDown(uint32_t interface)
Abstract base class for IPv4 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...
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
virtual uint32_t GetNRoutingProtocols(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)