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