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

Class representing the MAC layer of a LoRaWAN device. More...

#include "end-device-lorawan-mac.h"

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

Classes

struct  LoraRetxParameters
 Structure representing the parameters that will be used in the retransmission procedure. More...
 

Public Member Functions

 EndDeviceLorawanMac ()
 Default constructor.
 
 ~EndDeviceLorawanMac () override
 Destructor.
 
void AddMacCommand (Ptr< MacCommand > macCommand)
 Add a MAC command to the list of those that will be sent out in the next packet.
 
void ApplyNecessaryOptions (LoraFrameHeader &frameHeader)
 Add the necessary options and MAC commands to the LoraFrameHeader.
 
void ApplyNecessaryOptions (LorawanMacHeader &macHeader)
 Add the necessary options and MAC commands to the LorawanMacHeader.
 
virtual void DoSend (Ptr< Packet > packet)
 Checking if we are performing the transmission of a new packet or a retransmission, and call SendToPhy function.
 
void FailedReception (Ptr< const Packet > packet) override
 Function called by lower layers to inform this layer that reception of a packet we were locked on failed.
 
double GetAggregatedDutyCycle ()
 Get the aggregated duty cycle.
 
uint8_t GetDataRate ()
 Get the data rate this end device is set to use.
 
LoraDeviceAddress GetDeviceAddress ()
 Get the network address of this device.
 
uint8_t GetLastKnownGatewayCount () const
 Get the last known number of gateways concurrently receiving transmissions from the device.
 
uint8_t GetLastKnownLinkMarginDb () const
 Get the last known link margin from the demodulation floor.
 
uint8_t GetMaxNumberOfTransmissions ()
 Get the max number of unacknowledged redundant transmissions of each packet.
 
LorawanMacHeader::MType GetMType ()
 Get the message type to send when the Send method is called.
 
double GetTransmissionPowerDbm ()
 Get the transmission power this end device is set to use.
 
bool GetUplinkAdrBit () const
 Get the current value of the device's uplink ADR bit of the LoRaWAN FHDR.
 
void OnDevStatusReq ()
 Perform the actions that need to be taken when receiving a DevStatusReq command.
 
void OnDutyCycleReq (uint8_t maxDutyCycle)
 Perform the actions that need to be taken when receiving a DutyCycleReq command.
 
void OnLinkAdrReq (uint8_t dataRate, uint8_t txPower, uint16_t chMask, uint8_t chMaskCntl, uint8_t nbTrans)
 Perform the actions that need to be taken when receiving a LinkAdrReq command.
 
void OnLinkCheckAns (uint8_t margin, uint8_t gwCnt)
 Perform the actions that need to be taken when receiving a LinkCheckAns command.
 
void OnNewChannelReq (uint8_t chIndex, uint32_t frequencyHz, uint8_t minDataRate, uint8_t maxDataRate)
 Perform the actions that need to be taken when receiving a NewChannelReq command.
 
virtual void OnRxParamSetupReq (uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequencyHz)=0
 Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Device's Class Type.
 
void ParseCommands (LoraFrameHeader frameHeader)
 Parse and take action on the commands contained on this FrameHeader.
 
virtual void postponeTransmission (Time nextTxDelay, Ptr< Packet > packet)
 Postpone transmission to the specified time and delete previously scheduled transmissions if present.
 
void Receive (Ptr< const Packet > packet) override
 Receive a packet from the lower layer.
 
virtual void resetRetransmissionParameters ()
 Reset retransmission parameters contained in the structure LoraRetxParams.
 
void Send (Ptr< Packet > packet) override
 Send a packet.
 
virtual void SendToPhy (Ptr< Packet > packet)
 Add headers and send a packet with the sending function of the physical layer.
 
void SetDataRate (uint8_t dataRate)
 Set the data rate this end device will use when transmitting.
 
void SetDeviceAddress (LoraDeviceAddress address)
 Set the network address of this device.
 
void SetMaxNumberOfTransmissions (uint8_t nbTrans)
 Set the max number of unacknowledged redundant transmissions of each packet.
 
void SetMType (LorawanMacHeader::MType mType)
 Set the message type to send when the Send method is called.
 
void SetTransmissionPowerDbm (double txPowerDbm)
 Set the transmission power of this end device.
 
void SetUplinkAdrBit (bool adr)
 Signals to the network server that this device will or may not comply with LinkADRReq settings (data rate, transmission power and number of retransmissions) received in downlink.
 
