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

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 AddLogicalChannel (double frequency)
 Add a logical channel to the helper.
 
void AddLogicalChannel (Ptr< LogicalLoraChannel > logicalChannel)
 Add a logical channel to the helper.
 
void AddMacCommand (Ptr< MacCommand > macCommand)
 Add a MAC command to the list of those that will be sent out in the next packet.
 
void AddSubBand (double startFrequency, double endFrequency, double dutyCycle, double maxTxPowerDbm)
 Add a subband to the logical channel helper.
 
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 ()
 ‍**
 
uint8_t GetDataRate ()
 Get the data rate this end device is set to use.
 
bool GetDataRateAdaptation () const
 Get if data rate adaptation is enabled or not.
 
LoraDeviceAddress GetDeviceAddress ()
 Get the network address of this device.
 
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.
 
virtual uint8_t GetTransmissionPower ()
 Get the transmission power this end device is set to use.
 
void OnDevStatusReq ()
 Perform the actions that need to be taken when receiving a DevStatusReq command.
 
void OnDutyCycleReq (double dutyCycle)
 Perform the actions that need to be taken when receiving a DutyCycleReq command.
 
void OnLinkAdrReq (uint8_t dataRate, uint8_t txPower, std::list< int > enabledChannels, int repetitions)
 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, double frequency, uint8_t minDataRate, uint8_t maxDataRate)
 Perform the actions that need to be taken when receiving a NewChannelReq command.
 
virtual void OnRxClassParamSetupReq (Ptr< RxParamSetupReq > rxParamSetupReq)
 Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Device's Class Type.
 
void OnRxParamSetupReq (Ptr< RxParamSetupReq > rxParamSetupReq)
 Perform the actions that need to be taken when receiving a RxParamSetupReq command.
 
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.
 
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 SetDataRateAdaptation (bool adapt)
 Enable data rate adaptation in the retransmitting procedure.
 
void SetDeviceAddress (LoraDeviceAddress address)
 Set the network address of this device.
 
void SetLogicalChannel (uint8_t chIndex, double frequency, uint8_t minDataRate, uint8_t maxDataRate)
 Set a new logical channel in the helper.
 
void SetMaxNumberOfTransmissions (uint8_t maxNumbTx)
 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 TxFinished (Ptr< const Packet > packet) override
 Perform the actions that are required after a packet send.
 
- Public Member Functions inherited from ns3::lorawan::LorawanMac
 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.
 
LogicalLoraChannelHelper GetLogicalLoraChannelHelper ()
 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 (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) 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.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
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 waitingTime)
 Find the minimum waiting 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.
 
std::list< Ptr< MacCommand > > m_macCommandList
 List of the MAC commands that need to be applied to the next UL packet.
 
uint8_t m_maxNumbTx
 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_txPower
 The transmission power this device is using to transmit.
 
Ptr< UniformRandomVariablem_uniformRV
 An uniform random variable, used by the Shuffle method to randomly reorder 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.
 
LogicalLoraChannelHelper m_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 waiting time before the next possible transmission.
 
std::vector< Ptr< LogicalLoraChannel > > Shuffle (std::vector< Ptr< LogicalLoraChannel > > vector)
 Randomly shuffle a Ptr<LogicalLoraChannel> vector.
 

Private Attributes

TracedValue< doublem_aggregatedDutyCycle
 The aggregated duty cycle this device needs to respect across all sub-bands.
 
bool m_controlDataRate
 Whether this device's data rate should be controlled by the network server.
 
uint16_t m_currentFCnt
 current value of the device frame counter.
 
TracedValue< int > m_lastKnownGatewayCount
 The last known gateway count (i.e., gateways that are in communication range with this end device).
 
TracedValue< doublem_lastKnownLinkMargin
 The last known link margin.
 
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 44 of file end-device-lorawan-mac.h.

Constructor & Destructor Documentation

◆ EndDeviceLorawanMac()

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

Default constructor.

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

References ns3::EventId::Cancel(), m_maxNumbTx, m_nextTx, m_retxParams, m_uniformRV, NS_LOG_FUNCTION, and ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::retxLeft.

+ Here is the call graph for this function:

◆ ~EndDeviceLorawanMac()

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

