Class representing the MAC layer of a LoRaWAN device. More...
#include "end-device-lorawan-mac.h"
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. | |
![]() | |
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< NetDevice > | GetDevice () |
Get the device this MAC layer is installed on. | |
Ptr< 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< LoraPhy > | GetPhy () |
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. | |
![]() | |
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< Object > | GetObject () 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< Object > | GetObject (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. | |
![]() | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
![]() | |
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 TypeId | GetTypeId () |
Register this type. | |
![]() | |
static TypeId | GetTypeId () |
Register this type. | |
![]() | |
static TypeId | GetTypeId () |
Get the type ID. | |
Protected Member Functions | |
Ptr< LogicalLoraChannel > | GetChannelForTx () |
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. | |
![]() | |
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. | |
![]() | |
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< double > | m_txPowerDbm |
The transmission ERP [dBm] this device is currently using. | |
Ptr< UniformRandomVariable > | m_uniformRV |
An uniform random variable, used to randomly pick from the channel list. | |
![]() | |
std::vector< double > | m_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< LogicalLoraChannelHelper > | m_channelHelper |
The LogicalLoraChannelHelper instance that is assigned to this MAC. | |
Ptr< NetDevice > | m_device |
The device this MAC layer is installed on. | |
std::vector< uint32_t > | m_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< LoraPhy > | m_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< double > | m_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< double > | m_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 | |
![]() | |
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. | |
![]() | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Class representing the MAC layer of a LoRaWAN device.
Definition at line 33 of file end-device-lorawan-mac.h.
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().
|
override |
Destructor.
Definition at line 137 of file end-device-lorawan-mac.cc.
References NS_LOG_FUNCTION_NOARGS.
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.
macCommand | A pointer to the MAC command. |
Definition at line 947 of file end-device-lorawan-mac.cc.
References m_macCommandList, and NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceLorawanMac::ApplyNecessaryOptions | ( | LoraFrameHeader & | frameHeader | ) |
Add the necessary options and MAC commands to the LoraFrameHeader.
frameHeader | The 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().
void ns3::lorawan::EndDeviceLorawanMac::ApplyNecessaryOptions | ( | LorawanMacHeader & | macHeader | ) |
Add the necessary options and MAC commands to the LorawanMacHeader.
macHeader | The 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().
Checking if we are performing the transmission of a new packet or a retransmission, and call SendToPhy function.
packet | The 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().
|
overridevirtual |
Function called by lower layers to inform this layer that reception of a packet we were locked on failed.
packet | The packet we failed to receive. |
Implements ns3::lorawan::LorawanMac.
Definition at line 329 of file end-device-lorawan-mac.cc.
double ns3::lorawan::EndDeviceLorawanMac::GetAggregatedDutyCycle | ( | ) |
Get the aggregated duty cycle.
Definition at line 939 of file end-device-lorawan-mac.cc.
References m_aggregatedDutyCycle, and NS_LOG_FUNCTION_NOARGS.
|
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.
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().
uint8_t ns3::lorawan::EndDeviceLorawanMac::GetDataRate | ( | ) |
Get the data rate this end device is set to use.
Definition at line 592 of file end-device-lorawan-mac.cc.
References m_dataRate, and NS_LOG_FUNCTION.
LoraDeviceAddress ns3::lorawan::EndDeviceLorawanMac::GetDeviceAddress | ( | ) |
Get the network address of this device.
Definition at line 622 of file end-device-lorawan-mac.cc.
References m_address, and NS_LOG_FUNCTION.
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.
Definition at line 933 of file end-device-lorawan-mac.cc.
References m_lastKnownGatewayCount.
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.
Definition at line 927 of file end-device-lorawan-mac.cc.
References m_lastKnownLinkMarginDb.
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.
Definition at line 577 of file end-device-lorawan-mac.cc.
References m_nbTrans, and NS_LOG_FUNCTION.
LorawanMacHeader::MType ns3::lorawan::EndDeviceLorawanMac::GetMType | ( | ) |
Get the message type to send when the Send method is called.
Definition at line 465 of file end-device-lorawan-mac.cc.
References m_mType.
|
protectedvirtual |
Find the minimum wait time before the next possible transmission based on end device's Class Type.
waitTime | Currently known minimum wait time, possibly raised by this function. |
Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.
Definition at line 476 of file end-device-lorawan-mac.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by GetNextTransmissionDelay().
|
private |
Find the base minimum wait time before the next possible transmission.
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().
double ns3::lorawan::EndDeviceLorawanMac::GetTransmissionPowerDbm | ( | ) |
Get the transmission power this end device is set to use.
Definition at line 607 of file end-device-lorawan-mac.cc.
References m_txPowerDbm, and NS_LOG_FUNCTION.
|
static |
Register this type.
Definition at line 33 of file end-device-lorawan-mac.cc.
References ns3::lorawan::LorawanMac::LorawanMac(), ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP, m_adr, m_aggregatedDutyCycle, m_dataRate, m_enableDRAdapt, m_lastKnownGatewayCount, m_lastKnownLinkMarginDb, m_mType, m_nbTrans, m_requiredTxCallback, m_txPowerDbm, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeIntegerAccessor(), ns3::MakeIntegerChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), ns3::TypeId::SetParent(), and ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_UP.
bool ns3::lorawan::EndDeviceLorawanMac::GetUplinkAdrBit | ( | ) | const |
Get the current value of the device's uplink ADR bit of the LoRaWAN FHDR.
Definition at line 562 of file end-device-lorawan-mac.cc.
References m_adr, and NS_LOG_FUNCTION.
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().
void ns3::lorawan::EndDeviceLorawanMac::OnDutyCycleReq | ( | uint8_t | maxDutyCycle | ) |
Perform the actions that need to be taken when receiving a DutyCycleReq command.
maxDutyCycle | The 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().
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.
dataRate | The data rate value of the command. |
txPower | The transmission power value of the command. |
chMask | Mask of enabled channels of the command. |
chMaskCntl | Indicator of the 16 channel bank to apply the chMask to. |
nbTrans | The number of repetitions prescribed by the command. |
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().
void ns3::lorawan::EndDeviceLorawanMac::OnLinkCheckAns | ( | uint8_t | margin, |
uint8_t | gwCnt ) |
Perform the actions that need to be taken when receiving a LinkCheckAns command.
margin | The margin value of the command. |
gwCnt | The 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().
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.
chIndex | The ChIndex field of the received NewChannelReq command. |
frequencyHz | The Frequency [Hz] field of the received NewChannelReq command. |
minDataRate | The MinDR field of the received NewChannelReq command. |
maxDataRate | The 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().
|
pure virtual |
Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Device's Class Type.
rx1DrOffset | The first reception window data rate offset to set. |
rx2DataRate | The data rate to use for the second receive window. |
frequencyHz | The frequency [Hz] to use for the second receive window. |
Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac.
Referenced by ParseCommands().
void ns3::lorawan::EndDeviceLorawanMac::ParseCommands | ( | LoraFrameHeader | frameHeader | ) |
Parse and take action on the commands contained on this FrameHeader.
frameHeader | The 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().
|
virtual |
Postpone transmission to the specified time and delete previously scheduled transmissions if present.
nextTxDelay | Delay at which the transmission will be performed. |
packet | The 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().
Receive a packet from the lower layer.
packet | The received packet. |
Implements ns3::lorawan::LorawanMac.
Definition at line 324 of file end-device-lorawan-mac.cc.
|
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().
Send a packet.
The MAC layer of the end device will take care of using the right parameters.
packet | The 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().
Add headers and send a packet with the sending function of the physical layer.
packet | The packet to send. |
Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.
Definition at line 315 of file end-device-lorawan-mac.cc.
Referenced by DoSend().
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.
dataRate | The dataRate to use when transmitting. |
Definition at line 584 of file end-device-lorawan-mac.cc.
References m_dataRate, and NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceLorawanMac::SetDeviceAddress | ( | LoraDeviceAddress | address | ) |
Set the network address of this device.
address | The address to set. |
Definition at line 614 of file end-device-lorawan-mac.cc.
References m_address, and NS_LOG_FUNCTION.
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.
nbTrans | The number of transmissions. |
Definition at line 569 of file end-device-lorawan-mac.cc.
References m_nbTrans, m_retxParams, and NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceLorawanMac::SetMType | ( | LorawanMacHeader::MType | mType | ) |
Set the message type to send when the Send method is called.
mType | The message type. |
Definition at line 458 of file end-device-lorawan-mac.cc.
References m_mType, and NS_LOG_DEBUG.
void ns3::lorawan::EndDeviceLorawanMac::SetTransmissionPowerDbm | ( | double | txPowerDbm | ) |
Set the transmission power of this end device.
txPowerDbm | The transmission ERP [dBm] value. |
Definition at line 600 of file end-device-lorawan-mac.cc.
References m_txPowerDbm, and NS_LOG_FUNCTION.
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.
adr | The ADR bit. |
Definition at line 555 of file end-device-lorawan-mac.cc.
References m_adr, and NS_LOG_FUNCTION.
Perform actions after sending a packet.
packet | The packet that just finished transmission. |
Implements ns3::lorawan::LorawanMac.
Definition at line 471 of file end-device-lorawan-mac.cc.
|
protected |
The address of this device.
Definition at line 339 of file end-device-lorawan-mac.h.
Referenced by EndDeviceLorawanMac(), ApplyNecessaryOptions(), GetDeviceAddress(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), and SetDeviceAddress().
|
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().
|
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().
|
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().
|
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().
|
protected |
The data rate this device is using to transmit.
Definition at line 333 of file end-device-lorawan-mac.h.
Referenced by EndDeviceLorawanMac(), DoSend(), GetChannelForTx(), GetDataRate(), ns3::lorawan::ClassAEndDeviceLorawanMac::GetFirstReceiveWindowDataRate(), GetTypeId(), OnLinkAdrReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OnRxParamSetupReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetDataRate().
|
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().
|
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().
|
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().
|
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().
|
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().
|
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().
|
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().
|
protected |
Default number of unacknowledged redundant transmissions of each packet.
Definition at line 332 of file end-device-lorawan-mac.h.
Referenced by EndDeviceLorawanMac(), ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), DoSend(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), GetMaxNumberOfTransmissions(), GetTypeId(), OnLinkAdrReq(), ParseCommands(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), resetRetransmissionParameters(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetMaxNumberOfTransmissions().
|
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.
|
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().
|
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().
|
protected |
The trace source fired when the transmission procedure is finished.
Definition at line 398 of file end-device-lorawan-mac.h.
Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), DoSend(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), GetTypeId(), ParseCommands(), and ns3::lorawan::ClassAEndDeviceLorawanMac::Receive().
|
protected |
Structure containing the retransmission parameters for this device.
Definition at line 379 of file end-device-lorawan-mac.h.
Referenced by EndDeviceLorawanMac(), ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), DoSend(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay(), ParseCommands(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), resetRetransmissionParameters(), Send(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetMaxNumberOfTransmissions().
|
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().
|
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().