void TxFinished (Ptr< const Packet > packet) override
 Perform actions after sending a packet.
 
- Public Member Functions inherited from ns3::lorawan::LorawanMac
 LorawanMac ()
 Default constructor.
 
 ~LorawanMac () override
 Destructor.
 
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.
 
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.
 
- 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 final
 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::lorawan::LorawanMac
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 Member Functions

Ptr< LogicalLoraChannelGetChannelForTx ()
 Find a suitable channel for transmission.
 
virtual Time GetNextClassTransmissionDelay (Time waitTime)
 Find the minimum wait time before the next possible transmission based on end device's Class Type.
 
- 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.
 

Protected Attributes

LoraDeviceAddress m_address
 The address of this device.
 
uint8_t m_codingRate
 The coding rate used by this device.
 
TracedValue< uint8_t > m_dataRate
 The data rate this device is using to transmit.
 
bool m_enableDRAdapt
 Enable data rate adaptation (ADR) during the retransmission procedure.
 
bool m_headerDisabled
 Whether or not the LoRa PHY header is disabled for communications by this device.
 
double m_lastRxSnr
 Used to record the last reception SNR measurement to be included in the DevStatusAns.
 
std::list< Ptr< MacCommand > > m_macCommandList
 List of the MAC commands that need to be applied to the next UL packet.
 
uint8_t m_nbTrans
 Default number of unacknowledged redundant transmissions of each packet.
 
uint8_t m_receiveWindowDurationInSymbols
 The duration of a receive window in number of symbols.
 
TracedCallback< uint8_t, bool, Time, Ptr< Packet > > m_requiredTxCallback
 The trace source fired when the transmission procedure is finished.
 
struct LoraRetxParameters m_retxParams
 Structure containing the retransmission parameters for this device.
 
TracedValue< doublem_txPowerDbm
 The transmission ERP [dBm] this device is currently using.
 
Ptr< UniformRandomVariablem_uniformRV
 An uniform random variable, used to randomly pick from the channel list.
 
- Protected Attributes inherited from ns3::lorawan::LorawanMac
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.
 

Private Member Functions

Time GetNextTransmissionDelay ()
 Find the base minimum wait time before the next possible transmission.
 

Private Attributes

bool m_adr
 Uplink ADR bit contained in the FCtrl field of the LoRaWAN FHDR.
 
TracedValue< doublem_aggregatedDutyCycle
 The aggregated duty cycle this device needs to respect across all sub-bands.
 
uint16_t m_currentFCnt
 current value of the device frame counter.
 
TracedValue< uint8_t > m_lastKnownGatewayCount
 The last known gateway count (i.e., gateways that are in communication range with this end device).
 
TracedValue< uint8_t > m_lastKnownLinkMarginDb
 The last known link margin in dB from the demodulation floor.
 
LorawanMacHeader::MType m_mType
 The message type to apply to packets sent with the Send method.
 
EventId m_nextRetx
 The event of transmitting a packet in a consecutive moment, when the duty cycle let us transmit.
 
EventId m_nextTx
 The event of retransmitting a packet in a consecutive moment if an ACK is not received.
 

Additional Inherited Members

- Public Types inherited from ns3::lorawan::LorawanMac
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.
 

Detailed Description

Class representing the MAC layer of a LoRaWAN device.

Definition at line 33 of file end-device-lorawan-mac.h.

Constructor & Destructor Documentation

◆ EndDeviceLorawanMac()

ns3::lorawan::EndDeviceLorawanMac::EndDeviceLorawanMac ( )

Default constructor.

Definition at line 101 of file end-device-lorawan-mac.cc.

References ns3::CreateObject(), m_address, m_adr, m_aggregatedDutyCycle, m_codingRate, m_currentFCnt, m_dataRate, m_enableDRAdapt, m_headerDisabled, m_lastKnownGatewayCount, m_lastKnownLinkMarginDb, m_lastRxSnr, m_mType, m_nbTrans, m_nextTx, m_receiveWindowDurationInSymbols, m_retxParams, m_txPowerDbm, m_uniformRV, and NS_LOG_FUNCTION.

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetTypeId().

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

◆ ~EndDeviceLorawanMac()

ns3::lorawan::EndDeviceLorawanMac::~EndDeviceLorawanMac ( )
override

Destructor.

Definition at line 137 of file end-device-lorawan-mac.cc.