Destructor.

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

References NS_LOG_FUNCTION_NOARGS.

Member Function Documentation

◆ AddLogicalChannel() [1/2]

void ns3::lorawan::EndDeviceLorawanMac::AddLogicalChannel ( double  frequency)

Add a logical channel to the helper.

Parameters
frequencyThe channel's center frequency.

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

References ns3::lorawan::LogicalLoraChannelHelper::AddChannel(), ns3::lorawan::LorawanMac::m_channelHelper, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ AddLogicalChannel() [2/2]

void ns3::lorawan::EndDeviceLorawanMac::AddLogicalChannel ( Ptr< LogicalLoraChannel logicalChannel)

Add a logical channel to the helper.

Parameters
logicalChannelThe logical channel to add.

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

References ns3::lorawan::LogicalLoraChannelHelper::AddChannel(), ns3::lorawan::LorawanMac::m_channelHelper, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ 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 920 of file end-device-lorawan-mac.cc.

References m_macCommandList, and NS_LOG_FUNCTION.

◆ AddSubBand()

void ns3::lorawan::EndDeviceLorawanMac::AddSubBand ( double  startFrequency,
double  endFrequency,
double  dutyCycle,
double  maxTxPowerDbm 
)

Add a subband to the logical channel helper.

Parameters
startFrequencyThe SubBand's lowest frequency.
endFrequencyThe SubBand's highest frequency.
dutyCycleThe SubBand's duty cycle, in fraction form.
maxTxPowerDbmThe maximum transmission power allowed on the SubBand.

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

References ns3::lorawan::LogicalLoraChannelHelper::AddSubBand(), ns3::lorawan::LorawanMac::m_channelHelper, and NS_LOG_FUNCTION_NOARGS.

+ Here is the call graph for this 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 460 of file end-device-lorawan-mac.cc.

References ns3::lorawan::LoraFrameHeader::AddCommand(), ns3::lorawan::MacCommand::GetCIDFromMacCommand(), m_address, m_controlDataRate, 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 484 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 208 of file end-device-lorawan-mac.cc.

References ApplyNecessaryOptions(), ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP, ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::firstAttempt, ns3::lorawan::LoraFrameHeader::GetSerializedSize(), ns3::lorawan::LorawanMacHeader::GetSerializedSize(), m_currentFCnt, m_dataRate, m_macCommandList, ns3::lorawan::LorawanMac::m_maxAppPayloadForDataRate, m_maxNumbTx, m_mType, m_requiredTxCallback, m_retxParams, ns3::lorawan::LorawanMac::m_sentNewPacket, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_WARN, ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::packet, resetRetransmissionParameters(), ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::retxLeft, SendToPhy(), and ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::waitingAck.

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 335 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 912 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.

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

References ns3::lorawan::LogicalLoraChannelHelper::GetEnabledChannelList(), ns3::Time::GetSeconds(), ns3::lorawan::LogicalLoraChannelHelper::GetWaitingTime(), ns3::lorawan::LorawanMac::m_channelHelper, NS_LOG_DEBUG, NS_LOG_FUNCTION_NOARGS, ns3::Seconds(), and Shuffle().

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 662 of file end-device-lorawan-mac.cc.

References m_dataRate, and NS_LOG_FUNCTION.

◆ GetDataRateAdaptation()

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

Get if data rate adaptation is enabled or not.

Returns
True if the data rate adaptation is enabled, false if disabled.

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

References m_enableDRAdapt.

◆ GetDeviceAddress()

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

Get the network address of this device.

Returns
This device's address.

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

References m_address, and NS_LOG_FUNCTION.

◆ 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 647 of file end-device-lorawan-mac.cc.

References m_maxNumbTx, 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 500 of file end-device-lorawan-mac.cc.

References m_mType.

◆ GetNextClassTransmissionDelay()

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

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

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

Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.

Definition at line 511 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 waiting time before the next possible transmission.

Returns
The base minimum waiting time.

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

References ns3::lorawan::LogicalLoraChannelHelper::GetEnabledChannelList(), GetNextClassTransmissionDelay(), ns3::Time::GetSeconds(), ns3::lorawan::LogicalLoraChannelHelper::GetWaitingTime(), ns3::lorawan::LorawanMac::m_channelHelper, ns3::Time::Max(), NS_LOG_DEBUG, and NS_LOG_FUNCTION_NOARGS.

Referenced by Send().

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

◆ GetTransmissionPower()

uint8_t ns3::lorawan::EndDeviceLorawanMac::GetTransmissionPower ( )
virtual

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

Returns
The transmission power this device uses when transmitting.

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

References m_txPower.

◆ GetTypeId()

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

◆ OnDevStatusReq()

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

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

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

References m_macCommandList, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by ParseCommands().

+ Here is the caller graph for this function:

◆ OnDutyCycleReq()

void ns3::lorawan::EndDeviceLorawanMac::OnDutyCycleReq ( double  dutyCycle)

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

Parameters
dutyCycleThe aggregate duty cycle prescribed by the command, in fraction form.

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

References m_aggregatedDutyCycle, m_macCommandList, NS_ASSERT, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by ParseCommands().

+ Here is the caller graph for this function:

◆ OnLinkAdrReq()

void ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq ( uint8_t  dataRate,
uint8_t  txPower,
std::list< int >  enabledChannels,
int  repetitions 
)

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.
enabledChannelsA list of the enabled channels.
repetitionsThe number of repetitions prescribed by the command.

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

References ns3::lorawan::LorawanMac::GetBandwidthFromDataRate(), ns3::lorawan::LogicalLoraChannelHelper::GetChannelList(), ns3::lorawan::LorawanMac::GetDbmForTxPower(), ns3::lorawan::LorawanMac::GetSfFromDataRate(), ns3::lorawan::LorawanMac::m_channelHelper, m_dataRate, m_macCommandList, m_txPower, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

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 686 of file end-device-lorawan-mac.cc.

References m_lastKnownGatewayCount, m_lastKnownLinkMargin, and NS_LOG_FUNCTION.

Referenced by ParseCommands().

+ Here is the caller graph for this function:

◆ OnNewChannelReq()

