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 | 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< NetDevice > | GetDevice () |
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< 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. | |
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< 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. | |
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. | |
SimpleRefCount & | operator= (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< LogicalLoraChannel > | GetChannelForTx () |
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< double > | m_txPower |
The transmission power this device is using to transmit. | |
Ptr< UniformRandomVariable > | m_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< 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. | |
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 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< double > | m_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< double > | m_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. | |
Related Functions inherited from ns3::ObjectBase | |
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 44 of file end-device-lorawan-mac.h.
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.
|
override |
Destructor.
Definition at line 146 of file end-device-lorawan-mac.cc.
References NS_LOG_FUNCTION_NOARGS.
void ns3::lorawan::EndDeviceLorawanMac::AddLogicalChannel | ( | double | frequency | ) |
Add a logical channel to the helper.
frequency | The 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.
void ns3::lorawan::EndDeviceLorawanMac::AddLogicalChannel | ( | Ptr< LogicalLoraChannel > | logicalChannel | ) |
Add a logical channel to the helper.
logicalChannel | The 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.
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 920 of file end-device-lorawan-mac.cc.
References m_macCommandList, and NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceLorawanMac::AddSubBand | ( | double | startFrequency, |
double | endFrequency, | ||
double | dutyCycle, | ||
double | maxTxPowerDbm | ||
) |
Add a subband to the logical channel helper.
startFrequency | The SubBand's lowest frequency. |
endFrequency | The SubBand's highest frequency. |
dutyCycle | The SubBand's duty cycle, in fraction form. |
maxTxPowerDbm | The 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.
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 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().
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 484 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 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().
|
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 335 of file end-device-lorawan-mac.cc.
double ns3::lorawan::EndDeviceLorawanMac::GetAggregatedDutyCycle | ( | ) |
**
** Get the aggregated duty cycle.
Definition at line 912 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 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().
uint8_t ns3::lorawan::EndDeviceLorawanMac::GetDataRate | ( | ) |
Get the data rate this end device is set to use.
Definition at line 662 of file end-device-lorawan-mac.cc.
References m_dataRate, and NS_LOG_FUNCTION.
bool ns3::lorawan::EndDeviceLorawanMac::GetDataRateAdaptation | ( | ) | const |
Get if data rate adaptation is enabled or not.
Definition at line 633 of file end-device-lorawan-mac.cc.
References m_enableDRAdapt.
LoraDeviceAddress ns3::lorawan::EndDeviceLorawanMac::GetDeviceAddress | ( | ) |
Get the network address of this device.
Definition at line 678 of file end-device-lorawan-mac.cc.
References m_address, and NS_LOG_FUNCTION.
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 647 of file end-device-lorawan-mac.cc.
References m_maxNumbTx, 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 500 of file end-device-lorawan-mac.cc.
References m_mType.
|
protectedvirtual |
Find the minimum waiting time before the next possible transmission based on end device's Class Type.
waitingTime | Currently known minimum waiting time, possibly raised by this function. |
Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.
Definition at line 511 of file end-device-lorawan-mac.cc.
References NS_LOG_FUNCTION_NOARGS.
Referenced by GetNextTransmissionDelay().
|
private |
Find the base minimum waiting time before the next possible transmission.
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().
|
virtual |
Get the transmission power this end device is set to use.
Definition at line 928 of file end-device-lorawan-mac.cc.
References m_txPower.
|
static |
Register this type.
Definition at line 43 of file end-device-lorawan-mac.cc.
References ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP, m_aggregatedDutyCycle, m_controlDataRate, m_dataRate, m_enableDRAdapt, m_lastKnownGatewayCount, m_lastKnownLinkMargin, m_maxNumbTx, m_mType, m_requiredTxCallback, m_txPower, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeEnumChecker(), ns3::MakeIntegerAccessor(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::TypeId::SetParent(), and ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_UP.
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().
void ns3::lorawan::EndDeviceLorawanMac::OnDutyCycleReq | ( | double | dutyCycle | ) |
Perform the actions that need to be taken when receiving a DutyCycleReq command.
dutyCycle | The 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().
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.
dataRate | The data rate value of the command. |
txPower | The transmission power value of the command. |
enabledChannels | A list of the enabled channels. |
repetitions | The 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().
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 686 of file end-device-lorawan-mac.cc.
References m_lastKnownGatewayCount, m_lastKnownLinkMargin, and NS_LOG_FUNCTION.
Referenced by ParseCommands().
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.
chIndex | The ChIndex field of the received NewChannelReq command. |
frequency | The Frequency 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 851 of file end-device-lorawan-mac.cc.
References m_macCommandList, NS_LOG_FUNCTION, NS_LOG_INFO, and SetLogicalChannel().
Referenced by ParseCommands().
|
virtual |
Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Device's Class Type.
rxParamSetupReq | The Parameter Setup Request. |
Reimplemented in ns3::lorawan::ClassAEndDeviceLorawanMac.
Definition at line 824 of file end-device-lorawan-mac.cc.
Referenced by OnRxParamSetupReq().
void ns3::lorawan::EndDeviceLorawanMac::OnRxParamSetupReq | ( | Ptr< RxParamSetupReq > | rxParamSetupReq | ) |
Perform the actions that need to be taken when receiving a RxParamSetupReq command.
rxParamSetupReq | The Parameter Setup Request. |
Definition at line 829 of file end-device-lorawan-mac.cc.
References NS_LOG_FUNCTION, and OnRxClassParamSetupReq().
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 340 of file end-device-lorawan-mac.cc.
References ns3::lorawan::DEV_STATUS_REQ, ns3::lorawan::DL_CHANNEL_REQ, ns3::lorawan::DUTY_CYCLE_REQ, ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::firstAttempt, ns3::lorawan::LoraFrameHeader::GetAck(), ns3::lorawan::LoraFrameHeader::GetCommands(), ns3::lorawan::LINK_ADR_REQ, ns3::lorawan::LINK_CHECK_ANS, m_maxNumbTx, 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(), ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::packet, resetRetransmissionParameters(), ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::retxLeft, ns3::lorawan::RX_PARAM_SETUP_REQ, ns3::lorawan::RX_TIMING_SETUP_REQ, ns3::lorawan::TX_PARAM_SETUP_REQ, and ns3::lorawan::EndDeviceLorawanMac::LoraRetxParameters::waitingAck.
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 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().
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.
packet | The received packet. |
Implements ns3::lorawan::LorawanMac.
Definition at line 330 of file end-device-lorawan-mac.cc.
|
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().
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 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().
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 321 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 654 of file end-device-lorawan-mac.cc.
References m_dataRate, and NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceLorawanMac::SetDataRateAdaptation | ( | bool | adapt | ) |
Enable data rate adaptation in the retransmitting procedure.
adapt | If 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.
void ns3::lorawan::EndDeviceLorawanMac::SetDeviceAddress | ( | LoraDeviceAddress | address | ) |
Set the network address of this device.
address | The address to set. |
Definition at line 670 of file end-device-lorawan-mac.cc.
References m_address, and NS_LOG_FUNCTION.
void ns3::lorawan::EndDeviceLorawanMac::SetLogicalChannel | ( | uint8_t | chIndex, |
double | frequency, | ||
uint8_t | minDataRate, | ||
uint8_t | maxDataRate | ||
) |
Set a new logical channel in the helper.
chIndex | The channel's new index. |
frequency | The channel's center frequency. |
minDataRate | The minimum data rate allowed on the channel. |
maxDataRate | The 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().
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.
maxNumbTx | The 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.
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 493 of file end-device-lorawan-mac.cc.
References m_mType, and NS_LOG_DEBUG.
|
private |
Randomly shuffle a Ptr<LogicalLoraChannel> vector.
Used to pick a random channel on which to send the packet.
vector | The vector of pointers to logical LoRa channels. |
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().
Perform the actions that are required after a packet send.
This function handles opening of the first receive window.
packet | The packet that has just been transmitted. |
Implements ns3::lorawan::LorawanMac.
Definition at line 506 of file end-device-lorawan-mac.cc.
|
protected |
The address of this device.
Definition at line 395 of file end-device-lorawan-mac.h.
Referenced by ApplyNecessaryOptions(), GetDeviceAddress(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), and SetDeviceAddress().
|
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().
|
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().
|
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().
|
private |
current value of the device frame counter.
Definition at line 522 of file end-device-lorawan-mac.h.
Referenced by ApplyNecessaryOptions(), and DoSend().
|
protected |
The data rate this device is using to transmit.
Definition at line 390 of file end-device-lorawan-mac.h.
Referenced by DoSend(), GetDataRate(), ns3::lorawan::ClassAEndDeviceLorawanMac::GetFirstReceiveWindowDataRate(), GetTypeId(), OnLinkAdrReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetDataRate().
|
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().
|
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().
|
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().
|
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().
|
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().
|
protected |
Default number of unacknowledged redundant transmissions of each packet.
Definition at line 389 of file end-device-lorawan-mac.h.
Referenced by EndDeviceLorawanMac(), ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), DoSend(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), GetMaxNumberOfTransmissions(), GetTypeId(), ParseCommands(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), resetRetransmissionParameters(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetMaxNumberOfTransmissions().
|
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().
|
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.
|
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().
|
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().
|
protected |
The trace source fired when the transmission procedure is finished.
Definition at line 450 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 435 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 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().
|
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().