9#define NS_LOG_APPEND_CONTEXT                                                                      \ 
   10    if (m_ipv4 && m_ipv4->GetObject<Node>())                                                       \ 
   12        std::clog << Simulator::Now().GetSeconds() << " [node "                                    \ 
   13                  << m_ipv4->GetObject<Node>()->GetId() << "] ";                                   \ 
 
   24#include "ns3/output-stream-wrapper.h" 
   25#include "ns3/packet.h" 
   26#include "ns3/simulator.h" 
   44                            .SetGroupName(
"Internet")
 
 
   62    NS_LOG_FUNCTION(
this << network << 
" " << networkMask << 
" " << nextHop << 
" " 
   63                         << interface << 
" " << metric);
 
 
   81    NS_LOG_FUNCTION(
this << network << 
" " << networkMask << 
" " << interface << 
" " << metric);
 
 
   99    NS_LOG_FUNCTION(
this << dest << 
" " << nextHop << 
" " << interface << 
" " << metric);
 
 
  121                                     std::vector<uint32_t> outputInterfaces)
 
  123    NS_LOG_FUNCTION(
this << origin << 
" " << group << 
" " << inputInterface << 
" " 
  124                         << &outputInterfaces);
 
 
  159                  "Ipv4StaticRouting::GetMulticastRoute ():  Index out of range");
 
 
  181    NS_LOG_FUNCTION(
this << origin << 
" " << group << 
" " << inputInterface);
 
 
  236    uint16_t longest_mask = 0;
 
  237    uint32_t shortest_metric = 0xffffffff;
 
  243            "Try to send on link-local multicast address, and no interface index is given!");
 
  246        rtentry->SetDestination(dest);
 
  248        rtentry->SetOutputDevice(oif);
 
  257        Ipv4Mask mask = (j)->GetDestNetworkMask();
 
  260        NS_LOG_LOGIC(
"Searching for route to " << dest << 
", checking against route to " << entry
 
  264            NS_LOG_LOGIC(
"Found global network route " << j << 
", mask length " << masklen
 
  265                                                       << 
", metric " << metric);
 
  274            if (masklen < longest_mask) 
 
  279            if (masklen > longest_mask) 
 
  281                shortest_metric = 0xffffffff;
 
  283            longest_mask = masklen;
 
  284            if (metric > shortest_metric)
 
  286                NS_LOG_LOGIC(
"Equal mask length, but previous metric shorter, skipping");
 
  289            shortest_metric = metric;
 
  293            rtentry->SetDestination(route->
GetDest());
 
  305        NS_LOG_LOGIC(
"Matching route via " << rtentry->GetGateway() << 
" at the end");
 
  309        NS_LOG_LOGIC(
"No matching route to " << dest << 
" found");
 
 
  334            NS_LOG_LOGIC(
"Found multicast source specific route" << *i);
 
  342                mrtentry->SetGroup(route->
GetGroup());
 
 
  375    uint32_t shortest_metric = 0xffffffff;
 
  381        Ipv4Mask mask = (j)->GetDestNetworkMask();
 
  387        if (metric > shortest_metric)
 
  391        shortest_metric = metric;
 
 
  501                         << idev << &ucb << &mcb << &lcb << &ecb);
 
  520            mcb(mrtentry, p, ipHeader); 
 
  535            lcb(p, ipHeader, iif);
 
  560        NS_LOG_LOGIC(
"Found unicast destination- calling unicast callback");
 
  561        ucb(rtentry, p, ipHeader); 
 
  566        NS_LOG_LOGIC(
"Did not find unicast destination- returning false");
 
 
  621        if (it->first->GetInterface() == i)
 
 
  642    Ipv4Address networkAddress = address.GetLocal().CombineMask(address.GetMask());
 
  643    Ipv4Mask networkMask = address.GetMask();
 
 
  658    Ipv4Address networkAddress = address.GetLocal().CombineMask(address.GetMask());
 
  659    Ipv4Mask networkMask = address.GetMask();
 
  664        if (it->first->GetInterface() == 
interface && it->first->IsNetwork() &&
 
  665            it->first->GetDestNetwork() == networkAddress &&
 
  666            it->first->GetDestNetworkMask() == networkMask)
 
 
  702    std::ostream* os = stream->GetStream();
 
  704    std::ios oldState(
nullptr);
 
  705    oldState.copyfmt(*os);
 
  707    *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
 
  711        << 
", Ipv4StaticRouting table" << std::endl;
 
  715        *os << 
