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> ();
 
  238       rtentry->
SetSource (
m_ipv4->GetAddress (oif->GetIfIndex (), 0).GetLocal ());
 
  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> ();
 
  295       NS_LOG_LOGIC (
"No matching route to " << dest << 
" found");
 
  325           NS_LOG_LOGIC (
"Found multicast source specific route" << *i);
 
  333               mrtentry = Create<Ipv4MulticastRoute> ();
 
  334               mrtentry->SetGroup (route->
GetGroup ());
 
  335               mrtentry->SetOrigin (route->
GetOrigin ());
 
  365   uint32_t shortest_metric = 0xffffffff;
 
  372       uint32_t metric = i->second;
 
  373       Ipv4Mask mask = (j)->GetDestNetworkMask ();
 
  379       if (metric > shortest_metric)
 
  383       shortest_metric = metric;
 
  495   uint32_t iif = 
m_ipv4->GetInterfaceForDevice (idev); 
 
  508           mcb (mrtentry, p, ipHeader); 
 
  531   for (uint32_t j = 0; j < 
m_ipv4->GetNInterfaces (); j++)
 
  533       for (uint32_t i = 0; i < 
m_ipv4->GetNAddresses (j); i++)
 
  541                   NS_LOG_LOGIC (
"For me (destination " << addr << 
" match)");
 
  547               lcb (p, ipHeader, iif);
 
  553               lcb (p, ipHeader, iif);
 
  560   if (
m_ipv4->IsForwarding (iif) == 
false)
 
  562       NS_LOG_LOGIC (
"Forwarding disabled for this interface");
 
  570       NS_LOG_LOGIC (
"Found unicast destination- calling unicast callback");
 
  571       ucb (rtentry, p, ipHeader);  
 
  576       NS_LOG_LOGIC (
"Did not find unicast destination- returning false");
 
  613   for (uint32_t j = 0; j < 
m_ipv4->GetNAddresses (i); j++)
 
  620                              m_ipv4->GetAddress (i,j).GetMask (), i);
 
  632       if (it->first->GetInterface () == i)
 
  648   if (!
m_ipv4->IsUp (interface))
 
  659                          networkMask, interface);
 
  666   if (!
m_ipv4->IsUp (interface))
 
  676       if (it->first->GetInterface () == interface
 
  677           && it->first->IsNetwork ()
 
  678           && it->first->GetDestNetwork () == networkAddress
 
  679           && it->first->GetDestNetworkMask () == networkMask)
 
  697   for (uint32_t i = 0; i < 
m_ipv4->GetNInterfaces (); i++)
 
  717       *os << 
"Destination     Gateway         Genmask         Flags Metric Ref    Use Iface" << std::endl;
 
  720           std::ostringstream dest, gw, mask, flags;
 
  723           *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str ();
 
  725           *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str ();
 
  727           *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str ();
 
  737           *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str ();
 
  738           *os << std::setiosflags (std::ios::left) << std::setw (7) << 
GetMetric (j);
 
  759   if (
m_ipv4->GetNAddresses (interfaceIdx) == 1)  
 
  761       return m_ipv4->GetAddress (interfaceIdx, 0).GetLocal ();
 
  768   for (uint32_t i = 0; i < 
m_ipv4->GetNAddresses (interfaceIdx); i++)
 
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 
 
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. 
 
bool IsBroadcast(void) const 
 
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 
 
bool IsSecondary(void) const 
Check if the address is a secondary address. 
 
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. 
 
bool IsEqual(const Ipv4Address &other) const 
Comparison operation between two Ipv4Addresses. 
 
std::list< std::pair< Ipv4RoutingTableEntry *, uint32_t > >::const_iterator NetworkRoutesCI
Const Iterator for container for the network routes. 
 
Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest)
Choose the source address to use with destination address. 
 
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. 
 
Ipv4Address GetBroadcast(void) const 
Get the broadcast address. 
 
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. 
 
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. 
 
void test(void)
Example use of ns3::SystemThread. 
 
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.