References NS_LOG_FUNCTION_NOARGS.

Member Function Documentation

◆ AddMacCommand()

void ns3::lorawan::EndDeviceLorawanMac::AddMacCommand ( Ptr< MacCommand > macCommand)

Add a MAC command to the list of those that will be sent out in the next packet.

Parameters
macCommandA pointer to the MAC command.

Definition at line 947 of file end-device-lorawan-mac.cc.

References m_macCommandList, and NS_LOG_FUNCTION.

◆ ApplyNecessaryOptions() [1/2]

void ns3::lorawan::EndDeviceLorawanMac::ApplyNecessaryOptions ( LoraFrameHeader & frameHeader)

Add the necessary options and MAC commands to the LoraFrameHeader.

Parameters
frameHeaderThe frame header on which to apply the options.

Definition at line 425 of file end-device-lorawan-mac.cc.

References ns3::lorawan::LoraFrameHeader::AddCommand(), ns3::lorawan::MacCommand::GetCIDFromMacCommand(), m_address, m_adr, m_currentFCnt, m_macCommandList, NS_LOG_FUNCTION_NOARGS, NS_LOG_INFO, ns3::lorawan::LoraFrameHeader::SetAddress(), ns3::lorawan::LoraFrameHeader::SetAdr(), ns3::lorawan::LoraFrameHeader::SetAdrAckReq(), ns3::lorawan::LoraFrameHeader::SetAsUplink(), ns3::lorawan::LoraFrameHeader::SetFCnt(), and ns3::lorawan::LoraFrameHeader::SetFPort().

Referenced by DoSend().

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

◆ ApplyNecessaryOptions() [2/2]

void ns3::lorawan::EndDeviceLorawanMac::ApplyNecessaryOptions ( LorawanMacHeader & macHeader)

Add the necessary options and MAC commands to the LorawanMacHeader.

Parameters
macHeaderThe mac header on which to apply the options.

Definition at line 449 of file end-device-lorawan-mac.cc.

References m_mType, NS_LOG_FUNCTION_NOARGS, ns3::lorawan::LorawanMacHeader::SetMajor(), and ns3::lorawan::LorawanMacHeader::SetMType().

+ Here is the call graph for this function:

◆ DoSend()

void ns3::lorawan::EndDeviceLorawanMac::DoSend ( Ptr< Packet > packet)
virtual

Checking if we are performing the transmission of a new packet or a retransmission, and call SendToPhy function.

Parameters
packetThe packet to send.

Definition at line 199 of file end-device-lorawan-mac.cc.

References ApplyNecessaryOptions(), ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP, ns3::lorawan::LoraFrameHeader::GetSerializedSize(), ns3::lorawan::LorawanMacHeader::GetSerializedSize(), m_currentFCnt, m_dataRate, m_macCommandList, ns3::lorawan::LorawanMac::m_maxAppPayloadForDataRate, m_mType, m_nbTrans, m_requiredTxCallback, m_retxParams, ns3::lorawan::LorawanMac::m_sentNewPacket, ns3::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_WARN, resetRetransmissionParameters(), and SendToPhy().

Referenced by postponeTransmission(), and Send().

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

◆ FailedReception()

void ns3::lorawan::EndDeviceLorawanMac::FailedReception ( Ptr< const Packet > packet)
overridevirtual

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.

Implements ns3::lorawan::LorawanMac.

Definition at line 329 of file end-device-lorawan-mac.cc.

◆ GetAggregatedDutyCycle()

double ns3::lorawan::EndDeviceLorawanMac::GetAggregatedDutyCycle ( )

Get the aggregated duty cycle.

Returns
A time instance containing the aggregated duty cycle in fractional form.

Definition at line 939 of file end-device-lorawan-mac.cc.

References m_aggregatedDutyCycle, and NS_LOG_FUNCTION_NOARGS.

◆ GetChannelForTx()

Ptr< LogicalLoraChannel > ns3::lorawan::EndDeviceLorawanMac::GetChannelForTx ( )
protected

Find a suitable channel for transmission.

The channel is chosen among the ones that are available in the end device, based on their duty cycle limitations.

Returns
A pointer to the channel.
Todo
possibly move to LogicalChannelHelper

Definition at line 506 of file end-device-lorawan-mac.cc.

