Implement the IPv4 layer. More...
#include "ipv4-l3-protocol.h"
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 , DROP_DUPLICATE } |
Reason why a packet has been dropped. More... | |
typedef void(* | DropTracedCallback) (const Ipv4Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface) |
TracedCallback signature for packet drop events. More... | |
typedef void(* | SentTracedCallback) (const Ipv4Header &header, Ptr< const Packet > packet, uint32_t interface) |
TracedCallback signature for packet send, forward, or local deliver events. More... | |
typedef void(* | TxRxTracedCallback) (Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface) |
TracedCallback signature for packet transmission or reception events. More... | |
Public Member Functions | |
Ipv4L3Protocol () | |
Ipv4L3Protocol (const Ipv4L3Protocol &)=delete | |
~Ipv4L3Protocol () override | |
bool | AddAddress (uint32_t i, Ipv4InterfaceAddress address) override |
uint32_t | AddInterface (Ptr< NetDevice > device) override |
Ptr< Socket > | CreateRawSocket () override |
Creates a raw socket. More... | |
void | DeleteRawSocket (Ptr< Socket > socket) override |
Deletes a particular raw socket. More... | |
Ipv4InterfaceAddress | GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const override |
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to this method. More... | |
Ptr< Ipv4Interface > | GetInterface (uint32_t i) const |
Get an interface. More... | |
int32_t | GetInterfaceForAddress (Ipv4Address addr) const override |
Return the interface number of the interface that has been assigned the specified IP address. More... | |
int32_t | GetInterfaceForDevice (Ptr< const NetDevice > device) const override |
int32_t | GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const override |
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... | |
uint16_t | GetMetric (uint32_t i) const override |
uint16_t | GetMtu (uint32_t i) const override |
uint32_t | GetNAddresses (uint32_t interface) const override |
Ptr< NetDevice > | GetNetDevice (uint32_t i) override |
uint32_t | GetNInterfaces () const override |
Ptr< IpL4Protocol > | GetProtocol (int protocolNumber) const override |
Ptr< IpL4Protocol > | GetProtocol (int protocolNumber, int32_t interfaceIndex) const override |
Get L4 protocol by protocol number for the specified interface. More... | |
Ptr< Ipv4RoutingProtocol > | GetRoutingProtocol () const override |
Get the routing protocol to be used by this Ipv4 stack. More... | |
void | Insert (Ptr< IpL4Protocol > protocol) override |
void | Insert (Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex) override |
Add a L4 protocol to a specific interface. More... | |
bool | IsDestinationAddress (Ipv4Address address, uint32_t iif) const override |
Determine whether address and interface corresponding to received packet can be accepted for local delivery. More... | |
bool | IsForwarding (uint32_t i) const override |
bool | IsUnicast (Ipv4Address ad) const |
Check if an IPv4 address is unicast according to the node. More... | |
bool | IsUp (uint32_t i) const override |
Ipv4L3Protocol & | operator= (const Ipv4L3Protocol &)=delete |
void | 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: More... | |
void | Remove (Ptr< IpL4Protocol > protocol) override |
void | Remove (Ptr< IpL4Protocol > protocol, uint32_t interfaceIndex) override |
Remove a L4 protocol from a specific interface. More... | |
bool | RemoveAddress (uint32_t interface, Ipv4Address address) override |
Remove the given address on named Ipv4 interface. More... | |
bool | RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex) override |
Remove the address at addressIndex on named interface. More... | |
Ipv4Address | SelectSourceAddress (Ptr< const NetDevice > device, Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope) override |
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... | |
void | Send (Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route) override |
void | SendWithHeader (Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route) override |
void | SetDefaultTtl (uint8_t ttl) |
void | SetDown (uint32_t i) override |
void | SetForwarding (uint32_t i, bool val) override |
void | SetMetric (uint32_t i, uint16_t metric) override |
void | SetNode (Ptr< Node > node) |
Set node associated with this stack. More... | |
void | SetRoutingProtocol (Ptr< Ipv4RoutingProtocol > routingProtocol) override |
Register a new routing protocol to be used by this Ipv4 stack. More... | |
void | SetUp (uint32_t i) override |
Ipv4Address | SourceAddressSelection (uint32_t interface, Ipv4Address dest) override |
Choose the source address to use with destination address. More... | |
Public Member Functions inherited from ns3::Ipv4 | |
Ipv4 () | |
~Ipv4 () override | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. More... | |
~Object () override | |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose () |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. More... | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. More... | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. More... | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized () const |
Check if the object has been initialized. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o[[maybe_unused]]) |
Assignment operator. More... | |
void | Ref () const |
Increment the reference count. More... | |
void | Unref () 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 |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Ipv4 | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Attributes | |
static const uint16_t | PROT_NUMBER = 0x0800 |
Protocol number (0x0800) More... | |
Static Public Attributes inherited from ns3::Ipv4 | |
static const uint32_t | IF_ANY = 0xffffffff |
interface wildcard, meaning any interface More... | |
Protected Member Functions | |
void | DoDispose () override |
Destructor implementation. More... | |
void | NotifyNewAggregate () override |
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. More... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoInitialize () |
Initialize() implementation. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. More... | |
Private Types | |
typedef std::map< DupTuple_t, Time > | DupMap_t |
Maps packet duplicate tuple to expiration time. More... | |
typedef std::tuple< uint64_t, uint8_t, Ipv4Address, Ipv4Address > | DupTuple_t |
IETF RFC 6621, Section 6.2 de-duplication w/o IPSec RFC 6621 recommended duplicate packet tuple: {IPV hash, IP protocol, IP source address, IP destination address}. More... | |
typedef std::pair< uint64_t, uint32_t > | FragmentKey_t |
Key identifying a fragmented packet. More... | |
typedef std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > > | FragmentsTimeoutsList_t |
Container for fragment timeouts. More... | |
typedef std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > >::iterator | FragmentsTimeoutsListI_t |
Container Iterator for fragment timeouts.. More... | |
typedef std::vector< Ptr< Ipv4Interface > > | Ipv4InterfaceList |
Container of the IPv4 Interfaces. More... | |
typedef std::map< Ptr< const NetDevice >, uint32_t > | Ipv4InterfaceReverseContainer |
Container of NetDevices registered to IPv4 and their interface indexes. More... | |
typedef std::pair< Ptr< Packet >, Ipv4Header > | Ipv4PayloadHeaderPair |
Pair of a packet and an Ipv4 header. More... | |
typedef std::map< L4ListKey_t, Ptr< IpL4Protocol > > | L4List_t |
Container of the IPv4 L4 instances. More... | |
typedef std::pair< int, int32_t > | L4ListKey_t |
Container of the IPv4 L4 keys: protocol number, interface index. More... | |
typedef std::map< FragmentKey_t, Ptr< Fragments > > | MapFragments_t |
Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment. More... | |
typedef std::list< Ptr< Ipv4RawSocketImpl > > | SocketList |
Container of the IPv4 Raw Sockets. More... | |
Private Member Functions | |
uint32_t | AddIpv4Interface (Ptr< Ipv4Interface > interface) |
Add an IPv4 interface to the stack. More... | |
Ipv4Header | BuildHeader (Ipv4Address source, Ipv4Address destination, uint8_t protocol, uint16_t payloadSize, uint8_t ttl, uint8_t tos, bool mayFragment) |
Construct an IPv4 header. More... | |
void | CallTxTrace (const Ipv4Header &ipHeader, Ptr< Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface) |
Make a copy of the packet, add the header and invoke the TX trace callback. More... | |
void | DecreaseIdentification (Ipv4Address source, Ipv4Address destination, uint8_t protocol) |
Decrease the identification value for a dropped or recursed packet. More... | |
void | DoFragmentation (Ptr< Packet > packet, const Ipv4Header &ipv4Header, uint32_t outIfaceMtu, std::list< Ipv4PayloadHeaderPair > &listFragments) |
Fragment a packet. More... | |
Ptr< Icmpv4L4Protocol > | GetIcmp () const |
Get ICMPv4 protocol. More... | |
bool | GetIpForward () const override |
Get the IP forwarding state. More... | |
bool | GetStrongEndSystemModel () const override |
Get the Strong End System Model status. More... | |
bool | GetWeakEsModel () const override |
Get the Weak Es Model status. More... | |
void | HandleFragmentsTimeout (FragmentKey_t key, Ipv4Header &ipHeader, uint32_t iif) |
Process the timeout for packet fragments. More... | |
void | HandleTimeout () |
Handles a fragmented packet timeout. More... | |
void | IpForward (Ptr< Ipv4Route > rtentry, Ptr< const Packet > p, const Ipv4Header &header) |
Forward a packet. More... | |
void | IpMulticastForward (Ptr< Ipv4MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv4Header &header) |
Forward a multicast packet. More... | |
bool | IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const |
Check if an IPv4 address is unicast. More... | |
void | LocalDeliver (Ptr< const Packet > p, const Ipv4Header &ip, uint32_t iif) |
Deliver a packet. More... | |
bool | ProcessFragment (Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif) |
Process a packet fragment. More... | |
void | RemoveDuplicates () |
Remove expired duplicates packet entry. More... | |
void | RouteInputError (Ptr< const Packet > p, const Ipv4Header &ipHeader, Socket::SocketErrno sockErrno) |
Fallback when no route is found. More... | |
void | SendRealOut (Ptr< Ipv4Route > route, Ptr< Packet > packet, const Ipv4Header &ipHeader) |
Send packet with route. More... | |
void | SetIpForward (bool forward) override |
Set or unset the IP forwarding state. More... | |
void | SetStrongEndSystemModel (bool model) override |
Set or unset the Strong End System Model. More... | |
FragmentsTimeoutsListI_t | SetTimeout (FragmentKey_t key, Ipv4Header ipHeader, uint32_t iif) |
Set a new timeout "event" for a fragmented packet. More... | |
void | SetupLoopback () |
Setup loopback interface. More... | |
void | SetWeakEsModel (bool model) override |
Set or unset the Weak Es Model. More... | |
bool | UpdateDuplicate (Ptr< const Packet > p, const Ipv4Header &header) |
Registers duplicate entry, return false if new. More... | |
Private Attributes | |
EventId | m_cleanDpd |
event to cleanup expired duplicate entries More... | |
uint8_t | m_defaultTtl |
Default TTL. More... | |
TracedCallback< const Ipv4Header &, Ptr< const Packet >, DropReason, Ptr< Ipv4 >, uint32_t > | m_dropTrace |
Trace of dropped packets. More... | |
DupMap_t | m_dups |
map of packet duplicate tuples to expiry event More... | |
Ipv4RoutingProtocol::ErrorCallback | m_ecb |
Error callback. More... | |
bool | m_enableDpd |
Enable multicast duplicate packet detection. More... | |
Time | m_expire |
duplicate entry expiration delay More... | |
Time | m_fragmentExpirationTimeout |
Expiration timeout. More... | |
MapFragments_t | m_fragments |
Fragmented packets. More... | |
std::map< std::pair< uint64_t, uint8_t >, uint16_t > | m_identification |
Identification (for each {src, dst, proto} tuple) More... | |
Ipv4InterfaceList | m_interfaces |
List of IPv4 interfaces. More... | |
bool | m_ipForward |
Forwarding packets (i.e. More... | |
Ipv4RoutingProtocol::LocalDeliverCallback | m_lcb |
Local delivery callback. More... | |
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > | m_localDeliverTrace |
Trace of locally delivered packets. More... | |
Ipv4RoutingProtocol::MulticastForwardCallback | m_mcb |
Multicast forward callback. More... | |
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > | m_multicastForwardTrace |
Trace of multicast forwarded packets. More... | |
Ptr< Node > | m_node |
Node attached to stack. More... | |
L4List_t | m_protocols |
List of transport protocol. More... | |
Time | m_purge |
time between purging expired duplicate entries More... | |
Ipv4InterfaceReverseContainer | m_reverseInterfacesContainer |
Container of NetDevice / Interface index associations. More... | |
Ptr< Ipv4RoutingProtocol > | m_routingProtocol |
Routing protocol associated with the stack. More... | |
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > | m_rxTrace |
Trace of received packets. More... | |
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > | m_sendOutgoingTrace |
Trace of sent packets. More... | |
SocketList | m_sockets |
List of IPv4 raw sockets. More... | |
bool | m_strongEndSystemModel |
Strong End System Model state. More... | |
EventId | m_timeoutEvent |
Event for the next scheduled timeout. More... | |
FragmentsTimeoutsList_t | m_timeoutEventList |
Timeout "events" container. More... | |
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > | m_txTrace |
Trace of transmitted packets. More... | |
Ipv4RoutingProtocol::UnicastForwardCallback | m_ucb |
Unicast forward callback. More... | |
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > | m_unicastForwardTrace |
Trace of unicast forwarded packets. More... | |
Friends | |
class | ::Ipv4L3ProtocolTestCase |
Ipv4L3ProtocolTestCase test case. More... | |
Additional Inherited Members | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
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 83 of file ipv4-l3-protocol.h.
typedef void(* ns3::Ipv4L3Protocol::DropTracedCallback) (const Ipv4Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface) |
TracedCallback signature for packet drop events.
[in] | header | the Ipv4Header. |
[in] | packet | the packet. |
[in] | reason | the reason the packet was dropped. |
[in] | ipv4 | the Ipv4 protocol |
[in] | interface | IP-level interface number |
Ptr<Ipv4>
argument is deprecated and will be changed to Ptr<const Ipv4>
in a future release. Definition at line 274 of file ipv4-l3-protocol.h.
|
private |
Maps packet duplicate tuple to expiration time.
Definition at line 622 of file ipv4-l3-protocol.h.
|
private |
IETF RFC 6621, Section 6.2 de-duplication w/o IPSec RFC 6621 recommended duplicate packet tuple: {IPV hash, IP protocol, IP source address, IP destination address}.
Definition at line 620 of file ipv4-l3-protocol.h.
|
private |
Key identifying a fragmented packet.
Definition at line 510 of file ipv4-l3-protocol.h.
|
private |
Container for fragment timeouts.
Definition at line 514 of file ipv4-l3-protocol.h.
|
private |
Container Iterator for fragment timeouts..
Definition at line 517 of file ipv4-l3-protocol.h.
|
private |
Container of the IPv4 Interfaces.
Definition at line 449 of file ipv4-l3-protocol.h.
|
private |
Container of NetDevices registered to IPv4 and their interface indexes.
Definition at line 453 of file ipv4-l3-protocol.h.
|
private |
Pair of a packet and an Ipv4 header.
Definition at line 408 of file ipv4-l3-protocol.h.
|
private |
Container of the IPv4 L4 instances.
Definition at line 467 of file ipv4-l3-protocol.h.
|
private |
Container of the IPv4 L4 keys: protocol number, interface index.
Definition at line 462 of file ipv4-l3-protocol.h.
|
private |
Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment.
Definition at line 612 of file ipv4-l3-protocol.h.
typedef void(* ns3::Ipv4L3Protocol::SentTracedCallback) (const Ipv4Header &header, Ptr< const Packet > packet, uint32_t interface) |
TracedCallback signature for packet send, forward, or local deliver events.
[in] | header | the Ipv4Header |
[in] | packet | the packet |
[in] | interface | IP-level interface number |
Definition at line 246 of file ipv4-l3-protocol.h.
|
private |
Container of the IPv4 Raw Sockets.
Definition at line 457 of file ipv4-l3-protocol.h.
typedef void(* ns3::Ipv4L3Protocol::TxRxTracedCallback) (Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface) |
TracedCallback signature for packet transmission or reception events.
[in] | packet | the packet. |
[in] | ipv4 | the Ipv4 protocol |
[in] | interface | IP-level interface number |
Ptr<Ipv4>
argument is deprecated and will be changed to Ptr<const Ipv4>
in a future release. Definition at line 259 of file ipv4-l3-protocol.h.
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. |
DROP_DUPLICATE | Duplicate packet received. |
Definition at line 104 of file ipv4-l3-protocol.h.
ns3::Ipv4L3Protocol::Ipv4L3Protocol | ( | ) |
Definition at line 133 of file ipv4-l3-protocol.cc.
References IpForward(), IpMulticastForward(), LocalDeliver(), m_ecb, m_lcb, m_mcb, m_ucb, ns3::MakeCallback(), NS_LOG_FUNCTION, and RouteInputError().
|
override |
Definition at line 142 of file ipv4-l3-protocol.cc.
References NS_LOG_FUNCTION.
|
delete |
|
overridevirtual |
interface | Interface number of an Ipv4 interface |
address | Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1168 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::AddAddress(), first::address, m_routingProtocol, and NS_LOG_FUNCTION.
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.
Implements ns3::Ipv4.
Definition at line 400 of file ipv4-l3-protocol.cc.
References AddIpv4Interface(), ns3::CreateObject(), ns3::Object::GetObject(), m_ipForward, m_node, ns3::MakeCallback(), NS_ASSERT, NS_LOG_FUNCTION, ns3::PeekPointer(), ns3::ArpL3Protocol::PROT_NUMBER, PROT_NUMBER, ns3::ArpL3Protocol::Receive(), Receive(), ns3::TrafficControlLayer::Receive(), ns3::Node::RegisterProtocolHandler(), and ns3::Ipv4Interface::SetNode().
|
private |
Add an IPv4 interface to the stack.
interface | interface to add |
Definition at line 433 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::GetDevice(), m_interfaces, m_reverseInterfacesContainer, and NS_LOG_FUNCTION.
Referenced by AddInterface(), and SetupLoopback().
|
private |
Construct an IPv4 header.
source | source IPv4 address |
destination | destination IPv4 address |
protocol | L4 protocol |
payloadSize | payload size |
ttl | Time to Live |
tos | Type of Service |
mayFragment | true if the packet can be fragmented |
Definition at line 931 of file ipv4-l3-protocol.cc.
References ns3::Node::ChecksumEnabled(), ns3::Ipv4Header::EnableChecksum(), ns3::Ipv4Address::Get(), m_identification, NS_LOG_FUNCTION, ns3::Ipv4Header::SetDestination(), ns3::Ipv4Header::SetDontFragment(), ns3::Ipv4Header::SetIdentification(), ns3::Ipv4Header::SetMayFragment(), ns3::Ipv4Header::SetPayloadSize(), ns3::Ipv4Header::SetProtocol(), ns3::Ipv4Header::SetSource(), ns3::Ipv4Header::SetTos(), and ns3::Ipv4Header::SetTtl().
Referenced by Send().
|
private |
Make a copy of the packet, add the header and invoke the TX trace callback.
ipHeader | the IP header that will be added to the packet |
packet | the packet |
ipv4 | the Ipv4 protocol |
interface | the IP-level interface index |
Note: If the TracedCallback API ever is extended, we could consider to check for connected functions before adding the header
Definition at line 745 of file ipv4-l3-protocol.cc.
References ns3::Packet::AddHeader(), ns3::Packet::Copy(), nsclick-simple-lan::ipv4, and m_txTrace.
Referenced by SendRealOut().
Creates a raw socket.
Implements ns3::Ipv4.
Definition at line 254 of file ipv4-l3-protocol.cc.
References m_node, m_sockets, NS_LOG_FUNCTION, and ns3::Ipv4RawSocketImpl::SetNode().
|
private |
Decrease the identification value for a dropped or recursed packet.
source | source IPv4 address |
destination | destination IPv4 address |
protocol | L4 protocol |
Definition at line 919 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Address::Get(), and m_identification.
Referenced by Send().
Deletes a particular raw socket.
socket | Smart pointer to the raw socket to be deleted |
Implements ns3::Ipv4.
Definition at line 264 of file ipv4-l3-protocol.cc.
References m_sockets, and NS_LOG_FUNCTION.
|
overrideprotectedvirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overridden 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 314 of file ipv4-l3-protocol.cc.
References ns3::EventId::Cancel(), ns3::Object::DoDispose(), ns3::EventId::IsRunning(), m_cleanDpd, m_dups, m_fragments, m_interfaces, m_node, m_protocols, m_reverseInterfacesContainer, m_routingProtocol, m_sockets, m_timeoutEvent, m_timeoutEventList, and NS_LOG_FUNCTION.
|
private |
Fragment a packet.
packet | the packet |
ipv4Header | the IPv4 header |
outIfaceMtu | the MTU of the interface |
listFragments | the list of fragments |
Definition at line 1482 of file ipv4-l3-protocol.cc.
References ns3::Node::ChecksumEnabled(), ns3::Packet::Copy(), ns3::Packet::CreateFragment(), ns3::Ipv4Header::EnableChecksum(), ns3::Ipv4Header::GetFragmentOffset(), ns3::Ipv4Header::GetSerializedSize(), ns3::Packet::GetSize(), ns3::Ipv4Header::IsLastFragment(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Packet::Print(), ns3::Ipv4Header::SetFragmentOffset(), ns3::Ipv4Header::SetLastFragment(), ns3::Ipv4Header::SetMoreFragments(), and ns3::Ipv4Header::SetPayloadSize().
Referenced by SendRealOut().
|
overridevirtual |
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 |
Implements ns3::Ipv4.
Definition at line 1181 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::GetAddress(), and NS_LOG_FUNCTION.
Referenced by IsDestinationAddress(), IsUnicast(), LocalDeliver(), SelectSourceAddress(), Send(), and SourceAddressSelection().
|
private |
Get ICMPv4 protocol.
Definition at line 682 of file ipv4-l3-protocol.cc.
References ns3::Object::GetObject(), GetProtocol(), ns3::Icmpv4L4Protocol::GetStaticProtocolNumber(), and NS_LOG_FUNCTION.
Referenced by HandleFragmentsTimeout(), IpForward(), and LocalDeliver().
Ptr< Ipv4Interface > ns3::Ipv4L3Protocol::GetInterface | ( | uint32_t | i | ) | const |
Get an interface.
i | interface index |
Definition at line 443 of file ipv4-l3-protocol.cc.
References m_interfaces, and NS_LOG_FUNCTION.
Referenced by GetNAddresses(), GetNetDevice(), LocalDeliver(), and SendRealOut().
|
overridevirtual |
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.
Implements ns3::Ipv4.
Definition at line 461 of file ipv4-l3-protocol.cc.
References first::address, m_interfaces, and NS_LOG_FUNCTION.
|
overridevirtual |
device | The NetDevice for an Ipv4Interface |
Implements ns3::Ipv4.
Definition at line 499 of file ipv4-l3-protocol.cc.
References m_reverseInterfacesContainer, and NS_LOG_FUNCTION.
Referenced by IpForward(), SelectSourceAddress(), and Send().
|
overridevirtual |
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.
Implements ns3::Ipv4.
Definition at line 480 of file ipv4-l3-protocol.cc.
References first::address, m_interfaces, and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Get the IP forwarding state.
Implements ns3::Ipv4.
Definition at line 1434 of file ipv4-l3-protocol.cc.
References m_ipForward, and NS_LOG_FUNCTION.
|
overridevirtual |
interface | The interface number of an Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1334 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::GetMetric(), and NS_LOG_FUNCTION.
|
overridevirtual |
interface | Interface number of Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1342 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::GetDevice(), and NS_LOG_FUNCTION.
|
overridevirtual |
interface | Interface number of an Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1189 of file ipv4-l3-protocol.cc.
References GetInterface(), ns3::Ipv4Interface::GetNAddresses(), and NS_LOG_FUNCTION.
Referenced by IsDestinationAddress(), IsUnicast(), LocalDeliver(), SelectSourceAddress(), Send(), and SourceAddressSelection().
interface | The interface number of an Ipv4 interface. |
Implements ns3::Ipv4.
Definition at line 1416 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::GetDevice(), GetInterface(), and NS_LOG_FUNCTION.
Referenced by IpMulticastForward().
|
overridevirtual |
Implements ns3::Ipv4.
Definition at line 454 of file ipv4-l3-protocol.cc.
References m_interfaces, and NS_LOG_FUNCTION.
Referenced by IsDestinationAddress(), IsUnicast(), and SelectSourceAddress().
|
overridevirtual |
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.
Implements ns3::Ipv4.
Definition at line 211 of file ipv4-l3-protocol.cc.
References NS_LOG_FUNCTION.
Referenced by GetIcmp(), and LocalDeliver().
|
overridevirtual |
Get L4 protocol by protocol number for the specified interface.
protocolNumber | protocol number |
interfaceIndex | interface index, -1 means "any" interface. |
Implements ns3::Ipv4.
Definition at line 219 of file ipv4-l3-protocol.cc.
References m_protocols, and NS_LOG_FUNCTION.
|
overridevirtual |
Get the routing protocol to be used by this Ipv4 stack.
Implements ns3::Ipv4.
Definition at line 307 of file ipv4-l3-protocol.cc.
References m_routingProtocol, and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Get the Strong End System Model status.
RFC1122 term for whether host rejects datagram with a dest. address on another interface
Implements ns3::Ipv4.
Definition at line 1462 of file ipv4-l3-protocol.cc.
References m_strongEndSystemModel, and NS_LOG_FUNCTION.
Referenced by IsDestinationAddress().
|
static |
Get the type ID.
Definition at line 55 of file ipv4-l3-protocol.cc.
References m_defaultTtl, m_dropTrace, m_enableDpd, m_expire, m_fragmentExpirationTimeout, m_interfaces, m_localDeliverTrace, m_multicastForwardTrace, m_purge, m_rxTrace, m_sendOutgoingTrace, m_txTrace, m_unicastForwardTrace, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeObjectVectorAccessor(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::MilliSeconds(), ns3::Seconds(), and ns3::TypeId::SetParent().
|
overrideprivatevirtual |
Get the Weak Es Model status.
RFC1122 term for whether host accepts datagram with a dest. address on another interface
Implements ns3::Ipv4.
Definition at line 1448 of file ipv4-l3-protocol.cc.
References m_strongEndSystemModel, and NS_LOG_FUNCTION.
|
private |
Process the timeout for packet fragments.
key | representing the packet fragments |
ipHeader | the IP header of the original packet |
iif | Input Interface |
Definition at line 1761 of file ipv4-l3-protocol.cc.
References DROP_FRAGMENT_TIMEOUT, GetIcmp(), ns3::Packet::GetSize(), m_dropTrace, m_fragments, and NS_LOG_FUNCTION.
Referenced by HandleTimeout().
|
private |
Handles a fragmented packet timeout.
Definition at line 1901 of file ipv4-l3-protocol.cc.
References HandleFragmentsTimeout(), m_timeoutEvent, m_timeoutEventList, ns3::Simulator::Now(), and ns3::Simulator::Schedule().
Referenced by SetTimeout().
|
overridevirtual |
protocol | a 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.
Implements ns3::Ipv4.
Definition at line 148 of file ipv4-l3-protocol.cc.
References ns3::IpL4Protocol::GetProtocolNumber(), m_protocols, NS_LOG_FUNCTION, and NS_LOG_WARN.
|
overridevirtual |
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.
protocol | L4 protocol. |
interfaceIndex | interface index. |
Implements ns3::Ipv4.
Definition at line 160 of file ipv4-l3-protocol.cc.
References ns3::IpL4Protocol::GetProtocolNumber(), m_protocols, NS_LOG_FUNCTION, and NS_LOG_WARN.
|
private |
Forward a packet.
rtentry | route |
p | packet to forward |
header | IPv4 header to add to the packet |
Definition at line 1068 of file ipv4-l3-protocol.cc.
References ns3::Packet::AddPacketTag(), ns3::Packet::Copy(), DROP_TTL_EXPIRED, ns3::Ipv4Header::GetDestination(), GetIcmp(), ns3::Node::GetId(), GetInterfaceForDevice(), ns3::Ipv4Header::GetTos(), ns3::Ipv4Header::GetTtl(), ns3::Socket::IpTos2Priority(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsMulticast(), m_dropTrace, m_node, m_unicastForwardTrace, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Packet::RemovePacketTag(), SendRealOut(), ns3::SocketPriorityTag::SetPriority(), and ns3::Ipv4Header::SetTtl().
Referenced by Ipv4L3Protocol().
|
private |
Forward a multicast packet.
mrtentry | route |
p | packet to forward |
header | IPv4 header to add to the packet |
Definition at line 1031 of file ipv4-l3-protocol.cc.
References ns3::Packet::Copy(), DROP_TTL_EXPIRED, ns3::Ipv4Address::GetAny(), ns3::Ipv4Header::GetDestination(), ns3::Node::GetId(), GetNetDevice(), ns3::Ipv4Header::GetSource(), ns3::Ipv4Header::GetTtl(), m_dropTrace, m_multicastForwardTrace, m_node, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, SendRealOut(), and ns3::Ipv4Header::SetTtl().
Referenced by Ipv4L3Protocol().
|
overridevirtual |
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 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.
Implements ns3::Ipv4.
Definition at line 513 of file ipv4-l3-protocol.cc.
References first::address, GetAddress(), ns3::Ipv4InterfaceAddress::GetBroadcast(), ns3::Ipv4InterfaceAddress::GetLocal(), GetNAddresses(), GetNInterfaces(), GetStrongEndSystemModel(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
|
overridevirtual |
interface | Interface number of Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1399 of file ipv4-l3-protocol.cc.
References NS_LOG_FUNCTION, and NS_LOG_LOGIC.
bool ns3::Ipv4L3Protocol::IsUnicast | ( | Ipv4Address | ad | ) | const |
Check if an IPv4 address is unicast according to the node.
This function checks all the node's interfaces and the respective subnet masks. An address is considered unicast if it's not broadcast, subnet-broadcast or multicast.
ad | address |
Definition at line 697 of file ipv4-l3-protocol.cc.
References GetAddress(), ns3::Ipv4InterfaceAddress::GetBroadcast(), GetNAddresses(), GetNInterfaces(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsMulticast(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
|
private |
Check if an IPv4 address is unicast.
ad | address |
interfaceMask | the network mask |
Definition at line 727 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Address::IsMulticast(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), and NS_LOG_FUNCTION.
|
overridevirtual |
interface | Interface number of Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1350 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Interface::IsUp(), and NS_LOG_FUNCTION.
|
private |
Deliver a packet.
p | packet delivered |
ip | IPv4 header |
iif | input interface packet was received |
Definition at line 1105 of file ipv4-l3-protocol.cc.
References ns3::Ipv4Address::CombineMask(), ns3::Packet::Copy(), GetAddress(), ns3::Ipv4Header::GetDestination(), ns3::Ipv4Header::GetFragmentOffset(), GetIcmp(), GetInterface(), ns3::Ipv4InterfaceAddress::GetLocal(), ns3::Ipv4InterfaceAddress::GetMask(), GetNAddresses(), ns3::Ipv4Header::GetProtocol(), GetProtocol(), ns3::Packet::GetSize(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Header::IsLastFragment(), ns3::Ipv4Address::IsMulticast(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), m_localDeliverTrace, NS_LOG_FUNCTION, NS_LOG_LOGIC, ProcessFragment(), ns3::IpL4Protocol::Receive(), ns3::IpL4Protocol::RX_CSUM_FAILED, ns3::IpL4Protocol::RX_ENDPOINT_CLOSED, ns3::IpL4Protocol::RX_ENDPOINT_UNREACH, ns3::IpL4Protocol::RX_OK, ns3::Ipv4Header::SetFragmentOffset(), and ns3::Ipv4Header::SetPayloadSize().
Referenced by Ipv4L3Protocol().
|
overrideprotectedvirtual |
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 282 of file ipv4-l3-protocol.cc.
References m_node, ns3::Object::NotifyNewAggregate(), NS_LOG_FUNCTION, and SetNode().
|
delete |
|
private |
Process a packet fragment.
packet | the packet |
ipHeader | the IP header |
iif | Input Interface |
Definition at line 1566 of file ipv4-l3-protocol.cc.
References ns3::Ipv4L3Protocol::Fragments::AddFragment(), ns3::Packet::Copy(), ns3::Ipv4Address::Get(), ns3::Ipv4Header::GetDestination(), ns3::Ipv4Header::GetFragmentOffset(), ns3::Ipv4Header::GetIdentification(), ns3::Ipv4L3Protocol::Fragments::GetPacket(), ns3::Ipv4Header::GetProtocol(), ns3::Packet::GetSize(), ns3::Ipv4Header::GetSource(), ns3::Ipv4L3Protocol::Fragments::GetTimeoutIter(), ns3::Ipv4L3Protocol::Fragments::IsEntire(), ns3::Ipv4Header::IsLastFragment(), m_fragments, m_timeoutEventList, NS_LOG_FUNCTION, NS_LOG_LOGIC, SetTimeout(), and ns3::Ipv4L3Protocol::Fragments::SetTimeoutIter().
Referenced by LocalDeliver().
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:
device | network device |
p | the packet |
protocol | protocol value |
from | address of the correspondent |
to | address of the destination |
packetType | type of the packet |
Definition at line 579 of file ipv4-l3-protocol.cc.
References ns3::Node::ChecksumEnabled(), ns3::Packet::Copy(), DROP_BAD_CHECKSUM, DROP_DUPLICATE, DROP_INTERFACE_DOWN, DROP_NO_ROUTE, ns3::Ipv4Header::EnableChecksum(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::Ipv4Interface::GetArpCache(), ns3::Ipv4Header::GetDestination(), ns3::Node::GetId(), ns3::Ipv4Header::GetPayloadSize(), ns3::Packet::GetSize(), ns3::Ipv4Header::GetSource(), ns3::ArpCache::Entry::IsAlive(), ns3::Ipv4Header::IsChecksumOk(), ns3::Ipv4Address::IsMulticast(), ns3::Ipv4Interface::IsUp(), ns3::ArpCache::Lookup(), ns3::ArpCache::LookupInverse(), m_dropTrace, m_ecb, m_enableDpd, m_interfaces, m_lcb, m_mcb, m_node, m_routingProtocol, m_rxTrace, m_sockets, m_ucb, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Packet::RemoveAtEnd(), ns3::Packet::RemoveHeader(), UpdateDuplicate(), and ns3::ArpCache::Entry::UpdateSeen().
Referenced by AddInterface(), and SetupLoopback().
|
overridevirtual |
protocol | protocol to remove from this demux. |
The input value to this method should be the value returned from the Ipv4L4Protocol::Insert method.
Implements ns3::Ipv4.
Definition at line 174 of file ipv4-l3-protocol.cc.
References ns3::IpL4Protocol::GetProtocolNumber(), m_protocols, NS_LOG_FUNCTION, and NS_LOG_WARN.
|
overridevirtual |
Remove a L4 protocol from a specific interface.
protocol | L4 protocol to remove. |
interfaceIndex | interface index. |
Implements ns3::Ipv4.
Definition at line 192 of file ipv4-l3-protocol.cc.
References ns3::IpL4Protocol::GetProtocolNumber(), m_protocols, NS_LOG_FUNCTION, and NS_LOG_WARN.
|
overridevirtual |
Remove the given address on named Ipv4 interface.
interface | Interface number of an Ipv4 interface |
address | The address to remove |
Implements ns3::Ipv4.
Definition at line 1214 of file ipv4-l3-protocol.cc.
References first::address, ns3::Ipv4Address::GetLoopback(), m_routingProtocol, NS_LOG_FUNCTION, and NS_LOG_WARN.
|
overridevirtual |
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 |
Implements ns3::Ipv4.
Definition at line 1197 of file ipv4-l3-protocol.cc.
References first::address, m_routingProtocol, and NS_LOG_FUNCTION.
|
private |
Remove expired duplicates packet entry.
Definition at line 1850 of file ipv4-l3-protocol.cc.
References ns3::Time::IsStrictlyPositive(), m_cleanDpd, m_dups, m_purge, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Simulator::Schedule().
Referenced by UpdateDuplicate().
|
private |
Fallback when no route is found.
p | packet |
ipHeader | IPv4 header |
sockErrno | error number |
Definition at line 1469 of file ipv4-l3-protocol.cc.
References DROP_ROUTE_ERROR, m_dropTrace, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by Ipv4L3Protocol().
|
overridevirtual |
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 |
Implements ns3::Ipv4.
Definition at line 1264 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.
|
overridevirtual |
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.
Implements ns3::Ipv4.
Definition at line 759 of file ipv4-l3-protocol.cc.
References BuildHeader(), ns3::Ipv4Address::CombineMask(), ns3::Packet::Copy(), DecreaseIdentification(), DROP_NO_ROUTE, ns3::Ipv4Interface::GetAddress(), GetAddress(), ns3::Ipv4Address::GetAny(), ns3::Ipv4Header::GetDestination(), ns3::Ipv4Interface::GetDevice(), GetInterfaceForDevice(), ns3::Ipv4InterfaceAddress::GetLocal(), ns3::Ipv4InterfaceAddress::GetMask(), ns3::Ipv4Interface::GetNAddresses(), GetNAddresses(), ns3::Packet::GetSize(), ns3::SocketIpTosTag::GetTos(), ns3::SocketIpTtlTag::GetTtl(), ns3::Ipv4Address::IsAny(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsLocalMulticast(), ns3::Ipv4Address::IsMulticast(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), m_defaultTtl, m_dropTrace, m_enableDpd, m_interfaces, m_routingProtocol, m_sendOutgoingTrace, NS_FATAL_ERROR, NS_LOG_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, ns3::Packet::RemovePacketTag(), SendRealOut(), and UpdateDuplicate().
Referenced by ns3::dsr::DsrRouting::NotifyNewAggregate().
|
private |
Send packet with route.
route | route |
packet | packet to send |
ipHeader | IPv4 header to add to the packet |
Definition at line 978 of file ipv4-l3-protocol.cc.
References CallTxTrace(), DoFragmentation(), DROP_NO_ROUTE, ns3::Ipv4Header::GetDestination(), ns3::Ipv4Interface::GetDevice(), GetInterface(), ns3::Ipv4Header::GetSerializedSize(), ns3::Packet::GetSize(), ns3::Ipv4Interface::IsUp(), m_dropTrace, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, and ns3::Ipv4Interface::Send().
Referenced by IpForward(), IpMulticastForward(), Send(), and SendWithHeader().
|
overridevirtual |
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.)
Implements ns3::Ipv4.
Definition at line 734 of file ipv4-l3-protocol.cc.
References ns3::Node::ChecksumEnabled(), ns3::Ipv4Header::EnableChecksum(), NS_LOG_FUNCTION, and SendRealOut().
void ns3::Ipv4L3Protocol::SetDefaultTtl | ( | uint8_t | ttl | ) |
ttl | default ttl to use |
When we need to send an ipv4 packet, we use this default ttl value.
Definition at line 393 of file ipv4-l3-protocol.cc.
References m_defaultTtl, and NS_LOG_FUNCTION.
|
overridevirtual |
interface | Interface 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 1386 of file ipv4-l3-protocol.cc.
References m_routingProtocol, NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetDown().
|
overridevirtual |
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
Implements ns3::Ipv4.
Definition at line 1408 of file ipv4-l3-protocol.cc.
References NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetForwarding().
|
overrideprivatevirtual |
Set or unset the IP forwarding state.
forward | the forwarding state |
Implements ns3::Ipv4.
Definition at line 1423 of file ipv4-l3-protocol.cc.
References m_interfaces, m_ipForward, and NS_LOG_FUNCTION.
|
overridevirtual |
interface | The interface number of an Ipv4 interface |
metric | routing metric (cost) associated to the underlying Ipv4 interface |
Implements ns3::Ipv4.
Definition at line 1326 of file ipv4-l3-protocol.cc.
References NS_LOG_FUNCTION, and ns3::Ipv4Interface::SetMetric().
Set node associated with this stack.
node | node to set |
Definition at line 245 of file ipv4-l3-protocol.cc.
References m_node, NS_LOG_FUNCTION, and SetupLoopback().
Referenced by NotifyNewAggregate().
|
overridevirtual |
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 |
Implements ns3::Ipv4.
Definition at line 299 of file ipv4-l3-protocol.cc.
References m_routingProtocol, and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Set or unset the Strong End System Model.
RFC1122 term for whether host rejects datagram with a dest. address on another interface
model | true for Strong End System Model |
Implements ns3::Ipv4.
Definition at line 1455 of file ipv4-l3-protocol.cc.
References m_strongEndSystemModel, and NS_LOG_FUNCTION.
|
private |
Set a new timeout "event" for a fragmented packet.
key | the fragment identification |
ipHeader | the IPv4 header of the fragmented packet |
iif | input interface of the packet |
Definition at line 1884 of file ipv4-l3-protocol.cc.
References HandleTimeout(), m_fragmentExpirationTimeout, m_timeoutEvent, m_timeoutEventList, ns3::Simulator::Now(), and ns3::Simulator::Schedule().
Referenced by ProcessFragment().
|
overridevirtual |
interface | Interface 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 1358 of file ipv4-l3-protocol.cc.
References m_routingProtocol, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Ipv4Interface::SetUp().
|
private |
Setup loopback interface.
Definition at line 356 of file ipv4-l3-protocol.cc.
References ns3::Node::AddDevice(), AddIpv4Interface(), ns3::CreateObject(), ns3::Node::GetDevice(), ns3::Ipv4Address::GetLoopback(), ns3::Ipv4Mask::GetLoopback(), ns3::Node::GetNDevices(), m_node, m_routingProtocol, ns3::MakeCallback(), NS_LOG_FUNCTION, PROT_NUMBER, Receive(), and ns3::Node::RegisterProtocolHandler().
Referenced by SetNode().
|
overrideprivatevirtual |
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 |
Implements ns3::Ipv4.
Definition at line 1441 of file ipv4-l3-protocol.cc.
References m_strongEndSystemModel, and NS_LOG_FUNCTION.
|
overridevirtual |
Choose the source address to use with destination address.
interface | interface index |
dest | IPv4 destination address |
Implements ns3::Ipv4.
Definition at line 1237 of file ipv4-l3-protocol.cc.
References GetAddress(), ns3::Ipv4InterfaceAddress::GetLocal(), GetNAddresses(), and NS_LOG_FUNCTION.
|
private |
Registers duplicate entry, return false if new.
[in] | p | Possibly duplicate packet. |
[in] | header | Packet p header. |
Definition at line 1783 of file ipv4-l3-protocol.cc.
References ns3::Packet::AddHeader(), ns3::Packet::Copy(), ns3::Packet::CopyData(), ns3::Ipv4Header::GetDestination(), ns3::Ipv4Header::GetFragmentOffset(), ns3::Ipv4Header::GetIdentification(), ns3::Ipv4Header::GetProtocol(), ns3::Ipv4Header::GetSerializedSize(), ns3::Packet::GetSize(), ns3::Ipv4Header::GetSource(), ns3::Packet::GetUid(), nlohmann::detail::hash(), ns3::Hash32(), ns3::Ipv4Header::IsLastFragment(), ns3::EventId::IsRunning(), ns3::Time::IsStrictlyPositive(), m_cleanDpd, m_dups, m_expire, m_purge, ns3::Simulator::Now(), NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, RemoveDuplicates(), ns3::Simulator::Schedule(), and ns3::Seconds().
Referenced by Receive(), and Send().
|
friend |
Ipv4L3ProtocolTestCase test case.
Definition at line 294 of file ipv4-l3-protocol.h.
|
private |
event to cleanup expired duplicate entries
Definition at line 640 of file ipv4-l3-protocol.h.
Referenced by DoDispose(), RemoveDuplicates(), and UpdateDuplicate().
|
private |
Default TTL.
Definition at line 475 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), Send(), and SetDefaultTtl().
|
private |
Trace of dropped packets.
Ptr<Ipv4>
argument is deprecated and will be changed to Ptr<const Ipv4>
in a future release.Definition at line 503 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), HandleFragmentsTimeout(), IpForward(), IpMulticastForward(), Receive(), RouteInputError(), Send(), and SendRealOut().
|
private |
map of packet duplicate tuples to expiry event
Definition at line 637 of file ipv4-l3-protocol.h.
Referenced by DoDispose(), RemoveDuplicates(), and UpdateDuplicate().
|
private |
Error callback.
Definition at line 645 of file ipv4-l3-protocol.h.
Referenced by Ipv4L3Protocol(), and Receive().
|
private |
Enable multicast duplicate packet detection.
Definition at line 636 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), Receive(), and Send().
|
private |
duplicate entry expiration delay
Definition at line 638 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and UpdateDuplicate().
|
private |
Expiration timeout.
Definition at line 615 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and SetTimeout().
|
private |
Fragmented packets.
Definition at line 614 of file ipv4-l3-protocol.h.
Referenced by ns3::Ipv4L3Protocol::Fragments::AddFragment(), DoDispose(), ns3::Ipv4L3Protocol::Fragments::GetPacket(), ns3::Ipv4L3Protocol::Fragments::GetPartialPacket(), HandleFragmentsTimeout(), ns3::Ipv4L3Protocol::Fragments::IsEntire(), and ProcessFragment().
|
private |
Identification (for each {src, dst, proto} tuple)
Definition at line 477 of file ipv4-l3-protocol.h.
Referenced by BuildHeader(), and DecreaseIdentification().
|
private |
List of IPv4 interfaces.
Definition at line 472 of file ipv4-l3-protocol.h.
Referenced by AddIpv4Interface(), DoDispose(), GetInterface(), GetInterfaceForAddress(), GetInterfaceForPrefix(), GetNInterfaces(), GetTypeId(), Receive(), Send(), and SetIpForward().
|
private |
Forwarding packets (i.e.
router mode) state.
Definition at line 469 of file ipv4-l3-protocol.h.
Referenced by AddInterface(), GetIpForward(), and SetIpForward().
|
private |
Local delivery callback.
Definition at line 644 of file ipv4-l3-protocol.h.
Referenced by Ipv4L3Protocol(), and Receive().
|
private |
Trace of locally delivered packets.
Definition at line 487 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and LocalDeliver().
|
private |
Multicast forward callback.
Definition at line 643 of file ipv4-l3-protocol.h.
Referenced by Ipv4L3Protocol(), and Receive().
|
private |
Trace of multicast forwarded packets.
Definition at line 485 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and IpMulticastForward().
Node attached to stack.
Definition at line 478 of file ipv4-l3-protocol.h.
Referenced by AddInterface(), CreateRawSocket(), DoDispose(), IpForward(), IpMulticastForward(), NotifyNewAggregate(), Receive(), SetNode(), and SetupLoopback().
|
private |
List of transport protocol.
Definition at line 471 of file ipv4-l3-protocol.h.
Referenced by DoDispose(), GetProtocol(), Insert(), and Remove().
|
private |
time between purging expired duplicate entries
Definition at line 639 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), RemoveDuplicates(), and UpdateDuplicate().
|
private |
Container of NetDevice / Interface index associations.
Definition at line 474 of file ipv4-l3-protocol.h.
Referenced by AddIpv4Interface(), DoDispose(), and GetInterfaceForDevice().
|
private |
Routing protocol associated with the stack.
Definition at line 505 of file ipv4-l3-protocol.h.
Referenced by AddAddress(), DoDispose(), GetRoutingProtocol(), Receive(), RemoveAddress(), Send(), SetDown(), SetRoutingProtocol(), SetUp(), and SetupLoopback().
|
private |
Trace of received packets.
Ptr<Ipv4>
argument is deprecated and will be changed to Ptr<const Ipv4>
in a future release.Definition at line 497 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and Receive().
|
private |
Trace of sent packets.
Definition at line 481 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and Send().
|
private |
List of IPv4 raw sockets.
Definition at line 507 of file ipv4-l3-protocol.h.
Referenced by CreateRawSocket(), DeleteRawSocket(), DoDispose(), and Receive().
|
private |
Strong End System Model state.
Definition at line 470 of file ipv4-l3-protocol.h.
Referenced by GetStrongEndSystemModel(), GetWeakEsModel(), SetStrongEndSystemModel(), and SetWeakEsModel().
|
private |
Event for the next scheduled timeout.
Definition at line 543 of file ipv4-l3-protocol.h.
Referenced by DoDispose(), HandleTimeout(), and SetTimeout().
|
private |
Timeout "events" container.
Definition at line 541 of file ipv4-l3-protocol.h.
Referenced by DoDispose(), HandleTimeout(), ProcessFragment(), and SetTimeout().
|
private |
Trace of transmitted packets.
Ptr<Ipv4>
argument is deprecated and will be changed to Ptr<const Ipv4>
in a future release.Definition at line 493 of file ipv4-l3-protocol.h.
Referenced by CallTxTrace(), and GetTypeId().
|
private |
Unicast forward callback.
Definition at line 642 of file ipv4-l3-protocol.h.
Referenced by Ipv4L3Protocol(), and Receive().
|
private |
Trace of unicast forwarded packets.
Definition at line 483 of file ipv4-l3-protocol.h.
Referenced by GetTypeId(), and IpForward().
|
static |
Protocol number (0x0800)
Definition at line 91 of file ipv4-l3-protocol.h.
Referenced by ns3::NoBackhaulEpcHelper::AddEnb(), AddInterface(), ns3::OpenFlowSwitchNetDevice::BufferFromPacket(), ns3::EpcTftClassifier::Classify(), ns3::dsr::DsrRouting::PromiscReceive(), ns3::LteNetDevice::Receive(), ns3::EpcPgwApplication::RecvFromTunDevice(), ns3::Ipv4Interface::Send(), ns3::LteEnbNetDevice::Send(), ns3::LteUeNetDevice::Send(), and SetupLoopback().