14#ifndef SIXLOWPAN_ND_PROTOCOL_H
15#define SIXLOWPAN_ND_PROTOCOL_H
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"
151 Address* hardwareDestination)
override;
160 void SetRovr(
const std::vector<uint8_t> rovr);
175 const std::vector<uint8_t>& rovr,
192 const std::vector<uint8_t>& rovr,
275 std::list<Icmpv6OptionSixLowPanContext> contextList,
276 std::list<Icmpv6OptionPrefixInformation> prefixList);
284 std::list<Ptr<SixLowPanNdPrefix>>
GetPrefixes()
const;
302 std::map<uint8_t, Ptr<SixLowPanNdContext>>
GetContexts()
const;
639 std::set<Ipv6Address>
669 std::list<std::pair<Ipv6Address, Icmpv6OptionPrefixInformation>>
689 std::list<SixLowPanRegisteredAddress>
713 std::list<Ptr<SixLowPanNdBindingTable>>;
821 std::list<Icmpv6OptionPrefixInformation>& pios,
825 std::list<Icmpv6OptionSixLowPanContext>& contexts);
a polymophic address class
An identifier for simulation events.
Icmpv6L4Protocol()
Constructor.
ICMPv6 Neighbor Advertisement header.
ICMPv6 Neighbor Solicitation header.
ICMPv6 link-layer address option.
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.
Describes an IPv6 address.
The IPv6 representation of a network interface.
Describes an IPv6 prefix.
Smart pointer class similar to boost::intrusive_ptr.
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.
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.
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).
friend class SixLowPanNdNsEaroPacketTest
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.
friend class SixLowPanNdRsPacketTest
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.
friend class SixLowPanNdNaEaroPacketTest
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
@ SixLowPanBorderRouter
a 6LBR
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.
friend class SixLowPanNdNsNaTest
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).
friend class SixLowPanNdRaPacketTest
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.
friend class SixLowPanNdRovrTest
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.
SixLowPanNdProtocol()
Constructor.
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.
Forward calls to a chain of Callback.
a unique identifier for an interface.
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).
Ipv6Address registeredAddr
Registered address.
Ptr< Ipv6Interface > interface
Interface used for the registration.
Icmpv6OptionPrefixInformation pioHdr
Prefix Information Option for the address being registered.
Time registrationTimeout
Registration expiration time.