"Destination     Gateway         Genmask         Flags Metric Ref    Use Iface" 
  719            std::ostringstream dest;
 
  720            std::ostringstream gw;
 
  721            std::ostringstream mask;
 
  722            std::ostringstream flags;
 
  725            *os << std::setw(16) << dest.str();
 
  727            *os << std::setw(16) << gw.str();
 
  729            *os << std::setw(16) << mask.str();
 
  739            *os << std::setw(6) << flags.str();
 
  760    (*os).copyfmt(oldState);
 
 
bool IsNull() const
Check for null implementation.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetZero()
Ipv4Address CombineMask(const Ipv4Mask &mask) const
Combine this address with a network mask.
bool IsLocalMulticast() const
virtual bool IsForwarding(uint32_t interface) const =0
virtual uint32_t GetNAddresses(uint32_t interface) const =0
virtual Ipv4InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
virtual Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
virtual bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const =0
Determine whether address and interface corresponding to received packet can be accepted for local de...
static const uint32_t IF_ANY
interface wildcard, meaning any interface
virtual int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const =0
virtual Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest)=0
Choose the source address to use with destination address.
virtual uint32_t GetNInterfaces() const =0
virtual bool IsUp(uint32_t interface) const =0
a class to store IPv4 address information on an interface
Ipv4Mask GetMask() const
Get the network mask.
Ipv4Address GetLocal() const
Get the local address.
a class to represent an Ipv4 address mask
static Ipv4Mask GetOnes()
uint16_t GetPrefixLength() const
bool IsMatch(Ipv4Address a, Ipv4Address b) const
static Ipv4Mask GetZero()
static const uint32_t MAX_TTL
Maximum time-to-live (TTL)
A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting.
Ipv4Address GetGroup() const
Ipv4Address GetOrigin() const
uint32_t GetOutputInterface(uint32_t n) const
static Ipv4MulticastRoutingTableEntry CreateMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector< uint32_t > outputInterfaces)
uint32_t GetNOutputInterfaces() const
uint32_t GetInputInterface() const
Abstract base class for IPv4 routing protocols.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Ipv4Address GetDest() const
Ipv4Address GetGateway() const
uint32_t GetInterface() const
static Ipv4RoutingTableEntry CreateNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface)
Ipv4Mask GetDestNetworkMask() const
Static routing protocol for IP version 4 stacks.
void SetIpv4(Ptr< Ipv4 > ipv4) override
void NotifyInterfaceUp(uint32_t interface) override
void DoDispose() override
Destructor implementation.
Ipv4RoutingTableEntry GetDefaultRoute()
Get the default route with lowest metric from the static routing table.
void RemoveRoute(uint32_t i)
Remove a route from the static unicast routing table.
~Ipv4StaticRouting() override
bool LookupRoute(const Ipv4RoutingTableEntry &route, uint32_t metric)
Checks if a route is already present in the forwarding table.
Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
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.
MulticastRoutes m_multicastRoutes
the forwarding table for multicast.
void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override
uint32_t GetMetric(uint32_t index) const
Get a metric for route from the static unicast routing table.
NetworkRoutes m_networkRoutes
the forwarding table for network.
Ptr< Ipv4Route > LookupStatic(Ipv4Address dest, Ptr< NetDevice > oif=nullptr)
Lookup in the forwarding table for destination.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
void AddNetworkRouteTo(Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a network route to the static routing table.
uint32_t GetNMulticastRoutes() const
Get the number of individual multicast routes that have been added to the routing table.
Ipv4RoutingTableEntry GetRoute(uint32_t i) const
Get a route from the static unicast routing table.
void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override
void NotifyInterfaceDown(uint32_t interface) override
bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb) override
Route an input packet (to be forwarded or locally delivered)
static TypeId GetTypeId()
The interface Id associated with this class.
Ptr< Ipv4 > m_ipv4
Ipv4 reference.
Ipv4MulticastRoutingTableEntry GetMulticastRoute(uint32_t i) const
Get a route from the static multicast routing table.
void AddHostRouteTo(Ipv4Address dest, Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a host route to the static routing table.
void SetDefaultRoute(Ipv4Address nextHop, uint32_t interface, uint32_t metric=0)
Add a default route to the static routing table.
uint32_t GetNRoutes() const
Get the number of individual unicast routes that have been added to the routing table.
bool RemoveMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface)
Remove a route from the static multicast routing table.
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,...
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
SocketErrno
Enumeration of the possible errors returned by a socket.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Unit
The unit to use to interpret a number representing time.
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_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.