A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::SixLowPanMeshUnderRouting Class Referenceabstract

Abstract base class for 6LoWPAN mesh-under forwarding policies. More...

#include "sixlowpan-mesh-under-routing.h"

Inheritance diagram for ns3::SixLowPanMeshUnderRouting:
Collaboration diagram for ns3::SixLowPanMeshUnderRouting:

Public Types

using ForwardCallback = Callback<void, Ptr<Packet>>
 Callback used by a policy to forward a packet.

Public Member Functions

 SixLowPanMeshUnderRouting ()
 SixLowPanMeshUnderRouting (const SixLowPanMeshUnderRouting &)=delete
 ~SixLowPanMeshUnderRouting () override
virtual int64_t AssignStreams (int64_t stream)=0
 Assign a fixed random stream number to RNGs used by the policy.
bool IsDuplicate (const Address &originator, uint8_t seqNo) const
 Check whether a (originator, sequence) pair has already been seen.
virtual void OnDuplicateReceived (const Address &originator, uint8_t seqNo)
 React to a duplicate packet reception.
virtual void OnPacketForward (Ptr< Packet > packet, const Address &originator, uint8_t seqNo, uint8_t hopsLeft, ForwardCallback forwardCb)=0
 Decide whether (and when) to forward a new mesh-under packet.
SixLowPanMeshUnderRouting & operator= (const SixLowPanMeshUnderRouting &)=delete
void RecordPacket (const Address &originator, uint8_t seqNo)
 Record a (originator, sequence) pair in the cache.
Public Member Functions inherited from ns3::Object
 Object ()
 Caller graph was not generated because of its size.
 ~Object () override
 Destructor.
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
void Dispose ()
 Dispose of this Object.
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
TypeId GetInstanceTypeId () const final
 Get the most derived TypeId for this Object.
template<>
Ptr< Object > GetObject () const
 Specialization of () for objects of type ns3::Object.
template<typename T>
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
template<>
Ptr< Object > GetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
template<typename T>
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
bool IsInitialized () const
 Check if the object has been initialized.
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
uint32_t GetReferenceCount () const
 Get the reference count of the object.
SimpleRefCount & operator= (const SimpleRefCount &o)
 Assignment operator.
void Ref () const
 Increment the reference count.
void Unref () const
 Decrement the reference count.
Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.

Protected Member Functions

void DoDispose () override
 Destructor implementation.
Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
virtual void DoInitialize ()
 Initialize() implementation.
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.

Private Attributes

uint16_t m_meshCacheLength {10}
 Maximum cache size per originator. Oldest entry dropped beyond this (FIFO).
std::map< Address, std::deque< uint8_t > > m_seenPkts
 Per-originator FIFO of recently seen BC0 sequence numbers.

Additional Inherited Members

Detailed Description

Abstract base class for 6LoWPAN mesh-under forwarding policies.

This class decouples the mesh-under forwarding decision from SixLowPanNetDevice. Concrete policies inherit from this class and implement the OnPacketForward() method, which is invoked by the device whenever a new (non-duplicate) mesh-under packet arrives.

The base class owns the per-originator duplicate-detection cache. Concrete policies may override OnDuplicateReceived() to react to duplicates (e.g., to influence if and when the packet must be forwarded).

The forwarding mechanism is encapsulated in a ForwardCallback that is supplied by the device. The policy invokes the callback when (and if) it decides the packet should be rebroadcast.

The device orchestrates duplicate handling: it calls IsDuplicate(), then either OnDuplicateReceived() (duplicate) or RecordPacket() followed by OnPacketForward() (new packet). This contract is intentional, so that a policy can base its forwarding decisions on the duplicate signals without owning the receive path.

Definition at line 49 of file sixlowpan-mesh-under-routing.h.

Member Typedef Documentation

◆ ForwardCallback

Callback used by a policy to forward a packet.

The callback is provided by SixLowPanNetDevice and hands the packet to the underlying NetDevice for broadcast transmission. Policies invoke it when they decide to forward.

Definition at line 59 of file sixlowpan-mesh-under-routing.h.

Constructor & Destructor Documentation

◆ SixLowPanMeshUnderRouting() [1/2]

ns3::SixLowPanMeshUnderRouting::SixLowPanMeshUnderRouting ( )

Definition at line 37 of file sixlowpan-mesh-under-routing.cc.

References NS_LOG_FUNCTION.

Referenced by SixLowPanMeshUnderRouting(), ns3::SixLowPanSimpleFlooding::GetTypeId(), and operator=().

Here is the caller graph for this function:

◆ ~SixLowPanMeshUnderRouting()

ns3::SixLowPanMeshUnderRouting::~SixLowPanMeshUnderRouting ( )
override

Definition at line 42 of file sixlowpan-mesh-under-routing.cc.

References NS_LOG_FUNCTION.

◆ SixLowPanMeshUnderRouting() [2/2]

