20#include "ns3/boolean.h"
21#include "ns3/callback.h"
22#include "ns3/ipv4-address.h"
24#include "ns3/net-device.h"
26#include "ns3/object-vector.h"
27#include "ns3/packet.h"
28#include "ns3/socket.h"
29#include "ns3/string.h"
30#include "ns3/trace-source-accessor.h"
31#include "ns3/traffic-control-layer.h"
32#include "ns3/uinteger.h"
45 TypeId(
"ns3::Ipv4L3Protocol")
47 .SetGroupName(
"Internet")
49 .AddAttribute(
"DefaultTtl",
50 "The TTL value set by default on "
51 "all outgoing packets generated on this node.",
55 .AddAttribute(
"FragmentExpirationTimeout",
56 "When this timeout expires, the fragments "
57 "will be cleared from the buffer.",
61 .AddAttribute(
"EnableDuplicatePacketDetection",
62 "Enable multicast duplicate packet detection based on RFC 6621",
66 .AddAttribute(
"DuplicateExpire",
67 "Expiration delay for duplicate cache entries",
71 .AddAttribute(
"PurgeExpiredPeriod",
72 "Time between purges of expired duplicate packet entries, "
73 "0 means never purge",
78 "Send ipv4 packet to outgoing interface.",
80 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
82 "Receive ipv4 packet from incoming interface.",
84 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
85 .AddTraceSource(
"Drop",
88 "ns3::Ipv4L3Protocol::DropTracedCallback")
89 .AddAttribute(
"InterfaceList",
90 "The set of Ipv4 interfaces associated to this Ipv4 stack.",
95 .AddTraceSource(
"SendOutgoing",
96 "A newly-generated packet by this node is "
97 "about to be queued for transmission",
99 "ns3::Ipv4L3Protocol::SentTracedCallback")
100 .AddTraceSource(
"UnicastForward",
101 "A unicast IPv4 packet was received by this node "
102 "and is being forwarded to another node",
104 "ns3::Ipv4L3Protocol::SentTracedCallback")
105 .AddTraceSource(
"MulticastForward",
106 "A multicast IPv4 packet was received by this node "
107 "and is being forwarded to another node",
109 "ns3::Ipv4L3Protocol::SentTracedCallback")
110 .AddTraceSource(
"LocalDeliver",
111 "An IPv4 packet was received by/for this node, "
112 "and it is being forward up the stack",
114 "ns3::Ipv4L3Protocol::SentTracedCallback")
138 L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1);
141 NS_LOG_WARN(
"Overwriting default protocol " <<
int(protocol->GetProtocolNumber()));
151 L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex);
154 NS_LOG_WARN(
"Overwriting protocol " <<
int(protocol->GetProtocolNumber())
155 <<
" on interface " <<
int(interfaceIndex));
165 L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), -1);
169 NS_LOG_WARN(
"Trying to remove an non-existent default protocol "
170 <<
int(protocol->GetProtocolNumber()));
183 L4ListKey_t key = std::make_pair(protocol->GetProtocolNumber(), interfaceIndex);
187 NS_LOG_WARN(
"Trying to remove an non-existent protocol "
188 <<
int(protocol->GetProtocolNumber()) <<
" on interface "
189 <<
int(interfaceIndex));
206 if (interfaceIndex >= 0)
209 auto key = std::make_pair(protocolNumber, interfaceIndex);
217 auto key = std::make_pair(protocolNumber, -1);
318 it->second =
nullptr;
357 interface->SetDevice(device);
358 interface->SetNode(
m_node);
361 interface->AddAddress(ifaceAddr);
401 tc->RegisterProtocolHandler(
408 interface->SetDevice(device);
409 interface->SetTrafficControl(tc);
446 for (
uint32_t j = 0; j < (*i)->GetNAddresses(); j++)
448 if ((*i)->GetAddress(j).GetLocal() == address)
464 for (
uint32_t j = 0; j < (*i)->GetNAddresses(); j++)
466 if ((*i)->GetAddress(j).GetLocal().CombineMask(mask) == address.CombineMask(mask))
482 return (*iter).second;
497 NS_LOG_LOGIC(
"For me (destination " << address <<
" match)");
507 if (address.IsMulticast())
510 if (MulticastCheckGroup(iif, address))
518 if (address.IsBroadcast())
538 <<
" match) on another interface");
544 NS_LOG_LOGIC(
"For me (interface broadcast address on another interface)");
561 NS_LOG_FUNCTION(
this << device << p << protocol << from << to << packetType);
565 int32_t interface = GetInterfaceForDevice(device);
566 NS_ASSERT_MSG(interface != -1,
"Received a packet from an interface that is not known to IPv4");
572 if (ipv4Interface->IsUp())
574 m_rxTrace(packet,
this, interface);
578 NS_LOG_LOGIC(
"Dropping received packet -- interface is down");
580 packet->RemoveHeader(ipHeader);
581 m_dropTrace(ipHeader, packet, DROP_INTERFACE_DOWN,
this, interface);
586 if (Node::ChecksumEnabled())
590 packet->RemoveHeader(ipHeader);
595 packet->RemoveAtEnd(packet->GetSize() - ipHeader.
GetPayloadSize());
600 NS_LOG_LOGIC(
"Dropping received packet -- checksum not ok");
601 m_dropTrace(ipHeader, packet, DROP_BAD_CHECKSUM,
this, interface);
623 std::list<ArpCache::Entry*> entryList = arpCache->LookupInverse(from);
624 for (
auto iter = entryList.begin(); iter != entryList.end(); iter++)
626 if ((*iter)->IsAlive())
628 (*iter)->UpdateSeen();
634 for (
auto i = m_sockets.begin(); i != m_sockets.end(); ++i)
638 socket->ForwardUp(packet, ipHeader, ipv4Interface);
644 m_dropTrace(ipHeader, packet, DROP_DUPLICATE,
this, interface);
648 NS_ASSERT_MSG(m_routingProtocol,
"Need a routing protocol object to process packets");
649 if (!m_routingProtocol->RouteInput(packet, ipHeader, device, m_ucb, m_mcb, m_lcb, m_ecb))
651 NS_LOG_WARN(
"No route found for forwarding packet. Drop.");
652 m_dropTrace(ipHeader, packet, DROP_NO_ROUTE,
this, interface);
685 NS_LOG_LOGIC(
"Testing address " << ad <<
" with subnet-directed broadcast "
724 packetCopy->AddHeader(ipHeader);
738 bool mayFragment =
true;
745 bool ipTtlTagFound = packet->RemovePacketTag(ipTtlTag);
753 bool ipTosTagFound = packet->RemovePacketTag(ipTosTag);
761 BuildHeader(source, destination, protocol, packet->GetSize(), ttl, tos, mayFragment);
776 if (!route->GetGateway().IsInitialized())
782 NS_FATAL_ERROR(
"Ipv4L3Protocol::Send case 1a: packet passed with a route but the "
783 "Gateway address is uninitialized. This case not yet implemented.");
787 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 1b: passed in with route and valid gateway");
801 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 2: limited broadcast - no route");
804 ifaceIter++, ifaceIndex++)
808 bool sendIt = source.
IsAny();
810 for (
uint32_t index = 0; !sendIt && index < outInterface->GetNAddresses(); index++)
812 if (outInterface->GetAddress(index).GetLocal() == source)
822 route->SetDestination(destination);
824 route->SetSource(source);
825 route->SetOutputDevice(outInterface->GetDevice());
827 Send(pktCopyWithTags, source, destination, protocol, route);
847 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 3: subnet directed bcast to "
848 << ifAddr.
GetLocal() <<
" - no route");
851 route->SetDestination(destination);
853 route->SetSource(source);
854 route->SetOutputDevice(outInterface->GetDevice());
856 Send(pktCopyWithTags, source, destination, protocol, route);
863 NS_LOG_LOGIC(
"Ipv4L3Protocol::Send case 4: not broadcast and passed in with no route "
870 newRoute =
m_routingProtocol->RouteOutput(pktCopyWithTags, ipHeader, oif, errno_);
874 NS_LOG_ERROR(
"Ipv4L3Protocol::Send: m_routingProtocol == 0");
879 Send(pktCopyWithTags, source, destination, protocol, newRoute);
894 uint64_t src = source.
Get();
895 uint64_t dst = destination.
Get();
896 uint64_t srcDst = dst | (src << 32);
897 std::pair<uint64_t, uint8_t> key = std::make_pair(srcDst, protocol);
905 uint16_t payloadSize,
910 NS_LOG_FUNCTION(
this << source << destination << (uint16_t)protocol << payloadSize
911 << (uint16_t)ttl << (uint16_t)tos << mayFragment);
920 uint64_t src = source.
Get();
921 uint64_t dst = destination.
Get();
922 uint64_t srcDst = dst | (src << 32);
923 std::pair<uint64_t, uint8_t> key = std::make_pair(srcDst, protocol);
959 int32_t interface = GetInterfaceForDevice(outDev);
962 NS_LOG_LOGIC(
"Send via NetDevice ifIndex " << outDev->GetIfIndex() <<
" ipv4InterfaceIndex "
966 std::string targetLabel;
967 if (route->GetGateway().IsAny())
970 targetLabel =
"destination";
974 target = route->GetGateway();
975 targetLabel =
"gateway";
978 if (outInterface->IsUp())
980 NS_LOG_LOGIC(
"Send to " << targetLabel <<
" " << target);
981 if (packet->GetSize() + ipHeader.
GetSerializedSize() > outInterface->GetDevice()->GetMtu())
983 std::list<Ipv4PayloadHeaderPair> listFragments;
984 DoFragmentation(packet, ipHeader, outInterface->GetDevice()->GetMtu(), listFragments);
985 for (
auto it = listFragments.begin(); it != listFragments.end(); it++)
988 CallTxTrace(it->second, it->first,
this, interface);
989 outInterface->Send(it->first, it->second, target);
994 CallTxTrace(ipHeader, packet,
this, interface);
995 outInterface->Send(packet, ipHeader, target);
1009 std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap();
1011 for (
auto mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++)
1018 if (ipHeader.
GetTtl() <= 1)
1025 NS_LOG_LOGIC(
"Forward multicast via interface " << interface);
1027 rtentry->SetSource(ipHeader.
GetSource());
1047 if (ipHeader.
GetTtl() <= 1)
1053 icmp->SendTimeExceededTtl(ipHeader, packet,
false);
1062 packet->RemovePacketTag(priorityTag);
1068 packet->AddPacketTag(priorityTag);
1084 NS_LOG_LOGIC(
"Received a fragment, processing " << *p);
1085 bool isPacketComplete;
1087 if (!isPacketComplete)
1091 NS_LOG_LOGIC(
"Got last fragment, Packet is complete " << *p);
1119 bool subnetDirected =
false;
1127 subnetDirected =
true;
1130 if (!subnetDirected)
1132 GetIcmp()->SendDestUnreachPort(ipHeader, copy);
1143 bool retVal = interface->AddAddress(address);
1144 if (m_routingProtocol)
1146 m_routingProtocol->NotifyAddAddress(i, address);
1155 return interface->GetAddress(addressIndex);
1162 return iface->GetNAddresses();
1173 if (m_routingProtocol)
1175 m_routingProtocol->NotifyRemoveAddress(i, address);
1196 if (m_routingProtocol)
1198 m_routingProtocol->NotifyRemoveAddress(i, ifAddr);
1223 if (!
test.IsSecondary())
1225 return test.GetLocal();
1289 NS_LOG_WARN(
"Could not find source address for " << dst <<
" and scope " << scope
1290 <<
", returning 0");
1299 interface->SetMetric(metric);
1306 return interface->GetMetric();
1313 return interface->GetDevice()->GetMtu();
1320 return interface->IsUp();
1333 if (interface->GetDevice()->GetMtu() >= 68)
1337 if (m_routingProtocol)
1339 m_routingProtocol->NotifyInterfaceUp(i);
1347 <<
" is set to be down for IPv4. Reason: not respecting minimum IPv4 MTU (68 octets)");
1356 interface->SetDown();
1358 if (m_routingProtocol)
1360 m_routingProtocol->NotifyInterfaceDown(ifaceIndex);
1368 NS_LOG_LOGIC(
"Forwarding state: " << interface->IsForwarding());
1369 return interface->IsForwarding();
1377 interface->SetForwarding(val);
1393 (*i)->SetForwarding(forward);
1422 NS_LOG_LOGIC(
"Route input failure-- dropping packet to " << ipHeader <<
" with errno "
1433 std::list<Ipv4PayloadHeaderPair>& listFragments)
1445 "IPv4 fragmentation implementation only works without option headers.");
1447 uint16_t offset = 0;
1448 bool moreFragment =
true;
1451 uint32_t currentFragmentablePartSize = 0;
1458 NS_LOG_LOGIC(
"Fragmenting - Target Size: " << fragmentSize);
1464 if (p->GetSize() > offset + fragmentSize)
1466 moreFragment =
true;
1467 currentFragmentablePartSize = fragmentSize;
1472 moreFragment =
false;
1473 currentFragmentablePartSize = p->GetSize() - offset;
1474 if (!isLastFragment)
1484 NS_LOG_LOGIC(
"Fragment creation - " << offset <<
", " << currentFragmentablePartSize);
1485 Ptr<Packet> fragment = p->CreateFragment(offset, currentFragmentablePartSize);
1486 NS_LOG_LOGIC(
"Fragment created - " << offset <<
", " << fragment->GetSize());
1498 NS_LOG_LOGIC(
"New fragment Header " << fragmentHeader);
1500 std::ostringstream oss;
1501 oss << fragmentHeader;
1502 fragment->Print(oss);
1506 listFragments.emplace_back(fragment, fragmentHeader);
1508 offset += currentFragmentablePartSize;
1510 }
while (moreFragment);
1518 uint64_t addressCombination =
1526 key.first = addressCombination;
1527 key.second = idProto;
1535 m_fragments.insert(std::make_pair(key, fragments));
1538 fragments->SetTimeoutIter(iter);
1542 fragments = it->second;
1545 NS_LOG_LOGIC(
"Adding fragment - Size: " << packet->GetSize()
1550 if (fragments->IsEntire())
1552 packet = fragments->GetPacket();
1554 fragments =
nullptr;
1563 : m_moreFragment(false)
1570 uint16_t fragmentOffset,
1575 std::list<std::pair<Ptr<Packet>, uint16_t>>::iterator it;
1579 if (it->second > fragmentOffset)
1587 m_moreFragment = moreFragment;
1598 bool ret = !m_moreFragment && !
m_fragments.empty();
1602 uint16_t lastEndOffset = 0;
1607 NS_LOG_LOGIC(
"Checking overlaps " << lastEndOffset <<
" - " << it->second);
1609 if (lastEndOffset < it->
second)
1615 uint16_t fragmentEnd = it->first->GetSize() + it->second;
1616 lastEndOffset = std::max(lastEndOffset, fragmentEnd);
1631 uint16_t lastEndOffset = p->GetSize();
1636 if (lastEndOffset > it->second)
1642 uint32_t newStart = lastEndOffset - it->second;
1643 if (it->first->GetSize() > newStart)
1645 uint32_t newSize = it->first->GetSize() - newStart;
1646 Ptr<Packet> tempFragment = it->first->CreateFragment(newStart, newSize);
1647 p->AddAtEnd(tempFragment);
1653 p->AddAtEnd(it->first);
1655 lastEndOffset = p->GetSize();
1669 uint16_t lastEndOffset = 0;
1678 if (lastEndOffset > it->second)
1680 uint32_t newStart = lastEndOffset - it->second;
1681 uint32_t newSize = it->first->GetSize() - newStart;
1682 Ptr<Packet> tempFragment = it->first->CreateFragment(newStart, newSize);
1683 p->AddAtEnd(tempFragment);
1685 else if (lastEndOffset == it->second)
1688 p->AddAtEnd(it->first);
1690 lastEndOffset = p->GetSize();
1699 m_timeoutIter = iter;
1705 return m_timeoutIter;
1714 Ptr<Packet> packet = it->second->GetPartialPacket();
1717 if (packet->GetSize() > 8)
1720 icmp->SendTimeExceededTtl(ipHeader, packet,
true);
1725 it->second =
nullptr;
1742 uint64_t hash =
id << 32;
1754 pkt->AddHeader(header);
1756 std::ostringstream oss(std::ios_base::binary);
1757 pkt->CopyData(&oss, pkt->GetSize());
1758 std::string bytes = oss.str();
1760 NS_ASSERT_MSG(bytes.size() >= 20,
"Degenerate header serialization");
1764 bytes[6] = bytes[7] = 0;
1766 bytes[10] = bytes[11] = 0;
1773 hash |= (uint64_t)
Hash32(bytes);
1784 NS_LOG_DEBUG(
"Packet " << p->GetUid() <<
" key = (" << std::hex << std::get<0>(key) <<
", "
1785 << std::dec << +std::get<1>(key) <<
", " << std::get<2>(key) <<
", "
1786 << std::get<3>(key) <<
")");
1802 DupMap_t::size_type n = 0;
1804 auto iter =
m_dups.cbegin();
1805 while (iter !=
m_dups.cend())
1807 if (iter->second < expire)
1809 NS_LOG_LOGIC(
"Remove key = (" << std::hex << std::get<0>(iter->first) <<
", "
1810 << std::dec << +std::get<1>(iter->first) <<
", "
1811 << std::get<2>(iter->first) <<
", "
1812 << std::get<3>(iter->first) <<
")");
1813 iter =
m_dups.erase(iter);
1822 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.
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.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() 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.
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.
void SetNode(Ptr< Node > node)
Set node associated with interface.
Ptr< NetDevice > GetDevice() const
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.
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_NO_ROUTE
No route to host.
@ 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
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.
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
static constexpr uint16_t PROT_NUMBER
Protocol number.
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...
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
std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts..
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()
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.
Smart pointer class similar to boost::intrusive_ptr.
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.
AttributeValue implementation for Time.
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...
Ptr< const AttributeChecker > MakeBooleanChecker()
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 AttributeChecker > MakeObjectVectorChecker()
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
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 AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.
U * PeekPointer(const Ptr< U > &p)
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
-ns3 Test suite for the ns3 wrapper script