References ns3::Time::As(), ns3::Time::IsZero(), ns3::lorawan::LorawanMac::m_channelHelper, m_dataRate, m_uniformRV, NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Time::S.

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

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

◆ GetDataRate()

uint8_t ns3::lorawan::EndDeviceLorawanMac::GetDataRate ( )

Get the data rate this end device is set to use.

Returns
The data rate this device uses when transmitting.

Definition at line 592 of file end-device-lorawan-mac.cc.

References m_dataRate, and NS_LOG_FUNCTION.

◆ GetDeviceAddress()

LoraDeviceAddress ns3::lorawan::EndDeviceLorawanMac::GetDeviceAddress ( )

Get the network address of this device.

Returns
This device's address.

Definition at line 622 of file end-device-lorawan-mac.cc.

References m_address, and NS_LOG_FUNCTION.

◆ GetLastKnownGatewayCount()

uint8_t ns3::lorawan::EndDeviceLorawanMac::GetLastKnownGatewayCount ( ) const

Get the last known number of gateways concurrently receiving transmissions from the device.

This is intended for asynchronous polling by the Application layer of the device. For synchronous behavior provide a callback using the trace system.

Returns
The last known number of receiver gateways.

Definition at line 933 of file end-device-lorawan-mac.cc.

References m_lastKnownGatewayCount.

◆ GetLastKnownLinkMarginDb()

uint8_t ns3::lorawan::EndDeviceLorawanMac::GetLastKnownLinkMarginDb ( ) const

Get the last known link margin from the demodulation floor.

This is intended for asynchronous polling by the Application layer of the device. For synchronous behavior provide a callback using the trace system.

Returns
The last known link margin [dB]

Definition at line 927 of file end-device-lorawan-mac.cc.

References m_lastKnownLinkMarginDb.

◆ GetMaxNumberOfTransmissions()

uint8_t ns3::lorawan::EndDeviceLorawanMac::GetMaxNumberOfTransmissions ( )

Get the max number of unacknowledged redundant transmissions of each packet.

If, after a transmission, any acknowledgement is received, no more are sent for that packet.

Returns
The number of transmissions as uint8_t.

Definition at line 577 of file end-device-lorawan-mac.cc.

References m_nbTrans, and NS_LOG_FUNCTION.

◆ GetMType()

LorawanMacHeader::MType ns3::lorawan::EndDeviceLorawanMac::GetMType ( )

Get the message type to send when the Send method is called.

Returns
The message type.

Definition at line 465 of file end-device-lorawan-mac.cc.

References m_mType.

◆ GetNextClassTransmissionDelay()

Time ns3::lorawan::EndDeviceLorawanMac::GetNextClassTransmissionDelay ( Time waitTime)
protectedvirtual

Find the minimum wait time before the next possible transmission based on end device's Class Type.

Parameters
waitTimeCurrently known minimum wait time, possibly raised by this function.
Returns
The updated minimum wait time in Time format.

Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.

Definition at line 476 of file end-device-lorawan-mac.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by GetNextTransmissionDelay().

+ Here is the caller graph for this function:

◆ GetNextTransmissionDelay()

Time ns3::lorawan::EndDeviceLorawanMac::GetNextTransmissionDelay ( )
private

Find the base minimum wait time before the next possible transmission.

Returns
The base minimum wait time.
Todo
possibly move to LogicalChannelHelper

Definition at line 483 of file end-device-lorawan-mac.cc.

