A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
gateway-lora-phy.cc
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#include "gateway-lora-phy.h"
10
11namespace ns3
12{
13namespace lorawan
14{
15
16NS_LOG_COMPONENT_DEFINE("GatewayLoraPhy");
17
19
20/**************************************
21 * ReceptionPath implementation *
22 **************************************/
23
29
34
35bool
40
41void
43{
44 m_endReceiveEventId.Cancel();
45 m_available = true;
46 SetEvent(nullptr);
47}
48
49void
55
56void
61
67
73
74void
76{
77 m_endReceiveEventId = endReceiveEventId;
78}
79
80/***********************************************************************
81 * Implementation of gateway methods *
82 ***********************************************************************/
83
86{
87 static TypeId tid =
88 TypeId("ns3::GatewayLoraPhy")
90 .SetGroupName("lorawan")
91 .AddTraceSource(
92 "NoReceptionBecauseTransmitting",
93 "Trace source indicating a packet "
94 "could not be correctly received because"
95 "the gateway is in transmission mode",
97 "ns3::Packet::TracedCallback")
98 .AddTraceSource("LostPacketBecauseNoMoreReceivers",
99 "Trace source indicating a packet "
100 "could not be correctly received because"
101 "there are no more demodulators available",
103 "ns3::Packet::TracedCallback")
104 .AddTraceSource("OccupiedReceptionPaths",
105 "Number of currently occupied reception paths",
107 "ns3::TracedValueCallback::Int");
108 return tid;
109}
110
116
121
122// Sensitivity (from SX1301 datasheet)
123// {SF7, SF8, SF9, SF10, SF11, SF12}
124// These sensitivities are for a bandwidth of 125000 Hz
125const double GatewayLoraPhy::SENSITIVITY[6] = {-130.0, -132.5, -135.0, -137.5, -140.0, -142.5};
126
127bool
129{
130 NS_LOG_FUNCTION(this);
131 return m_isTransmitting;
132}
133
134bool
136{
137 NS_LOG_FUNCTION(this << frequencyHz);
138 // Look into our list of frequencies
139 for (auto& f : m_frequenciesHz)
140 {
141 if (f == frequencyHz)
142 {
143 return true;
144 }
145 }
146 return false;
147}
148
149void
156
157void
164
165void
170
171void
173{
174 NS_LOG_FUNCTION(this << frequencyHz);
175
176 m_frequenciesHz.push_back(frequencyHz);
177
178 NS_ASSERT(m_frequenciesHz.size() <= 8);
179}
180
181} // namespace lorawan
182} // namespace ns3
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:999
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.
TracedValue< int > m_occupiedReceptionPaths
The number of occupied reception paths.
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.
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
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#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_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:492
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.