15#include "ns3/simulator.h"
35 .SetGroupName(
"lorawan")
58 NS_LOG_FUNCTION(
this << packet << frequencyHz << iqPolarity << txParams << txPowerDbm);
63 if (!rxPath->IsAvailable())
81 m_channel->Send(
this, packet, frequencyHz, iqPolarity, txParams, txPowerDbm, duration);
91 uint8_t spreadingFactor,
95 NS_LOG_FUNCTION(
this << packet << frequencyHz << iqPolarity <<
unsigned(spreadingFactor)
96 << rxPowerDbm << duration);
99 auto event =
m_interference.Add(duration, rxPowerDbm, spreadingFactor, packet, frequencyHz);
104 NS_LOG_INFO(
"Dropping packet reception of packet with SF" <<
unsigned(spreadingFactor)
105 <<
" because we are in TX mode");
114 NS_LOG_INFO(
"Dropping packet reception of packet with SF"
115 <<
unsigned(spreadingFactor) <<
" because we are not listening to frequency "
116 << frequencyHz <<
" Hz");
123 NS_LOG_INFO(
"Dropping packet reception of packet with SF"
124 <<
unsigned(spreadingFactor)
125 <<
" because we are not listening to uplink transmissions");
134 NS_LOG_INFO(
"Dropping packet reception of packet with SF"
135 <<
unsigned(spreadingFactor) <<
" because under the sensitivity of " << sens
147 if (rxPath->IsAvailable())
149 NS_LOG_INFO(
"Scheduling reception of a packet, occupying one demodulator");
151 rxPath->LockOnEvent(event);
159 rxPath->SetEndReceive(endReceiveEventId);
167 NS_LOG_INFO(
"Dropping packet reception of packet with SF"
168 <<
unsigned(spreadingFactor) <<
" and frequency " << frequencyHz
169 <<
"Hz because no suitable demodulator was found");
182 if (rxPath->GetEvent() == event)
193 if (
auto sf =
m_interference.IsDestroyedByInterference(event); sf != 0)
198 packet->RemovePacketTag(tag);
200 packet->AddPacketTag(tag);
206 NS_LOG_INFO(
"Packet with SF " <<
unsigned(event->GetSpreadingFactor())
207 <<
" received correctly");
217 packet->RemovePacketTag(tag);
220 packet->AddPacketTag(tag);
An identifier for simulation events.
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.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
GatewayLoraPhy()
Default constructor.
bool m_isTransmitting
Flag indicating whether a transmission is going on.
TracedValue< int > m_occupiedReceptionPaths
The number of occupied reception paths.
TracedCallback< Ptr< const Packet >, uint32_t > m_noReceptionBecauseTransmitting
Trace source fired when a packet cannot be received because the gateway is in transmission state.
void TxFinished(Ptr< const Packet > packet) override
Internal call when transmission of a packet finishes.
static const double SENSITIVITY[6]
The sensitivity vector of this gateway to different SFs.
bool IsOnFrequency(uint32_t frequencyHz) const override
Implementation of LoraPhy's pure virtual function.
std::list< Ptr< ReceptionPath > > m_receptionPaths
A list containing the various parallel receivers that are managed by this gateway.
TracedCallback< Ptr< const Packet >, uint32_t > m_noMoreDemodulators
Trace source fired when a packet cannot be received because all available ReceivePath instances are b...
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet reception ends.
LoraInterferenceHelper m_interference
The LoraInterferenceHelper associated to this PHY.
TracedCallback< Ptr< const Packet >, uint32_t > m_interferedPacket
The trace source fired when a packet cannot be correctly received because of interference.
static Time GetTimeOnAir(uint32_t phyPayloadLen, const LoraTxParameters &txParams)
Compute the total transmission time for a physical packet based on modulation parameters.
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 SetFrequency(uint32_t frequencyHz)
Set the frequency of the packet.
void SetReceivePower(double receivePower)
Set the power this packet was received with.
void SetDestroyedBy(uint8_t sf)
Set which Spreading Factor this packet was destroyed by.
Class modeling a Lora SX1301 chip.
static TypeId GetTypeId()
Register this type.
void StartReceive(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, double rxPowerDbm, Time duration) override
Start receiving a packet.
void EndReceive(Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event) override
Finish reception of a packet.
SimpleGatewayLoraPhy()
Default constructor.
void Send(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, const LoraTxParameters &txParams, double txPowerDbm) override
Instruct the PHY to send a packet according to some parameters.
~SimpleGatewayLoraPhy() override
Destructor.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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.
IQPolarity
I/Q Polarity of LoRa transmission symbols.
@ UP
Uplink / Upchirp / Normal polarity.
#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...