A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-phy-operating-channel.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021
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 * Authors: Stefano Avallone <stavallo@unina.it>
18 * Sébastien Deronne <sebastien.deronne@gmail.com>
19 */
20
21#ifndef WIFI_PHY_OPERATING_CHANNEL_H
22#define WIFI_PHY_OPERATING_CHANNEL_H
23
24#include "wifi-phy-band.h"
25#include "wifi-standards.h"
26
27#include "ns3/he-ru.h"
28
29#include <set>
30#include <tuple>
31
32namespace ns3
33{
34
35/**
36 * A tuple (number, frequency, width, type, band) identifying a frequency channel
37 */
38typedef std::tuple<uint8_t, uint16_t, uint16_t, FrequencyChannelType, WifiPhyBand>
40
41/**
42 * \ingroup wifi
43 *
44 * Class that keeps track of all information about the current PHY operating channel.
45 */
47{
48 public:
49 /// Typedef for a const iterator pointing to a channel in the set of available channels
50 typedef std::set<FrequencyChannelInfo>::const_iterator ConstIterator;
51
52 /**
53 * Create an uninitialized PHY operating channel.
54 */
56
57 /**
58 * Create a PHY operating channel from an iterator pointing to a channel in the set of available
59 * channels.
60 *
61 * \param it the iterator pointing to a channel in the set of available channels
62 */
64
66
67 /**
68 * Check if the given WifiPhyOperatingChannel is equivalent.
69 * Note that the primary20 channels are not compared.
70 *
71 * \param other another WifiPhyOperatingChannel
72 *
73 * \return true if the given WifiPhyOperatingChannel is equivalent,
74 * false otherwise
75 */
76 bool operator==(const WifiPhyOperatingChannel& other) const;
77
78 /**
79 * Check if the given WifiPhyOperatingChannel is different.
80 *
81 * \param other another WifiPhyOperatingChannel
82 *
83 * \return true if the given WifiPhyOperatingChannel is different,
84 * false otherwise
85 */
86 bool operator!=(const WifiPhyOperatingChannel& other) const;
87
88 static const std::set<FrequencyChannelInfo>
89 m_frequencyChannels; //!< Available frequency channels
90
91 /**
92 * Return true if a valid channel has been set, false otherwise.
93 *
94 * \return true if a valid channel has been set, false otherwise
95 */
96 bool IsSet() const;
97 /**
98 * Set the channel according to the specified parameters if a unique
99 * frequency channel matches the specified criteria, or abort the
100 * simulation otherwise.
101 * If the channel width is a multiple of 20 MHz, the primary 20 MHz channel
102 * is set to the 20 MHz subchannel with the lowest center frequency.
103 *
104 * \param number the channel number (use 0 to leave it unspecified)
105 * \param frequency the channel center frequency in MHz (use 0 to leave it unspecified)
106 * \param width the channel width in MHz (use 0 to leave it unspecified)
107 * \param standard the standard
108 * \param band the PHY band
109 */
110 void Set(uint8_t number,
111 uint16_t frequency,
112 uint16_t width,
113 WifiStandard standard,
114 WifiPhyBand band);
115 /**
116 * Set the default channel of the given width and for the given standard and band.
117 * If the channel width is a multiple of 20 MHz, the primary 20 MHz channel
118 * is set to the 20 MHz subchannel with the lowest center frequency.
119 *
120 * \param width the channel width in MHz
121 * \param standard the standard
122 * \param band the PHY band
123 */
124 void SetDefault(uint16_t width, WifiStandard standard, WifiPhyBand band);
125
126 /**
127 * Get the default channel number of the given width and for the given standard
128 * and band.
129 *
130 * \param width the channel width in MHz
131 * \param standard the standard
132 * \param band the PHY band
133 * \return the default channel number
134 */
135 static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band);
136
137 /**
138 * Return the channel number identifying the whole operating channel.
139 *
140 * \return the channel number identifying the whole operating channel
141 */
142 uint8_t GetNumber() const;
143 /**
144 * Return the center frequency of the operating channel (in MHz).
145 *
146 * \return the center frequency of the operating channel (in MHz)
147 */
148 uint16_t GetFrequency() const;
149 /**
150 * Return the width of the whole operating channel (in MHz).
151 *
152 * \return the width of the whole operating channel (in MHz)
153 */
154 uint16_t GetWidth() const;
155 /**
156 * Return the PHY band of the operating channel
157 *
158 * \return the PHY band of the operating channel
159 */
160 WifiPhyBand GetPhyBand() const;
161 /**
162 * Return whether the operating channel is an OFDM channel.
163 *
164 * \return whether the operating channel is an OFDM channel
165 */
166 bool IsOfdm() const;
167 /**
168 * Return whether the operating channel is a DSSS channel.
169 *
170 * \return whether the operating channel is a DSSS channel
171 */
172 bool IsDsss() const;
173 /**
174 * Return whether the operating channel is an 802.11p channel.
175 *
176 * \return whether the operating channel is an 802.11p channel
177 */
178 bool Is80211p() const;
179
180 /**
181 * If the operating channel width is a multiple of 20 MHz, return the index of the
182 * primary channel of the given width within the operating channel (0 indicates
183 * the 20 MHz subchannel with the lowest center frequency). Otherwise, return 0.
184 *
185 * \param primaryChannelWidth the width of the primary channel in MHz
186 * \return the index of the requested primary channel within the operating channel
187 */
188 uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const;
189
190 /**
191 * If the operating channel width is made of a multiple of 20 MHz, return the index of the
192 * secondary channel of the given width within the operating channel (0 indicates
193 * the 20 MHz subchannel with the lowest center frequency). Otherwise, return 0.
194 *
195 * \param secondaryChannelWidth the width of the secondary channel in MHz
196 * \return the index of the requested secondary channel within the operating channel
197 */
198 uint8_t GetSecondaryChannelIndex(uint16_t secondaryChannelWidth) const;
199
200 /**
201 * Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel
202 * with the lowest center frequency).
203 *
204 * \param index the index of the primary 20 MHz channel
205 */
206 void SetPrimary20Index(uint8_t index);
207
208 /**
209 * Get the center frequency of the primary channel of the given width.
210 *
211 * \param primaryChannelWidth the width of the primary channel in MHz
212 * \return the center frequency of the primary channel of the given width
213 */
214 uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const;
215
216 /**
217 * Get the center frequency of the secondary channel of the given width.
218 *
219 * \param secondaryChannelWidth the width of the secondary channel in MHz
220 * \return the center frequency of the secondary channel of the given width
221 */
222 uint16_t GetSecondaryChannelCenterFrequency(uint16_t secondaryChannelWidth) const;
223
224 /**
225 * Get the channel indices of all the 20 MHz channels included in the primary
226 * channel of the given width, if such primary channel exists, or an empty set,
227 * otherwise.
228 *
229 * \param width the width in MHz of the primary channel
230 * \return the channel indices of all the 20 MHz channels included in the primary
231 * channel of the given width, if such primary channel exists, or an empty set,
232 * otherwise
233 */
234 std::set<uint8_t> GetAll20MHzChannelIndicesInPrimary(uint16_t width) const;
235 /**
236 * Get the channel indices of all the 20 MHz channels included in the secondary
237 * channel of the given width, if such secondary channel exists, or an empty set,
238 * otherwise.
239 *
240 * \param width the width in MHz of the secondary channel
241 * \return the channel indices of all the 20 MHz channels included in the secondary
242 * channel of the given width, if such secondary channel exists, or an empty set,
243 * otherwise
244 */
245 std::set<uint8_t> GetAll20MHzChannelIndicesInSecondary(uint16_t width) const;
246 /**
247 * Get the channel indices of all the 20 MHz channels included in the secondary
248 * channel corresponding to the given primary channel, if such secondary channel
249 * exists, or an empty set, otherwise.
250 *
251 * \param primaryIndices the channel indices of all the 20 MHz channels included
252 * in the primary channel
253 * \return the channel indices of all the 20 MHz channels included in the secondary
254 * channel corresponding to the given primary channel, if such secondary channel
255 * exists, or an empty set, otherwise
256 */
257 std::set<uint8_t> GetAll20MHzChannelIndicesInSecondary(
258 const std::set<uint8_t>& primaryIndices) const;
259
260 /**
261 * Find the first channel matching the specified parameters.
262 *
263 * \param number the channel number (use 0 to leave it unspecified)
264 * \param frequency the channel center frequency in MHz (use 0 to leave it unspecified)
265 * \param width the channel width in MHz (use 0 to leave it unspecified)
266 * \param standard the standard (use WIFI_STANDARD_UNSPECIFIED not to check whether a
267 * channel is suitable for a specific standard)
268 * \param band the PHY band
269 * \param start an iterator pointing to the channel to start the search with
270 * \return an iterator pointing to the found channel, if any, or to past-the-end
271 * of the set of available channels
272 */
273 static ConstIterator FindFirst(uint8_t number,
274 uint16_t frequency,
275 uint16_t width,
276 WifiStandard standard,
277 WifiPhyBand band,
278 ConstIterator start = m_frequencyChannels.begin());
279
280 /**
281 * Get channel number of the primary channel
282 * \param primaryChannelWidth the width of the primary channel (MHz)
283 * \param standard the standard
284 *
285 * \return channel number of the primary channel
286 */
287 uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const;
288
289 /**
290 * Get the channel indices of the minimum subset of 20 MHz channels containing the given RU.
291 *
292 * \param ru the given RU
293 * \param width the width in MHz of the channel to which the given RU refers to; normally,
294 * it is the width in MHz of the PPDU for which the RU is allocated
295 * \return the channel indices of the minimum subset of 20 MHz channels containing the given RU
296 */
297 std::set<uint8_t> Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, uint16_t width) const;
298
299 private:
300 ConstIterator m_channelIt; //!< const iterator pointing to the configured frequency channel
301 uint8_t m_primary20Index; /**< index of the primary20 channel (0 indicates the 20 MHz
302 subchannel with the lowest center frequency) */
303};
304
305/**
306 * \brief Stream insertion operator.
307 *
308 * \param os the stream
309 * \param channel the operating channel
310 * \returns a reference to the stream
311 */
312std::ostream& operator<<(std::ostream& os, const WifiPhyOperatingChannel& channel);
313
314} // namespace ns3
315
316#endif /* WIFI_PHY_OPERATING_CHANNEL_H */
RU Specification.
Definition: he-ru.h:66
Class that keeps track of all information about the current PHY operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
bool operator==(const WifiPhyOperatingChannel &other) const
Check if the given WifiPhyOperatingChannel is equivalent.
WifiPhyOperatingChannel()
Create an uninitialized PHY operating channel.
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
uint16_t GetSecondaryChannelCenterFrequency(uint16_t secondaryChannelWidth) const
Get the center frequency of the secondary channel of the given width.
bool operator!=(const WifiPhyOperatingChannel &other) const
Check if the given WifiPhyOperatingChannel is different.
bool IsDsss() const
Return whether the operating channel is a DSSS channel.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
ConstIterator m_channelIt
const iterator pointing to the configured frequency channel
static ConstIterator FindFirst(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first channel matching the specified parameters.
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
bool Is80211p() const
Return whether the operating channel is an 802.11p channel.
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
void SetDefault(uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given standard and band.
bool IsOfdm() const
Return whether the operating channel is an OFDM channel.
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band)
Get the default channel number of the given width and for the given standard and band.
std::set< uint8_t > GetAll20MHzChannelIndicesInSecondary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the secondary channel of the given wid...
std::set< uint8_t > Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, uint16_t width) const
Get the channel indices of the minimum subset of 20 MHz channels containing the given RU.
uint8_t GetSecondaryChannelIndex(uint16_t secondaryChannelWidth) const
If the operating channel width is made of a multiple of 20 MHz, return the index of the secondary cha...
uint8_t m_primary20Index
index of the primary20 channel (0 indicates the 20 MHz subchannel with the lowest center frequency)
std::set< uint8_t > GetAll20MHzChannelIndicesInPrimary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the primary channel of the given width...
WifiPhyBand GetPhyBand() const
Return the PHY band of the operating channel.
uint8_t GetNumber() const
Return the channel number identifying the whole operating channel.
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
std::set< FrequencyChannelInfo >::const_iterator ConstIterator
Typedef for a const iterator pointing to a channel in the set of available channels.
uint16_t GetFrequency() const
Return the center frequency of the operating channel (in MHz).
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::tuple< uint8_t, uint16_t, uint16_t, FrequencyChannelType, WifiPhyBand > FrequencyChannelInfo
A tuple (number, frequency, width, type, band) identifying a frequency channel.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159