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 <list>
27#include <map>
28#include <set>
29#include <utility>
30#include <vector>
31
32namespace ns3
33{
34
43
44/**
45 * @ingroup sixlowpan
46 * @brief An optimization of the ND protocol for 6LoWPANs.
47 */
49{
54 friend class SixLowPanNdNsNaTest;
55 friend class SixLowPanNdRovrTest;
56
57 public:
58 /**
59 * 6LoWPAN-ND EARO registration status codes
60 */
62 {
63 SUCCESS = 0x0, //!< Success
64 DUPLICATE_ADDRESS, //!< Duplicate Address
65 NEIGHBOR_CACHE_FULL, //!< Neighbor Cache Full
66 MOVED, //!< Registration failed because it is not the most recent
67 REMOVED, //!< Binding state was removed.
68 VALIDATION_REQUEST, //!< Registering Node is challenged for owning the Registered Address or
69 //!< for being an acceptable proxy for the registration.
70 DUPLICATE_SOURCE_ADDRESS, //!< Address used as the source of the NS(EARO) conflicts with an
71 //!< existing registration.
72 INVALID_SOURCE_ADDRESS, //!< Address used as the source of the NS(EARO) is not a Link-Local
73 //!< Address.
74 REGISTERED_ADDRESS_TOPOLOGICALLY_INCORRECT, //!< Address being registered is not usable on
75 //!< this link.
76 SIXLBR_REGISTRY_SATURATED, //!< 6LBR Registry is saturated.
77 VALIDATION_FAILED //!< The proof of ownership of the Registered Address is not correct.
78 };
79
80 /**
81 * @brief 6LBR constant: minimum delay (in seconds) before a context change may be
82 * advertised after a previous change. RFC 6775, Table 2.
83 */
84 static constexpr uint16_t MIN_CONTEXT_CHANGE_DELAY{300};
85
86 /**
87 * @brief 6LR constant: maximum number of initial RA transmissions. RFC 6775, Table 1.
88 * Currently unused; reserved for future 6LR role implementation.
89 */
90 static constexpr uint8_t MAX_RTR_ADVERTISEMENTS{3};
91
92 /**
93 * @brief 6LR constant: minimum delay (in seconds) between consecutive RAs. RFC 6775, Table 1.
94 * Currently unused; reserved for future 6LR role implementation.
95 */
96 static constexpr uint8_t MIN_DELAY_BETWEEN_RAS{10};
97
98 /**
99 * @brief 6LR constant: maximum delay (in seconds) before responding to an RS. RFC 6775,
100 * Table 1. Currently unused; reserved for future 6LR role implementation.
101 */
102 static constexpr uint8_t MAX_RA_DELAY_TIME{2};
103
104 /**
105 * @brief Router constant: hop limit used for multihop DAR/DAC messages. RFC 6775, Table 1.
106 */
107 static constexpr uint8_t MULTIHOP_HOPLIMIT{64};
108
109 /**
110 * @brief Constructor.
111 */
113
114 /**
115 * @brief Destructor.
116 */
117 ~SixLowPanNdProtocol() override;
118
119 /**
120 * @brief Get the type ID.
121 * @return The object TypeId.
122 */
123 static TypeId GetTypeId();
124
125 void DoInitialize() override;
126 void NotifyNewAggregate() override;
127
128 /**
129 * Assign a fixed random variable stream number to the random variables
130 * used by this model. Return the number of streams (possibly zero) that
131 * have been assigned.
132 *
133 * @param stream first stream index to use
134 * @return the number of stream indices assigned by this model
135 */
136 int64_t AssignStreams(int64_t stream);
137
139 const Ipv6Header& header,
140 Ptr<Ipv6Interface> interface) override;
141
142 /**
143 * @brief Create and register a binding table for the given device and interface.
144 * @param device the net device
145 * @param interface the IPv6 interface
146 */
148
149 bool Lookup(Ptr<Packet> p,
150 const Ipv6Header& ipHeader,
151 Ipv6Address dst,
152 Ptr<NetDevice> device,
153 Ptr<NdiscCache> cache,
154 Address* hardwareDestination) override;
155
156 void FunctionDadTimeout(Ipv6Interface* interface, Ipv6Address addr) override;
157
158 /**
159 * Sets the ROVR for the node.
160 *
161 * @param rovr ROVR to set for this node
162 */
163 void SetRovr(const std::vector<uint8_t> rovr);
164
165 /**
166 * @brief Send a NS for 6LoWPAN ND (+ EARO, SLLAO).
167 * @param addrToRegister source IPv6 address
168 * @param dst destination IPv6 address
169 * @param dstMac destination MAC address
170 * @param time registration lifetime (EARO)
171 * @param rovr ROVR (EARO)
172 * @param sixDevice SixLowPan NetDevice
173 */
174 void SendSixLowPanNsWithEaro(Ipv6Address addrToRegister,
175 Ipv6Address dst,
176 Address dstMac,
177 uint16_t time,
178 const std::vector<uint8_t>& rovr,
179 Ptr<NetDevice> sixDevice);
180
181 /**
182 * @brief Send a NA for 6LoWPAN ND (+ EARO).
183 * @param src source IPv6 address
184 * @param dst destination IPv6 address
185 * @param target target IPv6 address
186 * @param time registration lifetime (EARO)
187 * @param rovr ROVR (EARO)
188 * @param sixDevice SixLowPan NetDevice
189 * @param status status (EARO)
190 */
192 Ipv6Address dst,
193 Ipv6Address target,
194 uint16_t time,
195 const std::vector<uint8_t>& rovr,
196 Ptr<NetDevice> sixDevice,
197 uint8_t status);
198 /**
199 * @brief Send a Multicast RS (+ 6CIO) (RFC6775 5.3)
200 * @param src source IPv6 address
201 * @param hardwareAddress the hardware address of the node
202 */
203 void SendSixLowPanMulticastRS(Ipv6Address src, Address hardwareAddress);
204
205 /**
206 * @brief Send a RA for 6LoWPAN ND (+ PIO, 6CO, 6CIO, ABRO, SLLAO).
207 * @param src source IPv6 address
208 * @param dst destination IPv6 address
209 * @param interface the interface from which the packet will be sent
210 */
212
213 /**
214 * @brief Set an interface to be used as a 6LBR
215 * @param device device to be used for announcement
216 */
218
219 /**
220 * @brief Set a prefix to be announced on an interface (6LBR)
221 * @param device device to be used for announcement
222 * @param prefix announced prefix
223 */
225
226 /**
227 * @brief Add a context to be advertised on an interface (6LBR)
228 * @param device device to be used for advertisement
229 * @param context advertised context
230 */
232
233 /**
234 * @brief Remove a context to be advertised on an interface (6LBR)
235 * @param device device to be used for advertisement
236 * @param context advertised context
237 */
239
240 /**
241 * @brief Checks if an interface is set as 6LBR
242 * @param device the interface to check
243 * @return true if the interface is configured as a 6LBR
244 */
246
247 /**
248 * @brief Find the binding table corresponding to the IPv6 interface.
249 * @param interface the IPv6 interface
250 * @return the SixLowPanNdBindingTable associated with the interface
251 */
253
254 protected:
255 /**
256 * @brief Dispose this object.
257 */
258 void DoDispose() override;
259
260 private:
261 /**
262 * @brief RA advertised from routers for 6LoWPAN ND.
263 */
264 class SixLowPanRaEntry : public SimpleRefCount<SixLowPanRaEntry>
265 {
266 public:
268
269 /**
270 * Creates a RA entry from the RA header contents
271 * @param raHeader the RA header
272 * @param abroHdr the ABRO header
273 * @param contextList the list of Contexts
274 * @param prefixList the list of PIOs
275 */
276 SixLowPanRaEntry(Icmpv6RA raHeader,
278 std::list<Icmpv6OptionSixLowPanContext> contextList,
279 std::list<Icmpv6OptionPrefixInformation> prefixList);
280
282
283 /**
284 * @brief Get the prefixes advertised for this interface.
285 * @return a list of IPv6 prefixes
286 */
287 std::list<Ptr<SixLowPanNdPrefix>> GetPrefixes() const;
288
289 /**
290 * @brief Add a prefix to advertise on interface.
291 * @param prefix prefix to advertise
292 */
294
295 /**
296 * @brief Remove a prefix from the ones advertised on interface.
297 * @param prefix prefix to remove from advertisements
298 */
300
301 /**
302 * @brief Get list of 6LoWPAN contexts advertised for this interface.
303 * @return list of 6LoWPAN contexts
304 */
305 std::map<uint8_t, Ptr<SixLowPanNdContext>> GetContexts() const;
306
307 /**
308 * @brief Add a 6LoWPAN context to advertise on interface.
309 * @param context 6LoWPAN context to advertise
310 */
312
313 /**
314 * @brief Remove a 6LoWPAN context.
315 * @param context 6LoWPAN context to remove
316 */
318
319 /**
320 * Builds an Icmpv6RA from the stored data.
321 * @return the Icmpv6RA.
322 */
324
325 /**
326 * Builds a container of Icmpv6OptionPrefixInformation from the stored data.
327 * @return the Icmpv6OptionPrefixInformation container.
328 */
329 std::list<Icmpv6OptionPrefixInformation> BuildPrefixInformationOptions();
330
331 /**
332 * @brief Is managed flag enabled ?
333 * @return managed flag
334 */
335 bool IsManagedFlag() const;
336
337 /**
338 * @brief Set managed flag
339 * @param managedFlag value
340 */
341 void SetManagedFlag(bool managedFlag);
342
343 /**
344 * @brief Is "other config" flag enabled ?
345 * @return other config flag
346 */
347 bool IsOtherConfigFlag() const;
348
349 /**
350 * @brief Is "home agent" flag enabled ?
351 * @return "home agent" flag
352 */
353 bool IsHomeAgentFlag() const;
354
355 /**
356 * @brief Set "home agent" flag.
357 * @param homeAgentFlag value
358 */
359 void SetHomeAgentFlag(bool homeAgentFlag);
360
361 /**
362 * @brief Set "other config" flag
363 * @param otherConfigFlag value
364 */
365 void SetOtherConfigFlag(bool otherConfigFlag);
366
367 /**
368 * @brief Get reachable time.
369 * @return reachable time
370 */
372
373 /**
374 * @brief Set reachable time.
375 * @param time reachable time
376 */
377 void SetReachableTime(uint32_t time);
378
379 /**
380 * @brief Get router lifetime.
381 * @return router lifetime
382 */
384
385 /**
386 * @brief Set router lifetime.
387 * @param time router lifetime
388 */
389 void SetRouterLifeTime(uint32_t time);
390
391 /**
392 * @brief Get retransmission timer.
393 * @return retransmission timer
394 */
396
397 /**
398 * @brief Set retransmission timer.
399 * @param timer retransmission timer
400 */
401 void SetRetransTimer(uint32_t timer);
402
403 /**
404 * @brief Get current hop limit.
405 * @return current hop limit for the link
406 */
407 uint8_t GetCurHopLimit() const;
408
409 /**
410 * @brief Set current hop limit.
411 * @param curHopLimit current hop limit for the link
412 */
413 void SetCurHopLimit(uint8_t curHopLimit);
414
415 /**
416 * @brief Get version value (ABRO).
417 * @return the version value
418 */
419 uint32_t GetAbroVersion() const;
420
421 /**
422 * @brief Set version value (ABRO).
423 * @param version the version value
424 */
425 void SetAbroVersion(uint32_t version);
426
427 /**
428 * @brief Get valid lifetime value (ABRO).
429 * @return the valid lifetime (units of 60 seconds)
430 */
431 uint16_t GetAbroValidLifeTime() const;
432
433 /**
434 * @brief Set valid lifetime value (ABRO).
435 * @param time the valid lifetime (units of 60 seconds)
436 */
437 void SetAbroValidLifeTime(uint16_t time);
438
439 /**
440 * @brief Get Border Router address (ABRO).
441 * @return the Border Router address
442 */
444
445 /**
446 * @brief Set Border Router address (ABRO).
447 * @param border the Border Router address
448 */
450
451 /**
452 * @brief Parse an ABRO and records the appropriate params.
453 * @param abro the Authoritative Border Router Option header
454 * @return true if the parsing was correct.
455 */
457
458 /**
459 * @brief Build an ABRO header.
460 * @return the Authoritative Border Router Option header
461 */
463
464 private:
465 /**
466 * @brief Advertised Prefixes.
467 */
468 std::list<Ptr<SixLowPanNdPrefix>> m_prefixes;
469
470 /**
471 * @brief List of 6LoWPAN contexts advertised.
472 */
473 std::map<uint8_t, Ptr<SixLowPanNdContext>> m_contexts;
474
475 /**
476 * @brief Managed flag. If true, the host uses the stateful protocol for address
477 * autoconfiguration.
478 */
480
481 /**
482 * @brief Other configuration flag. If true, the host uses the stateful protocol for other
483 * (non-address) information.
484 */
486
487 /**
488 * @brief Flag to add HA (home agent) flag in RA.
489 */
491
492 /**
493 * @brief Reachable time in milliseconds.
494 */
496
497 /**
498 * @brief Retransmission timer in milliseconds.
499 */
501
502 /**
503 * @brief Current hop limit (TTL).
504 */
506
507 /**
508 * @brief Router life time in seconds.
509 */
511
512 /**
513 * @brief Version value for ABRO.
514 */
516
517 /**
518 * @brief Valid lifetime value for ABRO (units of 60 seconds).
519 */
521
522 /**
523 * @brief Border Router address for ABRO.
524 */
526 };
527
528 /**
529 * Role of the node: 6LN, 6LR, 6LBR
530 *
531 * A Node starts either as a 6LN or as a 6LBR.
532 * A 6LN can become a 6LR.
533 *
534 */
536 {
537 SixLowPanNodeOnly, //!< a 6LN that can not become a 6LR
538 SixLowPanNode, //!< a 6LN that can (and want to) become a 6LR
540 };
541
542 /**
543 * @brief The amount of time (units of 60 seconds) that the router should retain the NCE for the
544 * node.
545 */
546 uint16_t m_regTime;
547
548 /**
549 * @brief How many seconds before registration expiry to begin re-registration.
550 */
551 uint16_t m_advance;
552
553 /**
554 * @brief Status of the node.
555 */
557
558 Time m_routerLifeTime; //!< Default Router Lifetime.
559 Time m_pioPreferredLifeTime; //!< Default Prefix Information Preferred Lifetime.
560 Time m_pioValidLifeTime; //!< Default Prefix Information Valid Lifetime.
561 Time m_contextValidLifeTime; //!< Default Context Valid Lifetime.
562 Time m_abroValidLifeTime; //!< Default ABRO Valid Lifetime.
563
564 /**
565 * @brief Random jitter before sending address registrations.
566 */
568
569 /**
570 * @brief NS handler for 6LoWPAN ND.
571 * @param packet the packet.
572 * @param src source address.
573 * @param dst destination address.
574 * @param interface the interface from which the packet is coming.
575 */
576 void HandleSixLowPanNS(Ptr<Packet> packet,
577 const Ipv6Address& src,
578 const Ipv6Address& dst,
579 Ptr<Ipv6Interface> interface);
580
581 /**
582 * @brief NA handler for 6LoWPAN ND.
583 * @param packet the packet
584 * @param src source address
585 * @param dst destination address
586 * @param interface the interface from which the packet is coming
587 */
588 void HandleSixLowPanNA(Ptr<Packet> packet,
589 const Ipv6Address& src,
590 const Ipv6Address& dst,
591 Ptr<Ipv6Interface> interface);
592
593 /**
594 * @brief RS handler for 6LoWPAN ND.
595 * @param packet the packet
596 * @param src source address
597 * @param dst destination address
598 * @param interface the interface from which the packet is coming
599 */
600 void HandleSixLowPanRS(Ptr<Packet> packet,
601 const Ipv6Address& src,
602 const Ipv6Address& dst,
603 Ptr<Ipv6Interface> interface);
604
605 /**
606 * @brief RA handler for 6LoWPAN ND.
607 * @param packet the packet
608 * @param src source address
609 * @param dst destination address
610 * @param interface the interface from which the packet is coming
611 */
612 void HandleSixLowPanRA(Ptr<Packet> packet,
613 const Ipv6Address& src,
614 const Ipv6Address& dst,
615 Ptr<Ipv6Interface> interface);
616
617 /**
618 * Address registration procedure
619 */
620 void AddressRegistration();
621
622 /**
623 * Address registration success or failure.
624 *
625 * @param registrar node that performs the registration. Registered Node or a proxy.
626 */
628
629 /**
630 * Address registration timeout handler
631 */
633
634 uint8_t m_addressRegistrationCounter = 0; //!< Number of retries of an address registration.
635
636 std::vector<uint8_t> m_rovr; //!< Node ROVR
637
638 EventId m_addressRegistrationTimeoutEvent; //!< Address Registration timeout event.
639
640 EventId m_addressRegistrationEvent; //!< Address Registration event.
641
642 std::set<Ipv6Address>
643 m_raCache; //!< Set of 6LBR addresses from which a RA has already been processed.
644
645 std::map<Ptr<SixLowPanNetDevice>, Ptr<SixLowPanRaEntry>>
646 m_raEntries; //!< Router Advertisement entries (if the node is a 6LBR).
647
649 m_addressRegistrationResultTrace; //!< Traces address registration result (address,
650 //!< success/failure, status code)
651
653 AddressRegistrationCallback; //!< Trace sink signature for address registration result
654
655 TracedCallback<Ipv6Address> m_multicastRsTrace; //!< Trace fired whenever a multicast RS is sent
656
658 MulticastRsCallback; //!< Trace sink signature for multicast RS sends
659
660 TracedCallback<Ptr<Packet>> m_naRxTrace; //!< Trace fired whenever an NA packet is received
661
662 typedef Callback<void, Ptr<Packet>> NaRxCallback; //!< Trace sink signature for NA reception
663
664 /**
665 * Struct holding data about a pending RA being processed.
666 */
668 {
669 Ipv6Address source; //!< Origin of the RA / Registering Node (will be a 6LBR)
670 Icmpv6OptionLinkLayerAddress llaHdr; //!< Contains MAC address of the RA sender (6LBR)
671 Ptr<Ipv6Interface> interface; //!< Interface that received the RA
672 std::list<std::pair<Ipv6Address, Icmpv6OptionPrefixInformation>>
673 addressesToBeRegistered; //!< Addresses pending registration with their PIOs.
674 };
675
676 std::list<SixLowPanPendingRa> m_pendingRas; //!< RA awaiting processing (address registration).
677
678 /**
679 * Struct holding data about registered addresses.
680 */
682 {
683 Ipv6Address registrar; //!< Registering node (link-local addr / gaddr of 6LBR)
684 Time registrationTimeout; //!< Registration expiration time
685 Ipv6Address registeredAddr; //!< Registered address
686 Icmpv6OptionLinkLayerAddress llaHdr; //!< Contains MAC address of the RA sender (6LBR)
687 Ptr<Ipv6Interface> interface; //!< Interface used for the registration
689 pioHdr; //!< Prefix Information Option for the address being registered
690 };
691
692 std::list<SixLowPanRegisteredAddress>
693 m_registeredAddresses; //!< Addresses that have been registered.
694
695 /**
696 * Struct holding data for the address currently being registered.
697 */
699 {
700 bool isValid; //!< The data are valid (for timeouts and retransmissions)
701 Ipv6Address addressPendingRegistration; //!< Address being Registered
702 Ipv6Address registrar; //!< Registering node address (always link-local)
703 bool newRegistration; //!< new registration (true) or re-registration (false)
705 llaHdr; //!< Link-Layer address option from the RA (can be 6LR or 6LBR).
706 Ptr<Ipv6Interface> interface; //!< Interface on which the RA was received
708 pioHdr; //!< Prefix Information Option for the address being registered
709 };
710
711 AddressPendingRegistration m_addrPendingReg; //!< Address currently being Registered
712
713 Time m_maxRtrSolicitationInterval; //!< Maximum RS Retransmission interval
714
716 std::list<Ptr<SixLowPanNdBindingTable>>; //!< container of BindingTables
717
718 BindingTableList m_bindingTableList; //!< Binding Table for 6LoWPAN ND
719
720 /**
721 * @brief Construct NS (EARO) packet.
722 * @param src source address
723 * @param dst destination address
724 * @param nsHdr
725 * @param slla
726 * @param tlla
727 * @param earo
728 * @return NS (EARO) Packet
729 */
731 Ipv6Address dst,
732 Icmpv6NS& nsHdr,
736
737 /**
738 * @brief Construct NA (EARO) packet.
739 * @param src source address
740 * @param dst destination address
741 * @param naHdr
742 * @param earo
743 * @return NA (EARO) Packet
744 */
746 Ipv6Address dst,
747 Icmpv6NA& naHdr,
749
750 /**
751 * @brief Constructs a RA packet (raEntry contains info for raHdr, pios, abro and contexts)
752 * @param src source address
753 * @param dst destination address
754 * @param slla Source Link-Layer Address Option
755 * @param cio Capability Indication Option
756 * @param raEntry RA entry containing router advertisement information
757 * @return RA Packet
758 */
760 Ipv6Address dst,
763 Ptr<SixLowPanRaEntry> raEntry);
764
765 /**
766 * @brief Parses NS packet and populates params, returning true if packet is a valid NS/NS(EARO)
767 * packet
768 * @param p Packet to be parsed
769 * @param nsHdr populated with packet nsHdr
770 * @param slla populated with packet SLLAO if present
771 * @param tlla populated with packet TLLAO if present
772 * @param earo populated with packet EARO if present
773 * @param hasEaro true if NS packet contains an EARO option
774 * @return True if packet is valid, false otherwise
775 */
777 Icmpv6NS& nsHdr,
781 bool& hasEaro);
782
783 /**
784 * @brief Parses NA packet and populates params, returning true if packet is valid
785 * @param p Packet to be parsed
786 * @param naHdr populated with packet NA header
787 * @param tlla populated with packet Target Link-Layer Address Option if present
788 * @param earo populated with packet EARO if present
789 * @param hasEaro true if NA packet contains an EARO option
790 * @return True if packet is valid, false otherwise
791 */
793 Icmpv6NA& naHdr,
796 bool& hasEaro);
797
798 /**
799 * @brief Parses RS packet and populates params, returning true if packet is valid
800 * @param p Packet to be parsed
801 * @param rsHdr populated with packet RS header
802 * @param slla populated with packet Source Link-Layer Address Option if present
803 * @param cio populated with packet Capability Indication Option if present
804 * @return True if packet is valid, false otherwise
805 */
807 Icmpv6RS& rsHdr,
810
811 /**
812 * @brief Parses RA packet and populates params, returning true if packet is valid
813 * @param p Packet to be parsed
814 * @param raHdr populated with packet RA header
815 * @param pios populated with Prefix Information Options from the packet
816 * @param abro populated with Authoritative Border Router Option from the packet
817 * @param slla populated with Source Link-Layer Address Option if present
818 * @param cio populated with Capability Indication Option if present
819 * @param contexts populated with 6LoWPAN Context Options from the packet
820 * @return True if packet is valid, false otherwise
821 */
823 Icmpv6RA& raHdr,
824 std::list<Icmpv6OptionPrefixInformation>& pios,
828 std::list<Icmpv6OptionSixLowPanContext>& contexts);
829};
830
831} /* namespace ns3 */
832
833#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.