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/mobility-model.h"
15#include "ns3/net-device.h"
16#include "ns3/node.h"
17#include "ns3/nstime.h"
18#include "ns3/object.h"
19#include "ns3/traced-value.h"
20
21#include <list>
22
23namespace ns3
24{
25namespace lorawan
26{
27
28class LoraChannel;
29
30/**
31 * \ingroup lorawan
32 *
33 * Class modeling a Lora SX1301 chip.
34 *
35 * This class models the behaviour of the chip employed in Lora gateways. These
36 * chips are characterized by the presence of 8 receive paths, or parallel
37 * receivers, which can be employed to listen to different channels
38 * simultaneously. This characteristic of the chip is modeled using the
39 * ReceivePath class, which describes a single parallel receiver. GatewayLoraPhy
40 * essentially holds and manages a collection of these objects.
41 */
42class GatewayLoraPhy : public LoraPhy
43{
44 public:
45 /**
46 * Register this type.
47 * \return The object TypeId.
48 */
49 static TypeId GetTypeId();
50
51 GatewayLoraPhy(); //!< Default constructor
52 ~GatewayLoraPhy() override; //!< Destructor
53
55 double rxPowerDbm,
56 uint8_t sf,
57 Time duration,
58 double frequencyMHz) override = 0;
59
61
62 void Send(Ptr<Packet> packet,
63 LoraTxParameters txParams,
64 double frequencyMHz,
65 double txPowerDbm) override = 0;
66
67 bool IsTransmitting() override;
68
69 /**
70 * Check whether the GatewayLoraPhy is currently listening to the specified frequency.
71 *
72 * \param frequencyMHz The value of the frequency [MHz].
73 * \return True if the frequency is among the one being listened to, false otherwise.
74 */
75 bool IsOnFrequency(double frequencyMHz) override;
76
77 /**
78 * Add a reception path, locked on a specific frequency.
79 */
80 void AddReceptionPath();
81
82 /**
83 * Reset the list of reception paths.
84 *
85 * This method deletes all currently available ReceptionPath objects.
86 */
88
89 /**
90 * Add a frequency to the list of frequencies we are listening to.
91 *
92 * \param frequencyMHz The value of the frequency [MHz].
93 */
94 void AddFrequency(double frequencyMHz);
95
96 static const double sensitivity[6]; //!< A vector containing the sensitivities required to
97 //!< correctly decode different spreading factors.
98
99 protected:
100 /**
101 * Signals the end of a transmission by the GatewayLoraPhy.
102 *
103 * \param packet A pointer to the Packet transmitted.
104 */
105 void TxFinished(Ptr<const Packet> packet) override;
106
107 /**
108 * This class represents a configurable reception path.
109 *
110 * Differently from EndDeviceLoraPhys, these do not need to be configured to
111 * listen for a certain spreading factor. ReceptionPaths be either locked on an event or
112 * free.
113 */
114 class ReceptionPath : public SimpleRefCount<GatewayLoraPhy::ReceptionPath>
115 {
116 public:
117 /**
118 * Constructor.
119 */
121 ~ReceptionPath(); //!< Destructor
122
123 /**
124 * Query whether this reception path is available to lock on a signal.
125 *
126 * \return True if its current state is free, false if it's currently locked.
127 */
128 bool IsAvailable() const;
129
130 /**
131 * Set this reception path as available.
132 *
133 * This function sets the m_available variable as true, and deletes the
134 * LoraInterferenceHelper Event this ReceivePath was previously locked on.
135 */
136 void Free();
137
138 /**
139 * Set this reception path as not available and lock it on the
140 * provided event.
141 *
142 * \param event The LoraInterferenceHelper Event to lock on.
143 */
145
146 /**
147 * Set the event this reception path is currently on.
148 *
149 * \param event The event to lock this ReceptionPath on.
150 */
152
153 /**
154 * Get the event this reception path is currently on.
155 *
156 * \return 0 if no event is currently being received, a pointer to
157 * the event otherwise.
158 */
160
161 /**
162 * Get the EventId of the EndReceive call associated to this ReceptionPath's
163 * packet.
164 *
165 * \return The EventId instance.
166 */
168
169 /**
170 * Set the EventId of the EndReceive call associated to this ReceptionPath's
171 * packet.
172 *
173 * \param endReceiveEventId The EventId instance.
174 */
175 void SetEndReceive(EventId endReceiveEventId);
176
177 private:
178 bool m_available; //!< Whether this reception path is available to lock on a signal or not.
180 m_event; //!< The event this reception path is currently locked on.
181 EventId m_endReceiveEventId; //!< The EventId associated of the call to EndReceive that is
182 //!< scheduled to happen when the packet this ReceivePath is
183 //!< locked on finishes reception.
184 };
185
186 std::list<Ptr<ReceptionPath>> m_receptionPaths; //!< A list containing the various parallel
187 //!< receivers that are managed by this gateway.
188
189 TracedValue<int> m_occupiedReceptionPaths; //!< The number of occupied reception paths.
190
191 /**
192 * Trace source fired when a packet cannot be received because all available ReceivePath
193 * instances are busy.
194 */
196
197 /**
198 * Trace source fired when a packet cannot be received because the gateway is in transmission
199 * state.
200 */
202
203 bool m_isTransmitting; //!< Flag indicating whether a transmission is going on
204
205 std::list<double> m_frequencies; //!< List of frequencies the GatewayLoraPhy is listening to.
206};
207
208} // namespace lorawan
209
210} // namespace ns3
211#endif /* GATEWAY_LORA_PHY_H */
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
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:65
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:38