21 #define NS_LOG_APPEND_CONTEXT                                   \ 
   22   if (m_ipv4 && m_ipv4->GetObject<Node> ()) { \ 
   23       std::clog << Simulator::Now ().GetSeconds () \ 
   24                 << " [node " << m_ipv4->GetObject<Node> ()->GetId () << "] "; } 
   28 #include "ns3/names.h" 
   29 #include "ns3/packet.h" 
   31 #include "ns3/simulator.h" 
   32 #include "ns3/ipv4-route.h" 
   33 #include "ns3/output-stream-wrapper.h" 
   50     .SetGroupName (
"Internet")
 
   69   NS_LOG_FUNCTION (
this << network << 
" " << networkMask << 
" " << nextHop << 
" " << interface << 
" " << metric);
 
   84   NS_LOG_FUNCTION (
this << network << 
" " << networkMask << 
" " << interface << 
" " << metric);
 
   98   NS_LOG_FUNCTION (
this << dest << 
" " << nextHop << 
" " << interface << 
" " << metric);
 
  116   NS_LOG_FUNCTION (
this << nextHop << 
" " << interface << 
" " << metric);
 
  123                                       uint32_t inputInterface,
 
  124                                       std::vector<uint32_t> outputInterfaces)
 
  126   NS_LOG_FUNCTION (
this << origin << 
" " << group << 
" " << inputInterface << 
" " << &outputInterfaces);
 
  129                                                                  inputInterface, outputInterfaces);
 
  161                  "Ipv4StaticRouting::GetMulticastRoute ():  Index out of range");
 
  183                                          uint32_t inputInterface)
 
  185   NS_LOG_FUNCTION (
this << origin << 
" " << group << 
" " << inputInterface);
 
  227   uint16_t longest_mask = 0;
 
  228   uint32_t shortest_metric = 0xffffffff;
 
  232       NS_ASSERT_MSG (oif, 
"Try to send on link-local multicast address, and no interface index is given!");
 
  234       rtentry = Create<Ipv4Route> ();
 
  248       uint32_t metric =i->second;
 
  249       Ipv4Mask mask = (j)->GetDestNetworkMask ();
 
  252       NS_LOG_LOGIC (
"Searching for route to " << dest << 
", checking against route to " << entry << 
"/" << masklen);
 
  253       if (mask.
IsMatch (dest, entry)) 
 
  255           NS_LOG_LOGIC (
"Found global network route " << j << 
", mask length " << masklen << 
", metric " << metric);
 
  264           if (masklen < longest_mask) 
 
  269           if (masklen > longest_mask) 
 
  271               shortest_metric = 0xffffffff;
 
  273           longest_mask = masklen;
 
  274           if (metric > shortest_metric)
 
  276               NS_LOG_LOGIC (
"Equal mask length, but previous metric shorter, skipping");
 
  279           shortest_metric = metric;
 
  282           rtentry = Create<Ipv4Route> ();
 
  299       NS_LOG_LOGIC (
"No matching route to " << dest << 
" found");
 
  329           NS_LOG_LOGIC (
"Found multicast source specific route" << *i);
 
  337               mrtentry = Create<Ipv4MulticastRoute> ();
 
  338               mrtentry->SetGroup (route->
GetGroup ());
 
  339               mrtentry->SetOrigin (route->
GetOrigin ());
 
  369   uint32_t shortest_metric = 0xffffffff;
 
  376       uint32_t metric = i->second;
 
  377       Ipv4Mask mask = (j)->GetDestNetworkMask ();
 
  383       if (metric > shortest_metric)
 
  387       shortest_metric = metric;
 
  499   uint32_t iif = 
m_ipv4->GetInterfaceForDevice (idev); 
 
  512           mcb (mrtentry, p, ipHeader); 
 
  527           lcb (p, ipHeader, iif);
 
  542   if (
m_ipv4->IsForwarding (iif) == 
false)
 
  544       NS_LOG_LOGIC (
"Forwarding disabled for this interface");
 
  552       NS_LOG_LOGIC (
"Found unicast destination- calling unicast callback");
 
  553       ucb (rtentry, p, ipHeader);  
 
  558       NS_LOG_LOGIC (
"Did not find unicast destination- returning false");
 
  595   for (uint32_t j = 0; j < 
m_ipv4->GetNAddresses (i); j++)
 
  602                              m_ipv4->GetAddress (i,j).GetMask (), i);
 
  614       if (it->first->GetInterface () == i)
 
  630   if (!
m_ipv4->IsUp (interface))
 
  641                          networkMask, interface);
 
  648   if (!
m_ipv4->IsUp (interface))
 
  658       if (it->first->GetInterface () == interface
 
  659           && it->first->IsNetwork ()
 
  660           && it->first->GetDestNetwork () == networkAddress
 
  661           && it->first->GetDestNetworkMask () == networkMask)
 
  679   for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
 
  698   *os << 
"Node: " << 
m_ipv4->GetObject<
Node> ()->GetId ()
 
  700       << 
", Local time: " << GetObject<Node> ()->GetLocalTime ().As (
Time::S)
 
  701       << 
", Ipv4StaticRouting table" << std::endl;
 
  705       *os << 
