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 */
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,
97 MHz_u guardBandwidth,
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 */
118 const std::vector<MHz_u>& centerFrequencies,
119 MHz_u channelWidth,
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
129 * High Throughput (HT) (802.11n/ac). Channel width may vary between
130 * 20, 40, 80, and 160 MHz.
131 *
132 * @param centerFrequencies center frequency per segment
133 * @param channelWidth total allocated channel width over all segments
134 * @param txPower transmit power to allocate
135 * @param guardBandwidth width of the guard band
136 * @param minInnerBand the minimum relative power in the inner band
137 * @param minOuterband the minimum relative power in the outer band
138 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
139 * @return a pointer to a newly allocated SpectrumValue representing the HT OFDM Transmit Power
140 * Spectral Density in W/Hz for each Band
141 */
143 const std::vector<MHz_u>& centerFrequencies,
144 MHz_u channelWidth,
146 MHz_u guardBandwidth,
147 dBr_u minInnerBand = dBr_u{-20},
148 dBr_u minOuterband = dBr_u{-28},
149 dBr_u lowestPoint = dBr_u{-40});
150
151 /**
152 * Create a transmit power spectral density corresponding to OFDM
153 * High Efficiency (HE) (802.11ax) for contiguous channels.
154 * Channel width may vary between 20, 40, 80, and 160 MHz.
155 *
156 * @param centerFrequency center frequency
157 * @param channelWidth channel width
158 * @param txPower transmit power to allocate
159 * @param guardBandwidth width of the guard band
160 * @param minInnerBand the minimum relative power in the inner band
161 * @param minOuterband the minimum relative power in the outer band
162 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
163 * @param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
164 * @return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
165 * Spectral Density in W/Hz for each Band
166 */
169 MHz_u channelWidth,
171 MHz_u guardBandwidth,
172 dBr_u minInnerBand = dBr_u{-20},
173 dBr_u minOuterband = dBr_u{-28},
174 dBr_u lowestPoint = dBr_u{-40},
175 const std::vector<bool>& puncturedSubchannels = {});
176
177 /**
178 * Create a transmit power spectral density corresponding to OFDM
179 * High Efficiency (HE) (802.11ax) made of one or more frequency segment(s).
180 * Channel width may vary between 20, 40, 80, and 160 MHz.
181 *
182 * @param centerFrequencies center frequency per segment
183 * @param channelWidth total allocated channel width over all segments
184 * @param txPower transmit power to allocate
185 * @param guardBandwidth width of the guard band
186 * @param minInnerBand the minimum relative power in the inner band
187 * @param minOuterband the minimum relative power in the outer band
188 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
189 * @param puncturedSubchannels bitmap indicating whether a 20 MHz subchannel is punctured or not
190 * @return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
191 * Spectral Density in W/Hz for each Band
192 */
194 const std::vector<MHz_u>& centerFrequencies,
195 MHz_u channelWidth,
197 MHz_u guardBandwidth,
198 dBr_u minInnerBand = dBr_u{-20},
199 dBr_u minOuterband = dBr_u{-28},
200 dBr_u lowestPoint = dBr_u{-40},
201 const std::vector<bool>& puncturedSubchannels = {});
202
203 /**
204 * Create a transmit power spectral density corresponding to the OFDMA part
205 * of HE TB PPDUs for a given RU.
206 * An ideal (i.e. rectangular) spectral mask is considered for the time being.
207 *
208 * @param centerFrequencies center frequency per segment
209 * @param channelWidth total allocated channel width over all segments
210 * @param txPower transmit power to allocate
211 * @param guardBandwidth width of the guard band
212 * @param ru the RU band used by the STA
213 * @return a pointer to a newly allocated SpectrumValue representing the HE OFDM Transmit Power
214 * Spectral Density on the RU used by the STA in W/Hz for each Band
215 */
217 const std::vector<MHz_u>& centerFrequencies,
218 MHz_u channelWidth,
220 MHz_u guardBandwidth,
221 const std::vector<WifiSpectrumBandIndices>& ru);
222
223 /**
224 * Create a transmit power spectral density corresponding to OFDM
225 * transmit spectrum mask requirements for 11a/11g/11n/11ac/11ax
226 * Channel width may vary between 5, 10, 20, 40, 80, and 160 MHz.
227 * The default (standard) values are illustrated below.
228 *
229 * [ guard band ][ channel width ][ guard band ]
230 * __________ __________ _ 0 dBr
231 * / | | \
232 * / |_| \ _ -20 dBr
233 * . ' ' .
234 * . ' ' . _ -28 dBr
235 * .' '.
236 * .' '.
237 * .' '. _ lowest point
238 *
239 * |-----| |-----| outerBand left/right
240 * |------| |-- ---| middle band left/right
241 * |-| |-| inner band left/right
242 * |-----------------------| allocated sub-bands
243 * |-----------------------------------------------------| mask band
244 *
245 * Please take note that, since guard tones are within the allocated band
246 * while not being ideally allocated any power, the inner band had to be
247 * shifted inwards and a flat junction band (at -20 dBr) had to be added
248 * between the inner and the middle bands.
249 *
250 * @param c spectrumValue to allocate according to transmit power spectral density mask (in W/Hz
251 * for each band)
252 * @param allocatedSubBandsPerSegment vector of start and stop subcarrier indexes of the
253 * allocated sub bands, for each segment
254 * @param maskBand start and stop subcarrier indexes of transmit mask (in case signal doesn't
255 * cover whole SpectrumModel)
256 * @param txPowerPerBand power allocated to each subcarrier in the allocated sub bands
257 * @param nGuardBands size (in number of subcarriers) of the guard band (left and right)
258 * @param innerSlopeWidth size (in number of subcarriers) of the inner band (i.e. slope going
259 * from 0 dBr to -20 dBr in the figure above)
260 * @param minInnerBand the minimum relative power in the inner band (i.e., -20 dBr in the
261 * figure above)
262 * @param minOuterband the minimum relative power in the outer band (i.e., -28 dBr in the
263 * figure above)
264 * @param lowestPoint maximum relative power of the outermost subcarriers of the guard band
265 * @param puncturedSubBands vector of start and stop subcarrier indexes of the punctured sub
266 * bands, for each segment
267 * @param puncturedSlopeWidth size (in number of subcarriers) of the punctured band slope
268 */
269 static void CreateSpectrumMaskForOfdm(
271 const std::vector<std::vector<WifiSpectrumBandIndices>>& allocatedSubBandsPerSegment,
279 const std::vector<std::vector<WifiSpectrumBandIndices>>& puncturedSubBands = {},
281
282 /**
283 * Normalize the transmit spectrum mask generated by CreateSpectrumMaskForOfdm
284 * so that the total transmitted power corresponds to the input value.
285 *
286 * @param c spectrumValue to normalize (in W/Hz for each band)
287 * @param txPower total transmit power to allocate
288 */
290
291 /**
292 * Calculate the power of the specified band composed of uniformly-sized sub-bands.
293 *
294 * @param psd received Power Spectral Density in W/Hz
295 * @param segments a vector of pair of start and stop indexes that defines each segment of the
296 * band
297 *
298 * @return band power
299 */
301 const std::vector<WifiSpectrumBandIndices>& segments);
302};
303
304/**
305 * @ingroup spectrum
306 * Struct defining a frequency range between minFrequency and maxFrequency.
307 */
309{
310 MHz_u minFrequency{0}; ///< the minimum frequency
311 MHz_u maxFrequency{0}; ///< the maximum frequency
312};
313
314/**
315 * Compare two FrequencyRange values
316 *
317 * @param lhs the FrequencyRange value on the left of operator
318 * @param rhs the FrequencyRange value on the right of operator
319 *
320 * @return true if minFrequency of left is less than minFrequency of right, false otherwise
321 */
322bool operator<(const FrequencyRange& lhs, const FrequencyRange& rhs);
323
324/**
325 * Compare two FrequencyRange values
326 *
327 * @param lhs the FrequencyRange value on the left of operator
328 * @param rhs the FrequencyRange value on the right of operator
329 *
330 * @return true if both minFrequency and maxFrequency of left are equal to minFrequency and
331 * maxFrequency of right respectively, false otherwise
332 */
333bool operator==(const FrequencyRange& lhs, const FrequencyRange& rhs);
334
335/**
336 * Compare two FrequencyRange values
337 *
338 * @param lhs the FrequencyRange value on the left of operator
339 * @param rhs the FrequencyRange value on the right of operator
340 *
341 * @return true if either minFrequency or maxFrequency of left different from minFrequency or
342 * maxFrequency of right respectively, false otherwise
343 */
344bool operator!=(const FrequencyRange& lhs, const FrequencyRange& rhs);
345
346/**
347 * Serialize FrequencyRange values to ostream (human-readable).
348 *
349 * @param os the output stream
350 * @param freqRange the FrequencyRange
351 *
352 * @return std::ostream
353 */
354std::ostream& operator<<(std::ostream& os, const FrequencyRange& freqRange);
355
356/// Identifier for the frequency range covering the whole wifi spectrum
358
359/// Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band
361
362/// Identifier for the frequency range covering the wifi spectrum in the 5 GHz band
364
365/// Identifier for the frequency range covering the wifi spectrum in the 6 GHz band
367
368} // namespace ns3
369
370#endif /* WIFI_SPECTRUM_VALUE_HELPER_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
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) (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) (802....
static void NormalizeSpectrumMask(Ptr< SpectrumValue > c, Watt_u txPower)
Normalize the transmit spectrum mask generated by CreateSpectrumMaskForOfdm so that the total transmi...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
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
double MHz_u
MHz weak type.
Definition wifi-units.h:31
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
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: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
dB_u dBr_u
dBr weak type
Definition wifi-units.h:29
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 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.