A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Ipv4 Class Referenceabstract

Access to the IPv4 forwarding table, interfaces, and configuration. More...

#include "ipv4.h"

+ Inheritance diagram for ns3::Ipv4:
+ Collaboration diagram for ns3::Ipv4:

Public Member Functions

 Ipv4 ()
 
 ~Ipv4 () override
 
virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address)=0
 
virtual uint32_t AddInterface (Ptr< NetDevice > device)=0
 
virtual Ptr< SocketCreateRawSocket ()=0
 Creates a raw socket.
 
virtual void DeleteRawSocket (Ptr< Socket > socket)=0
 Deletes a particular raw socket.
 
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 this method.
 
virtual int32_t GetInterfaceForAddress (Ipv4Address address) const =0
 Return the interface number of the interface that has been assigned the specified IP address.
 
virtual int32_t GetInterfaceForDevice (Ptr< const NetDevice > device) const =0
 
virtual int32_t GetInterfaceForPrefix (Ipv4Address address, Ipv4Mask mask) const =0
 Return the interface number of first interface found that has an Ipv4 address within the prefix specified by the input address and mask parameters.
 
virtual uint16_t GetMetric (uint32_t interface) const =0
 
virtual uint16_t GetMtu (uint32_t interface) const =0
 
virtual uint32_t GetNAddresses (uint32_t interface) const =0
 
virtual Ptr< NetDeviceGetNetDevice (uint32_t interface)=0
 
virtual uint32_t GetNInterfaces () const =0
 
virtual Ptr< IpL4ProtocolGetProtocol (int protocolNumber) const =0
 
virtual Ptr< IpL4ProtocolGetProtocol (int protocolNumber, int32_t interfaceIndex) const =0
 Get L4 protocol by protocol number for the specified interface.
 
virtual Ptr< Ipv4RoutingProtocolGetRoutingProtocol () const =0
 Get the routing protocol to be used by this Ipv4 stack.
 
virtual void Insert (Ptr< IpL4Protocol > protocol)=0
 
virtual void Insert (Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex)=0
 Add a L4 protocol to a specific interface.
 
virtual bool IsDestinationAddress (Ipv4Address address, uint32_t iif) const =0
 Determine whether address and interface corresponding to received packet can be accepted for local delivery.
 
virtual bool IsForwarding (uint32_t interface) const =0
 
virtual bool IsUp (uint32_t interface) const =0
 
virtual void Remove (Ptr< IpL4Protocol > protocol)=0
 
virtual void Remove (Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex)=0
 Remove a L4 protocol from a specific interface.
 
virtual bool RemoveAddress (uint32_t interface, Ipv4Address address)=0
 Remove the given address on named Ipv4 interface.
 
virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex)=0
 Remove the address at addressIndex on named interface.
 
virtual Ipv4Address SelectSourceAddress (Ptr< const NetDevice > device, Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope)=0
 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.
 
virtual void Send (Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)=0
 
virtual void SendWithHeader (Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)=0
 
virtual void SetDown (uint32_t interface)=0
 
virtual void SetForwarding (uint32_t interface, bool val)=0
 
virtual void SetMetric (uint32_t interface, uint16_t metric)=0
 
virtual void SetRoutingProtocol (Ptr< Ipv4RoutingProtocol > routingProtocol)=0
 Register a new routing protocol to be used by this Ipv4 stack.
 
virtual void SetUp (uint32_t interface)=0
 
virtual Ipv4Address SourceAddressSelection (uint32_t interface, Ipv4Address dest)=0
 Choose the source address to use with destination address.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Static Public Attributes

static const uint32_t IF_ANY = 0xffffffff
 interface wildcard, meaning any interface
 

Private Member Functions

virtual bool GetIpForward () const =0
 Get the IP forwarding state.
 
virtual bool GetStrongEndSystemModel () const =0
 Get the Strong End System Model status.
 
virtual bool GetWeakEsModel () const =0
 Get the Weak Es Model status.
 
