This implementation of Ipv4 for nodes using a real Linux Stack. More...
#include <ipv4-linux.h>
Public Member Functions | |
Ipv4Linux () | |
virtual | ~Ipv4Linux () |
virtual bool | AddAddress (uint32_t interface, Ipv4InterfaceAddress address) |
virtual uint32_t | AddInterface (Ptr< NetDevice > device) |
virtual Ptr< Socket > | CreateRawSocket (void) |
virtual void | DeleteRawSocket (Ptr< Socket > socket) |
virtual Ipv4InterfaceAddress | GetAddress (uint32_t interface, uint32_t addressIndex) const |
virtual int32_t | GetInterfaceForAddress (Ipv4Address address) const |
Return the interface number of the interface that has been assigned the specified IP address. | |
virtual int32_t | GetInterfaceForDevice (Ptr< const NetDevice > device) const |
virtual int32_t | GetInterfaceForPrefix (Ipv4Address address, 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. | |
virtual uint16_t | GetMetric (uint32_t interface) const |
virtual uint16_t | GetMtu (uint32_t interface) const |
virtual uint32_t | GetNAddresses (uint32_t interface) const |
virtual Ptr< NetDevice > | GetNetDevice (uint32_t interface) |
virtual uint32_t | GetNInterfaces (void) const |
virtual Ptr< IpL4Protocol > | GetProtocol (int protocolNumber) const |
virtual Ptr< Ipv4RoutingProtocol > | GetRoutingProtocol (void) const |
Get the routing protocol to be used by this Ipv4 stack. | |
virtual void | Insert (Ptr< IpL4Protocol > protocol) |
virtual bool | IsDestinationAddress (Ipv4Address address, uint32_t iif) const |
Determine whether address and interface corresponding to received packet can be accepted for local delivery. | |
virtual bool | IsForwarding (uint32_t interface) const |
virtual bool | IsUp (uint32_t interface) const |
void | PopulateRoutingTable () |
virtual bool | RemoveAddress (uint32_t interface, uint32_t addressIndex) |
virtual bool | RemoveAddress (uint32_t interface, Ipv4Address address) |
Remove the given address on named Ipv4 interface. | |
virtual 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. | |
virtual void | Send (Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route) |
virtual void | SendWithHeader (Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route) |
virtual void | SetDown (uint32_t interface) |
virtual void | SetForwarding (uint32_t interface, bool val) |
virtual void | SetMetric (uint32_t interface, uint16_t metric) |
virtual void | SetRoutingProtocol (Ptr< Ipv4RoutingProtocol > routingProtocol) |
Register a new routing protocol to be used by this Ipv4 stack. | |
virtual void | SetUp (uint32_t interface) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
static void | InstallNode (Ptr< Node > node) |
Private Types | |
typedef std::vector< Ptr < Ipv4Interface > > | Ipv4InterfaceList |
Private Member Functions | |
uint32_t | AddIpv4Interface (Ptr< Ipv4Interface > interface) |
Ptr< Ipv4Interface > | GetInterface (uint32_t i) const |
virtual bool | GetIpForward (void) const |
virtual bool | GetWeakEsModel (void) const |
virtual void | SetIpForward (bool forward) |
virtual void | SetWeakEsModel (bool model) |
Private Attributes | |
Ipv4InterfaceList | m_interfaces |
bool | m_ipForward |
uint64_t | m_nanoSec |
Ptr< Ipv4RoutingProtocol > | m_routingProtocol |
bool | m_weakEsModel |
This implementation of Ipv4 for nodes using a real Linux Stack.
The main goal of this class is not to do the stack job which is done by the real code .... but it is used to not redo the wheel and in particular to be able to reuse these 2 standards NS-3 Helpers for two tasks: 1 - assign address to devices using Ipv4AddressHelper, 2 - create the static routes using Ipv4GlobalRoutingHelper
Definition at line 39 of file ipv4-linux.h.
|
private |
Definition at line 332 of file ipv4-linux.h.
ns3::Ipv4Linux::Ipv4Linux | ( | ) |
Definition at line 66 of file ipv4-linux.cc.
|
virtual |
Definition at line 72 of file ipv4-linux.cc.
|
virtual |
interface | Interface number of an Ipv4 interface |
address | Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface |
Definition at line 271 of file ipv4-linux.cc.
References GetInterface(), m_nanoSec, m_routingProtocol, and ns3::RunIp().
|
virtual |
device | device to add to the list of Ipv4 interfaces which can be used as output interfaces during packet forwarding. |
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.
Definition at line 93 of file ipv4-linux.cc.
References AddIpv4Interface(), and m_ipForward.
|
private |
Definition at line 103 of file ipv4-linux.cc.
References m_interfaces.
Referenced by AddInterface().
|
virtual |
Do nothing
Definition at line 552 of file ipv4-linux.cc.
|
virtual |
Do nothing
Definition at line 561 of file ipv4-linux.cc.
|
virtual |
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to this method.
interface | Interface number of an Ipv4 interface |
addressIndex | index of Ipv4InterfaceAddress |
Definition at line 303 of file ipv4-linux.cc.
References GetInterface().
Referenced by IsDestinationAddress(), and SelectSourceAddress().
|
private |
Definition at line 536 of file ipv4-linux.cc.
References m_interfaces.
Referenced by AddAddress(), GetAddress(), GetMetric(), GetMtu(), GetNAddresses(), GetNetDevice(), IsForwarding(), IsUp(), RemoveAddress(), SetDown(), SetForwarding(), SetMetric(), and SetUp().
|
virtual |
Return the interface number of the interface that has been assigned the specified IP address.
address | The IP address being searched for |
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.
Definition at line 119 of file ipv4-linux.cc.
References m_interfaces.
|
virtual |
device | The NetDevice for an Ipv4Interface |
Definition at line 253 of file ipv4-linux.cc.
References m_interfaces.
Referenced by SelectSourceAddress().
|
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.
address | The IP address assigned to the interface of interest. |
mask | The IP prefix to use in the mask |
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.
Definition at line 225 of file ipv4-linux.cc.
References m_interfaces.
|
privatevirtual |
Definition at line 496 of file ipv4-linux.cc.
References m_ipForward.
|
virtual |
interface | The interface number of an Ipv4 interface |
Definition at line 421 of file ipv4-linux.cc.
References GetInterface().
|
virtual |
interface | Interface number of Ipv4 interface |
Definition at line 428 of file ipv4-linux.cc.
References GetInterface().
|
virtual |
interface | Interface number of an Ipv4 interface |
Definition at line 296 of file ipv4-linux.cc.
References GetInterface().
Referenced by IsDestinationAddress(), and SelectSourceAddress().
|
virtual |
interface | The interface number of an Ipv4 interface. |
Definition at line 246 of file ipv4-linux.cc.
References GetInterface().
|
virtual |
Definition at line 112 of file ipv4-linux.cc.
References m_interfaces.
Referenced by IsDestinationAddress(), and SelectSourceAddress().
|
virtual |
Do nothing
Definition at line 546 of file ipv4-linux.cc.
|
virtual |
Get the routing protocol to be used by this Ipv4 stack.
Definition at line 86 of file ipv4-linux.cc.
References m_routingProtocol.
Referenced by PopulateRoutingTable().
|
static |
Definition at line 57 of file ipv4-linux.cc.
|
privatevirtual |
Definition at line 508 of file ipv4-linux.cc.
References m_weakEsModel.
Referenced by IsDestinationAddress().
|
virtual |
Do nothing
Definition at line 154 of file ipv4-linux.cc.
|
static |
Definition at line 514 of file ipv4-linux.cc.
Referenced by ns3::LinuxStackHelper::Install().
|
virtual |
Determine whether address and interface corresponding to received packet can be accepted for local delivery.
address | The IP address being considered |
iif | The 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.
Definition at line 160 of file ipv4-linux.cc.
References GetAddress(), GetNAddresses(), GetNInterfaces(), and GetWeakEsModel().
|
virtual |
interface | Interface number of Ipv4 interface |
Definition at line 468 of file ipv4-linux.cc.
References GetInterface().
|
virtual |
interface | Interface number of Ipv4 interface |
Definition at line 435 of file ipv4-linux.cc.
References GetInterface().
void ns3::Ipv4Linux::PopulateRoutingTable | ( | ) |
Definition at line 567 of file ipv4-linux.cc.
References GetRoutingProtocol(), m_nanoSec, and ns3::RunIp().
Referenced by ns3::LinuxStackHelper::PopulateRoutingTables().
|
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.
interface | Interface number of an Ipv4 interface |
addressIndex | index of Ipv4InterfaceAddress to remove |
Definition at line 311 of file ipv4-linux.cc.
References GetInterface(), and m_routingProtocol.
|
virtual |
Remove the given address on named Ipv4 interface.
interface | Interface number of an Ipv4 interface |
address | The address to remove |
Definition at line 328 of file ipv4-linux.cc.
References GetInterface(), and m_routingProtocol.
|
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.
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.
device | output NetDevice (optionally provided, only to constrain the search) |
dst | Destination address to match, if device is provided |
scope | Scope of returned address must be less than or equal to this |
Definition at line 351 of file ipv4-linux.cc.
References GetAddress(), GetInterfaceForDevice(), GetNAddresses(), and GetNInterfaces().
|
virtual |
Do nothing
Definition at line 141 of file ipv4-linux.cc.
|
virtual |
Do nothing
Definition at line 148 of file ipv4-linux.cc.
|
virtual |
interface | Interface number of Ipv4 interface |
Set the interface into the "down" state. In this state, it is ignored during Ipv4 forwarding.
Definition at line 455 of file ipv4-linux.cc.
References GetInterface(), and m_routingProtocol.
|
virtual |
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
Definition at line 477 of file ipv4-linux.cc.
References GetInterface().
|
privatevirtual |
Definition at line 485 of file ipv4-linux.cc.
References m_interfaces, and m_ipForward.
|
virtual |
interface | The interface number of an Ipv4 interface |
metric | routing metric (cost) associated to the underlying Ipv4 interface |
Definition at line 413 of file ipv4-linux.cc.
References GetInterface().
|
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.
routingProtocol | smart pointer to Ipv4RoutingProtocol object |
Definition at line 78 of file ipv4-linux.cc.
References m_routingProtocol.
|
virtual |
interface | Interface number of Ipv4 interface |
Set the interface into the "up" state. In this state, it is considered valid during Ipv4 forwarding.
Definition at line 442 of file ipv4-linux.cc.
References GetInterface(), and m_routingProtocol.
|
privatevirtual |
Definition at line 502 of file ipv4-linux.cc.
References m_weakEsModel.
|
private |
Definition at line 336 of file ipv4-linux.h.
Referenced by AddIpv4Interface(), GetInterface(), GetInterfaceForAddress(), GetInterfaceForDevice(), GetInterfaceForPrefix(), GetNInterfaces(), and SetIpForward().
|
private |
Definition at line 334 of file ipv4-linux.h.
Referenced by AddInterface(), GetIpForward(), and SetIpForward().
|
private |
Definition at line 337 of file ipv4-linux.h.
Referenced by AddAddress(), and PopulateRoutingTable().
|
private |
Definition at line 333 of file ipv4-linux.h.
Referenced by AddAddress(), GetRoutingProtocol(), RemoveAddress(), SetDown(), SetRoutingProtocol(), and SetUp().
|
private |
Definition at line 335 of file ipv4-linux.h.
Referenced by GetWeakEsModel(), and SetWeakEsModel().