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/trace-source-accessor.h"
31 #include "ns3/object-vector.h"
32 #include "ns3/ipv4-header.h"
33 #include "ns3/boolean.h"
34 #include "ns3/ipv4-routing-table-entry.h"
56 .SetGroupName (
"Internet")
58 .AddAttribute (
"DefaultTos",
59 "The TOS value set by default on "
60 "all outgoing packets generated on this node.",
63 MakeUintegerChecker<uint8_t> ())
64 .AddAttribute (
"DefaultTtl",
65 "The TTL value set by default on "
66 "all outgoing packets generated on this node.",
69 MakeUintegerChecker<uint8_t> ())
70 .AddAttribute (
"FragmentExpirationTimeout",
71 "When this timeout expires, the fragments "
72 "will be cleared from the buffer.",
76 .AddTraceSource (
"Tx",
77 "Send ipv4 packet to outgoing interface.",
79 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
80 .AddTraceSource (
"Rx",
81 "Receive ipv4 packet from incoming interface.",
83 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
84 .AddTraceSource (
"Drop",
87 "ns3::Ipv4L3Protocol::DropTracedCallback")
88 .AddAttribute (
"InterfaceList",
89 "The set of Ipv4 interfaces associated to this Ipv4 stack.",
92 MakeObjectVectorChecker<Ipv4Interface> ())
94 .AddTraceSource (
"SendOutgoing",
95 "A newly-generated packet by this node is "
96 "about to be queued for transmission",
98 "ns3::Ipv4L3Protocol::SentTracedCallback")
99 .AddTraceSource (
"UnicastForward",
100 "A unicast IPv4 packet was received by this node "
101 "and is being forwarded to another node",
103 "ns3::Ipv4L3Protocol::SentTracedCallback")
104 .AddTraceSource (
"LocalDeliver",
105 "An IPv4 packet was received by/for this node, "
106 "and it is being forward up the stack",
108 "ns3::Ipv4L3Protocol::SentTracedCallback")
175 NS_LOG_WARN (
"Trying to remove an non-existent protocol " <<
int(protocol->
GetProtocolNumber ()) <<
" on interface " <<
int(interfaceIndex));
197 L4List_t::const_iterator i;
198 if (interfaceIndex >= 0)
201 key = std::make_pair (protocolNumber, interfaceIndex);
209 key = std::make_pair (protocolNumber, -1);
314 if (it->second.IsRunning ())
316 it->second.Cancel ();
343 device = CreateObject<LoopbackNetDevice> ();
346 interface->SetDevice (device);
347 interface->SetNode (
m_node);
349 interface->AddAddress (ifaceAddr);
353 Ipv4L3Protocol::PROT_NUMBER, device);
375 Ipv4L3Protocol::PROT_NUMBER, device);
380 interface->SetNode (
m_node);
381 interface->SetDevice (device);
418 int32_t
interface = 0;
419 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
423 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
425 if ((*i)->GetAddress (j).GetLocal () ==
address)
441 int32_t
interface = 0;
442 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
446 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
448 if ((*i)->GetAddress (j).GetLocal ().CombineMask (mask) == address.
CombineMask (mask))
463 int32_t
interface = 0;
464 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
468 if ((*i)->GetDevice () == device)
487 NS_LOG_LOGIC (
"For me (destination " << address <<
" match)");
500 if (MulticastCheckGroup (iif, address ))
519 if (j == uint32_t (iif))
continue;
525 NS_LOG_LOGIC (
"For me (destination " << address <<
" match) on another interface");
531 NS_LOG_LOGIC (
"For me (interface broadcast address on another interface)");
544 NS_LOG_FUNCTION (
this << device << p << protocol << from << to << packetType);
546 NS_LOG_LOGIC (
"Packet from " << from <<
" received on node " <<
549 uint32_t
interface = 0;
553 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
558 if (ipv4Interface->
GetDevice () == device)
560 if (ipv4Interface->
IsUp ())
567 NS_LOG_LOGIC (
"Dropping received packet -- interface is down");
569 packet->RemoveHeader (ipHeader);
581 packet->RemoveHeader (ipHeader);
586 packet->RemoveAtEnd (packet->GetSize () - ipHeader.
GetPayloadSize ());
591 NS_LOG_LOGIC (
"Dropping received packet -- checksum not ok");
600 socket->
ForwardUp (packet, ipHeader, ipv4Interface);
611 NS_LOG_WARN (
"No route found for forwarding packet. Drop.");
643 for (uint32_t ifaceIndex = 0; ifaceIndex <
GetNInterfaces (); ifaceIndex++)
687 NS_LOG_FUNCTION (
this << packet << source << destination << uint32_t (protocol) << route);
690 bool mayFragment =
true;
717 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 1: limited broadcast");
718 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
719 uint32_t ifaceIndex = 0;
720 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
721 ifaceIter !=
m_interfaces.end (); ifaceIter++, ifaceIndex++)
731 outInterface->
Send (packetCopy, destination);
737 uint32_t ifaceIndex = 0;
738 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
739 ifaceIter !=
m_interfaces.end (); ifaceIter++, ifaceIndex++)
750 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
753 packetCopy->AddHeader (ipHeader);
755 outInterface->
Send (packetCopy, destination);
765 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 3: passed in with route");
766 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
779 NS_FATAL_ERROR (
"Ipv4L3Protocol::Send case 4: This case not yet implemented");
782 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 5: passed in with no route " << destination);
785 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
793 NS_LOG_ERROR (
"Ipv4L3Protocol::Send: m_routingProtocol == 0");
816 uint16_t payloadSize,
821 NS_LOG_FUNCTION (
this << source << destination << (uint16_t)protocol << payloadSize << (uint16_t)ttl << (uint16_t)tos << mayFragment);
830 uint64_t src = source.
Get ();
831 uint64_t dst = destination.
Get ();
832 uint64_t srcDst = dst | (src << 32);
833 std::pair<uint64_t, uint8_t> key = std::make_pair (srcDst, protocol);
835 if (mayFragment ==
true)
872 int32_t
interface = GetInterfaceForDevice (outDev);
875 NS_LOG_LOGIC (
"Send via NetDevice ifIndex " << outDev->GetIfIndex () <<
" ipv4InterfaceIndex " << interface);
879 if (outInterface->
IsUp ())
884 std::list<Ptr<Packet> > listFragments;
886 for (
std::list<
Ptr<Packet> >::iterator it = listFragments.begin (); it != listFragments.end (); it++ )
908 if (outInterface->
IsUp ())
913 std::list<Ptr<Packet> > listFragments;
915 for (
std::list<
Ptr<Packet> >::iterator it = listFragments.begin (); it != listFragments.end (); it++ )
945 std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap ();
946 std::map<uint32_t, uint32_t>::iterator mapIter;
948 for (mapIter = ttlMap.begin (); mapIter != ttlMap.end (); mapIter++)
950 uint32_t interfaceId = mapIter->first;
962 NS_LOG_LOGIC (
"Forward multicast via interface " << interfaceId);
983 ipHeader.SetTtl (ipHeader.GetTtl () - 1);
984 if (ipHeader.GetTtl () == 0)
988 ipHeader.GetDestination ().IsBroadcast () ==
false &&
989 ipHeader.GetDestination ().IsMulticast () ==
false)
992 icmp->SendTimeExceededTtl (ipHeader, packet);
1011 NS_LOG_LOGIC (
"Received a fragment, processing " << *p );
1012 bool isPacketComplete;
1014 if ( isPacketComplete ==
false)
1018 NS_LOG_LOGIC (
"Got last fragment, Packet is complete " << *p );
1047 bool subnetDirected =
false;
1054 subnetDirected =
true;
1057 if (subnetDirected ==
false)
1059 GetIcmp ()->SendDestUnreachPort (ipHeader, copy);
1070 bool retVal = interface->
AddAddress (address);
1151 if (iaddr.
GetScope () > scope)
continue;
1182 NS_LOG_WARN (
"Could not find source address for " << dst <<
" and scope "
1183 << scope <<
", returning 0");
1208 return interface->
GetDevice ()->GetMtu ();
1216 return interface->
IsUp ();
1229 if (interface->GetDevice ()->GetMtu () >= 68)
1231 interface->
SetUp ();
1240 NS_LOG_LOGIC (
"Interface " <<
int(i) <<
" is set to be down for IPv4. Reason: not respecting minimum IPv4 MTU (68 octects)");
1262 NS_LOG_LOGIC (
"Forwarding state: " << interface->IsForwarding ());
1263 return interface->IsForwarding ();
1288 (*i)->SetForwarding (forward);
1317 NS_LOG_LOGIC (
"Route input failure-- dropping packet to " << ipHeader <<
" with errno " << sockErrno);
1337 "IPv4 fragmentation implementation only works without option headers." );
1339 uint16_t offset = 0;
1340 bool moreFragment =
true;
1341 uint16_t originalOffset = 0;
1342 bool alreadyFragmented =
false;
1343 uint32_t currentFragmentablePartSize = 0;
1347 alreadyFragmented =
true;
1354 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.
GetSerializedSize () ) & ~uint32_t (0x7);
1356 NS_LOG_LOGIC (
"Fragmenting - Target Size: " << fragmentSize );
1362 if (p->
GetSize () > offset + fragmentSize )
1364 moreFragment =
true;
1365 currentFragmentablePartSize = fragmentSize;
1370 moreFragment =
false;
1371 currentFragmentablePartSize = p->
GetSize () - offset;
1372 if (alreadyFragmented)
1382 NS_LOG_LOGIC (
"Fragment creation - " << offset <<
", " << currentFragmentablePartSize );
1396 NS_LOG_LOGIC (
"New fragment Header " << fragmentHeader);
1399 std::ostringstream oss;
1400 fragment->
Print (oss);
1404 listFragments.push_back (fragment);
1406 offset += currentFragmentablePartSize;
1409 while (moreFragment);
1421 std::pair<uint64_t, uint32_t> key;
1425 key.first = addressCombination;
1426 key.second = idProto;
1430 MapFragments_t::iterator it =
m_fragments.find (key);
1433 fragments = Create<Fragments> ();
1434 m_fragments.insert (std::make_pair (key, fragments));
1437 key, ipHeader, iif);
1441 fragments = it->second;
1466 : m_moreFragment (0)
1481 std::list<std::pair<Ptr<Packet>, uint16_t> >::iterator it;
1485 if (it->second > fragmentOffset)
1493 m_moreFragment = moreFragment;
1504 bool ret = !m_moreFragment &&
m_fragments.size () > 0;
1508 uint16_t lastEndOffset = 0;
1513 NS_LOG_LOGIC (
"Checking overlaps " << lastEndOffset <<
" - " << it->second );
1515 if (lastEndOffset < it->
second)
1521 uint16_t fragmentEnd = it->first->GetSize () + it->second;
1522 lastEndOffset = std::max ( lastEndOffset, fragmentEnd );
1534 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1537 uint16_t lastEndOffset = p->
GetSize ();
1542 if ( lastEndOffset > it->second )
1548 uint32_t newStart = lastEndOffset - it->second;
1549 if ( it->first->GetSize () > newStart )
1551 uint32_t newSize = it->first->GetSize () - newStart;
1552 Ptr<Packet> tempFragment = it->first->CreateFragment (newStart, newSize);
1561 lastEndOffset = p->
GetSize ();
1572 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1575 uint16_t lastEndOffset = 0;
1584 if ( lastEndOffset > it->second )
1586 uint32_t newStart = lastEndOffset - it->second;
1587 uint32_t newSize = it->first->GetSize () - newStart;
1588 Ptr<Packet> tempFragment = it->first->CreateFragment (newStart, newSize);
1591 else if ( lastEndOffset == it->second )
1596 lastEndOffset = p->
GetSize ();
1607 MapFragments_t::iterator it =
m_fragments.find (key);
1608 Ptr<Packet> packet = it->second->GetPartialPacket ();
1614 icmp->SendTimeExceededTtl (ipHeader, packet);
void SetDown(void)
Disable this interface.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
bool m_weakEsModel
Weak ES model state.
void SetForwarding(bool val)
void SetDefaultTtl(uint8_t ttl)
virtual void SetIpForward(bool forward)
Set or unset the IP forwarding state.
void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Receive a packet.
Ptr< Packet > GetPacket() const
Get the entire packet.
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual void NotifyNewAggregate()
This function will notify other components connected to the node that a new stack member is now conne...
Time m_fragmentExpirationTimeout
Expiration timeout.
Ipv4Mask GetMask(void) const
Get the network mask.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ipv4Address GetLocal(void) const
Get the local address.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint8_t GetTos(void) const
Get the tag's TOS.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets.
a class to represent an Ipv4 address mask
void Send(Ptr< Packet > p, Ipv4Address dest)
static bool ChecksumEnabled(void)
bool IsLocalMulticast(void) const
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
PacketType
Packet types are used as they are in Linux.
U * PeekPointer(const Ptr< U > &p)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual bool GetWeakEsModel(void) const
Get the Weak Es Model status.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
bool IsMulticast(void) const
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
Fragment timeout exceeded.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const
virtual void DoDispose(void)
Destructor implementation.
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...
bool AddAddress(Ipv4InterfaceAddress address)
uint32_t AddInterface(Ptr< NetDevice > device)
TracedCallback< const Ipv4Header &, Ptr< const Packet >, DropReason, Ptr< Ipv4 >, uint32_t > m_dropTrace
Trace of dropped packets.
virtual int GetProtocolNumber(void) const =0
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
void Print(std::ostream &os) const
Print the packet contents.
Ptr< Ipv4RoutingProtocol > m_routingProtocol
Routing protocol associated with the stack.
uint8_t m_defaultTos
Default TOS.
L4List_t m_protocols
List of transport protocol.
a polymophic address class
Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetSource(Ipv4Address src)
bool IsSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
Ptr< NetDevice > GetOutputDevice(void) const
Ipv4InterfaceList m_interfaces
List of IPv4 interfaces.
bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const
Determine whether address and interface corresponding to received packet can be accepted for local de...
Ptr< Packet > GetPartialPacket() const
Get the complete part of the packet.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_rxTrace
Trace of received packets.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void SetupLoopback(void)
Setup loopback interface.
AttributeValue implementation for Time.
Ptr< Icmpv4L4Protocol > GetIcmp(void) const
Get ICMPv4 protocol.
uint32_t Get(void) const
Get the host-order 32-bit IP address.
void SetGateway(Ipv4Address gw)
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_txTrace
Trace of transmitted packets.
Hold an unsigned integer type.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_localDeliverTrace
Trace of locally delivered packets.
bool IsEntire() const
If all fragments have been added.
void SetMetric(uint32_t i, uint16_t metric)
virtual void DoDispose(void)
Destructor implementation.
bool IsBroadcast(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Ptr< Socket > CreateRawSocket(void)
Creates a raw socket.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
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.
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
static TypeId GetTypeId(void)
Get the type ID.
bool IsUp(uint32_t i) const
MapFragments_t m_fragments
Fragmented packets.
void SendWithHeader(Ptr< Packet > packet, Ipv4Header ipHeader, Ptr< Ipv4Route > route)
void IpForward(Ptr< Ipv4Route > rtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a packet.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ipv4Address GetGateway(void) const
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex)
Remove the address at addressIndex on named interface.
bool IsSecondary(void) const
Check if the address is a secondary address.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
Access to the Ipv4 forwarding table, interfaces, and configuration.
bool m_ipForward
Forwarding packets (i.e.
uint32_t GetNDevices(void) const
void SetForwarding(uint32_t i, bool val)
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Implement the Ipv4 layer.
static const uint16_t PROT_NUMBER
ARP protocol number (0x0806)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int32_t GetInterfaceForAddress(Ipv4Address addr) const
Return the interface number of the interface that has been assigned the specified IP address...
bool IsEqual(const Ipv4Address &other) const
Comparison operation between two Ipv4Addresses.
std::pair< int, int32_t > L4ListKey_t
Container of the IPv4 L4 keys: protocol number, interface index.
void DoFragmentation(Ptr< Packet > packet, uint32_t outIfaceMtu, std::list< Ptr< Packet > > &listFragments)
Fragment a packet.
Ptr< Node > m_node
Node attached to stack.
void RouteInputError(Ptr< const Packet > p, const Ipv4Header &ipHeader, Socket::SocketErrno sockErrno)
Fallback when no route is found.
Ipv4Header BuildHeader(Ipv4Address source, Ipv4Address destination, uint8_t protocol, uint16_t payloadSize, uint8_t ttl, uint8_t tos, bool mayFragment)
Construct an IPv4 header.
void SendRealOut(Ptr< Ipv4Route > route, Ptr< Packet > packet, Ipv4Header const &ipHeader)
Send packet with route.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
static Ipv4Address GetLoopback(void)
static Ipv4Mask GetLoopback(void)
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
Ptr< NetDevice > GetNetDevice(uint32_t i)
uint16_t GetMetric(void) const
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
bool ProcessFragment(Ptr< Packet > &packet, Ipv4Header &ipHeader, uint32_t iif)
Process a packet fragment.
uint32_t AddIpv4Interface(Ptr< Ipv4Interface > interface)
Add an IPv4 interface to the stack.
void Remove(Ptr< IpL4Protocol > protocol)
Ipv4 addresses are stored in host order in this class.
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
virtual void SetWeakEsModel(bool model)
Set or unset the Weak Es Model.
void SetNode(Ptr< Node > node)
Set node associated with this stack.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t GetId(void) const
a class to store IPv4 address information on an interface
SocketList m_sockets
List of IPv4 raw sockets.
void DeleteRawSocket(Ptr< Socket > socket)
Deletes a particular raw socket.
bool AddAddress(uint32_t i, Ipv4InterfaceAddress address)
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Ptr< NetDevice > GetDevice(void) const
Ptr< Ipv4Interface > GetInterface(uint32_t i) const
Get an interface.
InterfaceAddressScope_e
Address scope.
static uint16_t GetStaticProtocolNumber(void)
Get the protocol number.
void Insert(Ptr< IpL4Protocol > protocol)
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
bool IsUnicast(Ipv4Address ad) const
Check if an IPv4 address is unicast according to the node.
void LocalDeliver(Ptr< const Packet > p, Ipv4Header const &ip, uint32_t iif)
Deliver a packet.
void IpMulticastForward(Ptr< Ipv4MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv4Header &header)
Forward a multicast packet.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetNAddresses(uint32_t interface) const
MapFragmentsTimers_t m_fragmentsTimers
Expiration events.
uint16_t GetMtu(uint32_t i) const
void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Lower layer calls this method after calling L3Demux::Lookup The ARP subclass needs to know from which...
bool ForwardUp(Ptr< const Packet > p, Ipv4Header ipHeader, Ptr< Ipv4Interface > incomingInterface)
Forward up to receive method.
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope(void) const
Get address scope.
uint8_t m_defaultTtl
Default TTL.
uint32_t GetNInterfaces(void) const
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const
Interface is down so can not send packet.
void SetMetric(uint16_t metric)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
uint8_t GetTtl(void) const
Get the tag's TTL.
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets.
Container for a set of ns3::Object pointers.
uint16_t GetMetric(uint32_t i) const
Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const
Get the routing protocol to be used by this Ipv4 stack.
indicates whether the socket has IP_TOS set.
uint32_t GetNAddresses(void) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
std::map< std::pair< uint64_t, uint8_t >, uint16_t > m_identification
Identification (for each {src, dst, proto} tuple)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual ~Ipv4L3Protocol()
void HandleFragmentsTimeout(std::pair< uint64_t, uint32_t > key, Ipv4Header &ipHeader, uint32_t iif)
Process the timeout for packet fragments.
virtual bool GetIpForward(void) const
Get the IP forwarding state.
void AddHeader(const Header &header)
Add header to this packet.
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
void SetDestination(Ipv4Address dest)
bool IsUp(void) const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
void SetUp(void)
Enable this interface.
bool IsForwarding(uint32_t i) const
Ipv4Address SelectSourceAddress(Ptr< const NetDevice > device, Ipv4Address dst, Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
Return the first primary source address with scope less than or equal to the requested scope...
void SetRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol)
Register a new routing protocol to be used by this Ipv4 stack.