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" 35 #include "ns3/traffic-control-layer.h" 58 .SetGroupName (
"Internet")
60 .AddAttribute (
"DefaultTtl",
61 "The TTL value set by default on " 62 "all outgoing packets generated on this node.",
65 MakeUintegerChecker<uint8_t> ())
66 .AddAttribute (
"FragmentExpirationTimeout",
67 "When this timeout expires, the fragments " 68 "will be cleared from the buffer.",
72 .AddTraceSource (
"Tx",
73 "Send ipv4 packet to outgoing interface.",
75 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
76 .AddTraceSource (
"Rx",
77 "Receive ipv4 packet from incoming interface.",
79 "ns3::Ipv4L3Protocol::TxRxTracedCallback")
80 .AddTraceSource (
"Drop",
83 "ns3::Ipv4L3Protocol::DropTracedCallback")
84 .AddAttribute (
"InterfaceList",
85 "The set of Ipv4 interfaces associated to this Ipv4 stack.",
88 MakeObjectVectorChecker<Ipv4Interface> ())
90 .AddTraceSource (
"SendOutgoing",
91 "A newly-generated packet by this node is " 92 "about to be queued for transmission",
94 "ns3::Ipv4L3Protocol::SentTracedCallback")
95 .AddTraceSource (
"UnicastForward",
96 "A unicast IPv4 packet was received by this node " 97 "and is being forwarded to another node",
99 "ns3::Ipv4L3Protocol::SentTracedCallback")
100 .AddTraceSource (
"LocalDeliver",
101 "An IPv4 packet was received by/for this node, " 102 "and it is being forward up the stack",
104 "ns3::Ipv4L3Protocol::SentTracedCallback")
171 NS_LOG_WARN (
"Trying to remove an non-existent protocol " <<
int(protocol->
GetProtocolNumber ()) <<
" on interface " <<
int(interfaceIndex));
193 L4List_t::const_iterator i;
194 if (interfaceIndex >= 0)
197 key = std::make_pair (protocolNumber, interfaceIndex);
205 key = std::make_pair (protocolNumber, -1);
312 if (it->second.IsRunning ())
314 it->second.Cancel ();
341 device = CreateObject<LoopbackNetDevice> ();
344 interface->SetDevice (device);
345 interface->SetNode (
m_node);
347 interface->AddAddress (ifaceAddr);
388 interface->SetDevice (device);
389 interface->SetTrafficControl (tc);
427 int32_t
interface = 0;
428 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
432 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
434 if ((*i)->GetAddress (j).GetLocal () ==
address)
450 int32_t
interface = 0;
451 for (Ipv4InterfaceList::const_iterator i =
m_interfaces.begin ();
455 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++)
457 if ((*i)->GetAddress (j).GetLocal ().CombineMask (mask) ==
address.CombineMask (mask))
476 return (*iter).second;
505 if (MulticastCheckGroup (iif,
address ))
524 if (j == uint32_t (iif))
continue;
536 NS_LOG_LOGIC (
"For me (interface broadcast address on another interface)");
549 NS_LOG_FUNCTION (
this << device << p << protocol << from << to << packetType);
551 NS_LOG_LOGIC (
"Packet from " << from <<
" received on node " <<
555 int32_t
interface = GetInterfaceForDevice(device);
556 NS_ASSERT_MSG (interface != -1,
"Received a packet from an interface that is not known to IPv4");
562 if (ipv4Interface->
IsUp ())
568 NS_LOG_LOGIC (
"Dropping received packet -- interface is down");
590 NS_LOG_LOGIC (
"Dropping received packet -- checksum not ok");
613 std::list<ArpCache::Entry *> entryList = arpCache->
LookupInverse (from);
614 std::list<ArpCache::Entry *>::iterator iter;
615 for (iter = entryList.begin (); iter != entryList.end (); iter ++)
617 if ((*iter)->IsAlive ())
619 (*iter)->UpdateSeen ();
629 socket->
ForwardUp (packet, ipHeader, ipv4Interface);
640 NS_LOG_WARN (
"No route found for forwarding packet. Drop.");
672 for (uint32_t ifaceIndex = 0; ifaceIndex <
GetNInterfaces (); ifaceIndex++)
725 NS_LOG_FUNCTION (
this << packet << source << destination << uint32_t (protocol) << route);
728 bool mayFragment =
true;
755 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 1: limited broadcast");
756 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
757 uint32_t ifaceIndex = 0;
758 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
759 ifaceIter !=
m_interfaces.end (); ifaceIter++, ifaceIndex++)
767 for (uint32_t index = 0; index < outInterface->
GetNAddresses (); index++)
782 outInterface->
Send (packetCopy, ipHeader, destination);
789 uint32_t ifaceIndex = 0;
790 for (Ipv4InterfaceList::iterator ifaceIter =
m_interfaces.begin ();
791 ifaceIter !=
m_interfaces.end (); ifaceIter++, ifaceIndex++)
802 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
806 outInterface->
Send (packetCopy, ipHeader, destination);
816 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 3: passed in with route");
817 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
830 NS_FATAL_ERROR (
"Ipv4L3Protocol::Send case 4: This case not yet implemented");
833 NS_LOG_LOGIC (
"Ipv4L3Protocol::Send case 5: passed in with no route " << destination);
836 ipHeader =
BuildHeader (source, destination, protocol, packet->
GetSize (), ttl, tos, mayFragment);
844 NS_LOG_ERROR (
"Ipv4L3Protocol::Send: m_routingProtocol == 0");
867 uint16_t payloadSize,
872 NS_LOG_FUNCTION (
this << source << destination << (uint16_t)protocol << payloadSize << (uint16_t)ttl << (uint16_t)tos << mayFragment);
881 uint64_t src = source.
Get ();
882 uint64_t dst = destination.
Get ();
883 uint64_t srcDst = dst | (src << 32);
884 std::pair<uint64_t, uint8_t> key = std::make_pair (srcDst, protocol);
886 if (mayFragment ==
true)
922 int32_t
interface = GetInterfaceForDevice (outDev);
925 NS_LOG_LOGIC (
"Send via NetDevice ifIndex " << outDev->GetIfIndex () <<
" ipv4InterfaceIndex " << interface);
929 if (outInterface->
IsUp ())
934 std::list<Ipv4PayloadHeaderPair> listFragments;
936 for ( std::list<Ipv4PayloadHeaderPair>::iterator it = listFragments.begin (); it != listFragments.end (); it++ )
956 if (outInterface->
IsUp ())
961 std::list<Ipv4PayloadHeaderPair> listFragments;
963 for ( std::list<Ipv4PayloadHeaderPair>::iterator it = listFragments.begin (); it != listFragments.end (); it++ )
991 std::map<uint32_t, uint32_t> ttlMap = mrtentry->GetOutputTtlMap ();
992 std::map<uint32_t, uint32_t>::iterator mapIter;
994 for (mapIter = ttlMap.begin (); mapIter != ttlMap.end (); mapIter++)
996 uint32_t interfaceId = mapIter->first;
1008 NS_LOG_LOGIC (
"Forward multicast via interface " << interfaceId);
1029 ipHeader.SetTtl (ipHeader.GetTtl () - 1);
1030 if (ipHeader.GetTtl () == 0)
1034 ipHeader.GetDestination ().IsBroadcast () ==
false &&
1035 ipHeader.GetDestination ().IsMulticast () ==
false)
1038 icmp->SendTimeExceededTtl (ipHeader, packet,
false);
1068 NS_LOG_LOGIC (
"Received a fragment, processing " << *p );
1069 bool isPacketComplete;
1071 if ( isPacketComplete ==
false)
1075 NS_LOG_LOGIC (
"Got last fragment, Packet is complete " << *p );
1104 bool subnetDirected =
false;
1111 subnetDirected =
true;
1114 if (subnetDirected ==
false)
1116 GetIcmp ()->SendDestUnreachPort (ipHeader, copy);
1207 if (test.GetLocal ().CombineMask (test.GetMask ()) == dest.
CombineMask (test.GetMask ()))
1209 if (test.IsSecondary () ==
false)
1211 return test.GetLocal ();
1235 if (iaddr.
GetScope () > scope)
continue;
1266 NS_LOG_WARN (
"Could not find source address for " << dst <<
" and scope " 1267 << scope <<
", returning 0");
1292 return interface->
GetDevice ()->GetMtu ();
1300 return interface->
IsUp ();
1313 if (interface->GetDevice ()->GetMtu () >= 68)
1315 interface->
SetUp ();
1324 NS_LOG_LOGIC (
"Interface " <<
int(i) <<
" is set to be down for IPv4. Reason: not respecting minimum IPv4 MTU (68 octects)");
1346 NS_LOG_LOGIC (
"Forwarding state: " << interface->IsForwarding ());
1347 return interface->IsForwarding ();
1372 (*i)->SetForwarding (forward);
1401 NS_LOG_LOGIC (
"Route input failure-- dropping packet to " << ipHeader <<
" with errno " << sockErrno);
1420 "IPv4 fragmentation implementation only works without option headers." );
1422 uint16_t offset = 0;
1423 bool moreFragment =
true;
1426 uint32_t currentFragmentablePartSize = 0;
1431 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.
GetSerializedSize () ) & ~uint32_t (0x7);
1433 NS_LOG_LOGIC (
"Fragmenting - Target Size: " << fragmentSize );
1439 if (p->
GetSize () > offset + fragmentSize )
1441 moreFragment =
true;
1442 currentFragmentablePartSize = fragmentSize;
1447 moreFragment =
false;
1448 currentFragmentablePartSize = p->
GetSize () - offset;
1449 if (!isLastFragment)
1459 NS_LOG_LOGIC (
"Fragment creation - " << offset <<
", " << currentFragmentablePartSize );
1473 NS_LOG_LOGIC (
"New fragment Header " << fragmentHeader);
1475 std::ostringstream oss;
1476 oss << fragmentHeader;
1477 fragment->
Print (oss);
1483 offset += currentFragmentablePartSize;
1486 while (moreFragment);
1498 std::pair<uint64_t, uint32_t> key;
1502 key.first = addressCombination;
1503 key.second = idProto;
1507 MapFragments_t::iterator it =
m_fragments.find (key);
1510 fragments = Create<Fragments> ();
1511 m_fragments.insert (std::make_pair (key, fragments));
1514 key, ipHeader, iif);
1518 fragments = it->second;
1543 : m_moreFragment (0)
1558 std::list<std::pair<Ptr<Packet>, uint16_t> >::iterator it;
1562 if (it->second > fragmentOffset)
1570 m_moreFragment = moreFragment;
1581 bool ret = !m_moreFragment &&
m_fragments.size () > 0;
1585 uint16_t lastEndOffset = 0;
1590 NS_LOG_LOGIC (
"Checking overlaps " << lastEndOffset <<
" - " << it->second );
1592 if (lastEndOffset < it->
second)
1598 uint16_t fragmentEnd = it->first->GetSize () + it->second;
1599 lastEndOffset =
std::max ( lastEndOffset, fragmentEnd );
1611 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1614 uint16_t lastEndOffset = p->
GetSize ();
1619 if ( lastEndOffset > it->second )
1625 uint32_t newStart = lastEndOffset - it->second;
1626 if ( it->first->GetSize () > newStart )
1628 uint32_t newSize = it->first->GetSize () - newStart;
1629 Ptr<Packet> tempFragment = it->first->CreateFragment (newStart, newSize);
1638 lastEndOffset = p->
GetSize ();
1649 std::list<std::pair<Ptr<Packet>, uint16_t> >::const_iterator it =
m_fragments.begin ();
1652 uint16_t lastEndOffset = 0;
1661 if ( lastEndOffset > it->second )
1663 uint32_t newStart = lastEndOffset - it->second;
1664 uint32_t newSize = it->first->GetSize () - newStart;
1665 Ptr<Packet> tempFragment = it->first->CreateFragment (newStart, newSize);
1668 else if ( lastEndOffset == it->second )
1673 lastEndOffset = p->
GetSize ();
1684 MapFragments_t::iterator it =
m_fragments.find (key);
1685 Ptr<Packet> packet = it->second->GetPartialPacket ();
1691 icmp->SendTimeExceededTtl (ipHeader, packet,
true);
virtual Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest)
Choose the source address to use with destination address.
void SetDown(void)
Disable this interface.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
uint8_t GetTos(void) const
Get the tag's TOS.
bool m_weakEsModel
Weak ES model state.
void SetForwarding(bool val)
InterfaceAddressScope_e
Address scope.
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.
void Send(Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest)
static Ipv4Address GetAny(void)
void Print(std::ostream &os) const
Print the packet contents.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t GetNAddresses(uint32_t interface) const
bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const
Determine whether address and interface corresponding to received packet can be accepted for local de...
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.
uint32_t GetId(void) const
bool IsBroadcast(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Introspection did not find any typical Config paths.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets.
a class to represent an Ipv4 address mask
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static bool ChecksumEnabled(void)
ArpCache::Entry * Lookup(Ipv4Address destination)
Do lookup in the ARP cache against an IP address.
The IPv4 representation of a network interface.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
U * PeekPointer(const Ptr< U > &p)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
Fragment timeout exceeded.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
virtual void DoDispose(void)
Destructor implementation.
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.
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.
bool IsEntire() const
If all fragments have been added.
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
int32_t GetInterfaceForAddress(Ipv4Address addr) const
Return the interface number of the interface that has been assigned the specified IP address...
virtual int GetProtocolNumber(void) const =0
Returns the protocol number of this protocol.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual bool GetIpForward(void) const
Get the IP forwarding state.
Ipv4InterfaceAddress GetAddress(uint32_t index) const
Ptr< Ipv4RoutingProtocol > m_routingProtocol
Routing protocol associated with the stack.
uint32_t GetNInterfaces(void) const
L4List_t m_protocols
List of transport protocol.
void SetNode(Ptr< Node > node)
Set node associated with interface.
a polymophic address class
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< Packet > GetPartialPacket() const
Get the complete part of the packet.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetSource(Ipv4Address src)
Ipv4InterfaceList m_interfaces
List of IPv4 interfaces.
TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_rxTrace
Trace of received packets.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
bool IsMulticast(void) const
Ptr< Icmpv4L4Protocol > GetIcmp(void) const
Get ICMPv4 protocol.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
bool IsSubnetDirectedBroadcast(Ipv4Mask const &mask) const
Generate subnet-directed broadcast address corresponding to mask.
void SetupLoopback(void)
Setup loopback interface.
Ipv4Address CombineMask(Ipv4Mask const &mask) const
Combine this address with a network mask.
AttributeValue implementation for Time.
bool IsUnicast(Ipv4Address ad) const
Check if an IPv4 address is unicast according to the node.
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.
Ptr< Ipv4Interface > GetInterface(uint32_t i) const
Get an interface.
void SetMetric(uint32_t i, uint16_t metric)
virtual void DoDispose(void)
Destructor implementation.
indicates whether the socket has a priority set.
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.
bool IsLocalMulticast(void) const
virtual bool GetWeakEsModel(void) const
Get the Weak Es Model status.
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.
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
MapFragments_t m_fragments
Fragmented packets.
Ipv4Mask GetMask(void) const
Get the network mask.
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.
Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const
Get the routing protocol to be used by this Ipv4 stack.
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex)
Remove the address at addressIndex on named interface.
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...
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
Access to the IPv4 forwarding table, interfaces, and configuration.
bool m_ipForward
Forwarding packets (i.e.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetForwarding(uint32_t i, bool val)
void DoFragmentation(Ptr< Packet > packet, const Ipv4Header &ipv4Header, uint32_t outIfaceMtu, std::list< Ipv4PayloadHeaderPair > &listFragments)
Fragment a packet.
Implement the IPv4 layer.
Ptr< NetDevice > GetOutputDevice(void) const
static const uint16_t PROT_NUMBER
ARP protocol number (0x0806)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::pair< Ptr< Packet >, Ipv4Header > Ipv4PayloadHeaderPair
Pair of a packet and an Ipv4 header.
Ptr< NetDevice > GetDevice(void) const
Ptr< ArpCache > GetArpCache() const
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void RemoveAtEnd(uint32_t size)
Remove size bytes from the end of the current packet.
std::pair< int, int32_t > L4ListKey_t
Container of the IPv4 L4 keys: protocol number, interface index.
bool IsForwarding(uint32_t i) const
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.
A record that that holds information about an ArpCache entry.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope(void) const
Get address scope.
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)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
static Ipv4Mask GetLoopback(void)
bool IsUp(void) const
These are IP interface states and may be distinct from NetDevice states, such as found in real implem...
Ipv4Address GetGateway(void) const
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
Ptr< NetDevice > GetNetDevice(uint32_t i)
void UpdateSeen(void)
Update the entry when seeing a packet.
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.
uint16_t GetMetric(uint32_t i) const
uint16_t GetMetric(void) const
virtual void Remove(Ptr< IpL4Protocol > protocol)
Ipv4 addresses are stored in host order in this class.
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.
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const
a class to store IPv4 address information on an interface
Ptr< Packet > GetPacket() const
Get the entire packet.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
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.
static uint16_t GetStaticProtocolNumber(void)
Get the protocol number.
virtual void Insert(Ptr< IpL4Protocol > protocol)
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
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.
MapFragmentsTimers_t m_fragmentsTimers
Expiration events.
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...
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.
bool IsSecondary(void) const
Check if the address is a secondary address.
Ipv4Address GetLocal(void) const
Get the local address.
uint8_t m_defaultTtl
Default TTL.
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
Interface is down so can not send packet.
void SetMetric(uint16_t metric)
std::list< ArpCache::Entry * > LookupInverse(Address destination)
Do lookup in the ARP cache against a MAC address.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
uint32_t Get(void) const
Get the host-order 32-bit IP address.
uint32_t GetNAddresses(void) const
uint16_t GetMtu(uint32_t i) const
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
bool IsEqual(const Ipv4Address &other) const
Comparison operation between two Ipv4Addresses.
PacketType
Packet types are used as they are in Linux.
TracedCallback< const Ipv4Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets.
Container for a set of ns3::Object pointers.
This is the implementation of the ICMP protocol as described in RFC 792.
void SetPriority(uint8_t priority)
Set the tag's priority.
Ipv4InterfaceReverseContainer m_reverseInterfacesContainer
Container of NetDevice / Interface index associations.
indicates whether the socket has IP_TOS set.
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)
bool IsUp(uint32_t i) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual ~Ipv4L3Protocol()
virtual Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const
void HandleFragmentsTimeout(std::pair< uint64_t, uint32_t > key, Ipv4Header &ipHeader, uint32_t iif)
Process the timeout for packet fragments.
void AddHeader(const Header &header)
Add header to this packet.
uint8_t GetTtl(void) const
Get the tag's TTL.
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
void SetDestination(Ipv4Address dest)
uint32_t GetNDevices(void) const
void SetUp(void)
Enable this interface.
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.