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++)
759 NS_LOG_FUNCTION (
this << packet << source << destination << uint32_t (protocol) << route);
761 bool mayFragment =
true;
797 if (!route->GetGateway ().IsInitialized ())
803 NS_FATAL_ERROR (
"Ipv4L3Protocol::Send case 1a: packet passed with a route but the Gateway address is uninitialized. This case not yet implemented.");
807 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 1b: passed in with route and valid gateway");
821 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 2: limited broadcast - no route");
822 uint32_t ifaceIndex = 0;
823 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
824 ifaceIter !=
m_interfaces.end (); ifaceIter++, ifaceIndex++)
828 bool sendIt = source.
IsAny ();
830 for (uint32_t index = 0; !sendIt && index < outInterface->
GetNAddresses (); index++)
842 route->SetDestination (destination);
844 route->SetSource (source);
845 route->SetOutputDevice (outInterface->
GetDevice ());
847 Send (pktCopyWithTags, source, destination, protocol, route);
854 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
866 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 3: subnet directed bcast to " << ifAddr.
GetLocal () <<
" - no route");
869 route->SetDestination (destination);
871 route->SetSource (source);
872 route->SetOutputDevice (outInterface->
GetDevice ());
874 Send (pktCopyWithTags, source, destination, protocol, route);
881 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 4: not broadcast and passed in with no route " << destination);
887 newRoute =
m_routingProtocol->RouteOutput (pktCopyWithTags, ipHeader, oif, errno_);
891 NS_LOG_ERROR (
"Ipv4L3Protocol::Send: m_routingProtocol == 0");
896 Send (pktCopyWithTags, source, destination, protocol, newRoute);
911 uint64_t src = source.
Get ();
912 uint64_t dst = destination.
Get ();
913 uint64_t srcDst = dst | (src << 32);
914 std::pair<uint64_t, uint8_t> key = std::make_pair (srcDst, protocol);
923 uint16_t payloadSize,
928 NS_LOG_FUNCTION (
this << source << destination << (uint16_t)protocol << payloadSize << (uint16_t)ttl << (uint16_t)tos << mayFragment);
937 uint64_t src = source.
Get ();
938 uint64_t dst = destination.
Get ();
939 uint64_t srcDst = dst | (src << 32);
940 std::pair<uint64_t, uint8_t> key = std::make_pair (srcDst, protocol);
942 if (mayFragment ==
true)
978 int32_t
interface = GetInterfaceForDevice (outDev);
981 NS_LOG_LOGIC (
"Send via NetDevice ifIndex " << outDev->
GetIfIndex () <<
" ipv4InterfaceIndex " << interface);
984 std::string targetLabel;
985 if (route->GetGateway ().IsAny ())
988 targetLabel =
"destination";
992 target = route->GetGateway ();
993 targetLabel =
"gateway";
996 if (outInterface->
IsUp ())
998 NS_LOG_LOGIC (
"Send to " << targetLabel <<
" " << target);
1001 std::list<Ipv4PayloadHeaderPair> listFragments;
1003 for ( std::list<Ipv4PayloadHeaderPair>::iterator it = listFragments.begin (); it != listFragments.end (); it++ )
1006 CallTxTrace (it->second, it->first,
this, interface);
1007 outInterface->
Send (it->first, it->second, target);
1013 outInterface->
Send (packet, ipHeader, target);
1025 std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap ();
1026 std::map<uint32_t, uint32_t>::iterator mapIter;
1028 for (mapIter = ttlMap.begin (); mapIter != ttlMap.end (); mapIter++)
1030 uint32_t
interface = mapIter->
first;
1036 if (ipHeader.
GetTtl () == 0)
1042 NS_LOG_LOGIC (
"Forward multicast via interface " << interface);
1044 rtentry->SetSource (ipHeader.
GetSource ());
1066 if (ipHeader.
GetTtl () == 0)
1073 icmp->SendTimeExceededTtl (ipHeader, packet,
false);
1103 NS_LOG_LOGIC (
"Received a fragment, processing " << *p );
1104 bool isPacketComplete;
1106 if ( isPacketComplete ==
false)
1110 NS_LOG_LOGIC (
"Got last fragment, Packet is complete " << *p );
1139 bool subnetDirected =
false;
1146 subnetDirected =
true;
1149 if (subnetDirected ==
false)
1151 GetIcmp ()->SendDestUnreachPort (ipHeader, copy);
1242 if (test.GetLocal ().CombineMask (test.GetMask ()) == dest.
CombineMask (test.GetMask ()))
1244 if (test.IsSecondary () ==
false)
1246 return test.GetLocal ();
1270 if (iaddr.
GetScope () > scope)
continue;
1301 NS_LOG_WARN (
"Could not find source address for " << dst <<
" and scope "
1302 << scope <<
", returning 0");
1335 return interface->
IsUp ();
1348 if (interface->GetDevice ()->GetMtu () >= 68)
1350 interface->
SetUp ();
1359 NS_LOG_LOGIC (
"Interface " <<
int(i) <<
" is set to be down for IPv4. Reason: not respecting minimum IPv4 MTU (68 octects)");
1381 NS_LOG_LOGIC (
"Forwarding state: " << interface->IsForwarding ());
1382 return interface->IsForwarding ();
1407 (*i)->SetForwarding (forward);
1436 NS_LOG_LOGIC (
"Route input failure-- dropping packet to " << ipHeader <<
" with errno " << sockErrno);
1455 "IPv4 fragmentation implementation only works without option headers." );
1457 uint16_t offset = 0;
1458 bool moreFragment =
true;
1461 uint32_t currentFragmentablePartSize = 0;
1466 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.
GetSerializedSize () ) & ~uint32_t (0x7);
1468 NS_LOG_LOGIC (
"Fragmenting - Target Size: " << fragmentSize );
1474 if (p->
GetSize () > offset + fragmentSize )
1476 moreFragment =
true;
1477 currentFragmentablePartSize = fragmentSize;
1482 moreFragment =
false;
1483 currentFragmentablePartSize = p->
GetSize () - offset;
1484 if (!isLastFragment)
1494 NS_LOG_LOGIC (
"Fragment creation - " << offset <<
", " << currentFragmentablePartSize );
1508 NS_LOG_LOGIC (
"New fragment Header " << fragmentHeader);
1510 std::ostringstream oss;
1511 oss << fragmentHeader;
1512 fragment->
Print (oss);
1516 listFragments.emplace_back (fragment, fragmentHeader);
1518 offset += currentFragmentablePartSize;
1521 while (moreFragment);
1537 key.first = addressCombination;
1538 key.second = idProto;
1542 MapFragments_t::iterator it =
m_fragments.find (key);
1545 fragments = Create<Fragments> ();
1546 m_fragments.insert (std::make_pair (key, fragments));
1553 fragments = it->second;
1573 : m_moreFragment (0)
1588 std::list<std::pair<Ptr<Packet>, uint16_t> >::iterator it;
1592 if (it->second > fragmentOffset)
1600 m_moreFragment = moreFragment;
1611 bool ret = !m_moreFragment &&
m_fragments.size () > 0;
1615 uint16_t lastEndOffset = 0;
1620 NS_LOG_LOGIC (
"Checking overlaps " << lastEndOffset <<
" - " << it->second );
1622 if (lastEndOffset < it->
second)
1628 uint16_t fragmentEnd = it->first->GetSize () + it->second;
1629 lastEndOffset =
std::max ( lastEndOffset, fragmentEnd );
1641 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1644 uint16_t lastEndOffset = p->
GetSize ();
1649 if ( lastEndOffset > it->second )
1655 uint32_t newStart = lastEndOffset - it->second;
1656 if ( it->first->GetSize () > newStart )
1658 uint32_t newSize = it->first->GetSize () - newStart;
1668 lastEndOffset = p->
GetSize ();
1679 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1682 uint16_t lastEndOffset = 0;
1691 if ( lastEndOffset > it->second )
1693 uint32_t newStart = lastEndOffset - it->second;
1694 uint32_t newSize = it->first->
GetSize () - newStart;
1698 else if ( lastEndOffset == it->second )
1703 lastEndOffset = p->
GetSize ();
1712 m_timeoutIter = iter;
1719 return m_timeoutIter;
1728 MapFragments_t::iterator it =
m_fragments.find (key);
1729 Ptr<Packet> packet = it->second->GetPartialPacket ();
1735 icmp->SendTimeExceededTtl (ipHeader, packet,
true);
1757 uint64_t
hash =
id << 32;
1771 std::ostringstream oss (std::ios_base::binary);
1773 std::string bytes = oss.str ();
1775 NS_ASSERT_MSG (bytes.size () >= 20,
"Degenerate header serialization");
1779 bytes[6] = bytes[7] = 0;
1781 bytes[10] = bytes[11] = 0;
1800 std::hex << std::get<0> (key) <<
", " <<
1801 std::dec << +std::get<1> (key) <<
", " <<
1802 std::get<2> (key) <<
", " <<
1803 std::get<3> (key) <<
")");
1806 DupMap_t::iterator iter;
1807 bool inserted, isDup;
1808 std::tie (iter, inserted) =
m_dups.emplace (key,
Seconds (0));
1821 DupMap_t::size_type n = 0;
1823 auto iter =
m_dups.cbegin ();
1824 while (iter !=
m_dups.cend ())
1826 if (iter->second < expire)
1829 std::hex << std::get<0> (iter->first) <<
", " <<
1830 std::dec << +std::get<1> (iter->first) <<
", " <<
1831 std::get<2> (iter->first) <<
", " <<
1832 std::get<3> (iter->first) <<
")");
1833 iter =
m_dups.erase (iter);
1842 NS_LOG_DEBUG (
"Purged " << n <<
" expired duplicate entries out of " << (n +
m_dups.size ()));
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
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.
virtual uint32_t GetIfIndex(void) const =0
virtual uint16_t GetMtu(void) const =0
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 DoDispose(void)
Destructor implementation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
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.
std::size_t hash(const BasicJsonType &j)
hash a JSON value
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)