Class representing a LoRa transceiver. More...
#include "end-device-lora-phy.h"
Public Types | |
enum | State { SLEEP , STANDBY , TX , RX } |
An enumeration of the possible states of an EndDeviceLoraPhy. More... | |
![]() | |
typedef Callback< void, Ptr< const Packet > > | RxFailedCallback |
Type definition for a callback for when a packet reception fails. | |
typedef Callback< void, Ptr< const Packet > > | RxOkCallback |
Type definition for a callback for when a packet is correctly received. | |
typedef Callback< void, Ptr< const Packet > > | TxFinishedCallback |
Type definition for a callback to call when a packet has finished sending. | |
Public Member Functions | |
EndDeviceLoraPhy () | |
Default constructor. | |
~EndDeviceLoraPhy () override | |
Destructor. | |
void | EndReceive (Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event) override=0 |
Finish reception of a packet. | |
uint8_t | GetSpreadingFactor () const |
Get the Spreading Factor this end device is listening for. | |
EndDeviceLoraPhy::State | GetState () |
Return the state this end device is currently in. | |
bool | IsOnFrequency (uint32_t frequencyHz) override |
Whether this device is listening on the specified frequency or not. | |
bool | IsTransmitting () override |
Whether this device is transmitting or not. | |
void | RegisterListener (EndDeviceLoraPhyListener *listener) |
Add the input listener to the list of objects to be notified of PHY-level events. | |
void | Send (Ptr< Packet > packet, LoraTxParameters txParams, uint32_t frequencyHz, double txPowerDbm) override=0 |
Instruct the PHY to send a packet according to some parameters. | |
void | SetFrequency (uint32_t frequencyHz) |
Set the frequency this end device will listen on. | |
void | SetSpreadingFactor (uint8_t sf) |
Set the Spreading Factor this end device will listen for. | |
void | StartReceive (Ptr< Packet > packet, double rxPowerDbm, uint8_t sf, Time duration, uint32_t frequencyHz) override=0 |
Start receiving a packet. | |
void | SwitchToSleep () |
Switch to the SLEEP state. | |
void | SwitchToStandby () |
Switch to the STANDBY state. | |
void | UnregisterListener (EndDeviceLoraPhyListener *listener) |
Remove the input listener from the list of objects to be notified of PHY-level events. | |
![]() | |
LoraPhy () | |
Default constructor. | |
~LoraPhy () override | |
Destructor. | |
Ptr< LoraChannel > | GetChannel () const |
Get the channel instance associated to this PHY. | |
Ptr< NetDevice > | GetDevice () const |
Get the NetDevice associated to this PHY. | |
Ptr< MobilityModel > | GetMobility () |
Get the mobility model associated to this PHY. | |
void | SetChannel (Ptr< LoraChannel > channel) |
Set the LoraChannel instance PHY transmits on. | |
void | SetDevice (Ptr< NetDevice > device) |
Set the NetDevice that owns this PHY. | |
void | SetMobility (Ptr< MobilityModel > mobility) |
Set the mobility model associated to this PHY. | |
void | SetReceiveFailedCallback (RxFailedCallback callback) |
Set the callback to call upon failed reception of a packet we were previously locked on. | |
void | SetReceiveOkCallback (RxOkCallback callback) |
Set the callback to call upon successful reception of a packet. | |
void | SetTxFinishedCallback (TxFinishedCallback callback) |
Set the callback to call after transmission of a packet. | |
![]() | |
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 Time | GetOnAirTime (Ptr< Packet > packet, LoraTxParameters txParams) |
Compute the time that a packet with certain characteristics will take to be transmitted. | |
static Time | GetTSym (LoraTxParameters txParams) |
Compute the symbol time from spreading factor and bandwidth. | |
static TypeId | GetTypeId () |
Register this type. | |
![]() | |
static TypeId | GetTypeId () |
Register this type. | |
![]() | |
static TypeId | GetTypeId () |
Get the type ID. | |
Static Public Attributes | |
static const double | sensitivity [6] = {-124, -127, -130, -133, -135, -137} |
The sensitivity vector of this device to different SFs. | |
Protected Types | |
typedef std::vector< EndDeviceLoraPhyListener * > | Listeners |
typedef for a list of EndDeviceLoraPhyListener. | |
typedef std::vector< EndDeviceLoraPhyListener * >::iterator | ListenersI |
typedef for a list of EndDeviceLoraPhyListener iterator. | |
Protected Member Functions | |
void | SwitchToRx () |
Switch to the RX state. | |
void | SwitchToTx (double txPowerDbm) |
Switch to the TX state. | |
void | TxFinished (Ptr< const Packet > packet) override |
Signals the end of a transmission by the EndDeviceLoraPhy. | |
![]() | |
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 | |
uint32_t | m_frequencyHz |
The frequency [Hz] this device is listening on. | |
Listeners | m_listeners |
PHY listeners. | |
uint8_t | m_sf |
The Spreading Factor this device is listening for. | |
TracedValue< State > | m_state |
The state this PHY is currently in. | |
TracedCallback< Ptr< const Packet >, uint32_t > | m_wrongFrequency |
Trace source for when a packet is lost because it was transmitted on a frequency different from the one this EndDeviceLoraPhy was configured to listen on. | |
TracedCallback< Ptr< const Packet >, uint32_t > | m_wrongSf |
Trace source for when a packet is lost because it was using a spreading factor different from the one this EndDeviceLoraPhy was configured to listen for. | |
![]() | |
Ptr< LoraChannel > | m_channel |
The channel this PHY transmits on. | |
Ptr< NetDevice > | m_device |
The net device this PHY is attached to. | |
TracedCallback< Ptr< const Packet >, uint32_t > | m_interferedPacket |
The trace source fired when a packet cannot be correctly received because of interference. | |
LoraInterferenceHelper | m_interference |
The LoraInterferenceHelper associated to this PHY. | |
TracedCallback< Ptr< const Packet > > | m_phyRxBeginTrace |
The trace source fired when a packet begins the reception process from the medium. | |
TracedCallback< Ptr< const Packet > > | m_phyRxEndTrace |
The trace source fired when a packet reception ends. | |
RxFailedCallback | m_rxFailedCallback |
The callback to perform upon failed reception of a packet we were locked on. | |
RxOkCallback | m_rxOkCallback |
The callback to perform upon correct reception of a packet. | |
TracedCallback< Ptr< const Packet >, uint32_t > | m_startSending |
The trace source fired when a packet is sent. | |
TracedCallback< Ptr< const Packet >, uint32_t > | m_successfullyReceivedPacket |
The trace source fired when a packet was correctly received. | |
TxFinishedCallback | m_txFinishedCallback |
The callback to perform upon the end of a transmission. | |
TracedCallback< Ptr< const Packet >, uint32_t > | m_underSensitivity |
The trace source fired when a packet cannot be received because its power is below the sensitivity threshold. | |
Additional Inherited Members | |
![]() | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Class representing a LoRa transceiver.
This class inherits some functionality by LoraPhy, like the GetOnAirTime function, and extends it to represent the behavior of a LoRa chip, like the SX1272.
Additional behaviors featured in this class include a State member variable that expresses the current state of the device (SLEEP, TX, RX or STANDBY), and a frequency and Spreading Factor this device is listening to when in STANDBY mode. After transmission and reception, the device returns automatically to STANDBY mode. The decision of when to go into SLEEP mode is delegateed to an upper layer, which can modify the state of the device through the public SwitchToSleep and SwitchToStandby methods. In SLEEP mode, the device cannot lock on a packet and start reception.
Peculiarities about the error model and about how errors are handled are supposed to be handled by classes extending this one, like SimpleEndDeviceLoraPhy or SpectrumEndDeviceLoraPhy. These classes need to
Definition at line 96 of file end-device-lora-phy.h.
|
protected |
typedef for a list of EndDeviceLoraPhyListener.
Definition at line 273 of file end-device-lora-phy.h.
|
protected |
typedef for a list of EndDeviceLoraPhyListener iterator.
Definition at line 277 of file end-device-lora-phy.h.
An enumeration of the possible states of an EndDeviceLoraPhy.
It makes sense to define a state for End Devices since there's only one demodulator which can either send, receive, stay idle or go in a deep sleep state.
Definition at line 105 of file end-device-lora-phy.h.
ns3::lorawan::EndDeviceLoraPhy::EndDeviceLoraPhy | ( | ) |
Default constructor.
Definition at line 63 of file end-device-lora-phy.cc.
References m_frequencyHz, m_sf, m_state, and SLEEP.
Referenced by ns3::lorawan::SimpleEndDeviceLoraPhy::GetTypeId().
|
override |
Destructor.
Definition at line 70 of file end-device-lora-phy.cc.
|
overridepure virtual |
Finish reception of a packet.
This method is scheduled by StartReceive, based on the packet duration. By passing a LoraInterferenceHelper Event to this method, the class will be able to identify the packet that is being received among all those that were registered as interference by StartReceive.
packet | The received packet. |
event | The event that is tied to this packet in the LoraInterferenceHelper. |
Implements ns3::lorawan::LoraPhy.
Implemented in ns3::lorawan::SimpleEndDeviceLoraPhy.
uint8_t ns3::lorawan::EndDeviceLoraPhy::GetSpreadingFactor | ( | ) | const |
Get the Spreading Factor this end device is listening for.
Definition at line 86 of file end-device-lora-phy.cc.
References m_sf.
EndDeviceLoraPhy::State ns3::lorawan::EndDeviceLoraPhy::GetState | ( | ) |
Return the state this end device is currently in.
Definition at line 186 of file end-device-lora-phy.cc.
References m_state, and NS_LOG_FUNCTION_NOARGS.
|
static |
Register this type.
Definition at line 36 of file end-device-lora-phy.cc.
References ns3::lorawan::LoraPhy::LoraPhy(), m_state, m_wrongFrequency, m_wrongSf, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
|
overridevirtual |
Whether this device is listening on the specified frequency or not.
frequencyHz | The frequency [Hz] to query. |
Implements ns3::lorawan::LoraPhy.
Definition at line 98 of file end-device-lora-phy.cc.
References m_frequencyHz.
Referenced by ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().
|
overridevirtual |
Whether this device is transmitting or not.
Implements ns3::lorawan::LoraPhy.
Definition at line 92 of file end-device-lora-phy.cc.
void ns3::lorawan::EndDeviceLoraPhy::RegisterListener | ( | EndDeviceLoraPhyListener * | listener | ) |
Add the input listener to the list of objects to be notified of PHY-level events.
listener | The new listener. |
Definition at line 194 of file end-device-lora-phy.cc.
References m_listeners.
|
overridepure virtual |
Instruct the PHY to send a packet according to some parameters.
packet | The packet to send. |
txParams | The desired transmission parameters. |
frequencyHz | The frequency on which to transmit. |
txPowerDbm | The power in dBm with which to transmit the packet. |
Implements ns3::lorawan::LoraPhy.
Implemented in ns3::lorawan::SimpleEndDeviceLoraPhy.
void ns3::lorawan::EndDeviceLoraPhy::SetFrequency | ( | uint32_t | frequencyHz | ) |
Set the frequency this end device will listen on.
Should a packet be transmitted on a frequency different than that the EndDeviceLoraPhy is listening on, the packet will be discarded.
frequencyHz | The frequency [Hz] to listen to. |
Definition at line 104 of file end-device-lora-phy.cc.
References m_frequencyHz.
void ns3::lorawan::EndDeviceLoraPhy::SetSpreadingFactor | ( | uint8_t | sf | ) |
Set the Spreading Factor this end device will listen for.
The EndDeviceLoraPhy object will not be able to lock on transmissions that use a different spreading factor than the one it's listening for.
sf | The spreading factor to listen for. |
Definition at line 80 of file end-device-lora-phy.cc.
References m_sf.
|
overridepure virtual |
Start receiving a packet.
This method is typically called by LoraChannel.
packet | The packet that is arriving at this PHY layer. |
rxPowerDbm | The power of the arriving packet (assumed to be constant for the whole reception). |
sf | The Spreading Factor of the arriving packet. |
duration | The on air time of this packet. |
frequencyHz | The frequency this packet is being transmitted on. |
Implements ns3::lorawan::LoraPhy.
Implemented in ns3::lorawan::SimpleEndDeviceLoraPhy.
|
protected |
Switch to the RX state.
Definition at line 138 of file end-device-lora-phy.cc.
References m_listeners, m_state, NS_ASSERT, NS_LOG_FUNCTION_NOARGS, RX, and STANDBY.
Referenced by ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().
void ns3::lorawan::EndDeviceLoraPhy::SwitchToSleep | ( | ) |
Switch to the SLEEP state.
Definition at line 170 of file end-device-lora-phy.cc.
References m_listeners, m_state, NS_ASSERT, NS_LOG_FUNCTION_NOARGS, SLEEP, and STANDBY.
void ns3::lorawan::EndDeviceLoraPhy::SwitchToStandby | ( | ) |
Switch to the STANDBY state.
Definition at line 124 of file end-device-lora-phy.cc.
References m_listeners, m_state, NS_LOG_FUNCTION_NOARGS, and STANDBY.
Referenced by ns3::lorawan::SimpleEndDeviceLoraPhy::EndReceive(), and TxFinished().
|
protected |
Switch to the TX state.
txPowerDbm | The transmission power [dBm]. |
Definition at line 154 of file end-device-lora-phy.cc.
References m_listeners, m_state, NS_ASSERT, NS_LOG_FUNCTION_NOARGS, RX, and TX.
Referenced by ns3::lorawan::SimpleEndDeviceLoraPhy::Send().
|
overrideprotectedvirtual |
Signals the end of a transmission by the EndDeviceLoraPhy.
packet | A pointer to the Packet transmitted. |
Implements ns3::lorawan::LoraPhy.
Definition at line 110 of file end-device-lora-phy.cc.
References ns3::lorawan::LoraPhy::m_txFinishedCallback, NS_LOG_FUNCTION, and SwitchToStandby().
Referenced by ns3::lorawan::SimpleEndDeviceLoraPhy::Send().
void ns3::lorawan::EndDeviceLoraPhy::UnregisterListener | ( | EndDeviceLoraPhyListener * | listener | ) |
Remove the input listener from the list of objects to be notified of PHY-level events.
listener | The listener to be unregistered. |
Definition at line 200 of file end-device-lora-phy.cc.
References m_listeners.
|
protected |
The frequency [Hz] this device is listening on.
Definition at line 266 of file end-device-lora-phy.h.
Referenced by EndDeviceLoraPhy(), IsOnFrequency(), SetFrequency(), and ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().
|
protected |
PHY listeners.
Definition at line 279 of file end-device-lora-phy.h.
Referenced by RegisterListener(), SwitchToRx(), SwitchToSleep(), SwitchToStandby(), SwitchToTx(), and UnregisterListener().
|
protected |
The Spreading Factor this device is listening for.
Definition at line 268 of file end-device-lora-phy.h.
Referenced by EndDeviceLoraPhy(), GetSpreadingFactor(), SetSpreadingFactor(), and ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().
|
protected |
The state this PHY is currently in.
Definition at line 261 of file end-device-lora-phy.h.
Referenced by EndDeviceLoraPhy(), GetState(), GetTypeId(), IsTransmitting(), ns3::lorawan::SimpleEndDeviceLoraPhy::Send(), ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive(), SwitchToRx(), SwitchToSleep(), SwitchToStandby(), and SwitchToTx().
|
protected |
Trace source for when a packet is lost because it was transmitted on a frequency different from the one this EndDeviceLoraPhy was configured to listen on.
Definition at line 259 of file end-device-lora-phy.h.
Referenced by GetTypeId(), and ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().
|
protected |
Trace source for when a packet is lost because it was using a spreading factor different from the one this EndDeviceLoraPhy was configured to listen for.
Definition at line 252 of file end-device-lora-phy.h.
Referenced by GetTypeId(), and ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().
|
static |
The sensitivity vector of this device to different SFs.
Definition at line 226 of file end-device-lora-phy.h.
Referenced by ns3::lorawan::LorawanMacHelper::SetSpreadingFactorsUp(), and ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive().