A Discrete-Event Network Simulator
API
ht-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  */
21 
22 #include "ht-phy.h"
23 #include "ht-ppdu.h"
24 #include "ns3/wifi-psdu.h"
25 #include "ns3/wifi-phy.h"
26 #include "ns3/wifi-utils.h"
27 #include "ns3/interference-helper.h"
28 #include "ns3/log.h"
29 #include "ns3/assert.h"
30 
31 namespace ns3 {
32 
33 NS_LOG_COMPONENT_DEFINE ("HtPhy");
34 
35 /*******************************************************
36  * HT PHY (IEEE 802.11-2016, clause 19)
37  *******************************************************/
38 
39 /* *NS_CHECK_STYLE_OFF* */
41  { WIFI_PREAMBLE_HT_MF, { WIFI_PPDU_FIELD_PREAMBLE, //L-STF + L-LTF
43  WIFI_PPDU_FIELD_HT_SIG, //HT-SIG
44  WIFI_PPDU_FIELD_TRAINING, //HT-STF + HT-LTFs
46 };
47 /* *NS_CHECK_STYLE_ON* */
48 
49 HtPhy::HtPhy (uint8_t maxNss /* = 1 */, bool buildModeList /* = true */)
50  : OfdmPhy (OFDM_PHY_DEFAULT, false) //don't add OFDM modes to list
51 {
52  NS_LOG_FUNCTION (this << +maxNss << buildModeList);
53  m_maxSupportedNss = maxNss;
57  if (buildModeList)
58  {
59  NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4, "Unsupported max Nss " << +maxNss << " for HT PHY");
60  BuildModeList ();
61  }
62 }
63 
65 {
66  NS_LOG_FUNCTION (this);
67 }
68 
69 void
71 {
72  NS_LOG_FUNCTION (this);
73  NS_ASSERT (m_modeList.empty ());
75 
76  uint8_t index = 0;
77  for (uint8_t nss = 1; nss <= m_maxSupportedNss; ++nss)
78  {
79  for (uint8_t i = 0; i <= m_maxSupportedMcsIndexPerSs; ++i)
80  {
81  NS_LOG_LOGIC ("Add HtMcs" << +index << " to list");
82  m_modeList.emplace_back (CreateHtMcs (index));
83  ++index;
84  }
85  index = 8 * nss;
86  }
87 }
88 
90 HtPhy::GetMcs (uint8_t index) const
91 {
92  for (const auto & mcs : m_modeList)
93  {
94  if (mcs.GetMcsValue () == index)
95  {
96  return mcs;
97  }
98  }
99 
100  // Should have returned if MCS found
101  NS_ABORT_MSG ("Unsupported MCS index " << +index << " for this PHY entity");
102  return WifiMode ();
103 }
104 
105 bool
106 HtPhy::IsMcsSupported (uint8_t index) const
107 {
108  for (const auto & mcs : m_modeList)
109  {
110  if (mcs.GetMcsValue () == index)
111  {
112  return true;
113  }
114  }
115  return false;
116 }
117 
118 bool
120 {
121  return true;
122 }
123 
126 {
127  return m_htPpduFormats;
128 }
129 
130 WifiMode
131 HtPhy::GetSigMode (WifiPpduField field, const WifiTxVector& txVector) const
132 {
133  switch (field)
134  {
135  case WIFI_PPDU_FIELD_PREAMBLE: //consider non-HT header mode for preamble (useful for InterferenceHelper)
137  return GetLSigMode ();
138  case WIFI_PPDU_FIELD_TRAINING: //consider HT-SIG mode for training (useful for InterferenceHelper)
140  return GetHtSigMode ();
141  default:
142  return PhyEntity::GetSigMode (field, txVector);
143  }
144 }
145 
146 WifiMode
148 {
149  return GetOfdmRate6Mbps ();
150 }
151 
152 WifiMode
154 {
155  return GetLSigMode (); //same number of data tones as OFDM (i.e. 48)
156 }
157 
158 uint8_t
160 {
162 }
163 
164 void
166 {
167  NS_LOG_FUNCTION (this << +maxIndex);
168  NS_ABORT_MSG_IF (maxIndex > m_maxMcsIndexPerSs, "Provided max MCS index " << +maxIndex << " per SS greater than max standard-defined value " << +m_maxMcsIndexPerSs);
169  if (maxIndex != m_maxSupportedMcsIndexPerSs)
170  {
171  NS_LOG_LOGIC ("Rebuild mode list since max MCS index per spatial stream has changed");
172  m_maxSupportedMcsIndexPerSs = maxIndex;
173  m_modeList.clear ();
174  BuildModeList ();
175  }
176 }
177 
178 uint8_t
180 {
182 }
183 
184 void
186 {
187  NS_LOG_FUNCTION (this << +maxNss);
189  NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4, "Unsupported max Nss " << +maxNss << " for HT PHY");
190  if (maxNss != m_maxSupportedNss)
191  {
192  NS_LOG_LOGIC ("Rebuild mode list since max number of spatial streams has changed");
193  m_maxSupportedNss = maxNss;
194  m_modeList.clear ();
195  BuildModeList ();
196  }
197 }
198 
199 Time
200 HtPhy::GetDuration (WifiPpduField field, const WifiTxVector& txVector) const
201 {
202  switch (field)
203  {
205  return MicroSeconds (16); //L-STF + L-LTF or HT-GF-STF + HT-LTF1
207  return GetLSigDuration (txVector.GetPreambleType ());
209  {
210  //We suppose here that STBC = 0.
211  //If STBC > 0, we need a different mapping between Nss and Nltf
212  // (see IEEE 802.11-2016 , section 19.3.9.4.6 "HT-LTF definition").
213  uint8_t nDataLtf = 8;
214  uint8_t nss = txVector.GetNssMax (); //so as to cover also HE MU case (see section 27.3.10.10 of IEEE P802.11ax/D4.0)
215  if (nss < 3)
216  {
217  nDataLtf = nss;
218  }
219  else if (nss < 5)
220  {
221  nDataLtf = 4;
222  }
223  else if (nss < 7)
224  {
225  nDataLtf = 6;
226  }
227 
228  uint8_t nExtensionLtf = (txVector.GetNess () < 3) ? txVector.GetNess () : 4;
229 
230  return GetTrainingDuration (txVector, nDataLtf, nExtensionLtf);
231  }
233  return GetHtSigDuration ();
234  default:
235  return PhyEntity::GetDuration (field, txVector);
236  }
237 }
238 
239 Time
241 {
242  return MicroSeconds (4);
243 }
244 
245 Time
247  uint8_t nDataLtf, uint8_t nExtensionLtf /* = 0 */) const
248 {
249  NS_ABORT_MSG_IF (nDataLtf == 0 || nDataLtf > 4 || nExtensionLtf > 4 || (nDataLtf + nExtensionLtf) > 5,
250  "Unsupported combination of data (" << +nDataLtf << ") and extension (" << +nExtensionLtf << ") LTFs numbers for HT"); //see IEEE 802.11-2016, section 19.3.9.4.6 "HT-LTF definition"
251  Time duration = MicroSeconds (4) * (nDataLtf + nExtensionLtf);
252  return MicroSeconds (4) * (1 /* HT-STF */ + nDataLtf + nExtensionLtf);
253 }
254 
255 Time
257 {
258  return MicroSeconds (8); //HT-SIG
259 }
260 
261 Time
262 HtPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype,
263  bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
264  uint16_t staId) const
265 {
266  WifiMode payloadMode = txVector.GetMode (staId);
267  uint8_t stbc = txVector.IsStbc () ? 2 : 1; //corresponding to m_STBC in Nsym computation (see IEEE 802.11-2016, equations (19-32) and (21-62))
268  uint8_t nes = GetNumberBccEncoders (txVector);
269  //TODO: Update station managers to consider GI capabilities
270  Time symbolDuration = GetSymbolDuration (txVector);
271 
272  double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector, staId) * symbolDuration.GetNanoSeconds () / 1e9;
273  uint8_t service = GetNumberServiceBits ();
274 
275  double numSymbols = 0;
276  switch (mpdutype)
277  {
279  {
280  //First packet in an A-MPDU
281  numSymbols = (stbc * (service + size * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol));
282  if (incFlag == 1)
283  {
284  totalAmpduSize += size;
285  totalAmpduNumSymbols += numSymbols;
286  }
287  break;
288  }
290  {
291  //consecutive packets in an A-MPDU
292  numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
293  if (incFlag == 1)
294  {
295  totalAmpduSize += size;
296  totalAmpduNumSymbols += numSymbols;
297  }
298  break;
299  }
301  {
302  //last packet in an A-MPDU
303  uint32_t totalSize = totalAmpduSize + size;
304  numSymbols = lrint (stbc * ceil ((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)));
305  NS_ASSERT (totalAmpduNumSymbols <= numSymbols);
306  numSymbols -= totalAmpduNumSymbols;
307  if (incFlag == 1)
308  {
309  totalAmpduSize = 0;
310  totalAmpduNumSymbols = 0;
311  }
312  break;
313  }
314  case NORMAL_MPDU:
315  case SINGLE_MPDU:
316  {
317  //Not an A-MPDU or single MPDU (i.e. the current payload contains both service and padding)
318  //The number of OFDM symbols in the data field when BCC encoding
319  //is used is given in equation 19-32 of the IEEE 802.11-2016 standard.
320  numSymbols = lrint (stbc * ceil ((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)));
321  break;
322  }
323  default:
324  NS_FATAL_ERROR ("Unknown MPDU type");
325  }
326 
327  Time payloadDuration = FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
328  if (mpdutype == NORMAL_MPDU || mpdutype == SINGLE_MPDU || mpdutype == LAST_MPDU_IN_AGGREGATE)
329  {
330  payloadDuration += GetSignalExtension (band);
331  }
332  return payloadDuration;
333 }
334 
335 uint8_t
337 {
345  double maxRatePerCoder = (txVector.GetGuardInterval () == 800) ? 320e6 : 350e6;
346  return ceil (txVector.GetMode ().GetDataRate (txVector) / maxRatePerCoder);
347 }
348 
349 Time
350 HtPhy::GetSymbolDuration (const WifiTxVector& txVector) const
351 {
352  uint16_t gi = txVector.GetGuardInterval ();
353  NS_ASSERT (gi == 400 || gi == 800);
354  return NanoSeconds (3200 + gi);
355 }
356 
358 HtPhy::BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration)
359 {
360  NS_LOG_FUNCTION (this << psdus << txVector << ppduDuration);
361  return Create<HtPpdu> (psdus.begin ()->second, txVector, ppduDuration, m_wifiPhy->GetPhyBand (),
362  ObtainNextUid (txVector));
363 }
364 
367 {
368  NS_LOG_FUNCTION (this << field << *event);
369  switch (field)
370  {
372  return EndReceiveHtSig (event);
374  return PhyFieldRxStatus (true); //always consider that training has been correctly received
376  //no break so as to go to OfdmPhy for processing
377  default:
378  return OfdmPhy::DoEndReceiveField (field, event);
379  }
380 }
381 
384 {
385  NS_LOG_FUNCTION (this << *event);
386  NS_ASSERT (event->GetTxVector ().GetPreambleType () == WIFI_PREAMBLE_HT_MF);
388  NS_LOG_DEBUG ("HT-SIG: SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
389  PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
390  if (status.isSuccess)
391  {
392  NS_LOG_DEBUG ("Received HT-SIG");
393  if (!IsAllConfigSupported (WIFI_PPDU_FIELD_HT_SIG, event->GetPpdu ()))
394  {
395  status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
396  }
397  }
398  else
399  {
400  NS_LOG_DEBUG ("Drop packet because HT-SIG reception failed");
401  status.reason = HT_SIG_FAILURE;
402  status.actionIfFailure = DROP;
403  }
404  return status;
405 }
406 
407 bool
409 {
410  if (field == WIFI_PPDU_FIELD_NON_HT_HEADER)
411  {
412  return true; //wait till reception of HT-SIG (or SIG-A) to make decision
413  }
414  return OfdmPhy::IsAllConfigSupported (field, ppdu);
415 }
416 
417 bool
419 {
420  const WifiTxVector& txVector = ppdu->GetTxVector ();
421  if (txVector.GetNss () > m_wifiPhy->GetMaxSupportedRxSpatialStreams ())
422  {
423  NS_LOG_DEBUG ("Packet reception could not be started because not enough RX antennas");
424  return false;
425  }
426  if (!IsModeSupported (txVector.GetMode ()))
427  {
428  NS_LOG_DEBUG ("Drop packet because it was sent using an unsupported mode (" << txVector.GetMode () << ")");
429  return false;
430  }
431  return true;
432 }
433 
436 {
437  const WifiTxVector& txVector = ppdu->GetTxVector ();
438  uint16_t centerFrequency = GetCenterFrequencyForChannelWidth (txVector);
439  uint16_t channelWidth = txVector.GetChannelWidth ();
440  NS_LOG_FUNCTION (this << centerFrequency << channelWidth << txPowerW);
441  const auto & txMaskRejectionParams = GetTxMaskRejectionParams ();
442  Ptr<SpectrumValue> v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
443  std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
444  return v;
445 }
446 
447 void
449 {
450  for (uint8_t i = 0; i < 32; ++i)
451  {
452  GetHtMcs (i);
453  }
454 }
455 
456 WifiMode
457 HtPhy::GetHtMcs (uint8_t index)
458 {
459 #define CASE(x) \
460 case x: \
461  return GetHtMcs ## x (); \
462 
463  switch (index)
464  {
465  CASE ( 0)
466  CASE ( 1)
467  CASE ( 2)
468  CASE ( 3)
469  CASE ( 4)
470  CASE ( 5)
471  CASE ( 6)
472  CASE ( 7)
473  CASE ( 8)
474  CASE ( 9)
475  CASE (10)
476  CASE (11)
477  CASE (12)
478  CASE (13)
479  CASE (14)
480  CASE (15)
481  CASE (16)
482  CASE (17)
483  CASE (18)
484  CASE (19)
485  CASE (20)
486  CASE (21)
487  CASE (22)
488  CASE (23)
489  CASE (24)
490  CASE (25)
491  CASE (26)
492  CASE (27)
493  CASE (28)
494  CASE (29)
495  CASE (30)
496  CASE (31)
497  default:
498  NS_ABORT_MSG ("Inexistent (or not supported) index (" << +index << ") requested for HT");
499  return WifiMode ();
500  }
501 #undef CASE
502 }
503 
504 #define GET_HT_MCS(x) \
505 WifiMode \
506 HtPhy::GetHtMcs ## x (void) \
507 { \
508  static WifiMode mcs = CreateHtMcs (x); \
509  return mcs; \
510 }; \
511 
512 GET_HT_MCS (0)
513 GET_HT_MCS (1)
514 GET_HT_MCS (2)
515 GET_HT_MCS (3)
516 GET_HT_MCS (4)
517 GET_HT_MCS (5)
518 GET_HT_MCS (6)
519 GET_HT_MCS (7)
520 GET_HT_MCS (8)
521 GET_HT_MCS (9)
522 GET_HT_MCS (10)
523 GET_HT_MCS (11)
524 GET_HT_MCS (12)
525 GET_HT_MCS (13)
526 GET_HT_MCS (14)
527 GET_HT_MCS (15)
528 GET_HT_MCS (16)
529 GET_HT_MCS (17)
530 GET_HT_MCS (18)
531 GET_HT_MCS (19)
532 GET_HT_MCS (20)
533 GET_HT_MCS (21)
534 GET_HT_MCS (22)
535 GET_HT_MCS (23)
536 GET_HT_MCS (24)
537 GET_HT_MCS (25)
538 GET_HT_MCS (26)
539 GET_HT_MCS (27)
540 GET_HT_MCS (28)
541 GET_HT_MCS (29)
542 GET_HT_MCS (30)
543 GET_HT_MCS (31)
544 #undef GET_HT_MCS
545 
546 WifiMode
547 HtPhy::CreateHtMcs (uint8_t index)
548 {
549  NS_ASSERT_MSG (index <= 31, "HtMcs index must be <= 31!");
550  return WifiModeFactory::CreateWifiMcs ("HtMcs" + std::to_string (index),
551  index,
553  false,
560 }
561 
563 HtPhy::GetHtCodeRate (uint8_t mcsValue)
564 {
565  return GetCodeRate (mcsValue % 8);
566 }
567 
569 HtPhy::GetCodeRate (uint8_t mcsValue)
570 {
571  switch (mcsValue)
572  {
573  case 0:
574  case 1:
575  case 3:
576  return WIFI_CODE_RATE_1_2;
577  case 2:
578  case 4:
579  case 6:
580  return WIFI_CODE_RATE_3_4;
581  case 5:
582  return WIFI_CODE_RATE_2_3;
583  case 7:
584  return WIFI_CODE_RATE_5_6;
585  default:
587  }
588 }
589 
590 uint16_t
592 {
593  return GetConstellationSize (mcsValue % 8);
594 }
595 
596 uint16_t
597 HtPhy::GetConstellationSize (uint8_t mcsValue)
598 {
599  switch (mcsValue)
600  {
601  case 0:
602  return 2;
603  case 1:
604  case 2:
605  return 4;
606  case 3:
607  case 4:
608  return 16;
609  case 5:
610  case 6:
611  case 7:
612  return 64;
613  default:
614  return 0;
615  }
616 }
617 
618 uint64_t
619 HtPhy::GetPhyRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
620 {
621  WifiCodeRate codeRate = GetHtCodeRate (mcsValue);
622  uint64_t dataRate = GetDataRate (mcsValue, channelWidth, guardInterval, nss);
623  return CalculatePhyRate (codeRate, dataRate);
624 }
625 
626 uint64_t
627 HtPhy::CalculatePhyRate (WifiCodeRate codeRate, uint64_t dataRate)
628 {
629  return (dataRate / GetCodeRatio (codeRate));
630 }
631 
632 uint64_t
633 HtPhy::GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
634 {
635  return GetPhyRate (txVector.GetMode ().GetMcsValue (),
636  txVector.GetChannelWidth (),
637  txVector.GetGuardInterval (),
638  txVector.GetNss ());
639 }
640 
641 double
643 {
644  switch (codeRate)
645  {
646  case WIFI_CODE_RATE_5_6:
647  return (5.0 / 6.0);
648  default:
649  return OfdmPhy::GetCodeRatio (codeRate);
650  }
651 }
652 
653 uint64_t
654 HtPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
655 {
656  return GetDataRate (txVector.GetMode ().GetMcsValue (),
657  txVector.GetChannelWidth (),
658  txVector.GetGuardInterval (),
659  txVector.GetNss ());
660 }
661 
662 uint64_t
663 HtPhy::GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
664 {
665  NS_ASSERT (guardInterval == 800 || guardInterval == 400);
666  NS_ASSERT (nss <= 4);
667  return CalculateDataRate (3.2, guardInterval,
668  GetUsableSubcarriers (channelWidth),
669  static_cast<uint16_t> (log2 (GetHtConstellationSize (mcsValue))),
670  GetCodeRatio (GetHtCodeRate (mcsValue)), nss);
671 }
672 
673 uint64_t
674 HtPhy::CalculateDataRate (double symbolDuration, uint16_t guardInterval,
675  uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
676  double codingRate, uint8_t nss)
677 {
678  return nss * OfdmPhy::CalculateDataRate (symbolDuration, guardInterval,
679  usableSubCarriers, numberOfBitsPerSubcarrier,
680  codingRate);
681 }
682 
683 uint16_t
684 HtPhy::GetUsableSubcarriers (uint16_t channelWidth)
685 {
686  return (channelWidth == 40) ? 108 : 52;
687 }
688 
689 uint64_t
691 {
692  WifiCodeRate codeRate = GetHtCodeRate (mcsValue);
693  uint16_t constellationSize = GetHtConstellationSize (mcsValue);
694  return CalculateNonHtReferenceRate (codeRate, constellationSize);
695 }
696 
697 uint64_t
698 HtPhy::CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellationSize)
699 {
700  uint64_t dataRate;
701  switch (constellationSize)
702  {
703  case 2:
704  if (codeRate == WIFI_CODE_RATE_1_2)
705  {
706  dataRate = 6000000;
707  }
708  else if (codeRate == WIFI_CODE_RATE_3_4)
709  {
710  dataRate = 9000000;
711  }
712  else
713  {
714  NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
715  }
716  break;
717  case 4:
718  if (codeRate == WIFI_CODE_RATE_1_2)
719  {
720  dataRate = 12000000;
721  }
722  else if (codeRate == WIFI_CODE_RATE_3_4)
723  {
724  dataRate = 18000000;
725  }
726  else
727  {
728  NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
729  }
730  break;
731  case 16:
732  if (codeRate == WIFI_CODE_RATE_1_2)
733  {
734  dataRate = 24000000;
735  }
736  else if (codeRate == WIFI_CODE_RATE_3_4)
737  {
738  dataRate = 36000000;
739  }
740  else
741  {
742  NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
743  }
744  break;
745  case 64:
746  if (codeRate == WIFI_CODE_RATE_1_2 || codeRate == WIFI_CODE_RATE_2_3)
747  {
748  dataRate = 48000000;
749  }
750  else if (codeRate == WIFI_CODE_RATE_3_4 || codeRate == WIFI_CODE_RATE_5_6)
751  {
752  dataRate = 54000000;
753  }
754  else
755  {
756  NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
757  }
758  break;
759  default:
760  NS_FATAL_ERROR ("Wrong constellation size");
761  }
762  return dataRate;
763 }
764 
765 bool
766 HtPhy::IsAllowed (const WifiTxVector& /*txVector*/)
767 {
768  return true;
769 }
770 
771 uint32_t
773 {
774  return 65535;
775 }
776 
777 } //namespace ns3
778 
779 namespace {
780 
784 static class ConstructorHt
785 {
786 public:
788  {
790  ns3::WifiPhy::AddStaticPhyEntity (ns3::WIFI_MOD_CLASS_HT, ns3::Create<ns3::HtPhy> ()); //dummy Nss
791  }
793 
794 }
Constructor class for HT modes.
Definition: ht-phy.cc:785
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Return the PHY rate corresponding to the supplied code rate and data rate.
Definition: ht-phy.cc:627
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index between 0 and 7,...
Definition: ht-phy.cc:597
uint8_t m_bssMembershipSelector
the BSS membership selector
Definition: ht-phy.h:527
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: ht-phy.cc:366
uint8_t GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:179
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ht-phy.cc:772
uint8_t GetBssMembershipSelector(void) const
Definition: ht-phy.cc:159
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:591
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
Definition: ht-phy.h:525
bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
Definition: ht-phy.cc:408
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
Definition: ht-phy.cc:49
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:654
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied HT MCS index, channel width, guard interval,...
Definition: ht-phy.cc:663
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:563
static uint64_t CalculateNonHtReferenceRate(WifiCodeRate codeRate, uint16_t constellationSize)
Return the rate (in bps) of the non-HT Reference Rate which corresponds to the supplied code rate and...
Definition: ht-phy.cc:698
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
Definition: ht-phy.cc:246
virtual ~HtPhy()
Destructor for HT PHY.
Definition: ht-phy.cc:64
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
Definition: ht-phy.cc:106
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: ht-phy.cc:200
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: ht-phy.cc:262
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: ht-phy.cc:766
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:633
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
Definition: ht-phy.cc:90
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
Definition: ht-phy.cc:336
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:690
virtual Time GetLSigDuration(WifiPreamble preamble) const
Definition: ht-phy.cc:240
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied HT MCS index, channel width, guard interval,...
Definition: ht-phy.cc:619
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:165
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:457
virtual WifiMode GetHtSigMode(void) const
Definition: ht-phy.cc:153
static WifiMode GetLSigMode(void)
Definition: ht-phy.cc:147
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:547
static void InitializeModes(void)
Initialize all HT modes.
Definition: ht-phy.cc:448
static uint64_t CalculateDataRate(double symbolDuration, uint16_t guardInterval, uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss)
Calculates data rate from the supplied parameters.
Definition: ht-phy.cc:674
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7,...
Definition: ht-phy.cc:569
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
Definition: ht-phy.cc:131
virtual void BuildModeList(void)
Build mode list.
Definition: ht-phy.cc:70
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
Definition: ht-phy.cc:119
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ht-phy.cc:435
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: ht-phy.cc:418
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ht-phy.cc:358
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
Definition: ht-phy.h:549
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
Definition: ht-phy.cc:642
static const PpduFormats m_htPpduFormats
HT PPDU formats.
Definition: ht-phy.h:551
virtual Time GetHtSigDuration(void) const
Definition: ht-phy.cc:256
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
Definition: ht-phy.cc:185
PhyFieldRxStatus EndReceiveHtSig(Ptr< Event > event)
End receiving the HT-SIG, perform HT-specific actions, and provide the status of the reception.
Definition: ht-phy.cc:383
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: ht-phy.cc:125
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
Definition: ht-phy.cc:684
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
Definition: ht-phy.h:526
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
Definition: ht-phy.cc:350
PHY entity for OFDM (11a)
Definition: ofdm-phy.h:61
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
uint8_t GetNumberServiceBits(void) const
Definition: ofdm-phy.cc:263
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
Calculates data rate from the supplied parameters.
Definition: ofdm-phy.cc:568
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
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
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
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
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
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
Definition: phy-entity.cc:91
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
@ DROP
drop PPDU and set CCA_BUSY
Definition: phy-entity.h:102
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 CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:305
represent a single transmission mode
Definition: wifi-mode.h:48
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:155
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
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1138
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
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(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 High Throughput (HT) (802....
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.
uint8_t GetNess(void) const
WifiPreamble GetPreambleType(void) const
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint16_t GetChannelWidth(void) const
bool IsStbc(void) const
Check if STBC is used or not.
uint16_t GetGuardInterval(void) const
uint8_t GetNssMax(void) 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:67
#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_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#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 NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1268
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1284
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
WifiPpduField
The type of PPDU field (grouped for convenience)
MpduType
The type of an MPDU.
@ UNSUPPORTED_SETTINGS
@ HT_SIG_FAILURE
@ WIFI_PREAMBLE_HT_MF
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ OFDM_PHY_DEFAULT
Definition: ofdm-phy.h:45
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
@ 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_HT_SIG
HT-SIG field.
@ 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
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ SINGLE_MPDU
The MPDU is a single MPDU.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
#define CASE(x)
#define GET_HT_MCS(x)
Definition: ht-phy.cc:504
Declaration of ns3::HtPhy class.
#define HT_PHY
This defines the BSS membership value for HT PHY.
Definition: ht-phy.h:38
Declaration of ns3::HtPpdu class.
static class anonymous_namespace{ht-phy.cc}::ConstructorHt g_constructor_ht
the constructor for HT modes
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.h:25255
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 uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
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 uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
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
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