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
46 double rxPowerDbm,
47 uint8_t sf,
48 Time duration,
49 uint32_t frequencyHz) override = 0;
50
52
53 void Send(Ptr<Packet> packet,
54 LoraTxParameters txParams,
55 uint32_t frequencyHz,
56 double txPowerDbm) override = 0;
57
58 bool IsTransmitting() override;
59
60 /**
61 * Check whether the GatewayLoraPhy is currently listening to the specified frequency.
62 *
63 * @param frequencyHz The value of the frequency [Hz].
64 * @return True if the frequency is among the one being listened to, false otherwise.
65 */
66 bool IsOnFrequency(uint32_t frequencyHz) override;
67
68 /**
69 * Add a reception path, locked on a specific frequency.
70 */
71 void AddReceptionPath();
72
73 /**
74 * Reset the list of reception paths.
75 *
76 * This method deletes all currently available ReceptionPath objects.
77 */
79
80 /**
81 * Add a frequency to the list of frequencies we are listening to.
82 *
83 * @param frequencyHz The value of the frequency [Hz].
84 */
85 void AddFrequency(uint32_t frequencyHz);
86
87 static const double sensitivity[6]; //!< A vector containing the sensitivities required to
88 //!< correctly decode different spreading factors.
89
90 protected:
91 /**
92 * Signals the end of a transmission by the GatewayLoraPhy.
93 *
94 * @param packet A pointer to the Packet transmitted.
95 */
96 void TxFinished(Ptr<const Packet> packet) override;
97
98 /**
99 * This class represents a configurable reception path.
100 *
101 * Differently from EndDeviceLoraPhys, these do not need to be configured to
102 * listen for a certain spreading factor. ReceptionPaths be either locked on an event or
103 * free.
104 */
105 class ReceptionPath : public SimpleRefCount<GatewayLoraPhy::ReceptionPath>
106 {
107 public:
108 /**
109 * Constructor.
110 */
112 ~ReceptionPath(); //!< Destructor
113
114 /**
115 * Query whether this reception path is available to lock on a signal.
116 *
117 * @return True if its current state is free, false if it's currently locked.
118 */
119 bool IsAvailable() const;
120
121 /**
122 * Set this reception path as available.
123 *
124 * This function sets the m_available variable as true, and deletes the
125 * LoraInterferenceHelper Event this ReceivePath was previously locked on.
126 */
127 void Free();
128
129 /**
130 * Set this reception path as not available and lock it on the
131 * provided event.
132 *
133 * @param event The LoraInterferenceHelper Event to lock on.
134 */
136
137 /**
138 * Set the event this reception path is currently on.
139 *
140 * @param event The event to lock this ReceptionPath on.
141 */
143
144 /**
145 * Get the event this reception path is currently on.
146 *
147 * @return 0 if no event is currently being received, a pointer to
148 * the event otherwise.
149 */
151
152 /**
153 * Get the EventId of the EndReceive call associated to this ReceptionPath's
154 * packet.
155 *
156 * @return The EventId instance.
157 */
159
160 /**
161 * Set the EventId of the EndReceive call associated to this ReceptionPath's
162 * packet.
163 *
164 * @param endReceiveEventId The EventId instance.
165 */
166 void SetEndReceive(EventId endReceiveEventId);
167
168 private:
169 bool m_available; //!< Whether this reception path is available to lock on a signal or not.
171 m_event; //!< The event this reception path is currently locked on.
172 EventId m_endReceiveEventId; //!< The EventId associated of the call to EndReceive that is
173 //!< scheduled to happen when the packet this ReceivePath is
174 //!< locked on finishes reception.
175 };
176
177 std::list<Ptr<ReceptionPath>> m_receptionPaths; //!< A list containing the various parallel
178 //!< receivers that are managed by this gateway.
179
180 TracedValue<int> m_occupiedReceptionPaths; //!< The number of occupied reception paths.
181
182 /**
183 * Trace source fired when a packet cannot be received because all available ReceivePath
184 * instances are busy.
185 */
187
188 /**
189 * Trace source fired when a packet cannot be received because the gateway is in transmission
190 * state.
191 */
193
194 bool m_isTransmitting; //!< Flag indicating whether a transmission is going on
195
196 std::list<uint32_t>
197 m_frequenciesHz; //!< List of frequencies [Hz] the GatewayLoraPhy is listening to.
198};
199
200} // namespace lorawan
201} // namespace ns3
202
203#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 Send(Ptr< Packet > packet, LoraTxParameters txParams, uint32_t frequencyHz, double txPowerDbm) override=0
Instruct the PHY to send a packet according to some parameters.
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.
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(uint32_t frequencyHz) override
Check whether the GatewayLoraPhy is currently listening to the specified frequency.
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
Signals the end of a transmission by the GatewayLoraPhy.
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 reception path, locked on a specific frequency.
void StartReceive(Ptr< Packet > packet, double rxPowerDbm, uint8_t sf, Time duration, uint32_t frequencyHz) override=0
Start receiving a packet.
LoraPhy()
Default constructor.
Definition lora-phy.cc:67
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:54