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;
 
  243   bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
 
  249   void SetMetric (uint32_t i, uint16_t metric);
 
  251   uint16_t 
GetMtu (uint32_t i) 
const;
 
  252   bool IsUp (uint32_t i) 
const;
 
  253   void SetUp (uint32_t i);
 
  319   friend class ::Ipv4L3ProtocolTestCase;
 
  357     uint16_t payloadSize,
 
  479   typedef std::map<L4ListKey_t, Ptr<IpL4Protocol> > 
L4List_t;
 
bool m_weakEsModel
Weak ES model state. 
 
void SetDefaultTtl(uint8_t ttl)
 
Simulation virtual time values and global simulation resolution. 
 
virtual void SetIpForward(bool forward)
Set or unset the IP forwarding state. 
 
Ptr< Packet > GetPacket() const 
Get the entire packet. 
 
std::map< std::pair< uint64_t, uint32_t >, EventId > MapFragmentsTimers_t
Container of fragment timeout event, stored as pairs(src+dst addr, src+dst port) / EventId...
 
SocketErrno
Enumeration of the possible errors returned by a socket. 
 
virtual void NotifyNewAggregate()
This function will notify other components connected to the node that a new stack member is now conne...
 
Time m_fragmentExpirationTimeout
Expiration timeout. 
 
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets. 
 
a class to represent an Ipv4 address mask 
 
Forward calls to a chain of Callback. 
 
PacketType
Packet types are used as they are in Linux. 
 
std::map< std::pair< uint64_t, uint32_t >, Ptr< Fragments > > MapFragments_t
Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment. 
 
virtual bool GetWeakEsModel(void) const 
Get the Weak Es Model status. 
 
std::list< std::pair< Ptr< Packet >, uint16_t > > m_fragments
The current fragments. 
 
Fragment timeout exceeded. 
 
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const 
 
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...
 
uint32_t AddInterface(Ptr< NetDevice > device)
 
TracedCallback< const Ipv4Header &, Ptr< const Packet >, DropReason, Ptr< Ipv4 >, uint32_t > m_dropTrace
Trace of dropped packets. 
 
Ptr< Ipv4RoutingProtocol > m_routingProtocol
Routing protocol associated with the stack. 
 
uint8_t m_defaultTos
Default TOS. 
 
L4List_t m_protocols
List of transport protocol. 
 
a polymophic address class 
 
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...
 
DropReason
Reason why a packet has been dropped. 
 
Ipv4InterfaceList m_interfaces
List of IPv4 interfaces. 
 
bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const 
Determine whether address and interface corresponding to received packet can be accepted for local de...
 
Ptr< Packet > GetPartialPacket() const 
Get the complete part of the packet. 
 
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_rxTrace
Trace of received packets. 
 
void SetupLoopback(void)
Setup loopback interface. 
 
Ptr< Icmpv4L4Protocol > GetIcmp(void) const 
Get ICMPv4 protocol. 
 
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_txTrace
Trace of transmitted packets. 
 
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_localDeliverTrace
Trace of locally delivered packets. 
 
bool IsEntire() const 
If all fragments have been added. 
 
void SetMetric(uint32_t i, uint16_t metric)
 
virtual void DoDispose(void)
Destructor implementation. 
 
Ptr< Socket > CreateRawSocket(void)
Creates a raw socket. 
 
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
 
static TypeId GetTypeId(void)
Get the type ID. 
 
bool IsUp(uint32_t i) const 
 
MapFragments_t m_fragments
Fragmented packets. 
 
void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)
 
void IpForward(Ptr< Ipv4Route > rtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a packet. 
 
A Set of Fragment belonging to the same packet (src, dst, identification and proto) ...
 
std::vector< Ptr< Ipv4Interface > > Ipv4InterfaceList
Container of the IPv4 Interfaces. 
 
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex)
Remove the address at addressIndex on named interface. 
 
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment. 
 
Access to the Ipv4 forwarding table, interfaces, and configuration. 
 
