A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ofdm-phy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Orange Labs
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Rediet <getachew.redieteab@orange.com>
7 * Sébastien Deronne <sebastien.deronne@gmail.com> (for logic ported from wifi-phy)
8 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (for logic ported from wifi-phy)
9 */
10
11#ifndef OFDM_PHY_H
12#define OFDM_PHY_H
13
14#include "ns3/phy-entity.h"
15#include "ns3/wifi-export.h"
16
17/**
18 * @file
19 * @ingroup wifi
20 * Declaration of ns3::OfdmPhy class
21 * and ns3::OfdmPhyVariant enum.
22 */
23
24namespace ns3
25{
26
27/**
28 * @ingroup wifi
29 * The OFDM (11a) PHY variants.
30 *
31 * @see OfdmPhy
32 */
39
40/**
41 * @brief PHY entity for OFDM (11a)
42 * @ingroup wifi
43 *
44 * This class is also used for the 10 MHz and 5 MHz bandwidth
45 * variants addressing vehicular communications (default is 20 MHz
46 * bandwidth).
47 *
48 * Refer to IEEE 802.11-2016, clause 17.
49 */
50class WIFI_EXPORT OfdmPhy : public PhyEntity
51{
52 public:
53 /**
54 * Constructor for OFDM PHY
55 *
56 * @param variant the OFDM PHY variant
57 * @param buildModeList flag used to add OFDM modes to list (disabled
58 * by child classes to only add child classes' modes)
59 */
60 OfdmPhy(OfdmPhyVariant variant = OFDM_PHY_DEFAULT, bool buildModeList = true);
61 /**
62 * Destructor for OFDM PHY
63 */
64 ~OfdmPhy() override;
65
66 WifiMode GetSigMode(WifiPpduField field, const WifiTxVector& txVector) const override;
67 const PpduFormats& GetPpduFormats() const override;
68 Time GetDuration(WifiPpduField field, const WifiTxVector& txVector) const override;
70 const WifiTxVector& txVector,
71 WifiPhyBand band,
72 MpduType mpdutype,
73 bool incFlag,
74 uint32_t& totalAmpduSize,
75 double& totalAmpduNumSymbols,
76 uint16_t staId) const override;
78 const WifiTxVector& txVector,
79 Time ppduDuration) override;
81 WifiChannelListType channelType) const override;
83
84 /**
85 * Initialize all OFDM modes (for all variants).
86 */
87 static void InitializeModes();
88 /**
89 * Return a WifiMode for OFDM
90 * corresponding to the provided rate and
91 * the channel bandwidth (20, 10, or 5 MHz).
92 *
93 * @param rate the rate in bps
94 * @param bw the bandwidth
95 * @return a WifiMode for OFDM
96 */
97 static WifiMode GetOfdmRate(uint64_t rate, MHz_u bw = MHz_u{20});
98 /**
99 * @return a WifiMode for OFDM at 6 Mbps
100 */
102 /**
103 * @return a WifiMode for OFDM at 9 Mbps
104 */
106 /**
107 * @return a WifiMode for OFDM at 12 Mbps
108 */
110 /**
111 * @return a WifiMode for OFDM at 18 Mbps
112 */
114 /**
115 * @return a WifiMode for OFDM at 24 Mbps
116 */
118 /**
119 * @return a WifiMode for OFDM at 36 Mbps
120 */
122 /**
123 * @return a WifiMode for OFDM at 48 Mbps
124 */
126 /**
127 * @return a WifiMode for OFDM at 54 Mbps
128 */
130 /**
131 * @return a WifiMode for OFDM at 3 Mbps with 10 MHz channel spacing
132 */
134 /**
135 * @return a WifiMode for OFDM at 4.5 Mbps with 10 MHz channel spacing
136 */
138 /**
139 * @return a WifiMode for OFDM at 6 Mbps with 10 MHz channel spacing
140 */
142 /**
143 * @return a WifiMode for OFDM at 9 Mbps with 10 MHz channel spacing
144 */
146 /**
147 * @return a WifiMode for OFDM at 12 Mbps with 10 MHz channel spacing
148 */
150 /**
151 * @return a WifiMode for OFDM at 18 Mbps with 10 MHz channel spacing
152 */
154 /**
155 * @return a WifiMode for OFDM at 24 Mbps with 10 MHz channel spacing
156 */
158 /**
159 * @return a WifiMode for OFDM at 27 Mbps with 10 MHz channel spacing
160 */
162 /**
163 * @return a WifiMode for OFDM at 1.5 Mbps with 5 MHz channel spacing
164 */
166 /**
167 * @return a WifiMode for OFDM at 2.25 Mbps with 5 MHz channel spacing
168 */
170 /**
171 * @return a WifiMode for OFDM at 3 Mbps with 5 MHz channel spacing
172 */
174 /**
175 * @return a WifiMode for OFDM at 4.5 Mbps with 5 MHz channel spacing
176 */
178 /**
179 * @return a WifiMode for OFDM at 6 Mbps with 5 MHz channel spacing
180 */
182 /**
183 * @return a WifiMode for OFDM at 9 Mbps with 5 MHz channel spacing
184 */
186 /**
187 * @return a WifiMode for OFDM at 12 Mbps with 5 MHz channel spacing
188 */
190 /**
191 * @return a WifiMode for OFDM at 13.5 Mbps with 5 MHz channel spacing
192 */
194
195 /**
196 * Return the WifiCodeRate from the OFDM mode's unique name using
197 * ModulationLookupTable. This is mainly used as a callback for
198 * WifiMode operation.
199 *
200 * @param name the unique name of the OFDM mode
201 * @return WifiCodeRate corresponding to the unique name
202 */
203 static WifiCodeRate GetCodeRate(const std::string& name);
204 /**
205 * Return the constellation size from the OFDM mode's unique name using
206 * ModulationLookupTable. This is mainly used as a callback for
207 * WifiMode operation.
208 *
209 * @param name the unique name of the OFDM mode
210 * @return constellation size corresponding to the unique name
211 */
212 static uint16_t GetConstellationSize(const std::string& name);
213 /**
214 * Return the PHY rate from the OFDM mode's unique name and
215 * the supplied parameters. This function calls CalculatePhyRate
216 * and is mainly used as a callback for WifiMode operation.
217 *
218 * @param name the unique name of the OFDM mode
219 * @param channelWidth the considered channel width
220 *
221 * @return the physical bit rate of this signal in bps.
222 */
223 static uint64_t GetPhyRate(const std::string& name, MHz_u channelWidth);
224
225 /**
226 * Return the PHY rate corresponding to
227 * the supplied TXVECTOR.
228 * This function is mainly used as a callback
229 * for WifiMode operation.
230 *
231 * @param txVector the TXVECTOR used for the transmission
232 * @param staId the station ID (only here to have a common signature for all callbacks)
233 * @return the physical bit rate of this signal in bps.
234 */
235 static uint64_t GetPhyRateFromTxVector(const WifiTxVector& txVector, uint16_t staId);
236 /**
237 * Return the data rate corresponding to
238 * the supplied TXVECTOR.
239 * This function is mainly used as a callback
240 * for WifiMode operation.
241 *
242 * @param txVector the TXVECTOR used for the transmission
243 * @param staId the station ID (only here to have a common signature for all callbacks)
244 * @return the data bit rate in bps.
245 */
246 static uint64_t GetDataRateFromTxVector(const WifiTxVector& txVector, uint16_t staId);
247 /**
248 * Return the data rate from the OFDM mode's unique name and
249 * the supplied parameters. This function calls CalculateDataRate and
250 * is mainly used as a callback for WifiMode operation.
251 *
252 * @param name the unique name of the OFDM mode
253 * @param channelWidth the considered channel width
254 *
255 * @return the data bit rate of this signal in bps.
256 */
257 static uint64_t GetDataRate(const std::string& name, MHz_u channelWidth);
258 /**
259 * Check whether the combination in TXVECTOR is allowed.
260 * This function is used as a callback for WifiMode operation.
261 *
262 * @param txVector the TXVECTOR
263 * @returns true if this combination is allowed, false otherwise.
264 */
265 static bool IsAllowed(const WifiTxVector& txVector);
266
267 protected:
270 Ptr<const WifiPpdu> ppdu) const override;
271 uint32_t GetMaxPsduSize() const override;
272 MHz_u GetMeasurementChannelWidth(const Ptr<const WifiPpdu> ppdu) const override;
273
274 /**
275 * @param txVector the transmission parameters
276 * @return the WifiMode used for the SIGNAL field
277 */
278 virtual WifiMode GetHeaderMode(const WifiTxVector& txVector) const;
279
280 /**
281 * @param txVector the transmission parameters
282 * @return the duration of the preamble field
283 *
284 * @see WIFI_PPDU_FIELD_PREAMBLE
285 */
286 virtual Time GetPreambleDuration(const WifiTxVector& txVector) const;
287 /**
288 * @param txVector the transmission parameters
289 * @return the duration of the SIGNAL field
290 */
291 virtual Time GetHeaderDuration(const WifiTxVector& txVector) const;
292
293 /**
294 * @return the number of service bits
295 */
296 uint8_t GetNumberServiceBits() const;
297 /**
298 * @param band the frequency band being used
299 * @return the signal extension duration
300 */
302
303 /**
304 * End receiving the header, perform OFDM-specific actions, and
305 * provide the status of the reception.
306 *
307 * @param event the event holding incoming PPDU's information
308 * @return status of the reception of the header
309 */
311
312 /**
313 * Checks if the PPDU's bandwidth is supported by the PHY.
314 *
315 * @param ppdu the received PPDU
316 * @return \c true if supported, \c false otherwise
317 */
318 virtual bool IsChannelWidthSupported(Ptr<const WifiPpdu> ppdu) const;
319 /**
320 * Checks if the signaled configuration (including bandwidth)
321 * is supported by the PHY.
322 *
323 * @param field the current PPDU field (SIG used for checking config)
324 * @param ppdu the received PPDU
325 * @return \c true if supported, \c false otherwise
326 */
327 virtual bool IsAllConfigSupported(WifiPpduField field, Ptr<const WifiPpdu> ppdu) const;
328
329 /**
330 * Calculate the PHY rate in bps from code rate and data rate.
331 *
332 * @param codeRate the WifiCodeRate
333 * @param dataRate the data rate in bps
334 * @return the physical rate in bps from WifiCodeRate and data rate.
335 */
336 static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate);
337 /**
338 * Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
339 *
340 * @param codeRate the WifiCodeRate
341 * @return the ratio form of WifiCodeRate.
342 */
343 static double GetCodeRatio(WifiCodeRate codeRate);
344 /**
345 * Calculates data rate from the supplied parameters.
346 *
347 * @param codeRate the code rate of the mode
348 * @param constellationSize the size of modulation constellation
349 * @param channelWidth the considered channel width
350 *
351 * @return the data bit rate of this signal in bps.
352 */
353 static uint64_t CalculateDataRate(WifiCodeRate codeRate,
354 uint16_t constellationSize,
355 MHz_u channelWidth);
356 /**
357 * Calculates data rate from the supplied parameters.
358 *
359 * @param symbolDuration the symbol duration
360 * @param usableSubCarriers the number of usable subcarriers for data
361 * @param numberOfBitsPerSubcarrier the number of data bits per subcarrier
362 * @param codingRate the coding rate
363 *
364 * @return the data bit rate of this signal in bps.
365 */
366 static uint64_t CalculateDataRate(Time symbolDuration,
367 uint16_t usableSubCarriers,
368 uint16_t numberOfBitsPerSubcarrier,
369 double codingRate);
370
371 /**
372 * @return the number of usable subcarriers for data
373 */
374 static uint16_t GetUsableSubcarriers();
375
376 /**
377 * @param channelWidth the channel width
378 * @return the symbol duration
379 */
380 static Time GetSymbolDuration(MHz_u channelWidth);
381
382 private:
383 /**
384 * Create an OFDM mode from a unique name, the unique name
385 * must already be contained inside ModulationLookupTable.
386 * This method binds all the callbacks used by WifiMode.
387 *
388 * @param uniqueName the unique name of the WifiMode
389 * @param isMandatory whether the WifiMode is mandatory
390 * @return the OFDM WifiMode
391 */
392 static WifiMode CreateOfdmMode(std::string uniqueName, bool isMandatory);
393
394 static const PpduFormats m_ofdmPpduFormats; //!< OFDM PPDU formats
395
396 static const ModulationLookupTable
397 m_ofdmModulationLookupTable; //!< lookup table to retrieve code rate and constellation size
398 //!< corresponding to a unique name of modulation
399};
400
401} // namespace ns3
402
403#endif /* OFDM_PHY_H */
static WifiMode GetOfdmRate6Mbps()
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
Definition ofdm-phy.cc:651
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
static WifiMode GetOfdmRate48Mbps()
dBm_u GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold for a given channel type.
Definition ofdm-phy.cc:667
static const PpduFormats m_ofdmPpduFormats
OFDM PPDU formats.
Definition ofdm-phy.h:394
static uint16_t GetConstellationSize(const std::string &name)
Return the constellation size from the OFDM mode's unique name using ModulationLookupTable.
Definition ofdm-phy.cc:546
static WifiMode GetOfdmRate54Mbps()
uint8_t GetNumberServiceBits() const
Definition ofdm-phy.cc:272
static WifiCodeRate GetCodeRate(const std::string &name)
Return the WifiCodeRate from the OFDM mode's unique name using ModulationLookupTable.
Definition ofdm-phy.cc:540
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition ofdm-phy.cc:566
static WifiMode GetOfdmRate36Mbps()
static WifiMode GetOfdmRate3MbpsBW10MHz()
static void InitializeModes()
Initialize all OFDM modes (for all variants).
Definition ofdm-phy.cc:391
virtual bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
Definition ofdm-phy.cc:346
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform OFDM-specific actions, and provide the status of the reception.
Definition ofdm-phy.cc:309
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
Definition ofdm-phy.cc:177
static uint64_t GetDataRate(const std::string &name, MHz_u channelWidth)
Return the data rate from the OFDM mode's unique name and the supplied parameters.
Definition ofdm-phy.cc:596
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition ofdm-phy.cc:645
static WifiMode GetOfdmRate6MbpsBW5MHz()
OfdmPhy(OfdmPhyVariant variant=OFDM_PHY_DEFAULT, bool buildModeList=true)
Constructor for OFDM PHY.
Definition ofdm-phy.cc:98
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition ofdm-phy.cc:590
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
static WifiMode GetOfdmRate18MbpsBW10MHz()
static Time GetSymbolDuration(MHz_u channelWidth)
Definition ofdm-phy.cc:629
static WifiMode GetOfdmRate12MbpsBW10MHz()
static uint16_t GetUsableSubcarriers()
Definition ofdm-phy.cc:623
static WifiMode GetOfdmRate9MbpsBW10MHz()
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
static WifiMode GetOfdmRate3MbpsBW5MHz()
virtual Time GetPreambleDuration(const WifiTxVector &txVector) const
Definition ofdm-phy.cc:197
Ptr< const WifiPpdu > GetRxPpduFromTxPpdu(Ptr< const WifiPpdu > ppdu) override
The WifiPpdu from the TX PHY is received by each RX PHY attached to the same channel.
Definition ofdm-phy.cc:680
static WifiMode GetOfdmRate27MbpsBW10MHz()
Ptr< SpectrumValue > GetTxPowerSpectralDensity(Watt_u txPower, Ptr< const WifiPpdu > ppdu) const override
Definition ofdm-phy.cc:356
static WifiMode GetOfdmRate9MbpsBW5MHz()
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition ofdm-phy.cc:284
static WifiMode GetOfdmRate12Mbps()
static WifiMode CreateOfdmMode(std::string uniqueName, bool isMandatory)
Create an OFDM mode from a unique name, the unique name must already be contained inside ModulationLo...
Definition ofdm-phy.cc:522
static WifiMode GetOfdmRate24MbpsBW10MHz()
static WifiMode GetOfdmRate18Mbps()
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Calculate the PHY rate in bps from code rate and data rate.
Definition ofdm-phy.cc:560
static WifiMode GetOfdmRate6MbpsBW10MHz()
MHz_u GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const override
Return the channel width used to measure the RSSI.
Definition ofdm-phy.cc:657
static WifiMode GetOfdmRate24Mbps()
Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const override
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
Definition ofdm-phy.cc:183
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Definition ofdm-phy.cc:298
static WifiMode GetOfdmRate(uint64_t rate, MHz_u bw=MHz_u{20})
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
Definition ofdm-phy.cc:403
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, MHz_u channelWidth)
Calculates data rate from the supplied parameters.
Definition ofdm-phy.cc:604
virtual Time GetHeaderDuration(const WifiTxVector &txVector) const
Definition ofdm-phy.cc:221
virtual WifiMode GetHeaderMode(const WifiTxVector &txVector) const
Definition ofdm-phy.cc:158
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
Definition ofdm-phy.cc:144
static WifiMode GetOfdmRate12MbpsBW5MHz()
static uint64_t GetPhyRate(const std::string &name, MHz_u channelWidth)
Return the PHY rate from the OFDM mode's unique name and the supplied parameters.
Definition ofdm-phy.cc:552
static const ModulationLookupTable m_ofdmModulationLookupTable
lookup table to retrieve code rate and constellation size corresponding to a unique name of modulatio...
Definition ofdm-phy.h:397
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
static WifiMode GetOfdmRate9Mbps()
virtual bool IsChannelWidthSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the PPDU's bandwidth is supported by the PHY.
Definition ofdm-phy.cc:333
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
Definition ofdm-phy.cc:572
Time GetSignalExtension(WifiPhyBand band) const
Definition ofdm-phy.cc:278
Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const override
Definition ofdm-phy.cc:245
Abstract class for PHY entities.
Definition phy-entity.h:62
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition phy-entity.h:502
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition phy-entity.h:492
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
represent a single transmission mode
Definition wifi-mode.h:39
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPhyBand
Identifies the PHY band.
OfdmPhyVariant
The OFDM (11a) PHY variants.
Definition ofdm-phy.h:34
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
WifiPpduField
The type of PPDU field (grouped for convenience).
MpduType
The type of an MPDU.
Definition wifi-types.h:54
@ OFDM_PHY_10_MHZ
Definition ofdm-phy.h:36
@ OFDM_PHY_DEFAULT
Definition ofdm-phy.h:35
@ OFDM_PHY_5_MHZ
Definition ofdm-phy.h:37
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
double dBm_u
dBm weak type
Definition wifi-units.h:27
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:39
double Watt_u
Watt weak type.
Definition wifi-units.h:25
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
Status of the reception of the PPDU field.
Definition phy-entity.h:78