ns3::SixLowPanMeshUnderRouting::SixLowPanMeshUnderRouting ( const SixLowPanMeshUnderRouting & )
delete

References SixLowPanMeshUnderRouting().

Here is the call graph for this function:

Member Function Documentation

◆ AssignStreams()

virtual int64_t ns3::SixLowPanMeshUnderRouting::AssignStreams ( int64_t stream)
pure virtual

Assign a fixed random stream number to RNGs used by the policy.

Parameters
streamFirst stream index to use.
Returns
The number of stream indices assigned by this policy.

Implemented in ns3::SixLowPanSimpleFlooding.

◆ DoDispose()

void ns3::SixLowPanMeshUnderRouting::DoDispose ( )
overrideprotectedvirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Caller graph was not generated because of its size.

Reimplemented from ns3::Object.

Reimplemented in ns3::SixLowPanSimpleFlooding.

Definition at line 48 of file sixlowpan-mesh-under-routing.cc.

References ns3::Object::DoDispose(), m_seenPkts, and NS_LOG_FUNCTION.

Referenced by ns3::SixLowPanSimpleFlooding::DoDispose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::SixLowPanMeshUnderRouting::GetTypeId ( )
static

Get the type ID.

Returns
The object TypeId.

Definition at line 23 of file sixlowpan-mesh-under-routing.cc.

References ns3::Object::Object(), m_meshCacheLength, ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), and ns3::TypeId::SetParent().

Referenced by ns3::SixLowPanHelper::SetMeshUnderRouting().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDuplicate()

bool ns3::SixLowPanMeshUnderRouting::IsDuplicate ( const Address & originator,
uint8_t seqNo ) const

Check whether a (originator, sequence) pair has already been seen.

Parameters
originatorThe MESH header originator address.
seqNoThe BC0 header sequence number.
Returns
true if the pair is already cached, false otherwise.

Definition at line 56 of file sixlowpan-mesh-under-routing.cc.

References m_seenPkts, and NS_LOG_FUNCTION.

◆ OnDuplicateReceived()

void ns3::SixLowPanMeshUnderRouting::OnDuplicateReceived ( const Address & originator,
uint8_t seqNo )
virtual

React to a duplicate packet reception.

Default implementation is a no-op. Subclasses may override to react to duplicates (e.g., to modify the decisions on if / when to forward the packet).

Parameters
originatorThe MESH header originator address.
seqNoThe BC0 header sequence number.

Definition at line 80 of file sixlowpan-mesh-under-routing.cc.

References NS_LOG_FUNCTION.

◆ OnPacketForward()

virtual void ns3::SixLowPanMeshUnderRouting::OnPacketForward ( Ptr< Packet > packet,
const Address & originator,
uint8_t seqNo,
uint8_t hopsLeft,
ForwardCallback forwardCb )
pure virtual

Decide whether (and when) to forward a new mesh-under packet.

The device calls this method when a new, non-duplicate mesh-under packet must be considered for forwarding. The policy decides if and when to invoke forwardCb to perform the actual rebroadcast.

Parameters
PacketThe mesh frame ready for retransmission (MESH and BC0 headers applied, hop count already decremented by the device).
originatorThe MESH header originator address.
seqNoThe BC0 header sequence number.
hopsLeftThe hop-count value the next-hop receiver will see (already decremented by the device).
forwardCbThe callback that performs the actual forward.

Implemented in ns3::SixLowPanSimpleFlooding.

◆ operator=()

SixLowPanMeshUnderRouting & ns3::SixLowPanMeshUnderRouting::operator= ( const SixLowPanMeshUnderRouting & )
delete

References SixLowPanMeshUnderRouting().

Here is the call graph for this function:

◆ RecordPacket()

void ns3::SixLowPanMeshUnderRouting::RecordPacket ( const Address & originator,
uint8_t seqNo )

Record a (originator, sequence) pair in the cache.

If the per-originator cache already holds MeshCacheLength entries, the oldest entry is dropped (FIFO).

Parameters
originatorThe MESH header originator address.
seqNoThe BC0 header sequence number.

Definition at line 68 of file sixlowpan-mesh-under-routing.cc.

References m_meshCacheLength, m_seenPkts, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_meshCacheLength

uint16_t ns3::SixLowPanMeshUnderRouting::m_meshCacheLength {10}
private

Maximum cache size per originator. Oldest entry dropped beyond this (FIFO).

Definition at line 144 of file sixlowpan-mesh-under-routing.h.

Referenced by GetTypeId(), and RecordPacket().

◆ m_seenPkts

std::map<Address , std::deque<uint8_t > > ns3::SixLowPanMeshUnderRouting::m_seenPkts
private

Per-originator FIFO of recently seen BC0 sequence numbers.

Definition at line 141 of file sixlowpan-mesh-under-routing.h.

Referenced by DoDispose(), IsDuplicate(), and RecordPacket().


The documentation for this class was generated from the following files: