A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::Ipv4L3Protocol Class Reference

Implement the Ipv4 layer. More...

#include <ipv4-l3-protocol.h>

+ Inheritance diagram for ns3::Ipv4L3Protocol:
+ Collaboration diagram for ns3::Ipv4L3Protocol:

Classes

class  Fragments
 A Set of Fragment belonging to the same packet (src, dst, identification and proto) More...

Public Types

enum  DropReason {
  DROP_TTL_EXPIRED = 1, DROP_NO_ROUTE, DROP_BAD_CHECKSUM, DROP_INTERFACE_DOWN,
  DROP_ROUTE_ERROR, DROP_FRAGMENT_TIMEOUT
}
 Reason why a packet has been dropped. More...

Public Member Functions

 Ipv4L3Protocol ()
virtual ~Ipv4L3Protocol ()
bool AddAddress (uint32_t i, Ipv4InterfaceAddress address)
uint32_t AddInterface (Ptr< NetDevice > device)
Ptr< SocketCreateRawSocket (void)
 Creates a raw socket.
void DeleteRawSocket (Ptr< Socket > socket)
 Deletes a particular raw socket.
Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const
Ptr< Ipv4InterfaceGetInterface (uint32_t i) const
int32_t GetInterfaceForAddress (Ipv4Address addr) const
 Return the interface number of the interface that has been assigned the specified IP address.
int32_t GetInterfaceForDevice (Ptr< const NetDevice > device) const
int32_t GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const
 Return the interface number of first interface found that has an Ipv4 address within the prefix specified by the input address and mask parameters.
uint16_t GetMetric (uint32_t i) const
uint16_t GetMtu (uint32_t i) const
uint32_t GetNAddresses (uint32_t interface) const
Ptr< NetDeviceGetNetDevice (uint32_t i)
uint32_t GetNInterfaces (void) const
Ptr< IpL4ProtocolGetProtocol (int protocolNumber) const
Ptr< Ipv4RoutingProtocolGetRoutingProtocol (void) const
 Get the routing protocol to be used by this Ipv4 stack.
void Insert (Ptr< IpL4Protocol > protocol)
bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const
 Determine whether address and interface corresponding to received packet can be accepted for local delivery.
