A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
gateway-lora-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Davide Magrin <magrinda@dei.unipd.it>
7 */
8
9#ifndef GATEWAY_LORA_PHY_H
10#define GATEWAY_LORA_PHY_H
11
12#include "lora-phy.h"
13
14#include "ns3/traced-value.h"
15
16namespace ns3
17{
18namespace lorawan
19{
20
21/**
22 * @ingroup lorawan
23 *
24 * Class modeling a Lora SX1301 chip.
25 *
26 * This class models the behaviour of the chip employed in Lora gateways. These
27 * chips are characterized by the presence of 8 receive paths, or parallel
28 * receivers, which can be employed to listen to different channels
29 * simultaneously. This characteristic of the chip is modeled using the
30 * ReceivePath class, which describes a single parallel receiver. GatewayLoraPhy
31 * essentially holds and manages a collection of these objects.
32 */
33class GatewayLoraPhy : public LoraPhy
34{
35 public:
36 /**
37 * Register this type.
38 * @return The object TypeId.
39 */
40 static TypeId GetTypeId();
41
42 GatewayLoraPhy(); //!< Default constructor
43 ~GatewayLoraPhy() override; //!< Destructor
44
45 static const double SENSITIVITY[6]; //!< The sensitivity vector of this gateway to different SFs
46
47 // Forward LoraPhy's pure virtual function
48 void Send(Ptr<Packet> packet,
49 uint32_t frequencyHz,
50 IQPolarity iqPolarity,
51 const LoraTxParameters& txParams,
52 double txPowerDbm) override = 0;
53
54 // Forward LoraPhy's pure virtual function
56 uint32_t frequencyHz,
57 IQPolarity iqPolarity,
58 uint8_t spreadingFactor,
59 double rxPowerDbm,
60 Time duration) override = 0;
61
62 // Implementation of LoraPhy's pure virtual function
63 bool IsTransmitting() const override;
64
65 /**
66 * Implementation of LoraPhy's pure virtual function
67 *
68 * Check whether the GatewayLoraPhy is currently listening to the specified frequency.
69 *
70 * @param frequencyHz The value of the frequency [Hz].
71 * @return True if the frequency is among the one being listened to, false otherwise.
72 */
73 bool IsOnFrequency(uint32_t frequencyHz) const override;
74
75 /**
76 * Add a hardware reception path.
77 */
78 void AddReceptionPath();
79
80 /**
81 * Reset the list of reception paths.
82 *
83 * This method deletes all currently available ReceptionPath objects.
84 */
86
87 /**
88 * Add a frequency to the list of frequencies we are listening to.
89 *
90 * @param frequencyHz The value of the frequency [Hz].
91 */
92 void AddFrequency(uint32_t frequencyHz);
93
94 protected:
95 /**
96 * This class represents a configurable reception path.
97 *
98 * Differently from EndDeviceLoraPhys, these do not need to be configured to
99 * listen for a certain spreading factor. ReceptionPaths be either locked on an event or
100 * free.
101 */
102 class ReceptionPath : public SimpleRefCount<GatewayLoraPhy::ReceptionPath>
103 {
104 public:
105 ReceptionPath(); //!< Default constructor
106 ~ReceptionPath(); //!< Destructor
107
108 /**
109 * Query whether this reception path is available to lock on a signal.
110 *
111 * @return True if its current state is free, false if it's currently locked.
112 */
113 bool IsAvailable() const;
114
115 /**
116 * Set this reception path as available.
117 *
118 * This function sets the m_available variable as true, and deletes the
119 * LoraInterferenceHelper Event this ReceivePath was previously locked on.
120 */
121 void Free();
122
123 /**
124 * Set this reception path as not available and lock it on the
125 * provided event.
126 *
127 * @param event The LoraInterferenceHelper Event to lock on.
128 */
130
131 /**
132 * Set the event this reception path is currently on.
133 *
134 * @param event The event to lock this ReceptionPath on.
135 */
137
138 /**
139 * Get the event this reception path is currently on.
140 *
141 * @return 0 if no event is currently being received, a pointer to
142 * the event otherwise.
143 */
145
146 /**
147 * Get the EventId of the EndReceive call associated to this ReceptionPath's
148 * packet.
149 *
150 * @return The EventId instance.
151 */
153
154 /**
155 * Set the EventId of the EndReceive call associated to this ReceptionPath's
156 * packet.
157 *
158 * @param endReceiveEventId The EventId instance.
159 */
160 void SetEndReceive(EventId endReceiveEventId);
161
162 private:
163 bool m_available; //!< Whether this reception path is available to lock on a signal or not.
165 m_event; //!< The event this reception path is currently locked on.
166 EventId m_endReceiveEventId; //!< The EventId associated of the call to EndReceive that is
167 //!< scheduled to happen when the packet this ReceivePath is
168 //!< locked on finishes reception.
169 };
170
171 // Implementation of LoraPhy's pure virtual function
172 void TxFinished(Ptr<const Packet> packet) override;
173
174 /**
175 * Trace source fired when a packet cannot be received because all available ReceivePath
176 * instances are busy.
177 */
179
180 /**
181 * Trace source fired when a packet cannot be received because the gateway is in transmission
182 * state.
183 */
185
186 std::list<Ptr<ReceptionPath>> m_receptionPaths; //!< A list containing the various parallel
187 //!< receivers that are managed by this gateway.
188 std::list<uint32_t>
189 m_frequenciesHz; //!< List of frequencies [Hz] the GatewayLoraPhy is listening to.
190 bool m_isTransmitting; //!< Flag indicating whether a transmission is going on
191
192 TracedValue<int> m_occupiedReceptionPaths; //!< The number of occupied reception paths.
193
194 private:
195 // Forward LoraPhy's pure virtual function
197};
198
199} // namespace lorawan
200} // namespace ns3
201
202#endif /* GATEWAY_LORA_PHY_H */
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:50
EventId GetEndReceive()
Get the EventId of the EndReceive call associated to this ReceptionPath's packet.
Ptr< LoraInterferenceHelper::Event > m_event
The event this reception path is currently locked on.
void SetEvent(Ptr< LoraInterferenceHelper::Event > event)
Set the event this reception path is currently on.
Ptr< LoraInterferenceHelper::Event > GetEvent()
Get the event this reception path is currently on.
EventId m_endReceiveEventId
The EventId associated of the call to EndReceive that is scheduled to happen when the packet this Rec...
bool m_available
Whether this reception path is available to lock on a signal or not.
void Free()
Set this reception path as available.
void SetEndReceive(EventId endReceiveEventId)
Set the EventId of the EndReceive call associated to this ReceptionPath's packet.
void LockOnEvent(Ptr< LoraInterferenceHelper::Event > event)
Set this reception path as not available and lock it on the provided event.
bool IsAvailable() const
Query whether this reception path is available to lock on a signal.
GatewayLoraPhy()
Default constructor.
bool m_isTransmitting
Flag indicating whether a transmission is going on.
void StartReceive(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, uint8_t spreadingFactor, double rxPowerDbm, Time duration) override=0
Start receiving a packet.
TracedValue< int > m_occupiedReceptionPaths
The number of occupied reception paths.
void Send(Ptr< Packet > packet, uint32_t frequencyHz, IQPolarity iqPolarity, const LoraTxParameters &txParams, double txPowerDbm) override=0
Instruct the PHY to send a packet according to some parameters.
bool IsTransmitting() const override
Whether this device is transmitting or not.
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 AddFrequency(uint32_t frequencyHz)
Add a frequency to the list of frequencies we are listening to.
~GatewayLoraPhy() override
Destructor.
void ResetReceptionPaths()
Reset the list of reception paths.
static TypeId GetTypeId()
Register this type.
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.
void EndReceive(Ptr< Packet > packet, Ptr< LoraInterferenceHelper::Event > event) override=0
Finish reception of a packet.
std::list< Ptr< ReceptionPath > > m_receptionPaths
A list containing the various parallel receivers that are managed by this gateway.
std::list< uint32_t > m_frequenciesHz
List of frequencies [Hz] the GatewayLoraPhy is listening to.
TracedCallback< Ptr< const Packet >, uint32_t > m_noMoreDemodulators
Trace source fired when a packet cannot be received because all available ReceivePath instances are b...
void AddReceptionPath()
Add a hardware reception path.
LoraPhy()
Default constructor.
Definition lora-phy.cc:199
IQPolarity
I/Q Polarity of LoRa transmission symbols.
Definition lora-phy.h:33
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...
Definition lora-phy.h:73