14#include "ns3/simulator.h"
30 static TypeId tid =
TypeId(
"ns3::SimpleEndDeviceLoraPhy")
32 .SetGroupName(
"lorawan")
54 NS_LOG_FUNCTION(
this << packet << txParams << frequencyMHz << txPowerDbm);
61 NS_LOG_INFO(
"Cannot send because device is currently not in STANDBY or SLEEP mode");
73 packet->RemovePacketTag(tag);
75 packet->AddPacketTag(tag);
79 m_channel->Send(
this, packet, txPowerDbm, txParams, duration, frequencyMHz);
102 NS_LOG_FUNCTION(
this << packet << rxPowerDbm <<
unsigned(sf) << duration << frequencyMHz);
122 NS_LOG_INFO(
"Dropping packet because device is in SLEEP state");
126 NS_LOG_INFO(
"Dropping packet because device is in TX state");
130 NS_LOG_INFO(
"Dropping packet because device is already in RX state");
143 bool canLockOnPacket =
true;
152 NS_LOG_INFO(
"Packet lost because it's on frequency "
153 << frequencyMHz <<
" MHz and we are listening at " <<
m_frequency
166 canLockOnPacket =
false;
174 <<
unsigned(sf) <<
", while we are listening for SF" <<
unsigned(
m_sf));
186 canLockOnPacket =
false;
193 NS_LOG_INFO(
"Dropping packet reception of packet with sf = "
194 <<
unsigned(sf) <<
" because under the sensitivity of " <<
sensitivity
207 canLockOnPacket =
false;
bool IsNull() const
Check for null implementation.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Class representing a LoRa transceiver.
bool IsOnFrequency(double frequencyMHz) override
Whether this device is listening on the specified frequency or not.
static const double sensitivity[6]
The sensitivity vector of this device to different SFs.
uint8_t m_sf
The Spreading Factor this device is listening for.
void SwitchToRx()
Switch to the RX state.
void SwitchToStandby()
Switch to the STANDBY state.
TracedValue< State > m_state
The state this PHY is currently in.
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...
void SwitchToTx(double txPowerDbm)
Switch to the TX state.
@ RX
The PHY layer is receiving a packet.
@ TX
The PHY layer is sending a packet.
@ SLEEP
The PHY layer is sleeping.
@ STANDBY
The PHY layer is in STANDBY.
void TxFinished(Ptr< const Packet > packet) override
Signals the end of a transmission by the EndDeviceLoraPhy.
double m_frequency
The frequency this device is listening on.
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 o...
Ptr< LoraInterferenceHelper::Event > Add(Time duration, double rxPower, uint8_t spreadingFactor, Ptr< Packet > packet, double frequencyMHz)
Add an event to the InterferenceHelper.
uint8_t IsDestroyedByInterference(Ptr< LoraInterferenceHelper::Event > event)
Determine whether the event was destroyed by interference or not.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet reception ends.
LoraInterferenceHelper m_interference
The LoraInterferenceHelper associated to this PHY.
static Time GetOnAirTime(Ptr< Packet > packet, LoraTxParameters txParams)
Compute the time that a packet with certain characteristics will take to be transmitted.
TracedCallback< Ptr< const Packet >, uint32_t > m_interferedPacket
The trace source fired when a packet cannot be correctly received because of interference.
RxFailedCallback m_rxFailedCallback
The callback to perform upon failed reception of a packet we were locked on.
virtual void EndReceive(Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event)=0
Finish reception of a packet.
TracedCallback< Ptr< const Packet >, uint32_t > m_successfullyReceivedPacket
The trace source fired when a packet was correctly received.
TracedCallback< Ptr< const Packet >, uint32_t > m_startSending
The trace source fired when a packet is sent.
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 th...
Ptr< NetDevice > m_device
The net device this PHY is attached to.
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Ptr< LoraChannel > m_channel
The channel this PHY transmits on.
RxOkCallback m_rxOkCallback
The callback to perform upon correct reception of a packet.
Tag used to save various data about a packet, like its Spreading Factor and data about interference.
void SetSpreadingFactor(uint8_t sf)
Set which Spreading Factor this packet was transmitted with.
Class representing a simple LoRa transceiver, with an error model based on receiver sensitivity and a...
~SimpleEndDeviceLoraPhy() override
Destructor.
SimpleEndDeviceLoraPhy()
Default constructor.
void StartReceive(Ptr< Packet > packet, double rxPowerDbm, uint8_t sf, Time duration, double frequencyMHz) override
Start receiving a packet.
static TypeId GetTypeId()
Register this type.
void Send(Ptr< Packet > packet, LoraTxParameters txParams, double frequencyMHz, double txPowerDbm) override
Instruct the PHY to send a packet according to some parameters.
void EndReceive(Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event) override
Finish reception of a packet.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to collect all parameters that are used to compute the duration of a packet (excluding payl...
uint8_t sf
Spreading Factor.