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 
33 namespace ns3 {
34 
35 NS_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 
77 const 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 
95 const std::map<uint16_t, std::array<uint64_t, 8> >& GetOfdmRatesBpsList (void)
96 {
97  return s_ofdmRatesBpsList;
98 };
99 
100 
101 OfdmPhy::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 
146 WifiMode
147 OfdmPhy::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 
159 WifiMode
160 OfdmPhy::GetHeaderMode (const WifiTxVector& txVector) const
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 
184 Time
185 OfdmPhy::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 
198 Time
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 
219 Time
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 
242 Time
243 OfdmPhy::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 
262 uint8_t
264 {
265  return 16;
266 }
267 
268 Time
270 {
271  return (band == WIFI_PHY_BAND_2_4GHZ) ? MicroSeconds (6) : MicroSeconds (0);
272 }
273 
275 OfdmPhy::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, m_wifiPhy->GetPhyBand (),
279  ObtainNextUid (txVector));
280 }
281 
284 {
285  NS_LOG_FUNCTION (this << field << *event);
286  if (field == WIFI_PPDU_FIELD_NON_HT_HEADER)
287  {
288  return EndReceiveHeader (event); //L-SIG
289  }
290  return PhyEntity::DoEndReceiveField (field, event);
291 }
292 
295 {
296  NS_LOG_FUNCTION (this << *event);
298  NS_LOG_DEBUG ("L-SIG: SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
299  PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
300  if (status.isSuccess)
301  {
302  NS_LOG_DEBUG ("Received non-HT PHY header");
303  if (!IsAllConfigSupported (WIFI_PPDU_FIELD_NON_HT_HEADER, event->GetPpdu ()))
304  {
305  status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
306  }
307  }
308  else
309  {
310  NS_LOG_DEBUG ("Abort reception because non-HT PHY header reception failed");
311  status.reason = L_SIG_FAILURE;
312  status.actionIfFailure = ABORT;
313  }
314  return status;
315 }
316 
317 bool
319 {
320  uint16_t channelWidth = ppdu->GetTxVector ().GetChannelWidth ();
321  if ((channelWidth >= 40) && (channelWidth > m_wifiPhy->GetChannelWidth ()))
322  {
323  NS_LOG_DEBUG ("Packet reception could not be started because not enough channel width (" << channelWidth << " vs " << m_wifiPhy->GetChannelWidth () << ")");
324  return false;
325  }
326  return true;
327 }
328 
329 bool
331 {
332  if (!IsChannelWidthSupported (ppdu))
333  {
334  return false;
335  }
336  return IsConfigSupported (ppdu);
337 }
338 
341 {
342  const WifiTxVector& txVector = ppdu->GetTxVector ();
343  uint16_t centerFrequency = GetCenterFrequencyForChannelWidth (txVector);
344  uint16_t channelWidth = txVector.GetChannelWidth ();
345  NS_LOG_FUNCTION (this << centerFrequency << channelWidth << txPowerW);
346  const auto & txMaskRejectionParams = GetTxMaskRejectionParams ();
347  Ptr<SpectrumValue> v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
348  std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
349  return v;
350 }
351 
352 void
354 {
355  for (const auto & ratesPerBw : GetOfdmRatesBpsList ())
356  {
357  for (const auto & rate : ratesPerBw.second)
358  {
359  GetOfdmRate (rate, ratesPerBw.first);
360  }
361  }
362 }
363 
364 WifiMode
365 OfdmPhy::GetOfdmRate (uint64_t rate, uint16_t bw)
366 {
367  switch (bw)
368  {
369  case 20:
370  switch (rate)
371  {
372  case 6000000:
373  return GetOfdmRate6Mbps ();
374  case 9000000:
375  return GetOfdmRate9Mbps ();
376  case 12000000:
377  return GetOfdmRate12Mbps ();
378  case 18000000:
379  return GetOfdmRate18Mbps ();
380  case 24000000:
381  return GetOfdmRate24Mbps ();
382  case 36000000:
383  return GetOfdmRate36Mbps ();
384  case 48000000:
385  return GetOfdmRate48Mbps ();
386  case 54000000:
387  return GetOfdmRate54Mbps ();
388  default:
389  NS_ABORT_MSG ("Inexistent rate (" << rate << " bps) requested for 11a OFDM (default)");
390  return WifiMode ();
391  }
392  break;
393  case 10:
394  switch (rate)
395  {
396  case 3000000:
397  return GetOfdmRate3MbpsBW10MHz ();
398  case 4500000:
399  return GetOfdmRate4_5MbpsBW10MHz ();
400  case 6000000:
401  return GetOfdmRate6MbpsBW10MHz ();
402  case 9000000:
403  return GetOfdmRate9MbpsBW10MHz ();
404  case 12000000:
405  return GetOfdmRate12MbpsBW10MHz ();
406  case 18000000:
407  return GetOfdmRate18MbpsBW10MHz ();
408  case 24000000:
409  return GetOfdmRate24MbpsBW10MHz ();
410  case 27000000:
411  return GetOfdmRate27MbpsBW10MHz ();
412  default:
413  NS_ABORT_MSG ("Inexistent rate (" << rate << " bps) requested for 11a OFDM (10 MHz)");
414  return WifiMode ();
415  }
416  break;
417  case 5:
418  switch (rate)
419  {
420  case 1500000:
421  return GetOfdmRate1_5MbpsBW5MHz ();
422  case 2250000:
423  return GetOfdmRate2_25MbpsBW5MHz ();
424  case 3000000:
425  return GetOfdmRate3MbpsBW5MHz ();
426  case 4500000:
427  return GetOfdmRate4_5MbpsBW5MHz ();
428  case 6000000:
429  return GetOfdmRate6MbpsBW5MHz ();
430  case 9000000:
431  return GetOfdmRate9MbpsBW5MHz ();
432  case 12000000:
433  return GetOfdmRate12MbpsBW5MHz ();
434  case 13500000:
435  return GetOfdmRate13_5MbpsBW5MHz ();
436  default:
437  NS_ABORT_MSG ("Inexistent rate (" << rate << " bps) requested for 11a OFDM (5 MHz)");
438  return WifiMode ();
439  }
440  break;
441  default:
442  NS_ABORT_MSG ("Inexistent bandwidth (" << +bw << " MHz) requested for 11a OFDM");
443  return WifiMode ();
444  }
445 }
446 
447 #define GET_OFDM_MODE(x, f) \
448 WifiMode \
449 OfdmPhy::Get ## x (void) \
450 { \
451  static WifiMode mode = CreateOfdmMode (#x, f); \
452  return mode; \
453 }; \
454 
455 // 20 MHz channel rates (default)
456 GET_OFDM_MODE (OfdmRate6Mbps, true)
457 GET_OFDM_MODE (OfdmRate9Mbps, false)
458 GET_OFDM_MODE (OfdmRate12Mbps, true)
459 GET_OFDM_MODE (OfdmRate18Mbps, false)
460 GET_OFDM_MODE (OfdmRate24Mbps, true)
461 GET_OFDM_MODE (OfdmRate36Mbps, false)
462 GET_OFDM_MODE (OfdmRate48Mbps, false)
463 GET_OFDM_MODE (OfdmRate54Mbps, false)
464 // 10 MHz channel rates
465 GET_OFDM_MODE (OfdmRate3MbpsBW10MHz, true)
466 GET_OFDM_MODE (OfdmRate4_5MbpsBW10MHz, false)
467 GET_OFDM_MODE (OfdmRate6MbpsBW10MHz, true)
468 GET_OFDM_MODE (OfdmRate9MbpsBW10MHz, false)
469 GET_OFDM_MODE (OfdmRate12MbpsBW10MHz, true)
470 GET_OFDM_MODE (OfdmRate18MbpsBW10MHz, false)
471 GET_OFDM_MODE (OfdmRate24MbpsBW10MHz, false)
472 GET_OFDM_MODE (OfdmRate27MbpsBW10MHz, false)
473 // 5 MHz channel rates
474 GET_OFDM_MODE (OfdmRate1_5MbpsBW5MHz, true)
475 GET_OFDM_MODE (OfdmRate2_25MbpsBW5MHz, false)
476 GET_OFDM_MODE (OfdmRate3MbpsBW5MHz, true)
477 GET_OFDM_MODE (OfdmRate4_5MbpsBW5MHz, false)
478 GET_OFDM_MODE (OfdmRate6MbpsBW5MHz, true)
479 GET_OFDM_MODE (OfdmRate9MbpsBW5MHz, false)
480 GET_OFDM_MODE (OfdmRate12MbpsBW5MHz, false)
481 GET_OFDM_MODE (OfdmRate13_5MbpsBW5MHz, false)
482 #undef GET_OFDM_MODE
483 
484 WifiMode
485 OfdmPhy::CreateOfdmMode (std::string uniqueName, bool isMandatory)
486 {
487  // Check whether uniqueName is in lookup table
488  const auto it = m_ofdmModulationLookupTable.find (uniqueName);
489  NS_ASSERT_MSG (it != m_ofdmModulationLookupTable.end (), "OFDM mode cannot be created because it is not in the lookup table!");
490 
491  return WifiModeFactory::CreateWifiMode (uniqueName,
493  isMandatory,
494  MakeBoundCallback (&GetCodeRate, uniqueName),
499 }
500 
502 OfdmPhy::GetCodeRate (const std::string& name)
503 {
504  return m_ofdmModulationLookupTable.at (name).first;
505 }
506 
507 uint16_t
508 OfdmPhy::GetConstellationSize (const std::string& name)
509 {
510  return m_ofdmModulationLookupTable.at (name).second;
511 }
512 
513 uint64_t
514 OfdmPhy::GetPhyRate (const std::string& name, uint16_t channelWidth)
515 {
516  WifiCodeRate codeRate = GetCodeRate (name);
517  uint64_t dataRate = GetDataRate (name, channelWidth);
518  return CalculatePhyRate (codeRate, dataRate);
519 }
520 
521 uint64_t
522 OfdmPhy::CalculatePhyRate (WifiCodeRate codeRate, uint64_t dataRate)
523 {
524  return (dataRate / GetCodeRatio (codeRate));
525 }
526 
527 uint64_t
528 OfdmPhy::GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
529 {
530  return GetPhyRate (txVector.GetMode ().GetUniqueName (),
531  txVector.GetChannelWidth ());
532 }
533 
534 double
536 {
537  switch (codeRate)
538  {
539  case WIFI_CODE_RATE_3_4:
540  return (3.0 / 4.0);
541  case WIFI_CODE_RATE_2_3:
542  return (2.0 / 3.0);
543  case WIFI_CODE_RATE_1_2:
544  return (1.0 / 2.0);
546  default:
547  NS_FATAL_ERROR ("trying to get code ratio for undefined coding rate");
548  return 0;
549  }
550 }
551 
552 uint64_t
553 OfdmPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
554 {
555  return GetDataRate (txVector.GetMode ().GetUniqueName (),
556  txVector.GetChannelWidth ());
557 }
558 
559 uint64_t
560 OfdmPhy::GetDataRate (const std::string& name, uint16_t channelWidth)
561 {
562  WifiCodeRate codeRate = GetCodeRate (name);
563  uint16_t constellationSize = GetConstellationSize (name);
564  return CalculateDataRate (codeRate, constellationSize, channelWidth);
565 }
566 
567 uint64_t
568 OfdmPhy::CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
569 {
570  double symbolDuration = 3.2; //in us
571  uint16_t guardInterval = 800; //in ns
572  if (channelWidth == 10)
573  {
574  symbolDuration = 6.4;
575  guardInterval = 1600;
576  }
577  else if (channelWidth == 5)
578  {
579  symbolDuration = 12.8;
580  guardInterval = 3200;
581  }
582  return CalculateDataRate (symbolDuration, guardInterval,
583  48, static_cast<uint16_t> (log2 (constellationSize)),
584  GetCodeRatio (codeRate));
585 }
586 
587 uint64_t
588 OfdmPhy::CalculateDataRate (double symbolDuration, uint16_t guardInterval,
589  uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
590  double codingRate)
591 {
592  double symbolRate = (1 / (symbolDuration + (static_cast<double> (guardInterval) / 1000))) * 1e6;
593  return lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
594 }
595 
596 bool
597 OfdmPhy::IsAllowed (const WifiTxVector& /*txVector*/)
598 {
599  return true;
600 }
601 
602 uint32_t
604 {
605  return 4095;
606 }
607 
608 } //namespace ns3
609 
610 namespace {
611 
615 static class ConstructorOfdm
616 {
617 public:
619  {
621  ns3::WifiPhy::AddStaticPhyEntity (ns3::WIFI_MOD_CLASS_OFDM, ns3::Create<ns3::OfdmPhy> ()); //default variant will do
622  }
624 
625 }
Constructor class for OFDM modes.
Definition: ofdm-phy.cc:616
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:427
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:508
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:502
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ofdm-phy.cc:528
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
Calculates data rate from the supplied parameters.
Definition: ofdm-phy.cc:568
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:330
static WifiMode GetOfdmRate1_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 1.5 Mbps with 5 MHz channel spacing.
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform OFDM-specific actions, and provide the status of the reception.
Definition: ofdm-phy.cc:294
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: ofdm-phy.cc:597
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:553
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 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:514
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:365
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:485
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:340
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:522
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ofdm-phy.cc:603
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:283
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:353
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:429
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:560
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:318
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:535
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:1027
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
Definition: phy-entity.h:791
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition: phy-entity.h:487
double GetRandomValue(void) const
Obtain a random value from the WifiPhy's generator.
Definition: phy-entity.cc:997
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
Definition: phy-entity.cc:1080
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:477
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
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
Definition: phy-entity.cc:1074
std::list< WifiMode > m_modeList
the list of supported modes
Definition: phy-entity.h:794
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:252
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:1034
virtual bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: phy-entity.cc:902
@ DROP
drop PPDU and set CCA_BUSY
Definition: phy-entity.h:102
@ ABORT
abort reception of PPDU
Definition: phy-entity.h:103
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:352
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:399
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:391
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
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:887
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:652
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:918
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:1260
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1284
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
OfdmPhyVariant
The OFDM (11a) PHY variants.
Definition: ofdm-phy.h:44
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.
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
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
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...
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:447
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:111
WifiPhyRxfailureReason reason
failure reason
Definition: phy-entity.h:114
PhyRxFailureAction actionIfFailure
action to perform in case of failure
Definition: phy-entity.h:115
bool isSuccess
outcome (true if success) of the reception
Definition: phy-entity.h:113
A struct for both SNR and PER.
Definition: phy-entity.h:137
double snr
SNR in linear scale.
Definition: phy-entity.h:138