A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::SixLowPanHelper Class Reference

Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice. More...

#include "sixlowpan-helper.h"

Collaboration diagram for ns3::SixLowPanHelper:

Public Member Functions

 SixLowPanHelper ()
void AddAdvertisedContext (const Ptr< NetDevice > nd, Ipv6Prefix context)
 Add a new context to be advertised by 6LoWPAN-ND.
void AddContext (NetDeviceContainer c, uint8_t contextId, Ipv6Prefix context, Time validity)
 Adds a compression Context to a set of NetDevices.
int64_t AssignStreams (NetDeviceContainer c, int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model.
NetDeviceContainer Install (NetDeviceContainer c)
 Install the SixLoWPAN stack on top of an existing NetDevice.
Ipv6InterfaceContainer InstallSixLowPanNdBorderRouter (NetDeviceContainer c, Ipv6Address baseAddr)
 Install the SixLoWPAN-ND stack, associate it with a NetDevice, and set it as a 6LBR.
Ipv6InterfaceContainer InstallSixLowPanNdNode (NetDeviceContainer c)
 Install the SixLoWPAN-ND stack, associate it with a NetDevice, and set it as a 6LN.
void InvalidateContext (NetDeviceContainer c, uint8_t contextId)
 Invalidates a compression Context in a set of NetDevices.
void RemoveAdvertisedContext (const Ptr< NetDevice > nd, Ipv6Prefix context)
 Remove a context advertised by 6LoWPAN-ND.
void RemoveContext (NetDeviceContainer c, uint8_t contextId)
 Remove a compression Context in a set of NetDevices.
void RenewContext (NetDeviceContainer c, uint8_t contextId, Time validity)
 Renew a compression Context in a set of NetDevices.
void SetAdvertisedPrefix (const Ptr< NetDevice > nd, Ipv6Prefix prefix)
 Add a new prefix to be advertised by 6LoWPAN-ND.
void SetCapabilityIndication (const Ptr< NetDevice > nd, Icmpv6OptionSixLowPanCapabilityIndication capability)
 Add a Capability Indication to be advertised by 6LoWPAN-ND.
void SetDeviceAttribute (std::string n1, const AttributeValue &v1)
 Set an attribute on each ns3::SixlowpanNetDevice created by SixlowpanHelper::Install.

Static Public Member Functions

static void PrintBindingTable (Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
 Print the binding table of a node.
static void PrintBindingTableAllAt (Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
 Print the binding table of all nodes at a specific time.

Private Member Functions

std::vector< uint8_t > ConvertMacToRovr (const Address &mac)
 Convert a MAC address to a ROVR.
void InitializeRovr (Ptr< Node > node)
 Initialize the ROVR for a node.
void InstallSixLowPanNd (NetDeviceContainer c, bool borderRouter)
 Install the SixLoWPAN-ND stack in the node and associates it with a NetDevice.
std::string PrintRovr (const std::vector< uint8_t > &rovr)
 Print a ROVR as a string.

Private Attributes

ObjectFactory m_deviceFactory
 Object factory.

Detailed Description

Setup a sixlowpan stack to be used as a shim between IPv6 and a generic NetDevice.

Definition at line 33 of file sixlowpan-helper.h.

Constructor & Destructor Documentation

◆ SixLowPanHelper()

ns3::SixLowPanHelper::SixLowPanHelper ( )

Definition at line 35 of file sixlowpan-helper.cc.

References m_deviceFactory, and NS_LOG_FUNCTION.

Member Function Documentation

◆ AddAdvertisedContext()

void ns3::SixLowPanHelper::AddAdvertisedContext ( const Ptr< NetDevice > nd,
Ipv6Prefix context )

Add a new context to be advertised by 6LoWPAN-ND.

Parameters
[in]ndThe NetDevice.
contextannounced IPv6 context

Definition at line 286 of file sixlowpan-helper.cc.

References ns3::Ipv6Prefix::ConvertToIpv6Address(), ns3::DynamicCast(), NS_ABORT_MSG, NS_LOG_FUNCTION, and NS_LOG_WARN.

Here is the call graph for this function:

◆ AddContext()

void ns3::SixLowPanHelper::AddContext ( NetDeviceContainer c,
uint8_t contextId,
Ipv6Prefix context,
Time validity )

Adds a compression Context to a set of NetDevices.

This function installs one Compression Context on a set of NetDevices. The context is used only in IPHC compression and decompression.

Parameters
[in]cThe NetDevice container.
[in]contextIdThe context id (must be less than 16).
[in]contextThe context prefix.
[in]validitythe context validity time (relative to the actual time).

Definition at line 72 of file sixlowpan-helper.cc.

References ns3::DynamicCast(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

Referenced by SixlowpanIphcStatefulImplTest::DoRun().

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

◆ AssignStreams()

int64_t ns3::SixLowPanHelper::AssignStreams ( NetDeviceContainer c,
int64_t stream )

Assign a fixed random variable stream number to the random variables used by this model.

Return the number of streams (possibly zero) that have been assigned. The Install() method should have previously been called by the user.

Parameters
[in]cNetDeviceContainer of the set of net devices for which the SixLowPanNetDevice should be modified to use a fixed stream.
[in]streamFirst stream index to use.
Returns
The number of stream indices assigned by this helper.

Definition at line 139 of file sixlowpan-helper.cc.

References ns3::NetDeviceContainer::Begin(), ns3::DynamicCast(), and ns3::NetDeviceContainer::End().

Here is the call graph for this function:

◆ ConvertMacToRovr()

std::vector< uint8_t > ns3::SixLowPanHelper::ConvertMacToRovr ( const Address & mac)
private

Convert a MAC address to a ROVR.

Parameters
macThe MAC address to convert.
Returns
A vector of bytes representing the ROVR.

◆ InitializeRovr()

void ns3::SixLowPanHelper::InitializeRovr ( Ptr< Node > node)
private

Initialize the ROVR for a node.

Parameters
[in]nodeThe node to initialize the ROVR for.

Definition at line 336 of file sixlowpan-helper.cc.

References ns3::Address::CopyTo(), ns3::DynamicCast(), ns3::Address::GetLength(), ns3::Address::IsInvalid(), NS_ASSERT_MSG, and NS_LOG_INFO.

Referenced by InstallSixLowPanNdNode().

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

◆ Install()

NetDeviceContainer ns3::SixLowPanHelper::Install ( NetDeviceContainer c)

Install the SixLoWPAN stack on top of an existing NetDevice.

This function requires a set of properly configured NetDevices passed in as the parameter "c". The new NetDevices will have to be used instead of the original ones. In this way these SixLoWPAN devices will behave as shims between the NetDevices passed in and IPv6.

Note that only IPv6 (and related protocols, such as ICMPv6) can be transmitted over a 6LoWPAN interface. Any other protocol (e.g., IPv4) will be discarded by 6LoWPAN.

Other protocols (e.g., IPv4) could be used on the original NetDevices with some limitations. See the manual for a complete discussion.

Note
IPv6 stack must be installed after SixLoWPAN, using the SixLoWPAN NetDevices. See the example in the examples directory.
Parameters
[in]cThe NetDevice container.
Returns
A container with the newly created SixLowPanNetDevices.

Definition at line 49 of file sixlowpan-helper.cc.

References ns3::NetDeviceContainer::Add(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), m_deviceFactory, NS_ASSERT_MSG, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by ns3::SixLowPanNdFifteenLNRegTest::DoRun(), ns3::SixLowPanNdFiveLNRegTest::DoRun(), ns3::SixLowPanNdMulticastRsTimeoutTest::DoRun(), ns3::SixLowPanNdOneLNRegTest::DoRun(), ns3::SixLowPanNdRovrTest::DoRun(), ns3::SixLowPanNdTwentyLNRegTest::DoRun(), SixlowpanIphcStatefulImplTest::DoRun(), and UanExperiment::SetupCommunications().

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

◆ InstallSixLowPanNd()

void ns3::SixLowPanHelper::InstallSixLowPanNd ( NetDeviceContainer c,
bool borderRouter )
private

Install the SixLoWPAN-ND stack in the node and associates it with a NetDevice.

Parameters
[in]cThe NetDevice container.
[in]borderRouterSet the NetDevices to work as 6LBRs.

Definition at line 221 of file sixlowpan-helper.cc.

References ns3::CreateObject(), ns3::DynamicCast(), ns3::NetDeviceContainer::Get(), and ns3::NetDeviceContainer::GetN().

Referenced by InstallSixLowPanNdBorderRouter(), and InstallSixLowPanNdNode().

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

◆ InstallSixLowPanNdBorderRouter()

Ipv6InterfaceContainer ns3::SixLowPanHelper::InstallSixLowPanNdBorderRouter ( NetDeviceContainer c,
Ipv6Address baseAddr )

Install the SixLoWPAN-ND stack, associate it with a NetDevice, and set it as a 6LBR.

Note
IPv6 stack must NOT be installed after this function, because it has been already set up.
Parameters
[in]cThe NetDevice container.
[in]baseAddrThe prefix to be announced by the 6LBR.
Returns
A container of the addresses assigned to the NetDevices.

Definition at line 156 of file sixlowpan-helper.cc.

References ns3::Ipv6AddressHelper::AssignWithoutOnLink(), ns3::DynamicCast(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), InstallSixLowPanNd(), NS_ABORT_MSG, and ns3::Ipv6AddressHelper::SetBase().

Referenced by ns3::SixLowPanNdFifteenLNRegTest::DoRun(), ns3::SixLowPanNdFiveLNRegTest::DoRun(), ns3::SixLowPanNdOneLNRegTest::DoRun(), ns3::SixLowPanNdRovrTest::DoRun(), and ns3::SixLowPanNdTwentyLNRegTest::DoRun().

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

◆ InstallSixLowPanNdNode()

Ipv6InterfaceContainer ns3::SixLowPanHelper::InstallSixLowPanNdNode ( NetDeviceContainer c)

Install the SixLoWPAN-ND stack, associate it with a NetDevice, and set it as a 6LN.

Note
IPv6 stack must NOT be installed after this function, because it has been already set up.
Parameters
[in]cThe NetDevice container.
Returns
A container of the addresses assigned to the NetDevices.

Definition at line 184 of file sixlowpan-helper.cc.

References ns3::Ipv6AddressHelper::AssignWithoutAddress(), ns3::NetDeviceContainer::Get(), ns3::Ipv6InterfaceContainer::GetLinkLocalAddress(), ns3::Ipv6InterfaceContainer::GetN(), ns3::NetDeviceContainer::GetN(), InitializeRovr(), InstallSixLowPanNd(), ns3::Simulator::Schedule(), ns3::Seconds(), and ns3::SixLowPanNdProtocol::SendSixLowPanMulticastRS().

Referenced by ns3::SixLowPanNdFifteenLNRegTest::DoRun(), ns3::SixLowPanNdFiveLNRegTest::DoRun(), ns3::SixLowPanNdMulticastRsTimeoutTest::DoRun(), ns3::SixLowPanNdOneLNRegTest::DoRun(), ns3::SixLowPanNdRovrTest::DoRun(), and ns3::SixLowPanNdTwentyLNRegTest::DoRun().

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

◆ InvalidateContext()

void ns3::SixLowPanHelper::InvalidateContext ( NetDeviceContainer c,
uint8_t contextId )

Invalidates a compression Context in a set of NetDevices.

An invalid context is used only in IPHC decompression and not in IPHC compression.

This is necessary to avoid that a context reaching its validity lifetime can not be used for decompression whie packets are traveling the network.

Parameters
[in]cThe NetDevice container.
[in]contextIdThe context id (must be less than 16).

Definition at line 107 of file sixlowpan-helper.cc.

References ns3::DynamicCast(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

Here is the call graph for this function:

◆ PrintBindingTable()

void ns3::SixLowPanHelper::PrintBindingTable ( Ptr< Node > node,
Ptr< OutputStreamWrapper > stream,
Time::Unit unit = Time::S )
static

Print the binding table of a node.

Parameters
nodethe node for which the binding table is printed.
streamthe output stream wrapper used for printing.
unitthe time unit to be used in the report.

Definition at line 385 of file sixlowpan-helper.cc.

References ns3::Time::As(), ns3::Names::FindName(), and ns3::Simulator::Now().

Referenced by PrintBindingTableAllAt().

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

◆ PrintBindingTableAllAt()

void ns3::SixLowPanHelper::PrintBindingTableAllAt ( Time printTime,
Ptr< OutputStreamWrapper > stream,
Time::Unit unit = Time::S )
static

Print the binding table of all nodes at a specific time.

Parameters
printTimethe time at which the binding table is printed.
streamthe output stream wrapper used for printing.
unitthe time unit to be used in the report.

Definition at line 373 of file sixlowpan-helper.cc.

References ns3::NodeList::GetNNodes(), ns3::NodeList::GetNode(), PrintBindingTable(), and ns3::Simulator::Schedule().

Referenced by ns3::SixLowPanNdFifteenLNRegTest::DoRun(), ns3::SixLowPanNdFiveLNRegTest::DoRun(), ns3::SixLowPanNdOneLNRegTest::DoRun(), and ns3::SixLowPanNdTwentyLNRegTest::DoRun().

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

◆ PrintRovr()

std::string ns3::SixLowPanHelper::PrintRovr ( const std::vector< uint8_t > & rovr)
private

Print a ROVR as a string.

Parameters
rovrThe ROVR to print.
Returns
A string representation of the ROVR.

◆ RemoveAdvertisedContext()

void ns3::SixLowPanHelper::RemoveAdvertisedContext ( const Ptr< NetDevice > nd,
Ipv6Prefix context )

Remove a context advertised by 6LoWPAN-ND.

Parameters
[in]ndThe NetDevice.
contextannounced IPv6 context

Definition at line 311 of file sixlowpan-helper.cc.

References ns3::Ipv6Prefix::ConvertToIpv6Address(), ns3::DynamicCast(), NS_ABORT_MSG, NS_LOG_FUNCTION, and NS_LOG_WARN.

Here is the call graph for this function:

◆ RemoveContext()

void ns3::SixLowPanHelper::RemoveContext ( NetDeviceContainer c,
uint8_t contextId )

Remove a compression Context in a set of NetDevices.

The context is removed immediately from the contexts in the devices.

Parameters
[in]cThe NetDevice container.
[in]contextIdThe context id (must be less than 16).

Definition at line 123 of file sixlowpan-helper.cc.

References ns3::DynamicCast(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

Here is the call graph for this function:

◆ RenewContext()

void ns3::SixLowPanHelper::RenewContext ( NetDeviceContainer c,
uint8_t contextId,
Time validity )

Renew a compression Context in a set of NetDevices.

The context will have its lifetime extended and its validity for compression re-enabled.

Parameters
[in]cThe NetDevice container.
[in]contextIdThe context id (must be less than 16).
[in]validitythe context validity time (relative to the actual time).

Definition at line 91 of file sixlowpan-helper.cc.

References ns3::DynamicCast(), ns3::NetDeviceContainer::Get(), ns3::NetDeviceContainer::GetN(), and NS_LOG_FUNCTION.

Here is the call graph for this function:

◆ SetAdvertisedPrefix()

void ns3::SixLowPanHelper::SetAdvertisedPrefix ( const Ptr< NetDevice > nd,
Ipv6Prefix prefix )

Add a new prefix to be advertised by 6LoWPAN-ND.

Parameters
[in]ndThe NetDevice.
prefixannounced IPv6 prefix

Definition at line 262 of file sixlowpan-helper.cc.

References ns3::Ipv6Prefix::ConvertToIpv6Address(), ns3::DynamicCast(), NS_ABORT_MSG, NS_LOG_FUNCTION, and NS_LOG_WARN.

Referenced by ns3::SixLowPanNdFifteenLNRegTest::DoRun(), ns3::SixLowPanNdFiveLNRegTest::DoRun(), ns3::SixLowPanNdOneLNRegTest::DoRun(), ns3::SixLowPanNdRovrTest::DoRun(), and ns3::SixLowPanNdTwentyLNRegTest::DoRun().

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

◆ SetCapabilityIndication()

void ns3::SixLowPanHelper::SetCapabilityIndication ( const Ptr< NetDevice > nd,
Icmpv6OptionSixLowPanCapabilityIndication capability )

Add a Capability Indication to be advertised by 6LoWPAN-ND.

Parameters
[in]ndThe NetDevice.
capabilityannounced Node capability

References ns3::Time::S.

◆ SetDeviceAttribute()

void ns3::SixLowPanHelper::SetDeviceAttribute ( std::string n1,
const AttributeValue & v1 )

Set an attribute on each ns3::SixlowpanNetDevice created by SixlowpanHelper::Install.

Parameters
n1[in] The name of the attribute to set.
v1[in] The value of the attribute to set.

Definition at line 42 of file sixlowpan-helper.cc.

References m_deviceFactory, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_deviceFactory

ObjectFactory ns3::SixLowPanHelper::m_deviceFactory
private

Object factory.

Definition at line 238 of file sixlowpan-helper.h.

Referenced by SixLowPanHelper(), Install(), and SetDeviceAttribute().


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