References GetNextClassTransmissionDelay(), ns3::lorawan::LorawanMac::m_channelHelper, ns3::Time::Max(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Time::S.

Referenced by Send().

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

◆ GetTransmissionPowerDbm()

double ns3::lorawan::EndDeviceLorawanMac::GetTransmissionPowerDbm ( )

Get the transmission power this end device is set to use.

Returns
The transmission ERP [dBm] this device uses when transmitting.

Definition at line 607 of file end-device-lorawan-mac.cc.

References m_txPowerDbm, and NS_LOG_FUNCTION.

◆ GetTypeId()

◆ GetUplinkAdrBit()

bool ns3::lorawan::EndDeviceLorawanMac::GetUplinkAdrBit ( ) const

Get the current value of the device's uplink ADR bit of the LoRaWAN FHDR.

Returns
true The device will comply with data rate, transmission power and number of retransmissions settings received from the network server via LikADRReq.
false Signals to the network server that the device may not comply with the data rate, transmission power and number of retransmissions settings received via LikADRReq.

Definition at line 562 of file end-device-lorawan-mac.cc.

References m_adr, and NS_LOG_FUNCTION.

◆ OnDevStatusReq()

void ns3::lorawan::EndDeviceLorawanMac::OnDevStatusReq ( )

Perform the actions that need to be taken when receiving a DevStatusReq command.

Definition at line 832 of file end-device-lorawan-mac.cc.

References ns3::Create(), ns3::energy::EnergySourceContainer::GetN(), ns3::lorawan::LorawanMac::m_device, m_lastRxSnr, m_macCommandList, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by ParseCommands().

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

◆ OnDutyCycleReq()

void ns3::lorawan::EndDeviceLorawanMac::OnDutyCycleReq ( uint8_t maxDutyCycle)

Perform the actions that need to be taken when receiving a DutyCycleReq command.

Parameters
maxDutyCycleThe aggregate duty cycle encoded by the command.

Definition at line 822 of file end-device-lorawan-mac.cc.

References ns3::Create(), m_aggregatedDutyCycle, m_macCommandList, NS_ASSERT_MSG, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by ParseCommands().

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

◆ OnLinkAdrReq()

void ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq ( uint8_t dataRate,
uint8_t txPower,
uint16_t chMask,
uint8_t chMaskCntl,
uint8_t nbTrans )

Perform the actions that need to be taken when receiving a LinkAdrReq command.

Parameters
dataRateThe data rate value of the command.
txPowerThe transmission power value of the command.
chMaskMask of enabled channels of the command.
chMaskCntlIndicator of the 16 channel bank to apply the chMask to.
nbTransThe number of repetitions prescribed by the command.
Remarks
Original code considers this to be mobile-mode

Definition at line 639 of file end-device-lorawan-mac.cc.

References ns3::Create(), ns3::lorawan::LorawanMac::GetBandwidthFromDataRate(), ns3::lorawan::LorawanMac::GetDbmForTxPower(), ns3::lorawan::LorawanMac::GetSfFromDataRate(), m_adr, ns3::lorawan::LorawanMac::m_channelHelper, m_dataRate, m_macCommandList, m_nbTrans, m_txPowerDbm, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, and NS_LOG_WARN.

Referenced by ParseCommands().

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

◆ OnLinkCheckAns()

void ns3::lorawan::EndDeviceLorawanMac::OnLinkCheckAns ( uint8_t margin,
uint8_t gwCnt )

Perform the actions that need to be taken when receiving a LinkCheckAns command.

Parameters
marginThe margin value of the command.
gwCntThe gateway count value of the command.

Definition at line 630 of file end-device-lorawan-mac.cc.

References m_lastKnownGatewayCount, m_lastKnownLinkMarginDb, and NS_LOG_FUNCTION.

Referenced by ParseCommands().

+ Here is the caller graph for this function:

◆ OnNewChannelReq()

void ns3::lorawan::EndDeviceLorawanMac::OnNewChannelReq ( uint8_t chIndex,
uint32_t frequencyHz,
uint8_t minDataRate,
uint8_t maxDataRate )

Perform the actions that need to be taken when receiving a NewChannelReq command.

Parameters
chIndexThe ChIndex field of the received NewChannelReq command.
frequencyHzThe Frequency [Hz] field of the received NewChannelReq command.
minDataRateThe MinDR field of the received NewChannelReq command.
maxDataRateThe MaxDR field of the received NewChannelReq command.

Definition at line 862 of file end-device-lorawan-mac.cc.

References ns3::Create(), ns3::lorawan::LorawanMac::GetBandwidthFromDataRate(), ns3::lorawan::LorawanMac::GetSfFromDataRate(), ns3::lorawan::LorawanMac::m_channelHelper, m_macCommandList, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, and NS_LOG_WARN.

Referenced by ParseCommands().

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

◆ OnRxParamSetupReq()

virtual void ns3::lorawan::EndDeviceLorawanMac::OnRxParamSetupReq ( uint8_t rx1DrOffset,
uint8_t rx2DataRate,
double frequencyHz )
pure virtual

Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Device's Class Type.

Parameters
rx1DrOffsetThe first reception window data rate offset to set.
rx2DataRateThe data rate to use for the second receive window.
frequencyHzThe frequency [Hz] to use for the second receive window.

Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac.

Referenced by ParseCommands().

+ Here is the caller graph for this function:

◆ ParseCommands()

void ns3::lorawan::EndDeviceLorawanMac::ParseCommands ( LoraFrameHeader frameHeader)

Parse and take action on the commands contained on this FrameHeader.

Parameters
frameHeaderThe frame header.

Definition at line 334 of file end-device-lorawan-mac.cc.

References ns3::lorawan::DEV_STATUS_REQ, ns3::lorawan::DL_CHANNEL_REQ, ns3::lorawan::DUTY_CYCLE_REQ, ns3::DynamicCast(), ns3::lorawan::LoraFrameHeader::GetAck(), ns3::lorawan::LoraFrameHeader::GetCommands(), ns3::lorawan::LINK_ADR_REQ, ns3::lorawan::LINK_CHECK_ANS, m_nbTrans, m_requiredTxCallback, m_retxParams, ns3::lorawan::NEW_CHANNEL_REQ, NS_LOG_DEBUG, NS_LOG_ERROR, NS_LOG_FUNCTION, NS_LOG_INFO, OnDevStatusReq(), OnDutyCycleReq(), OnLinkAdrReq(), OnLinkCheckAns(), OnNewChannelReq(), OnRxParamSetupReq(), resetRetransmissionParameters(), ns3::lorawan::RX_PARAM_SETUP_REQ, ns3::lorawan::RX_TIMING_SETUP_REQ, and ns3::lorawan::TX_PARAM_SETUP_REQ.

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::Receive().

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

◆ postponeTransmission()

void ns3::lorawan::EndDeviceLorawanMac::postponeTransmission ( Time nextTxDelay,
Ptr< Packet > packet )
virtual

Postpone transmission to the specified time and delete previously scheduled transmissions if present.

Parameters
nextTxDelayDelay at which the transmission will be performed.
packetThe packet to delay the transmission of.

Definition at line 187 of file end-device-lorawan-mac.cc.

References ns3::Time::As(), ns3::Simulator::Cancel(), DoSend(), m_nextTx, NS_LOG_FUNCTION, NS_LOG_WARN, ns3::Time::S, and ns3::Simulator::Schedule().

Referenced by Send().

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

◆ Receive()

void ns3::lorawan::EndDeviceLorawanMac::Receive ( Ptr< const Packet > packet)
overridevirtual

Receive a packet from the lower layer.

Parameters
packetThe received packet.

Implements ns3::lorawan::LorawanMac.

Definition at line 324 of file end-device-lorawan-mac.cc.

◆ resetRetransmissionParameters()

void ns3::lorawan::EndDeviceLorawanMac::resetRetransmissionParameters ( )
virtual

Reset retransmission parameters contained in the structure LoraRetxParams.

Definition at line 543 of file end-device-lorawan-mac.cc.

References ns3::Simulator::Cancel(), m_nbTrans, m_nextTx, and m_retxParams.

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), DoSend(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), ParseCommands(), and ns3::lorawan::ClassAEndDeviceLorawanMac::Receive().

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

