22#include "ns3/assert.h"
23#include "ns3/boolean.h"
24#include "ns3/integer.h"
25#include "ns3/ipv6-interface.h"
26#include "ns3/ipv6-l3-protocol.h"
27#include "ns3/ipv6-route.h"
28#include "ns3/ipv6-routing-protocol.h"
30#include "ns3/mac16-address.h"
31#include "ns3/mac48-address.h"
32#include "ns3/mac64-address.h"
33#include "ns3/ndisc-cache.h"
35#include "ns3/nstime.h"
36#include "ns3/packet.h"
37#include "ns3/pointer.h"
39#include "ns3/string.h"
40#include "ns3/uinteger.h"
70 TypeId(
"ns3::SixLowPanNdProtocol")
72 .SetGroupName(
"Internet")
74 .AddAttribute(
"AddressRegistrationJitter",
75 "The jitter in ms a node is allowed to wait before sending any address "
76 "registration. Some jitter aims to prevent collisions. By default, the "
77 "model will wait for a duration in ms defined by a uniform "
78 "random variable between 0 and AddressRegistrationJitter",
79 StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=10.0]"),
82 .AddAttribute(
"RegistrationLifeTime",
83 "The amount of time (units of 60 seconds) that the router should retain "
84 "the NCE for the node.",
88 .AddAttribute(
"AdvanceTime",
89 "How many seconds before registration expiry to begin re-registration.",
93 .AddAttribute(
"DefaultRouterLifeTime",
94 "The default router lifetime.",
98 .AddAttribute(
"DefaultPrefixInformationPreferredLifeTime",
99 "The default Prefix Information preferred lifetime.",
103 .AddAttribute(
"DefaultPrefixInformationValidLifeTime",
104 "The default Prefix Information valid lifetime.",
108 .AddAttribute(
"DefaultContextValidLifeTime",
109 "The default Context valid lifetime.",
113 .AddAttribute(
"DefaultAbroValidLifeTime",
114 "The default ABRO Valid lifetime.",
118 .AddAttribute(
"MaxRtrSolicitationInterval",
119 "Maximum Time between two RS (after the backoff).",
124 "AddressRegistrationResult",
125 "Trace fired when an address registration succeeds or fails",
127 "ns3::SixLowPanNdProtocol::AddressRegistrationCallback")
128 .AddTraceSource(
"MulticastRS",
129 "Trace fired when a multicast RS is sent",
131 "ns3::SixLowPanNdProtocol::MulticastRsCallback")
132 .AddTraceSource(
"NaRx",
133 "Trace fired when a NA packet is received",
135 "ns3::SixLowPanNdProtocol::NaRxCallback");
189 const std::vector<uint8_t>& rovr,
192 NS_LOG_FUNCTION(
this << addrToRegister << dst << dstMac << time << rovr << sixLowPanNetDevice);
195 "Destination address must not be a multicast address in EARO messages.");
208 ipv6->GetAddress(ipv6->GetInterfaceForDevice(sixLowPanNetDevice), 0).GetAddress();
232 const std::vector<uint8_t>& rovr,
236 NS_LOG_FUNCTION(
this << src << dst << target << time << rovr << sixLowPanNetDevice << status);
270 if (ipv6->GetInterfaceForAddress(src) == -1)
272 NS_LOG_LOGIC(
"Preventing RS from being sent or rescheduled because the source address "
273 << src <<
" has been removed");
277 NS_LOG_LOGIC(
"Send RS (from " << src <<
" to AllRouters multicast address)");
326 "6LBR not configured on the interface");
357 interface->Send(p, ipHeader, dst);
369 packet->CopyData(&type,
sizeof(type));
412 if (!sixLowPanNetDevice)
427 NS_LOG_LOGIC(
"Discarding a NS from unspecified source address");
433 NS_LOG_LOGIC(
"Discarding a NS sent to a multicast destination");
443 bool hasEaro =
false;
461 NS_ASSERT_MSG(bindingTable,
"Can not find a SixLowPanNdBindingTable");
467 auto btEntry = bindingTable->Lookup(target);
468 if (btEntry && btEntry->IsReachable() && btEntry->GetRovr() != earoHdr.
GetRovr())
484 btEntry = bindingTable->Add(target);
485 btEntry->SetRovr(earoHdr.
GetRovr());
493 ncEntry = cache->Add(target);
504 ipv6l3Protocol->GetRoutingProtocol()->NotifyAddRoute(
508 ipv6l3Protocol->GetInterfaceForDevice(interface->GetDevice()));
543 bool hasEaro =
false;
566 NS_LOG_LOGIC(
"NA EARO: target does not match pending registration, discarding");
573 registrationSucceeded,
575 if (!registrationSucceeded)
593 if (!sixLowPanNetDevice)
595 HandleRS(packet, src, dst, interface);
602 NS_LOG_LOGIC(
"Discarding an RS because this node is not a router");
626 auto ncEntry = neighbourCache->Lookup(src);
629 ncEntry = neighbourCache->Add(src);
630 ncEntry->SetRouter(
false);
632 if (ncEntry->GetMacAddress() != slla.
GetAddress())
638 SendSixLowPanRA(interface->GetLinkLocalAddress().GetAddress(), src, interface);
651 if (!sixLowPanNetDevice)
653 HandleRA(packet, src, dst, interface);
676 std::list<Icmpv6OptionPrefixInformation> pios;
677 std::list<Icmpv6OptionSixLowPanContext> contexts;
701 for (
const auto& pio : pios)
748 table->SetDevice(device, interface,
this);
761 if (table->GetDevice() == device)
801 m_pendingRas.front().addressesToBeRegistered.front().first;
833 for (
uint32_t i = 0; i < ipv6->GetNInterfaces(); ++i)
848 iface->GetDevice()->GetAddress());
879 "AddressRegistrationSuccess, mismatch between sender and expected sender "
902 "AddressRegistrationSuccess, expected to register an address from the "
903 "pending RA list, but it's empty");
906 "AddressRegistrationSuccess, expected to register an address from the pending RA list "
907 <<
"but the pending registration address list is empty");
919 m_pendingRas.front().addressesToBeRegistered.pop_front();
920 if (
m_pendingRas.front().addressesToBeRegistered.empty())
938 ipv6->AddAutoconfiguredAddress(
940 prefixHdr.GetPrefix(),
941 prefixHdr.GetPrefixLength(),
942 prefixHdr.GetFlags(),
943 prefixHdr.GetValidTime(),
944 prefixHdr.GetPreferredTime(),
963 "Address Registration Timeout but there is no valid address pending registration. "
964 <<
"Node ID=" <<
m_node->GetId());
972 NS_LOG_INFO(
"Address registration failed for node "
999 newRa->SetManagedFlag(
false);
1000 newRa->SetHomeAgentFlag(
false);
1001 newRa->SetOtherConfigFlag(
false);
1002 newRa->SetCurHopLimit(0);
1003 newRa->SetRetransTimer(0);
1005 newRa->SetReachableTime(0);
1008 if (routerLifetime > 0xffff)
1010 routerLifetime = 0xffff;
1013 newRa->SetRouterLifeTime(routerLifetime);
1016 int32_t interfaceId = ipv6->GetInterfaceForDevice(device);
1018 for (
uint32_t i = 0; i < ipv6->GetNAddresses(interfaceId); ++i)
1022 borderAddress = ipv6->GetAddress(interfaceId, i).GetAddress();
1028 "Can not set a 6LBR because I can't find a global address associated with the interface");
1029 newRa->SetAbroBorderRouterAddress(borderAddress);
1030 newRa->SetAbroVersion(0x66);
1043 NS_LOG_LOGIC(
"Not adding a prefix to an unconfigured interface");
1062 NS_LOG_LOGIC(
"Not adding a context to an unconfigured interface");
1065 auto contextMap =
m_raEntries[device]->GetContexts();
1067 bool found = std::any_of(contextMap.begin(), contextMap.end(), [&context](
const auto& entry) {
1068 return entry.second->GetContextPrefix() == context;
1072 NS_LOG_WARN(
"Not adding an already existing context - remove the old one first "
1078 for (unusedCid = 0; unusedCid < 16; ++unusedCid)
1080 if (contextMap.count(unusedCid) == 0)
1100 NS_LOG_LOGIC(
"Not removing a context from an unconfigured interface");
1104 auto contextMap =
m_raEntries[device]->GetContexts();
1106 for (
const auto& [cid, ctx] : contextMap)
1108 if (ctx->GetContextPrefix() == context)
1114 NS_LOG_WARN(
"Not removing a non-existing context " << context);
1139 std::list<Icmpv6OptionSixLowPanContext> contextList,
1140 std::list<Icmpv6OptionPrefixInformation> prefixList)
1153 for (
const auto& ctxOpt : contextList)
1156 context->SetCid(ctxOpt.GetCid());
1157 context->SetFlagC(ctxOpt.IsFlagC());
1158 context->SetValidTime(
Minutes(ctxOpt.GetValidTime()));
1159 context->SetContextPrefix(ctxOpt.GetContextPrefix());
1165 for (
const auto& pfxOpt : prefixList)
1168 prefix->SetPrefix(pfxOpt.GetPrefix());
1169 prefix->SetPrefixLength(pfxOpt.GetPrefixLength());
1170 prefix->SetPreferredLifeTime(
Seconds(pfxOpt.GetPreferredTime()));
1171 prefix->SetValidLifeTime(
Seconds(pfxOpt.GetValidTime()));
1189 if (pfx->GetPrefix() == prefix->GetPrefix())
1191 NS_LOG_WARN(
"Ignoring an already-existing prefix: " << prefix->GetPrefix());
1206 if ((*it)->GetPrefix() == prefix->GetPrefix())
1214std::list<Ptr<SixLowPanNdPrefix>>
1225 m_contexts.emplace(context->GetCid(), context);
1236std::map<uint8_t, Ptr<SixLowPanNdContext>>
1260std::list<Icmpv6OptionPrefixInformation>
1264 std::list<Icmpv6OptionPrefixInformation> prefixHdrs;
1271 prefixHdr.
SetValidTime(pfx->GetValidLifeTime().GetSeconds());
1274 prefixHdrs.push_back(prefixHdr);
1466 p->AddHeader(nsHdr);
1484 p->AddHeader(naHdr);
1500 Icmpv6RA ra = raEntry->BuildRouterAdvertisementHeader();
1503 for (
const auto& pio : raEntry->BuildPrefixInformationOptions())
1509 p->AddHeader(raEntry->MakeAbro());
1518 for (
const auto& [cid, ctx] : raEntry->GetContexts())
1523 sixHdr.
SetCid(ctx->GetCid());
1526 double updatedValidTime =
1531 if (updatedValidTime > 1)
1534 p->AddHeader(sixHdr);
1555 p->RemoveHeader(nsHdr);
1556 bool hasSllao =
false;
1557 bool hasTllao =
false;
1561 while (next && p->GetSize() > 0)
1564 p->CopyData(&type,
sizeof(type));
1571 p->RemoveHeader(slla);
1578 p->RemoveHeader(tlla);
1585 p->RemoveHeader(earo);
1593 if (p->GetSize() == 0)
1602 if (!(hasSllao && hasTllao))
1606 "NS(EARO) message MUST have both source and target link layer options. Ignoring.");
1611 NS_LOG_LOGIC(
"Discarding NS(EARO) with different target and source addresses: TLLAO ("
1629 p->RemoveHeader(naHdr);
1634 while (next && p->GetSize() > 0)
1637 p->CopyData(&type,
sizeof(type));
1642 p->RemoveHeader(tlla);
1645 p->RemoveHeader(earo);
1652 if (p->GetSize() == 0)
1668 p->RemoveHeader(rsHdr);
1669 bool hasSlla =
false;
1670 bool hasCio =
false;
1673 while (next && p->GetSize() > 0)
1676 p->CopyData(&type,
sizeof(type));
1681 p->RemoveHeader(slla);
1685 p->RemoveHeader(cio);
1692 if (p->GetSize() == 0)
1700 NS_LOG_LOGIC(
"RS message MUST have source link-layer option, discarding it.");
1706 NS_LOG_LOGIC(
"RS message MUST have sixlowpan capability indication option, discarding it.");
1716 std::list<Icmpv6OptionPrefixInformation>& pios,
1720 std::list<Icmpv6OptionSixLowPanContext>& contexts)
1724 p->RemoveHeader(raHdr);
1726 bool hasAbro =
false;
1727 bool hasSlla =
false;
1728 bool hasCio =
false;
1731 while (next && p->GetSize() > 0)
1734 p->CopyData(&type,
sizeof(type));
1742 p->RemoveHeader(prefix);
1743 pios.push_back(prefix);
1746 p->RemoveHeader(context);
1747 contexts.push_back(context);
1750 p->RemoveHeader(abro);
1756 p->RemoveHeader(slla);
1760 p->RemoveHeader(cio);
1768 if (p->GetSize() == 0)
1783 NS_LOG_LOGIC(
"Ignoring RA: ABRO border router address is unspecified");
a polymophic address class
void ReceiveLLA(Icmpv6OptionLinkLayerAddress lla, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
Link layer address option processing.
IpL4Protocol::RxStatus Receive(Ptr< Packet > p, const Ipv4Header &header, Ptr< Ipv4Interface > interface) override
Receive method.
void DoDispose() override
Dispose this object.
uint32_t m_rsMaxRetransmissionCount
Maximum number of multicast RS retransmissions [RFC 7559].
void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb) override
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
uint32_t m_rsRetransmissionCount
Multicast RS retransmissions counter [RFC 7559].
void DelayedSendMessage(Ptr< Packet > packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl)
Helper function used during delayed solicitation.
Ptr< Node > GetNode()
Get the node.
Ptr< UniformRandomVariable > m_rsRetransmissionJitter
Random jitter for RS retransmissions.
void HandleRA(Ptr< Packet > p, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
Receive Router Advertisement method.
void HandleRS(Ptr< Packet > p, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
Receive Router Solicitation method.
uint8_t m_maxUnicastSolicit
Neighbor Discovery node constants: max unicast solicitations.
Ptr< Node > m_node
The node.
IpL4Protocol::DownTargetCallback6 m_downTarget
callback to Ipv6::Send
Ptr< NdiscCache > FindCache(Ptr< NetDevice > device)
Get the cache corresponding to the device.
static const uint8_t PROT_NUMBER
ICMPv6 protocol number (58).
Time m_retransmissionTime
Neighbor Discovery node constants: retransmission timer.
void HandleNS(Ptr< Packet > p, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
Receive Neighbor Solicitation method.
virtual bool Lookup(Ipv6Address dst, Ptr< NetDevice > device, Ptr< NdiscCache > cache, Address *hardwareDestination)
Lookup in the ND cache for the IPv6 address.
EventId m_handleRsTimeoutEvent
RS timeout handler event.
void SendMessage(Ptr< Packet > packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl)
Send a packet via ICMPv6, note that packet already contains ICMPv6 header.
Icmpv6L4Protocol()
Constructor.
Time GetReachableTime() const
Neighbor Discovery node constants: reachable time.
void SetNode(Ptr< Node > node)
Set the node.
void HandleNA(Ptr< Packet > p, const Ipv6Address &src, const Ipv6Address &dst, Ptr< Ipv6Interface > interface)
Receive Neighbor Advertisement method.
ICMPv6 Neighbor Advertisement header.
void SetFlagS(bool s)
Set the S flag.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
void SetFlagR(bool r)
Set the R flag.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
uint32_t GetSerializedSize() const override
Get the serialized size.
void SetFlagO(bool o)
Set the O flag.
ICMPv6 Neighbor Solicitation header.
uint32_t GetSerializedSize() const override
Get the serialized size.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
ICMPv6 link-layer address option.
Address GetAddress() const
Get the hardware address.
ICMPv6 Authoritative Border Router Option header (see RFC 8505).
void SetValidLifeTime(uint16_t time)
Set the valid lifetime field.
uint32_t GetVersion() const
Get the version field.
void SetVersion(uint32_t version)
Set the version field.
uint16_t GetValidLifeTime() const
Get the valid lifetime field.
void SetRouterAddress(Ipv6Address router)
Set the 6LBR address field.
Ipv6Address GetRouterAddress() const
Get the 6LBR address field.
6LoWPAN Capability Indication Option - see RFC 7400.
void SetOption(SixLowPanCapability_e option)
Set an option.
@ B
The node is a 6LBR (see RFC 8505).
@ E
The node is an IPv6 ND Registrar (see RFC 8505).
ICMPv6 SixLowPan Context Option header (see RFC 8505).
void SetFlagC(bool c)
Set the C flag.
void SetContextPrefix(Ipv6Prefix prefix)
Set the context prefix field.
void SetValidTime(uint16_t time)
Set the valid lifetime field.
void SetCid(uint8_t cid)
Set the context identifier field.
ICMPv6 Extended Address Registration Option header RFC 8505.
uint8_t GetStatus() const
Get the status field.
std::vector< uint8_t > GetRovr() const
Get the ROVR field.
uint16_t GetRegTime() const
Get the registration lifetime field.
ICMPv6 Router Advertisement header.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
uint32_t GetRetransmissionTime() const
Get the node Retransmission time (Neighbor Discovery).
void SetFlagH(bool h)
Set the H flag.
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
void SetFlagO(bool o)
Set the O flag.
void SetFlagM(bool m)
Set the M flag.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
uint32_t GetSerializedSize() const override
Get the serialized size.
uint16_t GetLifeTime() const
Get the node Life time (Neighbor Discovery).
uint32_t GetReachableTime() const
Get the node Reachable time (Neighbor Discovery).
uint8_t GetCurHopLimit() const
Get the IPv6 maximum number of jumps.
bool GetFlagO() const
Get the O flag.
bool GetFlagM() const
Get the M flag.
bool GetFlagH() const
Get the H flag.
ICMPv6 Router Solicitation header.
uint32_t GetSerializedSize() const override
Get the serialized size.
Describes an IPv6 address.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
static Ipv6Address MakeAutoconfiguredAddress(Address addr, Ipv6Address prefix)
Make the autoconfigured IPv6 address from a Mac address.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
static Ipv6Address GetAllRoutersMulticast()
Get the "all routers multicast" address.
virtual void Send(Ptr< Packet > packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr< Ipv6Route > route)=0
Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers.
IPv6 address associated with an interface.
Ipv6Address GetAddress() const
Get the IPv6 address.
@ GLOBAL
Global address (2000::/3).
The IPv6 representation of a network interface.
IPv6 layer implementation.
static constexpr uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
Describes an IPv6 prefix.
uint8_t GetPrefixLength() const
Get prefix length.
Ipv6Address ConvertToIpv6Address() const
Convert the Prefix into an IPv6 Address.
A record that holds information about a NdiscCache entry.
void StartReachableTimer()
Start the reachable timer.
std::list< Ipv6PayloadHeaderPair > MarkReachable(Address mac)
Changes the state to this entry to REACHABLE.
void SetMacAddress(Address mac)
Set the MAC address of this entry.
void SetRouter(bool router)
Set the node type.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoInitialize()
Initialize() implementation.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
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.
An optimization of the ND protocol for 6LoWPANs.
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 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).
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.
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.
@ SixLowPanNodeOnly
a 6LN that can not become a 6LR
@ SixLowPanNode
a 6LN that can (and want to) become a 6LR
@ SixLowPanBorderRouter
a 6LBR
void SetInterfaceAs6lbr(Ptr< SixLowPanNetDevice > device)
Set an interface to be used as a 6LBR.
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.
@ DUPLICATE_ADDRESS
Duplicate Address.
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.
void AddressRegistrationTimeout()
Address registration timeout handler.
~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.
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.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetMinutes() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time Minutes(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
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.