virtual void SetIpForward (bool forward)=0
 Set or unset the IP forwarding state.
 
virtual void SetStrongEndSystemModel (bool model)=0
 Set or unset the Strong End System Model.
 
virtual void SetWeakEsModel (bool model)=0
 Set or unset the Weak Es Model.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

Access to the IPv4 forwarding table, interfaces, and configuration.

Introspection did not find any typical Config paths.

This class defines the API to manipulate the following aspects of the IPv4 implementation:

  1. set/get an Ipv4RoutingProtocol
  2. register a NetDevice for use by the Ipv4 layer (basically, to create Ipv4-related state such as addressing and neighbor cache that is associated with a NetDevice)
  3. manipulate the status of the NetDevice from the Ipv4 perspective, such as marking it as Up or Down,
  4. adding, deleting, and getting addresses associated to the Ipv4 interfaces.
  5. exporting Ipv4 configuration attributes

Each NetDevice has conceptually a single Ipv4 interface associated with it (the corresponding structure in the Linux Ipv4 implementation is struct in_device). Each interface may have one or more Ipv4 addresses associated with it. Each Ipv4 address may have different subnet mask, scope, etc., so all of this per-address information is stored in an Ipv4InterfaceAddress class (the corresponding structure in Linux is struct in_ifaddr)

Ipv4 attributes such as whether IP forwarding is enabled and disabled are also stored in this class

TO DO: Add API to allow access to the Ipv4 neighbor table

See also
Ipv4RoutingProtocol
Ipv4InterfaceAddress


Attributes

  • IpForward: Globally enable or disable IP forwarding for all current and future Ipv4 devices.
    • Set with class: ns3::BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: constructwriteread
  • StrongEndSystemModel: Reject packets for an address not configured on the interface they're coming from (RFC1122, section 3.3.4.2).
    • Set with class: ns3::BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: constructwriteread
  • WeakEsModel: RFC1122 term for whether host accepts datagram with a dest. address on another interface
    • Set with class: ns3::BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: constructwriteread

No TraceSources are defined for this type.
Size of this type is 56 bytes (on a 64-bit architecture).

Definition at line 79 of file ipv4.h.

Constructor & Destructor Documentation

◆ Ipv4()

ns3::Ipv4::Ipv4 ( )

Definition at line 76 of file ipv4.cc.

References NS_LOG_FUNCTION.

◆ ~Ipv4()

ns3::Ipv4::~Ipv4 ( )
override

Definition at line 81 of file ipv4.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddAddress()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ AddInterface()

virtual uint32_t ns3::Ipv4::AddInterface ( Ptr< NetDevice device)
pure 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.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ CreateRawSocket()

virtual Ptr< Socket > ns3::Ipv4::CreateRawSocket ( )
pure virtual

Creates a raw socket.

Returns
a smart pointer to the instantiated raw socket

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ DeleteRawSocket()

virtual void ns3::Ipv4::DeleteRawSocket ( Ptr< Socket socket)
pure virtual

Deletes a particular raw socket.

Parameters
socketSmart pointer to the raw socket to be deleted

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetAddress()

virtual Ipv4InterfaceAddress ns3::Ipv4::GetAddress ( uint32_t  interface,
uint32_t  addressIndex 
) const
pure 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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetInterfaceForAddress()

virtual int32_t ns3::Ipv4::GetInterfaceForAddress ( Ipv4Address  address) const
pure 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.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetInterfaceForDevice()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetInterfaceForPrefix()

virtual int32_t ns3::Ipv4::GetInterfaceForPrefix ( Ipv4Address  address,
Ipv4Mask  mask 
) const
pure 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.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetIpForward()

virtual bool ns3::Ipv4::GetIpForward ( ) const
privatepure virtual

Get the IP forwarding state.

