31 #include "ns3/boolean.h"
32 #include "ns3/callback.h"
33 #include "ns3/ipv4-address.h"
35 #include "ns3/net-device.h"
37 #include "ns3/object-vector.h"
38 #include "ns3/packet.h"
39 #include "ns3/socket.h"
40 #include "ns3/string.h"
41 #include "ns3/trace-source-accessor.h"
42 #include "ns3/traffic-control-layer.h"
43 #include "ns3/uinteger.h"
58 TypeId(
"ns3::Ipv4L3Protocol")
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",
80 "Expiration delay for duplicate cache entries",
84 .AddAttribute(
"PurgeExpiredPeriod",
85 "Time between purges of expired duplicate packet entries, "
86 "0 means never purge",
91 "Send ipv4 packet to outgoing interface.",
93 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
95 "Receive ipv4 packet from incoming interface.",
97 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
98 .AddTraceSource(
"Drop",
101 "ns3::Ipv4L3Protocol::DropTracedCallback")
102 .AddAttribute(
"InterfaceList",
103 "The set of Ipv4 interfaces associated to this Ipv4 stack.",
106 MakeObjectVectorChecker<Ipv4Interface>())
108 .AddTraceSource(
"SendOutgoing",
109 "A newly-generated packet by this node is "
110 "about to be queued for transmission",
112 "ns3::Ipv4L3Protocol::SentTracedCallback")
113 .AddTraceSource(
"UnicastForward",
114 "A unicast IPv4 packet was received by this node "
115 "and is being forwarded to another node",
117 "ns3::Ipv4L3Protocol::SentTracedCallback")
118 .AddTraceSource(
"MulticastForward",
119 "A multicast IPv4 packet was received by this node "
120 "and is being forwarded to another node",
122 "ns3::Ipv4L3Protocol::SentTracedCallback")
123 .AddTraceSource(
"LocalDeliver",
124 "An IPv4 packet was received by/for this node, "
125 "and it is being forward up the stack",
127 "ns3::Ipv4L3Protocol::SentTracedCallback")
168 <<
" on interface " <<
int(interfaceIndex));
182 NS_LOG_WARN(
"Trying to remove an non-existent default protocol "
200 NS_LOG_WARN(
"Trying to remove an non-existent protocol "
202 <<
int(interfaceIndex));
223 if (interfaceIndex >= 0)
226 auto key = std::make_pair(protocolNumber, interfaceIndex);
234 auto key = std::make_pair(protocolNumber, -1);
287 Ptr<Node> node = this->GetObject<Node>();
336 it->second =
nullptr;
372 device = CreateObject<LoopbackNetDevice>();
375 interface->SetDevice(device);
376 interface->SetNode(
m_node);
379 interface->AddAddress(ifaceAddr);
419 tc->RegisterProtocolHandler(
426 interface->SetDevice(device);
427 interface->SetTrafficControl(tc);
464 int32_t
interface = 0;
467 for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++)
469 if ((*i)->GetAddress(j).GetLocal() ==
address)
483 int32_t
interface = 0;
486 for (uint32_t j = 0; j < (*i)->GetNAddresses(); j++)
488 if ((*i)->GetAddress(j).GetLocal().CombineMask(mask) ==
address.CombineMask(mask))
506 return (*iter).second;
535 if (MulticastCheckGroup(iif,
address))
553 if (j == uint32_t(iif))
563 <<
" match) on another interface");
569 NS_LOG_LOGIC(
"For me (interface broadcast address on another interface)");
586 NS_LOG_FUNCTION(
this << device << p << protocol << from << to << packetType);
590 int32_t
interface = GetInterfaceForDevice(device);
591 NS_ASSERT_MSG(interface != -1,
"Received a packet from an interface that is not known to IPv4");
597 if (ipv4Interface->
IsUp())
603 NS_LOG_LOGIC(
"Dropping received packet -- interface is down");
625 NS_LOG_LOGIC(
"Dropping received packet -- checksum not ok");
648 std::list<ArpCache::Entry*> entryList = arpCache->
LookupInverse(from);
649 for (
auto iter = entryList.begin(); iter != entryList.end(); iter++)
651 if ((*iter)->IsAlive())
653 (*iter)->UpdateSeen();
663 socket->
ForwardUp(packet, ipHeader, ipv4Interface);
676 NS_LOG_WARN(
"No route found for forwarding packet. Drop.");
708 for (uint32_t ifaceIndex = 0; ifaceIndex <
GetNInterfaces(); ifaceIndex++)
713 NS_LOG_LOGIC(
"Testing address " << ad <<
" with subnet-directed broadcast "
765 NS_LOG_FUNCTION(
this << packet << source << destination << uint32_t(protocol) << route);
767 bool mayFragment =
true;
805 if (!route->GetGateway().IsInitialized())
811 NS_FATAL_ERROR(
"Ipv4L3Protocol::Send case 1a: packet passed with a route but the "
812 "Gateway address is uninitialized. This case not yet implemented.");
816 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 1b: passed in with route and valid gateway");
830 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 2: limited broadcast - no route");
831 uint32_t ifaceIndex = 0;
833 ifaceIter++, ifaceIndex++)
837 bool sendIt = source.
IsAny();
839 for (uint32_t index = 0; !sendIt && index < outInterface->
GetNAddresses(); index++)
851 route->SetDestination(destination);
853 route->SetSource(source);
854 route->SetOutputDevice(outInterface->
GetDevice());
856 Send(pktCopyWithTags, source, destination, protocol, route);
876 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 3: subnet directed bcast to "
877 << ifAddr.
GetLocal() <<
" - no route");
880 route->SetDestination(destination);
882 route->SetSource(source);
883 route->SetOutputDevice(outInterface->
GetDevice());
885 Send(pktCopyWithTags, source, destination, protocol, route);
892 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 4: not broadcast and passed in with no route "
899 newRoute =
m_routingProtocol->RouteOutput(pktCopyWithTags, ipHeader, oif, errno_);
903 NS_LOG_ERROR(
"Ipv4L3Protocol::Send: m_routingProtocol == 0");
908 Send(pktCopyWithTags, source, destination, protocol, newRoute);
923 uint64_t src = source.
Get();
924 uint64_t dst = destination.
Get();
925 uint64_t srcDst = dst | (src << 32);
926 std::pair<uint64_t, uint8_t> key = std::make_pair(srcDst, protocol);
934 uint16_t payloadSize,
939 NS_LOG_FUNCTION(
this << source << destination << (uint16_t)protocol << payloadSize
940 << (uint16_t)ttl << (uint16_t)tos << mayFragment);
949 uint64_t src = source.
Get();
950 uint64_t dst = destination.
Get();
951 uint64_t srcDst = dst | (src << 32);
952 std::pair<uint64_t, uint8_t> key = std::make_pair(srcDst, protocol);
988 int32_t
interface = GetInterfaceForDevice(outDev);
991 NS_LOG_LOGIC(
"Send via NetDevice ifIndex " << outDev->GetIfIndex() <<
" ipv4InterfaceIndex "
995 std::string targetLabel;
996 if (route->GetGateway().IsAny())
999 targetLabel =
"destination";
1003 target = route->GetGateway();
1004 targetLabel =
"gateway";
1007 if (outInterface->
IsUp())
1009 NS_LOG_LOGIC(
"Send to " << targetLabel <<
" " << target);
1012 std::list<Ipv4PayloadHeaderPair> listFragments;
1014 for (
auto it = listFragments.begin(); it != listFragments.end(); it++)
1017 CallTxTrace(it->second, it->first,
this, interface);
1018 outInterface->
Send(it->first, it->second, target);
1024 outInterface->
Send(packet, ipHeader, target);
1038 std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap();
1040 for (
auto mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++)
1042 uint32_t
interface = mapIter->
first;
1048 if (ipHeader.
GetTtl() == 0)
1054 NS_LOG_LOGIC(
"Forward multicast via interface " << interface);
1056 rtentry->SetSource(ipHeader.
GetSource());
1077 if (ipHeader.
GetTtl() == 0)
1083 icmp->SendTimeExceededTtl(ipHeader, packet,
false);
1113 NS_LOG_LOGIC(
"Received a fragment, processing " << *p);
1114 bool isPacketComplete;
1116 if (!isPacketComplete)
1120 NS_LOG_LOGIC(
"Got last fragment, Packet is complete " << *p);
1148 bool subnetDirected =
false;
1156 subnetDirected =
true;
1159 if (!subnetDirected)
1161 GetIcmp()->SendDestUnreachPort(ipHeader, copy);
1252 if (test.GetLocal().CombineMask(test.GetMask()) == dest.
CombineMask(test.GetMask()))
1254 if (!test.IsSecondary())
1256 return test.GetLocal();
1320 NS_LOG_WARN(
"Could not find source address for " << dst <<
" and scope " << scope
1321 <<
", returning 0");
1346 return interface->
GetDevice()->GetMtu();
1354 return interface->
IsUp();
1367 if (interface->GetDevice()->GetMtu() >= 68)
1381 <<
" is set to be down for IPv4. Reason: not respecting minimum IPv4 MTU (68 octets)");
1403 NS_LOG_LOGIC(
"Forwarding state: " << interface->IsForwarding());
1404 return interface->IsForwarding();
1429 (*i)->SetForwarding(forward);
1474 NS_LOG_LOGIC(
"Route input failure-- dropping packet to " << ipHeader <<
" with errno "
1484 uint32_t outIfaceMtu,
1485 std::list<Ipv4PayloadHeaderPair>& listFragments)
1497 "IPv4 fragmentation implementation only works without option headers.");
1499 uint16_t offset = 0;
1500 bool moreFragment =
true;
1503 uint32_t currentFragmentablePartSize = 0;
1508 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.
GetSerializedSize()) & ~uint32_t(0x7);
1510 NS_LOG_LOGIC(
"Fragmenting - Target Size: " << fragmentSize);
1516 if (p->
GetSize() > offset + fragmentSize)
1518 moreFragment =
true;
1519 currentFragmentablePartSize = fragmentSize;
1524 moreFragment =
false;
1525 currentFragmentablePartSize = p->
GetSize() - offset;
1526 if (!isLastFragment)
1536 NS_LOG_LOGIC(
"Fragment creation - " << offset <<
", " << currentFragmentablePartSize);
1550 NS_LOG_LOGIC(
"New fragment Header " << fragmentHeader);
1552 std::ostringstream oss;
1553 oss << fragmentHeader;
1554 fragment->
Print(oss);
1558 listFragments.emplace_back(fragment, fragmentHeader);
1560 offset += currentFragmentablePartSize;
1562 }
while (moreFragment);
1570 uint64_t addressCombination =
1578 key.first = addressCombination;
1579 key.second = idProto;
1586 fragments = Create<Fragments>();
1587 m_fragments.insert(std::make_pair(key, fragments));
1594 fragments = it->second;
1606 fragments =
nullptr;
1615 : m_moreFragment(false)
1622 uint16_t fragmentOffset,
1627 std::list<std::pair<Ptr<Packet>, uint16_t>>::iterator it;
1631 if (it->second > fragmentOffset)
1639 m_moreFragment = moreFragment;
1650 bool ret = !m_moreFragment && !
m_fragments.empty();
1654 uint16_t lastEndOffset = 0;
1659 NS_LOG_LOGIC(
"Checking overlaps " << lastEndOffset <<
" - " << it->second);
1661 if (lastEndOffset < it->
second)
1667 uint16_t fragmentEnd = it->first->GetSize() + it->second;
1668 lastEndOffset =
std::max(lastEndOffset, fragmentEnd);
1683 uint16_t lastEndOffset = p->
GetSize();
1688 if (lastEndOffset > it->second)
1694 uint32_t newStart = lastEndOffset - it->second;
1695 if (it->first->GetSize() > newStart)
1697 uint32_t newSize = it->first->GetSize() - newStart;
1721 uint16_t lastEndOffset = 0;
1730 if (lastEndOffset > it->second)
1732 uint32_t newStart = lastEndOffset - it->second;
1733 uint32_t newSize = it->first->
GetSize() - newStart;
1737 else if (lastEndOffset == it->second)
1751 m_timeoutIter = iter;
1757 return m_timeoutIter;
1766 Ptr<Packet> packet = it->second->GetPartialPacket();
1772 icmp->SendTimeExceededTtl(ipHeader, packet,
true);
1777 it->second =
nullptr;
1794 uint64_t
hash =
id << 32;
1808 std::ostringstream oss(std::ios_base::binary);
1810 std::string bytes = oss.str();
1812 NS_ASSERT_MSG(bytes.size() >= 20,
"Degenerate header serialization");
1816 bytes[6] = bytes[7] = 0;
1818 bytes[10] = bytes[11] = 0;
1836 NS_LOG_DEBUG(
"Packet " << p->
GetUid() <<
" key = (" << std::hex << std::get<0>(key) <<
", "
1837 << std::dec << +std::get<1>(key) <<
", " << std::get<2>(key) <<
", "
1838 << std::get<3>(key) <<
")");
1854 DupMap_t::size_type n = 0;
1856 auto iter =
m_dups.cbegin();
1857 while (iter !=
m_dups.cend())
1859 if (iter->second < expire)
1861 NS_LOG_LOGIC(
"Remove key = (" << std::hex << std::get<0>(iter->first) <<
", "
1862 << std::dec << +std::get<1>(iter->first) <<
", "
1863 << std::get<2>(iter->first) <<
", "
1864 << std::get<3>(iter->first) <<
")");
1865 iter =
m_dups.erase(iter);
1874 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()
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)
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
This is the implementation of the ICMP protocol as described in RFC 792.
static uint16_t GetStaticProtocolNumber()
Get the protocol number.
virtual RxStatus Receive(Ptr< Packet > p, const Ipv4Header &header, Ptr< Ipv4Interface > incomingInterface)=0
Called from lower-level layers to send the packet up in the stack.
virtual int GetProtocolNumber() const =0
Returns the protocol number of this protocol.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetLoopback()
bool IsSubnetDirectedBroadcast(const Ipv4Mask &mask) const
Generate subnet-directed broadcast address corresponding to mask.
Ipv4Address CombineMask(const Ipv4Mask &mask) const
Combine this address with a network mask.
uint32_t Get() const
Get the host-order 32-bit IP address.
static Ipv4Address GetAny()
bool IsLocalMulticast() const
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
Ipv4Mask GetMask() const
Get the network mask.
InterfaceAddressScope_e
Address scope.
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope() const
Get address scope.
Ipv4Address GetLocal() const
Get the local address.
bool IsSecondary() const
Check if the address is a secondary address.
Ipv4Address GetBroadcast() const
Get the broadcast address.
The IPv4 representation of a network interface.
uint32_t GetNAddresses() const
void SetNode(Ptr< Node > node)
Set node associated with interface.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
bool AddAddress(Ipv4InterfaceAddress address)
uint16_t GetMetric() const
bool IsUp() const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
void SetUp()
Enable this interface.
Ptr< ArpCache > GetArpCache() const
Ptr< NetDevice > GetDevice() const
void SetDown()
Disable this interface.
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
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.
void DeleteRawSocket(Ptr< Socket > socket) override
Deletes a particular raw socket.
MapFragments_t m_fragments
Fragmented packets.
void LocalDeliver(Ptr< const Packet > p, const Ipv4Header &ip, uint32_t iif)
Deliver a packet.
bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const override
Determine whether address and interface corresponding to received packet can be accepted for local de...
std::pair< uint64_t, uint32_t > FragmentKey_t
Key identifying a fragmented packet.
Time m_expire
duplicate entry expiration delay
bool m_strongEndSystemModel
Strong End System Model state.
Ipv4RoutingProtocol::ErrorCallback m_ecb
Error callback.
~Ipv4L3Protocol() override
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...
void SetUp(uint32_t i) override
uint32_t GetNInterfaces() const override
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 SetMetric(uint32_t i, uint16_t metric) override
std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts..
void DoDispose() override
Destructor implementation.
void Remove(Ptr< IpL4Protocol > protocol) override
void SetIpForward(bool forward) override
Set or unset the IP forwarding state.
bool AddAddress(uint32_t i, Ipv4InterfaceAddress address) override
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets.
bool GetWeakEsModel() const override
Get the Weak Es Model status.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_localDeliverTrace
Trace of locally delivered packets.
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.
uint16_t GetMtu(uint32_t i) const override
Ptr< Icmpv4L4Protocol > GetIcmp() const
Get ICMPv4 protocol.
Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const override
void RemoveDuplicates()
Remove expired duplicates packet entry.
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.
bool m_enableDpd
Enable multicast duplicate packet detection.
std::map< std::pair< uint64_t, uint8_t >, uint16_t > m_identification
Identification (for each {src, dst, proto} tuple)
bool IsUp(uint32_t i) const override
Time m_fragmentExpirationTimeout
Expiration timeout.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets.
EventId m_timeoutEvent
Event for the next scheduled timeout.
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 speci...
void SetWeakEsModel(bool model) override
Set or unset the Weak Es Model.
Time m_purge
time between purging expired duplicate entries
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 override
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_txTrace
Trace of transmitted packets.
Ptr< Socket > CreateRawSocket() override
Creates a raw socket.
bool ProcessFragment(Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif)
Process a packet fragment.
static TypeId GetTypeId()
Get the type ID.
Ipv4RoutingProtocol::UnicastForwardCallback m_ucb
Unicast forward callback.
void HandleTimeout()
Handles a fragmented packet timeout.
Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest) override
Choose the source address to use with destination address.
void NotifyNewAggregate() override
This function will notify other components connected to the node that a new stack member is now conne...
Ipv4InterfaceReverseContainer m_reverseInterfacesContainer
Container of NetDevice / Interface index associations.
uint32_t AddInterface(Ptr< NetDevice > device) override
EventId m_cleanDpd
event to cleanup expired duplicate entries
void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route) override
bool IsForwarding(uint32_t i) const override
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route) override
Ptr< NetDevice > GetNetDevice(uint32_t i) override
L4List_t m_protocols
List of transport protocol.
uint32_t GetNAddresses(uint32_t interface) const override
void SetDown(uint32_t i) override
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol) override
Register a new routing protocol to be used by this Ipv4 stack.
Ptr< Ipv4RoutingProtocol > GetRoutingProtocol() const override
Get the routing protocol to be used by this Ipv4 stack.
Ptr< Ipv4RoutingProtocol > m_routingProtocol
Routing protocol associated with the stack.
Ipv4RoutingProtocol::MulticastForwardCallback m_mcb
Multicast forward callback.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_multicastForwardTrace
Trace of multicast forwarded packets.
bool GetStrongEndSystemModel() const override
Get the Strong End System Model status.
uint8_t m_defaultTtl
Default TTL.
DupMap_t m_dups
map of packet duplicate tuples to expiry event
void SendRealOut(Ptr< Ipv4Route > route, Ptr< Packet > packet, const Ipv4Header &ipHeader)
Send packet with route.
Ptr< Node > m_node
Node attached to stack.
bool UpdateDuplicate(Ptr< const Packet > p, const Ipv4Header &header)
Registers duplicate entry, return false if new.
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,...
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) override
Remove the address at addressIndex on named interface.
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 thi...
int32_t GetInterfaceForAddress(Ipv4Address addr) const override
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 SetForwarding(uint32_t i, bool val) override
void SetupLoopback()
Setup loopback interface.
void SetStrongEndSystemModel(bool model) override
Set or unset the Strong End System Model.
void SetDefaultTtl(uint8_t ttl)
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const override
Ipv4RoutingProtocol::LocalDeliverCallback m_lcb
Local delivery callback.
void Insert(Ptr< IpL4Protocol > protocol) override
TracedCallback< const Ipv4Header &, Ptr< const Packet >, DropReason, Ptr< Ipv4 >, uint32_t > m_dropTrace
Trace of dropped packets.
FragmentsTimeoutsListI_t SetTimeout(FragmentKey_t key, Ipv4Header ipHeader, uint32_t iif)
Set a new timeout "event" for a fragmented packet.
bool GetIpForward() const override
Get the IP forwarding state.
std::pair< int, int32_t > L4ListKey_t
Container of the IPv4 L4 keys: protocol number, interface index.
uint32_t AddIpv4Interface(Ptr< Ipv4Interface > interface)
Add an IPv4 interface to the stack.
a class to represent an Ipv4 address mask
static Ipv4Mask GetLoopback()
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.
PacketType
Packet types are used as they are in Linux.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t GetNDevices() const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static bool ChecksumEnabled()
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoDispose()
Destructor implementation.
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 GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
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.
uint64_t GetUid() const
Returns the packet's Uid.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
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() 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() 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() const
Exactly equivalent to t > 0.
The Traffic Control layer aims at introducing an equivalent of the Linux Traffic Control infrastructu...
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...
#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 > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
U * PeekPointer(const Ptr< U > &p)