"Destination     Gateway         Genmask         Flags Metric Ref    Use Iface" << std::endl;
 
  708           std::ostringstream dest, gw, mask, flags;
 
  711           *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str ();
 
  713           *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str ();
 
  715           *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str ();
 
  725           *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str ();
 
  726           *os << std::setiosflags (std::ios::left) << std::setw (7) << 
GetMetric (j);
 
static Ipv4Mask GetOnes(void)
 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
 
SocketErrno
Enumeration of the possible errors returned by a socket. 
 
Ipv4Mask GetMask(void) const 
Get the network mask. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
bool IsMatch(Ipv4Address a, Ipv4Address b) const 
 
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table. 
 
Ipv4Address GetLocal(void) const 
Get the local address. 
 
static TypeId GetTypeId(void)
The interface Id associated with this class. 
 
a class to represent an Ipv4 address mask 
 
void RemoveRoute(uint32_t i)
Remove a route from the static unicast routing table. 
 
Ipv4Address GetOrigin(void) const 
 
bool IsLocalMulticast(void) const 
 
bool IsNull(void) const 
Check for null implementation. 
 
Ipv4RoutingTableEntry GetDefaultRoute(void)
Get the default route with lowest metric from the static routing table. 
 
std::list< std::pair< Ipv4RoutingTableEntry *, uint32_t > >::iterator NetworkRoutesI
Iterator for container for the network routes. 
 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
 
Ipv4MulticastRoutingTableEntry GetMulticastRoute(uint32_t i) const 
Get a route from the static multicast routing table. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
uint32_t GetInputInterface(void) const 
 
bool IsMulticast(void) const 
 
Ipv4Address CombineMask(Ipv4Mask const &mask) const 
Combine this address with a network mask. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
void AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a host route to the static routing table. 
 
static Ipv4MulticastRoutingTableEntry CreateMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
 
Ptr< Ipv4Route > LookupStatic(Ipv4Address dest, Ptr< NetDevice > oif=0)
Lookup in the forwarding table for destination. 
 
void SetSource(Ipv4Address src)
 
uint32_t GetInterface(void) const 
 
virtual void NotifyInterfaceDown(uint32_t interface)
 
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting. 
 
bool RemoveMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface)
Remove a route from the static multicast routing table. 
 
bool IsGateway(void) const 
 
void SetGateway(Ipv4Address gw)
 
static Ipv4RoutingTableEntry CreateNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
 
static Ipv4Mask GetZero(void)
 
MulticastRoutes m_multicastRoutes
the forwarding table for multicast. 
 
std::list< Ipv4MulticastRoutingTableEntry * >::iterator MulticastRoutesI
Iterator for container for the multicast routes. 
 
Ipv4RoutingTableEntry GetRoute(uint32_t i) const 
Get a route from the static unicast routing table. 
 
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) 
 
Ptr< Ipv4 > m_ipv4
Ipv4 reference. 
 
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC. 
 
Ipv4Address GetGateway(void) const 
 
std::list< Ipv4MulticastRoutingTableEntry * >::const_iterator MulticastRoutesCI
Const Iterator for container for the multicast routes. 
 
uint32_t GetMetric(uint32_t index) const 
Get a metric for route from the static unicast routing table. 
 
uint32_t GetNRoutes(void) const 
Get the number of individual unicast routes that have been added to the routing table. 
 
uint32_t GetOutputInterface(uint32_t n) const 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
Static routing protocol for IP version 4 stacks. 
 
std::list< std::pair< Ipv4RoutingTableEntry *, uint32_t > >::const_iterator NetworkRoutesCI
Const Iterator for container for the network routes. 
 
Ipv4Address GetDest(void) const 
 
static Ipv4Address GetZero(void)
 
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev. 
 
virtual ~Ipv4StaticRouting()
 
A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting. 
 
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const 
Print the Routing Table entries. 
 
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
 
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table. 
 
Ipv4 addresses are stored in host order in this class. 
 
virtual void DoDispose(void)
Destructor implementation. 
 
TimeWithUnit As(const enum Unit unit) const 
Attach a unit to a Time, to facilitate output in a specific unit. 
 
a class to store IPv4 address information on an interface 
 
virtual void NotifyInterfaceUp(uint32_t interface)
 
NetworkRoutes m_networkRoutes
the forwarding table for network. 
 
Ipv4Address GetGroup(void) const 
 
Ipv4Address GetGateway(void) const 
 
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
 
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
 
static const uint32_t IF_ANY
interface wildcard, meaning any interface 
 
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and...
 
Abstract base class for IPv4 routing protocols. 
 
Time Now(void)
create an ns3::Time instance which contains the current simulation time. 
 
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
 
uint32_t GetNOutputInterfaces(void) const 
 
uint32_t GetNMulticastRoutes(void) const 
Get the number of individual multicast routes that have been added to the routing table...
 
Ipv4Mask GetDestNetworkMask(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. 
 
uint16_t GetPrefixLength(void) const 
 
static const uint32_t MAX_TTL
Maximum time-to-live (TTL) 
 
void SetDestination(Ipv4Address dest)
 
void SetDefaultMulticastRoute(uint32_t outputInterface)
Add a default multicast route to the static routing table. 
 
void AddMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
Add a multicast route to the static routing table. 
 
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.