Returns
true if IP is in forwarding state

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetMetric()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetMtu()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetNAddresses()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetNetDevice()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetNInterfaces()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by ns3::NoBackhaulEpcHelper::NoBackhaulEpcHelper(), ns3::EmuEpcHelper::AddEnb(), ns3::NoBackhaulEpcHelper::AddEnb(), ns3::PointToPointEpcHelper::AddEnb(), and ns3::NoBackhaulEpcHelper::AddX2Interface().

+ Here is the caller graph for this function:

◆ GetProtocol() [1/2]

virtual Ptr< IpL4Protocol > ns3::Ipv4::GetProtocol ( int  protocolNumber) const
pure 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.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetProtocol() [2/2]

virtual Ptr< IpL4Protocol > ns3::Ipv4::GetProtocol ( int  protocolNumber,
int32_t  interfaceIndex 
) const
pure virtual

Get L4 protocol by protocol number for the specified interface.

Parameters
protocolNumberprotocol number
interfaceIndexinterface index, -1 means "any" interface.
Returns
corresponding IpL4Protocol or 0 if not found

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ GetRoutingProtocol()

virtual Ptr< Ipv4RoutingProtocol > ns3::Ipv4::GetRoutingProtocol ( ) const
pure virtual

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

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by Ipv4ForwardingTest::DoRun(), Ipv4RipTest::DoRun(), and Ipv4RipCountToInfinityTest::DoRun().

+ Here is the caller graph for this function:

◆ GetStrongEndSystemModel()

virtual bool ns3::Ipv4::GetStrongEndSystemModel ( ) const
privatepure virtual

Get the Strong End System Model status.

RFC1122 term for whether host rejects datagram with a dest. address on another interface

Returns
true for Strong End System Model activated

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::Ipv4::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 36 of file ipv4.cc.

References ns3::TypeId::DEPRECATED, GetIpForward(), ns3::UdpSocket::GetMtuDiscover(), GetStrongEndSystemModel(), GetWeakEsModel(), ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), NS_WARNING_POP, NS_WARNING_PUSH_DEPRECATED, SetIpForward(), ns3::UdpSocket::SetMtuDiscover(), ns3::TypeId::SetParent(), SetStrongEndSystemModel(), and SetWeakEsModel().

+ Here is the call graph for this function:

◆ GetWeakEsModel()

virtual bool ns3::Ipv4::GetWeakEsModel ( ) const
privatepure virtual

Get the Weak Es Model status.

RFC1122 term for whether host accepts datagram with a dest. address on another interface

Returns
true for Weak Es Model activated
Deprecated:
Deprecated since ns-3.41. Use SetStrongEndSystemModel instead.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ Insert() [1/2]

virtual void ns3::Ipv4::Insert ( Ptr< IpL4Protocol protocol)
pure virtual
Parameters
protocola template for the protocol to add to this L4 Demux.

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.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ Insert() [2/2]

virtual void ns3::Ipv4::Insert ( Ptr< IpL4Protocol protocol,
uint32_t  interfaceIndex 
)
pure virtual

Add a L4 protocol to a specific interface.

This may be called multiple times for multiple interfaces for the same protocol. To insert for all interfaces, use the separate Insert (Ptr<IpL4Protocol> protocol) method.

Setting a protocol on a specific interface will overwrite the previously bound protocol.

Parameters
protocolL4 protocol.
interfaceIndexinterface index.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ IsDestinationAddress()

virtual bool ns3::Ipv4::IsDestinationAddress ( Ipv4Address  address,
uint32_t  iif 
) const
pure 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
Returns
true if the address is associated with the 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 StrongEndSystemModel is true, the address must match one assigned to the incoming device. If the attribute is false, the unicast address may match any of the Ipv4 addresses on any interface.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ IsForwarding()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ IsUp()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ Remove() [1/2]

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

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ Remove() [2/2]

virtual void ns3::Ipv4::Remove ( Ptr< IpL4Protocol protocol,
uint32_t  interfaceIndex 
)
pure virtual

Remove a L4 protocol from a specific interface.

Parameters
protocolL4 protocol to remove.
interfaceIndexinterface index.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ RemoveAddress() [1/2]