◆ Send()

void ns3::lorawan::EndDeviceLorawanMac::Send ( Ptr< Packet > packet)
overridevirtual

Send a packet.

The MAC layer of the end device will take care of using the right parameters.

Parameters
packetThe packet to send.

Implements ns3::lorawan::LorawanMac.

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

References DoSend(), GetChannelForTx(), GetNextTransmissionDelay(), ns3::Time::IsStrictlyPositive(), ns3::lorawan::LorawanMac::m_cannotSendBecauseDutyCycle, m_retxParams, m_txPowerDbm, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, and postponeTransmission().

Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), and ns3::lorawan::ClassAEndDeviceLorawanMac::Receive().

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

◆ SendToPhy()

void ns3::lorawan::EndDeviceLorawanMac::SendToPhy ( Ptr< Packet > packet)
virtual

Add headers and send a packet with the sending function of the physical layer.

Parameters
packetThe packet to send.

Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.

Definition at line 315 of file end-device-lorawan-mac.cc.

Referenced by DoSend().

+ Here is the caller graph for this function:

◆ SetDataRate()

void ns3::lorawan::EndDeviceLorawanMac::SetDataRate ( uint8_t dataRate)

Set the data rate this end device will use when transmitting.

For End Devices, this value is assumed to be fixed, and can be modified via MAC commands issued by the gateway.

Parameters
dataRateThe dataRate to use when transmitting.

Definition at line 584 of file end-device-lorawan-mac.cc.

