A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-spectrum-value-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 * Copyright (c) 2017 Orange Labs
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Nicola Baldo <nbaldo@cttc.es>
19 * Rediet <getachew.redieteab@orange.com>
20 */
21
22#ifndef WIFI_SPECTRUM_VALUE_HELPER_H
23#define WIFI_SPECTRUM_VALUE_HELPER_H
24
25#include "spectrum-value.h"
26
27namespace ns3
28{
29
30/**
31 * typedef for a pair of start and stop sub-band indices
32 */
33using WifiSpectrumBandIndices = std::pair<uint32_t, uint32_t>;
34
35/**
36 * \ingroup spectrum
37 *
38 * This class defines all functions to create a spectrum model for
39 * Wi-Fi based on a a spectral model aligned with an OFDM subcarrier
40 * spacing of 312.5 KHz (model also reused for DSSS modulations)
41 */
43{
44 public:
45 /**
46 * Destructor
47 */
48 virtual ~WifiSpectrumValueHelper() = default;
49
50 /**
51 * Return a SpectrumModel instance corresponding to the center frequency
52 * and channel width. The spectrum model spans the channel width
53 * +/- the guard bands (i.e. the model will span (channelWidth +
54 * 2 * guardBandwidth) MHz of bandwidth).
55 *
56 * \param centerFrequency center frequency (MHz)
57 * \param channelWidth channel width (MHz)
58 * \param carrierSpacing carrier spacing (Hz)
59 * \param guardBandwidth width of the guard band (MHz)
60 *
61 * \return the static SpectrumModel instance corresponding to the
62 * given carrier frequency and channel width configuration.
63 */
64 static Ptr<SpectrumModel> GetSpectrumModel(uint32_t centerFrequency,
65 uint16_t channelWidth,
66 uint32_t carrierSpacing,
67 uint16_t guardBandwidth);
68
69 /**
70 * Create a transmit power spectral density corresponding to DSSS
71 *
72 * The center frequency typically corresponds to 802.11b channel
73 * center frequencies but is not restricted to those frequencies.
74 *
75 * \note There is no channel width parameter; this method assumes 22 MHz
76 *
77 * \param centerFrequency center frequency (MHz)
78 * \param txPowerW transmit power (W) to allocate
79 * \param guardBandwidth width of the guard band (MHz)
80 * \returns a pointer to a newly allocated SpectrumValue representing the DSSS Transmit Power
81 * Spectral Density in W/Hz
82 */
84 double txPowerW,
85 uint16_t guardBandwidth);
86
87 /**
88 * Create a transmit power spectral density corresponding to OFDM
89 * (802.11a/g). Channel width may vary between 20, 10, and 5 MHz.
90 * Guard bandwidth also typically varies with channel width.
91 *
92 * \param centerFrequency center frequency (MHz)
93 * \param channelWidth channel width (MHz)
94 * \param txPowerW transmit power (W) to allocate
95 * \param guardBandwidth width of the guard band (MHz)
96 * \param minInnerBandDbr the minimum relative power in the inner band (in dBr)
97 * \param minOuterbandDbr the minimum relative power in the outer band (in dBr)
98 * \param lowestPointDbr maximum relative power of the outermost subcarriers of the guard band
99 * (in dBr)
100 * \return a pointer to a newly allocated SpectrumValue representing the OFDM Transmit Power
101 * Spectral Density in W/Hz for each Band
102 */
104 uint16_t channelWidth,
105 double txPowerW,
106 uint16_t guardBandwidth,
107 double minInnerBandDbr = -20,
108 double minOuterbandDbr = -28,
109 double lowestPointDbr = -40);
110
111 /**
112 * Create a transmit power spectral density corresponding to OFDM duplicated over multiple 20
113 * MHz subchannels. Channel width may vary between 20, 40, 80, and 160 MHz.
114 *
115 * \param centerFrequency center frequency (MHz)
116 * \param channelWidth channel width (MHz)
117 * \param txPowerW transmit power (W) to allocate
118 * \param guardBandwidth width of the guard band (MHz)
119 * \param minInnerBandDbr the minimum relative power in the inner band (in dBr)
120 * \param minOuterbandDbr the minimum relative power in the outer band (in dBr)
121 * \param lowestPointDbr maximum relative power of the outermost subcarriers of the guard band
122 * (in dBr)
123 * \param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
124 * \return a pointer to a newly allocated SpectrumValue representing the duplicated 20 MHz OFDM
125 * Transmit Power Spectral Density in W/Hz for each Band
126 */
128 uint32_t centerFrequency,
129 uint16_t channelWidth,
130 double txPowerW,
131 uint16_t guardBandwidth,
132 double minInnerBandDbr = -20,
133 double minOuterbandDbr = -28,
134 double lowestPointDbr = -40,
135 const std::vector<bool>& puncturedSubchannels = std::vector<bool>{});
136
137 /**
138 * Create a transmit power spectral density corresponding to OFDM
139 * High Throughput (HT) (802.11n/ac). Channel width may vary between
140 * 20, 40, 80, and 160 MHz.
141 *
142 * \param centerFrequency center frequency (MHz)
143 * \param channelWidth channel width (MHz)
144 * \param txPowerW transmit power (W) to allocate
145 * \param guardBandwidth width of the guard band (MHz)
146 * \param minInnerBandDbr the minimum relative power in the inner band (in dBr)
147 * \param minOuterbandDbr the minimum relative power in the outer band (in dBr)
148 * \param lowestPointDbr maximum relative power of the outermost subcarriers of the guard band
149 * (in dBr)
150 * \return a pointer to a newly allocated SpectrumValue representing the HT OFDM Transmit Power
151 * Spectral Density in W/Hz for each Band
152 */
154 uint16_t channelWidth,
155 double txPowerW,
156 uint16_t guardBandwidth,
157 double minInnerBandDbr = -20,
158 double minOuterbandDbr = -28,
159 double lowestPointDbr = -40);
160
161 /**
162 * Create a transmit power spectral density corresponding to OFDM
163 * High Efficiency (HE) (802.11ax). Channel width may vary between
164 * 20, 40, 80, and 160 MHz.
165 *
166 * \param centerFrequency center frequency (MHz)
167 * \param channelWidth channel width (MHz)
168 * \param txPowerW transmit power (W) to allocate
169 * \param guardBandwidth width of the guard band (MHz)
170 * \param minInnerBandDbr the minimum relative power in the inner band (in dBr)
171 * \param minOuterbandDbr the minimum relative power in the outer band (in dBr)
172 * \param lowestPointDbr maximum relative power of the outermost subcarriers of the guard band
173 * (in dBr)
174 * \param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
175 * \return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
176 * Spectral Density in W/Hz for each Band
177 */
179 uint32_t centerFrequency,
180 uint16_t channelWidth,
181 double txPowerW,
182 uint16_t guardBandwidth,
183 double minInnerBandDbr = -20,
184 double minOuterbandDbr = -28,
185 double lowestPointDbr = -40,
186 const std::vector<bool>& puncturedSubchannels = std::vector<bool>{});
187
188 /**
189 * Create a transmit power spectral density corresponding to the OFDMA part
190 * of HE TB PPDUs for a given RU.
191 * An ideal (i.e. rectangular) spectral mask is considered for the time being.
192 *
193 * \param centerFrequency center frequency (MHz)
194 * \param channelWidth channel width (MHz)
195 * \param txPowerW transmit power (W) to allocate
196 * \param guardBandwidth width of the guard band (MHz)
197 * \param ru the RU band used by the STA
198 * \return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
199 * Spectral Density on the RU used by the STA in W/Hz for each Band
200 */
201 static Ptr<SpectrumValue> CreateHeMuOfdmTxPowerSpectralDensity(
202 uint32_t centerFrequency,
203 uint16_t channelWidth,
204 double txPowerW,
205 uint16_t guardBandwidth,
206 const WifiSpectrumBandIndices& ru);
207
208 /**
209 * Create a power spectral density corresponding to the noise
210 *
211 * \param centerFrequency center frequency (MHz)
212 * \param channelWidth channel width (MHz)
213 * \param carrierSpacing carrier spacing (Hz)
214 * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
215 * \param guardBandwidth width of the guard band (MHz)
216 * \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral
217 * Density in W/Hz for each Band
218 */
219 static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity(uint32_t centerFrequency,
220 uint16_t channelWidth,
221 uint32_t carrierSpacing,
222 double noiseFigure,
223 uint16_t guardBandwidth);
224
225 /**
226 * Create a thermal noise power spectral density
227 *
228 * \param noiseFigure the noise figure
229 * \param spectrumModel the spectrum model
230 * \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral
231 * Density in W/Hz corresponding to thermal noise, for each Band
232 */
233 static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity(double noiseFigure,
234 Ptr<SpectrumModel> spectrumModel);
235
236 /**
237 * Create a transmit power spectral density corresponding to OFDM
238 * transmit spectrum mask requirements for 11a/11g/11n/11ac/11ax
239 * Channel width may vary between 5, 10, 20, 40, 80, and 160 MHz.
240 * The default (standard) values are illustrated below.
241 *
242 * [ guard band ][ channel width ][ guard band ]
243 * __________ __________ _ 0 dBr
244 * / | | \
245 * / |_| \ _ -20 dBr
246 * . ' ' .
247 * . ' ' . _ -28 dBr
248 * .' '.
249 * .' '.
250 * .' '. _ lowest point
251 *
252 * |-----| |-----| outerBand left/right
253 * |------| |-- ---| middle band left/right
254 * |-| |-| inner band left/right
255 * |-----------------------| allocated sub-bands
256 * |-----------------------------------------------------| mask band
257 *
258 * Please take note that, since guard tones are within the allocated band
259 * while not being ideally allocated any power, the inner band had to be
260 * shifted inwards and a flat junction band (at -20 dBr) had to be added
261 * between the inner and the middle bands.
262 *
263 * \param c spectrumValue to allocate according to transmit power spectral density mask (in W/Hz
264 * for each band)
265 * \param allocatedSubBands vector of start and stop subcarrier indexes of the allocated sub
266 * bands
267 * \param maskBand start and stop subcarrier indexes of transmit mask (in case signal doesn't
268 * cover whole SpectrumModel)
269 * \param txPowerPerBandW power allocated to each subcarrier in the allocated sub bands
270 * \param nGuardBands size (in number of subcarriers) of the guard band (left and right)
271 * \param innerSlopeWidth size (in number of subcarriers) of the inner band (i.e. slope going
272 * from 0 dBr to -20 dBr in the figure above)
273 * \param minInnerBandDbr the minimum relative power in the inner band (i.e., -20 dBr in the
274 * figure above)
275 * \param minOuterbandDbr the minimum relative power in the outer band (i.e., -28 dBr in the
276 * figure above)
277 * \param lowestPointDbr maximum relative power of the outermost subcarriers of the guard band
278 * (in dBr)
279 * \param puncturedSubBands vector of start and stop subcarrier indexes of the punctured sub
280 * bands
281 * \param puncturedSlopeWidth size (in number of subcarriers) of the punctured band slope
282 */
283 static void CreateSpectrumMaskForOfdm(
284 Ptr<SpectrumValue> c,
285 const std::vector<WifiSpectrumBandIndices>& allocatedSubBands,
286 const WifiSpectrumBandIndices& maskBand,
287 double txPowerPerBandW,
288 uint32_t nGuardBands,
289 uint32_t innerSlopeWidth,
290 double minInnerBandDbr,
291 double minOuterbandDbr,
292 double lowestPointDbr,
293 const std::vector<WifiSpectrumBandIndices>& puncturedSubBands =
294 std::vector<WifiSpectrumBandIndices>{},
295 uint32_t puncturedSlopeWidth = 0);
296
297 /**
298 * Normalize the transmit spectrum mask generated by CreateSpectrumMaskForOfdm
299 * so that the total transmitted power corresponds to the input value.
300 *
301 * \param c spectrumValue to normalize (in W/Hz for each band)
302 * \param txPowerW total transmit power (W) to allocate
303 */
304 static void NormalizeSpectrumMask(Ptr<SpectrumValue> c, double txPowerW);
305
306 /**
307 * Convert from dBm to Watts.
308 * Taken from wifi-utils since the original method couldn't be called from here
309 * due to resulting circular dependencies of spectrum and wifi modules.
310 *
311 * \param dbm the power in dBm
312 *
313 * \return the equivalent Watts for the given dBm
314 */
315 static double DbmToW(double dbm);
316
317 /**
318 * Calculate the power of the specified band composed of uniformly-sized sub-bands.
319 *
320 * \param psd received Power Spectral Density in W/Hz
321 * \param band a pair of start and stop indexes that defines the band
322 *
323 * \return band power in W
324 */
325 static double GetBandPowerW(Ptr<SpectrumValue> psd, const WifiSpectrumBandIndices& band);
326};
327
328/**
329 * \ingroup spectrum
330 * Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
331 */
333{
334 uint16_t minFrequency{0}; ///< the minimum frequency in MHz
335 uint16_t maxFrequency{0}; ///< the maximum frequency in MHz
336};
337
338/**
339 * Compare two FrequencyRange values
340 *
341 * \param lhs the FrequencyRange value on the left of operator
342 * \param rhs the FrequencyRange value on the right of operator
343 *
344 * \return true if minFrequency of left is less than minFrequency of right, false otherwise
345 */
346bool operator<(const FrequencyRange& lhs, const FrequencyRange& rhs);
347
348/**
349 * Compare two FrequencyRange values
350 *
351 * \param lhs the FrequencyRange value on the left of operator
352 * \param rhs the FrequencyRange value on the right of operator
353 *
354 * \return true if both minFrequency and maxFrequency of left are equal to minFrequency and
355 * maxFrequency of right respectively, false otherwise
356 */
357bool operator==(const FrequencyRange& lhs, const FrequencyRange& rhs);
358
359/**
360 * Compare two FrequencyRange values
361 *
362 * \param lhs the FrequencyRange value on the left of operator
363 * \param rhs the FrequencyRange value on the right of operator
364 *
365 * \return true if either minFrequency or maxFrequency of left different from minFrequency or
366 * maxFrequency of right respectively, false otherwise
367 */
368bool operator!=(const FrequencyRange& lhs, const FrequencyRange& rhs);
369
370/**
371 * Serialize FrequencyRange values to ostream (human-readable).
372 *
373 * \param os the output stream
374 * \param freqRange the FrequencyRange
375 *
376 * \return std::ostream
377 */
378std::ostream& operator<<(std::ostream& os, const FrequencyRange& freqRange);
379
380/// Identifier for the frequency range covering the whole wifi spectrum
381constexpr FrequencyRange WHOLE_WIFI_SPECTRUM = {2401, 7125};
382
383/// Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band
384constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ = {2401, 2483};
385
386/// Identifier for the frequency range covering the wifi spectrum in the 5 GHz band
387constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ = {5170, 5915};
388
389/// Identifier for the frequency range covering the wifi spectrum in the 6 GHz band
390constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ = {5945, 7125};
391
392} // namespace ns3
393
394#endif /* WIFI_SPECTRUM_VALUE_HELPER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
This class defines all functions to create a spectrum model for Wi-Fi based on a a spectral model ali...
static Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, uint32_t carrierSpacing, double noiseFigure, uint16_t guardBandwidth)
Create a power spectral density corresponding to the noise.
static Ptr< SpectrumValue > CreateDuplicated20MhzTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40, const std::vector< bool > &puncturedSubchannels=std::vector< bool >{})
Create a transmit power spectral density corresponding to OFDM duplicated over multiple 20 MHz subcha...
static void CreateSpectrumMaskForOfdm(Ptr< SpectrumValue > c, const std::vector< WifiSpectrumBandIndices > &allocatedSubBands, const WifiSpectrumBandIndices &maskBand, double txPowerPerBandW, uint32_t nGuardBands, uint32_t innerSlopeWidth, double minInnerBandDbr, double minOuterbandDbr, double lowestPointDbr, const std::vector< WifiSpectrumBandIndices > &puncturedSubBands=std::vector< WifiSpectrumBandIndices >{}, uint32_t puncturedSlopeWidth=0)
Create a transmit power spectral density corresponding to OFDM transmit spectrum mask requirements fo...
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM High Throughput (HT) (802....
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
virtual ~WifiSpectrumValueHelper()=default
Destructor.
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t centerFrequency, uint16_t channelWidth, uint32_t carrierSpacing, uint16_t guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width.
static Ptr< SpectrumValue > CreateDsssTxPowerSpectralDensity(uint32_t centerFrequency, double txPowerW, uint16_t guardBandwidth)
Create a transmit power spectral density corresponding to DSSS.
static double GetBandPowerW(Ptr< SpectrumValue > psd, const WifiSpectrumBandIndices &band)
Calculate the power of the specified band composed of uniformly-sized sub-bands.
static double DbmToW(double dbm)
Convert from dBm to Watts.
static void NormalizeSpectrumMask(Ptr< SpectrumValue > c, double txPowerW)
Normalize the transmit spectrum mask generated by CreateSpectrumMaskForOfdm so that the total transmi...
static Ptr< SpectrumValue > CreateHeMuOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, const WifiSpectrumBandIndices &ru)
Create a transmit power spectral density corresponding to the OFDMA part of HE TB PPDUs for a given R...
static Ptr< SpectrumValue > CreateHeOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40, const std::vector< bool > &puncturedSubchannels=std::vector< bool >{})
Create a transmit power spectral density corresponding to OFDM High Efficiency (HE) (802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ
Identifier for the frequency range covering the wifi spectrum in the 6 GHz band.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:678
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
constexpr FrequencyRange WHOLE_WIFI_SPECTRUM
Identifier for the frequency range covering the whole wifi spectrum.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
uint16_t maxFrequency
the maximum frequency in MHz
uint16_t minFrequency
the minimum frequency in MHz