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

Class representing the LoRaWAN MAC layer. More...

#include "lorawan-mac.h"

+ Inheritance diagram for ns3::lorawan::LorawanMac:
+ Collaboration diagram for ns3::lorawan::LorawanMac:

Public Types

typedef std::array< std::array< uint8_t, 6 >, 8 > ReplyDataRateMatrix
 Matrix structure to store possible data rate value to be used by a LoRaWAN end device for listening during the RX1 receive window.
 

Public Member Functions

 LorawanMac ()
 Default constructor.
 
 ~LorawanMac () override
 Destructor.
 
virtual void FailedReception (Ptr< const Packet > packet)=0
 Function called by lower layers to inform this layer that reception of a packet we were locked on failed.
 
double GetBandwidthFromDataRate (uint8_t dataRate)
 Get the bandwidth corresponding to a data rate, based on this MAC's region.
 
double GetDbmForTxPower (uint8_t txPower)
 Get the transmission power in dBm that corresponds, in this region, to the encoded 8-bit txPower.
 
Ptr< NetDeviceGetDevice ()
 Get the device this MAC layer is installed on.
 
Ptr< LogicalLoraChannelHelperGetLogicalLoraChannelHelper ()
 Get the logical lora channel helper associated with this MAC.
 
int GetNPreambleSymbols () const
 Get the number of PHY preamble symbols this MAC is set to use.
 
Ptr< LoraPhyGetPhy ()
 Get the underlying PHY layer.
 
uint8_t GetSfFromDataRate (uint8_t dataRate)
 Get the spreading factor corresponding to a data rate, based on this MAC's region.
 
virtual void Receive (Ptr< const Packet > packet)=0
 Receive a packet from the lower layer.
 
virtual void Send (Ptr< Packet > packet)=0
 Send a packet.
 
void SetBandwidthForDataRate (std::vector< double > bandwidthForDataRate)
 Set the vector to use to check up correspondence between bandwidth and data rate.
 
void SetDevice (Ptr< NetDevice > device)
 Set the device this MAC layer is installed on.
 
void SetLogicalLoraChannelHelper (Ptr< LogicalLoraChannelHelper > helper)
 Set the LogicalLoraChannelHelper this MAC instance will use.
 
void SetMaxAppPayloadForDataRate (std::vector< uint32_t > maxAppPayloadForDataRate)
 Set the maximum App layer payload for a set data rate.
 
void SetNPreambleSymbols (int nPreambleSymbols)
 Set the number of PHY preamble symbols this MAC is set to use.
 
void SetPhy (Ptr< LoraPhy > phy)
 Set the underlying PHY layer.
 
void SetReplyDataRateMatrix (ReplyDataRateMatrix replyDataRateMatrix)
 Set the matrix to use when deciding with which data rate to respond.
 
void SetSfForDataRate (std::vector< uint8_t > sfForDataRate)
 Set the vector to use to check up correspondence between spreading factor and data rate.
 
void SetTxDbmForTxPower (std::vector< double > txDbmForTxPower)
 Set the vector to use to check up which transmission power in Dbm corresponds to a certain TxPower value in this MAC's region.
 