bool IsForwarding (uint32_t i) const
bool IsUp (uint32_t i) const
void Receive (Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
void Remove (Ptr< IpL4Protocol > protocol)
bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex)
Ipv4Address SelectSourceAddress (Ptr< const NetDevice > device, Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
 Return the first primary source address with scope less than or equal to the requested scope, to use in sending a packet to destination dst out of the specified device.
void Send (Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
void SendWithHeader (Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)
void SetDefaultTtl (uint8_t ttl)
void SetDown (uint32_t i)
void SetForwarding (uint32_t i, bool val)
void SetMetric (uint32_t i, uint16_t metric)
void SetNode (Ptr< Node > node)
void SetRoutingProtocol (Ptr< Ipv4RoutingProtocol > routingProtocol)
 Register a new routing protocol to be used by this Ipv4 stack.
void SetUp (uint32_t i)
- Public Member Functions inherited from ns3::Ipv4
 Ipv4 ()
virtual ~Ipv4 ()
- Public Member Functions inherited from ns3::Object
 Object ()
virtual ~Object ()
void AggregateObject (Ptr< Object > other)
void Dispose (void)
AggregateIterator GetAggregateIterator (void) const
virtual TypeId GetInstanceTypeId (void) const
template<typename T >
Ptr< T > GetObject (void) const
template<typename T >
Ptr< T > GetObject (TypeId tid) const
void Start (void)
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 SimpleRefCount (const SimpleRefCount &o)
uint32_t GetReferenceCount (void) const
SimpleRefCountoperator= (const SimpleRefCount &o)
void Ref (void) const
void Unref (void) const
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
void GetAttribute (std::string name, AttributeValue &value) const
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
void SetAttribute (std::string name, const AttributeValue &value)
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::Ipv4L3Protocol.

Static Public Attributes

static const uint16_t PROT_NUMBER = 0x0800
- Static Public Attributes inherited from ns3::Ipv4
static const uint32_t IF_ANY = 0xffffffff

Protected Member Functions

virtual void DoDispose (void)
virtual void NotifyNewAggregate ()

Private Types

typedef std::vector< Ptr
< Ipv4Interface > > 
Ipv4InterfaceList
typedef std::list< Ptr
< IpL4Protocol > > 
L4List_t
typedef std::map< std::pair
< uint64_t, uint32_t >, Ptr
< Fragments > > 
MapFragments_t
typedef std::map< std::pair
< uint64_t, uint32_t >
, EventId
MapFragmentsTimers_t
typedef std::list< Ptr
< Ipv4RawSocketImpl > > 
SocketList

Private Member Functions

 Ipv4L3Protocol (const Ipv4L3Protocol &)
uint32_t AddIpv4Interface (Ptr< Ipv4Interface > interface)
Ipv4Header BuildHeader (Ipv4Address source, Ipv4Address destination, uint8_t protocol, uint16_t payloadSize, uint8_t ttl, bool mayFragment)
void DoFragmentation (Ptr< Packet > packet, uint32_t outIfaceMtu, std::list< Ptr< Packet > > &listFragments)
 Fragment a packet.
Ptr< Icmpv4L4ProtocolGetIcmp (void) const
 Get ICMPv4 protocol.
virtual bool GetIpForward (void) const
virtual bool GetWeakEsModel (void) const
void HandleFragmentsTimeout (std::pair< uint64_t, uint32_t > key, Ipv4Header &ipHeader, uint32_t iif)
 Process the timeout for packet fragments.
void IpForward (Ptr< Ipv4Route > rtentry, Ptr< const Packet > p, const Ipv4Header &header)
void IpMulticastForward (Ptr< Ipv4MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv4Header &header)
bool IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const
void LocalDeliver (Ptr< const Packet > p, Ipv4Header const &ip, uint32_t iif)
Ipv4L3Protocoloperator= (const Ipv4L3Protocol &)
bool ProcessFragment (Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif)
 Process a packet fragment.
void RouteInputError (Ptr< const Packet > p, const Ipv4Header &ipHeader, Socket::SocketErrno sockErrno)
void SendRealOut (Ptr< Ipv4Route > route, Ptr< Packet > packet, Ipv4Header const &ipHeader)
virtual void SetIpForward (bool forward)
void SetupLoopback (void)
virtual void SetWeakEsModel (bool model)

Private Attributes

uint8_t m_defaultTtl
TracedCallback< const
Ipv4Header &, Ptr< const
Packet >, DropReason, Ptr
< Ipv4 >, uint32_t > 
m_dropTrace
Time m_fragmentExpirationTimeout
MapFragments_t m_fragments
 The hash of fragmented packets.
MapFragmentsTimers_t m_fragmentsTimers
uint16_t m_identification
Ipv4InterfaceList m_interfaces
bool m_ipForward
TracedCallback< const
Ipv4Header &, Ptr< const
Packet >, uint32_t > 
m_localDeliverTrace
Ptr< Nodem_node
L4List_t m_protocols
Ptr< Ipv4RoutingProtocolm_routingProtocol
TracedCallback< Ptr< const
Packet >, Ptr< Ipv4 >
, uint32_t > 
m_rxTrace
TracedCallback< const
Ipv4Header &, Ptr< const
Packet >, uint32_t > 
m_sendOutgoingTrace
SocketList m_sockets
TracedCallback< Ptr< const
Packet >, Ptr< Ipv4 >
, uint32_t > 
m_txTrace
TracedCallback< const
Ipv4Header &, Ptr< const
Packet >, uint32_t > 
m_unicastForwardTrace
bool m_weakEsModel

Friends

class Ipv4L3ProtocolTestCase

Detailed Description

Implement the Ipv4 layer.

This is the actual implementation of IP. It contains APIs to send and receive packets at the IP layer, as well as APIs for IP routing.

This class contains two distinct groups of trace sources. The trace sources 'Rx' and 'Tx' are called, respectively, immediately after receiving from the NetDevice and immediately before sending to a NetDevice for transmitting a packet. These are low level trace sources that include the Ipv4Header already serialized into the packet. In contrast, the Drop, SendOutgoing, UnicastForward, and LocalDeliver trace sources are slightly higher-level and pass around the Ipv4Header as an explicit parameter and not as part of the packet.

IP fragmentation and reassembly is handled at this level. At the moment the fragmentation does not handle IP option headers, and in particular the ones that shall not be fragmented. Moreover, the actual implementation does not mimic exactly the Linux kernel. Hence it is not possible, for instance, to test a fragmentation attack.

Definition at line 77 of file ipv4-l3-protocol.h.

Member Typedef Documentation

Definition at line 292 of file ipv4-l3-protocol.h.

Definition at line 294 of file ipv4-l3-protocol.h.

typedef std::map< std::pair<uint64_t, uint32_t>, Ptr<Fragments> > ns3::Ipv4L3Protocol::MapFragments_t
private

Definition at line 374 of file ipv4-l3-protocol.h.

typedef std::map< std::pair<uint64_t, uint32_t>, EventId > ns3::Ipv4L3Protocol::MapFragmentsTimers_t
private

Definition at line 375 of file ipv4-l3-protocol.h.

Definition at line 293 of file ipv4-l3-protocol.h.

Member Enumeration Documentation

Reason why a packet has been dropped.

Enumerator:
DROP_TTL_EXPIRED 

Packet TTL has expired

DROP_NO_ROUTE 

No route to host

DROP_BAD_CHECKSUM 

Bad checksum

DROP_INTERFACE_DOWN 

Interface is down so can not send packet

DROP_ROUTE_ERROR 

Route error

DROP_FRAGMENT_TIMEOUT 

Fragment timeout exceeded

Definition at line 90 of file ipv4-l3-protocol.h.

Constructor & Destructor Documentation

ns3::Ipv4L3Protocol::Ipv4L3Protocol ( )

Definition at line 88 of file ipv4-l3-protocol.cc.

References NS_LOG_FUNCTION.

ns3::Ipv4L3Protocol::~Ipv4L3Protocol ( )
virtual

Definition at line 94 of file ipv4-l3-protocol.cc.

References NS_LOG_FUNCTION.

ns3::Ipv4L3Protocol::Ipv4L3Protocol ( const Ipv4L3Protocol )
private

Member Function Documentation

bool ns3::Ipv4L3Protocol::AddAddress ( uint32_t  interface,
Ipv4InterfaceAddress  address 
)
virtual
Parameters
interfaceInterface number of an Ipv4 interface
addressIpv4InterfaceAddress address to associate with the underlying Ipv4 interface
Returns
true if the operation succeeded

Implements ns3::Ipv4.

Definition at line 904 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Interface::AddAddress(), GetInterface(), m_routingProtocol, ns3::Ipv4RoutingProtocol::NotifyAddAddress(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

uint32_t ns3::Ipv4L3Protocol::AddInterface ( Ptr< NetDevice device)
virtual
Parameters
devicedevice to add to the list of Ipv4 interfaces which can be used as output interfaces during packet forwarding.
Returns
the index of the Ipv4 interface added.

Once a device has been added, it can never be removed: if you want to disable it, you can invoke Ipv4::SetDown which will make sure that it is never used during packet forwarding.

Implements ns3::Ipv4.

Definition at line 268 of file ipv4-l3-protocol.cc.

References AddIpv4Interface(), ns3::CreateObject(), m_ipForward, m_node, ns3::MakeCallback(), NS_LOG_FUNCTION, ns3::PeekPointer(), ns3::ArpL3Protocol::PROT_NUMBER, PROT_NUMBER, ns3::ArpL3Protocol::Receive(), Receive(), and ns3::Node::RegisterProtocolHandler().

+ Here is the call graph for this function:

uint32_t ns3::Ipv4L3Protocol::AddIpv4Interface ( Ptr< Ipv4Interface interface)
private

Definition at line 286 of file ipv4-l3-protocol.cc.

References m_interfaces, and NS_LOG_FUNCTION.

Referenced by AddInterface(), and SetupLoopback().

+ Here is the caller graph for this function:

Ipv4Header ns3::Ipv4L3Protocol::BuildHeader ( Ipv4Address  source,
Ipv4Address  destination,
uint8_t  protocol,
uint16_t  payloadSize,
uint8_t  ttl,
bool  mayFragment 
)
private
Ptr< Socket > ns3::Ipv4L3Protocol::CreateRawSocket ( void  )
virtual

Creates a raw socket.

Returns
a smart pointer to the instantiated raw socket

Implements ns3::Ipv4.

Definition at line 131 of file ipv4-l3-protocol.cc.

References m_node, m_sockets, NS_LOG_FUNCTION, and ns3::Ipv4RawSocketImpl::SetNode().

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::DeleteRawSocket ( Ptr< Socket socket)
virtual

Deletes a particular raw socket.

Parameters
socketSmart pointer to the raw socket to be deleted

Implements ns3::Ipv4.

Definition at line 140 of file ipv4-l3-protocol.cc.

References m_sockets, and NS_LOG_FUNCTION.

void ns3::Ipv4L3Protocol::DoDispose ( void  )
protectedvirtual

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

It is safe to call GetObject from within this method.

Reimplemented from ns3::Object.

Definition at line 189 of file ipv4-l3-protocol.cc.

References m_fragments, m_fragmentsTimers, m_interfaces, m_node, m_protocols, m_routingProtocol, m_sockets, and NS_LOG_FUNCTION.

void ns3::Ipv4L3Protocol::DoFragmentation ( Ptr< Packet packet,
uint32_t  outIfaceMtu,
std::list< Ptr< Packet > > &  listFragments 
)
private
Ipv4InterfaceAddress ns3::Ipv4L3Protocol::GetAddress ( uint32_t  interface,
uint32_t  addressIndex 
) const
virtual

Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to this method.

Parameters
interfaceInterface number of an Ipv4 interface
addressIndexindex of Ipv4InterfaceAddress
Returns
the Ipv4InterfaceAddress associated to the interface and addressIndex

Implements ns3::Ipv4.

Definition at line 917 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Interface::GetAddress(), and GetInterface().

Referenced by IsDestinationAddress(), LocalDeliver(), ns3::aodv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyAddAddress(), ns3::aodv::RoutingProtocol::NotifyRemoveAddress(), ns3::dsdv::RoutingProtocol::NotifyRemoveAddress(), SelectSourceAddress(), Send(), and ns3::dsr::DsrRouting::Start().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ptr< Icmpv4L4Protocol > ns3::Ipv4L3Protocol::GetIcmp ( void  ) const
private

Get ICMPv4 protocol.

Returns
Icmpv4L4Protocol pointer

Definition at line 510 of file ipv4-l3-protocol.cc.

References ns3::Object::GetObject(), GetProtocol(), and ns3::Icmpv4L4Protocol::GetStaticProtocolNumber().

Referenced by HandleFragmentsTimeout(), IpForward(), and LocalDeliver().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t ns3::Ipv4L3Protocol::GetInterfaceForAddress ( Ipv4Address  address) const
virtual

Return the interface number of the interface that has been assigned the specified IP address.

Parameters
addressThe IP address being searched for
Returns
The interface number of the Ipv4 interface with the given address or -1 if not found.

Each IP interface has one or more IP addresses associated with it. This method searches the list of interfaces for one that holds a particular address. This call takes an IP address as a parameter and returns the interface number of the first interface that has been assigned that address, or -1 if not found. There must be an exact match; this method will not match broadcast or multicast addresses.

Implements ns3::Ipv4.

Definition at line 311 of file ipv4-l3-protocol.cc.

References m_interfaces.

Referenced by ns3::dsr::DsrRouting::SendReply(), and ns3::dsr::DsrRouting::Start().

+ Here is the caller graph for this function:

int32_t ns3::Ipv4L3Protocol::GetInterfaceForDevice ( Ptr< const NetDevice device) const
virtual
Parameters
deviceThe NetDevice for an Ipv4Interface
Returns
The interface number of an Ipv4 interface or -1 if not found.

Implements ns3::Ipv4.

Definition at line 354 of file ipv4-l3-protocol.cc.

References m_interfaces.

Referenced by IpForward(), SelectSourceAddress(), Send(), and SendRealOut().

+ Here is the caller graph for this function:

int32_t ns3::Ipv4L3Protocol::GetInterfaceForPrefix ( Ipv4Address  address,
Ipv4Mask  mask 
) const
virtual

Return the interface number of first interface found that has an Ipv4 address within the prefix specified by the input address and mask parameters.

Parameters
addressThe IP address assigned to the interface of interest.
maskThe IP prefix to use in the mask
Returns
The interface number of the Ipv4 interface with the given address or -1 if not found.

Each IP interface has one or more IP addresses associated with it. This method searches the list of interfaces for the first one found that holds an address that is included within the prefix formed by the input address and mask parameters. The value -1 is returned if no match is found.

Implements ns3::Ipv4.

Definition at line 332 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Address::CombineMask(), and m_interfaces.

+ Here is the call graph for this function:

bool ns3::Ipv4L3Protocol::GetIpForward ( void  ) const
privatevirtual

Definition at line 1090 of file ipv4-l3-protocol.cc.

References m_ipForward.

uint16_t ns3::Ipv4L3Protocol::GetMetric ( uint32_t  interface) const
virtual
Parameters
interfaceThe interface number of an Ipv4 interface
Returns
routing metric (cost) associated to the underlying Ipv4 interface

Implements ns3::Ipv4.

Definition at line 1009 of file ipv4-l3-protocol.cc.

References GetInterface(), and ns3::Ipv4Interface::GetMetric().

+ Here is the call graph for this function:

uint16_t ns3::Ipv4L3Protocol::GetMtu ( uint32_t  interface) const
virtual
Parameters
interfaceInterface number of Ipv4 interface
Returns
the Maximum Transmission Unit (in bytes) associated to the underlying Ipv4 interface

Implements ns3::Ipv4.

Definition at line 1016 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Interface::GetDevice(), GetInterface(), and ns3::NetDevice::GetMtu().

+ Here is the call graph for this function:

uint32_t ns3::Ipv4L3Protocol::GetNAddresses ( uint32_t  interface) const
virtual
Parameters
interfaceInterface number of an Ipv4 interface
Returns
the number of Ipv4InterfaceAddress entries for the interface.

Implements ns3::Ipv4.

Definition at line 924 of file ipv4-l3-protocol.cc.

References GetInterface(), and ns3::Ipv4Interface::GetNAddresses().

Referenced by IsDestinationAddress(), LocalDeliver(), ns3::aodv::RoutingProtocol::NotifyAddAddress(), ns3::aodv::RoutingProtocol::NotifyRemoveAddress(), ns3::dsdv::RoutingProtocol::NotifyRemoveAddress(), SelectSourceAddress(), and Send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ptr< NetDevice > ns3::Ipv4L3Protocol::GetNetDevice ( uint32_t  interface)
virtual
Parameters
interfaceThe interface number of an Ipv4 interface.
Returns
The NetDevice associated with the Ipv4 interface number.

Implements ns3::Ipv4.

Definition at line 1073 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Interface::GetDevice(), and GetInterface().

Referenced by ns3::dsr::DsrRouting::DoDispose(), IpMulticastForward(), ns3::aodv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyInterfaceDown(), ns3::dsr::DsrRouting::SendReply(), and ns3::dsr::DsrRouting::Start().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32_t ns3::Ipv4L3Protocol::GetNInterfaces ( void  ) const
virtual
Returns
the number of interfaces added by the user.

Implements ns3::Ipv4.

Definition at line 305 of file ipv4-l3-protocol.cc.

References m_interfaces.

Referenced by ns3::dsr::DsrRouting::DoDispose(), IsDestinationAddress(), SelectSourceAddress(), and ns3::dsr::DsrRouting::Start().

+ Here is the caller graph for this function:

Ptr< IpL4Protocol > ns3::Ipv4L3Protocol::GetProtocol ( int  protocolNumber) const
virtual
Parameters
protocolNumbernumber of protocol to lookup in this L4 Demux
Returns
a matching L4 Protocol

This method is typically called by lower layers to forward packets up the stack to the right protocol.

Implements ns3::Ipv4.

Definition at line 105 of file ipv4-l3-protocol.cc.

References m_protocols.

Referenced by GetIcmp(), LocalDeliver(), and ns3::dsr::DsrRouting::Receive().

+ Here is the caller graph for this function:

Ptr< Ipv4RoutingProtocol > ns3::Ipv4L3Protocol::GetRoutingProtocol ( void  ) const
virtual

Get the routing protocol to be used by this Ipv4 stack.

Returns
smart pointer to Ipv4RoutingProtocol object, or null pointer if none

Implements ns3::Ipv4.

Definition at line 183 of file ipv4-l3-protocol.cc.

References m_routingProtocol.

TypeId ns3::Ipv4L3Protocol::GetTypeId ( void  )
static

This method returns the TypeId associated to ns3::Ipv4L3Protocol.

This object is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/$ns3::Ipv4L3Protocol

Attributes defined for this type:

  • DefaultTtl: The TTL value set by default on all outgoing packets generated on this node.
  • FragmentExpirationTimeout: When this timeout expires, the fragments will be cleared from the buffer.
    • Set with class: TimeValue
    • Underlying type: Time
    • Initial value: +30000000000.0ns
    • Flags: construct write read
  • InterfaceList: The set of Ipv4 interfaces associated to this Ipv4 stack.

Attributes defined in parent class ns3::Ipv4:

  • IpForward: Globally enable or disable IP forwarding for all current and future Ipv4 devices.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: construct write read
  • WeakEsModel: RFC1122 term for whether host accepts datagram with a dest. address on another interface
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: construct write read

TraceSources defined for this type:

  • Tx: Send ipv4 packet to outgoing interface.
  • Rx: Receive ipv4 packet from incoming interface.
  • Drop: Drop ipv4 packet
  • SendOutgoing: A newly-generated packet by this node is about to be queued for transmission
  • UnicastForward: A unicast IPv4 packet was received by this node and is being forwarded to another node
  • LocalDeliver: An IPv4 packet was received by/for this node, and it is being forward up the stack

Reimplemented from ns3::Ipv4.

Definition at line 52 of file ipv4-l3-protocol.cc.

References m_defaultTtl, m_dropTrace, m_fragmentExpirationTimeout, m_interfaces, m_localDeliverTrace, m_rxTrace, m_sendOutgoingTrace, m_txTrace, m_unicastForwardTrace, ns3::MakeObjectVectorAccessor(), ns3::MakeTraceSourceAccessor(), ns3::Seconds(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

bool ns3::Ipv4L3Protocol::GetWeakEsModel ( void  ) const
privatevirtual

Definition at line 1102 of file ipv4-l3-protocol.cc.

References m_weakEsModel.

Referenced by IsDestinationAddress().

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::HandleFragmentsTimeout ( std::pair< uint64_t, uint32_t >  key,
Ipv4Header ipHeader,
uint32_t  iif 
)
private

Process the timeout for packet fragments.

Parameters
keyrepresenting the packet fragments
ipHeaderthe IP header of the original packet
iifInput Interface

Definition at line 1392 of file ipv4-l3-protocol.cc.

References DROP_FRAGMENT_TIMEOUT, GetIcmp(), ns3::Object::GetObject(), ns3::Packet::GetSize(), m_dropTrace, m_fragments, m_fragmentsTimers, m_node, and NS_LOG_FUNCTION.

Referenced by ProcessFragment().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::Insert ( Ptr< IpL4Protocol protocol)
virtual
Parameters
protocola template for the protocol to add to this L4 Demux.
Returns
the L4Protocol effectively added.

Invoke Copy on the input template to get a copy of the input protocol which can be used on the Node on which this L4 Demux is running. The new L4Protocol is registered internally as a working L4 Protocol and returned from this method. The caller does not get ownership of the returned pointer.

Implements ns3::Ipv4.

Definition at line 100 of file ipv4-l3-protocol.cc.

References m_protocols.

Referenced by ns3::NscTcpL4Protocol::NotifyNewAggregate(), and ns3::dsr::DsrRouting::NotifyNewAggregate().

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::IpForward ( Ptr< Ipv4Route rtentry,
Ptr< const Packet p,
const Ipv4Header header 
)
private

Definition at line 815 of file ipv4-l3-protocol.cc.

References ns3::Packet::Copy(), DROP_TTL_EXPIRED, GetIcmp(), ns3::Node::GetId(), GetInterfaceForDevice(), ns3::Object::GetObject(), m_dropTrace, m_node, m_unicastForwardTrace, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Icmpv4L4Protocol::PROT_NUMBER, and SendRealOut().

Referenced by Receive().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::Ipv4L3Protocol::IsDestinationAddress ( Ipv4Address  address,
uint32_t  iif 
) const
virtual

Determine whether address and interface corresponding to received packet can be accepted for local delivery.

Parameters
addressThe IP address being considered
iifThe incoming Ipv4 interface index

This method can be used to determine whether a received packet has an acceptable address for local delivery on the host. The address may be a unicast, multicast, or broadcast address. This method will return true if address is an exact match of a unicast address on one of the host's interfaces (see below), if address corresponds to a multicast group that the host has joined (and the incoming device is acceptable), or if address corresponds to a broadcast address.

If the Ipv4 attribute WeakEsModel is true, the unicast address may match any of the Ipv4 addresses on any interface. If the attribute is false, the address must match one assigned to the incoming device.

Implements ns3::Ipv4.

Definition at line 372 of file ipv4-l3-protocol.cc.

References GetAddress(), ns3::Ipv4InterfaceAddress::GetBroadcast(), ns3::Ipv4InterfaceAddress::GetLocal(), GetNAddresses(), GetNInterfaces(), GetWeakEsModel(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsMulticast(), and NS_LOG_LOGIC.

+ Here is the call graph for this function:

bool ns3::Ipv4L3Protocol::IsForwarding ( uint32_t  interface) const
virtual
Parameters
interfaceInterface number of Ipv4 interface
Returns
true if IP forwarding enabled for input datagrams on this device

Implements ns3::Ipv4.

Definition at line 1056 of file ipv4-l3-protocol.cc.

References GetInterface(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

bool ns3::Ipv4L3Protocol::IsUnicast ( Ipv4Address  ad,
Ipv4Mask  interfaceMask 
) const
private

Definition at line 524 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Address::IsMulticast(), and ns3::Ipv4Address::IsSubnetDirectedBroadcast().

+ Here is the call graph for this function:

bool ns3::Ipv4L3Protocol::IsUp ( uint32_t  interface) const
virtual
Parameters
interfaceInterface number of Ipv4 interface
Returns
true if the underlying interface is in the "up" state, false otherwise.

Implements ns3::Ipv4.

Definition at line 1023 of file ipv4-l3-protocol.cc.

References GetInterface(), and ns3::Ipv4Interface::IsUp().

Referenced by ns3::aodv::RoutingProtocol::NotifyAddAddress(), and ns3::dsdv::RoutingProtocol::NotifyAddAddress().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::NotifyNewAggregate ( void  )
protectedvirtual

This function will notify other components connected to the node that a new stack member is now connected This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.

Reimplemented from ns3::Object.

Definition at line 158 of file ipv4-l3-protocol.cc.

References m_node, and SetNode().

+ Here is the call graph for this function:

Ipv4L3Protocol& ns3::Ipv4L3Protocol::operator= ( const Ipv4L3Protocol )
private
bool ns3::Ipv4L3Protocol::ProcessFragment ( Ptr< Packet > &  packet,
Ipv4Header ipHeader,
uint32_t  iif 
)
private
void ns3::Ipv4L3Protocol::Receive ( Ptr< NetDevice device,
Ptr< const Packet p,
uint16_t  protocol,
const Address from,
const Address to,
NetDevice::PacketType  packetType 
)

Lower layer calls this method after calling L3Demux::Lookup The ARP subclass needs to know from which NetDevice this packet is coming to:

  • implement a per-NetDevice ARP cache
  • send back arp replies on the right device
    Parameters
    devicenetwork device
    pthe packet
    protocolprotocol value
    fromaddress of the correspondant
    toaddress of the destination
    packetTypetype of the packet

Definition at line 434 of file ipv4-l3-protocol.cc.

References ns3::Node::ChecksumEnabled(), ns3::Packet::Copy(), DROP_BAD_CHECKSUM, DROP_INTERFACE_DOWN, DROP_NO_ROUTE, ns3::Ipv4Header::EnableChecksum(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::Ipv4Interface::GetDevice(), ns3::Node::GetId(), ns3::Object::GetObject(), ns3::Ipv4Header::GetPayloadSize(), IpForward(), IpMulticastForward(), ns3::Ipv4Header::IsChecksumOk(), ns3::Ipv4Interface::IsUp(), LocalDeliver(), m_dropTrace, m_interfaces, m_node, m_routingProtocol, m_rxTrace, m_sockets, ns3::MakeCallback(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Ipv4RoutingProtocol::RouteInput(), and RouteInputError().

Referenced by AddInterface(), ns3::Ipv4Interface::Send(), and SetupLoopback().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::Remove ( Ptr< IpL4Protocol protocol)
Parameters
protocolprotocol to remove from this demux.

The input value to this method should be the value returned from the Ipv4L4Protocol::Insert method.

Definition at line 117 of file ipv4-l3-protocol.cc.

References m_protocols.

bool ns3::Ipv4L3Protocol::RemoveAddress ( uint32_t  interface,
uint32_t  addressIndex 
)
virtual

Remove the address at addressIndex on named interface. The addressIndex for all higher indices will decrement by one after this method is called; so, for example, to remove 5 addresses from an interface i, one could call RemoveAddress (i, 0); 5 times.

Parameters
interfaceInterface number of an Ipv4 interface
addressIndexindex of Ipv4InterfaceAddress to remove
Returns
true if the operation succeeded

Implements ns3::Ipv4.

Definition at line 931 of file ipv4-l3-protocol.cc.

References GetInterface(), m_routingProtocol, ns3::Ipv4RoutingProtocol::NotifyRemoveAddress(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::RouteInputError ( Ptr< const Packet p,
const Ipv4Header ipHeader,
Socket::SocketErrno  sockErrno 
)
private

Definition at line 1108 of file ipv4-l3-protocol.cc.

References DROP_ROUTE_ERROR, ns3::Object::GetObject(), m_dropTrace, m_node, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by Receive().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ipv4Address ns3::Ipv4L3Protocol::SelectSourceAddress ( Ptr< const NetDevice device,
Ipv4Address  dst,
Ipv4InterfaceAddress::InterfaceAddressScope_e  scope 
)
virtual

Return the first primary source address with scope less than or equal to the requested scope, to use in sending a packet to destination dst out of the specified device.

This method mirrors the behavior of Linux inet_select_addr() and is provided because interfaces may have multiple IP addresses configured on them with different scopes, and with a primary and secondary status. Secondary addresses are never returned.

See Also
Ipv4InterfaceAddress

If a non-zero device pointer is provided, the method first tries to return a primary address that is configured on that device, and whose subnet matches that of dst and whose scope is less than or equal to the requested scope. If a primary address does not match the subnet of dst but otherwise matches the scope, it is returned. If no such address on the device is found, the other devices are searched in order of their interface index, but not considering dst as a factor in the search. Because a loopback interface is typically the first one configured on a node, it will be the first alternate device to be tried. Addresses scoped at LINK scope are not returned in this phase.

If no device pointer is provided, the same logic as above applies, only that there is no preferred device that is consulted first. This means that if the device pointer is null, input parameter dst will be ignored.

If there are no possible addresses to return, a warning log message is issued and the all-zeroes address is returned.

Parameters
deviceoutput NetDevice (optionally provided, only to constrain the search)
dstDestination address to match, if device is provided
scopeScope of returned address must be less than or equal to this
Returns
the first primary Ipv4Address that meets the search criteria

Implements ns3::Ipv4.

Definition at line 948 of file ipv4-l3-protocol.cc.

References ns3::Ipv4Address::CombineMask(), GetAddress(), GetInterfaceForDevice(), ns3::Ipv4InterfaceAddress::GetLocal(), ns3::Ipv4InterfaceAddress::GetMask(), GetNAddresses(), GetNInterfaces(), ns3::Ipv4InterfaceAddress::GetScope(), ns3::Ipv4InterfaceAddress::IsSecondary(), ns3::Ipv4InterfaceAddress::LINK, NS_ASSERT_MSG, NS_LOG_FUNCTION, and NS_LOG_WARN.

Referenced by ns3::ArpL3Protocol::SendArpRequest().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::Send ( Ptr< Packet packet,
Ipv4Address  source,
Ipv4Address  destination,
uint8_t  protocol,
Ptr< Ipv4Route route 
)
virtual
void ns3::Ipv4L3Protocol::SendWithHeader ( Ptr< Packet packet,
Ipv4Header  ipHeader,
Ptr< Ipv4Route route 
)
virtual
Parameters
packetpacket to send
ipHeaderIP Header
routeroute entry

Higher-level layers call this method to send a packet with IPv4 Header (Intend to be used with IpHeaderInclude attribute.)

Implements ns3::Ipv4.

Definition at line 530 of file ipv4-l3-protocol.cc.

References NS_LOG_FUNCTION, and SendRealOut().

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::SetDefaultTtl ( uint8_t  ttl)
Parameters
ttldefault ttl to use

When we need to send an ipv4 packet, we use this default ttl value.

Definition at line 262 of file ipv4-l3-protocol.cc.

References m_defaultTtl.

void ns3::Ipv4L3Protocol::SetDown ( uint32_t  interface)
virtual
Parameters
interfaceInterface number of Ipv4 interface

Set the interface into the "down" state. In this state, it is ignored during Ipv4 forwarding.

Implements ns3::Ipv4.

Definition at line 1043 of file ipv4-l3-protocol.cc.

References GetInterface(), m_routingProtocol, ns3::Ipv4RoutingProtocol::NotifyInterfaceDown(), NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetDown().

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::SetForwarding ( uint32_t  interface,
bool  val 
)
virtual
Parameters
interfaceInterface number of Ipv4 interface
valValue to set the forwarding flag

If set to true, IP forwarding is enabled for input datagrams on this device

Implements ns3::Ipv4.

Definition at line 1065 of file ipv4-l3-protocol.cc.

References GetInterface(), NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetForwarding().

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::SetIpForward ( bool  forward)
privatevirtual

Definition at line 1079 of file ipv4-l3-protocol.cc.

References m_interfaces, m_ipForward, and NS_LOG_FUNCTION.

void ns3::Ipv4L3Protocol::SetMetric ( uint32_t  interface,
uint16_t  metric 
)
virtual
Parameters
interfaceThe interface number of an Ipv4 interface
metricrouting metric (cost) associated to the underlying Ipv4 interface

Implements ns3::Ipv4.

Definition at line 1001 of file ipv4-l3-protocol.cc.

References GetInterface(), NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetMetric().

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::SetNode ( Ptr< Node node)

Definition at line 123 of file ipv4-l3-protocol.cc.

References m_node, and SetupLoopback().

Referenced by NotifyNewAggregate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::SetRoutingProtocol ( Ptr< Ipv4RoutingProtocol routingProtocol)
virtual

Register a new routing protocol to be used by this Ipv4 stack.

This call will replace any routing protocol that has been previously registered. If you want to add multiple routing protocols, you must add them to a Ipv4ListRoutingProtocol directly.

Parameters
routingProtocolsmart pointer to Ipv4RoutingProtocol object

Implements ns3::Ipv4.

Definition at line 174 of file ipv4-l3-protocol.cc.

References m_routingProtocol, NS_LOG_FUNCTION, and ns3::Ipv4RoutingProtocol::SetIpv4().

Referenced by ns3::AddInternetStack(), ns3::CreateDualStackNode(), and ns3::TcpTestCase::CreateInternetNode().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4L3Protocol::SetUp ( uint32_t  interface)
virtual
Parameters
interfaceInterface number of Ipv4 interface

Set the interface into the "up" state. In this state, it is considered valid during Ipv4 forwarding.

Implements ns3::Ipv4.

Definition at line 1030 of file ipv4-l3-protocol.cc.

References GetInterface(), m_routingProtocol, ns3::Ipv4RoutingProtocol::NotifyInterfaceUp(), NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetUp().

+ Here is the call graph for this function:

void ns3::Ipv4L3Protocol::SetupLoopback ( void  )
private
void ns3::Ipv4L3Protocol::SetWeakEsModel ( bool  model)
privatevirtual

Definition at line 1096 of file ipv4-l3-protocol.cc.

References m_weakEsModel.

Friends And Related Function Documentation

friend class Ipv4L3ProtocolTestCase
friend

Definition at line 221 of file ipv4-l3-protocol.h.

Member Data Documentation

uint8_t ns3::Ipv4L3Protocol::m_defaultTtl
private

Definition at line 300 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), Send(), and SetDefaultTtl().

TracedCallback<const Ipv4Header &, Ptr<const Packet>, DropReason, Ptr<Ipv4>, uint32_t> ns3::Ipv4L3Protocol::m_dropTrace
private
Time ns3::Ipv4L3Protocol::m_fragmentExpirationTimeout
private

Definition at line 381 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), and ProcessFragment().

MapFragmentsTimers_t ns3::Ipv4L3Protocol::m_fragmentsTimers
private

Definition at line 382 of file ipv4-l3-protocol.h.

Referenced by DoDispose(), HandleFragmentsTimeout(), and ProcessFragment().

uint16_t ns3::Ipv4L3Protocol::m_identification
private

Definition at line 301 of file ipv4-l3-protocol.h.

Referenced by BuildHeader().

bool ns3::Ipv4L3Protocol::m_ipForward
private

Definition at line 296 of file ipv4-l3-protocol.h.

Referenced by AddInterface(), GetIpForward(), and SetIpForward().

TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> ns3::Ipv4L3Protocol::m_localDeliverTrace
private

Definition at line 306 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), and LocalDeliver().

L4List_t ns3::Ipv4L3Protocol::m_protocols
private

Definition at line 298 of file ipv4-l3-protocol.h.

Referenced by DoDispose(), GetProtocol(), Insert(), and Remove().

Ptr<Ipv4RoutingProtocol> ns3::Ipv4L3Protocol::m_routingProtocol
private
TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> ns3::Ipv4L3Protocol::m_rxTrace
private

Definition at line 310 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), and Receive().

TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> ns3::Ipv4L3Protocol::m_sendOutgoingTrace
private

Definition at line 304 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), and Send().

SocketList ns3::Ipv4L3Protocol::m_sockets
private

Definition at line 316 of file ipv4-l3-protocol.h.

Referenced by CreateRawSocket(), DeleteRawSocket(), DoDispose(), and Receive().

TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> ns3::Ipv4L3Protocol::m_txTrace
private

Definition at line 309 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), Send(), and SendRealOut().

TracedCallback<const Ipv4Header &, Ptr<const Packet>, uint32_t> ns3::Ipv4L3Protocol::m_unicastForwardTrace
private

Definition at line 305 of file ipv4-l3-protocol.h.

Referenced by GetTypeId(), and IpForward().

bool ns3::Ipv4L3Protocol::m_weakEsModel
private

Definition at line 297 of file ipv4-l3-protocol.h.

Referenced by GetWeakEsModel(), and SetWeakEsModel().


The documentation for this class was generated from the following files: