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 {{ 20, // MHz
75 { 6000000, 9000000, 12000000, 18000000,
76 24000000, 36000000, 48000000, 54000000 }},
77 { 10, // MHz
78 { 3000000, 4500000, 6000000, 9000000,
79 12000000, 18000000, 24000000, 27000000 }},
80 { 5, // MHz
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(20))
110 {
111 WifiMode mode = GetOfdmRate(rate, 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(10))
118 {
119 WifiMode mode = GetOfdmRate(rate, 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(5))
126 {
127 WifiMode mode = GetOfdmRate(rate, 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 =
264 lrint(ceil((GetNumberServiceBits() + size * 8.0 + 6.0) / (numDataBitsPerSymbol)));
265
266 Time payloadDuration =
267 FemtoSeconds(static_cast<uint64_t>(numSymbols * symbolDuration.GetFemtoSeconds()));
268 payloadDuration += GetSignalExtension(band);
269 return payloadDuration;
270}
271
272uint8_t
274{
275 return 16;
276}
277
278Time
280{
281 return (band == WIFI_PHY_BAND_2_4GHZ) ? MicroSeconds(6) : MicroSeconds(0);
282}
283
286 const WifiTxVector& txVector,
287 Time /* ppduDuration */)
288{
289 NS_LOG_FUNCTION(this << psdus << txVector);
290 return Create<OfdmPpdu>(
291 psdus.begin()->second,
292 txVector,
294 m_wifiPhy->GetLatestPhyEntity()->ObtainNextUid(
295 txVector)); // use latest PHY entity to handle MU-RTS sent with non-HT rate
296}
297
300{
301 NS_LOG_FUNCTION(this << field << *event);
303 {
304 return EndReceiveHeader(event); // L-SIG
305 }
306 return PhyEntity::DoEndReceiveField(field, event);
307}
308
311{
312 NS_LOG_FUNCTION(this << *event);
314 NS_LOG_DEBUG("L-SIG: SNR(dB)=" << RatioToDb(snrPer.snr) << ", PER=" << snrPer.per);
315 PhyFieldRxStatus status(GetRandomValue() > snrPer.per);
316 if (status.isSuccess)
317 {
318 NS_LOG_DEBUG("Received non-HT PHY header");
320 {
322 }
323 }
324 else
325 {
326 NS_LOG_DEBUG("Abort reception because non-HT PHY header reception failed");
327 status.reason = L_SIG_FAILURE;
328 status.actionIfFailure = ABORT;
329 }
330 return status;
331}
332
333bool
335{
336 const auto channelWidth = ppdu->GetTxVector().GetChannelWidth();
337 if ((channelWidth >= 40) && (channelWidth > m_wifiPhy->GetChannelWidth()))
338 {
339 NS_LOG_DEBUG("Packet reception could not be started because not enough channel width ("
340 << channelWidth << " vs " << m_wifiPhy->GetChannelWidth() << ")");
341 return false;
342 }
343 return true;
344}
345
346bool
348{
349 if (!IsChannelWidthSupported(ppdu))
350 {
351 return false;
352 }
353 return IsConfigSupported(ppdu);
354}
355
358{
359 const auto& centerFrequencies = ppdu->GetTxCenterFreqs();
360 const auto& txVector = ppdu->GetTxVector();
361 const auto channelWidth = txVector.GetChannelWidth();
362 NS_LOG_FUNCTION(this << centerFrequencies.front() << channelWidth << txPower);
363 const auto& txMaskRejectionParams = GetTxMaskRejectionParams();
365 if (txVector.IsNonHtDuplicate())
366 {
368 centerFrequencies,
369 channelWidth,
370 txPower,
371 GetGuardBandwidth(channelWidth),
372 std::get<0>(txMaskRejectionParams),
373 std::get<1>(txMaskRejectionParams),
374 std::get<2>(txMaskRejectionParams));
375 }
376 else
377 {
378 NS_ASSERT(centerFrequencies.size() == 1);
380 centerFrequencies.front(),
381 channelWidth,
382 txPower,
383 GetGuardBandwidth(channelWidth),
384 std::get<0>(txMaskRejectionParams),
385 std::get<1>(txMaskRejectionParams),
386 std::get<2>(txMaskRejectionParams));
387 }
388 return v;
389}
390
391void
393{
394 for (const auto& ratesPerBw : GetOfdmRatesBpsList())
395 {
396 for (const auto& rate : ratesPerBw.second)
397 {
398 GetOfdmRate(rate, ratesPerBw.first);
399 }
400 }
401}
402
404OfdmPhy::GetOfdmRate(uint64_t rate, MHz_u bw)
405{
406 switch (static_cast<uint16_t>(bw))
407 {
408 case 20:
409 switch (rate)
410 {
411 case 6000000:
412 return GetOfdmRate6Mbps();
413 case 9000000:
414 return GetOfdmRate9Mbps();
415 case 12000000:
416 return GetOfdmRate12Mbps();
417 case 18000000:
418 return GetOfdmRate18Mbps();
419 case 24000000:
420 return GetOfdmRate24Mbps();
421 case 36000000:
422 return GetOfdmRate36Mbps();
423 case 48000000:
424 return GetOfdmRate48Mbps();
425 case 54000000:
426 return GetOfdmRate54Mbps();
427 default:
428 NS_ABORT_MSG("Inexistent rate (" << rate << " bps) requested for 11a OFDM (default)");
429 return WifiMode();
430 }
431 break;
432 case 10:
433 switch (rate)
434 {
435 case 3000000:
437 case 4500000:
439 case 6000000:
441 case 9000000:
443 case 12000000:
445 case 18000000:
447 case 24000000:
449 case 27000000:
451 default:
452 NS_ABORT_MSG("Inexistent rate (" << rate << " bps) requested for 11a OFDM (10 MHz)");
453 return WifiMode();
454 }
455 break;
456 case 5:
457 switch (rate)
458 {
459 case 1500000:
461 case 2250000:
463 case 3000000:
464 return GetOfdmRate3MbpsBW5MHz();
465 case 4500000:
467 case 6000000:
468 return GetOfdmRate6MbpsBW5MHz();
469 case 9000000:
470 return GetOfdmRate9MbpsBW5MHz();
471 case 12000000:
473 case 13500000:
475 default:
476 NS_ABORT_MSG("Inexistent rate (" << rate << " bps) requested for 11a OFDM (5 MHz)");
477 return WifiMode();
478 }
479 break;
480 default:
481 NS_ABORT_MSG("Inexistent bandwidth (" << +bw << " MHz) requested for 11a OFDM");
482 return WifiMode();
483 }
484}
485
486#define GET_OFDM_MODE(x, f) \
487 WifiMode OfdmPhy::Get##x() \
488 { \
489 static WifiMode mode = CreateOfdmMode(#x, f); \
490 return mode; \
491 }
492
493// 20 MHz channel rates (default)
494GET_OFDM_MODE(OfdmRate6Mbps, true)
495GET_OFDM_MODE(OfdmRate9Mbps, false)
496GET_OFDM_MODE(OfdmRate12Mbps, true)
497GET_OFDM_MODE(OfdmRate18Mbps, false)
498GET_OFDM_MODE(OfdmRate24Mbps, true)
499GET_OFDM_MODE(OfdmRate36Mbps, false)
500GET_OFDM_MODE(OfdmRate48Mbps, false)
501GET_OFDM_MODE(OfdmRate54Mbps, false)
502// 10 MHz channel rates
503GET_OFDM_MODE(OfdmRate3MbpsBW10MHz, true)
504GET_OFDM_MODE(OfdmRate4_5MbpsBW10MHz, false)
505GET_OFDM_MODE(OfdmRate6MbpsBW10MHz, true)
506GET_OFDM_MODE(OfdmRate9MbpsBW10MHz, false)
507GET_OFDM_MODE(OfdmRate12MbpsBW10MHz, true)
508GET_OFDM_MODE(OfdmRate18MbpsBW10MHz, false)
509GET_OFDM_MODE(OfdmRate24MbpsBW10MHz, false)
510GET_OFDM_MODE(OfdmRate27MbpsBW10MHz, false)
511// 5 MHz channel rates
512GET_OFDM_MODE(OfdmRate1_5MbpsBW5MHz, true)
513GET_OFDM_MODE(OfdmRate2_25MbpsBW5MHz, false)
514GET_OFDM_MODE(OfdmRate3MbpsBW5MHz, true)
515GET_OFDM_MODE(OfdmRate4_5MbpsBW5MHz, false)
516GET_OFDM_MODE(OfdmRate6MbpsBW5MHz, true)
517GET_OFDM_MODE(OfdmRate9MbpsBW5MHz, false)
518GET_OFDM_MODE(OfdmRate12MbpsBW5MHz, false)
519GET_OFDM_MODE(OfdmRate13_5MbpsBW5MHz, false)
520#undef GET_OFDM_MODE
521
522WifiMode
523OfdmPhy::CreateOfdmMode(std::string uniqueName, bool isMandatory)
524{
525 // Check whether uniqueName is in lookup table
526 const auto it = m_ofdmModulationLookupTable.find(uniqueName);
528 "OFDM mode cannot be created because it is not in the lookup table!");
529
530 return WifiModeFactory::CreateWifiMode(uniqueName,
532 isMandatory,
533 MakeBoundCallback(&GetCodeRate, uniqueName),
538}
539
541OfdmPhy::GetCodeRate(const std::string& name)
542{
543 return m_ofdmModulationLookupTable.at(name).first;
544}
545
546uint16_t
547OfdmPhy::GetConstellationSize(const std::string& name)
548{
549 return m_ofdmModulationLookupTable.at(name).second;
550}
551
552uint64_t
553OfdmPhy::GetPhyRate(const std::string& name, MHz_u channelWidth)
554{
555 WifiCodeRate codeRate = GetCodeRate(name);
556 uint64_t dataRate = GetDataRate(name, channelWidth);
557 return CalculatePhyRate(codeRate, dataRate);
558}
559
560uint64_t
561OfdmPhy::CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
562{
563 return (dataRate / GetCodeRatio(codeRate));
564}
565
566uint64_t
567OfdmPhy::GetPhyRateFromTxVector(const WifiTxVector& txVector, uint16_t /* staId */)
568{
569 return GetPhyRate(txVector.GetMode().GetUniqueName(), txVector.GetChannelWidth());
570}
571
572double
574{
575 switch (codeRate)
576 {
578 return (3.0 / 4.0);
580 return (2.0 / 3.0);
582 return (1.0 / 2.0);
584 default:
585 NS_FATAL_ERROR("trying to get code ratio for undefined coding rate");
586 return 0;
587 }
588}
589
590uint64_t
591OfdmPhy::GetDataRateFromTxVector(const WifiTxVector& txVector, uint16_t /* staId */)
592{
593 return GetDataRate(txVector.GetMode().GetUniqueName(), txVector.GetChannelWidth());
594}
595
596uint64_t
597OfdmPhy::GetDataRate(const std::string& name, MHz_u channelWidth)
598{
599 WifiCodeRate codeRate = GetCodeRate(name);
600 uint16_t constellationSize = GetConstellationSize(name);
601 return CalculateDataRate(codeRate, constellationSize, channelWidth);
602}
603
604uint64_t
605OfdmPhy::CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, MHz_u channelWidth)
606{
607 return CalculateDataRate(GetSymbolDuration(channelWidth),
609 static_cast<uint16_t>(log2(constellationSize)),
610 GetCodeRatio(codeRate));
611}
612
613uint64_t
615 uint16_t usableSubCarriers,
616 uint16_t numberOfBitsPerSubcarrier,
617 double codingRate)
618{
619 double symbolRate = (1e9 / static_cast<double>(symbolDuration.GetNanoSeconds()));
620 return lrint(ceil(symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
621}
622
623uint16_t
625{
626 return 48;
627}
628
629Time
631{
632 Time symbolDuration = MicroSeconds(4);
633 uint8_t bwFactor = 1;
634 if (channelWidth == 10)
635 {
636 bwFactor = 2;
637 }
638 else if (channelWidth == 5)
639 {
640 bwFactor = 4;
641 }
642 return bwFactor * symbolDuration;
643}
644
645bool
647{
648 return true;
649}
650
653{
654 return 4095;
655}
656
657MHz_u
659{
660 if (!ppdu)
661 {
662 return std::min<MHz_u>(m_wifiPhy->GetChannelWidth(), 20);
663 }
664 return GetRxChannelWidth(ppdu->GetTxVector());
665}
666
667dBm_u
669{
670 if (ppdu && ppdu->GetTxVector().GetChannelWidth() < 20)
671 {
672 // scale CCA sensitivity threshold for BW of 5 and 10 MHz
673 const auto bw = GetRxChannelWidth(ppdu->GetTxVector());
674 const auto thresholdW = DbmToW(m_wifiPhy->GetCcaSensitivityThreshold()) * (bw / 20.0);
675 return WToDbm(thresholdW);
676 }
677 return PhyEntity::GetCcaThreshold(ppdu, channelType);
678}
679
682{
683 const auto txWidth = ppdu->GetTxChannelWidth();
684 const auto& txVector = ppdu->GetTxVector();
685 // Update channel width in TXVECTOR for non-HT duplicate PPDUs.
686 if (txVector.IsNonHtDuplicate() && txWidth > m_wifiPhy->GetChannelWidth())
687 {
688 // We also do a copy of the PPDU for non-HT duplicate PPDUs since other
689 // PHYs might set a different channel width in the reconstructed TXVECTOR.
690 auto rxPpdu = ppdu->Copy();
691 auto updatedTxVector = txVector;
692 updatedTxVector.SetChannelWidth(std::min(txWidth, m_wifiPhy->GetChannelWidth()));
693 rxPpdu->UpdateTxVector(updatedTxVector);
694 return rxPpdu;
695 }
697}
698
699} // namespace ns3
700
701namespace
702{
703
704/**
705 * Constructor class for OFDM modes
706 */
708{
709 public:
716} g_constructor_ofdm; ///< the constructor for OFDM modes
717
718} // namespace
Constructor class for OFDM modes.
Definition ofdm-phy.cc:708
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:652
~OfdmPhy() override
Destructor for OFDM PHY.
Definition ofdm-phy.cc:138
static WifiMode GetOfdmRate(uint64_t rate, MHz_u bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
Definition ofdm-phy.cc:404
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:668
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:547
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54 Mbps.
uint8_t GetNumberServiceBits() const
Definition ofdm-phy.cc:273
static WifiCodeRate GetCodeRate(const std::string &name)
Return the WifiCodeRate from the OFDM mode's unique name using ModulationLookupTable.
Definition ofdm-phy.cc:541
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition ofdm-phy.cc:567
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:392
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:347
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform OFDM-specific actions, and provide the status of the reception.
Definition ofdm-phy.cc:310
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:597
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition ofdm-phy.cc:646
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:591
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:630
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12 Mbps with 10 MHz channel spacing.
static uint16_t GetUsableSubcarriers()
Definition ofdm-phy.cc:624
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:681
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:357
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:285
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:523
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:561
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:658
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:299
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, MHz_u channelWidth)
Calculates data rate from the supplied parameters.
Definition ofdm-phy.cc:605
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:553
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:334
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:573
Time GetSignalExtension(WifiPhyBand band) const
Definition ofdm-phy.cc:279
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:939
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition phy-entity.h:539
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:529
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:943
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:259
represent a single transmission mode
Definition wifi-mode.h:40
const std::string & GetUniqueName() const
Definition wifi-mode.cc:137
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:111
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:795
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1093
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1075
Ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition wifi-phy.cc:769
dBm_u GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold.
Definition wifi-phy.cc:540
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(MHz_u centerFrequency, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, dBr_u minInnerBand=-20, dBr_u minOuterband=-28, dBr_u lowestPoint=-40)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
static Ptr< SpectrumValue > CreateDuplicated20MhzTxPowerSpectralDensity(const std::vector< MHz_u > &centerFrequencies, MHz_u channelWidth, Watt_u txPower, MHz_u guardBandwidth, dBr_u minInnerBand=-20, dBr_u minOuterband=-28, dBr_u lowestPoint=-40, const std::vector< bool > &puncturedSubchannels={})
Create a transmit power spectral density corresponding to OFDM duplicated over multiple 20 MHz subcha...
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:1332
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1368
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:41
@ 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.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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:44
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:37
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:31
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
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:486
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