A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-l3-protocol.h
Go to the documentation of this file.
1//
2// Copyright (c) 2006 Georgia Tech Research Corporation
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: George F. Riley<riley@ece.gatech.edu>
18//
19
20#ifndef IPV4_L3_PROTOCOL_H
21#define IPV4_L3_PROTOCOL_H
22
23#include "ipv4-header.h"
25#include "ipv4.h"
26
27#include "ns3/deprecated.h"
28#include "ns3/ipv4-address.h"
29#include "ns3/net-device.h"
30#include "ns3/nstime.h"
31#include "ns3/ptr.h"
32#include "ns3/simulator.h"
33#include "ns3/traced-callback.h"
34
35#include <list>
36#include <map>
37#include <stdint.h>
38#include <vector>
39
41
42namespace ns3
43{
44
45class Packet;
46class NetDevice;
47class Ipv4Interface;
48class Ipv4Address;
49class Ipv4Header;
50class Ipv4RoutingTableEntry;
51class Ipv4Route;
52class Node;
53class Socket;
54class Ipv4RawSocketImpl;
55class IpL4Protocol;
56class Icmpv4L4Protocol;
57
58/**
59 * \ingroup ipv4
60 *
61 * \brief Implement the IPv4 layer.
62 *
63 * This is the actual implementation of IP. It contains APIs to send and
64 * receive packets at the IP layer, as well as APIs for IP routing.
65 *
66 * This class contains two distinct groups of trace sources. The
67 * trace sources 'Rx' and 'Tx' are called, respectively, immediately
68 * after receiving from the NetDevice and immediately before sending
69 * to a NetDevice for transmitting a packet. These are low level
70 * trace sources that include the Ipv4Header already serialized into
71 * the packet. In contrast, the Drop, SendOutgoing, UnicastForward,
72 * and LocalDeliver trace sources are slightly higher-level and pass
73 * around the Ipv4Header as an explicit parameter and not as part of
74 * the packet.
75 *
76 * IP fragmentation and reassembly is handled at this level.
77 * At the moment the fragmentation does not handle IP option headers,
78 * and in particular the ones that shall not be fragmented.
79 * Moreover, the actual implementation does not mimic exactly the Linux
80 * kernel. Hence it is not possible, for instance, to test a fragmentation
81 * attack.
82 */
83class Ipv4L3Protocol : public Ipv4
84{
85 public:
86 /**
87 * \brief Get the type ID.
88 * \return the object TypeId
89 */
90 static TypeId GetTypeId();
91 static const uint16_t PROT_NUMBER; //!< Protocol number (0x0800)
92
94 ~Ipv4L3Protocol() override;
95
96 // Delete copy constructor and assignment operator to avoid misuse
99
100 /**
101 * \enum DropReason
102 * \brief Reason why a packet has been dropped.
103 */
105 {
106 DROP_TTL_EXPIRED = 1, /**< Packet TTL has expired */
107 DROP_NO_ROUTE, /**< No route to host */
108 DROP_BAD_CHECKSUM, /**< Bad checksum */
109 DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */
110 DROP_ROUTE_ERROR, /**< Route error */
111 DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout exceeded */
112 DROP_DUPLICATE /**< Duplicate packet received */
113 };
114
115 /**
116 * \brief Set node associated with this stack.
117 * \param node node to set
118 */
119 void SetNode(Ptr<Node> node);
120
121 // functions defined in base class Ipv4
122
123 void SetRoutingProtocol(Ptr<Ipv4RoutingProtocol> routingProtocol) override;
125
126 Ptr<Socket> CreateRawSocket() override;
127 void DeleteRawSocket(Ptr<Socket> socket) override;
128
129 void Insert(Ptr<IpL4Protocol> protocol) override;
130 void Insert(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) override;
131
132 void Remove(Ptr<IpL4Protocol> protocol) override;
133 void Remove(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) override;
134
135 Ptr<IpL4Protocol> GetProtocol(int protocolNumber) const override;
136 Ptr<IpL4Protocol> GetProtocol(int protocolNumber, int32_t interfaceIndex) const override;
137
138 Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest) override;
139
140 /**
141 * \param ttl default ttl to use
142 *
143 * When we need to send an ipv4 packet, we use this default
144 * ttl value.
145 */
146 void SetDefaultTtl(uint8_t ttl);
147
148 /**
149 * Lower layer calls this method after calling L3Demux::Lookup
150 * The ARP subclass needs to know from which NetDevice this
151 * packet is coming to:
152 * - implement a per-NetDevice ARP cache
153 * - send back arp replies on the right device
154 * \param device network device
155 * \param p the packet
156 * \param protocol protocol value
157 * \param from address of the correspondent
158 * \param to address of the destination
159 * \param packetType type of the packet
160 */
161 void Receive(Ptr<NetDevice> device,
163 uint16_t protocol,
164 const Address& from,
165 const Address& to,
166 NetDevice::PacketType packetType);
167
168 /**
169 * \param packet packet to send
170 * \param source source address of packet
171 * \param destination address of packet
172 * \param protocol number of packet
173 * \param route route entry
174 *
175 * Higher-level layers call this method to send a packet
176 * down the stack to the MAC and PHY layers.
177 */
178 void Send(Ptr<Packet> packet,
179 Ipv4Address source,
180 Ipv4Address destination,
181 uint8_t protocol,
182 Ptr<Ipv4Route> route) override;
183 /**
184 * \param packet packet to send
185 * \param ipHeader IP Header
186 * \param route route entry
187 *
188 * Higher-level layers call this method to send a packet with IPv4 Header
189 * (Intend to be used with IpHeaderInclude attribute.)
190 */
191 void SendWithHeader(Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route) override;
192
193 uint32_t AddInterface(Ptr<NetDevice> device) override;
194 /**
195 * \brief Get an interface.
196 * \param i interface index
197 * \return IPv4 interface pointer
198 */
200 uint32_t GetNInterfaces() const override;
201
202 int32_t GetInterfaceForAddress(Ipv4Address addr) const override;
203 int32_t GetInterfaceForPrefix(Ipv4Address addr, Ipv4Mask mask) const override;
205 bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const override;
206
207 bool AddAddress(uint32_t i, Ipv4InterfaceAddress address) override;
208 Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const override;
209 uint32_t GetNAddresses(uint32_t interface) const override;
210 bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) override;
211 bool RemoveAddress(uint32_t interface, Ipv4Address address) override;
213 Ipv4Address dst,
215
216 void SetMetric(uint32_t i, uint16_t metric) override;
217 uint16_t GetMetric(uint32_t i) const override;
218 uint16_t GetMtu(uint32_t i) const override;
219 bool IsUp(uint32_t i) const override;
220 void SetUp(uint32_t i) override;
221 void SetDown(uint32_t i) override;
222 bool IsForwarding(uint32_t i) const override;
223 void SetForwarding(uint32_t i, bool val) override;
224
226
227 /**
228 * \brief Check if an IPv4 address is unicast according to the node.
229 *
230 * This function checks all the node's interfaces and the respective subnet masks.
231 * An address is considered unicast if it's not broadcast, subnet-broadcast or multicast.
232 *
233 * \param ad address
234 *
235 * \return true if the address is unicast
236 */
237 bool IsUnicast(Ipv4Address ad) const;
238
239 /**
240 * TracedCallback signature for packet send, forward, or local deliver events.
241 *
242 * \param [in] header the Ipv4Header
243 * \param [in] packet the packet
244 * \param [in] interface IP-level interface number
245 */
246 typedef void (*SentTracedCallback)(const Ipv4Header& header,
247 Ptr<const Packet> packet,
248 uint32_t interface);
249
250 /**
251 * TracedCallback signature for packet transmission or reception events.
252 *
253 * \param [in] packet the packet.
254 * \param [in] ipv4 the Ipv4 protocol
255 * \param [in] interface IP-level interface number
256 * \deprecated The non-const \c Ptr<Ipv4> argument is deprecated
257 * and will be changed to \c Ptr<const Ipv4> in a future release.
258 */
259 typedef void (*TxRxTracedCallback)(Ptr<const Packet> packet,
260 Ptr<Ipv4> ipv4,
261 uint32_t interface);
262
263 /**
264 * TracedCallback signature for packet drop events.
265 *
266 * \param [in] header the Ipv4Header.
267 * \param [in] packet the packet.
268 * \param [in] reason the reason the packet was dropped.
269 * \param [in] ipv4 the Ipv4 protocol
270 * \param [in] interface IP-level interface number
271 * \deprecated The non-const \c Ptr<Ipv4> argument is deprecated
272 * and will be changed to \c Ptr<const Ipv4> in a future release.
273 */
274 typedef void (*DropTracedCallback)(const Ipv4Header& header,
275 Ptr<const Packet> packet,
276 DropReason reason,
277 Ptr<Ipv4> ipv4,
278 uint32_t interface);
279
280 protected:
281 void DoDispose() override;
282 /**
283 * This function will notify other components connected to the node that a new stack member is
284 * now connected This will be used to notify Layer 3 protocol of layer 4 protocol stack to
285 * connect them together.
286 */
287 void NotifyNewAggregate() override;
288
289 private:
290 /**
291 * \brief Ipv4L3ProtocolTestCase test case.
292 * \relates Ipv4L3ProtocolTestCase
293 */
294 friend class ::Ipv4L3ProtocolTestCase;
295
296 // class Ipv4 attributes
297 void SetIpForward(bool forward) override;
298 bool GetIpForward() const override;
299
300 NS_DEPRECATED_3_41("Use SetStrongEndSystemModel instead")
301 void SetWeakEsModel(bool model) override;
303 bool GetWeakEsModel() const override;
304
305 void SetStrongEndSystemModel(bool model) override;
306 bool GetStrongEndSystemModel() const override;
307
308 /**
309 * \brief Decrease the identification value for a dropped or recursed packet
310 * \param source source IPv4 address
311 * \param destination destination IPv4 address
312 * \param protocol L4 protocol
313 */
314 void DecreaseIdentification(Ipv4Address source, Ipv4Address destination, uint8_t protocol);
315
316 /**
317 * \brief Construct an IPv4 header.
318 * \param source source IPv4 address
319 * \param destination destination IPv4 address
320 * \param protocol L4 protocol
321 * \param payloadSize payload size
322 * \param ttl Time to Live
323 * \param tos Type of Service
324 * \param mayFragment true if the packet can be fragmented
325 * \return newly created IPv4 header
326 */
328 Ipv4Address destination,
329 uint8_t protocol,
330 uint16_t payloadSize,
331 uint8_t ttl,
332 uint8_t tos,
333 bool mayFragment);
334
335 /**
336 * \brief Send packet with route.
337 * \param route route
338 * \param packet packet to send
339 * \param ipHeader IPv4 header to add to the packet
340 */
341 void SendRealOut(Ptr<Ipv4Route> route, Ptr<Packet> packet, const Ipv4Header& ipHeader);
342
343 /**
344 * \brief Forward a packet.
345 * \param rtentry route
346 * \param p packet to forward
347 * \param header IPv4 header to add to the packet
348 */
349 void IpForward(Ptr<Ipv4Route> rtentry, Ptr<const Packet> p, const Ipv4Header& header);
350
351 /**
352 * \brief Forward a multicast packet.
353 * \param mrtentry route
354 * \param p packet to forward
355 * \param header IPv4 header to add to the packet
356 */
358 Ptr<const Packet> p,
359 const Ipv4Header& header);
360
361 /**
362 * \brief Deliver a packet.
363 * \param p packet delivered
364 * \param ip IPv4 header
365 * \param iif input interface packet was received
366 */
367 void LocalDeliver(Ptr<const Packet> p, const Ipv4Header& ip, uint32_t iif);
368
369 /**
370 * \brief Fallback when no route is found.
371 * \param p packet
372 * \param ipHeader IPv4 header
373 * \param sockErrno error number
374 */
375 void RouteInputError(Ptr<const Packet> p,
376 const Ipv4Header& ipHeader,
377 Socket::SocketErrno sockErrno);
378
379 /**
380 * \brief Add an IPv4 interface to the stack.
381 * \param interface interface to add
382 * \return index of newly added interface
383 */
385
386 /**
387 * \brief Setup loopback interface.
388 */
389 void SetupLoopback();
390
391 /**
392 * \brief Get ICMPv4 protocol.
393 * \return Icmpv4L4Protocol pointer
394 */
396
397 /**
398 * \brief Check if an IPv4 address is unicast.
399 * \param ad address
400 * \param interfaceMask the network mask
401 * \return true if the address is unicast
402 */
403 bool IsUnicast(Ipv4Address ad, Ipv4Mask interfaceMask) const;
404
405 /**
406 * \brief Pair of a packet and an Ipv4 header.
407 */
409
410 /**
411 * \brief Fragment a packet
412 * \param packet the packet
413 * \param ipv4Header the IPv4 header
414 * \param outIfaceMtu the MTU of the interface
415 * \param listFragments the list of fragments
416 */
417 void DoFragmentation(Ptr<Packet> packet,
418 const Ipv4Header& ipv4Header,
419 uint32_t outIfaceMtu,
420 std::list<Ipv4PayloadHeaderPair>& listFragments);
421
422 /**
423 * \brief Process a packet fragment
424 * \param packet the packet
425 * \param ipHeader the IP header
426 * \param iif Input Interface
427 * \return true is the fragment completed the packet
428 */
429 bool ProcessFragment(Ptr<Packet>& packet, Ipv4Header& ipHeader, uint32_t iif);
430
431 /**
432 * \brief Make a copy of the packet, add the header and invoke the TX trace callback
433 * \param ipHeader the IP header that will be added to the packet
434 * \param packet the packet
435 * \param ipv4 the Ipv4 protocol
436 * \param interface the IP-level interface index
437 *
438 * Note: If the TracedCallback API ever is extended, we could consider
439 * to check for connected functions before adding the header
440 */
441 void CallTxTrace(const Ipv4Header& ipHeader,
442 Ptr<Packet> packet,
443 Ptr<Ipv4> ipv4,
444 uint32_t interface);
445
446 /**
447 * \brief Container of the IPv4 Interfaces.
448 */
450 /**
451 * \brief Container of NetDevices registered to IPv4 and their interface indexes.
452 */
454 /**
455 * \brief Container of the IPv4 Raw Sockets.
456 */
458
459 /**
460 * \brief Container of the IPv4 L4 keys: protocol number, interface index
461 */
462 typedef std::pair<int, int32_t> L4ListKey_t;
463
464 /**
465 * \brief Container of the IPv4 L4 instances.
466 */
468
469 bool m_ipForward; //!< Forwarding packets (i.e. router mode) state.
470 bool m_strongEndSystemModel; //!< Strong End System Model state
471 L4List_t m_protocols; //!< List of transport protocol.
472 Ipv4InterfaceList m_interfaces; //!< List of IPv4 interfaces.
474 m_reverseInterfacesContainer; //!< Container of NetDevice / Interface index associations.
475 uint8_t m_defaultTtl; //!< Default TTL
476 std::map<std::pair<uint64_t, uint8_t>, uint16_t>
477 m_identification; //!< Identification (for each {src, dst, proto} tuple)
478 Ptr<Node> m_node; //!< Node attached to stack.
479
480 /// Trace of sent packets
482 /// Trace of unicast forwarded packets
484 /// Trace of multicast forwarded packets
486 /// Trace of locally delivered packets
488
489 // The following two traces pass a packet with an IP header
490 /// Trace of transmitted packets
491 /// \deprecated The non-const \c Ptr<Ipv4> argument is deprecated
492 /// and will be changed to \c Ptr<const Ipv4> in a future release.
494 /// Trace of received packets
495 /// \deprecated The non-const \c Ptr<Ipv4> argument is deprecated
496 /// and will be changed to \c Ptr<const Ipv4> in a future release.
498 // <ip-header, payload, reason, ifindex> (ifindex not valid if reason is DROP_NO_ROUTE)
499 /// Trace of dropped packets
500 /// \deprecated The non-const \c Ptr<Ipv4> argument is deprecated
501 /// and will be changed to \c Ptr<const Ipv4> in a future release.
504
505 Ptr<Ipv4RoutingProtocol> m_routingProtocol; //!< Routing protocol associated with the stack
506
507 SocketList m_sockets; //!< List of IPv4 raw sockets.
508
509 /// Key identifying a fragmented packet
510 typedef std::pair<uint64_t, uint32_t> FragmentKey_t;
511
512 /// Container for fragment timeouts.
513 typedef std::list<std::tuple<Time, FragmentKey_t, Ipv4Header, uint32_t>>
515 /// Container Iterator for fragment timeouts..
516 typedef std::list<std::tuple<Time, FragmentKey_t, Ipv4Header, uint32_t>>::iterator
518
519 /**
520 * \brief Process the timeout for packet fragments
521 * \param key representing the packet fragments
522 * \param ipHeader the IP header of the original packet
523 * \param iif Input Interface
524 */
526
527 /**
528 * \brief Set a new timeout "event" for a fragmented packet
529 * \param key the fragment identification
530 * \param ipHeader the IPv4 header of the fragmented packet
531 * \param iif input interface of the packet
532 * \return an iterator to the inserted "event"
533 */
535
536 /**
537 * \brief Handles a fragmented packet timeout
538 */
539 void HandleTimeout();
540
541 FragmentsTimeoutsList_t m_timeoutEventList; //!< Timeout "events" container
542
543 EventId m_timeoutEvent; //!< Event for the next scheduled timeout
544
545 /**
546 * \brief A Set of Fragment belonging to the same packet (src, dst, identification and proto)
547 */
549 {
550 public:
551 /**
552 * \brief Constructor.
553 */
554 Fragments();
555
556 /**
557 * \brief Add a fragment.
558 * \param fragment the fragment
559 * \param fragmentOffset the offset of the fragment
560 * \param moreFragment the bit "More Fragment"
561 */
562 void AddFragment(Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
563
564 /**
565 * \brief If all fragments have been added.
566 * \returns true if the packet is entire
567 */
568 bool IsEntire() const;
569
570 /**
571 * \brief Get the entire packet.
572 * \return the entire packet
573 */
574 Ptr<Packet> GetPacket() const;
575
576 /**
577 * \brief Get the complete part of the packet.
578 * \return the part we have comeplete
579 */
580 Ptr<Packet> GetPartialPacket() const;
581
582 /**
583 * \brief Set the Timeout iterator.
584 * \param iter The iterator.
585 */
586 void SetTimeoutIter(FragmentsTimeoutsListI_t iter);
587
588 /**
589 * \brief Get the Timeout iterator.
590 * \returns The iterator.
591 */
592 FragmentsTimeoutsListI_t GetTimeoutIter();
593
594 private:
595 /**
596 * \brief True if other fragments will be sent.
597 */
599
600 /**
601 * \brief The current fragments.
602 */
603 std::list<std::pair<Ptr<Packet>, uint16_t>> m_fragments;
604
605 /**
606 * \brief Timeout iterator to "event" handler
607 */
609 };
610
611 /// Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment
612 typedef std::map<FragmentKey_t, Ptr<Fragments>> MapFragments_t;
613
614 MapFragments_t m_fragments; //!< Fragmented packets.
615 Time m_fragmentExpirationTimeout; //!< Expiration timeout
616
617 /// IETF RFC 6621, Section 6.2 de-duplication w/o IPSec
618 /// RFC 6621 recommended duplicate packet tuple: {IPV hash, IP protocol, IP source address, IP
619 /// destination address}
620 typedef std::tuple<uint64_t, uint8_t, Ipv4Address, Ipv4Address> DupTuple_t;
621 /// Maps packet duplicate tuple to expiration time
622 typedef std::map<DupTuple_t, Time> DupMap_t;
623
624 /**
625 * Registers duplicate entry, return false if new
626 * \param [in] p Possibly duplicate packet.
627 * \param [in] header Packet \pname{p} header.
628 * \return True if this packet is a duplicate
629 */
630 bool UpdateDuplicate(Ptr<const Packet> p, const Ipv4Header& header);
631 /**
632 * Remove expired duplicates packet entry
633 */
634 void RemoveDuplicates();
635
636 bool m_enableDpd; //!< Enable multicast duplicate packet detection
637 DupMap_t m_dups; //!< map of packet duplicate tuples to expiry event
638 Time m_expire; //!< duplicate entry expiration delay
639 Time m_purge; //!< time between purging expired duplicate entries
640 EventId m_cleanDpd; //!< event to cleanup expired duplicate entries
641
646};
647
648} // Namespace ns3
649
650#endif /* IPV4_L3_PROTOCOL_H */
a polymophic address class
Definition: address.h:101
An identifier for simulation events.
Definition: event-id.h:55
This is the implementation of the ICMP protocol as described in RFC 792.
L4 Protocol abstract base class.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:80
a class to store IPv4 address information on an interface
The IPv4 representation of a network interface.
A Set of Fragment belonging to the same packet (src, dst, identification and proto)
std::list< std::pair< Ptr< Packet >, uint16_t > > m_fragments
The current fragments.
bool m_moreFragment
True if other fragments will be sent.
FragmentsTimeoutsListI_t m_timeoutIter
Timeout iterator to "event" handler.
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.
DropReason
Reason why a packet has been dropped.
@ 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.
std::map< FragmentKey_t, Ptr< Fragments > > MapFragments_t
Container of fragments, stored as pairs(src+dst addr, src+dst port) / fragment.
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.
std::list< std::tuple< Time, FragmentKey_t, Ipv4Header, uint32_t > > FragmentsTimeoutsList_t
Container for fragment timeouts.
Time m_expire
duplicate entry expiration delay
bool m_strongEndSystemModel
Strong End System Model state.
Ipv4RoutingProtocol::ErrorCallback m_ecb
Error callback.
std::pair< Ptr< Packet >, Ipv4Header > Ipv4PayloadHeaderPair
Pair of a packet and an Ipv4 header.
bool m_ipForward
Forwarding packets (i.e.
void(* DropTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet drop events.
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.
std::list< Ptr< Ipv4RawSocketImpl > > SocketList
Container of the IPv4 Raw Sockets.
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.
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
std::map< Ptr< const NetDevice >, uint32_t > Ipv4InterfaceReverseContainer
Container of NetDevices registered to IPv4 and their interface indexes.
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
Ipv4L3Protocol & operator=(const Ipv4L3Protocol &)=delete
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.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
TracedCallback signature for packet transmission or reception events.
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.
std::map< L4ListKey_t, Ptr< IpL4Protocol > > L4List_t
Container of the IPv4 L4 instances.
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.
std::vector< Ptr< Ipv4Interface > > Ipv4InterfaceList
Container of the IPv4 Interfaces.
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.
Ipv4L3Protocol(const Ipv4L3Protocol &)=delete
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(* SentTracedCallback)(const Ipv4Header &header, Ptr< const Packet > packet, uint32_t interface)
TracedCallback signature for packet send, forward, or local deliver events.
void SetDefaultTtl(uint8_t ttl)
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const override
std::map< DupTuple_t, Time > DupMap_t
Maps packet duplicate tuple to expiration time.
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
Definition: ipv4-address.h:257
Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
Definition: ipv4-route.h:115
IPv4 route cache entry (similar to Linux struct rtable)
Definition: ipv4-route.h:42
Abstract base class for IPv4 routing protocols.
Network layer to device interface.
Definition: net-device.h:98
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:300
A network Node.
Definition: node.h:57
network packets
Definition: packet.h:239
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:68
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
#define NS_DEPRECATED_3_41(msg)
Tag for things deprecated in version ns-3.41.
Definition: deprecated.h:109
Every class exported by the ns3 library is enclosed in the ns3 namespace.
STL namespace.
#define list