void ns3::lorawan::EndDeviceLorawanMac::OnNewChannelReq ( uint8_t  chIndex,
double  frequency,
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.
frequencyThe Frequency 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 851 of file end-device-lorawan-mac.cc.

References m_macCommandList, NS_LOG_FUNCTION, NS_LOG_INFO, and SetLogicalChannel().

Referenced by ParseCommands().

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

◆ OnRxClassParamSetupReq()

void ns3::lorawan::EndDeviceLorawanMac::OnRxClassParamSetupReq ( Ptr< RxParamSetupReq rxParamSetupReq)
virtual

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

Parameters
rxParamSetupReqThe Parameter Setup Request.

Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.

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

Referenced by OnRxParamSetupReq().

+ Here is the caller graph for this function:

◆ OnRxParamSetupReq()

void ns3::lorawan::EndDeviceLorawanMac::OnRxParamSetupReq ( Ptr< RxParamSetupReq rxParamSetupReq)

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

Parameters
rxParamSetupReqThe Parameter Setup Request.

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

References NS_LOG_FUNCTION, and OnRxClassParamSetupReq().

Referenced by ParseCommands().

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

◆ ParseCommands()

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

◆ 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 196 of file end-device-lorawan-mac.cc.

References ns3::Simulator::Cancel(), DoSend(), ns3::Time::GetSeconds(), m_nextTx, NS_LOG_FUNCTION, NS_LOG_WARN, 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.

This method is typically registered as a callback in the underlying PHY layer so that it's called when a packet is going up the stack.

Parameters
packetThe received packet.

Implements ns3::lorawan::LorawanMac.

Definition at line 330 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 614 of file end-device-lorawan-mac.cc.

References ns3::Simulator::Cancel(), ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::firstAttempt, m_maxNumbTx, m_nextTx, m_retxParams, ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::packet, ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::retxLeft, ns3::Seconds(), and ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::waitingAck.

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 156 of file end-device-lorawan-mac.cc.

References DoSend(), GetChannelForTx(), GetNextTransmissionDelay(), ns3::lorawan::LogicalLoraChannelHelper::GetTxPowerForChannel(), ns3::lorawan::LorawanMac::m_cannotSendBecauseDutyCycle, ns3::lorawan::LorawanMac::m_channelHelper, m_retxParams, m_txPower, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, postponeTransmission(), ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::retxLeft, and ns3::Seconds().

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 321 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 654 of file end-device-lorawan-mac.cc.

References m_dataRate, and NS_LOG_FUNCTION.

◆ SetDataRateAdaptation()

void ns3::lorawan::EndDeviceLorawanMac::SetDataRateAdaptation ( bool  adapt)

Enable data rate adaptation in the retransmitting procedure.

Parameters
adaptIf the data rate adaptation is enabled or not.

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

References m_enableDRAdapt, 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 670 of file end-device-lorawan-mac.cc.

References m_address, and NS_LOG_FUNCTION.

◆ SetLogicalChannel()

void ns3::lorawan::EndDeviceLorawanMac::SetLogicalChannel ( uint8_t  chIndex,
double  frequency,
uint8_t  minDataRate,
uint8_t  maxDataRate 
)

Set a new logical channel in the helper.

Parameters
chIndexThe channel's new index.
frequencyThe channel's center frequency.
minDataRateThe minimum data rate allowed on the channel.
maxDataRateThe maximum data rate allowed on the channel.

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

References ns3::lorawan::LorawanMac::m_channelHelper, NS_LOG_FUNCTION, and ns3::lorawan::LogicalLoraChannelHelper::SetChannel().

Referenced by OnNewChannelReq().

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

◆ SetMaxNumberOfTransmissions()

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

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
maxNumbTxThe number of transmissions.

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

References m_maxNumbTx, m_retxParams, NS_LOG_FUNCTION, and ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::retxLeft.

◆ 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 493 of file end-device-lorawan-mac.cc.

References m_mType, and NS_LOG_DEBUG.

◆ Shuffle()

std::vector< Ptr< LogicalLoraChannel > > ns3::lorawan::EndDeviceLorawanMac::Shuffle ( std::vector< Ptr< LogicalLoraChannel > >  vector)
private

Randomly shuffle a Ptr<LogicalLoraChannel> vector.

Used to pick a random channel on which to send the packet.

Parameters
vectorThe vector of pointers to logical LoRa channels.
Returns
The shuffled vector.

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

References ns3::UniformRandomVariable::GetValue(), m_uniformRV, and NS_LOG_FUNCTION_NOARGS.

Referenced by GetChannelForTx().

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

◆ TxFinished()

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

Perform the actions that are required after a packet send.

This function handles opening of the first receive window.

Parameters
packetThe packet that has just been transmitted.

Implements ns3::lorawan::LorawanMac.

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

Member Data Documentation

◆ m_address

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

◆ 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 512 of file end-device-lorawan-mac.h.

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

◆ m_codingRate

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

The coding rate used by this device.

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

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

◆ m_controlDataRate

bool ns3::lorawan::EndDeviceLorawanMac::m_controlDataRate
private

Whether this device's data rate should be controlled by the network server.

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

Referenced by ApplyNecessaryOptions(), and GetTypeId().

◆ m_currentFCnt

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

current value of the device frame counter.

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

Referenced by ApplyNecessaryOptions(), and DoSend().

◆ m_dataRate

TracedValue<uint8_t> ns3::lorawan::EndDeviceLorawanMac::m_dataRate
protected

◆ m_enableDRAdapt

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

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

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

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

◆ 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 393 of file end-device-lorawan-mac.h.

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

◆ m_lastKnownGatewayCount

TracedValue<int> 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 507 of file end-device-lorawan-mac.h.

Referenced by GetTypeId(), and OnLinkCheckAns().

◆ m_lastKnownLinkMargin

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

The last known link margin.

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

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

Referenced by GetTypeId(), and OnLinkCheckAns().

◆ 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 430 of file end-device-lorawan-mac.h.

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

◆ m_maxNumbTx

◆ 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 517 of file end-device-lorawan-mac.h.

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

◆ 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 490 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 481 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 425 of file end-device-lorawan-mac.h.

Referenced by 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_txPower

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

The transmission power this device is using to transmit.

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

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

◆ m_uniformRV

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

An uniform random variable, used by the Shuffle method to randomly reorder the channel list.

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

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


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