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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Nicola Baldo <nbaldo@cttc.es>
8 * Rediet <getachew.redieteab@orange.com>
9 */
10
11#ifndef WIFI_SPECTRUM_VALUE_HELPER_H
12#define WIFI_SPECTRUM_VALUE_HELPER_H
13
14#include "wifi-units.h"
15
16#include "ns3/spectrum-value.h"
17
18#include <vector>
19
20namespace ns3
21{
22
23/**
24 * typedef for a pair of start and stop sub-band indices
25 */
26using WifiSpectrumBandIndices = std::pair<uint32_t, uint32_t>;
27
28/**
29 * @ingroup spectrum
30 *
31 * This class defines all functions to create a spectrum model for
32 * Wi-Fi based on a a spectral model aligned with an OFDM subcarrier
33 * spacing of 312.5 KHz (model also reused for DSSS modulations)
34 */
36{
37 public:
38 /**
39 * Destructor
40 */
41 virtual ~WifiSpectrumValueHelper() = default;
42
43 /**
44 * Return a SpectrumModel instance corresponding to the center frequency
45 * and channel width. The spectrum model spans the channel width
46 * +/- the guard bands (i.e. the model will span (channelWidth +
47 * 2 * guardBandwidth) MHz of bandwidth).
48 *
49 * @param centerFrequencies center frequency per segment
50 * @param channelWidth total allocated channel width over all segments
51 * @param carrierSpacing carrier spacing
52 * @param guardBandwidth total width of the guard band, which will be split over the segments
53 * @return the static SpectrumModel instance corresponding to the
54 * given carrier frequency and channel width configuration.
55 */
56 static Ptr<SpectrumModel> GetSpectrumModel(const std::vector<MHz_u>& centerFrequencies,
57 MHz_u channelWidth,
58 Hz_u carrierSpacing,
59 MHz_u guardBandwidth);
60
61 /**
62 * Create a transmit power spectral density corresponding to DSSS
63 *
64 * The center frequency typically corresponds to 802.11b channel
65 * center frequencies but is not restricted to those frequencies.
66 *
67 * @note There is no channel width parameter; this method assumes 22 MHz
68 *
69 * @param centerFrequency center frequency
70 * @param txPower transmit power to allocate
71 * @param guardBandwidth width of the guard band
72 * @returns a pointer to a newly allocated SpectrumValue representing the DSSS Transmit Power
73 * Spectral Density in W/Hz
74 */
76 Watt_u txPower,
77 MHz_u guardBandwidth);
78
79 /**
80 * Create a transmit power spectral density corresponding to OFDM
81 * (802.11a/g). Channel width may vary between 20, 10, and 5 MHz.
82 * Guard bandwidth also typically varies with channel width.
83 *
84 * @param centerFrequency center frequency
85 * @param channelWidth channel width
86 * @param txPower transmit power to allocate
87 * @param guardBandwidth width of the guard band
88 * @param minInnerBand the minimum relative power in the inner band
89 * @param minOuterband the minimum relative power in the outer band
90 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
91 * @return a pointer to a newly allocated SpectrumValue representing the OFDM Transmit Power
92 * Spectral Density in W/Hz for each Band
93 */
95 MHz_u channelWidth,
96 Watt_u txPower,
97 MHz_u guardBandwidth,
98 dBr_u minInnerBand = dBr_u{-20},
99 dBr_u minOuterband = dBr_u{-28},
100 dBr_u lowestPoint = dBr_u{-40});
101
102 /**
103 * Create a transmit power spectral density corresponding to OFDM duplicated over multiple 20
104 * MHz subchannels. Channel width may vary between 20, 40, 80, and 160 MHz.
105 *
106 * @param centerFrequencies center frequency per segment
107 * @param channelWidth total allocated channel width over all segments
108 * @param txPower transmit power to allocate
109 * @param guardBandwidth width of the guard band
110 * @param minInnerBand the minimum relative power in the inner band
111 * @param minOuterband the minimum relative power in the outer band
112 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
113 * @param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
114 * @return a pointer to a newly allocated SpectrumValue representing the duplicated 20 MHz OFDM
115 * Transmit Power Spectral Density in W/Hz for each Band
116 */
117 static Ptr<SpectrumValue> CreateDuplicated20MhzTxPowerSpectralDensity(
118 const std::vector<MHz_u>& centerFrequencies,
119 MHz_u channelWidth,
120 Watt_u txPower,
121 MHz_u guardBandwidth,
122 dBr_u minInnerBand = dBr_u{-20},
123 dBr_u minOuterband = dBr_u{-28},
124 dBr_u lowestPoint = dBr_u{-40},
125 const std::vector<bool>& puncturedSubchannels = {});
126
127 /**
128 * Create a transmit power spectral density corresponding to OFDM High Throughput (HT/VHT)
129 * (802.11n/ac). Channel width may vary between 20, 40, 80, and 160 MHz.
130 *
131 * @param centerFrequencies center frequency per segment
132 * @param channelWidth total allocated channel width over all segments
133 * @param txPower transmit power to allocate
134 * @param guardBandwidth width of the guard band
135 * @param minInnerBand the minimum relative power in the inner band
136 * @param minOuterband the minimum relative power in the outer band
137 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
138 * @return a pointer to a newly allocated SpectrumValue representing the HT OFDM Transmit Power
139 * Spectral Density in W/Hz for each Band
140 */
141 static Ptr<SpectrumValue> CreateHtOfdmTxPowerSpectralDensity(
142 const std::vector<MHz_u>& centerFrequencies,
143 MHz_u channelWidth,
144 Watt_u txPower,
145 MHz_u guardBandwidth,
146 dBr_u minInnerBand = dBr_u{-20},
147 dBr_u minOuterband = dBr_u{-28},
148 dBr_u lowestPoint = dBr_u{-40});
149
150 /**
151 * Create a transmit power spectral density corresponding to OFDM High Efficiency (HE/EHT)
152 * (802.11ax/be) for contiguous channels. Channel width may vary between 20, 40, 80, 160 and 320
153 * MHz.
154 *
155 * @param centerFrequency center frequency
156 * @param channelWidth channel width
157 * @param txPower transmit power to allocate
158 * @param guardBandwidth width of the guard band
159 * @param minInnerBand the minimum relative power in the inner band
160 * @param minOuterband the minimum relative power in the outer band
161 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
162 * @param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
163 * @return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
164 * Spectral Density in W/Hz for each Band
165 */
166 static Ptr<SpectrumValue> CreateHeOfdmTxPowerSpectralDensity(
167 MHz_u centerFrequency,
168 MHz_u channelWidth,
169 Watt_u txPower,
170 MHz_u guardBandwidth,
171 dBr_u minInnerBand = dBr_u{-20},
172 dBr_u minOuterband = dBr_u{-28},
173 dBr_u lowestPoint = dBr_u{-40},
174 const std::vector<bool>& puncturedSubchannels = {});
175
176 /**
177 * Create a transmit power spectral density corresponding to OFDM
178 * High Efficiency (HE) (802.11ax) made of one or more frequency segment(s).
179 * Channel width may vary between 20, 40, 80, and 160 MHz.
180 *
181 * @param centerFrequencies center frequency per segment
182 * @param channelWidth total allocated channel width over all segments
183 * @param txPower transmit power to allocate
184 * @param guardBandwidth width of the guard band
185 * @param minInnerBand the minimum relative power in the inner band
186 * @param minOuterband the minimum relative power in the outer band
187 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
188 * @param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
189 * @return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
190 * Spectral Density in W/Hz for each Band
191 */
192 static Ptr<SpectrumValue> CreateHeOfdmTxPowerSpectralDensity(
193 const std::vector<MHz_u>& centerFrequencies,
194 MHz_u channelWidth,
195 Watt_u txPower,
196 MHz_u guardBandwidth,
197 dBr_u minInnerBand = dBr_u{-20},
198 dBr_u minOuterband = dBr_u{-28},
199 dBr_u lowestPoint = dBr_u{-40},
200 const std::vector<bool>& puncturedSubchannels = {});
201
202 /**
203 * Create a transmit power spectral density corresponding to the OFDMA part
204 * of HE TB PPDUs for a given RU.
205 * An ideal (i.e. rectangular) spectral mask is considered for the time being.
206 *
207 * @param centerFrequencies center frequency per segment
208 * @param channelWidth total allocated channel width over all segments
209 * @param txPower transmit power to allocate
210 * @param guardBandwidth width of the guard band
211 * @param ru the RU band used by the STA
212 * @return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
213 * Spectral Density on the RU used by the STA in W/Hz for each Band
214 */
215 static Ptr<SpectrumValue> CreateHeMuOfdmTxPowerSpectralDensity(
216 const std::vector<MHz_u>& centerFrequencies,
217 MHz_u channelWidth,
218 Watt_u txPower,
219 MHz_u guardBandwidth,
220 const std::vector<WifiSpectrumBandIndices>& ru);
221
222 /**
223 * Create a transmit power spectral density corresponding to OFDM
224 * transmit spectrum mask requirements for 11a/11g/11n/11ac/11ax
225 * Channel width may vary between 5, 10, 20, 40, 80, and 160 MHz.
226 * The default (standard) values are illustrated below.
227 *
228 * [ guard band ][ channel width ][ guard band ]
229 * __________ __________ _ 0 dBr
230 * / | | \
231 * / |_| \ _ -20 dBr
232 * . ' ' .
233 * . ' ' . _ -28 dBr
234 * .' '.
235 * .' '.
236 * .' '. _ lowest point
237 *
238 * |-----| |-----| outerBand left/right
239 * |------| |-- ---| middle band left/right
240 * |-| |-| inner band left/right
241 * |-----------------------| allocated sub-bands
242 * |-----------------------------------------------------| mask band
243 *
244 * Please take note that, since guard tones are within the allocated band
245 * while not being ideally allocated any power, the inner band had to be
246 * shifted inwards and a flat junction band (at -20 dBr) had to be added
247 * between the inner and the middle bands.
248 *
249 * @param c spectrumValue to allocate according to transmit power spectral density mask (in W/Hz
250 * for each band)
251 * @param allocatedSubBandsPerSegment vector of start and stop subcarrier indexes of the
252 * allocated sub bands, for each segment
253 * @param maskBand start and stop subcarrier indexes of transmit mask (in case signal doesn't
254 * cover whole SpectrumModel)
255 * @param txPowerPerBand power allocated to each subcarrier in the allocated sub bands
256 * @param nGuardBands size (in number of subcarriers) of the guard band (left and right)
257 * @param innerSlopeWidth size (in number of subcarriers) of the inner band (i.e. slope going
258 * from 0 dBr to -20 dBr in the figure above)
259 * @param minInnerBand the minimum relative power in the inner band (i.e., -20 dBr in the
260 * figure above)
261 * @param minOuterband the minimum relative power in the outer band (i.e., -28 dBr in the
262 * figure above)
263 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
264 * @param puncturedSubBands vector of start and stop subcarrier indexes of the punctured sub
265 * bands, for each segment
266 * @param puncturedSlopeWidth size (in number of subcarriers) of the punctured band slope
267 */
268 static void CreateSpectrumMaskForOfdm(
269 Ptr<SpectrumValue> c,
270 const std::vector<std::vector<WifiSpectrumBandIndices>>& allocatedSubBandsPerSegment,
271 const WifiSpectrumBandIndices& maskBand,
272 Watt_u txPowerPerBand,
273 uint32_t nGuardBands,
274 uint32_t innerSlopeWidth,
275 dBr_u minInnerBand,
276 dBr_u minOuterband,
277 dBr_u lowestPoint,
278 const std::vector<std::vector<WifiSpectrumBandIndices>>& puncturedSubBands = {},
279 uint32_t puncturedSlopeWidth = 0);
280
281 /**
282 * Normalize the transmit spectrum mask generated by CreateSpectrumMaskForOfdm
283 * so that the total transmitted power corresponds to the input value.
284 *
285 * @param c spectrumValue to normalize (in W/Hz for each band)
286 * @param txPower total transmit power to allocate
287 */
288 static void NormalizeSpectrumMask(Ptr<SpectrumValue> c, Watt_u txPower);
289
290 /**
291 * Calculate the power of the specified band composed of uniformly-sized sub-bands.
292 *
293 * @param psd received Power Spectral Density in W/Hz
294 * @param segments a vector of pair of start and stop indexes that defines each segment of the
295 * band
296 *
297 * @return band power
298 */
299 static Watt_u GetBandPowerW(Ptr<SpectrumValue> psd,
300 const std::vector<WifiSpectrumBandIndices>& segments);
301};
302
303/**
304 * @ingroup spectrum
305 * Struct defining a frequency range between minFrequency and maxFrequency.
306 */
308{
309 MHz_u minFrequency{0}; ///< the minimum frequency
310 MHz_u maxFrequency{0}; ///< the maximum frequency
311};
312
313/**
314 * Compare two FrequencyRange values
315 *
316 * @param lhs the FrequencyRange value on the left of operator
317 * @param rhs the FrequencyRange value on the right of operator
318 *
319 * @return true if minFrequency of left is less than minFrequency of right, false otherwise
320 */
321bool operator<(const FrequencyRange& lhs, const FrequencyRange& rhs);
322
323/**
324 * Compare two FrequencyRange values
325 *
326 * @param lhs the FrequencyRange value on the left of operator
327 * @param rhs the FrequencyRange value on the right of operator
328 *
329 * @return true if both minFrequency and maxFrequency of left are equal to minFrequency and
330 * maxFrequency of right respectively, false otherwise
331 */
332bool operator==(const FrequencyRange& lhs, const FrequencyRange& rhs);
333
334/**
335 * Compare two FrequencyRange values
336 *
337 * @param lhs the FrequencyRange value on the left of operator
338 * @param rhs the FrequencyRange value on the right of operator
339 *
340 * @return true if either minFrequency or maxFrequency of left different from minFrequency or
341 * maxFrequency of right respectively, false otherwise
342 */
343bool operator!=(const FrequencyRange& lhs, const FrequencyRange& rhs);
344
345/**
346 * Serialize FrequencyRange values to ostream (human-readable).
347 *
348 * @param os the output stream
349 * @param freqRange the FrequencyRange
350 *
351 * @return std::ostream
352 */
353std::ostream& operator<<(std::ostream& os, const FrequencyRange& freqRange);
354
355/// Identifier for the frequency range covering the whole wifi spectrum
357
358/// Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band
360
361/// Identifier for the frequency range covering the wifi spectrum in the 5 GHz band
363
364/// Identifier for the frequency range covering the wifi spectrum in the 6 GHz band
366
367} // namespace ns3
368
369#endif /* WIFI_SPECTRUM_VALUE_HELPER_H */
Smart pointer class similar to boost::intrusive_ptr.
This class defines all functions to create a spectrum model for Wi-Fi based on a a spectral model ali...
virtual ~WifiSpectrumValueHelper()=default
Destructor.
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, dBr_u minInnerBand=dBr_u{-20}, dBr_u minOuterband=dBr_u{-28}, dBr_u lowestPoint=dBr_u{-40})
Create a transmit power spectral density corresponding to OFDM High Throughput (HT/VHT) (802....
static Ptr< SpectrumValue > CreateDsssTxPowerSpectralDensity(MHz_u centerFrequency, Watt_u txPower, MHz_u guardBandwidth)
Create a transmit power spectral density corresponding to DSSS.
static Ptr< SpectrumValue > CreateDuplicated20MhzTxPowerSpectralDensity(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, dBr_u minInnerBand=dBr_u{-20}, dBr_u minOuterband=dBr_u{-28}, dBr_u lowestPoint=dBr_u{-40}, const std::vector< bool > &puncturedSubchannels={})
Create a transmit power spectral density corresponding to OFDM duplicated over multiple 20 MHz subcha...
static void CreateSpectrumMaskForOfdm(Ptr< SpectrumValue > c, const std::vector< std::vector< WifiSpectrumBandIndices > > &allocatedSubBandsPerSegment, const WifiSpectrumBandIndices &maskBand, Watt_u txPowerPerBand, uint32_t nGuardBands, uint32_t innerSlopeWidth, dBr_u minInnerBand, dBr_u minOuterband, dBr_u lowestPoint, const std::vector< std::vector< WifiSpectrumBandIndices > > &puncturedSubBands={}, uint32_t puncturedSlopeWidth=0)
Create a transmit power spectral density corresponding to OFDM transmit spectrum mask requirements fo...
static Ptr< SpectrumModel > GetSpectrumModel(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Hz_u carrierSpacing, MHz_u guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width.
static Watt_u GetBandPowerW(Ptr< SpectrumValue > psd, const std::vector< WifiSpectrumBandIndices > &segments)
Calculate the power of the specified band composed of uniformly-sized sub-bands.
static Ptr< SpectrumValue > CreateHeMuOfdmTxPowerSpectralDensity(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, const std::vector< WifiSpectrumBandIndices > &ru)
Create a transmit power spectral density corresponding to the OFDMA part of HE TB PPDUs for a given R...
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(MHz_u centerFrequency, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, dBr_u minInnerBand=dBr_u{-20}, dBr_u minOuterband=dBr_u{-28}, dBr_u lowestPoint=dBr_u{-40})
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
static Ptr< SpectrumValue > CreateHeOfdmTxPowerSpectralDensity(MHz_u centerFrequency, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, dBr_u minInnerBand=dBr_u{-20}, dBr_u minOuterband=dBr_u{-28}, dBr_u lowestPoint=dBr_u{-40}, const std::vector< bool > &puncturedSubchannels={})
Create a transmit power spectral density corresponding to OFDM High Efficiency (HE/EHT) (802....
static void NormalizeSpectrumMask(Ptr< SpectrumValue > c, Watt_u txPower)
Normalize the transmit spectrum mask generated by CreateSpectrumMaskForOfdm so that the total transmi...
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:658
bool operator==(const EventId &a, const EventId &b)
Definition event-id.h:155
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:148
double MHz_u
MHz weak type.
Definition wifi-units.h:31
dB_u dBr_u
dBr weak type
Definition wifi-units.h:29
bool operator<(const EventId &a, const EventId &b)
Definition event-id.h:168
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
double Watt_u
Watt weak type.
Definition wifi-units.h:25
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
std::pair< uint32_t, uint32_t > WifiSpectrumBandIndices
typedef for a pair of start and stop sub-band indices
Struct defining a frequency range between minFrequency and maxFrequency.
MHz_u minFrequency
the minimum frequency
MHz_u maxFrequency
the maximum frequency
Declaration of the SI units (as weak types aliases) used across wifi module.