Public Member Functions | Static Public Member Functions

ns3::Ipv4 Class Reference
[Ipv4]

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

#include <ipv4.h>

Inheritance diagram for ns3::Ipv4:
Inheritance graph
[legend]
Collaboration diagram for ns3::Ipv4:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void SetRoutingProtocol (Ptr< Ipv4RoutingProtocol > routingProtocol)=0
 Register a new routing protocol to be used by this Ipv4 stack.
virtual Ptr< Ipv4RoutingProtocolGetRoutingProtocol (void) const =0
 Get the routing protocol to be used by this Ipv4 stack.
virtual uint32_t AddInterface (Ptr< NetDevice > device)=0
virtual uint32_t GetNInterfaces (void) const =0
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 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 Ptr< NetDeviceGetNetDevice (uint32_t interface)=0
virtual int32_t GetInterfaceForDevice (Ptr< const NetDevice > device) const =0
virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address)=0
virtual uint32_t GetNAddresses (uint32_t interface) const =0
virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const =0
virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex)=0
virtual void SetMetric (uint32_t interface, uint16_t metric)=0
virtual uint16_t GetMetric (uint32_t interface) const =0
virtual uint16_t GetMtu (uint32_t interface) const =0
virtual bool IsUp (uint32_t interface) const =0
virtual void SetUp (uint32_t interface)=0
virtual void SetDown (uint32_t interface)=0
virtual bool IsForwarding (uint32_t interface) const =0
virtual void SetForwarding (uint32_t interface, bool val)=0

Static Public Member Functions

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

Detailed Description

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

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

Member Function Documentation

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

Implemented in ns3::Ipv4L3Protocol.

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

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:
interface Interface number of an Ipv4 interface
addressIndex index of Ipv4InterfaceAddress
Returns:
the Ipv4InterfaceAddress associated to the interface and addresIndex

Implemented in ns3::Ipv4L3Protocol.

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:
address The 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.

Implemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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:
address The IP address assigned to the interface of interest.
mask The 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::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

virtual Ptr<Ipv4RoutingProtocol> ns3::Ipv4::GetRoutingProtocol ( void   )  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::Ipv4L3Protocol.

static TypeId ns3::Ipv4::GetTypeId ( void   )  [static]

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

Attributes defined for this type:

  • 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

No TraceSources defined for this type.

Reimplemented from ns3::Object.

Reimplemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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

Implemented in ns3::Ipv4L3Protocol.

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:
interface Interface number of an Ipv4 interface
addressIndex index of Ipv4InterfaceAddress to remove
Returns:
true if the operation succeeded

Implemented in ns3::Ipv4L3Protocol.

virtual void ns3::Ipv4::SetDown ( uint32_t  interface  )  [pure virtual]
Parameters:
interface Interface number of Ipv4 interface

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

Implemented in ns3::Ipv4L3Protocol.

virtual void ns3::Ipv4::SetForwarding ( uint32_t  interface,
bool  val 
) [pure virtual]
Parameters:
interface Interface number of Ipv4 interface
val Value to set the forwarding flag

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

Implemented in ns3::Ipv4L3Protocol.

virtual void ns3::Ipv4::SetMetric ( uint32_t  interface,
uint16_t  metric 
) [pure virtual]
Parameters:
interface The interface number of an Ipv4 interface
metric routing metric (cost) associated to the underlying Ipv4 interface

Implemented in ns3::Ipv4L3Protocol.

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:
routingProtocol smart pointer to Ipv4RoutingProtocol object

Implemented in ns3::Ipv4L3Protocol.

virtual void ns3::Ipv4::SetUp ( uint32_t  interface  )  [pure virtual]
Parameters:
interface Interface number of Ipv4 interface

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

Implemented in ns3::Ipv4L3Protocol.


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