A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
logical-lora-channel-helper.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 LOGICAL_LORA_CHANNEL_HELPER_H
10#define LOGICAL_LORA_CHANNEL_HELPER_H
11
13#include "sub-band.h"
14
15#include "ns3/nstime.h"
16#include "ns3/object.h"
17#include "ns3/packet.h"
18
19#include <iterator>
20#include <list>
21#include <vector>
22
23namespace ns3
24{
25namespace lorawan
26{
27
28/**
29 * \ingroup lorawan
30 *
31 * This class supports LorawanMac instances by managing a list of the logical
32 * channels that the device is supposed to be using, and establishes their
33 * relationship with SubBands.
34 *
35 * This class also takes into account duty cycle limitations, by updating a list
36 * of SubBand objects and providing methods to query whether transmission on a
37 * set channel is admissible or not.
38 */
40{
41 public:
42 /**
43 * Register this type.
44 * \return The object TypeId.
45 */
46 static TypeId GetTypeId();
47
48 LogicalLoraChannelHelper(); //!< Default constructor
49 ~LogicalLoraChannelHelper() override; //!< Destructor
50
51 /**
52 * Get the time it is necessary to wait before transmitting again, according
53 * to the aggregate duty cycle timer.
54 *
55 * \return The aggregate waiting time.
56 */
58
59 /**
60 * Get the time it is necessary to wait for before transmitting on a given
61 * channel.
62 *
63 * \remark This function does not take into account aggregate waiting time.
64 * Check on this should be performed before calling this function.
65 *
66 * \param channel A pointer to the channel we want to know the waiting time.
67 * for.
68 * \return A Time instance containing the waiting time before transmission is.
69 * allowed on the channel.
70 */
72
73 /**
74 * Register the transmission of a packet.
75 *
76 * \param duration The duration of the transmission event.
77 * \param channel The channel the transmission was made on.
78 */
79 void AddEvent(Time duration, Ptr<LogicalLoraChannel> channel);
80
81 /**
82 * Get the list of LogicalLoraChannels currently registered on this helper.
83 *
84 * \return A list of the managed channels.
85 */
86 std::vector<Ptr<LogicalLoraChannel>> GetChannelList();
87
88 /**
89 * Get the list of LogicalLoraChannels currently registered on this helper
90 * that have been enabled for Uplink transmission with the channel mask.
91 *
92 * \return A list of the managed channels enabled for Uplink transmission.
93 */
94 std::vector<Ptr<LogicalLoraChannel>> GetEnabledChannelList();
95
96 /**
97 * Add a new channel to the list.
98 *
99 * \param frequency The frequency of the channel to create.
100 */
101 void AddChannel(double frequency);
102
103 /**
104 * Add a new channel to the list.
105 *
106 * \param logicalChannel A pointer to the channel to add to the list.
107 */
108 void AddChannel(Ptr<LogicalLoraChannel> logicalChannel);
109
110 /**
111 * Set a new channel at a fixed index.
112 *
113 * \param chIndex The index of the channel to substitute.
114 * \param logicalChannel A pointer to the channel to add to the list.
115 */
116 void SetChannel(uint8_t chIndex, Ptr<LogicalLoraChannel> logicalChannel);
117
118 /**
119 * Add a new SubBand to this helper.
120 *
121 * \param firstFrequency The first frequency of the subband, in MHz.
122 * \param lastFrequency The last frequency of the subband, in MHz.
123 * \param dutyCycle The duty cycle that needs to be enforced on this subband.
124 * \param maxTxPowerDbm The maximum transmission power [dBm] that can be used.
125 * on this SubBand.
126 */
127 void AddSubBand(double firstFrequency,
128 double lastFrequency,
129 double dutyCycle,
130 double maxTxPowerDbm);
131
132 /**
133 * Add a new SubBand.
134 *
135 * \param subBand A pointer to the SubBand that needs to be added.
136 */
137 void AddSubBand(Ptr<SubBand> subBand);
138
139 /**
140 * Remove a channel.
141 *
142 * \param channel A pointer to the channel we want to remove.
143 */
145
146 /**
147 * Returns the maximum transmission power [dBm] that is allowed on a channel.
148 *
149 * \param logicalChannel The power for which to check the maximum allowed.
150 * transmission power.
151 * \return The power in dBm.
152 */
153 double GetTxPowerForChannel(Ptr<LogicalLoraChannel> logicalChannel);
154
155 /**
156 * Get the SubBand a channel belongs to.
157 *
158 * \param channel The channel whose SubBand we want to get.
159 * \return The SubBand the channel belongs to.
160 */
162
163 /**
164 * Get the SubBand a frequency belongs to.
165 *
166 * \param frequency The frequency we want to check.
167 * \return The SubBand the frequency belongs to.
168 */
169 Ptr<SubBand> GetSubBandFromFrequency(double frequency);
170
171 /**
172 * Disable the channel at a specified index.
173 *
174 * \param index The index of the channel to disable.
175 */
176 void DisableChannel(int index);
177
178 private:
179 /**
180 * A list of the SubBands that are currently registered within this helper.
181 */
182 std::list<Ptr<SubBand>> m_subBandList;
183
184 /**
185 * A vector of the LogicalLoraChannels that are currently registered within
186 * this helper. This vector represents the node's channel mask. The first N
187 * channels are the default ones for a fixed region.
188 */
189 std::vector<Ptr<LogicalLoraChannel>> m_channelList;
190
191 Time m_nextAggregatedTransmissionTime; //!< The next time at which
192 //! transmission will be possible
193 //! according to the aggregated
194 //! transmission timer
195
196 double m_aggregatedDutyCycle; //!< The next time at which
197 //! transmission will be possible
198 //! according to the aggregated
199 //! transmission timer
200};
201} // namespace lorawan
202
203} // namespace ns3
204#endif /* LOGICAL_LORA_CHANNEL_HELPER_H */
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
This class supports LorawanMac instances by managing a list of the logical channels that the device i...
void RemoveChannel(Ptr< LogicalLoraChannel > channel)
Remove a channel.
double GetTxPowerForChannel(Ptr< LogicalLoraChannel > logicalChannel)
Returns the maximum transmission power [dBm] that is allowed on a channel.
Time GetAggregatedWaitingTime()
Get the time it is necessary to wait before transmitting again, according to the aggregate duty cycle...
Ptr< SubBand > GetSubBandFromFrequency(double frequency)
Get the SubBand a frequency belongs to.
void SetChannel(uint8_t chIndex, Ptr< LogicalLoraChannel > logicalChannel)
Set a new channel at a fixed index.
void DisableChannel(int index)
Disable the channel at a specified index.
double m_aggregatedDutyCycle
transmission will be possible according to the aggregated transmission timer
std::vector< Ptr< LogicalLoraChannel > > GetChannelList()
Get the list of LogicalLoraChannels currently registered on this helper.
static TypeId GetTypeId()
Register this type.
std::vector< Ptr< LogicalLoraChannel > > m_channelList
A vector of the LogicalLoraChannels that are currently registered within this helper.
Time m_nextAggregatedTransmissionTime
The next time at which.
std::vector< Ptr< LogicalLoraChannel > > GetEnabledChannelList()
Get the list of LogicalLoraChannels currently registered on this helper that have been enabled for Up...
void AddSubBand(double firstFrequency, double lastFrequency, double dutyCycle, double maxTxPowerDbm)
Add a new SubBand to this helper.
Time GetWaitingTime(Ptr< LogicalLoraChannel > channel)
Get the time it is necessary to wait for before transmitting on a given channel.
void AddEvent(Time duration, Ptr< LogicalLoraChannel > channel)
Register the transmission of a packet.
std::list< Ptr< SubBand > > m_subBandList
A list of the SubBands that are currently registered within this helper.
Ptr< SubBand > GetSubBandFromChannel(Ptr< LogicalLoraChannel > channel)
Get the SubBand a channel belongs to.
void AddChannel(double frequency)
Add a new channel to the list.
Every class exported by the ns3 library is enclosed in the ns3 namespace.