bool m_ipForward
Forwarding packets (i.e. 
 
void SetForwarding(uint32_t i, bool val)
 
std::list< Ptr< Ipv4RawSocketImpl > > SocketList
Container of the IPv4 Raw Sockets. 
 
Implement the Ipv4 layer. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
int32_t GetInterfaceForAddress(Ipv4Address addr) const 
Return the interface number of the interface that has been assigned the specified IP address...
 
std::pair< int, int32_t > L4ListKey_t
Container of the IPv4 L4 keys: protocol number, interface index. 
 
void DoFragmentation(Ptr< Packet > packet, uint32_t outIfaceMtu, std::list< Ptr< Packet > > &listFragments)
Fragment a packet. 
 
Ptr< Node > m_node
Node attached to stack. 
 
void RouteInputError(Ptr< const Packet > p, const Ipv4Header &ipHeader, Socket::SocketErrno sockErrno)
Fallback when no route is found. 
 
Ipv4Header BuildHeader(Ipv4Address source, Ipv4Address destination, uint8_t protocol, uint16_t payloadSize, uint8_t ttl, uint8_t tos, bool mayFragment)
Construct an IPv4 header. 
 
void SendRealOut(Ptr< Ipv4Route > route, Ptr< Packet > packet, Ipv4Header const &ipHeader)
Send packet with route. 
 
Ptr< NetDevice > GetNetDevice(uint32_t i)
 
void(* SentTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, uint32_t interface)
TracedCallback signature for packet send, forward, or local deliver events. 
 
bool ProcessFragment(Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif)
Process a packet fragment. 
 
uint32_t AddIpv4Interface(Ptr< Ipv4Interface > interface)
Add an IPv4 interface to the stack. 
 
void Remove(Ptr< IpL4Protocol > protocol)
 
Ipv4 addresses are stored in host order in this class. 
 
virtual void SetWeakEsModel(bool model)
Set or unset the Weak Es Model. 
 
void SetNode(Ptr< Node > node)
Set node associated with this stack. 
 
a class to store IPv4 address information on an interface 
 
An identifier for simulation events. 
 
SocketList m_sockets
List of IPv4 raw sockets. 
 
void DeleteRawSocket(Ptr< Socket > socket)
Deletes a particular raw socket. 
 
bool AddAddress(uint32_t i, Ipv4InterfaceAddress address)
 
Ptr< Ipv4Interface > GetInterface(uint32_t i) const 
Get an interface. 
 
InterfaceAddressScope_e
Address scope. 
 
void Insert(Ptr< IpL4Protocol > protocol)
 
bool IsUnicast(Ipv4Address ad) const 
Check if an IPv4 address is unicast according to the node. 
 
Ipv4L3Protocol & operator=(const Ipv4L3Protocol &)
Copy constructor. 
 
void LocalDeliver(Ptr< const Packet > p, Ipv4Header const &ip, uint32_t iif)
Deliver a packet. 
 
void IpMulticastForward(Ptr< Ipv4MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a multicast packet. 
 
uint32_t GetNAddresses(uint32_t interface) const 
 
MapFragmentsTimers_t m_fragmentsTimers
Expiration events. 
 
uint16_t GetMtu(uint32_t i) const 
 
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...
 
uint8_t m_defaultTtl
Default TTL. 
 
uint32_t GetNInterfaces(void) const 
 
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const 
 
Interface is down so can not send packet. 
 
void(* TxRxTracedCallback)(Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet transmission or reception events. 
 
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets. 
 
uint16_t GetMetric(uint32_t i) const 
 
Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const 
Get the routing protocol to be used by this Ipv4 stack. 
 
std::map< L4ListKey_t, Ptr< IpL4Protocol > > L4List_t
Container of the IPv4 L4 instances. 
 
A template-based reference counting class. 
 
a unique identifier for an interface. 
 
std::map< std::pair< uint64_t, uint8_t >, uint16_t > m_identification
Identification (for each {src, dst, proto} tuple) 
 
virtual ~Ipv4L3Protocol()
 
void HandleFragmentsTimeout(std::pair< uint64_t, uint32_t > key, Ipv4Header &ipHeader, uint32_t iif)
Process the timeout for packet fragments. 
 
virtual bool GetIpForward(void) const 
Get the IP forwarding state. 
 
static const uint16_t PROT_NUMBER
Protocol number (0x0800) 
 
bool m_moreFragment
True if other fragments will be sent. 
 
bool IsForwarding(uint32_t i) const 
 
void(* DropTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet drop events. 
 
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...
 
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.