A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ofdm-phy.cc
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#include "ofdm-phy.h"
12
13#include "ofdm-ppdu.h"
14
15#include "ns3/interference-helper.h"
16#include "ns3/log.h"
17#include "ns3/simulator.h"
18#include "ns3/wifi-phy.h"
19#include "ns3/wifi-psdu.h"
20#include "ns3/wifi-utils.h"
21
22#include <array>
23
24#undef NS_LOG_APPEND_CONTEXT
25#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
26
27namespace ns3
28{
29
31
32/*******************************************************
33 * OFDM PHY (IEEE 802.11-2016, clause 17)
34 *******************************************************/
35
36// clang-format off
37
42};
43
45 // Unique name Code rate Constellation size
46 { "OfdmRate6Mbps", { WIFI_CODE_RATE_1_2, 2 } }, // 20 MHz
47 { "OfdmRate9Mbps", { WIFI_CODE_RATE_3_4, 2 } }, // |
48 { "OfdmRate12Mbps", { WIFI_CODE_RATE_1_2, 4 } }, // V
49 { "OfdmRate18Mbps", { WIFI_CODE_RATE_3_4, 4 } },
50 { "OfdmRate24Mbps", { WIFI_CODE_RATE_1_2, 16 } },
51 { "OfdmRate36Mbps", { WIFI_CODE_RATE_3_4, 16 } },
52 { "OfdmRate48Mbps", { WIFI_CODE_RATE_2_3, 64 } },
53 { "OfdmRate54Mbps", { WIFI_CODE_RATE_3_4, 64 } },
54 { "OfdmRate3MbpsBW10MHz", { WIFI_CODE_RATE_1_2, 2 } }, // 10 MHz
55 { "OfdmRate4_5MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 2 } }, // |
56 { "OfdmRate6MbpsBW10MHz", { WIFI_CODE_RATE_1_2, 4 } }, // V
57 { "OfdmRate9MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 4 } },
58 { "OfdmRate12MbpsBW10MHz", { WIFI_CODE_RATE_1_2, 16 } },
59 { "OfdmRate18MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 16 } },
60 { "OfdmRate24MbpsBW10MHz", { WIFI_CODE_RATE_2_3, 64 } },
61 { "OfdmRate27MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 64 } },
62 { "OfdmRate1_5MbpsBW5MHz", { WIFI_CODE_RATE_1_2, 2 } }, // 5 MHz
63 { "OfdmRate2_25MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 2 } }, // |
64 { "OfdmRate3MbpsBW5MHz", { WIFI_CODE_RATE_1_2, 4 } }, // V
65 { "OfdmRate4_5MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 4 } },
66 { "OfdmRate6MbpsBW5MHz", { WIFI_CODE_RATE_1_2, 16 } },
67 { "OfdmRate9MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 16 } },
68 { "OfdmRate12MbpsBW5MHz", { WIFI_CODE_RATE_2_3, 64 } },
69 { "OfdmRate13_5MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 64 } }
70};
71
72/// OFDM rates in bits per second for each bandwidth
73const std::map<MHz_u, std::array<uint64_t, 8> > s_ofdmRatesBpsList =
74 {{ MHz_u{20},
75 { 6000000, 9000000, 12000000, 18000000,
76 24000000, 36000000, 48000000, 54000000 }},
77 { MHz_u{10},
78 { 3000000, 4500000, 6000000, 9000000,
79 12000000, 18000000, 24000000, 27000000 }},
80 { MHz_u{5},
81 { 1500000, 2250000, 3000000, 4500000,
82 6000000, 9000000, 12000000, 13500000 }},
83};
84
85// clang-format on
86
87/**
88 * Get the array of possible OFDM rates for each bandwidth.
89 *
90 * @return the OFDM rates in bits per second
91 */
92const std::map<MHz_u, std::array<uint64_t, 8>>&
97
98OfdmPhy::OfdmPhy(OfdmPhyVariant variant /* = OFDM_PHY_DEFAULT */, bool buildModeList /* = true */)
99{
100 NS_LOG_FUNCTION(this << variant << buildModeList);
101
102 if (buildModeList)
103 {
104 auto bwRatesMap = GetOfdmRatesBpsList();
105
106 switch (variant)
107 {
108 case OFDM_PHY_DEFAULT:
109 for (const auto& rate : bwRatesMap.at(MHz_u{20}))
110 {
111 WifiMode mode = GetOfdmRate(rate, MHz_u{20});
112 NS_LOG_LOGIC("Add " << mode << " to list");
113 m_modeList.emplace_back(mode);
114 }
115 break;
116 case OFDM_PHY_10_MHZ:
117 for (const auto& rate : bwRatesMap.at(MHz_u{10}))
118 {
119 WifiMode mode = GetOfdmRate(rate, MHz_u{10});
120 NS_LOG_LOGIC("Add " << mode << " to list");
121 m_modeList.emplace_back(mode);
122 }
123 break;
124 case OFDM_PHY_5_MHZ:
125 for (const auto& rate : bwRatesMap.at(MHz_u{5}))
126 {
127 WifiMode mode = GetOfdmRate(rate, MHz_u{5});
128 NS_LOG_LOGIC("Add " << mode << " to list");
129 m_modeList.emplace_back(mode);
130 }
131 break;
132 default:
133 NS_ABORT_MSG("Unsupported 11a OFDM variant");
134 }
135 }
136}
137
139{
140 NS_LOG_FUNCTION(this);
141}
142
144OfdmPhy::GetSigMode(WifiPpduField field, const WifiTxVector& txVector) const
145{
146 switch (field)
147 {
148 case WIFI_PPDU_FIELD_PREAMBLE: // consider header mode for preamble (useful for
149 // InterferenceHelper)
151 return GetHeaderMode(txVector);
152 default:
153 return PhyEntity::GetSigMode(field, txVector);
154 }
155}
156
159{
160 switch (static_cast<uint16_t>(txVector.GetChannelWidth()))
161 {
162 case 5:
164 case 10:
166 case 20:
167 default:
168 // Section 17.3.2 "PPDU frame format"; IEEE Std 802.11-2016.
169 // Actually this is only the first part of the PhyHeader,
170 // because the last 16 bits of the PhyHeader are using the
171 // same mode of the payload
172 return GetOfdmRate6Mbps();
173 }
174}
175
178{
179 return m_ofdmPpduFormats;
180}
181
182Time
184{
185 switch (field)
186 {
188 return GetPreambleDuration(txVector); // L-STF + L-LTF
190 return GetHeaderDuration(txVector); // L-SIG
191 default:
192 return PhyEntity::GetDuration(field, txVector);
193 }
194}
195
196Time
198{
199 switch (static_cast<uint16_t>(txVector.GetChannelWidth()))
200 {
201 case 20:
202 default:
203 // Section 17.3.3 "PHY preamble (SYNC)" Figure 17-4 "OFDM training structure"
204 // also Section 17.3.2.3 "Modulation-dependent parameters" Table 17-4 "Modulation-dependent
205 // parameters"; IEEE Std 802.11-2016
206 return MicroSeconds(16);
207 case 10:
208 // Section 17.3.3 "PHY preamble (SYNC)" Figure 17-4 "OFDM training structure"
209 // also Section 17.3.2.3 "Modulation-dependent parameters" Table 17-4 "Modulation-dependent
210 // parameters"; IEEE Std 802.11-2016
211 return MicroSeconds(32);
212 case 5:
213 // Section 17.3.3 "PHY preamble (SYNC)" Figure 17-4 "OFDM training structure"
214 // also Section 17.3.2.3 "Modulation-dependent parameters" Table 17-4 "Modulation-dependent
215 // parameters"; IEEE Std 802.11-2016
216 return MicroSeconds(64);
217 }
218}
219
220Time
222{
223 switch (static_cast<uint16_t>(txVector.GetChannelWidth()))
224 {
225 case 20:
226 default:
227 // Section 17.3.3 "PHY preamble (SYNC)" and Figure 17-4 "OFDM training structure"; IEEE Std
228 // 802.11-2016 also Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related
229 // parameters"; IEEE Std 802.11-2016 We return the duration of the SIGNAL field only, since
230 // the SERVICE field (which strictly speaking belongs to the PHY header, see Section 17.3.2
231 // and Figure 17-1) is sent using the payload mode.
232 return MicroSeconds(4);
233 case 10:
234 // Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related parameters"; IEEE
235 // Std 802.11-2016
236 return MicroSeconds(8);
237 case 5:
238 // Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related parameters"; IEEE
239 // Std 802.11-2016
240 return MicroSeconds(16);
241 }
242}
243
244Time
246 const WifiTxVector& txVector,
247 WifiPhyBand band,
248 MpduType /* mpdutype */,
249 bool /* incFlag */,
250 uint32_t& /* totalAmpduSize */,
251 double& /* totalAmpduNumSymbols */,
252 uint16_t /* staId */) const
253{
254 //(Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related parameters"; IEEE Std
255 // 802.11-2016 corresponds to T_{SYM} in the table)
256 Time symbolDuration = MicroSeconds(4);
257
258 double numDataBitsPerSymbol =
259 txVector.GetMode().GetDataRate(txVector) * symbolDuration.GetNanoSeconds() / 1e9;
260
261 // The number of OFDM symbols in the data field when BCC encoding
262 // is used is given in equation 19-32 of the IEEE 802.11-2016 standard.
263 double numSymbols = ceil((GetNumberServiceBits() + size * 8.0 + 6.0) / (numDataBitsPerSymbol));
264
265 Time payloadDuration =
266 FemtoSeconds(static_cast<uint64_t>(numSymbols * symbolDuration.GetFemtoSeconds()));
267 payloadDuration += GetSignalExtension(band);
268 return payloadDuration;
269}
270
271uint8_t
273{
274 return 16;
275}
276
277Time
279{
280 return (band == WIFI_PHY_BAND_2_4GHZ) ? MicroSeconds(6) : MicroSeconds(0);
281}
282
285 const WifiTxVector& txVector,
286 Time /* ppduDuration */)
287{
288 NS_LOG_FUNCTION(this << psdus << txVector);
289 return Create<OfdmPpdu>(
290 psdus.begin()->second,
291 txVector,
293 m_wifiPhy->GetLatestPhyEntity()->ObtainNextUid(
294 txVector)); // use latest PHY entity to handle MU-RTS sent with non-HT rate
295}
296
299{
300 NS_LOG_FUNCTION(this << field << *event);
302 {
303 return EndReceiveHeader(event); // L-SIG
304 }
305 return PhyEntity::DoEndReceiveField(field, event);
306}
307
310{
311 NS_LOG_FUNCTION(this << *event);
313 NS_LOG_DEBUG("L-SIG: SNR(dB)=" << RatioToDb(snrPer.snr) << ", PER=" << snrPer.per);
314 PhyFieldRxStatus status(GetRandomValue() > snrPer.per);
315 if (status.isSuccess)
316 {
317 NS_LOG_DEBUG("Received non-HT PHY header");
319 {
321 }
322 }
323 else
324 {
325 NS_LOG_DEBUG("Abort reception because non-HT PHY header reception failed");
326 status.reason = L_SIG_FAILURE;
327 status.actionIfFailure = ABORT;
328 }
329 return status;
330}
331
332bool
334{
335 const auto channelWidth = ppdu->GetTxVector().GetChannelWidth();
336 if ((channelWidth >= MHz_u{40}) && (channelWidth > m_wifiPhy->GetChannelWidth()))
337 {
338 NS_LOG_DEBUG("Packet reception could not be started because not enough channel width ("
339 << channelWidth << " vs " << m_wifiPhy->GetChannelWidth() << ")");
340 return false;
341 }
342 return true;
343}
344
345bool
347{
348 if (!IsChannelWidthSupported(ppdu))
349 {
350 return false;
351 }
352 return IsConfigSupported(ppdu);
353}
354
357{
358 const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
359 const auto& txVector = ppdu->GetTxVector();
360 const auto channelWidth = txVector.GetChannelWidth();
361 NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPower);
362 const auto& txMaskRejectionParams = GetTxMaskRejectionParams();
364 if (txVector.IsNonHtDuplicate())
365 {
367 centerFrequencies,
368 channelWidth,
369 txPower,
370 GetGuardBandwidth(channelWidth),
371 std::get<0>(txMaskRejectionParams),
372 std::get<1>(txMaskRejectionParams),
373 std::get<2>(txMaskRejectionParams));
374 }
375 else
376 {
377 NS_ASSERT(centerFrequencies.size() == 1);
379 centerFrequencies.front(),
380 channelWidth,
381 txPower,
382 GetGuardBandwidth(channelWidth),
383 std::get<0>(txMaskRejectionParams),
384 std::get<1>(txMaskRejectionParams),
385 std::get<2>(txMaskRejectionParams));
386 }
387 return v;
388}
389
390void
392{
393 for (const auto& ratesPerBw : GetOfdmRatesBpsList())
394 {
395 for (const auto& rate : ratesPerBw.second)
396 {
397 GetOfdmRate(rate, ratesPerBw.first);
398 }
399 }
400}
401
403OfdmPhy::GetOfdmRate(uint64_t rate, MHz_u bw)
404{
405 switch (static_cast<uint16_t>(bw))
406 {
407 case 20:
408 switch (rate)
409 {
410 case 6000000:
411 return GetOfdmRate6Mbps();
412 case 9000000:
413 return GetOfdmRate9Mbps();
414 case 12000000:
415 return GetOfdmRate12Mbps();
416 case 18000000:
417 return GetOfdmRate18Mbps();
418 case 24000000:
419 return GetOfdmRate24Mbps();
420 case 36000000:
421 return GetOfdmRate36Mbps();
422 case 48000000:
423 return GetOfdmRate48Mbps();
424 case 54000000:
425 return GetOfdmRate54Mbps();
426 default:
427 NS_ABORT_MSG("Inexistent rate (" << rate << " bps) requested for 11a OFDM (default)");
428 return WifiMode();
429 }
430 break;
431 case 10:
432 switch (rate)
433 {
434 case 3000000:
436 case 4500000:
438 case 6000000:
440 case 9000000:
442 case 12000000:
444 case 18000000:
446 case 24000000:
448 case 27000000:
450 default:
451 NS_ABORT_MSG("Inexistent rate (" << rate << " bps) requested for 11a OFDM (10 MHz)");
452 return WifiMode();
453 }
454 break;
455 case 5:
456 switch (rate)
457 {
458 case 1500000:
460 case 2250000:
462 case 3000000:
463 return GetOfdmRate3MbpsBW5MHz();
464 case 4500000:
466 case 6000000:
467 return GetOfdmRate6MbpsBW5MHz();
468 case 9000000:
469 return GetOfdmRate9MbpsBW5MHz();
470 case 12000000:
472 case 13500000:
474 default:
475 NS_ABORT_MSG("Inexistent rate (" << rate << " bps) requested for 11a OFDM (5 MHz)");
476 return WifiMode();
477 }
478 break;
479 default:
480 NS_ABORT_MSG("Inexistent bandwidth (" << +bw << " MHz) requested for 11a OFDM");
481 return WifiMode();
482 }
483}
484
485#define GET_OFDM_MODE(x, f) \
486 WifiMode OfdmPhy::Get##x() \
487 { \
488 static WifiMode mode = CreateOfdmMode(#x, f); \
489 return mode; \
490 }
491
492// 20 MHz channel rates (default)
493GET_OFDM_MODE(OfdmRate6Mbps, true)
494GET_OFDM_MODE(OfdmRate9Mbps, false)
495GET_OFDM_MODE(OfdmRate12Mbps, true)
496GET_OFDM_MODE(OfdmRate18Mbps, false)
497GET_OFDM_MODE(OfdmRate24Mbps, true)
498GET_OFDM_MODE(OfdmRate36Mbps, false)
499GET_OFDM_MODE(OfdmRate48Mbps, false)
500GET_OFDM_MODE(OfdmRate54Mbps, false)
501// 10 MHz channel rates
502GET_OFDM_MODE(OfdmRate3MbpsBW10MHz, true)
503GET_OFDM_MODE(OfdmRate4_5MbpsBW10MHz, false)
504GET_OFDM_MODE(OfdmRate6MbpsBW10MHz, true)
505GET_OFDM_MODE(OfdmRate9MbpsBW10MHz, false)
506GET_OFDM_MODE(OfdmRate12MbpsBW10MHz, true)
507GET_OFDM_MODE(OfdmRate18MbpsBW10MHz, false)
508GET_OFDM_MODE(OfdmRate24MbpsBW10MHz, false)
509GET_OFDM_MODE(OfdmRate27MbpsBW10MHz, false)
510// 5 MHz channel rates
511GET_OFDM_MODE(OfdmRate1_5MbpsBW5MHz, true)
512GET_OFDM_MODE(OfdmRate2_25MbpsBW5MHz, false)
513GET_OFDM_MODE(OfdmRate3MbpsBW5MHz, true)
514GET_OFDM_MODE(OfdmRate4_5MbpsBW5MHz, false)
515GET_OFDM_MODE(OfdmRate6MbpsBW5MHz, true)
516GET_OFDM_MODE(OfdmRate9MbpsBW5MHz, false)
517GET_OFDM_MODE(OfdmRate12MbpsBW5MHz, false)
518GET_OFDM_MODE(OfdmRate13_5MbpsBW5MHz, false)
519#undef GET_OFDM_MODE
520
521WifiMode
522OfdmPhy::CreateOfdmMode(std::string uniqueName, bool isMandatory)
523{
524 // Check whether uniqueName is in lookup table
525 const auto it = m_ofdmModulationLookupTable.find(uniqueName);
527 "OFDM mode cannot be created because it is not in the lookup table!");
528
529 return WifiModeFactory::CreateWifiMode(uniqueName,
531 isMandatory,
532 MakeBoundCallback(&GetCodeRate, uniqueName),
537}
538
540OfdmPhy::GetCodeRate(const std::string& name)
541{
542 return m_ofdmModulationLookupTable.at(name).first;
543}
544
545uint16_t
546OfdmPhy::GetConstellationSize(const std::string& name)
547{
548 return m_ofdmModulationLookupTable.at(name).second;
549}
550
551uint64_t
552OfdmPhy::GetPhyRate(const std::string& name, MHz_u channelWidth)
553{
554 WifiCodeRate codeRate = GetCodeRate(name);
555 uint64_t dataRate = GetDataRate(name, channelWidth);
556 return CalculatePhyRate(codeRate, dataRate);
557}
558
559uint64_t
560OfdmPhy::CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
561{
562 return (dataRate / GetCodeRatio(codeRate));
563}
564
565uint64_t
566OfdmPhy::GetPhyRateFromTxVector(const WifiTxVector& txVector, uint16_t /* staId */)
567{
568 return GetPhyRate(txVector.GetMode().GetUniqueName(), txVector.GetChannelWidth());
569}
570
571double
573{
574 switch (codeRate)
575 {
577 return (3.0 / 4.0);
579 return (2.0 / 3.0);
581 return (1.0 / 2.0);
583 default:
584 NS_FATAL_ERROR("trying to get code ratio for undefined coding rate");
585 return 0;
586 }
587}
588
589uint64_t
590OfdmPhy::GetDataRateFromTxVector(const WifiTxVector& txVector, uint16_t /* staId */)
591{
592 return GetDataRate(txVector.GetMode().GetUniqueName(), txVector.GetChannelWidth());
593}
594
595uint64_t
596OfdmPhy::GetDataRate(const std::string& name, MHz_u channelWidth)
597{
598 WifiCodeRate codeRate = GetCodeRate(name);
599 uint16_t constellationSize = GetConstellationSize(name);
600 return CalculateDataRate(codeRate, constellationSize, channelWidth);
601}
602
603uint64_t
604OfdmPhy::CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, MHz_u channelWidth)
605{
606 return CalculateDataRate(GetSymbolDuration(channelWidth),
608 static_cast<uint16_t>(log2(constellationSize)),
609 GetCodeRatio(codeRate));
610}
611
612uint64_t
614 uint16_t usableSubCarriers,
615 uint16_t numberOfBitsPerSubcarrier,
616 double codingRate)
617{
618 double symbolRate = (1e9 / static_cast<double>(symbolDuration.GetNanoSeconds()));
619 return ceil(symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate);
620}
621
622uint16_t
624{
625 return 48;
626}
627
628Time
630{
631 Time symbolDuration = MicroSeconds(4);
632 uint8_t bwFactor = 1;
633 if (channelWidth == MHz_u{10})
634 {
635 bwFactor = 2;
636 }
637 else if (channelWidth == MHz_u{5})
638 {
639 bwFactor = 4;
640 }
641 return bwFactor * symbolDuration;
642}
643
644bool
646{
647 return true;
648}
649
652{
653 return 4095;
654}
655
656MHz_u
658{
659 if (!ppdu)
660 {
661 return std::min(m_wifiPhy->GetChannelWidth(), MHz_u{20});
662 }
663 return GetRxChannelWidth(ppdu->GetTxVector());
664}
665
666dBm_u
668{
669 if (ppdu && ppdu->GetTxVector().GetChannelWidth() < MHz_u{20})
670 {
671 // scale CCA sensitivity threshold for BW of 5 and 10 MHz
672 const auto bw = GetRxChannelWidth(ppdu->GetTxVector());
673 const auto thresholdW = DbmToW(m_wifiPhy->GetCcaSensitivityThreshold()) * (bw / MHz_u{20});
674 return WToDbm(thresholdW);
675 }
676 return PhyEntity::GetCcaThreshold(ppdu, channelType);
677}
678
681{
682 const auto txWidth = ppdu->GetTxChannelWidth();
683 const auto& txVector = ppdu->GetTxVector();
684 // Update channel width in TXVECTOR for non-HT duplicate PPDUs.
685 if (txVector.IsNonHtDuplicate() && txWidth > m_wifiPhy->GetChannelWidth())
686 {
687 // We also do a copy of the PPDU for non-HT duplicate PPDUs since other
688 // PHYs might set a different channel width in the reconstructed TXVECTOR.
689 auto rxPpdu = ppdu->Copy();
690 auto updatedTxVector = txVector;
691 updatedTxVector.SetChannelWidth(std::min(txWidth, m_wifiPhy->GetChannelWidth()));
692 rxPpdu->UpdateTxVector(updatedTxVector);
693 return rxPpdu;
694 }
696}
697
698} // namespace ns3
699
700namespace
701{
702
703/**
704 * Constructor class for OFDM modes
705 */
707{
708 public:
715} g_constructor_ofdm; ///< the constructor for OFDM modes
716
717} // namespace
Constructor class for OFDM modes.
Definition ofdm-phy.cc:707
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6 Mbps.
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
Definition ofdm-phy.cc:651
~OfdmPhy() override
Destructor for OFDM PHY.
Definition ofdm-phy.cc:138
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate48Mbps()
Return a WifiMode for OFDM at 48 Mbps.
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:441
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()
Return a WifiMode for OFDM at 54 Mbps.
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()
Return a WifiMode for OFDM at 36 Mbps.
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for OFDM at 3 Mbps with 10 MHz channel spacing.
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()
Return a WifiMode for OFDM at 2.25 Mbps with 5 MHz channel spacing.
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()
Return a WifiMode for OFDM at 6 Mbps with 5 MHz channel spacing.
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()
Return a WifiMode for OFDM at 1.5 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18 Mbps with 10 MHz channel spacing.
static Time GetSymbolDuration(MHz_u channelWidth)
Definition ofdm-phy.cc:629
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12 Mbps with 10 MHz channel spacing.
static uint16_t GetUsableSubcarriers()
Definition ofdm-phy.cc:623
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for OFDM at 3 Mbps with 5 MHz channel spacing.
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()
Return a WifiMode for OFDM at 27 Mbps with 10 MHz channel spacing.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(Watt_u txPower, Ptr< const WifiPpdu > ppdu) const override
Definition ofdm-phy.cc:356
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9 Mbps with 5 MHz channel spacing.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition ofdm-phy.cc:284
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for OFDM at 12Mbps.
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()
Return a WifiMode for OFDM at 24 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18 Mbps.
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()
Return a WifiMode for OFDM at 6 Mbps with 10 MHz channel spacing.
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()
Return a WifiMode for OFDM at 24 Mbps.
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()
Return a WifiMode for OFDM at 12 Mbps with 5 MHz channel spacing.
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:444
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for OFDM at 4.5 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate9Mbps()
Return a WifiMode for OFDM at 9 Mbps.
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
MHz_u GetGuardBandwidth(MHz_u currentChannelWidth) const
virtual Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
Definition phy-entity.h:941
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition phy-entity.h:541
virtual MHz_u GetRxChannelWidth(const WifiTxVector &txVector) const
Return the channel width used in the reception spectrum model.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition phy-entity.h:531
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
virtual dBm_u GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const
Return the CCA threshold for a given channel type.
std::list< WifiMode > m_modeList
the list of supported modes
Definition phy-entity.h:945
double GetRandomValue() const
Obtain a random value from the WifiPhy's generator.
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
virtual Ptr< const WifiPpdu > GetRxPpduFromTxPpdu(Ptr< const WifiPpdu > ppdu)
The WifiPpdu from the TX PHY is received by each RX PHY attached to the same channel.
std::tuple< dBr_u, dBr_u, dBr_u > GetTxMaskRejectionParams() const
virtual bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
@ DROP
drop PPDU and set CCA_BUSY
Definition phy-entity.h:71
@ ABORT
abort reception of PPDU
Definition phy-entity.h:72
virtual PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:407
int64_t GetFemtoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:417
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, AllowedCallback isAllowedCallback)
Definition wifi-mode.cc:257
represent a single transmission mode
Definition wifi-mode.h:38
const std::string & GetUniqueName() const
Definition wifi-mode.cc:136
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:110
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Definition wifi-phy.cc:810
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1087
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1069
Ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition wifi-phy.cc:784
dBm_u GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold.
Definition wifi-phy.cc:555
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 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).
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
MHz_u GetChannelWidth() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Definition callback.h:745
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1405
WifiPhyBand
Identifies the PHY band.
OfdmPhyVariant
The OFDM (11a) PHY variants.
Definition ofdm-phy.h:33
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:48
@ UNSUPPORTED_SETTINGS
@ L_SIG_FAILURE
@ WIFI_PREAMBLE_LONG
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ OFDM_PHY_10_MHZ
Definition ofdm-phy.h:35
@ OFDM_PHY_DEFAULT
Definition ofdm-phy.h:34
@ OFDM_PHY_5_MHZ
Definition ofdm-phy.h:36
@ WIFI_PPDU_FIELD_NON_HT_HEADER
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_DATA
data field
class anonymous_namespace{ofdm-phy.cc}::ConstructorOfdm g_constructor_ofdm
the constructor for OFDM modes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
Definition wifi-utils.cc:45
const std::map< MHz_u, std::array< uint64_t, 8 > > & GetOfdmRatesBpsList()
Get the array of possible OFDM rates for each bandwidth.
Definition ofdm-phy.cc:93
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
Definition wifi-utils.cc:38
double MHz_u
MHz weak type.
Definition wifi-units.h:31
double dBm_u
dBm weak type
Definition wifi-units.h:27
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Definition wifi-utils.cc:32
const std::map< MHz_u, std::array< uint64_t, 8 > > s_ofdmRatesBpsList
OFDM rates in bits per second for each bandwidth.
Definition ofdm-phy.cc:73
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
@ WIFI_CODE_RATE_2_3
2/3 coding rate
@ WIFI_CODE_RATE_1_2
1/2 coding rate
@ WIFI_CODE_RATE_3_4
3/4 coding rate
@ WIFI_CODE_RATE_UNDEFINED
undefined coding rate
#define GET_OFDM_MODE(x, f)
Definition ofdm-phy.cc:485
Declaration of ns3::OfdmPhy class and ns3::OfdmPhyVariant enum.
Declaration of ns3::OfdmPpdu class.
Status of the reception of the PPDU field.
Definition phy-entity.h:80
WifiPhyRxfailureReason reason
failure reason
Definition phy-entity.h:82
PhyRxFailureAction actionIfFailure
action to perform in case of failure
Definition phy-entity.h:83
bool isSuccess
outcome (true if success) of the reception
Definition phy-entity.h:81
A struct for both SNR and PER.
Definition phy-entity.h:115
double snr
SNR in linear scale.
Definition phy-entity.h:116