13#include "ns3/ipv6-address.h"
14#include "ns3/ipv6-interface.h"
15#include "ns3/ipv6-l3-protocol.h"
16#include "ns3/ipv6-routing-protocol.h"
20#include "ns3/simulator.h"
21#include "ns3/uinteger.h"
39 TypeId(
"ns3::SixLowPanNdBindingTable")
41 .SetGroupName(
"SixLowPan")
43 .AddAttribute(
"StaleDuration",
44 "The duration (in hours) an entry remains in STALE state before "
45 "being removed from the binding table.",
95 if (device ==
nullptr)
97 NS_LOG_ERROR(
"Device is null, cannot set device for SixLowPanNdBindingTable");
132 entry->SetIpv6Address(to);
134 NS_LOG_DEBUG(
"Added new binding table entry for " << to);
149 NS_LOG_DEBUG(
"Removing binding table entry for " << it->first);
159 std::ostream* os = stream->GetStream();
162 std::vector<std::pair<Ipv6Address, SixLowPanNdBindingTableEntry*>> entries;
165 entries.emplace_back(i.first, i.second);
169 std::sort(entries.begin(), entries.end(), [](
const auto& a,
const auto& b) {
170 return a.first < b.first;
174 for (
const auto& entry : entries)
176 entry.second->Print(*os);
241 NS_LOG_DEBUG(
"Entry marked REACHABLE with lifetime " << time <<
" minutes");
295 NS_LOG_DEBUG(
"Registered timer expired, marking entry as STALE");
303 Ptr<Node> node = device ? device->GetNode() :
nullptr;
308 ipv6l3Protocol->GetRoutingProtocol()->NotifyRemoveRoute(
312 ipv6l3Protocol->GetInterfaceForDevice(device));
338 if (rovr.size() >= 16)
340 m_rovr.assign(rovr.begin(), rovr.begin() + 16);
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
IPv6 layer implementation.
Describes an IPv6 prefix.
Object()
Caller graph was not generated because of its size.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
A record that holds information about an SixLowPanNdBindingTable entry.
std::vector< uint8_t > m_rovr
The ROVR value.
void MarkStale()
Change the state to this entry to STALE.
void MarkReachable(uint16_t time)
Changes the state to this entry to REACHABLE.
Timer m_staleTimer
Timer (used for STALE entries).
void SetIpv6Address(Ipv6Address ipv6Address)
Set the IPv6 address for this entry.
Timer m_reachableTimer
Timer (used for REACHABLE entries).
SixLowPanNdBindingTableEntryType_e m_type
The state of the entry.
Ipv6Address m_ipv6Address
The IPv6 address for this entry.
Ipv6Address GetIpv6Address() const
Get the IPv6 address for this entry.
SixLowPanNdBindingTable * m_bindingTable
The binding table this entry belongs to.
bool IsStale() const
Is the entry STALE.
SixLowPanNdBindingTable * GetBindingTable() const
Get the binding table this entry belongs to.
std::vector< uint8_t > GetRovr() const
Get the ROVR field.
void FunctionTimeout()
Function called when timer timeout.
void Print(std::ostream &os) const
Print the binding table entry to an output stream.
bool IsReachable() const
Is the entry REACHABLE.
SixLowPanNdBindingTableEntry(SixLowPanNdBindingTable *bt)
Constructor.
@ REACHABLE
Active registration.
@ STALE
Registration expired; entry pending removal.
void SetRovr(const std::vector< uint8_t > &rovr)
Set the ROVR field.
A binding table for 6LoWPAN ND.
Ptr< NetDevice > m_device
The NetDevice associated with this binding table.
Ptr< Ipv6Interface > GetInterface() const
Get the IPv6 interface associated with this binding table.
Time m_staleDuration
The duration (in hours) an entry remains in STALE state before being removed from the binding table.
void SetDevice(Ptr< NetDevice > device, Ptr< Ipv6Interface > interface, Ptr< Icmpv6L4Protocol > icmpv6)
Set the device and interface.
void Remove(SixLowPanNdBindingTable::SixLowPanNdBindingTableEntry *entry)
Remove an entry from the binding table.
SixLowPanNdBindingTable::SixLowPanNdBindingTableEntry * Add(Ipv6Address to)
Add an entry.
void PrintBindingTable(Ptr< OutputStreamWrapper > stream)
Print the SixLowPanNdBindingTable entries.
Ptr< Icmpv6L4Protocol > m_icmpv6
The ICMPv6 protocol associated with this binding table.
Ptr< NetDevice > GetDevice() const
Get the NetDevice associated with this cache.
Ptr< Ipv6Interface > m_interface
The IPv6 interface associated with this binding table.
SixLowPanNdBindingTable::SixLowPanNdBindingTableEntry * Lookup(Ipv6Address dst)
Lookup in the binding table.
void DoDispose() override
Dispose this object.
SixLowPanNdBindingTable()
Constructor.
SixLowPanTable m_sixLowPanNdBindingTable
The actual binding table.
~SixLowPanNdBindingTable()
Destructor.
static TypeId GetTypeId()
Get the type ID.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
A simple virtual Timer class.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
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.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Hours(double value)
Construct a Time in the indicated unit.
Time Minutes(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
static const uint8_t STALE_DURATION
Duration before an entry transitions to STALE state, in hours (RFC 8929).