A Discrete-Event Network Simulator
API
ofdm-phy.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2020 Orange Labs
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Rediet <getachew.redieteab@orange.com>
19 * S├ębastien Deronne <sebastien.deronne@gmail.com> (for logic ported from wifi-phy)
20 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (for logic ported from wifi-phy)
21 */
22
23#include "ofdm-phy.h"
24#include "ofdm-ppdu.h"
25#include "ns3/wifi-psdu.h"
26#include "ns3/wifi-phy.h"
27#include "ns3/wifi-utils.h"
28#include "ns3/interference-helper.h"
29#include "ns3/simulator.h"
30#include "ns3/log.h"
31#include <array>
32
33namespace ns3 {
34
35NS_LOG_COMPONENT_DEFINE ("OfdmPhy");
36
37/*******************************************************
38 * OFDM PHY (IEEE 802.11-2016, clause 17)
39 *******************************************************/
40
41/* *NS_CHECK_STYLE_OFF* */
46};
47
49 // Unique name Code rate Constellation size
50 { "OfdmRate6Mbps", { WIFI_CODE_RATE_1_2, 2 } }, // 20 MHz
51 { "OfdmRate9Mbps", { WIFI_CODE_RATE_3_4, 2 } }, // |
52 { "OfdmRate12Mbps", { WIFI_CODE_RATE_1_2, 4 } }, // V
53 { "OfdmRate18Mbps", { WIFI_CODE_RATE_3_4, 4 } },
54 { "OfdmRate24Mbps", { WIFI_CODE_RATE_1_2, 16 } },
55 { "OfdmRate36Mbps", { WIFI_CODE_RATE_3_4, 16 } },
56 { "OfdmRate48Mbps", { WIFI_CODE_RATE_2_3, 64 } },
57 { "OfdmRate54Mbps", { WIFI_CODE_RATE_3_4, 64 } },
58 { "OfdmRate3MbpsBW10MHz", { WIFI_CODE_RATE_1_2, 2 } }, // 10 MHz
59 { "OfdmRate4_5MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 2 } }, // |
60 { "OfdmRate6MbpsBW10MHz", { WIFI_CODE_RATE_1_2, 4 } }, // V
61 { "OfdmRate9MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 4 } },
62 { "OfdmRate12MbpsBW10MHz", { WIFI_CODE_RATE_1_2, 16 } },
63 { "OfdmRate18MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 16 } },
64 { "OfdmRate24MbpsBW10MHz", { WIFI_CODE_RATE_2_3, 64 } },
65 { "OfdmRate27MbpsBW10MHz", { WIFI_CODE_RATE_3_4, 64 } },
66 { "OfdmRate1_5MbpsBW5MHz", { WIFI_CODE_RATE_1_2, 2 } }, // 5 MHz
67 { "OfdmRate2_25MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 2 } }, // |
68 { "OfdmRate3MbpsBW5MHz", { WIFI_CODE_RATE_1_2, 4 } }, // V
69 { "OfdmRate4_5MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 4 } },
70 { "OfdmRate6MbpsBW5MHz", { WIFI_CODE_RATE_1_2, 16 } },
71 { "OfdmRate9MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 16 } },
72 { "OfdmRate12MbpsBW5MHz", { WIFI_CODE_RATE_2_3, 64 } },
73 { "OfdmRate13_5MbpsBW5MHz", { WIFI_CODE_RATE_3_4, 64 } }
74};
75
77const std::map<uint16_t, std::array<uint64_t, 8> > s_ofdmRatesBpsList =
78 {{ 20, // MHz
79 { 6000000, 9000000, 12000000, 18000000,
80 24000000, 36000000, 48000000, 54000000 }},
81 { 10, // MHz
82 { 3000000, 4500000, 6000000, 9000000,
83 12000000, 18000000, 24000000, 27000000 }},
84 { 5, // MHz
85 { 1500000, 2250000, 3000000, 4500000,
86 6000000, 9000000, 12000000, 13500000 }}};
87
88/* *NS_CHECK_STYLE_ON* */
89
95const std::map<uint16_t, std::array<uint64_t, 8> >& GetOfdmRatesBpsList (void)
96{
97 return s_ofdmRatesBpsList;
98};
99
100
101OfdmPhy::OfdmPhy (OfdmPhyVariant variant /* = OFDM_PHY_DEFAULT */, bool buildModeList /* = true */)
102{
103 NS_LOG_FUNCTION (this << variant << buildModeList);
104
105 if (buildModeList)
106 {
107 auto bwRatesMap = GetOfdmRatesBpsList ();
108
109 switch (variant)
110 {
111 case OFDM_PHY_DEFAULT:
112 for (const auto & rate : bwRatesMap.at (20))
113 {
114 WifiMode mode = GetOfdmRate (rate, 20);
115 NS_LOG_LOGIC ("Add " << mode << " to list");
116 m_modeList.emplace_back (mode);
117 }
118 break;
119 case OFDM_PHY_10_MHZ:
120 for (const auto & rate : bwRatesMap.at (10))
121 {
122 WifiMode mode = GetOfdmRate (rate, 10);
123 NS_LOG_LOGIC ("Add " << mode << " to list");
124 m_modeList.emplace_back (mode);
125 }
126 break;
127 case OFDM_PHY_5_MHZ:
128 for (const auto & rate : bwRatesMap.at (5))
129 {
130 WifiMode mode = GetOfdmRate (rate, 5);
131 NS_LOG_LOGIC ("Add " << mode << " to list");
132 m_modeList.emplace_back (mode);
133 }
134 break;
135 default:
136 NS_ABORT_MSG ("Unsupported 11a OFDM variant");
137 }
138 }
139}
140
142{
143 NS_LOG_FUNCTION (this);
144}
145
147OfdmPhy::GetSigMode (WifiPpduField field, const WifiTxVector& txVector) const
148{
149 switch (field)
150 {
151 case WIFI_PPDU_FIELD_PREAMBLE: //consider header mode for preamble (useful for InterferenceHelper)
153 return GetHeaderMode (txVector);
154 default:
155 return PhyEntity::GetSigMode (field, txVector);
156 }
157}
158
161{
162 switch (txVector.GetChannelWidth ())
163 {
164 case 5:
165 return GetOfdmRate1_5MbpsBW5MHz ();
166 case 10:
167 return GetOfdmRate3MbpsBW10MHz ();
168 case 20:
169 default:
170 //Section 17.3.2 "PPDU frame format"; IEEE Std 802.11-2016.
171 //Actually this is only the first part of the PhyHeader,
172 //because the last 16 bits of the PhyHeader are using the
173 //same mode of the payload
174 return GetOfdmRate6Mbps ();
175 }
176}
177
180{
181 return m_ofdmPpduFormats;
182}
183
184Time
185OfdmPhy::GetDuration (WifiPpduField field, const WifiTxVector& txVector) const
186{
187 switch (field)
188 {
190 return GetPreambleDuration (txVector); //L-STF + L-LTF
192 return GetHeaderDuration (txVector); //L-SIG
193 default:
194 return PhyEntity::GetDuration (field, txVector);
195 }
196}
197
198Time
200{
201 switch (txVector.GetChannelWidth ())
202 {
203 case 20:
204 default:
205 //Section 17.3.3 "PHY preamble (SYNC)" Figure 17-4 "OFDM training structure"
206 //also Section 17.3.2.3 "Modulation-dependent parameters" Table 17-4 "Modulation-dependent parameters"; IEEE Std 802.11-2016
207 return MicroSeconds (16);
208 case 10:
209 //Section 17.3.3 "PHY preamble (SYNC)" Figure 17-4 "OFDM training structure"
210 //also Section 17.3.2.3 "Modulation-dependent parameters" Table 17-4 "Modulation-dependent 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 parameters"; IEEE Std 802.11-2016
215 return MicroSeconds (64);
216 }
217}
218
219Time
221{
222 switch (txVector.GetChannelWidth ())
223 {
224 case 20:
225 default:
226 //Section 17.3.3 "PHY preamble (SYNC)" and Figure 17-4 "OFDM training structure"; IEEE Std 802.11-2016
227 //also Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related parameters"; IEEE Std 802.11-2016
228 //We return the duration of the SIGNAL field only, since the
229 //SERVICE field (which strictly speaking belongs to the PHY
230 //header, see Section 17.3.2 and Figure 17-1) is sent using the
231 //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 Std 802.11-2016
235 return MicroSeconds (8);
236 case 5:
237 //Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related parameters"; IEEE Std 802.11-2016
238 return MicroSeconds (16);
239 }
240}
241
242Time
243OfdmPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType /* mpdutype */,
244 bool /* incFlag */, uint32_t & /* totalAmpduSize */, double & /* totalAmpduNumSymbols */,
245 uint16_t /* staId */) const
246{
247 //(Section 17.3.2.4 "Timing related parameters" Table 17-5 "Timing-related parameters"; IEEE Std 802.11-2016
248 //corresponds to T_{SYM} in the table)
249 Time symbolDuration = MicroSeconds (4);
250
251 double numDataBitsPerSymbol = txVector.GetMode ().GetDataRate (txVector) * symbolDuration.GetNanoSeconds () / 1e9;
252
253 //The number of OFDM symbols in the data field when BCC encoding
254 //is used is given in equation 19-32 of the IEEE 802.11-2016 standard.
255 double numSymbols = lrint (ceil ((GetNumberServiceBits () + size * 8.0 + 6.0) / (numDataBitsPerSymbol)));
256
257 Time payloadDuration = FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
258 payloadDuration += GetSignalExtension (band);
259 return payloadDuration;
260}
261
262uint8_t
264{
265 return 16;
266}
267
268Time
270{
271 return (band == WIFI_PHY_BAND_2_4GHZ) ? MicroSeconds (6) : MicroSeconds (0);
272}
273
275OfdmPhy::BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time /* ppduDuration */)
276{
277 NS_LOG_FUNCTION (this << psdus << txVector);
278 return Create<OfdmPpdu> (psdus.begin ()->second, txVector,
280 m_wifiPhy->GetPhyBand (), ObtainNextUid (txVector));
281}
282
285{
286 NS_LOG_FUNCTION (this << field << *event);
288 {
289 return EndReceiveHeader (event); //L-SIG
290 }
291 return PhyEntity::DoEndReceiveField (field, event);
292}
293
296{
297 NS_LOG_FUNCTION (this << *event);
299 NS_LOG_DEBUG ("L-SIG: SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
300 PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
301 if (status.isSuccess)
302 {
303 NS_LOG_DEBUG ("Received non-HT PHY header");
304 if (!IsAllConfigSupported (WIFI_PPDU_FIELD_NON_HT_HEADER, event->GetPpdu ()))
305 {
306 status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
307 }
308 }
309 else
310 {
311 NS_LOG_DEBUG ("Abort reception because non-HT PHY header reception failed");
312 status.reason = L_SIG_FAILURE;
313 status.actionIfFailure = ABORT;
314 }
315 return status;
316}
317
318bool
320{
321 uint16_t channelWidth = ppdu->GetTxVector ().GetChannelWidth ();
322 if ((channelWidth >= 40) && (channelWidth > m_wifiPhy->GetChannelWidth ()))
323 {
324 NS_LOG_DEBUG ("Packet reception could not be started because not enough channel width (" << channelWidth << " vs " << m_wifiPhy->GetChannelWidth () << ")");
325 return false;
326 }
327 return true;
328}
329
330bool
332{
333 if (!IsChannelWidthSupported (ppdu))
334 {
335 return false;
336 }
337 return IsConfigSupported (ppdu);
338}
339
342{
343 const WifiTxVector& txVector = ppdu->GetTxVector ();
344 uint16_t centerFrequency = GetCenterFrequencyForChannelWidth (txVector);
345 uint16_t channelWidth = txVector.GetChannelWidth ();
346 NS_LOG_FUNCTION (this << centerFrequency << channelWidth << txPowerW);
347 const auto & txMaskRejectionParams = GetTxMaskRejectionParams ();
348 Ptr<SpectrumValue> v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
349 std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
350 return v;
351}
352
353void
355{
356 for (const auto & ratesPerBw : GetOfdmRatesBpsList ())
357 {
358 for (const auto & rate : ratesPerBw.second)
359 {
360 GetOfdmRate (rate, ratesPerBw.first);
361 }
362 }
363}
364
366OfdmPhy::GetOfdmRate (uint64_t rate, uint16_t bw)
367{
368 switch (bw)
369 {
370 case 20:
371 switch (rate)
372 {
373 case 6000000:
374 return GetOfdmRate6Mbps ();
375 case 9000000:
376 return GetOfdmRate9Mbps ();
377 case 12000000:
378 return GetOfdmRate12Mbps ();
379 case 18000000:
380 return GetOfdmRate18Mbps ();
381 case 24000000:
382 return GetOfdmRate24Mbps ();
383 case 36000000:
384 return GetOfdmRate36Mbps ();
385 case 48000000:
386 return GetOfdmRate48Mbps ();
387 case 54000000:
388 return GetOfdmRate54Mbps ();
389 default:
390 NS_ABORT_MSG ("Inexistent rate (" << rate << " bps) requested for 11a OFDM (default)");
391 return WifiMode ();
392 }
393 break;
394 case 10:
395 switch (rate)
396 {
397 case 3000000:
398 return GetOfdmRate3MbpsBW10MHz ();
399 case 4500000:
401 case 6000000:
402 return GetOfdmRate6MbpsBW10MHz ();
403 case 9000000:
404 return GetOfdmRate9MbpsBW10MHz ();
405 case 12000000:
406 return GetOfdmRate12MbpsBW10MHz ();
407 case 18000000:
408 return GetOfdmRate18MbpsBW10MHz ();
409 case 24000000:
410 return GetOfdmRate24MbpsBW10MHz ();
411 case 27000000:
412 return GetOfdmRate27MbpsBW10MHz ();
413 default:
414 NS_ABORT_MSG ("Inexistent rate (" << rate << " bps) requested for 11a OFDM (10 MHz)");
415 return WifiMode ();
416 }
417 break;
418 case 5:
419 switch (rate)
420 {
421 case 1500000:
422 return GetOfdmRate1_5MbpsBW5MHz ();
423 case 2250000:
425 case 3000000:
426 return GetOfdmRate3MbpsBW5MHz ();
427 case 4500000:
428 return GetOfdmRate4_5MbpsBW5MHz ();
429 case 6000000:
430 return GetOfdmRate6MbpsBW5MHz ();
431 case 9000000:
432 return GetOfdmRate9MbpsBW5MHz ();
433 case 12000000:
434 return GetOfdmRate12MbpsBW5MHz ();
435 case 13500000:
437 default:
438 NS_ABORT_MSG ("Inexistent rate (" << rate << " bps) requested for 11a OFDM (5 MHz)");
439 return WifiMode ();
440 }
441 break;
442 default:
443 NS_ABORT_MSG ("Inexistent bandwidth (" << +bw << " MHz) requested for 11a OFDM");
444 return WifiMode ();
445 }
446}
447
448#define GET_OFDM_MODE(x, f) \
449WifiMode \
450OfdmPhy::Get ## x (void) \
451{ \
452 static WifiMode mode = CreateOfdmMode (#x, f); \
453 return mode; \
454}; \
455
456// 20 MHz channel rates (default)
457GET_OFDM_MODE (OfdmRate6Mbps, true)
458GET_OFDM_MODE (OfdmRate9Mbps, false)
459GET_OFDM_MODE (OfdmRate12Mbps, true)
460GET_OFDM_MODE (OfdmRate18Mbps, false)
461GET_OFDM_MODE (OfdmRate24Mbps, true)
462GET_OFDM_MODE (OfdmRate36Mbps, false)
463GET_OFDM_MODE (OfdmRate48Mbps, false)
464GET_OFDM_MODE (OfdmRate54Mbps, false)
465// 10 MHz channel rates
466GET_OFDM_MODE (OfdmRate3MbpsBW10MHz, true)
467GET_OFDM_MODE (OfdmRate4_5MbpsBW10MHz, false)
468GET_OFDM_MODE (OfdmRate6MbpsBW10MHz, true)
469GET_OFDM_MODE (OfdmRate9MbpsBW10MHz, false)
470GET_OFDM_MODE (OfdmRate12MbpsBW10MHz, true)
471GET_OFDM_MODE (OfdmRate18MbpsBW10MHz, false)
472GET_OFDM_MODE (OfdmRate24MbpsBW10MHz, false)
473GET_OFDM_MODE (OfdmRate27MbpsBW10MHz, false)
474// 5 MHz channel rates
475GET_OFDM_MODE (OfdmRate1_5MbpsBW5MHz, true)
476GET_OFDM_MODE (OfdmRate2_25MbpsBW5MHz, false)
477GET_OFDM_MODE (OfdmRate3MbpsBW5MHz, true)
478GET_OFDM_MODE (OfdmRate4_5MbpsBW5MHz, false)
479GET_OFDM_MODE (OfdmRate6MbpsBW5MHz, true)
480GET_OFDM_MODE (OfdmRate9MbpsBW5MHz, false)
481GET_OFDM_MODE (OfdmRate12MbpsBW5MHz, false)
482GET_OFDM_MODE (OfdmRate13_5MbpsBW5MHz, false)
483#undef GET_OFDM_MODE
484
485WifiMode
486OfdmPhy::CreateOfdmMode (std::string uniqueName, bool isMandatory)
487{
488 // Check whether uniqueName is in lookup table
489 const auto it = m_ofdmModulationLookupTable.find (uniqueName);
490 NS_ASSERT_MSG (it != m_ofdmModulationLookupTable.end (), "OFDM mode cannot be created because it is not in the lookup table!");
491
492 return WifiModeFactory::CreateWifiMode (uniqueName,
494 isMandatory,
495 MakeBoundCallback (&GetCodeRate, uniqueName),
500}
501
503OfdmPhy::GetCodeRate (const std::string& name)
504{
505 return m_ofdmModulationLookupTable.at (name).first;
506}
507
508uint16_t
509OfdmPhy::GetConstellationSize (const std::string& name)
510{
511 return m_ofdmModulationLookupTable.at (name).second;
512}
513
514uint64_t
515OfdmPhy::GetPhyRate (const std::string& name, uint16_t channelWidth)
516{
517 WifiCodeRate codeRate = GetCodeRate (name);
518 uint64_t dataRate = GetDataRate (name, channelWidth);
519 return CalculatePhyRate (codeRate, dataRate);
520}
521
522uint64_t
523OfdmPhy::CalculatePhyRate (WifiCodeRate codeRate, uint64_t dataRate)
524{
525 return (dataRate / GetCodeRatio (codeRate));
526}
527
528uint64_t
529OfdmPhy::GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
530{
531 return GetPhyRate (txVector.GetMode ().GetUniqueName (),
532 txVector.GetChannelWidth ());
533}
534
535double
537{
538 switch (codeRate)
539 {
541 return (3.0 / 4.0);
543 return (2.0 / 3.0);
545 return (1.0 / 2.0);
547 default:
548 NS_FATAL_ERROR ("trying to get code ratio for undefined coding rate");
549 return 0;
550 }
551}
552
553uint64_t
554OfdmPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
555{
556 return GetDataRate (txVector.GetMode ().GetUniqueName (),
557 txVector.GetChannelWidth ());
558}
559
560uint64_t
561OfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth)
562{
563 WifiCodeRate codeRate = GetCodeRate (name);
564 uint16_t constellationSize = GetConstellationSize (name);
565 return CalculateDataRate (codeRate, constellationSize, channelWidth);
566}
567
568uint64_t
569OfdmPhy::CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
570{
571 return CalculateDataRate (GetSymbolDuration (channelWidth),
573 static_cast<uint16_t> (log2 (constellationSize)),
574 GetCodeRatio (codeRate));
575}
576
577uint64_t
578OfdmPhy::CalculateDataRate (Time symbolDuration, uint16_t usableSubCarriers,
579 uint16_t numberOfBitsPerSubcarrier, double codingRate)
580{
581 double symbolRate = (1e9 / static_cast<double> (symbolDuration.GetNanoSeconds ()));
582 return lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
583}
584
585uint16_t
587{
588 return 48;
589}
590
591Time
592OfdmPhy::GetSymbolDuration (uint16_t channelWidth)
593{
594 Time symbolDuration = MicroSeconds (4);
595 uint8_t bwFactor = 1;
596 if (channelWidth == 10)
597 {
598 bwFactor = 2;
599 }
600 else if (channelWidth == 5)
601 {
602 bwFactor = 4;
603 }
604 return bwFactor * symbolDuration;
605}
606
607bool
608OfdmPhy::IsAllowed (const WifiTxVector& /*txVector*/)
609{
610 return true;
611}
612
615{
616 return 4095;
617}
618
619uint16_t
621{
622 if (ppdu == nullptr)
623 {
624 return 20;
625 }
626 return GetRxChannelWidth (ppdu->GetTxVector ());
627}
628
629double
631{
632 if (ppdu != nullptr && ppdu->GetTxVector ().GetChannelWidth () < 20)
633 {
634 //scale CCA sensitivity threshold for BW of 5 and 10 MHz
635 uint16_t bw = GetRxChannelWidth (ppdu->GetTxVector ());
636 double thresholdW = DbmToW (m_wifiPhy->GetCcaSensitivityThreshold ()) * (bw / 20.0);
637 return WToDbm (thresholdW);
638 }
639 return PhyEntity::GetCcaThreshold (ppdu, channelType);
640}
641
642} //namespace ns3
643
644namespace {
645
649static class ConstructorOfdm
650{
651public:
653 {
655 ns3::WifiPhy::AddStaticPhyEntity (ns3::WIFI_MOD_CLASS_OFDM, ns3::Create<ns3::OfdmPhy> ()); //default variant will do
656 }
658
659}
Constructor class for OFDM modes.
Definition: ofdm-phy.cc:650
static WifiMode GetOfdmRate2_25MbpsBW5MHz(void)
Return a WifiMode for OFDM at 2.25 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate3MbpsBW10MHz(void)
Return a WifiMode for OFDM at 3 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate48Mbps(void)
Return a WifiMode for OFDM at 48 Mbps.
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
static const PpduFormats m_ofdmPpduFormats
OFDM PPDU formats.
Definition: ofdm-phy.h:439
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:509
static WifiMode GetOfdmRate27MbpsBW10MHz(void)
Return a WifiMode for OFDM at 27 Mbps with 10 MHz channel spacing.
uint8_t GetNumberServiceBits(void) const
Definition: ofdm-phy.cc:263
static WifiCodeRate GetCodeRate(const std::string &name)
Return the WifiCodeRate from the OFDM mode's unique name using ModulationLookupTable.
Definition: ofdm-phy.cc:503
double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold in dBm for a given channel type.
Definition: ofdm-phy.cc:630
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ofdm-phy.cc:529
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
Calculates data rate from the supplied parameters.
Definition: ofdm-phy.cc:569
static WifiMode GetOfdmRate9Mbps(void)
Return a WifiMode for OFDM at 9 Mbps.
static WifiMode GetOfdmRate36Mbps(void)
Return a WifiMode for OFDM at 36 Mbps.
static WifiMode GetOfdmRate9MbpsBW5MHz(void)
Return a WifiMode for OFDM at 9 Mbps with 5 MHz channel spacing.
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:331
static WifiMode GetOfdmRate1_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 1.5 Mbps with 5 MHz channel spacing.
static uint16_t GetUsableSubcarriers(void)
Definition: ofdm-phy.cc:586
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform OFDM-specific actions, and provide the status of the reception.
Definition: ofdm-phy.cc:295
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: ofdm-phy.cc:608
OfdmPhy(OfdmPhyVariant variant=OFDM_PHY_DEFAULT, bool buildModeList=true)
Constructor for OFDM PHY.
Definition: ofdm-phy.cc:101
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ofdm-phy.cc:554
static WifiMode GetOfdmRate4_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 4.5 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate6MbpsBW10MHz(void)
Return a WifiMode for OFDM at 6 Mbps with 10 MHz channel spacing.
static Time GetSymbolDuration(uint16_t channelWidth)
Definition: ofdm-phy.cc:592
static uint64_t GetPhyRate(const std::string &name, uint16_t channelWidth)
Return the PHY rate from the OFDM mode's unique name and the supplied parameters.
Definition: ofdm-phy.cc:515
static WifiMode GetOfdmRate4_5MbpsBW10MHz(void)
Return a WifiMode for OFDM at 4.5 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate18MbpsBW10MHz(void)
Return a WifiMode for OFDM at 18 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate24MbpsBW10MHz(void)
Return a WifiMode for OFDM at 24 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate12Mbps(void)
Return a WifiMode for OFDM at 12Mbps.
virtual Time GetPreambleDuration(const WifiTxVector &txVector) const
Definition: ofdm-phy.cc:199
static WifiMode GetOfdmRate13_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 13.5 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate(uint64_t rate, uint16_t bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
Definition: ofdm-phy.cc:366
static WifiMode GetOfdmRate9MbpsBW10MHz(void)
Return a WifiMode for OFDM at 9 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate18Mbps(void)
Return a WifiMode for OFDM at 18 Mbps.
static WifiMode GetOfdmRate12MbpsBW10MHz(void)
Return a WifiMode for OFDM at 12 Mbps with 10 MHz channel spacing.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ofdm-phy.cc:275
static WifiMode GetOfdmRate6MbpsBW5MHz(void)
Return a WifiMode for OFDM at 6 Mbps with 5 MHz channel spacing.
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:486
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const override
Return the channel width used to measure the RSSI.
Definition: ofdm-phy.cc:620
static WifiMode GetOfdmRate54Mbps(void)
Return a WifiMode for OFDM at 54 Mbps.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ofdm-phy.cc:341
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:523
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ofdm-phy.cc:614
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:185
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:284
virtual Time GetHeaderDuration(const WifiTxVector &txVector) const
Definition: ofdm-phy.cc:220
virtual WifiMode GetHeaderMode(const WifiTxVector &txVector) const
Definition: ofdm-phy.cc:160
static void InitializeModes(void)
Initialize all OFDM modes (for all variants).
Definition: ofdm-phy.cc:354
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:147
static WifiMode GetOfdmRate24Mbps(void)
Return a WifiMode for OFDM at 24 Mbps.
virtual ~OfdmPhy()
Destructor for OFDM PHY.
Definition: ofdm-phy.cc:141
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:441
static uint64_t GetDataRate(const std::string &name, uint16_t channelWidth)
Return the data rate from the OFDM mode's unique name and the supplied parameters.
Definition: ofdm-phy.cc:561
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: ofdm-phy.cc:179
virtual bool IsChannelWidthSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the PPDU's bandwidth is supported by the PHY.
Definition: ofdm-phy.cc:319
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:536
Time GetSignalExtension(WifiPhyBand band) const
Definition: ofdm-phy.cc:269
static WifiMode GetOfdmRate3MbpsBW5MHz(void)
Return a WifiMode for OFDM at 3 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate12MbpsBW5MHz(void)
Return a WifiMode for OFDM at 12 Mbps with 5 MHz channel spacing.
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:243
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...
Definition: phy-entity.cc:178
virtual uint64_t ObtainNextUid(const WifiTxVector &txVector)
Obtain the next UID for the PPDU to transmit.
Definition: phy-entity.cc:1106
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
Definition: phy-entity.h:874
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition: phy-entity.h:490
virtual double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const
Return the CCA threshold in dBm for a given channel type.
Definition: phy-entity.cc:1060
double GetRandomValue(void) const
Obtain a random value from the WifiPhy's generator.
Definition: phy-entity.cc:1019
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
Definition: phy-entity.cc:1159
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:480
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
Definition: phy-entity.cc:142
virtual uint16_t GetRxChannelWidth(const WifiTxVector &txVector) const
Return the channel width used in the reception spectrum model.
Definition: phy-entity.cc:1054
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
Definition: phy-entity.cc:1153
std::list< WifiMode > m_modeList
the list of supported modes
Definition: phy-entity.h:877
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
Definition: phy-entity.cc:253
uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector &txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
Definition: phy-entity.cc:1113
virtual bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: phy-entity.cc:920
@ DROP
drop PPDU and set CCA_BUSY
Definition: phy-entity.h:104
@ ABORT
abort reception of PPDU
Definition: phy-entity.h:105
virtual PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Definition: phy-entity.cc:353
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:400
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:392
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:260
represent a single transmission mode
Definition: wifi-mode.h:48
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:140
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:945
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:932
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:686
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:963
double GetCcaSensitivityThreshold(void) const
Return the CCA sensitivity threshold (dBm).
Definition: wifi-phy.cc:468
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-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.
uint16_t GetChannelWidth(void) const
#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:88
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1709
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1261
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1285
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
OfdmPhyVariant
The OFDM (11a) PHY variants.
Definition: ofdm-phy.h:44
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.
@ UNSUPPORTED_SETTINGS
@ L_SIG_FAILURE
@ WIFI_PREAMBLE_LONG
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ OFDM_PHY_10_MHZ
Definition: ofdm-phy.h:46
@ OFDM_PHY_DEFAULT
Definition: ofdm-phy.h:45
@ OFDM_PHY_5_MHZ
Definition: ofdm-phy.h:47
@ 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
static 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.
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:49
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:43
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
const std::map< uint16_t, std::array< uint64_t, 8 > > s_ofdmRatesBpsList
OFDM rates in bits per second for each bandwidth (MHz)
Definition: ofdm-phy.cc:77
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:37
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
const std::map< uint16_t, std::array< uint64_t, 8 > > & GetOfdmRatesBpsList(void)
Get the array of possible OFDM rates for each bandwidth (MHz).
Definition: ofdm-phy.cc:95
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
#define GET_OFDM_MODE(x, f)
Definition: ofdm-phy.cc:448
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:113
WifiPhyRxfailureReason reason
failure reason
Definition: phy-entity.h:116
PhyRxFailureAction actionIfFailure
action to perform in case of failure
Definition: phy-entity.h:117
bool isSuccess
outcome (true if success) of the reception
Definition: phy-entity.h:115
A struct for both SNR and PER.
Definition: phy-entity.h:139
double snr
SNR in linear scale.
Definition: phy-entity.h:140