A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sixlowpan-nd-protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Università di Firenze, Italy
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 *
7 *
8 * Author: Alessio Bonadio <alessio.bonadio@gmail.com>
9 * Tommaso Pecorella <tommaso.pecorella@unifi.it>
10 * Adnan Rashid <adnanrashidpk@gmail.com>
11 * Boh Jie Qi <jieqiboh5836@gmail.com>
12 */
13
14#ifndef SIXLOWPAN_ND_PROTOCOL_H
15#define SIXLOWPAN_ND_PROTOCOL_H
16
17#include "sixlowpan-header.h"
19#include "sixlowpan-nd-header.h"
20
21#include "ns3/icmpv6-l4-protocol.h"
22#include "ns3/ip-l4-protocol.h"
23#include "ns3/ipv6-address.h"
24#include "ns3/lollipop-counter.h"
25
26#include <set>
27#include <utility>
28
29namespace ns3
30{
31
40
41/**
42 * @ingroup sixlowpan
43 * @brief An optimization of the ND protocol for 6LoWPANs.
44 */
46{
51 friend class SixLowPanNdNsNaTest;
52 friend class SixLowPanNdRovrTest;
53
54 public:
55 /**
56 * 6LoWPAN-ND EARO registration status codes
57 */
59 {
60 SUCCESS = 0x0, //!< Success
61 DUPLICATE_ADDRESS, //!< Duplicate Address
62 NEIGHBOR_CACHE_FULL, //!< Neighbor Cache Full
63 MOVED, //!< Registration failed because it is not the most recent
64 REMOVED, //!< Binding state was removed.
65 VALIDATION_REQUEST, //!< Registering Node is challenged for owning the Registered Address or
66 //!< for being an acceptable proxy for the registration.
67 DUPLICATE_SOURCE_ADDRESS, //!< Address used as the source of the NS(EARO) conflicts with an
68 //!< existing registration.
69 INVALID_SOURCE_ADDRESS, //!< Address used as the source of the NS(EARO) is not a Link-Local
70 //!< Address.
71 REGISTERED_ADDRESS_TOPOLOGICALLY_INCORRECT, //!< Address being registered is not usable on
72 //!< this link.
73 SIXLBR_REGISTRY_SATURATED, //!< 6LBR Registry is saturated.
74 VALIDATION_FAILED //!< The proof of ownership of the Registered Address is not correct.
75 };
76
77 /**
78 * @brief 6LBR constant: minimum delay (in seconds) before a context change may be
79 * advertised after a previous change. RFC 6775, Table 2.
80 */
81 static constexpr uint16_t MIN_CONTEXT_CHANGE_DELAY{300};
82
83 /**
84 * @brief 6LR constant: maximum number of initial RA transmissions. RFC 6775, Table 1.
85 * Currently unused; reserved for future 6LR role implementation.
86 */
87 static constexpr uint8_t MAX_RTR_ADVERTISEMENTS{3};
88
89 /**
90 * @brief 6LR constant: minimum delay (in seconds) between consecutive RAs. RFC 6775, Table 1.
91 * Currently unused; reserved for future 6LR role implementation.
92 */
93 static constexpr uint8_t MIN_DELAY_BETWEEN_RAS{10};
94
95 /**
96 * @brief 6LR constant: maximum delay (in seconds) before responding to an RS. RFC 6775,
97 * Table 1. Currently unused; reserved for future 6LR role implementation.
98 */
99 static constexpr uint8_t MAX_RA_DELAY_TIME{2};
100
101 /**
102 * @brief Router constant: hop limit used for multihop DAR/DAC messages. RFC 6775, Table 1.
103 */
104 static constexpr uint8_t MULTIHOP_HOPLIMIT{64};
105
106 /**
107 * @brief Constructor.
108 */
110
111 /**
112 * @brief Destructor.
113 */
114 ~SixLowPanNdProtocol() override;
115
116 /**
117 * @brief Get the type ID.
118 * @return The object TypeId.
119 */
120 static TypeId GetTypeId();
121
122 void DoInitialize() override;
123 void NotifyNewAggregate() override;
124
125 /**
126 * Assign a fixed random variable stream number to the random variables
127 * used by this model. Return the number of streams (possibly zero) that
128 * have been assigned.
129 *
130 * @param stream first stream index to use
131 * @return the number of stream indices assigned by this model
132 */
133 int64_t AssignStreams(int64_t stream);
134
136 const Ipv6Header& header,
137 Ptr<Ipv6Interface> interface) override;
138
139 /**
140 * @brief Create and register a binding table for the given device and interface.
141 * @param device the net device
142 * @param interface the IPv6 interface
143 */
145
146 bool Lookup(Ptr<Packet> p,
147 const Ipv6Header& ipHeader,
148 Ipv6Address dst,
149 Ptr<NetDevice> device,
150 Ptr<NdiscCache> cache,
151 Address* hardwareDestination) override;
152
153 void FunctionDadTimeout(Ipv6Interface* interface, Ipv6Address addr) override;
154
155 /**
156 * Sets the ROVR for the node.
157 *
158 * @param rovr ROVR to set for this node
159 */
160 void SetRovr(const std::vector<uint8_t> rovr);
161
162 /**
163 * @brief Send a NS for 6LoWPAN ND (+ EARO, SLLAO).
164 * @param addrToRegister source IPv6 address
165 * @param dst destination IPv6 address
166 * @param dstMac destination MAC address
167 * @param time registration lifetime (EARO)
168 * @param rovr ROVR (EARO)
169 * @param sixDevice SixLowPan NetDevice
170 */
171 void SendSixLowPanNsWithEaro(Ipv6Address addrToRegister,
172 Ipv6Address dst,
173 Address dstMac,
174 uint16_t time,
175 const std::vector<uint8_t>& rovr,
176 Ptr<NetDevice> sixDevice);
177
178 /**
179 * @brief Send a NA for 6LoWPAN ND (+ EARO).
180 * @param src source IPv6 address
181 * @param dst destination IPv6 address
182 * @param target target IPv6 address
183 * @param time registration lifetime (EARO)
184 * @param rovr ROVR (EARO)
185 * @param sixDevice SixLowPan NetDevice
186 * @param status status (EARO)
187 */
189 Ipv6Address dst,
190 Ipv6Address target,
191 uint16_t time,
192 const std::vector<uint8_t>& rovr,
193 Ptr<NetDevice> sixDevice,
194 uint8_t status);
195 /**
196 * @brief Send a Multicast RS (+ 6CIO) (RFC6775 5.3)
197 * @param src source IPv6 address
198 * @param hardwareAddress the hardware address of the node
199 */
200 void SendSixLowPanMulticastRS(Ipv6Address src, Address hardwareAddress);
201
202 /**
203 * @brief Send a RA for 6LoWPAN ND (+ PIO, 6CO, 6CIO, ABRO, SLLAO).
204 * @param src source IPv6 address
205 * @param dst destination IPv6 address
206 * @param interface the interface from which the packet will be sent
207 */
209
210 /**
211 * @brief Set an interface to be used as a 6LBR
212 * @param device device to be used for announcement
213 */
215
216 /**
217 * @brief Set a prefix to be announced on an interface (6LBR)
218 * @param device device to be used for announcement
219 * @param prefix announced prefix
220 */
222
223 /**
224 * @brief Add a context to be advertised on an interface (6LBR)
225 * @param device device to be used for advertisement
226 * @param context advertised context
227 */
229
230 /**
231 * @brief Remove a context to be advertised on an interface (6LBR)
232 * @param device device to be used for advertisement
233 * @param context advertised context
234 */
236
237 /**
238 * @brief Checks if an interface is set as 6LBR
239 * @param device the interface to check
240 * @return true if the interface is configured as a 6LBR
241 */
243
244 /**
245 * @brief Find the binding table corresponding to the IPv6 interface.
246 * @param interface the IPv6 interface
247 * @return the SixLowPanNdBindingTable associated with the interface
248 */
250
251 protected:
252 /**
253 * @brief Dispose this object.
254 */
255 void DoDispose() override;
256
257 private:
258 /**
259 * @brief RA advertised from routers for 6LoWPAN ND.
260 */
261 class SixLowPanRaEntry : public SimpleRefCount<SixLowPanRaEntry>
262 {
263 public:
265
266 /**
267 * Creates a RA entry from the RA header contents
268 * @param raHeader the RA header
269 * @param abroHdr the ABRO header
270 * @param contextList the list of Contexts
271 * @param prefixList the list of PIOs
272 */
273 SixLowPanRaEntry(Icmpv6RA raHeader,
275 std::list<Icmpv6OptionSixLowPanContext> contextList,
276 std::list<Icmpv6OptionPrefixInformation> prefixList);
277
279
280 /**
281 * @brief Get the prefixes advertised for this interface.
282 * @return a list of IPv6 prefixes
283 */
284 std::list<Ptr<SixLowPanNdPrefix>> GetPrefixes() const;
285
286 /**
287 * @brief Add a prefix to advertise on interface.
288 * @param prefix prefix to advertise
289 */
291
292 /**
293 * @brief Remove a prefix from the ones advertised on interface.
294 * @param prefix prefix to remove from advertisements
295 */
297
298 /**
299 * @brief Get list of 6LoWPAN contexts advertised for this interface.
300 * @return list of 6LoWPAN contexts
301 */
302 std::map<uint8_t, Ptr<SixLowPanNdContext>> GetContexts() const;
303
304 /**
305 * @brief Add a 6LoWPAN context to advertise on interface.
306 * @param context 6LoWPAN context to advertise
307 */
309
310 /**
311 * @brief Remove a 6LoWPAN context.
312 * @param context 6LoWPAN context to remove
313 */
315
316 /**
317 * Builds an Icmpv6RA from the stored data.
318 * @return the Icmpv6RA.
319 */
321
322 /**
323 * Builds a container of Icmpv6OptionPrefixInformation from the stored data.
324 * @return the Icmpv6OptionPrefixInformation container.
325 */
326 std::list<Icmpv6OptionPrefixInformation> BuildPrefixInformationOptions();
327
328 /**
329 * @brief Is managed flag enabled ?
330 * @return managed flag
331 */
332 bool IsManagedFlag() const;
333
334 /**
335 * @brief Set managed flag
336 * @param managedFlag value
337 */
338 void SetManagedFlag(bool managedFlag);
339
340 /**
341 * @brief Is "other config" flag enabled ?
342 * @return other config flag
343 */
344 bool IsOtherConfigFlag() const;
345
346 /**
347 * @brief Is "home agent" flag enabled ?
348 * @return "home agent" flag
349 */
350 bool IsHomeAgentFlag() const;
351
352 /**
353 * @brief Set "home agent" flag.
354 * @param homeAgentFlag value
355 */
356 void SetHomeAgentFlag(bool homeAgentFlag);
357
358 /**
359 * @brief Set "other config" flag
360 * @param otherConfigFlag value
361 */
362 void SetOtherConfigFlag(bool otherConfigFlag);
363
364 /**
365 * @brief Get reachable time.
366 * @return reachable time
367 */
369
370 /**
371 * @brief Set reachable time.
372 * @param time reachable time
373 */
374 void SetReachableTime(uint32_t time);
375
376 /**
377 * @brief Get router lifetime.
378 * @return router lifetime
379 */
381
382 /**
383 * @brief Set router lifetime.
384 * @param time router lifetime
385 */
386 void SetRouterLifeTime(uint32_t time);
387
388 /**
389 * @brief Get retransmission timer.
390 * @return retransmission timer
391 */
393
394 /**
395 * @brief Set retransmission timer.
396 * @param timer retransmission timer
397 */
398 void SetRetransTimer(uint32_t timer);
399
400 /**
401 * @brief Get current hop limit.
402 * @return current hop limit for the link
403 */
404 uint8_t GetCurHopLimit() const;
405
406 /**
407 * @brief Set current hop limit.
408 * @param curHopLimit current hop limit for the link
409 */
410 void SetCurHopLimit(uint8_t curHopLimit);
411
412 /**
413 * @brief Get version value (ABRO).
414 * @return the version value
415 */
416 uint32_t GetAbroVersion() const;
417
418 /**
419 * @brief Set version value (ABRO).
420 * @param version the version value
421 */
422 void SetAbroVersion(uint32_t version);
423
424 /**
425 * @brief Get valid lifetime value (ABRO).
426 * @return the valid lifetime (units of 60 seconds)
427 */
428 uint16_t GetAbroValidLifeTime() const;
429
430 /**
431 * @brief Set valid lifetime value (ABRO).
432 * @param time the valid lifetime (units of 60 seconds)
433 */
434 void SetAbroValidLifeTime(uint16_t time);
435
436 /**
437 * @brief Get Border Router address (ABRO).
438 * @return the Border Router address
439 */
441
442 /**
443 * @brief Set Border Router address (ABRO).
444 * @param border the Border Router address
445 */
447
448 /**
449 * @brief Parse an ABRO and records the appropriate params.
450 * @param abro the Authoritative Border Router Option header
451 * @return true if the parsing was correct.
452 */
454
455 /**
456 * @brief Build an ABRO header.
457 * @return the Authoritative Border Router Option header
458 */
460
461 private:
462 /**
463 * @brief Advertised Prefixes.
464 */
465 std::list<Ptr<SixLowPanNdPrefix>> m_prefixes;
466
467 /**
468 * @brief List of 6LoWPAN contexts advertised.
469 */
470 std::map<uint8_t, Ptr<SixLowPanNdContext>> m_contexts;
471
472 /**
473 * @brief Managed flag. If true, the host uses the stateful protocol for address
474 * autoconfiguration.
475 */
477
478 /**
479 * @brief Other configuration flag. If true, the host uses the stateful protocol for other
480 * (non-address) information.
481 */
483
484 /**
485 * @brief Flag to add HA (home agent) flag in RA.
486 */
488
489 /**
490 * @brief Reachable time in milliseconds.
491 */
493
494 /**
495 * @brief Retransmission timer in milliseconds.
496 */
498
499 /**
500 * @brief Current hop limit (TTL).
501 */
503
504 /**
505 * @brief Router life time in seconds.
506 */
508
509 /**
510 * @brief Version value for ABRO.
511 */
513
514 /**
515 * @brief Valid lifetime value for ABRO (units of 60 seconds).
516 */
518
519 /**
520 * @brief Border Router address for ABRO.
521 */
523 };
524
525 /**
526 * Role of the node: 6LN, 6LR, 6LBR
527 *
528 * A Node starts either as a 6LN or as a 6LBR.
529 * A 6LN can become a 6LR.
530 *
531 */
533 {
534 SixLowPanNodeOnly, //!< a 6LN that can not become a 6LR
535 SixLowPanNode, //!< a 6LN that can (and want to) become a 6LR
537 };
538
539 /**
540 * @brief The amount of time (units of 60 seconds) that the router should retain the NCE for the
541 * node.
542 */
543 uint16_t m_regTime;
544
545 /**
546 * @brief How many seconds before registration expiry to begin re-registration.
547 */
548 uint16_t m_advance;
549
550 /**
551 * @brief Status of the node.
552 */
554
555 Time m_routerLifeTime; //!< Default Router Lifetime.
556 Time m_pioPreferredLifeTime; //!< Default Prefix Information Preferred Lifetime.
557 Time m_pioValidLifeTime; //!< Default Prefix Information Valid Lifetime.
558 Time m_contextValidLifeTime; //!< Default Context Valid Lifetime.
559 Time m_abroValidLifeTime; //!< Default ABRO Valid Lifetime.
560
561 /**
562 * @brief Random jitter before sending address registrations.
563 */
565
566 /**
567 * @brief NS handler for 6LoWPAN ND.
568 * @param packet the packet.
569 * @param src source address.
570 * @param dst destination address.
571 * @param interface the interface from which the packet is coming.
572 */
573 void HandleSixLowPanNS(Ptr<Packet> packet,
574 const Ipv6Address& src,
575 const Ipv6Address& dst,
576 Ptr<Ipv6Interface> interface);
577
578 /**
579 * @brief NA handler for 6LoWPAN ND.
580 * @param packet the packet
581 * @param src source address
582 * @param dst destination address
583 * @param interface the interface from which the packet is coming
584 */
585 void HandleSixLowPanNA(Ptr<Packet> packet,
586 const Ipv6Address& src,
587 const Ipv6Address& dst,
588 Ptr<Ipv6Interface> interface);
589
590 /**
591 * @brief RS handler for 6LoWPAN ND.
592 * @param packet the packet
593 * @param src source address
594 * @param dst destination address
595 * @param interface the interface from which the packet is coming
596 */
597 void HandleSixLowPanRS(Ptr<Packet> packet,
598 const Ipv6Address& src,
599 const Ipv6Address& dst,
600 Ptr<Ipv6Interface> interface);
601
602 /**
603 * @brief RA handler for 6LoWPAN ND.
604 * @param packet the packet
605 * @param src source address
606 * @param dst destination address
607 * @param interface the interface from which the packet is coming
608 */
609 void HandleSixLowPanRA(Ptr<Packet> packet,
610 const Ipv6Address& src,
611 const Ipv6Address& dst,
612 Ptr<Ipv6Interface> interface);
613
614 /**
615 * Address registration procedure
616 */
617 void AddressRegistration();
618
619 /**
620 * Address registration success or failure.
621 *
622 * @param registrar node that performs the registration. Registered Node or a proxy.
623 */
625
626 /**
627 * Address registration timeout handler
628 */
630
631 uint8_t m_addressRegistrationCounter = 0; //!< Number of retries of an address registration.
632
633 std::vector<uint8_t> m_rovr; //!< Node ROVR
634
635 EventId m_addressRegistrationTimeoutEvent; //!< Address Registration timeout event.
636
637 EventId m_addressRegistrationEvent; //!< Address Registration event.
638
639 std::set<Ipv6Address>
640 m_raCache; //!< Set of 6LBR addresses from which a RA has already been processed.
641
642 std::map<Ptr<SixLowPanNetDevice>, Ptr<SixLowPanRaEntry>>
643 m_raEntries; //!< Router Advertisement entries (if the node is a 6LBR).
644
646 m_addressRegistrationResultTrace; //!< Traces address registration result (address,
647 //!< success/failure, status code)
648
650 AddressRegistrationCallback; //!< Trace sink signature for address registration result
651
652 TracedCallback<Ipv6Address> m_multicastRsTrace; //!< Trace fired whenever a multicast RS is sent
653
655 MulticastRsCallback; //!< Trace sink signature for multicast RS sends
656
657 TracedCallback<Ptr<Packet>> m_naRxTrace; //!< Trace fired whenever an NA packet is received
658
659 typedef Callback<void, Ptr<Packet>> NaRxCallback; //!< Trace sink signature for NA reception
660
661 /**
662 * Struct holding data about a pending RA being processed.
663 */
665 {
666 Ipv6Address source; //!< Origin of the RA / Registering Node (will be a 6LBR)
667 Icmpv6OptionLinkLayerAddress llaHdr; //!< Contains MAC address of the RA sender (6LBR)
668 Ptr<Ipv6Interface> interface; //!< Interface that received the RA
669 std::list<std::pair<Ipv6Address, Icmpv6OptionPrefixInformation>>
670 addressesToBeRegistered; //!< Addresses pending registration with their PIOs.
671 };
672
673 std::list<SixLowPanPendingRa> m_pendingRas; //!< RA awaiting processing (address registration).
674
675 /**
676 * Struct holding data about registered addresses.
677 */
679 {
680 Ipv6Address registrar; //!< Registering node (link-local addr / gaddr of 6LBR)
681 Time registrationTimeout; //!< Registration expiration time
682 Ipv6Address registeredAddr; //!< Registered address
683 Icmpv6OptionLinkLayerAddress llaHdr; //!< Contains MAC address of the RA sender (6LBR)
684 Ptr<Ipv6Interface> interface; //!< Interface used for the registration
686 pioHdr; //!< Prefix Information Option for the address being registered
687 };
688
689 std::list<SixLowPanRegisteredAddress>
690 m_registeredAddresses; //!< Addresses that have been registered.
691
692 /**
693 * Struct holding data for the address currently being registered.
694 */
696 {
697 bool isValid; //!< The data are valid (for timeouts and retransmissions)
698 Ipv6Address addressPendingRegistration; //!< Address being Registered
699 Ipv6Address registrar; //!< Registering node address (always link-local)
700 bool newRegistration; //!< new registration (true) or re-registration (false)
702 llaHdr; //!< Link-Layer address option from the RA (can be 6LR or 6LBR).
703 Ptr<Ipv6Interface> interface; //!< Interface on which the RA was received
705 pioHdr; //!< Prefix Information Option for the address being registered
706 };
707
708 AddressPendingRegistration m_addrPendingReg; //!< Address currently being Registered
709
710 Time m_maxRtrSolicitationInterval; //!< Maximum RS Retransmission interval
711
713 std::list<Ptr<SixLowPanNdBindingTable>>; //!< container of BindingTables
714
715 BindingTableList m_bindingTableList; //!< Binding Table for 6LoWPAN ND
716
717 /**
718 * @brief Construct NS (EARO) packet.
719 * @param src source address
720 * @param dst destination address
721 * @param nsHdr
722 * @param slla
723 * @param tlla
724 * @param earo
725 * @return NS (EARO) Packet
726 */
728 Ipv6Address dst,
729 Icmpv6NS& nsHdr,
733
734 /**
735 * @brief Construct NA (EARO) packet.
736 * @param src source address
737 * @param dst destination address
738 * @param naHdr
739 * @param earo
740 * @return NA (EARO) Packet
741 */
743 Ipv6Address dst,
744 Icmpv6NA& naHdr,
746
747 /**
748 * @brief Constructs a RA packet (raEntry contains info for raHdr, pios, abro and contexts)
749 * @param src source address
750 * @param dst destination address
751 * @param slla Source Link-Layer Address Option
752 * @param cio Capability Indication Option
753 * @param raEntry RA entry containing router advertisement information
754 * @return RA Packet
755 */
757 Ipv6Address dst,
760 Ptr<SixLowPanRaEntry> raEntry);
761
762 /**
763 * @brief Parses NS packet and populates params, returning true if packet is a valid NS/NS(EARO)
764 * packet
765 * @param p Packet to be parsed
766 * @param nsHdr populated with packet nsHdr
767 * @param slla populated with packet SLLAO if present
768 * @param tlla populated with packet TLLAO if present
769 * @param earo populated with packet EARO if present
770 * @param hasEaro true if NS packet contains an EARO option
771 * @return True if packet is valid, false otherwise
772 */
774 Icmpv6NS& nsHdr,
778 bool& hasEaro);
779
780 /**
781 * @brief Parses NA packet and populates params, returning true if packet is valid
782 * @param p Packet to be parsed
783 * @param naHdr populated with packet NA header
784 * @param tlla populated with packet Target Link-Layer Address Option if present
785 * @param earo populated with packet EARO if present
786 * @param hasEaro true if NA packet contains an EARO option
787 * @return True if packet is valid, false otherwise
788 */
790 Icmpv6NA& naHdr,
793 bool& hasEaro);
794
795 /**
796 * @brief Parses RS packet and populates params, returning true if packet is valid
797 * @param p Packet to be parsed
798 * @param rsHdr populated with packet RS header
799 * @param slla populated with packet Source Link-Layer Address Option if present
800 * @param cio populated with packet Capability Indication Option if present
801 * @return True if packet is valid, false otherwise
802 */
804 Icmpv6RS& rsHdr,
807
808 /**
809 * @brief Parses RA packet and populates params, returning true if packet is valid
810 * @param p Packet to be parsed
811 * @param raHdr populated with packet RA header
812 * @param pios populated with Prefix Information Options from the packet
813 * @param abro populated with Authoritative Border Router Option from the packet
814 * @param slla populated with Source Link-Layer Address Option if present
815 * @param cio populated with Capability Indication Option if present
816 * @param contexts populated with 6LoWPAN Context Options from the packet
817 * @return True if packet is valid, false otherwise
818 */
820 Icmpv6RA& raHdr,
821 std::list<Icmpv6OptionPrefixInformation>& pios,
825 std::list<Icmpv6OptionSixLowPanContext>& contexts);
826};
827
828} /* namespace ns3 */
829
830#endif
a polymophic address class
Definition address.h:114
Callback template class.
Definition callback.h:428
An identifier for simulation events.
Definition event-id.h:45
ICMPv6 Neighbor Advertisement header.
ICMPv6 Neighbor Solicitation header.
ICMPv6 Option Prefix Information.
ICMPv6 Authoritative Border Router Option header (see RFC 8505).
6LoWPAN Capability Indication Option - see RFC 7400.
ICMPv6 Extended Address Registration Option header RFC 8505.
ICMPv6 Router Advertisement header.
ICMPv6 Router Solicitation header.
RxStatus
Rx status codes.
Describes an IPv6 address.
Packet header for IPv6.
Definition ipv6-header.h:24
The IPv6 representation of a network interface.
Describes an IPv6 prefix.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
6LoWPAN context container for 6LoWPAN ND.
6LoWPAN-ND test case for NA(EARO) packet creation and parsing
6LoWPAN-ND test case for NS(EARO) packet creation and parsing
Router prefix container for 6LoWPAN ND.
void SetManagedFlag(bool managedFlag)
Set managed flag.
void SetHomeAgentFlag(bool homeAgentFlag)
Set "home agent" flag.
void SetCurHopLimit(uint8_t curHopLimit)
Set current hop limit.
Icmpv6OptionSixLowPanAuthoritativeBorderRouter MakeAbro()
Build an ABRO header.
std::list< Ptr< SixLowPanNdPrefix > > m_prefixes
Advertised Prefixes.
uint32_t GetRouterLifeTime() const
Get router lifetime.
uint32_t m_retransTimer
Retransmission timer in milliseconds.
uint16_t m_abroValidLifeTime
Valid lifetime value for ABRO (units of 60 seconds).
void RemovePrefix(Ptr< SixLowPanNdPrefix > prefix)
Remove a prefix from the ones advertised on interface.
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
uint8_t GetCurHopLimit() const
Get current hop limit.
bool m_homeAgentFlag
Flag to add HA (home agent) flag in RA.
std::list< Ptr< SixLowPanNdPrefix > > GetPrefixes() const
Get the prefixes advertised for this interface.
Ipv6Address m_abroBorderRouter
Border Router address for ABRO.
SixLowPanRaEntry()
void SetRouterLifeTime(uint32_t time)
Set router lifetime.
uint32_t GetRetransTimer() const
Get retransmission timer.
void SetAbroVersion(uint32_t version)
Set version value (ABRO).
bool m_otherConfigFlag
Other configuration flag.
Icmpv6RA BuildRouterAdvertisementHeader() const
Builds an Icmpv6RA from the stored data.
void SetAbroValidLifeTime(uint16_t time)
Set valid lifetime value (ABRO).
uint32_t GetReachableTime() const
Get reachable time.
bool m_managedFlag
Managed flag.
std::map< uint8_t, Ptr< SixLowPanNdContext > > GetContexts() const
Get list of 6LoWPAN contexts advertised for this interface.
uint8_t m_curHopLimit
Current hop limit (TTL).
uint32_t GetAbroVersion() const
Get version value (ABRO).
Ipv6Address GetAbroBorderRouterAddress() const
Get Border Router address (ABRO).
void SetRetransTimer(uint32_t timer)
Set retransmission timer.
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
std::list< Icmpv6OptionPrefixInformation > BuildPrefixInformationOptions()
Builds a container of Icmpv6OptionPrefixInformation from the stored data.
void SetAbroBorderRouterAddress(Ipv6Address border)
Set Border Router address (ABRO).
uint32_t m_routerLifeTime
Router life time in seconds.
uint32_t m_reachableTime
Reachable time in milliseconds.
bool IsManagedFlag() const
Is managed flag enabled ?
void SetOtherConfigFlag(bool otherConfigFlag)
Set "other config" flag.
void SetReachableTime(uint32_t time)
Set reachable time.
~SixLowPanRaEntry()
uint32_t m_abroVersion
Version value for ABRO.
uint16_t GetAbroValidLifeTime() const
Get valid lifetime value (ABRO).
void AddContext(Ptr< SixLowPanNdContext > context)
Add a 6LoWPAN context to advertise on interface.
void RemoveContext(Ptr< SixLowPanNdContext > context)
Remove a 6LoWPAN context.
bool ParseAbro(Icmpv6OptionSixLowPanAuthoritativeBorderRouter abro)
Parse an ABRO and records the appropriate params.
std::map< uint8_t, Ptr< SixLowPanNdContext > > m_contexts
List of 6LoWPAN contexts advertised.
void AddPrefix(Ptr< SixLowPanNdPrefix > prefix)
Add a prefix to advertise on interface.
void AddAdvertisedContext(Ptr< SixLowPanNetDevice > device, Ipv6Prefix context)
Add a context to be advertised on an interface (6LBR).
void SendSixLowPanNsWithEaro(Ipv6Address addrToRegister, Ipv6Address dst, Address dstMac, uint16_t time, const std::vector< uint8_t > &rovr, Ptr< NetDevice > sixDevice)
Send a NS for 6LoWPAN ND (+ EARO, SLLAO).
void FunctionDadTimeout(Ipv6Interface *interface, Ipv6Address addr) override
Function called when DAD timeout.
static constexpr uint8_t MAX_RTR_ADVERTISEMENTS
6LR constant: maximum number of initial RA transmissions.
static Ptr< Packet > MakeRaPacket(Ipv6Address src, Ipv6Address dst, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionSixLowPanCapabilityIndication &cio, Ptr< SixLowPanRaEntry > raEntry)
Constructs a RA packet (raEntry contains info for raHdr, pios, abro and contexts).
std::list< Ptr< SixLowPanNdBindingTable > > BindingTableList
container of BindingTables
Time m_routerLifeTime
Default Router Lifetime.
void HandleSixLowPanRA(Ptr< Packet > packet, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
RA handler for 6LoWPAN ND.
static bool ParseAndValidateRaPacket(Ptr< Packet > p, Icmpv6RA &raHdr, std::list< Icmpv6OptionPrefixInformation > &pios, Icmpv6OptionSixLowPanAuthoritativeBorderRouter &abro, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionSixLowPanCapabilityIndication &cio, std::list< Icmpv6OptionSixLowPanContext > &contexts)
Parses RA packet and populates params, returning true if packet is valid.
void SendSixLowPanMulticastRS(Ipv6Address src, Address hardwareAddress)
Send a Multicast RS (+ 6CIO) (RFC6775 5.3).
void SendSixLowPanRA(Ipv6Address src, Ipv6Address dst, Ptr< Ipv6Interface > interface)
Send a RA for 6LoWPAN ND (+ PIO, 6CO, 6CIO, ABRO, SLLAO).
TracedCallback< Ptr< Packet > > m_naRxTrace
Trace fired whenever an NA packet is received.
TracedCallback< Ipv6Address, bool, uint8_t > m_addressRegistrationResultTrace
Traces address registration result (address, success/failure, status code).
static Ptr< Packet > MakeNaEaroPacket(Ipv6Address src, Ipv6Address dst, Icmpv6NA &naHdr, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo)
Construct NA (EARO) packet.
static bool ParseAndValidateNsEaroPacket(Ptr< Packet > p, Icmpv6NS &nsHdr, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionLinkLayerAddress &tlla, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo, bool &hasEaro)
Parses NS packet and populates params, returning true if packet is a valid NS/NS(EARO) packet.
void AddressRegistration()
Address registration procedure.
Time m_pioPreferredLifeTime
Default Prefix Information Preferred Lifetime.
Time m_maxRtrSolicitationInterval
Maximum RS Retransmission interval.
Time m_contextValidLifeTime
Default Context Valid Lifetime.
std::list< SixLowPanRegisteredAddress > m_registeredAddresses
Addresses that have been registered.
void SendSixLowPanNaWithEaro(Ipv6Address src, Ipv6Address dst, Ipv6Address target, uint16_t time, const std::vector< uint8_t > &rovr, Ptr< NetDevice > sixDevice, uint8_t status)
Send a NA for 6LoWPAN ND (+ EARO).
std::map< Ptr< SixLowPanNetDevice >, Ptr< SixLowPanRaEntry > > m_raEntries
Router Advertisement entries (if the node is a 6LBR).
void HandleSixLowPanNS(Ptr< Packet > packet, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
NS handler for 6LoWPAN ND.
static constexpr uint16_t MIN_CONTEXT_CHANGE_DELAY
6LBR constant: minimum delay (in seconds) before a context change may be advertised after a previous ...
void SetRovr(const std::vector< uint8_t > rovr)
Sets the ROVR for the node.
Time m_pioValidLifeTime
Default Prefix Information Valid Lifetime.
SixLowPanNodeStatus_e m_nodeRole
Status of the node.
std::set< Ipv6Address > m_raCache
Set of 6LBR addresses from which a RA has already been processed.
static bool ParseAndValidateNaEaroPacket(Ptr< Packet > p, Icmpv6NA &naHdr, Icmpv6OptionLinkLayerAddress &tlla, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo, bool &hasEaro)
Parses NA packet and populates params, returning true if packet is valid.
std::list< SixLowPanPendingRa > m_pendingRas
RA awaiting processing (address registration).
void AddressRegistrationSuccess(Ipv6Address registrar)
Address registration success or failure.
static bool ParseAndValidateRsPacket(Ptr< Packet > p, Icmpv6RS &rsHdr, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionSixLowPanCapabilityIndication &cio)
Parses RS packet and populates params, returning true if packet is valid.
SixLowPanNodeStatus_e
Role of the node: 6LN, 6LR, 6LBR.
@ SixLowPanNodeOnly
a 6LN that can not become a 6LR
@ SixLowPanNode
a 6LN that can (and want to) become a 6LR
static constexpr uint8_t MULTIHOP_HOPLIMIT
Router constant: hop limit used for multihop DAR/DAC messages.
void SetInterfaceAs6lbr(Ptr< SixLowPanNetDevice > device)
Set an interface to be used as a 6LBR.
Callback< void, Ptr< Packet > > NaRxCallback
Trace sink signature for NA reception.
static constexpr uint8_t MIN_DELAY_BETWEEN_RAS
6LR constant: minimum delay (in seconds) between consecutive RAs.
bool IsBorderRouterOnInterface(Ptr< SixLowPanNetDevice > device) const
Checks if an interface is set as 6LBR.
Ptr< SixLowPanNdBindingTable > FindBindingTable(Ptr< Ipv6Interface > interface)
Find the binding table corresponding to the IPv6 interface.
uint16_t m_regTime
The amount of time (units of 60 seconds) that the router should retain the NCE for the node.
AddressPendingRegistration m_addrPendingReg
Address currently being Registered.
TracedCallback< Ipv6Address > m_multicastRsTrace
Trace fired whenever a multicast RS is sent.
EventId m_addressRegistrationEvent
Address Registration event.
void DoInitialize() override
Initialize() implementation.
RegStatus
6LoWPAN-ND EARO registration status codes
@ MOVED
Registration failed because it is not the most recent.
@ SIXLBR_REGISTRY_SATURATED
6LBR Registry is saturated.
@ NEIGHBOR_CACHE_FULL
Neighbor Cache Full.
@ DUPLICATE_SOURCE_ADDRESS
Address used as the source of the NS(EARO) conflicts with an existing registration.
@ VALIDATION_REQUEST
Registering Node is challenged for owning the Registered Address or for being an acceptable proxy for...
@ INVALID_SOURCE_ADDRESS
Address used as the source of the NS(EARO) is not a Link-Local Address.
@ VALIDATION_FAILED
The proof of ownership of the Registered Address is not correct.
@ REMOVED
Binding state was removed.
@ DUPLICATE_ADDRESS
Duplicate Address.
@ REGISTERED_ADDRESS_TOPOLOGICALLY_INCORRECT
Address being registered is not usable on this link.
bool Lookup(Ptr< Packet > p, const Ipv6Header &ipHeader, Ipv6Address dst, Ptr< NetDevice > device, Ptr< NdiscCache > cache, Address *hardwareDestination) override
Lookup in the ND cache for the IPv6 address (similar as ARP protocol).
void RemoveAdvertisedContext(Ptr< SixLowPanNetDevice > device, Ipv6Prefix context)
Remove a context to be advertised on an interface (6LBR).
static Ptr< Packet > MakeNsEaroPacket(Ipv6Address src, Ipv6Address dst, Icmpv6NS &nsHdr, Icmpv6OptionLinkLayerAddress &slla, Icmpv6OptionLinkLayerAddress &tlla, Icmpv6OptionSixLowPanExtendedAddressRegistration &earo)
Construct NS (EARO) packet.
void NotifyNewAggregate() override
This method is called by AggregateObject and completes the aggregation by setting the node in the ICM...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
BindingTableList m_bindingTableList
Binding Table for 6LoWPAN ND.
void HandleSixLowPanRS(Ptr< Packet > packet, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
RS handler for 6LoWPAN ND.
Ptr< RandomVariableStream > m_addressRegistrationJitter
Random jitter before sending address registrations.
Callback< void, Ipv6Address > MulticastRsCallback
Trace sink signature for multicast RS sends.
void AddressRegistrationTimeout()
Address registration timeout handler.
Callback< void, Ipv6Address, bool, uint8_t > AddressRegistrationCallback
Trace sink signature for address registration result.
~SixLowPanNdProtocol() override
Destructor.
std::vector< uint8_t > m_rovr
Node ROVR.
void HandleSixLowPanNA(Ptr< Packet > packet, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
NA handler for 6LoWPAN ND.
static TypeId GetTypeId()
Get the type ID.
void SetAdvertisedPrefix(Ptr< SixLowPanNetDevice > device, Ipv6Prefix prefix)
Set a prefix to be announced on an interface (6LBR).
uint16_t m_advance
How many seconds before registration expiry to begin re-registration.
void DoDispose() override
Dispose this object.
EventId m_addressRegistrationTimeoutEvent
Address Registration timeout event.
static constexpr uint8_t MAX_RA_DELAY_TIME
6LR constant: maximum delay (in seconds) before responding to an RS.
uint8_t m_addressRegistrationCounter
Number of retries of an address registration.
void CreateBindingTable(Ptr< NetDevice > device, Ptr< Ipv6Interface > interface)
Create and register a binding table for the given device and interface.
Time m_abroValidLifeTime
Default ABRO Valid Lifetime.
enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, const Ipv6Header &header, Ptr< Ipv6Interface > interface) override
Receive method.
6LoWPAN-ND test case for RA packet creation and parsing
Test successful registration of varying numbers of 6LNs with 1 6LBR.
6LoWPAN-ND test case for RS packet creation and parsing
Shim performing 6LoWPAN compression, decompression and fragmentation.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:50
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Struct holding data for the address currently being registered.
Icmpv6OptionLinkLayerAddress llaHdr
Link-Layer address option from the RA (can be 6LR or 6LBR).
bool isValid
The data are valid (for timeouts and retransmissions).
Icmpv6OptionPrefixInformation pioHdr
Prefix Information Option for the address being registered.
bool newRegistration
new registration (true) or re-registration (false)
Ptr< Ipv6Interface > interface
Interface on which the RA was received.
Ipv6Address addressPendingRegistration
Address being Registered.
Ipv6Address registrar
Registering node address (always link-local).
Struct holding data about a pending RA being processed.
std::list< std::pair< Ipv6Address, Icmpv6OptionPrefixInformation > > addressesToBeRegistered
Addresses pending registration with their PIOs.
Icmpv6OptionLinkLayerAddress llaHdr
Contains MAC address of the RA sender (6LBR).
Ptr< Ipv6Interface > interface
Interface that received the RA.
Ipv6Address source
Origin of the RA / Registering Node (will be a 6LBR).
Struct holding data about registered addresses.
Icmpv6OptionLinkLayerAddress llaHdr
Contains MAC address of the RA sender (6LBR).
Ipv6Address registrar
Registering node (link-local addr / gaddr of 6LBR).
Ptr< Ipv6Interface > interface
Interface used for the registration.
Icmpv6OptionPrefixInformation pioHdr
Prefix Information Option for the address being registered.