virtual bool ns3::Ipv4::RemoveAddress ( uint32_t  interface,
Ipv4Address  address 
)
pure virtual

Remove the given address on named Ipv4 interface.

Parameters
interfaceInterface number of an Ipv4 interface
addressThe address to remove
Returns
true if the operation succeeded

Implemented in ns3::Ipv4L3Protocol, and ns3::Ipv4L3ClickProtocol.

◆ RemoveAddress() [2/2]

virtual bool ns3::Ipv4::RemoveAddress ( uint32_t  interface,
uint32_t  addressIndex 
)
pure 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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ SelectSourceAddress()

virtual Ipv4Address ns3::Ipv4::SelectSourceAddress ( Ptr< const NetDevice device,
Ipv4Address  dst,
Ipv4InterfaceAddress::InterfaceAddressScope_e  scope 
)
pure 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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ Send()

virtual void ns3::Ipv4::Send ( Ptr< Packet packet,
Ipv4Address  source,
Ipv4Address  destination,
uint8_t  protocol,
Ptr< Ipv4Route route 
)
pure virtual
Parameters
packetpacket to send
sourcesource address of packet
destinationaddress of packet
protocolnumber of packet
routeroute entry

Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by ns3::Icmpv4L4Protocol::NotifyNewAggregate(), ns3::TcpL4Protocol::NotifyNewAggregate(), and ns3::UdpL4Protocol::NotifyNewAggregate().

+ Here is the caller graph for this function:

◆ SendWithHeader()

virtual void ns3::Ipv4::SendWithHeader ( Ptr< Packet packet,
Ipv4Header  ipHeader,
Ptr< Ipv4Route route 
)
pure 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.)

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ SetDown()

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

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by Ipv4DynamicGlobalRoutingTestCase::DoRun(), and NixVectorRoutingTest::DoRun().

+ Here is the caller graph for this function:

◆ SetForwarding()

virtual void ns3::Ipv4::SetForwarding ( uint32_t  interface,
bool  val 
)
pure 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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ SetIpForward()

virtual void ns3::Ipv4::SetIpForward ( bool  forward)
privatepure virtual

Set or unset the IP forwarding state.

Parameters
forwardthe forwarding state

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetMetric()

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ SetRoutingProtocol()

virtual void ns3::Ipv4::SetRoutingProtocol ( Ptr< Ipv4RoutingProtocol routingProtocol)
pure 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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

◆ SetStrongEndSystemModel()

virtual void ns3::Ipv4::SetStrongEndSystemModel ( bool  model)
privatepure virtual

Set or unset the Strong End System Model.

RFC1122 term for whether host rejects datagram with a dest. address on another interface

Parameters
modeltrue for Strong End System Model

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SetUp()

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

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

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by Ipv4DynamicGlobalRoutingTestCase::DoRun().

+ Here is the caller graph for this function:

◆ SetWeakEsModel()

virtual void ns3::Ipv4::SetWeakEsModel ( bool  model)
privatepure virtual

Set or unset the Weak Es Model.

RFC1122 term for whether host accepts datagram with a dest. address on another interface

Parameters
modeltrue for Weak Es Model
Deprecated:
Deprecated since ns-3.41. Use SetStrongEndSystemModel instead.

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

◆ SourceAddressSelection()

virtual Ipv4Address ns3::Ipv4::SourceAddressSelection ( uint32_t  interface,
Ipv4Address  dest 
)
pure virtual

Choose the source address to use with destination address.

Parameters
interfaceinterface index
destIPv4 destination address
Returns
IPv4 source address to use

Implemented in ns3::Ipv4L3ClickProtocol, and ns3::Ipv4L3Protocol.

Member Data Documentation

◆ IF_ANY

const uint32_t ns3::Ipv4::IF_ANY = 0xffffffff
static

interface wildcard, meaning any interface

Definition at line 442 of file ipv4.h.

Referenced by ns3::Ipv4StaticRouting::LookupStatic().


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