14#include "ns3/simulator.h"
34 .SetGroupName(
"lorawan")
61 NS_LOG_DEBUG(
"Duration of packet: " << duration <<
", SF" <<
unsigned(txParams.
sf));
64 std::list<Ptr<SimpleGatewayLoraPhy::ReceptionPath>>::iterator it;
69 if (!currentPath->IsAvailable())
93 m_channel->Send(
this, packet, txPowerDbm, txParams, duration, frequencyMHz);
117 NS_LOG_FUNCTION(
this << packet << rxPowerDbm << duration << frequencyMHz);
125 NS_LOG_INFO(
"Dropping packet reception of packet with sf = "
126 <<
unsigned(sf) <<
" because we are in TX mode");
148 std::list<Ptr<SimpleGatewayLoraPhy::ReceptionPath>>::iterator it;
156 if (currentPath->IsAvailable())
164 NS_LOG_INFO(
"Dropping packet reception of packet with sf = "
165 <<
unsigned(sf) <<
" because under the sensitivity of " <<
sensitivity
183 NS_LOG_INFO(
"Scheduling reception of a packet, occupying one demodulator");
186 currentPath->LockOnEvent(event);
193 currentPath->SetEndReceive(endReceiveEventId);
201 NS_LOG_INFO(
"Dropping packet reception of packet with sf = "
202 <<
unsigned(sf) <<
" and frequency " << frequencyMHz
203 <<
"MHz because no suitable demodulator was found");
227 uint8_t packetDestroyed = 0;
231 if (packetDestroyed != uint8_t(0))
233 NS_LOG_DEBUG(
"packetDestroyed by " <<
unsigned(packetDestroyed));
237 packet->RemovePacketTag(tag);
239 packet->AddPacketTag(tag);
253 NS_LOG_INFO(
"Packet with SF " <<
unsigned(event->GetSpreadingFactor())
254 <<
" received correctly");
276 packet->RemovePacketTag(tag);
279 packet->AddPacketTag(tag);
287 std::list<Ptr<SimpleGatewayLoraPhy::ReceptionPath>>::iterator it;
293 if (currentPath->GetEvent() == event)
bool IsNull() const
Check for null implementation.
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.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Class modeling a Lora SX1301 chip.
bool m_isTransmitting
Flag indicating whether a transmission is going on.
TracedValue< int > m_occupiedReceptionPaths
The number of occupied reception paths.
static const double sensitivity[6]
A vector containing the sensitivities required to correctly decode different spreading factors.
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
Signals the end of a transmission by the GatewayLoraPhy.
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...
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.
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 SetFrequency(double frequency)
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.
void Send(Ptr< Packet > packet, LoraTxParameters txParams, double frequencyMHz, double txPowerDbm) override
Instruct the PHY to send a packet according to some parameters.
static TypeId GetTypeId()
Register this type.
void StartReceive(Ptr< Packet > packet, double rxPowerDbm, uint8_t sf, Time duration, double frequencyMHz) override
Start receiving a packet.
void EndReceive(Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event) override
Finish reception of a packet.
SimpleGatewayLoraPhy()
Default constructor.
~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_NOARGS()
Output the name of the function.
#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.