21 #include "ns3/packet.h"
23 #include "ns3/callback.h"
24 #include "ns3/ipv4-address.h"
25 #include "ns3/ipv4-route.h"
27 #include "ns3/socket.h"
28 #include "ns3/net-device.h"
29 #include "ns3/uinteger.h"
30 #include "ns3/string.h"
31 #include "ns3/boolean.h"
32 #include "ns3/trace-source-accessor.h"
33 #include "ns3/object-vector.h"
34 #include "ns3/ipv4-header.h"
35 #include "ns3/boolean.h"
36 #include "ns3/ipv4-routing-table-entry.h"
37 #include "ns3/traffic-control-layer.h"
60 .SetGroupName (
"Internet")
62 .AddAttribute (
"DefaultTtl",
63 "The TTL value set by default on "
64 "all outgoing packets generated on this node.",
67 MakeUintegerChecker<uint8_t> ())
68 .AddAttribute (
"FragmentExpirationTimeout",
69 "When this timeout expires, the fragments "
70 "will be cleared from the buffer.",
74 .AddAttribute (
"EnableDuplicatePacketDetection",
75 "Enable multicast duplicate packet detection based on RFC 6621",
79 .AddAttribute (
"DuplicateExpire",
"Expiration delay for duplicate cache entries",
83 .AddAttribute (
"PurgeExpiredPeriod",
84 "Time between purges of expired duplicate packet entries, "
85 "0 means never purge",
89 .AddTraceSource (
"Tx",
90 "Send ipv4 packet to outgoing interface.",
92 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
93 .AddTraceSource (
"Rx",
94 "Receive ipv4 packet from incoming interface.",
96 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
97 .AddTraceSource (
"Drop",
100 "ns3::Ipv4L3Protocol::DropTracedCallback")
101 .AddAttribute (
"InterfaceList",
102 "The set of Ipv4 interfaces associated to this Ipv4 stack.",
105 MakeObjectVectorChecker<Ipv4Interface> ())
107 .AddTraceSource (
"SendOutgoing",
108 "A newly-generated packet by this node is "
109 "about to be queued for transmission",
111 "ns3::Ipv4L3Protocol::SentTracedCallback")
112 .AddTraceSource (
"UnicastForward",
113 "A unicast IPv4 packet was received by this node "
114 "and is being forwarded to another node",
116 "ns3::Ipv4L3Protocol::SentTracedCallback")
117 .AddTraceSource (
"MulticastForward",
118 "A multicast IPv4 packet was received by this node "
119 "and is being forwarded to another node",
121 "ns3::Ipv4L3Protocol::SentTracedCallback")
122 .AddTraceSource (
"LocalDeliver",
123 "An IPv4 packet was received by/for this node, "
124 "and it is being forward up the stack",
126 "ns3::Ipv4L3Protocol::SentTracedCallback")
193 NS_LOG_WARN (
"Trying to remove an non-existent protocol " <<
int(protocol->
GetProtocolNumber ()) <<
" on interface " <<
int(interfaceIndex));
215 L4List_t::const_iterator i;
216 if (interfaceIndex >= 0)
219 key = std::make_pair (protocolNumber, interfaceIndex);
227 key = std::make_pair (protocolNumber, -1);
365 device = CreateObject<LoopbackNetDevice> ();
368 interface->SetDevice (device);
369 interface->SetNode (
m_node);
371 interface->AddAddress (ifaceAddr);
412 interface->SetDevice (device);
413 interface->SetTrafficControl (tc);
451 int32_t
interface = 0;
452 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
456 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
458 if ((*i)->GetAddress (j).GetLocal () ==
address)
474 int32_t
interface = 0;
475 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
479 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
481 if ((*i)->GetAddress (j).GetLocal ().CombineMask (mask) ==
address.CombineMask (mask))
500 return (*iter).second;
529 if (MulticastCheckGroup (iif,
address ))
548 if (j == uint32_t (iif))
continue;
560 NS_LOG_LOGIC (
"For me (interface broadcast address on another interface)");
573 NS_LOG_FUNCTION (
this << device << p << protocol << from << to << packetType);
575 NS_LOG_LOGIC (
"Packet from " << from <<
" received on node " <<
579 int32_t
interface = GetInterfaceForDevice(device);
580 NS_ASSERT_MSG (interface != -1,
"Received a packet from an interface that is not known to IPv4");
586 if (ipv4Interface->
IsUp ())
592 NS_LOG_LOGIC (
"Dropping received packet -- interface is down");
614 NS_LOG_LOGIC (
"Dropping received packet -- checksum not ok");
637 std::list<ArpCache::Entry *> entryList = arpCache->
LookupInverse (from);
638 std::list<ArpCache::Entry *>::iterator iter;
639 for (iter = entryList.begin (); iter != entryList.end (); iter ++)
641 if ((*iter)->IsAlive ())
643 (*iter)->UpdateSeen ();
653 socket->
ForwardUp (packet, ipHeader, ipv4Interface);
658 NS_LOG_LOGIC (
"Dropping received packet -- duplicate.");
671 NS_LOG_WARN (
"No route found for forwarding packet. Drop.");
703 for (uint32_t ifaceIndex = 0; ifaceIndex <
GetNInterfaces (); ifaceIndex++)
756 NS_LOG_FUNCTION (
this << packet << source << destination << uint32_t (protocol) << route);
758 bool mayFragment =
true;
800 NS_FATAL_ERROR (
"Ipv4L3Protocol::Send case 1a: packet passed with a route but the Gateway address is uninitialized. This case not yet implemented.");
804 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 1b: passed in with route and valid gateway");
814 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 2: limited broadcast - no route");
815 uint32_t ifaceIndex = 0;
816 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
817 ifaceIter !=
m_interfaces.end (); ifaceIter++, ifaceIndex++)
821 bool sendIt = source.
IsAny ();
823 for (uint32_t index = 0; !sendIt && index < outInterface->
GetNAddresses (); index++)
840 Send (pktCopyWithTags, source, destination, protocol, route);
847 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
859 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 3: subnet directed bcast to " << ifAddr.
GetLocal () <<
" - no route");
867 Send (pktCopyWithTags, source, destination, protocol, route);
874 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 4: not broadcast and passed in with no route " << destination);
880 newRoute =
m_routingProtocol->RouteOutput (pktCopyWithTags, ipHeader, oif, errno_);
884 NS_LOG_ERROR (
"Ipv4L3Protocol::Send: m_routingProtocol == 0");
889 Send (pktCopyWithTags, source, destination, protocol, newRoute);
904 uint64_t src = source.
Get ();
905 uint64_t dst = destination.
Get ();
906 uint64_t srcDst = dst | (src << 32);
907 std::pair<uint64_t, uint8_t> key = std::make_pair (srcDst, protocol);
916 uint16_t payloadSize,
921 NS_LOG_FUNCTION (
this << source << destination << (uint16_t)protocol << payloadSize << (uint16_t)ttl << (uint16_t)tos << mayFragment);
930 uint64_t src = source.
Get ();
931 uint64_t dst = destination.
Get ();
932 uint64_t srcDst = dst | (src << 32);
933 std::pair<uint64_t, uint8_t> key = std::make_pair (srcDst, protocol);
935 if (mayFragment ==
true)
971 int32_t
interface = GetInterfaceForDevice (outDev);
974 NS_LOG_LOGIC (
"Send via NetDevice ifIndex " << outDev->GetIfIndex () <<
" ipv4InterfaceIndex " << interface);
977 std::string targetLabel;
981 targetLabel =
"destination";
986 targetLabel =
"gateway";
989 if (outInterface->
IsUp ())
991 NS_LOG_LOGIC (
"Send to " << targetLabel <<
" " << target);
994 std::list<Ipv4PayloadHeaderPair> listFragments;
996 for ( std::list<Ipv4PayloadHeaderPair>::iterator it = listFragments.begin (); it != listFragments.end (); it++ )
1000 outInterface->
Send (it->first, it->second, target);
1006 outInterface->
Send (packet, ipHeader, target);
1018 std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap ();
1019 std::map<uint32_t, uint32_t>::iterator mapIter;
1021 for (mapIter = ttlMap.begin (); mapIter != ttlMap.end (); mapIter++)
1023 uint32_t
interface = mapIter->
first;
1029 if (ipHeader.
GetTtl () == 0)
1035 NS_LOG_LOGIC (
"Forward multicast via interface " << interface);
1059 if (ipHeader.
GetTtl () == 0)
1066 icmp->SendTimeExceededTtl (ipHeader, packet,
false);
1096 NS_LOG_LOGIC (
"Received a fragment, processing " << *p );
1097 bool isPacketComplete;
1099 if ( isPacketComplete ==
false)
1103 NS_LOG_LOGIC (
"Got last fragment, Packet is complete " << *p );
1132 bool subnetDirected =
false;
1139 subnetDirected =
true;
1142 if (subnetDirected ==
false)
1144 GetIcmp ()->SendDestUnreachPort (ipHeader, copy);
1235 if (test.GetLocal ().CombineMask (test.GetMask ()) == dest.
CombineMask (test.GetMask ()))
1237 if (test.IsSecondary () ==
false)
1239 return test.GetLocal ();
1263 if (iaddr.
GetScope () > scope)
continue;
1294 NS_LOG_WARN (
"Could not find source address for " << dst <<
" and scope "
1295 << scope <<
", returning 0");
1320 return interface->
GetDevice ()->GetMtu ();
1328 return interface->
IsUp ();
1341 if (interface->GetDevice ()->GetMtu () >= 68)
1343 interface->
SetUp ();
1352 NS_LOG_LOGIC (
"Interface " <<
int(i) <<
" is set to be down for IPv4. Reason: not respecting minimum IPv4 MTU (68 octects)");
1374 NS_LOG_LOGIC (
"Forwarding state: " << interface->IsForwarding ());
1375 return interface->IsForwarding ();
1400 (*i)->SetForwarding (forward);
1429 NS_LOG_LOGIC (
"Route input failure-- dropping packet to " << ipHeader <<
" with errno " << sockErrno);
1448 "IPv4 fragmentation implementation only works without option headers." );
1450 uint16_t offset = 0;
1451 bool moreFragment =
true;
1454 uint32_t currentFragmentablePartSize = 0;
1459 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.
GetSerializedSize () ) & ~uint32_t (0x7);
1461 NS_LOG_LOGIC (
"Fragmenting - Target Size: " << fragmentSize );
1467 if (p->
GetSize () > offset + fragmentSize )
1469 moreFragment =
true;
1470 currentFragmentablePartSize = fragmentSize;
1475 moreFragment =
false;
1476 currentFragmentablePartSize = p->
GetSize () - offset;
1477 if (!isLastFragment)
1487 NS_LOG_LOGIC (
"Fragment creation - " << offset <<
", " << currentFragmentablePartSize );
1501 NS_LOG_LOGIC (
"New fragment Header " << fragmentHeader);
1503 std::ostringstream oss;
1504 oss << fragmentHeader;
1505 fragment->
Print (oss);
1509 listFragments.emplace_back (fragment, fragmentHeader);
1511 offset += currentFragmentablePartSize;
1514 while (moreFragment);
1530 key.first = addressCombination;
1531 key.second = idProto;
1535 MapFragments_t::iterator it =
m_fragments.find (key);
1538 fragments = Create<Fragments> ();
1539 m_fragments.insert (std::make_pair (key, fragments));
1546 fragments = it->second;
1566 : m_moreFragment (0)
1581 std::list<std::pair<Ptr<Packet>, uint16_t> >::iterator it;
1585 if (it->second > fragmentOffset)
1593 m_moreFragment = moreFragment;
1604 bool ret = !m_moreFragment &&
m_fragments.size () > 0;
1608 uint16_t lastEndOffset = 0;
1613 NS_LOG_LOGIC (
"Checking overlaps " << lastEndOffset <<
" - " << it->second );
1615 if (lastEndOffset < it->
second)
1621 uint16_t fragmentEnd = it->first->GetSize () + it->second;
1622 lastEndOffset =
std::max ( lastEndOffset, fragmentEnd );
1634 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1637 uint16_t lastEndOffset = p->
GetSize ();
1642 if ( lastEndOffset > it->second )
1648 uint32_t newStart = lastEndOffset - it->second;
1649 if ( it->first->GetSize () > newStart )
1651 uint32_t newSize = it->first->GetSize () - newStart;
1661 lastEndOffset = p->
GetSize ();
1672 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1675 uint16_t lastEndOffset = 0;
1684 if ( lastEndOffset > it->second )
1686 uint32_t newStart = lastEndOffset - it->second;
1687 uint32_t newSize = it->first->
GetSize () - newStart;
1691 else if ( lastEndOffset == it->second )
1696 lastEndOffset = p->
GetSize ();
1705 m_timeoutIter = iter;
1712 return m_timeoutIter;
1721 MapFragments_t::iterator it =
m_fragments.find (key);
1722 Ptr<Packet> packet = it->second->GetPartialPacket ();
1728 icmp->SendTimeExceededTtl (ipHeader, packet,
true);
1750 uint64_t
hash =
id << 32;
1764 std::ostringstream oss (std::ios_base::binary);
1766 std::string bytes = oss.str ();
1768 NS_ASSERT_MSG (bytes.size () >= 20,
"Degenerate header serialization");
1772 bytes[6] = bytes[7] = 0;
1774 bytes[10] = bytes[11] = 0;
1793 std::hex << std::get<0> (key) <<
", " <<
1794 std::dec << +std::get<1> (key) <<
", " <<
1795 std::get<2> (key) <<
", " <<
1796 std::get<3> (key) <<
")");
1799 DupMap_t::iterator iter;
1800 bool inserted, isDup;
1801 std::tie (iter, inserted) =
m_dups.emplace (key,
Seconds (0));
1814 DupMap_t::size_type
n = 0;
1816 auto iter =
m_dups.cbegin ();
1817 while (iter !=
m_dups.cend ())
1819 if (iter->second < expire)
1822 std::hex << std::get<0> (iter->first) <<
", " <<
1823 std::dec << +std::get<1> (iter->first) <<
", " <<
1824 std::get<2> (iter->first) <<
", " <<
1825 std::get<3> (iter->first) <<
")");
1826 iter =
m_dups.erase (iter);
a polymophic address class
A record that that holds information about an ArpCache entry.
void UpdateSeen(void)
Update the entry when seeing a packet.
std::list< ArpCache::Entry * > LookupInverse(Address destination)
Do lookup in the ARP cache against a MAC address.
ArpCache::Entry * Lookup(Ipv4Address destination)
Do lookup in the ARP cache against an IP address.
void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Receive a packet.
static const uint16_t PROT_NUMBER
ARP protocol number (0x0806)
AttributeValue implementation for Boolean.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
This is the implementation of the ICMP protocol as described in RFC 792.
static uint16_t GetStaticProtocolNumber(void)
Get the protocol number.
virtual int GetProtocolNumber(void) const =0
Returns the protocol number of this protocol.
virtual enum RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)=0
Called from lower-level layers to send the packet up in the stack.
Ipv4 addresses are stored in host order in this class.
uint32_t Get(void) const
Get the host-order 32-bit IP address.
bool IsMulticast(void) const
bool IsInitialized(void) const
static Ipv4Address GetLoopback(void)
bool IsBroadcast(void) const
static Ipv4Address GetAny(void)
bool IsSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
bool IsLocalMulticast(void) const
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope(void) const
Get address scope.
InterfaceAddressScope_e
Address scope.
Ipv4Mask GetMask(void) const
Get the network mask.
Ipv4Address GetLocal(void) const
Get the local address.
bool IsSecondary(void) const
Check if the address is a secondary address.
The IPv4 representation of a network interface.
void SetUp(void)
Enable this interface.
void SetNode(Ptr< Node > node)
Set node associated with interface.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
bool AddAddress(Ipv4InterfaceAddress address)
uint32_t GetNAddresses(void) const
Ptr< ArpCache > GetArpCache() const
uint16_t GetMetric(void) const
Ptr< NetDevice > GetDevice(void) const
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
void SetDown(void)
Disable this interface.
bool IsUp(void) const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
void SetForwarding(bool val)
void SetMetric(uint16_t metric)
bool IsEntire() const
If all fragments have been added.
Ptr< Packet > GetPartialPacket() const
Get the complete part of the packet.
FragmentsTimeoutsListI_t GetTimeoutIter()
Get the Timeout iterator.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
Ptr< Packet > GetPacket() const
Get the entire packet.
void SetTimeoutIter(FragmentsTimeoutsListI_t iter)
Set the Timeout iterator.
Implement the IPv4 layer.
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
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...
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.
@ DROP_BAD_CHECKSUM
Bad checksum.
@ DROP_NO_ROUTE
No route to host.
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
@ DROP_DUPLICATE
Duplicate packet received.
@ DROP_TTL_EXPIRED
Packet TTL has expired.
@ DROP_ROUTE_ERROR
Route error.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
void DecreaseIdentification(Ipv4Address source, Ipv4Address destination, uint8_t protocol)
Decrease the identification value for a dropped or recursed packet.
Ipv4InterfaceList m_interfaces
List of IPv4 interfaces.
bool IsUp(uint32_t i) const
MapFragments_t m_fragments
Fragmented packets.
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex)
Remove the address at addressIndex on named interface.
std::pair< uint64_t, uint32_t > FragmentKey_t
Key identifying a fragmented packet.
void DeleteRawSocket(Ptr< Socket > socket)
Deletes a particular raw socket.
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...
Time m_expire
duplicate entry expiration delay
virtual bool GetIpForward(void) const
Get the IP forwarding state.
bool m_ipForward
Forwarding packets (i.e.
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...
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 RouteInputError(Ptr< const Packet > p, const Ipv4Header &ipHeader, Socket::SocketErrno sockErrno)
Fallback when no route is found.
void SetForwarding(uint32_t i, bool val)
virtual void NotifyNewAggregate()
This function will notify other components connected to the node that a new stack member is now conne...
uint32_t GetNAddresses(uint32_t interface) const
uint16_t GetMtu(uint32_t i) const
virtual void SetIpForward(bool forward)
Set or unset the IP forwarding state.
virtual void SetWeakEsModel(bool model)
Set or unset the Weak Es Model.
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const
Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const
Get the routing protocol to be used by this Ipv4 stack.
bool IsUnicast(Ipv4Address ad) const
Check if an IPv4 address is unicast according to the node.
void HandleFragmentsTimeout(FragmentKey_t key, Ipv4Header &ipHeader, uint32_t iif)
Process the timeout for packet fragments.
void DoFragmentation(Ptr< Packet > packet, const Ipv4Header &ipv4Header, uint32_t outIfaceMtu, std::list< Ipv4PayloadHeaderPair > &listFragments)
Fragment a packet.
SocketList m_sockets
List of IPv4 raw sockets.
virtual Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest)
Choose the source address to use with destination address.
bool m_enableDpd
Enable multicast duplicate packet detection.
bool AddAddress(uint32_t i, Ipv4InterfaceAddress address)
virtual ~Ipv4L3Protocol()
std::map< std::pair< uint64_t, uint8_t >, uint16_t > m_identification
Identification (for each {src, dst, proto} tuple)
Time m_fragmentExpirationTimeout
Expiration timeout.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_localDeliverTrace
Trace of locally delivered packets.
virtual void Remove(Ptr< IpL4Protocol > protocol)
void HandleTimeout(void)
Handles a fragmented packet timeout.
Ptr< NetDevice > GetNetDevice(uint32_t i)
EventId m_timeoutEvent
Event for the next scheduled timeout.
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.
Time m_purge
time between purging expired duplicate entries
TracedCallback< const Ipv4Header &, Ptr< const Packet >, DropReason, Ptr< Ipv4 >, uint32_t > m_dropTrace
Trace of dropped packets.
void SetNode(Ptr< Node > node)
Set node associated with this stack.
void IpMulticastForward(Ptr< Ipv4MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a multicast packet.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_rxTrace
Trace of received packets.
uint16_t GetMetric(uint32_t i) const
void RemoveDuplicates(void)
Remove expired duplicates packet entry.
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
bool IsForwarding(uint32_t i) const
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_txTrace
Trace of transmitted packets.
void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)
bool ProcessFragment(Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif)
Process a packet fragment.
Ipv4InterfaceReverseContainer m_reverseInterfacesContainer
Container of NetDevice / Interface index associations.
void SetupLoopback(void)
Setup loopback interface.
void LocalDeliver(Ptr< const Packet > p, Ipv4Header const &ip, uint32_t iif)
Deliver a packet.
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,...
EventId m_cleanDpd
event to cleanup expired duplicate entries
L4List_t m_protocols
List of transport protocol.
Ptr< Socket > CreateRawSocket(void)
Creates a raw socket.
Ptr< Ipv4RoutingProtocol > m_routingProtocol
Routing protocol associated with the stack.
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
void SendRealOut(Ptr< Ipv4Route > route, Ptr< Packet > packet, Ipv4Header const &ipHeader)
Send packet with route.
Ptr< Icmpv4L4Protocol > GetIcmp(void) const
Get ICMPv4 protocol.
uint32_t AddInterface(Ptr< NetDevice > device)
virtual void DoDispose(void)
Destructor implementation.
uint8_t m_defaultTtl
Default TTL.
bool m_weakEsModel
Weak ES model state.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets.
void SetMetric(uint32_t i, uint16_t metric)
DupMap_t m_dups
map of packet duplicate tuples to expiry event
Ptr< Node > m_node
Node attached to stack.
bool UpdateDuplicate(Ptr< const Packet > p, const Ipv4Header &header)
Registers duplicate entry, return false if new.
virtual void Insert(Ptr< IpL4Protocol > protocol)
int32_t GetInterfaceForAddress(Ipv4Address addr) const
Return the interface number of the interface that has been assigned the specified IP address.
Ptr< Ipv4Interface > GetInterface(uint32_t i) const
Get an interface.
void IpForward(Ptr< Ipv4Route > rtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a packet.
void SetDefaultTtl(uint8_t ttl)
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const
uint32_t GetNInterfaces(void) const
FragmentsTimeoutsListI_t SetTimeout(FragmentKey_t key, Ipv4Header ipHeader, uint32_t iif)
Set a new timeout "event" for a fragmented packet.
virtual bool GetWeakEsModel(void) const
Get the Weak Es Model status.
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...
std::pair< int, int32_t > L4ListKey_t
Container of the IPv4 L4 keys: protocol number, interface index.
std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts..
bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const
Determine whether address and interface corresponding to received packet can be accepted for local de...
uint32_t AddIpv4Interface(Ptr< Ipv4Interface > interface)
Add an IPv4 interface to the stack.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_multicastForwardTrace
Trace of multicast forwarded packets.
a class to represent an Ipv4 address mask
static Ipv4Mask GetLoopback(void)
bool ForwardUp(Ptr< const Packet > p, Ipv4Header ipHeader, Ptr< Ipv4Interface > incomingInterface)
Forward up to receive method.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
void SetGateway(Ipv4Address gw)
Ptr< NetDevice > GetOutputDevice(void) const
void SetDestination(Ipv4Address dest)
void SetSource(Ipv4Address src)
Ipv4Address GetGateway(void) const
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
PacketType
Packet types are used as they are in Linux.
static bool ChecksumEnabled(void)
uint32_t GetId(void) const
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t GetNDevices(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
virtual void DoDispose(void)
Destructor implementation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Container for a set of ns3::Object pointers.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void RemoveAtEnd(uint32_t size)
Remove size bytes from the end of the current packet.
uint64_t GetUid(void) const
Returns the packet's Uid.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
void Print(std::ostream &os) const
Print the packet contents.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now(void)
Return the current simulation virtual time.
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
SocketErrno
Enumeration of the possible errors returned by a socket.
indicates whether the socket has IP_TOS set.
uint8_t GetTos(void) const
Get the tag's TOS.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
uint8_t GetTtl(void) const
Get the tag's TTL.
indicates whether the socket has a priority set.
void SetPriority(uint8_t priority)
Set the tag's priority.
Simulation virtual time values and global simulation resolution.
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
AttributeValue implementation for Time.
Introspection did not find any typical Config paths.
virtual void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Called by NetDevices, incoming packet.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint32_t Hash32(const char *buffer, const std::size_t size)
Compute 32-bit hash of a byte buffer, using the default hash function.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
U * PeekPointer(const Ptr< U > &p)