|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #ifndef IPV4_L3_PROTOCOL_H
22 #define IPV4_L3_PROTOCOL_H
28 #include "ns3/ipv4-address.h"
30 #include "ns3/net-device.h"
32 #include "ns3/traced-callback.h"
33 #include "ns3/ipv4-header.h"
34 #include "ns3/ipv4-routing-protocol.h"
35 #include "ns3/nstime.h"
36 #include "ns3/simulator.h"
47 class Ipv4RoutingTableEntry;
51 class Ipv4RawSocketImpl;
53 class Icmpv4L4Protocol;
196 bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
202 void SetMetric (uint32_t i, uint16_t metric);
204 uint16_t
GetMtu (uint32_t i)
const;
205 bool IsUp (uint32_t i)
const;
206 void SetUp (uint32_t i);
277 friend class ::Ipv4L3ProtocolTestCase;
325 uint16_t payloadSize,
461 typedef std::map<L4ListKey_t, Ptr<IpL4Protocol> >
L4List_t;
613 typedef std::tuple <uint64_t, uint8_t, Ipv4Address, Ipv4Address>
DupTuple_t;
void HandleTimeout(void)
Handles a fragmented packet timeout.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_localDeliverTrace
Trace of locally delivered packets.
a unique identifier for an interface.
Time m_fragmentExpirationTimeout
Expiration timeout.
Ipv4InterfaceList m_interfaces
List of IPv4 interfaces.
Ipv4L3Protocol(const Ipv4L3Protocol &)
Copy constructor.
std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts..
Ipv4L3Protocol & operator=(const Ipv4L3Protocol &)
Copy constructor.
A Set of Fragment belonging to the same packet (src, dst, identification and proto)
@ DROP_NO_ROUTE
No route to host.
@ DROP_DUPLICATE
Duplicate packet received.
bool m_ipForward
Forwarding packets (i.e.
Ptr< Socket > CreateRawSocket(void)
Creates a raw socket.
An identifier for simulation events.
virtual bool GetIpForward(void) const
Get the IP forwarding state.
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual void SetIpForward(bool forward)
Set or unset the IP forwarding state.
Ipv4Header BuildHeader(Ipv4Address source, Ipv4Address destination, uint8_t protocol, uint16_t payloadSize, uint8_t ttl, uint8_t tos, bool mayFragment)
Construct an IPv4 header.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex)
Remove the address at addressIndex on named interface.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets.
virtual void SetWeakEsModel(bool model)
Set or unset the Weak Es Model.
void SetForwarding(uint32_t i, bool val)
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.
std::map< L4ListKey_t, Ptr< IpL4Protocol > > L4List_t
Container of the IPv4 L4 instances.
void IpMulticastForward(Ptr< Ipv4MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a multicast packet.
virtual void NotifyNewAggregate()
This function will notify other components connected to the node that a new stack member is now conne...
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const
@ DROP_TTL_EXPIRED
Packet TTL has expired.
std::map< FragmentKey_t, Ptr< Fragments > > MapFragments_t
Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment.
Ptr< Packet > GetPacket() const
Get the entire packet.
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...
uint32_t GetNAddresses(uint32_t interface) const
void DoFragmentation(Ptr< Packet > packet, const Ipv4Header &ipv4Header, uint32_t outIfaceMtu, std::list< Ipv4PayloadHeaderPair > &listFragments)
Fragment a packet.
Ptr< Ipv4Interface > GetInterface(uint32_t i) const
Get an interface.
void SetMetric(uint32_t i, uint16_t metric)
A template-based reference counting class.
Ipv4 addresses are stored in host order in this class.
Ptr< Node > m_node
Node attached to stack.
Ptr< Packet > GetPartialPacket() const
Get the complete part of the packet.
std::pair< uint64_t, uint32_t > FragmentKey_t
Key identifying a fragmented packet.
Time m_expire
duplicate entry expiration delay
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets.
std::pair< Ptr< Packet >, Ipv4Header > Ipv4PayloadHeaderPair
Pair of a packet and an Ipv4 header.
void HandleFragmentsTimeout(FragmentKey_t key, Ipv4Header &ipHeader, uint32_t iif)
Process the timeout for packet fragments.
DropReason
Reason why a packet has been dropped.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_txTrace
Trace of transmitted packets.
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...
void RouteInputError(Ptr< const Packet > p, const Ipv4Header &ipHeader, Socket::SocketErrno sockErrno)
Fallback when no route is found.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, DropReason, Ptr< Ipv4 >, uint32_t > m_dropTrace
Trace of dropped packets.
EventId m_timeoutEvent
Event for the next scheduled timeout.
bool IsEntire() const
If all fragments have been added.
Ipv4InterfaceReverseContainer m_reverseInterfacesContainer
Container of NetDevice / Interface index associations.
void SetTimeoutIter(FragmentsTimeoutsListI_t iter)
Set the Timeout iterator.
bool IsUp(uint32_t i) const
std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > > FragmentsTimeoutsList_t
Container for fragment timeouts.
void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)
int32_t GetInterfaceForPrefix(Ipv4Address addr, Ipv4Mask mask) const
Return the interface number of first interface found that has an Ipv4 address within the prefix speci...
bool AddAddress(uint32_t i, Ipv4InterfaceAddress address)
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual ~Ipv4L3Protocol()
std::vector< Ptr< Ipv4Interface > > Ipv4InterfaceList
Container of the IPv4 Interfaces.
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,...
bool m_weakEsModel
Weak ES model state.
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.
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
Ptr< Ipv4RoutingProtocol > m_routingProtocol
Routing protocol associated with the stack.
std::list< Ptr< Ipv4RawSocketImpl > > SocketList
Container of the IPv4 Raw Sockets.
void LocalDeliver(Ptr< const Packet > p, Ipv4Header const &ip, uint32_t iif)
Deliver a packet.
a polymophic address class
FragmentsTimeoutsListI_t m_timeoutIter
Timeout iterator to "event" handler.
a class to store IPv4 address information on an interface
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const
Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const
Get the routing protocol to be used by this Ipv4 stack.
void DecreaseIdentification(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Decrease the identification value for a dropped or recursed packet.
SocketList m_sockets
List of IPv4 raw sockets.
InterfaceAddressScope_e
Address scope.
std::pair< int, int32_t > L4ListKey_t
Container of the IPv4 L4 keys: protocol number, interface index.
Simulation virtual time values and global simulation resolution.
void DeleteRawSocket(Ptr< Socket > socket)
Deletes a particular raw socket.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_rxTrace
Trace of received packets.
bool m_moreFragment
True if other fragments will be sent.
virtual Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest)
Choose the source address to use with destination address.
@ DROP_BAD_CHECKSUM
Bad checksum.
DupMap_t m_dups
map of packet duplicate tuples to expiry event
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_multicastForwardTrace
Trace of multicast forwarded packets.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
bool m_enableDpd
Enable multicast duplicate packet detection.
void IpForward(Ptr< Ipv4Route > rtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a packet.
bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const
Determine whether address and interface corresponding to received packet can be accepted for local de...
Time m_purge
time between purging expired duplicate entries
bool IsUnicast(Ipv4Address ad) const
Check if an IPv4 address is unicast according to the node.
uint32_t AddInterface(Ptr< NetDevice > device)
uint32_t GetNInterfaces(void) const
std::map< Ptr< const NetDevice >, uint32_t > Ipv4InterfaceReverseContainer
Container of NetDevices registered to IPv4 and their interface indexes.
@ DROP_ROUTE_ERROR
Route error.
uint32_t AddIpv4Interface(Ptr< Ipv4Interface > interface)
Add an IPv4 interface to the stack.
std::map< std::pair< uint64_t, uint8_t >, uint16_t > m_identification
Identification (for each {src, dst, proto} tuple)
void SetNode(Ptr< Node > node)
Set node associated with this stack.
FragmentsTimeoutsListI_t GetTimeoutIter()
Get the Timeout iterator.
void SetDefaultTtl(uint8_t ttl)
EventId m_cleanDpd
event to cleanup expired duplicate entries
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
bool ProcessFragment(Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif)
Process a packet fragment.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet transmission or reception events.
void SendRealOut(Ptr< Ipv4Route > route, Ptr< Packet > packet, Ipv4Header const &ipHeader)
Send packet with route.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
void RemoveDuplicates(void)
Remove expired duplicates packet entry.
bool IsForwarding(uint32_t i) const
uint16_t GetMtu(uint32_t i) const
uint16_t GetMetric(uint32_t i) const
bool UpdateDuplicate(Ptr< const Packet > p, const Ipv4Header &header)
Registers duplicate entry, return false if new.
virtual void Remove(Ptr< IpL4Protocol > protocol)
Implement the IPv4 layer.
uint8_t m_defaultTtl
Default TTL.
a class to represent an Ipv4 address mask
Ptr< Icmpv4L4Protocol > GetIcmp(void) const
Get ICMPv4 protocol.
Ptr< NetDevice > GetNetDevice(uint32_t i)
void(* DropTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet drop events.
int32_t GetInterfaceForAddress(Ipv4Address addr) const
Return the interface number of the interface that has been assigned the specified IP address.
virtual bool GetWeakEsModel(void) const
Get the Weak Es Model status.
PacketType
Packet types are used as they are in Linux.
FragmentsTimeoutsListI_t SetTimeout(FragmentKey_t key, Ipv4Header ipHeader, uint32_t iif)
Set a new timeout "event" for a fragmented packet.
Forward calls to a chain of Callback.
void SetupLoopback(void)
Setup loopback interface.
std::map< DupTuple_t, Time > DupMap_t
Maps packet duplicate tuple to expiration time.
L4List_t m_protocols
List of transport protocol.
MapFragments_t m_fragments
Fragmented packets.
Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
static TypeId GetTypeId(void)
Get the type ID.
void(* SentTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, uint32_t interface)
TracedCallback signature for packet send, forward, or local deliver events.
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
virtual void DoDispose(void)
Destructor implementation.
virtual void Insert(Ptr< IpL4Protocol > protocol)
std::list< std::pair< Ptr< Packet >, uint16_t > > m_fragments
The current fragments.