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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20#ifndef GATEWAY_LORA_PHY_H
21#define GATEWAY_LORA_PHY_H
22
23#include "lora-phy.h"
24
25#include "ns3/mobility-model.h"
26#include "ns3/net-device.h"
27#include "ns3/node.h"
28#include "ns3/nstime.h"
29#include "ns3/object.h"
30#include "ns3/traced-value.h"
31
32#include <list>
33
34namespace ns3
35{
36namespace lorawan
37{
38
39class LoraChannel;
40
41/**
42 * \ingroup lorawan
43 *
44 * Class modeling a Lora SX1301 chip.
45 *
46 * This class models the behaviour of the chip employed in Lora gateways. These
47 * chips are characterized by the presence of 8 receive paths, or parallel
48 * receivers, which can be employed to listen to different channels
49 * simultaneously. This characteristic of the chip is modeled using the
50 * ReceivePath class, which describes a single parallel receiver. GatewayLoraPhy
51 * essentially holds and manages a collection of these objects.
52 */
53class GatewayLoraPhy : public LoraPhy
54{
55 public:
56 /**
57 * Register this type.
58 * \return The object TypeId.
59 */
60 static TypeId GetTypeId();
61
62 GatewayLoraPhy(); //!< Default constructor
63 ~GatewayLoraPhy() override; //!< Destructor
64
66 double rxPowerDbm,
67 uint8_t sf,
68 Time duration,
69 double frequencyMHz) override = 0;
70
72
73 void Send(Ptr<Packet> packet,
74 LoraTxParameters txParams,
75 double frequencyMHz,
76 double txPowerDbm) override = 0;
77
78 bool IsTransmitting() override;
79
80 /**
81 * Check whether the GatewayLoraPhy is currently listening to the specified frequency.
82 *
83 * \param frequencyMHz The value of the frequency [MHz].
84 * \return True if the frequency is among the one being listened to, false otherwise.
85 */
86 bool IsOnFrequency(double frequencyMHz) override;
87
88 /**
89 * Add a reception path, locked on a specific frequency.
90 */
91 void AddReceptionPath();
92
93 /**
94 * Reset the list of reception paths.
95 *
96 * This method deletes all currently available ReceptionPath objects.
97 */
99
100 /**
101 * Add a frequency to the list of frequencies we are listening to.
102 *
103 * \param frequencyMHz The value of the frequency [MHz].
104 */
105 void AddFrequency(double frequencyMHz);
106
107 static const double sensitivity[6]; //!< A vector containing the sensitivities required to
108 //!< correctly decode different spreading factors.
109
110 protected:
111 /**
112 * Signals the end of a transmission by the GatewayLoraPhy.
113 *
114 * \param packet A pointer to the Packet transmitted.
115 */
116 void TxFinished(Ptr<const Packet> packet) override;
117
118 /**
119 * This class represents a configurable reception path.
120 *
121 * Differently from EndDeviceLoraPhys, these do not need to be configured to
122 * listen for a certain spreading factor. ReceptionPaths be either locked on an event or
123 * free.
124 */
125 class ReceptionPath : public SimpleRefCount<GatewayLoraPhy::ReceptionPath>
126 {
127 public:
128 /**
129 * Constructor.
130 */
132 ~ReceptionPath(); //!< Destructor
133
134 /**
135 * Query whether this reception path is available to lock on a signal.
136 *
137 * \return True if its current state is free, false if it's currently locked.
138 */
139 bool IsAvailable() const;
140
141 /**
142 * Set this reception path as available.
143 *
144 * This function sets the m_available variable as true, and deletes the
145 * LoraInterferenceHelper Event this ReceivePath was previously locked on.
146 */
147 void Free();
148
149 /**
150 * Set this reception path as not available and lock it on the
151 * provided event.
152 *
153 * \param event The LoraInterferenceHelper Event to lock on.
154 */
156
157 /**
158 * Set the event this reception path is currently on.
159 *
160 * \param event The event to lock this ReceptionPath on.
161 */
163
164 /**
165 * Get the event this reception path is currently on.
166 *
167 * \return 0 if no event is currently being received, a pointer to
168 * the event otherwise.
169 */
171
172 /**
173 * Get the EventId of the EndReceive call associated to this ReceptionPath's
174 * packet.
175 *
176 * \return The EventId instance.
177 */
179
180 /**
181 * Set the EventId of the EndReceive call associated to this ReceptionPath's
182 * packet.
183 *
184 * \param endReceiveEventId The EventId instance.
185 */
186 void SetEndReceive(EventId endReceiveEventId);
187
188 private:
189 bool m_available; //!< Whether this reception path is available to lock on a signal or not.
191 m_event; //!< The event this reception path is currently locked on.
192 EventId m_endReceiveEventId; //!< The EventId associated of the call to EndReceive that is
193 //!< scheduled to happen when the packet this ReceivePath is
194 //!< locked on finishes reception.
195 };
196
197 std::list<Ptr<ReceptionPath>> m_receptionPaths; //!< A list containing the various parallel
198 //!< receivers that are managed by this gateway.
199
200 TracedValue<int> m_occupiedReceptionPaths; //!< The number of occupied reception paths.
201
202 /**
203 * Trace source fired when a packet cannot be received because all available ReceivePath
204 * instances are busy.
205 */
207
208 /**
209 * Trace source fired when a packet cannot be received because the gateway is in transmission
210 * state.
211 */
213
214 bool m_isTransmitting; //!< Flag indicating whether a transmission is going on
215
216 std::list<double> m_frequencies; //!< List of frequencies the GatewayLoraPhy is listening to.
217};
218
219} // namespace lorawan
220
221} // namespace ns3
222#endif /* GATEWAY_LORA_PHY_H */
An identifier for simulation events.
Definition: event-id.h:56
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
This class represents a configurable reception path.
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.
Class modeling a Lora SX1301 chip.
GatewayLoraPhy()
Default constructor.
bool m_isTransmitting
Flag indicating whether a transmission is going on.
void AddFrequency(double frequencyMHz)
Add a frequency to the list of frequencies we are listening to.
TracedValue< int > m_occupiedReceptionPaths
The number of occupied reception paths.
bool IsTransmitting() override
Whether this device is transmitting or not.
static const double sensitivity[6]
A vector containing the sensitivities required to correctly decode different spreading factors.
std::list< double > m_frequencies
List of frequencies the GatewayLoraPhy is listening to.
TracedCallback< Ptr< const Packet >, uint32_t > m_noReceptionBecauseTransmitting
Trace source fired when a packet cannot be received because the gateway is in transmission state.
bool IsOnFrequency(double frequencyMHz) override
Check whether the GatewayLoraPhy is currently listening to the specified frequency.
~GatewayLoraPhy() override
Destructor.
void ResetReceptionPaths()
Reset the list of reception paths.
static TypeId GetTypeId()
Register this type.
void TxFinished(Ptr< const Packet > packet) override
Signals the end of a transmission by the GatewayLoraPhy.
void StartReceive(Ptr< Packet > packet, double rxPowerDbm, uint8_t sf, Time duration, double frequencyMHz) override=0
Start receiving a packet.
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.
void Send(Ptr< Packet > packet, LoraTxParameters txParams, double frequencyMHz, double txPowerDbm) override=0
Instruct the PHY to send a packet according to some parameters.
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 reception path, locked on a specific frequency.
Base class for PHY layers implementing the LoRa modulation scheme.
Definition: lora-phy.h:76
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:49