virtual void TxFinished (Ptr< const Packet > packet)=0
 Perform actions after sending a packet.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~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 override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () 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.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
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.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (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 ()
 Register this type.
 
- 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 Attributes

std::vector< doublem_bandwidthForDataRate
 A vector holding the bandwidth each data rate corresponds to.
 
TracedCallback< Ptr< const Packet > > m_cannotSendBecauseDutyCycle
 The trace source that is fired when a packet cannot be sent because of duty cycle limitations.
 
Ptr< LogicalLoraChannelHelperm_channelHelper
 The LogicalLoraChannelHelper instance that is assigned to this MAC.
 
Ptr< NetDevicem_device
 The device this MAC layer is installed on.
 
std::vector< uint32_tm_maxAppPayloadForDataRate
 A vector holding the maximum app payload size that corresponds to a certain data rate.
 
int m_nPreambleSymbols
 The number of symbols to use in the PHY preamble.
 
Ptr< LoraPhym_phy
 The PHY instance that sits under this MAC layer.
 
TracedCallback< Ptr< const Packet > > m_receivedPacket
 Trace source that is fired when a packet reaches the MAC layer.
 
ReplyDataRateMatrix m_replyDataRateMatrix
 The matrix that decides the data rate the gateway will use in a reply based on the end device's sending data rate and on the value of the RX1DROffset parameter.
 
TracedCallback< Ptr< const Packet > > m_sentNewPacket
 Trace source that is fired when a new APP layer packet arrives at the MAC layer.
 
std::vector< uint8_t > m_sfForDataRate
 A vector holding the spreading factor each data rate corresponds to.
 
std::vector< doublem_txDbmForTxPower
 A vector holding the power that corresponds to a certain TxPower value.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
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.
 

Detailed Description

Class representing the LoRaWAN MAC layer.

This class is meant to be extended differently based on whether the layer belongs to an end device or a gateway, while holding some functionality that is common to both.

Definition at line 36 of file lorawan-mac.h.

Member Typedef Documentation

◆ ReplyDataRateMatrix

typedef std::array<std::array<uint8_t, 6>, 8> ns3::lorawan::LorawanMac::ReplyDataRateMatrix

Matrix structure to store possible data rate value to be used by a LoRaWAN end device for listening during the RX1 receive window.

It is a function of the uplink data rate and the RX1DROffset [0:5].

Definition at line 53 of file lorawan-mac.h.

Constructor & Destructor Documentation

◆ LorawanMac()

ns3::lorawan::LorawanMac::LorawanMac ( )

Default constructor.

Definition at line 47 of file lorawan-mac.cc.

References NS_LOG_FUNCTION.

◆ ~LorawanMac()

ns3::lorawan::LorawanMac::~LorawanMac ( )
override

Destructor.

Definition at line 52 of file lorawan-mac.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ FailedReception()

virtual void ns3::lorawan::LorawanMac::FailedReception ( Ptr< const Packet > packet)
pure virtual

Function called by lower layers to inform this layer that reception of a packet we were locked on failed.

Parameters
packetThe packet we failed to receive.

Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac, ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.

Referenced by SetPhy().

+ Here is the caller graph for this function:

◆ GetBandwidthFromDataRate()

double ns3::lorawan::LorawanMac::GetBandwidthFromDataRate ( uint8_t dataRate)

Get the bandwidth corresponding to a data rate, based on this MAC's region.

Parameters
dataRateThe data rate we need to convert to a bandwidth value.
Returns
The bandwidth that corresponds to the parameter data rate in this MAC's region, or 0 if the dataRate is not valid.

Definition at line 114 of file lorawan-mac.cc.

References m_bandwidthForDataRate, and NS_LOG_FUNCTION.

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay(), ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OnRxClassParamSetupReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow(), ns3::lorawan::GatewayLorawanMac::Send(), and ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy().

+ Here is the caller graph for this function:

◆ GetDbmForTxPower()

double ns3::lorawan::LorawanMac::GetDbmForTxPower ( uint8_t txPower)

Get the transmission power in dBm that corresponds, in this region, to the encoded 8-bit txPower.

Parameters
txPowerThe 8-bit encoded txPower to convert.
Returns
The corresponding transmission power in dBm, or 0 if the encoded power was not recognized as valid.

Definition at line 128 of file lorawan-mac.cc.

References m_txDbmForTxPower, and NS_LOG_FUNCTION.

Referenced by ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq().

+ Here is the caller graph for this function:

◆ GetDevice()

Ptr< NetDevice > ns3::lorawan::LorawanMac::GetDevice ( )

Get the device this MAC layer is installed on.

Returns
The NetDevice this MAC layer will refer to.

Definition at line 64 of file lorawan-mac.cc.

References m_device.

◆ GetLogicalLoraChannelHelper()

Ptr< LogicalLoraChannelHelper > ns3::lorawan::LorawanMac::GetLogicalLoraChannelHelper ( )

Get the logical lora channel helper associated with this MAC.

Returns
A Ptr to the instance of LogicalLoraChannelHelper that this MAC is using.

Definition at line 88 of file lorawan-mac.cc.

References m_channelHelper.

◆ GetNPreambleSymbols()

int ns3::lorawan::LorawanMac::GetNPreambleSymbols ( ) const

Get the number of PHY preamble symbols this MAC is set to use.

Returns
The number of preamble symbols to use (typically 8).

Definition at line 171 of file lorawan-mac.cc.

References m_nPreambleSymbols.

◆ GetPhy()

Ptr< LoraPhy > ns3::lorawan::LorawanMac::GetPhy ( )

Get the underlying PHY layer.

Returns
The PHY layer that this MAC is connected to.

Definition at line 70 of file lorawan-mac.cc.

References m_phy.

◆ GetSfFromDataRate()

uint8_t ns3::lorawan::LorawanMac::GetSfFromDataRate ( uint8_t dataRate)

Get the spreading factor corresponding to a data rate, based on this MAC's region.

Parameters
dataRateThe data rate we need to convert to a Spreading Factor value.
Returns
The spreading factor that corresponds to a data rate in this MAC's region, or 0 if the dataRate is not valid.

Definition at line 100 of file lorawan-mac.cc.

References m_sfForDataRate, and NS_LOG_FUNCTION.

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay(), ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OnRxClassParamSetupReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow(), ns3::lorawan::GatewayLorawanMac::Send(), and ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::lorawan::LorawanMac::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 23 of file lorawan-mac.cc.

References m_cannotSendBecauseDutyCycle, m_receivedPacket, m_sentNewPacket, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ Receive()

virtual void ns3::lorawan::LorawanMac::Receive ( Ptr< const Packet > packet)
pure virtual

Receive a packet from the lower layer.

Parameters
packetThe received packet.

Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac, ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.

Referenced by SetPhy().

+ Here is the caller graph for this function:

◆ Send()

virtual void ns3::lorawan::LorawanMac::Send ( Ptr< Packet > packet)
pure virtual

Send a packet.

Parameters
packetThe packet to send.

Implemented in ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.

◆ SetBandwidthForDataRate()

void ns3::lorawan::LorawanMac::SetBandwidthForDataRate ( std::vector< double > bandwidthForDataRate)

Set the vector to use to check up correspondence between bandwidth and data rate.

Parameters
bandwidthForDataRateA vector that contains at position i the bandwidth that should correspond to data rate i in this MAC's region.

Definition at line 147 of file lorawan-mac.cc.

References m_bandwidthForDataRate.

◆ SetDevice()

void ns3::lorawan::LorawanMac::SetDevice ( Ptr< NetDevice > device)

Set the device this MAC layer is installed on.

Parameters
deviceThe NetDevice this MAC layer will refer to.

Definition at line 58 of file lorawan-mac.cc.

References m_device.

◆ SetLogicalLoraChannelHelper()

void ns3::lorawan::LorawanMac::SetLogicalLoraChannelHelper ( Ptr< LogicalLoraChannelHelper > helper)

Set the LogicalLoraChannelHelper this MAC instance will use.

Parameters
helperA Ptr to the instance of the helper to use.

Definition at line 94 of file lorawan-mac.cc.

References m_channelHelper.

◆ SetMaxAppPayloadForDataRate()

void ns3::lorawan::LorawanMac::SetMaxAppPayloadForDataRate ( std::vector< uint32_t > maxAppPayloadForDataRate)

Set the maximum App layer payload for a set data rate.

Parameters
maxAppPayloadForDataRateA vector that contains at position i the maximum Application layer payload that should correspond to data rate i in this MAC's region.

Definition at line 153 of file lorawan-mac.cc.

References m_maxAppPayloadForDataRate.

◆ SetNPreambleSymbols()

void ns3::lorawan::LorawanMac::SetNPreambleSymbols ( int nPreambleSymbols)

Set the number of PHY preamble symbols this MAC is set to use.

Parameters
nPreambleSymbolsThe number of preamble symbols to use (typically 8).

Definition at line 165 of file lorawan-mac.cc.

References m_nPreambleSymbols.

◆ SetPhy()

void ns3::lorawan::LorawanMac::SetPhy ( Ptr< LoraPhy > phy)

Set the underlying PHY layer.

Parameters
phyThe phy layer.

Definition at line 76 of file lorawan-mac.cc.

References FailedReception(), m_phy, ns3::MakeCallback(), Receive(), and TxFinished().

+ Here is the call graph for this function:

◆ SetReplyDataRateMatrix()

void ns3::lorawan::LorawanMac::SetReplyDataRateMatrix ( ReplyDataRateMatrix replyDataRateMatrix)

Set the matrix to use when deciding with which data rate to respond.

Region based.

Parameters
replyDataRateMatrixA matrix containing the reply DataRates, based on the sending data rate and on the value of the RX1DROffset parameter.

Definition at line 177 of file lorawan-mac.cc.

References m_replyDataRateMatrix.

◆ SetSfForDataRate()

void ns3::lorawan::LorawanMac::SetSfForDataRate ( std::vector< uint8_t > sfForDataRate)

Set the vector to use to check up correspondence between spreading factor and data rate.

Parameters
sfForDataRateA vector that contains at position i the spreading factor that should correspond to data rate i.

Definition at line 141 of file lorawan-mac.cc.

References m_sfForDataRate.

◆ SetTxDbmForTxPower()

void ns3::lorawan::LorawanMac::SetTxDbmForTxPower ( std::vector< double > txDbmForTxPower)

Set the vector to use to check up which transmission power in Dbm corresponds to a certain TxPower value in this MAC's region.

Parameters
txDbmForTxPowerA vector that contains at position i the transmission power in dBm that should correspond to a TXPOWER value of i in this MAC's region.

Definition at line 159 of file lorawan-mac.cc.

References m_txDbmForTxPower.

◆ TxFinished()

virtual void ns3::lorawan::LorawanMac::TxFinished ( Ptr< const Packet > packet)
pure virtual

Perform actions after sending a packet.

Parameters
packetThe packet that just finished transmission.

Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac, ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.

Referenced by SetPhy().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_bandwidthForDataRate

std::vector<double> ns3::lorawan::LorawanMac::m_bandwidthForDataRate
protected

A vector holding the bandwidth each data rate corresponds to.

Definition at line 256 of file lorawan-mac.h.

Referenced by GetBandwidthFromDataRate(), and SetBandwidthForDataRate().

◆ m_cannotSendBecauseDutyCycle

TracedCallback<Ptr<const Packet> > ns3::lorawan::LorawanMac::m_cannotSendBecauseDutyCycle
protected

The trace source that is fired when a packet cannot be sent because of duty cycle limitations.

Definition at line 220 of file lorawan-mac.h.

Referenced by GetTypeId(), and ns3::lorawan::EndDeviceLorawanMac::Send().

◆ m_channelHelper

◆ m_device

Ptr<NetDevice> ns3::lorawan::LorawanMac::m_device
protected

The device this MAC layer is installed on.

Definition at line 241 of file lorawan-mac.h.

Referenced by GetDevice(), ns3::lorawan::GatewayLorawanMac::Receive(), and SetDevice().

◆ m_maxAppPayloadForDataRate

std::vector<uint32_t> ns3::lorawan::LorawanMac::m_maxAppPayloadForDataRate
protected

A vector holding the maximum app payload size that corresponds to a certain data rate.

Definition at line 262 of file lorawan-mac.h.

Referenced by ns3::lorawan::EndDeviceLorawanMac::DoSend(), and SetMaxAppPayloadForDataRate().

◆ m_nPreambleSymbols

int ns3::lorawan::LorawanMac::m_nPreambleSymbols
protected

The number of symbols to use in the PHY preamble.

Definition at line 267 of file lorawan-mac.h.

Referenced by GetNPreambleSymbols(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetNPreambleSymbols().

◆ m_phy

◆ m_receivedPacket

TracedCallback<Ptr<const Packet> > ns3::lorawan::LorawanMac::m_receivedPacket
protected

Trace source that is fired when a packet reaches the MAC layer.

Definition at line 225 of file lorawan-mac.h.

Referenced by GetTypeId(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), and ns3::lorawan::GatewayLorawanMac::Receive().

◆ m_replyDataRateMatrix

ReplyDataRateMatrix ns3::lorawan::LorawanMac::m_replyDataRateMatrix
protected

The matrix that decides the data rate the gateway will use in a reply based on the end device's sending data rate and on the value of the RX1DROffset parameter.

Definition at line 278 of file lorawan-mac.h.

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetFirstReceiveWindowDataRate(), and SetReplyDataRateMatrix().

◆ m_sentNewPacket

TracedCallback<Ptr<const Packet> > ns3::lorawan::LorawanMac::m_sentNewPacket
protected

Trace source that is fired when a new APP layer packet arrives at the MAC layer.

Definition at line 231 of file lorawan-mac.h.

Referenced by ns3::lorawan::EndDeviceLorawanMac::DoSend(), GetTypeId(), and ns3::lorawan::GatewayLorawanMac::Send().

◆ m_sfForDataRate

std::vector<uint8_t> ns3::lorawan::LorawanMac::m_sfForDataRate
protected

A vector holding the spreading factor each data rate corresponds to.

Definition at line 251 of file lorawan-mac.h.

Referenced by GetSfFromDataRate(), and SetSfForDataRate().

◆ m_txDbmForTxPower

std::vector<double> ns3::lorawan::LorawanMac::m_txDbmForTxPower
protected

A vector holding the power that corresponds to a certain TxPower value.

Definition at line 272 of file lorawan-mac.h.

Referenced by GetDbmForTxPower(), and SetTxDbmForTxPower().


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