References m_dataRate, and NS_LOG_FUNCTION.

◆ SetDeviceAddress()

void ns3::lorawan::EndDeviceLorawanMac::SetDeviceAddress ( LoraDeviceAddress address)

Set the network address of this device.

Parameters
addressThe address to set.

Definition at line 614 of file end-device-lorawan-mac.cc.

References m_address, and NS_LOG_FUNCTION.

◆ SetMaxNumberOfTransmissions()

void ns3::lorawan::EndDeviceLorawanMac::SetMaxNumberOfTransmissions ( uint8_t nbTrans)

Set the max number of unacknowledged redundant transmissions of each packet.

If, after a transmission, any acknowledgement is received, no more are sent for that packet.

Parameters
nbTransThe number of transmissions.

Definition at line 569 of file end-device-lorawan-mac.cc.

References m_nbTrans, m_retxParams, and NS_LOG_FUNCTION.

◆ SetMType()

void ns3::lorawan::EndDeviceLorawanMac::SetMType ( LorawanMacHeader::MType mType)

Set the message type to send when the Send method is called.

Parameters
mTypeThe message type.

Definition at line 458 of file end-device-lorawan-mac.cc.

References m_mType, and NS_LOG_DEBUG.

◆ SetTransmissionPowerDbm()

void ns3::lorawan::EndDeviceLorawanMac::SetTransmissionPowerDbm ( double txPowerDbm)

Set the transmission power of this end device.

Parameters
txPowerDbmThe transmission ERP [dBm] value.

Definition at line 600 of file end-device-lorawan-mac.cc.

References m_txPowerDbm, and NS_LOG_FUNCTION.

◆ SetUplinkAdrBit()

void ns3::lorawan::EndDeviceLorawanMac::SetUplinkAdrBit ( bool adr)

Signals to the network server that this device will or may not comply with LinkADRReq settings (data rate, transmission power and number of retransmissions) received in downlink.

Parameters
adrThe ADR bit.

Definition at line 555 of file end-device-lorawan-mac.cc.

References m_adr, and NS_LOG_FUNCTION.

◆ TxFinished()

void ns3::lorawan::EndDeviceLorawanMac::TxFinished ( Ptr< const Packet > packet)
overridevirtual

Perform actions after sending a packet.

Parameters
packetThe packet that just finished transmission.

Implements ns3::lorawan::LorawanMac.

Definition at line 471 of file end-device-lorawan-mac.cc.

Member Data Documentation

◆ m_address

LoraDeviceAddress ns3::lorawan::EndDeviceLorawanMac::m_address
protected

◆ m_adr

bool ns3::lorawan::EndDeviceLorawanMac::m_adr
private

Uplink ADR bit contained in the FCtrl field of the LoRaWAN FHDR.

Controlled by the device, if set to false signals the network server that the device may not accept attempts to control the number of retransmissions, the data rate, or the TX power with downlink LinkADRReq commands.

Definition at line 408 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), ApplyNecessaryOptions(), GetTypeId(), GetUplinkAdrBit(), OnLinkAdrReq(), and SetUplinkAdrBit().

◆ m_aggregatedDutyCycle

TracedValue<double> ns3::lorawan::EndDeviceLorawanMac::m_aggregatedDutyCycle
private

The aggregated duty cycle this device needs to respect across all sub-bands.

Definition at line 451 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), GetAggregatedDutyCycle(), GetTypeId(), and OnDutyCycleReq().

◆ m_codingRate

uint8_t ns3::lorawan::EndDeviceLorawanMac::m_codingRate
protected

The coding rate used by this device.

Definition at line 336 of file end-device-lorawan-mac.h.

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

◆ m_currentFCnt

uint16_t ns3::lorawan::EndDeviceLorawanMac::m_currentFCnt
private

current value of the device frame counter.

Definition at line 461 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), ApplyNecessaryOptions(), and DoSend().

◆ m_dataRate

◆ m_enableDRAdapt

bool ns3::lorawan::EndDeviceLorawanMac::m_enableDRAdapt
protected

Enable data rate adaptation (ADR) during the retransmission procedure.

Definition at line 331 of file end-device-lorawan-mac.h.

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

◆ m_headerDisabled

bool ns3::lorawan::EndDeviceLorawanMac::m_headerDisabled
protected

Whether or not the LoRa PHY header is disabled for communications by this device.

Definition at line 337 of file end-device-lorawan-mac.h.

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

