Class representing the LoRaWAN MAC layer. More...
#include "lorawan-mac.h"
Public Types | |
typedef std::array< std::array< uint8_t, 6 >, 8 > | ReplyDataRateMatrix |
Matrix structure to store possible data rate value to be used by a LoRaWAN end device for listening during the RX1 receive window. | |
Public Member Functions | |
LorawanMac () | |
Default constructor. | |
~LorawanMac () override | |
Destructor. | |
virtual void | FailedReception (Ptr< const Packet > packet)=0 |
Function called by lower layers to inform this layer that reception of a packet we were locked on failed. | |
double | GetBandwidthFromDataRate (uint8_t dataRate) |
Get the bandwidth corresponding to a data rate, based on this MAC's region. | |
double | GetDbmForTxPower (uint8_t txPower) |
Get the transmission power in dBm that corresponds, in this region, to the encoded 8-bit txPower. | |
Ptr< 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. | |
virtual void | Receive (Ptr< const Packet > packet)=0 |
Receive a packet from the lower layer. | |
virtual void | Send (Ptr< Packet > packet)=0 |
Send a packet. | |
void | SetBandwidthForDataRate (std::vector< double > bandwidthForDataRate) |
Set the vector to use to check up correspondence between bandwidth and data rate. | |
void | SetDevice (Ptr< NetDevice > device) |
Set the device this MAC layer is installed on. | |
void | SetLogicalLoraChannelHelper (Ptr< LogicalLoraChannelHelper > helper) |
Set the LogicalLoraChannelHelper this MAC instance will use. | |
void | SetMaxAppPayloadForDataRate (std::vector< uint32_t > maxAppPayloadForDataRate) |
Set the maximum App layer payload for a set data rate. | |
void | SetNPreambleSymbols (int nPreambleSymbols) |
Set the number of PHY preamble symbols this MAC is set to use. | |
void | SetPhy (Ptr< LoraPhy > phy) |
Set the underlying PHY layer. | |
void | SetReplyDataRateMatrix (ReplyDataRateMatrix replyDataRateMatrix) |
Set the matrix to use when deciding with which data rate to respond. | |
void | SetSfForDataRate (std::vector< uint8_t > sfForDataRate) |
Set the vector to use to check up correspondence between spreading factor and data rate. | |
void | SetTxDbmForTxPower (std::vector< double > txDbmForTxPower) |
Set the vector to use to check up which transmission power in Dbm corresponds to a certain TxPower value in this MAC's region. | |
virtual void | TxFinished (Ptr< const Packet > packet)=0 |
Perform actions after sending a packet. | |
Public Member Functions inherited from ns3::Object | |
Object () | |
Constructor. | |
~Object () override | |
Destructor. | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. | |
void | Dispose () |
Dispose of this Object. | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. | |
template<> | |
Ptr< 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, bool permissive=false) const |
Get the value of an attribute, raising fatal errors if unsuccessful. | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. | |
Protected Attributes | |
std::vector< 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. | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
Copy an Object. | |
virtual void | DoDispose () |
Destructor implementation. | |
virtual void | DoInitialize () |
Initialize() implementation. | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. | |
Related Symbols inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Class representing the LoRaWAN MAC layer.
This class is meant to be extended differently based on whether the layer belongs to an end device or a gateway, while holding some functionality that is common to both.
Definition at line 36 of file lorawan-mac.h.
typedef std::array<std::array<uint8_t, 6>, 8> ns3::lorawan::LorawanMac::ReplyDataRateMatrix |
Matrix structure to store possible data rate value to be used by a LoRaWAN end device for listening during the RX1 receive window.
It is a function of the uplink data rate and the RX1DROffset [0:5].
Definition at line 53 of file lorawan-mac.h.
ns3::lorawan::LorawanMac::LorawanMac | ( | ) |
|
override |
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. |
Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac, ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.
Referenced by SetPhy().
double ns3::lorawan::LorawanMac::GetBandwidthFromDataRate | ( | uint8_t | dataRate | ) |
Get the bandwidth corresponding to a data rate, based on this MAC's region.
dataRate | The data rate we need to convert to a bandwidth value. |
Definition at line 114 of file lorawan-mac.cc.
References m_bandwidthForDataRate, and NS_LOG_FUNCTION.
Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay(), ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OnRxClassParamSetupReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow(), ns3::lorawan::GatewayLorawanMac::Send(), and ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy().
double ns3::lorawan::LorawanMac::GetDbmForTxPower | ( | uint8_t | txPower | ) |
Get the transmission power in dBm that corresponds, in this region, to the encoded 8-bit txPower.
txPower | The 8-bit encoded txPower to convert. |
Definition at line 128 of file lorawan-mac.cc.
References m_txDbmForTxPower, and NS_LOG_FUNCTION.
Referenced by ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq().
Get the device this MAC layer is installed on.
Definition at line 64 of file lorawan-mac.cc.
References m_device.
Ptr< LogicalLoraChannelHelper > ns3::lorawan::LorawanMac::GetLogicalLoraChannelHelper | ( | ) |
Get the logical lora channel helper associated with this MAC.
Definition at line 88 of file lorawan-mac.cc.
References m_channelHelper.
int ns3::lorawan::LorawanMac::GetNPreambleSymbols | ( | ) | const |
Get the number of PHY preamble symbols this MAC is set to use.
Definition at line 171 of file lorawan-mac.cc.
References m_nPreambleSymbols.
Get the underlying PHY layer.
Definition at line 70 of file lorawan-mac.cc.
References m_phy.
uint8_t ns3::lorawan::LorawanMac::GetSfFromDataRate | ( | uint8_t | dataRate | ) |
Get the spreading factor corresponding to a data rate, based on this MAC's region.
dataRate | The data rate we need to convert to a Spreading Factor value. |
Definition at line 100 of file lorawan-mac.cc.
References m_sfForDataRate, and NS_LOG_FUNCTION.
Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetNextClassTransmissionDelay(), ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OnRxClassParamSetupReq(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow(), ns3::lorawan::GatewayLorawanMac::Send(), and ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy().
|
static |
Register this type.
Definition at line 23 of file lorawan-mac.cc.
References m_cannotSendBecauseDutyCycle, m_receivedPacket, m_sentNewPacket, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
Receive a packet from the lower layer.
packet | The received packet. |
Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac, ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.
Referenced by SetPhy().
Send a packet.
packet | The packet to send. |
Implemented in ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.
void ns3::lorawan::LorawanMac::SetBandwidthForDataRate | ( | std::vector< double > | bandwidthForDataRate | ) |
Set the vector to use to check up correspondence between bandwidth and data rate.
bandwidthForDataRate | A vector that contains at position i the bandwidth that should correspond to data rate i in this MAC's region. |
Definition at line 147 of file lorawan-mac.cc.
References m_bandwidthForDataRate.
Set the device this MAC layer is installed on.
device | The NetDevice this MAC layer will refer to. |
Definition at line 58 of file lorawan-mac.cc.
References m_device.
void ns3::lorawan::LorawanMac::SetLogicalLoraChannelHelper | ( | Ptr< LogicalLoraChannelHelper > | helper | ) |
Set the LogicalLoraChannelHelper this MAC instance will use.
helper | A Ptr to the instance of the helper to use. |
Definition at line 94 of file lorawan-mac.cc.
References m_channelHelper.
void ns3::lorawan::LorawanMac::SetMaxAppPayloadForDataRate | ( | std::vector< uint32_t > | maxAppPayloadForDataRate | ) |
Set the maximum App layer payload for a set data rate.
maxAppPayloadForDataRate | A vector that contains at position i the maximum Application layer payload that should correspond to data rate i in this MAC's region. |
Definition at line 153 of file lorawan-mac.cc.
References m_maxAppPayloadForDataRate.
void ns3::lorawan::LorawanMac::SetNPreambleSymbols | ( | int | nPreambleSymbols | ) |
Set the number of PHY preamble symbols this MAC is set to use.
nPreambleSymbols | The number of preamble symbols to use (typically 8). |
Definition at line 165 of file lorawan-mac.cc.
References m_nPreambleSymbols.
Set the underlying PHY layer.
phy | The phy layer. |
Definition at line 76 of file lorawan-mac.cc.
References FailedReception(), m_phy, ns3::MakeCallback(), Receive(), and TxFinished().
void ns3::lorawan::LorawanMac::SetReplyDataRateMatrix | ( | ReplyDataRateMatrix | replyDataRateMatrix | ) |
Set the matrix to use when deciding with which data rate to respond.
Region based.
replyDataRateMatrix | A matrix containing the reply DataRates, based on the sending data rate and on the value of the RX1DROffset parameter. |
Definition at line 177 of file lorawan-mac.cc.
References m_replyDataRateMatrix.
void ns3::lorawan::LorawanMac::SetSfForDataRate | ( | std::vector< uint8_t > | sfForDataRate | ) |
Set the vector to use to check up correspondence between spreading factor and data rate.
sfForDataRate | A vector that contains at position i the spreading factor that should correspond to data rate i. |
Definition at line 141 of file lorawan-mac.cc.
References m_sfForDataRate.
void ns3::lorawan::LorawanMac::SetTxDbmForTxPower | ( | std::vector< double > | txDbmForTxPower | ) |
Set the vector to use to check up which transmission power in Dbm corresponds to a certain TxPower value in this MAC's region.
txDbmForTxPower | A vector that contains at position i the transmission power in dBm that should correspond to a TXPOWER value of i in this MAC's region. |
Definition at line 159 of file lorawan-mac.cc.
References m_txDbmForTxPower.
Perform actions after sending a packet.
packet | The packet that just finished transmission. |
Implemented in ns3::lorawan::ClassAEndDeviceLorawanMac, ns3::lorawan::EndDeviceLorawanMac, and ns3::lorawan::GatewayLorawanMac.
Referenced by SetPhy().
|
protected |
A vector holding the bandwidth each data rate corresponds to.
Definition at line 256 of file lorawan-mac.h.
Referenced by GetBandwidthFromDataRate(), and SetBandwidthForDataRate().
|
protected |
The trace source that is fired when a packet cannot be sent because of duty cycle limitations.
Definition at line 220 of file lorawan-mac.h.
Referenced by GetTypeId(), and ns3::lorawan::EndDeviceLorawanMac::Send().
|
protected |
The LogicalLoraChannelHelper instance that is assigned to this MAC.
Definition at line 246 of file lorawan-mac.h.
Referenced by ns3::lorawan::EndDeviceLorawanMac::AddLogicalChannel(), ns3::lorawan::EndDeviceLorawanMac::AddLogicalChannel(), ns3::lorawan::EndDeviceLorawanMac::AddSubBand(), ns3::lorawan::EndDeviceLorawanMac::GetChannelForTx(), GetLogicalLoraChannelHelper(), ns3::lorawan::EndDeviceLorawanMac::GetNextTransmissionDelay(), ns3::lorawan::GatewayLorawanMac::GetWaitingTime(), ns3::lorawan::EndDeviceLorawanMac::OnLinkAdrReq(), ns3::lorawan::GatewayLorawanMac::Send(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), ns3::lorawan::EndDeviceLorawanMac::SetLogicalChannel(), and SetLogicalLoraChannelHelper().
The device this MAC layer is installed on.
Definition at line 241 of file lorawan-mac.h.
Referenced by GetDevice(), ns3::lorawan::GatewayLorawanMac::Receive(), and SetDevice().
|
protected |
A vector holding the maximum app payload size that corresponds to a certain data rate.
Definition at line 262 of file lorawan-mac.h.
Referenced by ns3::lorawan::EndDeviceLorawanMac::DoSend(), and SetMaxAppPayloadForDataRate().
|
protected |
The number of symbols to use in the PHY preamble.
Definition at line 267 of file lorawan-mac.h.
Referenced by GetNPreambleSymbols(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), and SetNPreambleSymbols().
The PHY instance that sits under this MAC layer.
Definition at line 236 of file lorawan-mac.h.
Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::CloseFirstReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::CloseSecondReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::FailedReception(), GetPhy(), ns3::lorawan::GatewayLorawanMac::IsTransmitting(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenFirstReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::OpenSecondReceiveWindow(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), ns3::lorawan::GatewayLorawanMac::Send(), ns3::lorawan::ClassAEndDeviceLorawanMac::SendToPhy(), SetPhy(), and ns3::lorawan::ClassAEndDeviceLorawanMac::TxFinished().
|
protected |
Trace source that is fired when a packet reaches the MAC layer.
Definition at line 225 of file lorawan-mac.h.
Referenced by GetTypeId(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), and ns3::lorawan::GatewayLorawanMac::Receive().
|
protected |
The matrix that decides the data rate the gateway will use in a reply based on the end device's sending data rate and on the value of the RX1DROffset parameter.
Definition at line 278 of file lorawan-mac.h.
Referenced by ns3::lorawan::ClassAEndDeviceLorawanMac::GetFirstReceiveWindowDataRate(), and SetReplyDataRateMatrix().
|
protected |
Trace source that is fired when a new APP layer packet arrives at the MAC layer.
Definition at line 231 of file lorawan-mac.h.
Referenced by ns3::lorawan::EndDeviceLorawanMac::DoSend(), GetTypeId(), and ns3::lorawan::GatewayLorawanMac::Send().
|
protected |
A vector holding the spreading factor each data rate corresponds to.
Definition at line 251 of file lorawan-mac.h.
Referenced by GetSfFromDataRate(), and SetSfForDataRate().
|
protected |
A vector holding the power that corresponds to a certain TxPower value.
Definition at line 272 of file lorawan-mac.h.
Referenced by GetDbmForTxPower(), and SetTxDbmForTxPower().