Access to the Ipv4 forwarding table, interfaces, and configuration. More...
#include <ipv4.h>
Public Member Functions | |
Ipv4 () | |
virtual | ~Ipv4 () |
virtual bool | AddAddress (uint32_t interface, Ipv4InterfaceAddress address)=0 |
virtual uint32_t | AddInterface (Ptr< NetDevice > device)=0 |
virtual Ptr< Socket > | CreateRawSocket (void)=0 |
Creates a raw socket. More... | |
virtual void | DeleteRawSocket (Ptr< Socket > socket)=0 |
Deletes a particular raw socket. More... | |
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. More... | |
virtual int32_t | GetInterfaceForAddress (Ipv4Address address) const =0 |
Return the interface number of the interface that has been assigned the specified IP address. More... | |
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. More... | |
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< NetDevice > | GetNetDevice (uint32_t interface)=0 |
virtual uint32_t | GetNInterfaces (void) const =0 |
virtual Ptr< IpL4Protocol > | GetProtocol (int protocolNumber) const =0 |
virtual Ptr< Ipv4RoutingProtocol > | GetRoutingProtocol (void) const =0 |
Get the routing protocol to be used by this Ipv4 stack. More... | |
virtual void | Insert (Ptr< IpL4Protocol > protocol)=0 |
virtual bool | IsDestinationAddress (Ipv4Address address, uint32_t iif) const =0 |
Determine whether address and interface corresponding to received packet can be accepted for local delivery. More... | |
virtual bool | IsForwarding (uint32_t interface) const =0 |
virtual bool | IsUp (uint32_t interface) const =0 |
virtual bool | RemoveAddress (uint32_t interface, uint32_t addressIndex)=0 |
Remove the address at addressIndex on named interface. More... | |
virtual bool | RemoveAddress (uint32_t interface, Ipv4Address address)=0 |
Remove the given address on named Ipv4 interface. More... | |
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. More... | |
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. More... | |
virtual void | SetUp (uint32_t interface)=0 |
Public Member Functions inherited from ns3::Object | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
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 | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
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) |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Noop. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Attributes | |
static const uint32_t | IF_ANY = 0xffffffff |
interface wildcard, meaning any interface More... | |
Private Member Functions | |
virtual bool | GetIpForward (void) const =0 |
Get the IP forwarding state. More... | |
virtual bool | GetWeakEsModel (void) const =0 |
Get the Weak Es Model status. More... | |
virtual void | SetIpForward (bool forward)=0 |
Set or unset the IP forwarding state. More... | |
virtual void | SetWeakEsModel (bool model)=0 |
Set or unset the Weak Es Model. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
virtual void | DoDispose (void) |
This method is called by Object::Dispose or by the object's destructor, whichever comes first. More... | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. More... | |
Access to the Ipv4 forwarding table, interfaces, and configuration.
Doxygen introspection did not find any typical Config paths.
This class defines the API to manipulate the following aspects of the Ipv4 implementation:
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
No TraceSources are defined for this type.
ns3::Ipv4::Ipv4 | ( | ) |
Definition at line 61 of file ipv4.cc.
References NS_LOG_FUNCTION.
|
virtual |
Definition at line 66 of file ipv4.cc.
References NS_LOG_FUNCTION.
|
pure virtual |
interface | Interface number of an Ipv4 interface |
address | Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
Referenced by TcpTestCase::AddSimpleNetDevice(), AddSimpleNetDevice(), StaticRoutingSlash32TestCase::DoRun(), Ipv4ForwardingTest::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4PacketInfoTagTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), Ipv4FragmentationTest::DoRun(), UdpSocketImplTest::DoRun(), GlobalRoutingSlash32TestCase::DoRun(), main(), and Tunnel::Tunnel().
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.
Implemented in ns3::Ipv4L3Protocol.
Referenced by TcpTestCase::AddSimpleNetDevice(), AddSimpleNetDevice(), StaticRoutingSlash32TestCase::DoRun(), Ipv4ForwardingTest::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4PacketInfoTagTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), Ipv4FragmentationTest::DoRun(), UdpSocketImplTest::DoRun(), GlobalRoutingSlash32TestCase::DoRun(), main(), and Tunnel::Tunnel().
Creates a raw socket.
Implemented in ns3::Ipv4L3Protocol.
Deletes a particular raw socket.
socket | Smart pointer to the raw socket to be deleted |
Implemented in ns3::Ipv4L3Protocol.
|
pure 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 |
Implemented in ns3::Ipv4L3Protocol.
Referenced by Experiment::ApplicationSetup(), main(), and PrintPosition().
|
pure 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.
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
device | The NetDevice for an Ipv4Interface |
Implemented in ns3::Ipv4L3Protocol.
|
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.
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.
Implemented in ns3::Ipv4L3Protocol.
|
privatepure virtual |
Get the IP forwarding state.
Implemented in ns3::Ipv4L3Protocol.
Referenced by GetTypeId().
|
pure virtual |
interface | The interface number of an Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
interface | Interface number of Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
interface | Interface number of an Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
interface | The interface number of an Ipv4 interface. |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
Implemented in ns3::Ipv4L3Protocol.
Referenced by ns3::PointToPointEpcHelper::AddEnb(), ns3::PointToPointEpcHelper::AddX2Interface(), and ns3::GlobalRouter::FindDesignatedRouterForLink().
|
pure virtual |
protocolNumber | number of protocol to lookup in this L4 Demux |
This method is typically called by lower layers to forward packets up the stack to the right protocol.
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
Get the routing protocol to be used by this Ipv4 stack.
Implemented in ns3::Ipv4L3Protocol.
Referenced by ns3::AnimationInterface::GetIpv4RoutingTable(), main(), ns3::AnimationInterface::RecursiveIpv4RoutePathSearch(), and ns3::AnimationInterface::TrackIpv4RoutePaths().
|
static |
Get the type ID.
Definition at line 35 of file ipv4.cc.
References GetIpForward(), ns3::UdpSocket::GetMtuDiscover(), GetWeakEsModel(), SetIpForward(), ns3::UdpSocket::SetMtuDiscover(), ns3::TypeId::SetParent(), and SetWeakEsModel().
|
privatepure virtual |
Get the Weak Es Model status.
RFC1122 term for whether host accepts datagram with a dest. address on another interface
Implemented in ns3::Ipv4L3Protocol.
Referenced by GetTypeId().
|
pure virtual |
protocol | a pointer to the protocol to add to this L4 Demux. |
Adds a protocol to an internal list of L4 protocols.
Implemented in ns3::Ipv4L3Protocol.
|
pure 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.
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
interface | Interface number of Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
interface | Interface number of Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
|
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.
interface | Interface number of an Ipv4 interface |
addressIndex | index of Ipv4InterfaceAddress to remove |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
Remove the given address on named Ipv4 interface.
interface | Interface number of an Ipv4 interface |
address | The address to remove |
Implemented in ns3::Ipv4L3Protocol.
|
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.
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 |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
packet | packet to send |
source | source address of packet |
destination | address of packet |
protocol | number of packet |
route | route entry |
Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers.
Implemented in ns3::Ipv4L3Protocol.
Referenced by ns3::Icmpv4L4Protocol::NotifyNewAggregate(), ns3::TcpL4Protocol::NotifyNewAggregate(), and ns3::UdpL4Protocol::NotifyNewAggregate().
|
pure virtual |
packet | packet to send |
ipHeader | IP Header |
route | route entry |
Higher-level layers call this method to send a packet with IPv4 Header (Intend to be used with IpHeaderInclude attribute.)
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
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.
Referenced by main().
|
pure 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
Implemented in ns3::Ipv4L3Protocol.
|
privatepure virtual |
Set or unset the IP forwarding state.
forward | the forwarding state |
Implemented in ns3::Ipv4L3Protocol.
Referenced by GetTypeId().
|
pure virtual |
interface | The interface number of an Ipv4 interface |
metric | routing metric (cost) associated to the underlying Ipv4 interface |
Implemented in ns3::Ipv4L3Protocol.
Referenced by StaticRoutingSlash32TestCase::DoRun(), Ipv4PacketInfoTagTest::DoRun(), GlobalRoutingSlash32TestCase::DoRun(), and main().
|
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.
routingProtocol | smart pointer to Ipv4RoutingProtocol object |
Implemented in ns3::Ipv4L3Protocol.
|
pure virtual |
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.
Referenced by TcpTestCase::AddSimpleNetDevice(), AddSimpleNetDevice(), StaticRoutingSlash32TestCase::DoRun(), Ipv4ForwardingTest::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4PacketInfoTagTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), Ipv4FragmentationTest::DoRun(), UdpSocketImplTest::DoRun(), GlobalRoutingSlash32TestCase::DoRun(), main(), and Tunnel::Tunnel().
|
privatepure virtual |
Set or unset the Weak Es Model.
RFC1122 term for whether host accepts datagram with a dest. address on another interface
model | true for Weak Es Model |
Implemented in ns3::Ipv4L3Protocol.
Referenced by GetTypeId().
|
static |
interface wildcard, meaning any interface
Definition at line 386 of file ipv4.h.
Referenced by ns3::Ipv4StaticRouting::LookupStatic().