◆ m_lastKnownGatewayCount

TracedValue<uint8_t> ns3::lorawan::EndDeviceLorawanMac::m_lastKnownGatewayCount
private

The last known gateway count (i.e., gateways that are in communication range with this end device).

This value is obtained (and updated) when a LinkCheckAns Mac command is received.

Definition at line 446 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), GetLastKnownGatewayCount(), GetTypeId(), and OnLinkCheckAns().

◆ m_lastKnownLinkMarginDb

TracedValue<uint8_t> ns3::lorawan::EndDeviceLorawanMac::m_lastKnownLinkMarginDb
private

The last known link margin in dB from the demodulation floor.

This value is obtained (and updated) when a LinkCheckAns Mac command is received.

Definition at line 437 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), GetLastKnownLinkMarginDb(), GetTypeId(), and OnLinkCheckAns().

◆ m_lastRxSnr

double ns3::lorawan::EndDeviceLorawanMac::m_lastRxSnr
protected

Used to record the last reception SNR measurement to be included in the DevStatusAns.

Definition at line 389 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), OnDevStatusReq(), and ns3::lorawan::ClassAEndDeviceLorawanMac::Receive().

◆ m_macCommandList

std::list<Ptr<MacCommand> > ns3::lorawan::EndDeviceLorawanMac::m_macCommandList
protected

List of the MAC commands that need to be applied to the next UL packet.

Definition at line 374 of file end-device-lorawan-mac.h.

Referenced by AddMacCommand(), ApplyNecessaryOptions(), DoSend(), OnDevStatusReq(), OnDutyCycleReq(), OnLinkAdrReq(), OnNewChannelReq(), and ns3::lorawan::ClassAEndDeviceLorawanMac::OnRxParamSetupReq().

◆ m_mType

LorawanMacHeader::MType ns3::lorawan::EndDeviceLorawanMac::m_mType
private

The message type to apply to packets sent with the Send method.

Definition at line 456 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), ApplyNecessaryOptions(), DoSend(), GetMType(), GetTypeId(), and SetMType().

◆ m_nbTrans

◆ m_nextRetx

EventId ns3::lorawan::EndDeviceLorawanMac::m_nextRetx
private

The event of transmitting a packet in a consecutive moment, when the duty cycle let us transmit.

This Event is used to cancel the transmission of this packet if a newer packet is delivered from the application to be sent.

Definition at line 429 of file end-device-lorawan-mac.h.

◆ m_nextTx

EventId ns3::lorawan::EndDeviceLorawanMac::m_nextTx
private

The event of retransmitting a packet in a consecutive moment if an ACK is not received.

This Event is used to cancel the retransmission if the ACK is found in ParseCommand function and if a newer packet is delivered from the application to be sent.

Definition at line 420 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), postponeTransmission(), and resetRetransmissionParameters().

◆ m_receiveWindowDurationInSymbols

uint8_t ns3::lorawan::EndDeviceLorawanMac::m_receiveWindowDurationInSymbols
protected

The duration of a receive window in number of symbols.

This should be converted to time based or the reception parameter used.

The downlink preamble transmitted by the gateways contains 8 symbols. The receiver requires 5 symbols to detect the preamble and synchronize. Therefore there must be a 5 symbols overlap between the receive window and the transmitted preamble. (Ref: Recommended SX1272/76 Settings for EU868 LoRaWAN Network Operation )

Definition at line 369 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow(), and ns3::lorawan::ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow().

◆ m_requiredTxCallback

TracedCallback<uint8_t, bool, Time, Ptr<Packet> > ns3::lorawan::EndDeviceLorawanMac::m_requiredTxCallback
protected

◆ m_retxParams

◆ m_txPowerDbm

TracedValue<double> ns3::lorawan::EndDeviceLorawanMac::m_txPowerDbm
protected

The transmission ERP [dBm] this device is currently using.

Definition at line 335 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), GetTransmissionPowerDbm(), GetTypeId(), OnLinkAdrReq(), Send(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetTransmissionPowerDbm().

◆ m_uniformRV

Ptr<UniformRandomVariable> ns3::lorawan::EndDeviceLorawanMac::m_uniformRV
protected

An uniform random variable, used to randomly pick from the channel list.

Definition at line 384 of file end-device-lorawan-mac.h.

Referenced by EndDeviceLorawanMac(), GetChannelForTx(), and ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay().


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