A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-l3-protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
7 */
8
9#ifndef IPV6_L3_PROTOCOL_H
10#define IPV6_L3_PROTOCOL_H
11
12#include "ipv6-header.h"
13#include "ipv6-pmtu-cache.h"
15#include "ipv6.h"
16
17#include "ns3/ipv6-address.h"
18#include "ns3/net-device.h"
19#include "ns3/traced-callback.h"
20
21#include <list>
22
24
25namespace ns3
26{
27
28class Node;
29class Ipv6Interface;
30class IpL4Protocol;
31class Ipv6Route;
36
37/**
38 * @ingroup ipv6
39 *
40 * @brief IPv6 layer implementation.
41 *
42 * This class contains two distinct groups of trace sources. The
43 * trace sources 'Rx' and 'Tx' are called, respectively, immediately
44 * after receiving from the NetDevice and immediately before sending
45 * to a NetDevice for transmitting a packet. These are low level
46 * trace sources that include the Ipv6Header already serialized into
47 * the packet. In contrast, the Drop, SendOutgoing, UnicastForward,
48 * and LocalDeliver trace sources are slightly higher-level and pass
49 * around the Ipv6Header as an explicit parameter and not as part of
50 * the packet.
51 */
52class Ipv6L3Protocol : public Ipv6
53{
54 public:
55 /**
56 * @brief Get the type ID of this class.
57 * @return type ID
58 */
59 static TypeId GetTypeId();
60
61 /**
62 * @brief The protocol number for IPv6 (0x86DD).
63 */
64 static constexpr uint16_t PROT_NUMBER = 0x86DD;
65
66 /**
67 * @enum DropReason
68 * @brief Reason why a packet has been dropped.
69 */
71 {
72 DROP_TTL_EXPIRED = 1, /**< Packet TTL has expired */
73 DROP_NO_ROUTE, /**< No route to host */
74 DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */
75 DROP_ROUTE_ERROR, /**< Route error */
76 DROP_UNKNOWN_PROTOCOL, /**< Unknown L4 protocol */
77 DROP_UNKNOWN_OPTION, /**< Unknown option */
78 DROP_MALFORMED_HEADER, /**< Malformed header */
79 DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout */
80 };
81
82 /**
83 * @brief Constructor.
84 */
86
87 /**
88 * @brief Destructor.
89 */
90 ~Ipv6L3Protocol() override;
91
92 // Delete copy constructor and assignment operator to avoid misuse
95
96 /**
97 * @brief Set node associated with this stack.
98 * @param node node to set
99 */
100 void SetNode(Ptr<Node> node);
101
102 void Insert(Ptr<IpL4Protocol> protocol) override;
103 void Insert(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) override;
104
105 void Remove(Ptr<IpL4Protocol> protocol) override;
106 void Remove(Ptr<IpL4Protocol> protocol, uint32_t interfaceIndex) override;
107
108 Ptr<IpL4Protocol> GetProtocol(int protocolNumber) const override;
109 Ptr<IpL4Protocol> GetProtocol(int protocolNumber, int32_t interfaceIndex) const override;
110
111 /**
112 * @brief Create raw IPv6 socket.
113 * @return newly raw socket
114 */
116
117 /**
118 * @brief Remove raw IPv6 socket.
119 * @param socket socket to remove
120 */
121 void DeleteRawSocket(Ptr<Socket> socket);
122
123 /**
124 * @brief Set the default TTL.
125 * @param ttl TTL to set
126 */
127 void SetDefaultTtl(uint8_t ttl);
128
129 /**
130 * @brief Set the default TCLASS.
131 * @param tclass TCLASS to set
132 */
133 void SetDefaultTclass(uint8_t tclass);
134
135 /**
136 * @brief Receive method when a packet arrive in the stack.
137 * This method removes IPv6 header and forward up to L4 protocol.
138 *
139 * @param device network device
140 * @param p the packet
141 * @param protocol next header value
142 * @param from address of the correspondent
143 * @param to address of the destination
144 * @param packetType type of the packet
145 */
146 void Receive(Ptr<NetDevice> device,
148 uint16_t protocol,
149 const Address& from,
150 const Address& to,
151 NetDevice::PacketType packetType);
152
153 void Send(Ptr<Packet> packet,
154 Ipv6Address source,
155 Ipv6Address destination,
156 uint8_t protocol,
157 Ptr<Ipv6Route> route) override;
158
159 /**
160 * @brief Set routing protocol for this stack.
161 * @param routingProtocol IPv6 routing protocol to set
162 */
163 void SetRoutingProtocol(Ptr<Ipv6RoutingProtocol> routingProtocol) override;
164
165 /**
166 * @brief Get current routing protocol used.
167 * @return routing protocol
168 */
170
171 /**
172 * @brief Add IPv6 interface for a device.
173 * @param device net device
174 * @return interface index
175 */
176 uint32_t AddInterface(Ptr<NetDevice> device) override;
177
178 /**
179 * @brief Get an interface.
180 * @param i interface index
181 * @return IPv6 interface pointer
182 */
184
185 /**
186 * @brief Get current number of interface on this stack.
187 * @return number of interface registered
188 */
189 uint32_t GetNInterfaces() const override;
190
191 /**
192 * @brief Get interface index which has specified IPv6 address
193 * @param addr IPv6 address
194 * @return interface index or -1 if not found
195 */
196 int32_t GetInterfaceForAddress(Ipv6Address addr) const override;
197
198 /**
199 * @brief Get interface index which match specified address/prefix.
200 * @param addr IPv6 address
201 * @param mask IPv6 prefix (mask)
202 * @return interface index or -1 if not found
203 */
204 int32_t GetInterfaceForPrefix(Ipv6Address addr, Ipv6Prefix mask) const override;
205
206 /**
207 * @brief Get interface index which is on a specified net device.
208 * @param device net device
209 * @returns the interface index
210 */
212
213 /**
214 * @brief Add an address on interface.
215 * @param i interface index
216 * @param address address to add
217 * @param addOnLinkRoute add on-link route to the network (default true)
218 * @returns true if the operation succeeded
219 */
220 bool AddAddress(uint32_t i, Ipv6InterfaceAddress address, bool addOnLinkRoute = true) override;
221
222 /**
223 * @brief Get an address.
224 * @param interfaceIndex interface index
225 * @param addressIndex address index on the interface
226 * @return Ipv6InterfaceAddress or assert if not found
227 */
228 Ipv6InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const override;
229
230 /**
231 * @brief Get number of address for an interface.
232 * @param interface interface index
233 * @return number of address
234 */
235 uint32_t GetNAddresses(uint32_t interface) const override;
236
237 /**
238 * @brief Remove an address from an interface.
239 * @param interfaceIndex interface index
240 * @param addressIndex address index on the interface
241 * @returns true if the operation succeeded
242 */
243 bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) override;
244
245 /**
246 * @brief Remove a specified Ipv6 address from an interface.
247 * @param interfaceIndex interface index
248 * @param address Ipv6Address to be removed from the interface
249 * @returns true if the operation succeeded
250 */
251 bool RemoveAddress(uint32_t interfaceIndex, Ipv6Address address) override;
252
253 /**
254 * @brief Set metric for an interface.
255 * @param i index
256 * @param metric
257 */
258 void SetMetric(uint32_t i, uint16_t metric) override;
259
260 /**
261 * @brief Get metric for an interface.
262 * @param i index
263 * @return metric
264 */
265 uint16_t GetMetric(uint32_t i) const override;
266
267 /**
268 * @brief Get MTU for an interface.
269 * @param i index
270 * @return MTU
271 */
272 uint16_t GetMtu(uint32_t i) const override;
273
274 /**
275 * @brief Set the Path MTU for the specified IPv6 destination address.
276 * @param dst Ipv6 destination address
277 * @param pmtu the Path MTU
278 */
279 void SetPmtu(Ipv6Address dst, uint32_t pmtu) override;
280
281 /**
282 * @brief Is specified interface up ?
283 * @param i interface index
284 * @returns true if the interface is up
285 */
286 bool IsUp(uint32_t i) const override;
287
288 /**
289 * @brief Set an interface up.
290 * @param i interface index
291 */
292 void SetUp(uint32_t i) override;
293
294 /**
295 * @brief set an interface down.
296 * @param i interface index
297 */
298 void SetDown(uint32_t i) override;
299
300 /**
301 * @brief Is interface allows forwarding ?
302 * @param i interface index
303 * @returns true if the interface is forwarding
304 */
305 bool IsForwarding(uint32_t i) const override;
306
307 /**
308 * @brief Enable or disable forwarding on interface
309 * @param i interface index
310 * @param val true = enable forwarding, false = disable
311 */
312 void SetForwarding(uint32_t i, bool val) override;
313
314 Ipv6Address SourceAddressSelection(uint32_t interface, Ipv6Address dest) override;
315
316 /**
317 * @brief Get device by index.
318 * @param i device index on this stack
319 * @return NetDevice pointer
320 */
322
323 /**
324 * @brief Get ICMPv6 protocol.
325 * @return Icmpv6L4Protocol pointer
326 */
328
329 /**
330 * @brief Add an autoconfigured address with RA information.
331 * @param interface interface index
332 * @param network network prefix
333 * @param mask network mask
334 * @param flags flags of the prefix information option (home agent, ...)
335 * @param validTime valid time of the prefix
336 * @param preferredTime preferred time of the prefix
337 * @param defaultRouter default router address
338 */
339 void AddAutoconfiguredAddress(uint32_t interface,
340 Ipv6Address network,
341 Ipv6Prefix mask,
342 uint8_t flags,
343 uint32_t validTime,
344 uint32_t preferredTime,
345 Ipv6Address defaultRouter = Ipv6Address::GetZero());
346
347 /**
348 * @brief Remove an autoconfigured address.
349 *
350 * Typically it is used when an autoconfigured address expires.
351 * @param interface interface index
352 * @param network network prefix
353 * @param mask network mask
354 * @param defaultRouter gateway
355 */
357 Ipv6Address network,
358 Ipv6Prefix mask,
359 Ipv6Address defaultRouter);
360
361 void RegisterExtensions() override;
362 void RegisterOptions() override;
363
364 /**
365 * @brief Report a packet drop
366 *
367 * This function is used by Fragment Timeout handling to signal a fragment drop.
368 *
369 * @param ipHeader the IPv6 header of dropped packet
370 * @param p the packet (if available)
371 * @param dropReason the drop reason
372 *
373 */
374 virtual void ReportDrop(Ipv6Header ipHeader, Ptr<Packet> p, DropReason dropReason);
375
376 /**
377 * TracedCallback signature for packet sent, forwarded or
378 * local-delivered events.
379 *
380 * @param [in] header the Ipv6Header.
381 * @param [in] packet the packet.
382 * @param [in] interface the IP-level interface index
383 */
384 typedef void (*SentTracedCallback)(const Ipv6Header& header,
385 Ptr<const Packet> packet,
386 uint32_t interface);
387
388 /**
389 * TracedCallback signature for packet transmission or reception events.
390 *
391 * @param [in] packet the packet.
392 * @param [in] ipv6 the Ipv6 protocol
393 * @param [in] interface the IP-level interface index
394 * @deprecated The non-const \c Ptr<Ipv6> argument is deprecated
395 * and will be changed to \c Ptr<const Ipv6> in a future release.
396 */
397 // NS_DEPRECATED() - tag for future removal
398 typedef void (*TxRxTracedCallback)(Ptr<const Packet> packet,
399 Ptr<Ipv6> ipv6,
400 uint32_t interface);
401
402 /**
403 * TracedCallback signature for packet drop events.
404 *
405 * @param [in] header the Ipv6Header.
406 * @param [in] packet the packet.
407 * @param [in] reason the reason the packet was dropped.
408 * @param [in] ipv6 the Ipv6 protocol
409 * @param [in] interface the IP-level interface index
410 * @deprecated The non-const \c Ptr<Ipv6> argument is deprecated
411 * and will be changed to \c Ptr<const Ipv6> in a future release.
412 */
413 // NS_DEPRECATED() - tag for future removal
414 typedef void (*DropTracedCallback)(const Ipv6Header& header,
415 Ptr<const Packet> packet,
416 DropReason reason,
417 Ptr<Ipv6> ipv6,
418 uint32_t interface);
419
420 /**
421 * Adds a multicast address to the list of addresses to pass to local deliver.
422 * @param address the address.
423 */
424 void AddMulticastAddress(Ipv6Address address);
425
426 /**
427 * Adds a multicast address to the list of addresses to pass to local deliver.
428 * @param address the address.
429 * @param interface the incoming interface.
430 */
431 void AddMulticastAddress(Ipv6Address address, uint32_t interface);
432
433 /**
434 * Removes a multicast address from the list of addresses to pass to local deliver.
435 * @param address the address.
436 */
438
439 /**
440 * Removes a multicast address from the list of addresses to pass to local deliver.
441 * @param address the address.
442 * @param interface the incoming interface.
443 */
444 void RemoveMulticastAddress(Ipv6Address address, uint32_t interface);
445
446 /**
447 * Checks if the address has been registered.
448 * @param address the address.
449 * @return true if the address is registered.
450 */
451 bool IsRegisteredMulticastAddress(Ipv6Address address) const;
452
453 /**
454 * Checks if the address has been registered for a specific interface.
455 * @param address the address.
456 * @param interface the incoming interface.
457 * @return true if the address is registered.
458 */
459 bool IsRegisteredMulticastAddress(Ipv6Address address, uint32_t interface) const;
460
461 /**
462 * Provides reachability hint for Neighbor Cache Entries from L4-L7 protocols.
463 *
464 * This function shall be called by L4-L7 protocols when an address is confirmed
465 * to be reachable (i.e., at least a packet send and a reply received).
466 * The net effect is to extend the NCE reachability time if the NCE is in
467 * REACHABLE state, and to mark the NCE as REACHABLE if it is in STALE, PROBE, or
468 * DELAY states. NCEs in INCOMPLETE state are not changed.
469 *
470 * Note that the IP interface index might not be the same as the NetDevice index.
471 * The correct way to check the IP interface index is by using
472 * Ipv6::GetInterfaceForDevice ().
473 *
474 * @param ipInterfaceIndex IP interface index
475 * @param address reachable address
476 * @return true if the NCE has been successfully updated.
477 */
478 bool ReachabilityHint(uint32_t ipInterfaceIndex, Ipv6Address address);
479
480 protected:
481 /**
482 * @brief Dispose object.
483 */
484 void DoDispose() override;
485
486 /**
487 * @brief Notify other components connected to the node that a new stack member is now
488 * connected.
489 *
490 * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them
491 * together.
492 */
493 void NotifyNewAggregate() override;
494
495 private:
496 /**
497 * @brief Ipv6L3ProtocolTestCase test case.
498 * @relates Ipv6L3ProtocolTestCase
499 */
500 friend class ::Ipv6L3ProtocolTestCase;
501 /**
502 * @brief Ipv6ExtensionLooseRouting.
503 * @relates Ipv6ExtensionLooseRouting
504 */
506
507 /**
508 * @brief Container of the IPv6 Interfaces.
509 */
510 typedef std::vector<Ptr<Ipv6Interface>> Ipv6InterfaceList;
511
512 /**
513 * @brief Container of NetDevices registered to IPv6 and their interface indexes.
514 */
515 typedef std::map<Ptr<const NetDevice>, uint32_t> Ipv6InterfaceReverseContainer;
516
517 /**
518 * @brief Container of the IPv6 Raw Sockets.
519 */
520 typedef std::list<Ptr<Ipv6RawSocketImpl>> SocketList;
521
522 /**
523 * @brief Container of the IPv6 L4 keys: protocol number, interface index
524 */
525 typedef std::pair<int, int32_t> L4ListKey_t;
526
527 /**
528 * @brief Container of the IPv6 L4 instances.
529 */
530 typedef std::map<L4ListKey_t, Ptr<IpL4Protocol>> L4List_t;
531
532 /**
533 * @brief Container of the IPv6 Autoconfigured addresses.
534 */
535 typedef std::list<Ptr<Ipv6AutoconfiguredPrefix>> Ipv6AutoconfiguredPrefixList;
536
537 /**
538 * @brief Iterator of the container of the IPv6 Autoconfigured addresses.
539 */
540 typedef std::list<Ptr<Ipv6AutoconfiguredPrefix>>::iterator Ipv6AutoconfiguredPrefixListI;
541
542 /**
543 * @brief Make a copy of the packet, add the header and invoke the TX trace callback
544 * @param ipHeader the IP header that will be added to the packet
545 * @param packet the packet
546 * @param ipv6 the Ipv6 protocol
547 * @param interface the IP-level interface index
548 *
549 * Note: If the TracedCallback API ever is extended, we could consider
550 * to check for connected functions before adding the header
551 */
552 void CallTxTrace(const Ipv6Header& ipHeader,
553 Ptr<Packet> packet,
554 Ptr<Ipv6> ipv6,
555 uint32_t interface);
556
557 /**
558 * @brief Callback to trace TX (transmission) packets.
559 * @deprecated The non-const \c Ptr<Ipv6> argument is deprecated
560 * and will be changed to \c Ptr<const Ipv6> in a future release.
561 */
562 // NS_DEPRECATED() - tag for future removal
564
565 /**
566 * @brief Callback to trace RX (reception) packets.
567 * @deprecated The non-const \c Ptr<Ipv6> argument is deprecated
568 * and will be changed to \c Ptr<const Ipv6> in a future release.
569 */
570 // NS_DEPRECATED() - tag for future removal
572
573 /**
574 * @brief Callback to trace drop packets.
575 * @deprecated The non-const \c Ptr<Ipv6> argument is deprecated
576 * and will be changed to \c Ptr<const Ipv6> in a future release.
577 */
578 // NS_DEPRECATED() - tag for future removal
581
582 /// Trace of sent packets
584 /// Trace of unicast forwarded packets
586 /// Trace of locally delivered packets
588
589 /**
590 * @brief Construct an IPv6 header.
591 * @param src source IPv6 address
592 * @param dst destination IPv6 address
593 * @param protocol L4 protocol
594 * @param payloadSize payload size
595 * @param hopLimit Hop limit
596 * @param tclass Tclass
597 * @return newly created IPv6 header
598 */
600 Ipv6Address dst,
601 uint8_t protocol,
602 uint16_t payloadSize,
603 uint8_t hopLimit,
604 uint8_t tclass);
605
606 /**
607 * @brief Send packet with route.
608 * @param route route
609 * @param packet packet to send
610 * @param ipHeader IPv6 header to add to the packet
611 */
612 void SendRealOut(Ptr<Ipv6Route> route, Ptr<Packet> packet, const Ipv6Header& ipHeader);
613
614 /**
615 * @brief Forward a packet.
616 * @param idev Pointer to ingress network device
617 * @param rtentry route
618 * @param p packet to forward
619 * @param header IPv6 header to add to the packet
620 */
622 Ptr<Ipv6Route> rtentry,
624 const Ipv6Header& header);
625
626 /**
627 * @brief Forward a multicast packet.
628 * @param idev Pointer to ingress network device
629 * @param mrtentry route
630 * @param p packet to forward
631 * @param header IPv6 header to add to the packet
632 */
636 const Ipv6Header& header);
637
638 /**
639 * @brief Deliver a packet.
640 * @param p packet delivered
641 * @param ip IPv6 header
642 * @param iif input interface packet was received
643 */
644 void LocalDeliver(Ptr<const Packet> p, const Ipv6Header& ip, uint32_t iif);
645
646 /**
647 * @brief Fallback when no route is found.
648 * @param p packet
649 * @param ipHeader IPv6 header
650 * @param sockErrno error number
651 */
653 const Ipv6Header& ipHeader,
654 Socket::SocketErrno sockErrno);
655
656 /**
657 * @brief Add an IPv6 interface to the stack.
658 * @param interface interface to add
659 * @return index of newly added interface
660 */
662
663 /**
664 * @brief Setup loopback interface.
665 */
666 void SetupLoopback();
667
668 /**
669 * @brief Set IPv6 forwarding state.
670 * @param forward IPv6 forwarding enabled or not
671 */
672 void SetIpForward(bool forward) override;
673
674 /**
675 * @brief Get IPv6 forwarding state.
676 * @return forwarding state (enabled or not)
677 */
678 bool GetIpForward() const override;
679
680 /**
681 * @brief Set IPv6 MTU discover state.
682 * @param mtuDiscover IPv6 MTU discover enabled or not
683 */
684 void SetMtuDiscover(bool mtuDiscover) override;
685
686 /**
687 * @brief Get IPv6 MTU discover state.
688 * @return MTU discover state (enabled or not)
689 */
690 bool GetMtuDiscover() const override;
691
692 /**
693 * @brief Set the ICMPv6 Redirect sending state.
694 * @param sendIcmpv6Redirect ICMPv6 Redirect sending enabled or not
695 */
696 virtual void SetSendIcmpv6Redirect(bool sendIcmpv6Redirect);
697
698 /**
699 * @brief Get the ICMPv6 Redirect sending state.
700 * @return ICMPv6 Redirect sending state (enabled or not)
701 */
702 virtual bool GetSendIcmpv6Redirect() const;
703
704 void SetStrongEndSystemModel(bool model) override;
705 bool GetStrongEndSystemModel() const override;
706
707 /**
708 * @brief Node attached to stack.
709 */
711
712 /**
713 * @brief Forwarding packets (i.e. router mode) state.
714 */
716
717 /**
718 * @brief MTU Discover (i.e. Path MTU) state.
719 */
721
722 /**
723 * @brief Path MTU Cache.
724 */
726
727 /**
728 * @brief List of transport protocol.
729 */
731
732 /**
733 * @brief List of IPv6 interfaces.
734 */
736
737 /**
738 * Container of NetDevice / Interface index associations.
739 */
741
742 /**
743 * @brief Number of IPv6 interfaces managed by the stack.
744 */
746
747 /**
748 * @brief Default TTL for outgoing packets.
749 */
751
752 /**
753 * @brief Default TCLASS for outgoing packets.
754 */
756
757 /**
758 * @brief Rejects packets directed to an interface with wrong address (\RFC{1222}).
759 */
761
762 /**
763 * @brief Routing protocol.
764 */
766
767 /**
768 * @brief List of IPv6 raw sockets.
769 */
771
772 /**
773 * @brief List of IPv6 prefix received from RA.
774 */
776
777 /**
778 * @brief Allow ICMPv6 Redirect sending state
779 */
781
782 /**
783 * @brief IPv6 multicast addresses / interface key.
784 */
785 typedef std::pair<Ipv6Address, uint64_t> Ipv6RegisteredMulticastAddressKey_t;
786
787 /**
788 * @brief Container of the IPv6 multicast addresses.
789 */
790 typedef std::map<Ipv6RegisteredMulticastAddressKey_t, uint32_t>
792
793 /**
794 * @brief Container Iterator of the IPv6 multicast addresses.
795 */
796 typedef std::map<Ipv6RegisteredMulticastAddressKey_t, uint32_t>::iterator
798
799 /**
800 * @brief Container Const Iterator of the IPv6 multicast addresses.
801 */
802 typedef std::map<Ipv6RegisteredMulticastAddressKey_t, uint32_t>::const_iterator
804
805 /**
806 * @brief Container of the IPv6 multicast addresses.
807 */
808 typedef std::map<Ipv6Address, uint32_t> Ipv6RegisteredMulticastAddressNoInterface_t;
809
810 /**
811 * @brief Container Iterator of the IPv6 multicast addresses.
812 */
813 typedef std::map<Ipv6Address, uint32_t>::iterator
815
816 /**
817 * @brief Container Const Iterator of the IPv6 multicast addresses.
818 */
819 typedef std::map<Ipv6Address, uint32_t>::const_iterator
821
822 /**
823 * @brief List of multicast IP addresses of interest, divided per interface.
824 */
826
827 /**
828 * @brief List of multicast IP addresses of interest for all the interfaces.
829 */
831
836};
837
838} /* namespace ns3 */
839
840#endif /* IPV6_L3_PROTOCOL_H */
a polymophic address class
Definition address.h:90
An implementation of the ICMPv6 protocol.
L4 Protocol abstract base class.
Describes an IPv6 address.
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Packet header for IPv6.
Definition ipv6-header.h:24
Ipv6()
Constructor.
Definition ipv6.cc:50
IPv6 address associated with an interface.
The IPv6 representation of a network interface.
bool GetIpForward() const override
Get IPv6 forwarding state.
Ptr< Ipv6PmtuCache > m_pmtuCache
Path MTU Cache.
Ipv6RoutingProtocol::MulticastForwardCallback m_mcb
Multicast forward callback.
void(* SentTracedCallback)(const Ipv6Header &header, Ptr< const Packet > packet, uint32_t interface)
TracedCallback signature for packet sent, forwarded or local-delivered events.
void SetForwarding(uint32_t i, bool val) override
Enable or disable forwarding on interface.
void SetPmtu(Ipv6Address dst, uint32_t pmtu) override
Set the Path MTU for the specified IPv6 destination address.
std::map< L4ListKey_t, Ptr< IpL4Protocol > > L4List_t
Container of the IPv6 L4 instances.
void RegisterOptions() override
Register the IPv6 Options.
void RouteInputError(Ptr< const Packet > p, const Ipv6Header &ipHeader, Socket::SocketErrno sockErrno)
Fallback when no route is found.
uint8_t m_defaultTclass
Default TCLASS for outgoing packets.
bool IsRegisteredMulticastAddress(Ipv6Address address) const
Checks if the address has been registered.
Ptr< Ipv6RoutingProtocol > GetRoutingProtocol() const override
Get current routing protocol used.
bool GetMtuDiscover() const override
Get IPv6 MTU discover state.
bool AddAddress(uint32_t i, Ipv6InterfaceAddress address, bool addOnLinkRoute=true) override
Add an address on interface.
std::map< Ipv6RegisteredMulticastAddressKey_t, uint32_t >::const_iterator Ipv6RegisteredMulticastAddressCIter_t
Container Const Iterator of the IPv6 multicast addresses.
uint16_t GetMetric(uint32_t i) const override
Get metric for an interface.
Ipv6RoutingProtocol::UnicastForwardCallback m_ucb
Unicast forward callback.
void AddAutoconfiguredAddress(uint32_t interface, Ipv6Address network, Ipv6Prefix mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime, Ipv6Address defaultRouter=Ipv6Address::GetZero())
Add an autoconfigured address with RA information.
void SetUp(uint32_t i) override
Set an interface up.
std::list< Ptr< Ipv6AutoconfiguredPrefix > > Ipv6AutoconfiguredPrefixList
Container of the IPv6 Autoconfigured addresses.
TracedCallback< Ptr< const Packet >, Ptr< Ipv6 >, uint32_t > m_txTrace
Callback to trace TX (transmission) packets.
std::map< Ipv6Address, uint32_t > Ipv6RegisteredMulticastAddressNoInterface_t
Container of the IPv6 multicast addresses.
bool IsForwarding(uint32_t i) const override
Is interface allows forwarding ?
void SetStrongEndSystemModel(bool model) override
Set or unset the Strong End System Model.
bool m_sendIcmpv6Redirect
Allow ICMPv6 Redirect sending state.
Ptr< Icmpv6L4Protocol > GetIcmpv6() const
Get ICMPv6 protocol.
bool ReachabilityHint(uint32_t ipInterfaceIndex, Ipv6Address address)
Provides reachability hint for Neighbor Cache Entries from L4-L7 protocols.
uint8_t m_defaultTtl
Default TTL for outgoing packets.
void SetMetric(uint32_t i, uint16_t metric) override
Set metric for an interface.
TracedCallback< Ptr< const Packet >, Ptr< Ipv6 >, uint32_t > m_rxTrace
Callback to trace RX (reception) packets.
TracedCallback< const Ipv6Header &, Ptr< const Packet >, DropReason, Ptr< Ipv6 >, uint32_t > m_dropTrace
Callback to trace drop packets.
std::vector< Ptr< Ipv6Interface > > Ipv6InterfaceList
Container of the IPv6 Interfaces.
DropReason
Reason why a packet has been dropped.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout.
@ DROP_ROUTE_ERROR
Route error.
@ DROP_TTL_EXPIRED
Packet TTL has expired.
@ DROP_INTERFACE_DOWN
Interface is down so can not send packet.
@ DROP_UNKNOWN_OPTION
Unknown option.
@ DROP_NO_ROUTE
No route to host.
@ DROP_UNKNOWN_PROTOCOL
Unknown L4 protocol.
@ DROP_MALFORMED_HEADER
Malformed header.
uint32_t GetNAddresses(uint32_t interface) const override
Get number of address for an interface.
int32_t GetInterfaceForDevice(Ptr< const NetDevice > device) const override
Get interface index which is on a specified net device.
void RegisterExtensions() override
Register the IPv6 Extensions.
TracedCallback< const Ipv6Header &, Ptr< const Packet >, uint32_t > m_sendOutgoingTrace
Trace of sent packets.
bool m_ipForward
Forwarding packets (i.e.
Ipv6AutoconfiguredPrefixList m_prefixes
List of IPv6 prefix received from RA.
std::list< Ptr< Ipv6AutoconfiguredPrefix > >::iterator Ipv6AutoconfiguredPrefixListI
Iterator of the container of the IPv6 Autoconfigured addresses.
void CallTxTrace(const Ipv6Header &ipHeader, Ptr< Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
Make a copy of the packet, add the header and invoke the TX trace callback.
std::map< Ipv6RegisteredMulticastAddressKey_t, uint32_t > Ipv6RegisteredMulticastAddress_t
Container of the IPv6 multicast addresses.
Ipv6InterfaceList m_interfaces
List of IPv6 interfaces.
void Remove(Ptr< IpL4Protocol > protocol) override
Remove a L4 protocol.
Ipv6RegisteredMulticastAddressNoInterface_t m_multicastAddressesNoInterface
List of multicast IP addresses of interest for all the interfaces.
Ipv6InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const override
Get an address.
SocketList m_sockets
List of IPv6 raw sockets.
Ipv6Header BuildHeader(Ipv6Address src, Ipv6Address dst, uint8_t protocol, uint16_t payloadSize, uint8_t hopLimit, uint8_t tclass)
Construct an IPv6 header.
void SetNode(Ptr< Node > node)
Set node associated with this stack.
Ipv6Address SourceAddressSelection(uint32_t interface, Ipv6Address dest) override
Choose the source address to use with destination address.
Ptr< Node > m_node
Node attached to stack.
virtual bool GetSendIcmpv6Redirect() const
Get the ICMPv6 Redirect sending state.
L4List_t m_protocols
List of transport protocol.
Ptr< Ipv6Interface > GetInterface(uint32_t i) const
Get an interface.
void(* DropTracedCallback)(const Ipv6Header &header, Ptr< const Packet > packet, DropReason reason, Ptr< Ipv6 > ipv6, uint32_t interface)
TracedCallback signature for packet drop events.
TracedCallback< const Ipv6Header &, Ptr< const Packet >, uint32_t > m_unicastForwardTrace
Trace of unicast forwarded packets.
uint32_t m_nInterfaces
Number of IPv6 interfaces managed by the stack.
void AddMulticastAddress(Ipv6Address address)
Adds a multicast address to the list of addresses to pass to local deliver.
virtual void ReportDrop(Ipv6Header ipHeader, Ptr< Packet > p, DropReason dropReason)
Report a packet drop.
void Send(Ptr< Packet > packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr< Ipv6Route > route) override
Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers.
void SetupLoopback()
Setup loopback interface.
Ipv6L3Protocol(const Ipv6L3Protocol &)=delete
Ptr< IpL4Protocol > GetProtocol(int protocolNumber) const override
Get L4 protocol by protocol number.
Ptr< Socket > CreateRawSocket()
Create raw IPv6 socket.
Ipv6RegisteredMulticastAddress_t m_multicastAddresses
List of multicast IP addresses of interest, divided per interface.
void RemoveAutoconfiguredAddress(uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter)
Remove an autoconfigured address.
uint16_t GetMtu(uint32_t i) const override
Get MTU for an interface.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, Ptr< Ipv6 > ipv6, uint32_t interface)
TracedCallback signature for packet transmission or reception events.
void Insert(Ptr< IpL4Protocol > protocol) override
Add a L4 protocol.
bool m_mtuDiscover
MTU Discover (i.e.
void SetDefaultTtl(uint8_t ttl)
Set the default TTL.
static constexpr uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
uint32_t AddInterface(Ptr< NetDevice > device) override
Add IPv6 interface for a device.
Ipv6RoutingProtocol::ErrorCallback m_ecb
Error callback.
bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) override
Remove an address from an interface.
void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Receive method when a packet arrive in the stack.
std::map< Ipv6Address, uint32_t >::iterator Ipv6RegisteredMulticastAddressNoInterfaceIter_t
Container Iterator of the IPv6 multicast addresses.
std::map< Ptr< const NetDevice >, uint32_t > Ipv6InterfaceReverseContainer
Container of NetDevices registered to IPv6 and their interface indexes.
Ptr< NetDevice > GetNetDevice(uint32_t i) override
Get device by index.
std::map< Ipv6Address, uint32_t >::const_iterator Ipv6RegisteredMulticastAddressNoInterfaceCIter_t
Container Const Iterator of the IPv6 multicast addresses.
void RemoveMulticastAddress(Ipv6Address address)
Removes a multicast address from the list of addresses to pass to local deliver.
void SetDown(uint32_t i) override
set an interface down.
void DoDispose() override
Dispose object.
uint32_t AddIpv6Interface(Ptr< Ipv6Interface > interface)
Add an IPv6 interface to the stack.
Ptr< Ipv6RoutingProtocol > m_routingProtocol
Routing protocol.
friend class Ipv6ExtensionLooseRouting
Ipv6ExtensionLooseRouting.
virtual void SetSendIcmpv6Redirect(bool sendIcmpv6Redirect)
Set the ICMPv6 Redirect sending state.
void NotifyNewAggregate() override
Notify other components connected to the node that a new stack member is now connected.
void IpMulticastForward(Ptr< const NetDevice > idev, Ptr< Ipv6MulticastRoute > mrtentry, Ptr< const Packet > p, const Ipv6Header &header)
Forward a multicast packet.
~Ipv6L3Protocol() override
Destructor.
void DeleteRawSocket(Ptr< Socket > socket)
Remove raw IPv6 socket.
std::list< Ptr< Ipv6RawSocketImpl > > SocketList
Container of the IPv6 Raw Sockets.
std::map< Ipv6RegisteredMulticastAddressKey_t, uint32_t >::iterator Ipv6RegisteredMulticastAddressIter_t
Container Iterator of the IPv6 multicast addresses.
Ipv6InterfaceReverseContainer m_reverseInterfacesContainer
Container of NetDevice / Interface index associations.
void SendRealOut(Ptr< Ipv6Route > route, Ptr< Packet > packet, const Ipv6Header &ipHeader)
Send packet with route.
bool m_strongEndSystemModel
Rejects packets directed to an interface with wrong address (RFC 1222).
TracedCallback< const Ipv6Header &, Ptr< const Packet >, uint32_t > m_localDeliverTrace
Trace of locally delivered packets.
int32_t GetInterfaceForPrefix(Ipv6Address addr, Ipv6Prefix mask) const override
Get interface index which match specified address/prefix.
void SetDefaultTclass(uint8_t tclass)
Set the default TCLASS.
void IpForward(Ptr< const NetDevice > idev, Ptr< Ipv6Route > rtentry, Ptr< const Packet > p, const Ipv6Header &header)
Forward a packet.
uint32_t GetNInterfaces() const override
Get current number of interface on this stack.
bool IsUp(uint32_t i) const override
Is specified interface up ?
void SetRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol) override
Set routing protocol for this stack.
std::pair< Ipv6Address, uint64_t > Ipv6RegisteredMulticastAddressKey_t
IPv6 multicast addresses / interface key.
Ipv6RoutingProtocol::LocalDeliverCallback m_lcb
Local delivery callback.
std::pair< int, int32_t > L4ListKey_t
Container of the IPv6 L4 keys: protocol number, interface index.
bool GetStrongEndSystemModel() const override
Get the Strong End System Model status.
int32_t GetInterfaceForAddress(Ipv6Address addr) const override
Get interface index which has specified IPv6 address.
Ipv6L3Protocol()
Constructor.
void SetIpForward(bool forward) override
Set IPv6 forwarding state.
Ipv6L3Protocol & operator=(const Ipv6L3Protocol &)=delete
void LocalDeliver(Ptr< const Packet > p, const Ipv6Header &ip, uint32_t iif)
Deliver a packet.
static TypeId GetTypeId()
Get the type ID of this class.
void SetMtuDiscover(bool mtuDiscover) override
Set IPv6 MTU discover state.
IPv6 multicast route entry.
Definition ipv6-route.h:127
Describes an IPv6 prefix.
IPv6 route cache entry.
Definition ipv6-route.h:30
Callback< void, Ptr< const Packet >, const Ipv6Header &, Socket::SocketErrno > ErrorCallback
Callback for routing errors (e.g., no route found)
Callback< void, Ptr< const NetDevice >, Ptr< Ipv6MulticastRoute >, Ptr< const Packet >, const Ipv6Header & > MulticastForwardCallback
Callback for multicast packets to be forwarded.
Callback< void, Ptr< const Packet >, const Ipv6Header &, uint32_t > LocalDeliverCallback
Callback for packets to be locally delivered.
Callback< void, Ptr< const NetDevice >, Ptr< Ipv6Route >, Ptr< const Packet >, const Ipv6Header & > UnicastForwardCallback
Callback for unicast packets to be forwarded.
PacketType
Packet types are used as they are in Linux.
Definition net-device.h:289
A network Node.
Definition node.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition socket.h:73
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
Every class exported by the ns3 library is enclosed in the ns3 namespace.