Helper class for configuring and installing the LorawanMac class on devices and gateways. More...
#include "lorawan-mac-helper.h"
Public Types | |
enum | DeviceType { GW , ED_A } |
Define the kind of device. More... | |
enum | Regions { EU , US , China , EU433MHz , Australia , CN , AS923MHz , SouthKorea , SingleChannel , ALOHA } |
Define the operational region. More... | |
Public Member Functions | |
LorawanMacHelper () | |
Default constructor. | |
Ptr< LorawanMac > | Install (Ptr< Node > node, Ptr< NetDevice > device) const |
Create the LorawanMac instance and connect it to a device. | |
void | Set (std::string name, const AttributeValue &v) |
Set an attribute of the underlying MAC object. | |
void | SetAddressGenerator (Ptr< LoraDeviceAddressGenerator > addrGen) |
Set the address generator to use for creation of these nodes. | |
void | SetDeviceType (enum DeviceType dt) |
Set the kind of MAC this helper will create. | |
void | SetRegion (enum Regions region) |
Set the region in which the device is to operate. | |
Static Public Member Functions | |
static std::vector< int > | SetSpreadingFactorsGivenDistribution (NodeContainer endDevices, NodeContainer gateways, std::vector< double > distribution) |
Randomly initialize the end devices' data rate parameter according to the given distribution. | |
static std::vector< int > | SetSpreadingFactorsUp (NodeContainer endDevices, NodeContainer gateways, Ptr< LoraChannel > channel) |
Initialize the end devices' data rate parameter. | |
Private Member Functions | |
void | ApplyCommonAlohaConfigurations (Ptr< LorawanMac > lorawanMac) const |
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac classes. | |
void | ApplyCommonEuConfigurations (Ptr< LorawanMac > lorawanMac) const |
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac classes. | |
void | ApplyCommonSingleChannelConfigurations (Ptr< LorawanMac > lorawanMac) const |
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac classes. | |
void | ConfigureForAlohaRegion (Ptr< ClassAEndDeviceLorawanMac > edMac) const |
Perform region-specific configurations for the ALOHA band. | |
void | ConfigureForAlohaRegion (Ptr< GatewayLorawanMac > gwMac) const |
Perform region-specific configurations for the ALOHA band. | |
void | ConfigureForEuRegion (Ptr< ClassAEndDeviceLorawanMac > edMac) const |
Perform region-specific configurations for the 868 MHz EU band. | |
void | ConfigureForEuRegion (Ptr< GatewayLorawanMac > gwMac) const |
Perform region-specific configurations for the 868 MHz EU band. | |
void | ConfigureForSingleChannelRegion (Ptr< ClassAEndDeviceLorawanMac > edMac) const |
Perform region-specific configurations for the SINGLECHANNEL band. | |
void | ConfigureForSingleChannelRegion (Ptr< GatewayLorawanMac > gwMac) const |
Perform region-specific configurations for the SINGLECHANNEL band. | |
Private Attributes | |
Ptr< LoraDeviceAddressGenerator > | m_addrGen |
Pointer to the address generator to use. | |
enum DeviceType | m_deviceType |
The kind of device to install. | |
ObjectFactory | m_mac |
MAC-layer object factory. | |
enum Regions | m_region |
The region in which the device will operate. | |
Helper class for configuring and installing the LorawanMac class on devices and gateways.
The user must set all parameters before calling Install on nodes.
Definition at line 33 of file lorawan-mac-helper.h.
Define the kind of device.
Can be either GW (Gateway) or ED (End Device).
Enumerator | |
---|---|
GW | |
ED_A |
Definition at line 39 of file lorawan-mac-helper.h.
Define the operational region.
Enumerator | |
---|---|
EU | |
US | |
China | |
EU433MHz | |
Australia | |
CN | |
AS923MHz | |
SouthKorea | |
SingleChannel | |
ALOHA |
Definition at line 48 of file lorawan-mac-helper.h.
ns3::lorawan::LorawanMacHelper::LorawanMacHelper | ( | ) |
Default constructor.
Definition at line 24 of file lorawan-mac-helper.cc.
References LorawanMacHelper(), EU, and m_region.
Referenced by LorawanMacHelper().
|
private |
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac classes.
lorawanMac | Pointer to the MAC layer to configure. |
Definition at line 195 of file lorawan-mac-helper.cc.
References ns3::Create(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ConfigureForAlohaRegion(), and ConfigureForAlohaRegion().
|
private |
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac classes.
lorawanMac | Pointer to the MAC layer to configure. |
Definition at line 301 of file lorawan-mac-helper.cc.
References ns3::Create(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ConfigureForEuRegion(), ConfigureForEuRegion(), and ConfigureForSingleChannelRegion().
|
private |
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac classes.
lorawanMac | Pointer to the MAC layer to configure. |
Definition at line 416 of file lorawan-mac-helper.cc.
References ns3::Create(), and NS_LOG_FUNCTION_NOARGS.
Referenced by ConfigureForSingleChannelRegion().
|
private |
Perform region-specific configurations for the ALOHA band.
edMac | Pointer to the device MAC layer to configure. |
Definition at line 129 of file lorawan-mac-helper.cc.
References ApplyCommonAlohaConfigurations(), and NS_LOG_FUNCTION_NOARGS.
Referenced by Install().
|
private |
Perform region-specific configurations for the ALOHA band.
gwMac | Pointer to the gateway MAC layer to configure. |
Definition at line 166 of file lorawan-mac-helper.cc.
References ApplyCommonAlohaConfigurations(), ns3::DynamicCast(), NS_LOG_DEBUG, and NS_LOG_FUNCTION_NOARGS.
|
private |
Perform region-specific configurations for the 868 MHz EU band.
edMac | Pointer to the device MAC layer to configure. |
Definition at line 226 of file lorawan-mac-helper.cc.
References ApplyCommonEuConfigurations(), and NS_LOG_FUNCTION_NOARGS.
Referenced by Install().
|
private |
Perform region-specific configurations for the 868 MHz EU band.
gwMac | Pointer to the gateway MAC layer to configure. |
Definition at line 263 of file lorawan-mac-helper.cc.
References ApplyCommonEuConfigurations(), ns3::DynamicCast(), NS_LOG_DEBUG, and NS_LOG_FUNCTION_NOARGS.
|
private |
Perform region-specific configurations for the SINGLECHANNEL band.
edMac | Pointer to the device MAC layer to configure. |
Definition at line 343 of file lorawan-mac-helper.cc.
References ApplyCommonSingleChannelConfigurations(), and NS_LOG_FUNCTION_NOARGS.
Referenced by Install().
|
private |
Perform region-specific configurations for the SINGLECHANNEL band.
gwMac | Pointer to the gateway MAC layer to configure. |
Definition at line 380 of file lorawan-mac-helper.cc.
References ApplyCommonEuConfigurations(), ns3::DynamicCast(), NS_LOG_DEBUG, and NS_LOG_FUNCTION_NOARGS.
Ptr< LorawanMac > ns3::lorawan::LorawanMacHelper::Install | ( | Ptr< Node > | node, |
Ptr< NetDevice > | device ) const |
Create the LorawanMac instance and connect it to a device.
node | The node on which we wish to create a wifi MAC. |
device | The device within which this MAC will be created. |
Definition at line 66 of file lorawan-mac-helper.cc.
References ALOHA, ConfigureForAlohaRegion(), ConfigureForEuRegion(), ConfigureForSingleChannelRegion(), ns3::DynamicCast(), ED_A, EU, m_addrGen, m_deviceType, m_mac, m_region, NS_LOG_ERROR, and SingleChannel.
Referenced by ns3::lorawan::LoraHelper::Install(), and MacCommandTest::Reset().
void ns3::lorawan::LorawanMacHelper::Set | ( | std::string | name, |
const AttributeValue & | v ) |
Set an attribute of the underlying MAC object.
name | The name of the attribute to set. |
v | The value of the attribute. |
Definition at line 30 of file lorawan-mac-helper.cc.
References m_mac.
void ns3::lorawan::LorawanMacHelper::SetAddressGenerator | ( | Ptr< LoraDeviceAddressGenerator > | addrGen | ) |
Set the address generator to use for creation of these nodes.
addrGen | Pointer to the address generator object. |
Definition at line 52 of file lorawan-mac-helper.cc.
References m_addrGen, and NS_LOG_FUNCTION.
void ns3::lorawan::LorawanMacHelper::SetDeviceType | ( | enum DeviceType | dt | ) |
Set the kind of MAC this helper will create.
dt | The device type (either gateway or end device). |
Definition at line 36 of file lorawan-mac-helper.cc.
References ED_A, GW, m_deviceType, m_mac, and NS_LOG_FUNCTION.
Referenced by ns3::lorawan::CreateEndDevices(), ns3::lorawan::CreateGateways(), and MacCommandTest::Reset().
void ns3::lorawan::LorawanMacHelper::SetRegion | ( | enum Regions | region | ) |
Set the region in which the device is to operate.
region | The region enum value. |
Definition at line 60 of file lorawan-mac-helper.cc.
References m_region.
Referenced by MacCommandTest::Reset().
|
static |
Randomly initialize the end devices' data rate parameter according to the given distribution.
This function expects a data rate (DR) distribution vector of length 6 filled with real numbers summing up to 1. The value at index
distribution[0] == 0.2 -> fraction of devices to be assigned to DR5
distribution[1] == 0.1 -> fraction of devices to be assigned to DR4
distribution[2] == 0.1 -> fraction of devices to be assigned to DR3
distribution[3] == 0.1 -> fraction of devices to be assigned to DR2
distribution[4] == 0.2 -> fraction of devices to be assigned to DR1
distribution[5] == 0.3 -> fraction of devices to be assigned to DR0
Devices are then randomly assigned a DR following the provided distribution.
It returns a DR distribution vector with the following counters:
v[0] -> number of devices using DR5
v[1] -> number of devices using DR4
v[2] -> number of devices using DR3
v[3] -> number of devices using DR2
v[4] -> number of devices using DR1
v[5] -> number of devices using DR0
endDevices | The end devices to configure. |
gateways | The gateways in the network (this is only a placeholder parameter). |
distribution | The distribution (probability mass function) of DR assignment. |
Definition at line 590 of file lorawan-mac-helper.cc.
References ns3::NodeContainer::Begin(), ns3::CreateObject(), ns3::DynamicCast(), ns3::NodeContainer::End(), NS_ASSERT, NS_LOG_DEBUG, and NS_LOG_FUNCTION_NOARGS.
|
static |
Initialize the end devices' data rate parameter.
The Data Rate (DR) of each device is set to the maximum possible for its transmissions to be correctly received by the gateway measuring the best RSSI from the device, mimicking the DR maximization part of the default online LoRaWAN Adaptive Data Rate (ADR) algorithm. Please note that a single RSSI measurement between each device and gateway pair is taken for the DR assignment, so the assignment may be suboptimal in scenarios with a time-varying channel.
This function uses the following convention (EU868) to compute the transmission range:
DR5 -> SF7
DR4 -> SF8
DR3 -> SF9
DR2 -> SF10
DR1 -> SF11
DR0 -> SF12
It returns a DR distribution vector with the following counters:
v[0] -> number of devices using DR5
v[1] -> number of devices using DR4
v[2] -> number of devices using DR3
v[3] -> number of devices using DR2
v[4] -> number of devices using DR1
v[5] -> number of devices using DR0, in range of at least a gateway
v[6] -> number of devices using DR0, out of range
endDevices | The end devices to configure. |
gateways | The gateways to consider for RSSI measurements. |
channel | The radio channel to consider for RSSI measurements. |
Definition at line 447 of file lorawan-mac-helper.cc.
References ns3::NodeContainer::Begin(), ns3::DynamicCast(), ns3::NodeContainer::End(), ns3::NodeContainer::Get(), NS_ASSERT, NS_LOG_FUNCTION_NOARGS, and ns3::lorawan::EndDeviceLoraPhy::sensitivity.
Referenced by ns3::lorawan::InitializeNetwork().
|
private |
Pointer to the address generator to use.
Definition at line 247 of file lorawan-mac-helper.h.
Referenced by Install(), and SetAddressGenerator().
|
private |
The kind of device to install.
Definition at line 248 of file lorawan-mac-helper.h.
Referenced by Install(), and SetDeviceType().
|
private |
MAC-layer object factory.
Definition at line 246 of file lorawan-mac-helper.h.
Referenced by Install(), Set(), and SetDeviceType().
|
private |
The region in which the device will operate.
Definition at line 249 of file lorawan-mac-helper.h.
Referenced by LorawanMacHelper(), Install(), and SetRegion().