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/log.h"
28 #include "ns3/assert.h"
29 
30 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("HtPhy");
33 
34 /*******************************************************
35  * HT PHY (IEEE 802.11-2016, clause 19)
36  *******************************************************/
37 
38 /* *NS_CHECK_STYLE_OFF* */
40  { WIFI_PREAMBLE_HT_MF, { WIFI_PPDU_FIELD_PREAMBLE, //L-STF + L-LTF
42  WIFI_PPDU_FIELD_HT_SIG, //HT-SIG
43  WIFI_PPDU_FIELD_TRAINING, //HT-STF + HT-LTFs
45 };
46 /* *NS_CHECK_STYLE_ON* */
47 
48 HtPhy::HtPhy (uint8_t maxNss /* = 1 */, bool buildModeList /* = true */)
49  : OfdmPhy (OFDM_PHY_DEFAULT, false) //don't add OFDM modes to list
50 {
51  NS_LOG_FUNCTION (this << +maxNss << buildModeList);
52  m_maxSupportedNss = maxNss;
56  if (buildModeList)
57  {
58  NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4, "Unsupported max Nss " << +maxNss << " for HT PHY");
59  BuildModeList ();
60  }
61 }
62 
64 {
65  NS_LOG_FUNCTION (this);
66 }
67 
68 void
70 {
71  NS_LOG_FUNCTION (this);
72  NS_ASSERT (m_modeList.empty ());
74 
75  uint8_t index = 0;
76  for (uint8_t nss = 1; nss <= m_maxSupportedNss; ++nss)
77  {
78  for (uint8_t i = 0; i <= m_maxSupportedMcsIndexPerSs; ++i)
79  {
80  NS_LOG_LOGIC ("Add HtMcs" << +index << " to list");
81  m_modeList.emplace_back (CreateHtMcs (index));
82  ++index;
83  }
84  index = 8 * nss;
85  }
86 }
87 
89 HtPhy::GetMcs (uint8_t index) const
90 {
91  for (const auto & mcs : m_modeList)
92  {
93  if (mcs.GetMcsValue () == index)
94  {
95  return mcs;
96  }
97  }
98 
99  // Should have returned if MCS found
100  NS_ABORT_MSG ("Unsupported MCS index " << +index << " for this PHY entity");
101  return WifiMode ();
102 }
103 
104 bool
105 HtPhy::IsMcsSupported (uint8_t index) const
106 {
107  for (const auto & mcs : m_modeList)
108  {
109  if (mcs.GetMcsValue () == index)
110  {
111  return true;
112  }
113  }
114  return false;
115 }
116 
117 bool
119 {
120  return true;
121 }
122 
125 {
126  return m_htPpduFormats;
127 }
128 
129 WifiMode
130 HtPhy::GetSigMode (WifiPpduField field, const WifiTxVector& txVector) const
131 {
132  switch (field)
133  {
134  case WIFI_PPDU_FIELD_PREAMBLE: //consider non-HT header mode for preamble (useful for InterferenceHelper)
136  return GetLSigMode ();
137  case WIFI_PPDU_FIELD_TRAINING: //consider HT-SIG mode for training (useful for InterferenceHelper)
139  return GetHtSigMode ();
140  default:
141  return PhyEntity::GetSigMode (field, txVector);
142  }
143 }
144 
145 WifiMode
147 {
148  return GetOfdmRate6Mbps ();
149 }
150 
151 WifiMode
153 {
154  return GetLSigMode (); //same number of data tones as OFDM (i.e. 48)
155 }
156 
157 uint8_t
159 {
161 }
162 
163 void
165 {
166  NS_LOG_FUNCTION (this << +maxIndex);
167  NS_ABORT_MSG_IF (maxIndex > m_maxMcsIndexPerSs, "Provided max MCS index " << +maxIndex << " per SS greater than max standard-defined value " << +m_maxMcsIndexPerSs);
168  if (maxIndex != m_maxSupportedMcsIndexPerSs)
169  {
170  NS_LOG_LOGIC ("Rebuild mode list since max MCS index per spatial stream has changed");
171  m_maxSupportedMcsIndexPerSs = maxIndex;
172  m_modeList.clear ();
173  BuildModeList ();
174  }
175 }
176 
177 uint8_t
179 {
181 }
182 
183 void
185 {
186  NS_LOG_FUNCTION (this << +maxNss);
188  NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4, "Unsupported max Nss " << +maxNss << " for HT PHY");
189  if (maxNss != m_maxSupportedNss)
190  {
191  NS_LOG_LOGIC ("Rebuild mode list since max number of spatial streams has changed");
192  m_maxSupportedNss = maxNss;
193  m_modeList.clear ();
194  BuildModeList ();
195  }
196 }
197 
198 Time
199 HtPhy::GetDuration (WifiPpduField field, const WifiTxVector& txVector) const
200 {
201  switch (field)
202  {
204  return MicroSeconds (16); //L-STF + L-LTF or HT-GF-STF + HT-LTF1
206  return GetLSigDuration (txVector.GetPreambleType ());
208  {
209  //We suppose here that STBC = 0.
210  //If STBC > 0, we need a different mapping between Nss and Nltf
211  // (see IEEE 802.11-2016 , section 19.3.9.4.6 "HT-LTF definition").
212  uint8_t nDataLtf = 8;
213  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)
214  if (nss < 3)
215  {
216  nDataLtf = nss;
217  }
218  else if (nss < 5)
219  {
220  nDataLtf = 4;
221  }
222  else if (nss < 7)
223  {
224  nDataLtf = 6;
225  }
226 
227  uint8_t nExtensionLtf = (txVector.GetNess () < 3) ? txVector.GetNess () : 4;
228 
229  return GetTrainingDuration (txVector, nDataLtf, nExtensionLtf);
230  }
232  return GetHtSigDuration ();
233  default:
234  return PhyEntity::GetDuration (field, txVector);
235  }
236 }
237 
238 Time
240 {
241  return MicroSeconds (4);
242 }
243 
244 Time
246  uint8_t nDataLtf, uint8_t nExtensionLtf /* = 0 */) const
247 {
248  NS_ABORT_MSG_IF (nDataLtf == 0 || nDataLtf > 4 || nExtensionLtf > 4 || (nDataLtf + nExtensionLtf) > 5,
249  "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"
250  Time duration = MicroSeconds (4) * (nDataLtf + nExtensionLtf);
251  return MicroSeconds (4) * (1 /* HT-STF */ + nDataLtf + nExtensionLtf);
252 }
253 
254 Time
256 {
257  return MicroSeconds (8); //HT-SIG
258 }
259 
260 Time
261 HtPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype,
262  bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
263  uint16_t staId) const
264 {
265  WifiMode payloadMode = txVector.GetMode (staId);
266  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))
267  uint8_t nes = GetNumberBccEncoders (txVector);
268  //TODO: Update station managers to consider GI capabilities
269  Time symbolDuration = GetSymbolDuration (txVector);
270 
271  double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector, staId) * symbolDuration.GetNanoSeconds () / 1e9;
272  uint8_t service = GetNumberServiceBits ();
273 
274  double numSymbols = 0;
275  switch (mpdutype)
276  {
278  {
279  //First packet in an A-MPDU
280  numSymbols = (stbc * (service + size * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol));
281  if (incFlag == 1)
282  {
283  totalAmpduSize += size;
284  totalAmpduNumSymbols += numSymbols;
285  }
286  break;
287  }
289  {
290  //consecutive packets in an A-MPDU
291  numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
292  if (incFlag == 1)
293  {
294  totalAmpduSize += size;
295  totalAmpduNumSymbols += numSymbols;
296  }
297  break;
298  }
300  {
301  //last packet in an A-MPDU
302  uint32_t totalSize = totalAmpduSize + size;
303  numSymbols = lrint (stbc * ceil ((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)));
304  NS_ASSERT (totalAmpduNumSymbols <= numSymbols);
305  numSymbols -= totalAmpduNumSymbols;
306  if (incFlag == 1)
307  {
308  totalAmpduSize = 0;
309  totalAmpduNumSymbols = 0;
310  }
311  break;
312  }
313  case NORMAL_MPDU:
314  case SINGLE_MPDU:
315  {
316  //Not an A-MPDU or single MPDU (i.e. the current payload contains both service and padding)
317  //The number of OFDM symbols in the data field when BCC encoding
318  //is used is given in equation 19-32 of the IEEE 802.11-2016 standard.
319  numSymbols = lrint (stbc * ceil ((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)));
320  break;
321  }
322  default:
323  NS_FATAL_ERROR ("Unknown MPDU type");
324  }
325 
326  Time payloadDuration = FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
327  if (mpdutype == NORMAL_MPDU || mpdutype == SINGLE_MPDU || mpdutype == LAST_MPDU_IN_AGGREGATE)
328  {
329  payloadDuration += GetSignalExtension (band);
330  }
331  return payloadDuration;
332 }
333 
334 uint8_t
336 {
344  double maxRatePerCoder = (txVector.GetGuardInterval () == 800) ? 320e6 : 350e6;
345  return ceil (txVector.GetMode ().GetDataRate (txVector) / maxRatePerCoder);
346 }
347 
348 Time
349 HtPhy::GetSymbolDuration (const WifiTxVector& txVector) const
350 {
351  uint16_t gi = txVector.GetGuardInterval ();
352  NS_ASSERT (gi == 400 || gi == 800);
353  return NanoSeconds (3200 + gi);
354 }
355 
357 HtPhy::BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration)
358 {
359  NS_LOG_FUNCTION (this << psdus << txVector << ppduDuration);
360  return Create<HtPpdu> (psdus.begin ()->second, txVector, ppduDuration, m_wifiPhy->GetPhyBand (),
361  ObtainNextUid (txVector));
362 }
363 
366 {
367  NS_LOG_FUNCTION (this << field << *event);
368  switch (field)
369  {
371  return EndReceiveHtSig (event);
373  return PhyFieldRxStatus (true); //always consider that training has been correctly received
375  //no break so as to go to OfdmPhy for processing
376  default:
377  return OfdmPhy::DoEndReceiveField (field, event);
378  }
379 }
380 
383 {
384  NS_LOG_FUNCTION (this << *event);
385  NS_ASSERT (IsHt (event->GetTxVector ().GetPreambleType ()));
387  NS_LOG_DEBUG ("HT-SIG: SNR(dB)=" << RatioToDb (snrPer.snr) << ", PER=" << snrPer.per);
388  PhyFieldRxStatus status (GetRandomValue () > snrPer.per);
389  if (status.isSuccess)
390  {
391  NS_LOG_DEBUG ("Received HT-SIG");
392  if (!IsAllConfigSupported (WIFI_PPDU_FIELD_HT_SIG, event->GetPpdu ()))
393  {
394  status = PhyFieldRxStatus (false, UNSUPPORTED_SETTINGS, DROP);
395  }
396  }
397  else
398  {
399  NS_LOG_DEBUG ("Drop packet because HT-SIG reception failed");
400  status.reason = HT_SIG_FAILURE;
401  status.actionIfFailure = DROP;
402  }
403  return status;
404 }
405 
406 bool
408 {
409  if (field == WIFI_PPDU_FIELD_NON_HT_HEADER)
410  {
411  return true; //wait till reception of HT-SIG (or SIG-A) to make decision
412  }
413  return OfdmPhy::IsAllConfigSupported (field, ppdu);
414 }
415 
416 bool
418 {
419  const WifiTxVector& txVector = ppdu->GetTxVector ();
420  if (txVector.GetNss () > m_wifiPhy->GetMaxSupportedRxSpatialStreams ())
421  {
422  NS_LOG_DEBUG ("Packet reception could not be started because not enough RX antennas");
423  return false;
424  }
425  if (!IsModeSupported (txVector.GetMode ()))
426  {
427  NS_LOG_DEBUG ("Drop packet because it was sent using an unsupported mode (" << txVector.GetMode () << ")");
428  return false;
429  }
430  return true;
431 }
432 
435 {
436  const WifiTxVector& txVector = ppdu->GetTxVector ();
437  uint16_t centerFrequency = GetCenterFrequencyForChannelWidth (txVector);
438  uint16_t channelWidth = txVector.GetChannelWidth ();
439  NS_LOG_FUNCTION (this << centerFrequency << channelWidth << txPowerW);
440  const auto & txMaskRejectionParams = GetTxMaskRejectionParams ();
441  Ptr<SpectrumValue> v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
442  std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
443  return v;
444 }
445 
446 void
448 {
449  for (uint8_t i = 0; i < 32; ++i)
450  {
451  GetHtMcs (i);
452  }
453 }
454 
455 WifiMode
456 HtPhy::GetHtMcs (uint8_t index)
457 {
458 #define CASE(x) \
459 case x: \
460  return GetHtMcs ## x (); \
461 
462  switch (index)
463  {
464  CASE ( 0)
465  CASE ( 1)
466  CASE ( 2)
467  CASE ( 3)
468  CASE ( 4)
469  CASE ( 5)
470  CASE ( 6)
471  CASE ( 7)
472  CASE ( 8)
473  CASE ( 9)
474  CASE (10)
475  CASE (11)
476  CASE (12)
477  CASE (13)
478  CASE (14)
479  CASE (15)
480  CASE (16)
481  CASE (17)
482  CASE (18)
483  CASE (19)
484  CASE (20)
485  CASE (21)
486  CASE (22)
487  CASE (23)
488  CASE (24)
489  CASE (25)
490  CASE (26)
491  CASE (27)
492  CASE (28)
493  CASE (29)
494  CASE (30)
495  CASE (31)
496  default:
497  NS_ABORT_MSG ("Inexistent (or not supported) index (" << +index << ") requested for HT");
498  return WifiMode ();
499  }
500 #undef CASE
501 }
502 
503 #define GET_HT_MCS(x) \
504 WifiMode \
505 HtPhy::GetHtMcs ## x (void) \
506 { \
507  static WifiMode mcs = CreateHtMcs (x); \
508  return mcs; \
509 }; \
510 
511 GET_HT_MCS (0)
512 GET_HT_MCS (1)
513 GET_HT_MCS (2)
514 GET_HT_MCS (3)
515 GET_HT_MCS (4)
516 GET_HT_MCS (5)
517 GET_HT_MCS (6)
518 GET_HT_MCS (7)
519 GET_HT_MCS (8)
520 GET_HT_MCS (9)
521 GET_HT_MCS (10)
522 GET_HT_MCS (11)
523 GET_HT_MCS (12)
524 GET_HT_MCS (13)
525 GET_HT_MCS (14)
526 GET_HT_MCS (15)
527 GET_HT_MCS (16)
528 GET_HT_MCS (17)
529 GET_HT_MCS (18)
530 GET_HT_MCS (19)
531 GET_HT_MCS (20)
532 GET_HT_MCS (21)
533 GET_HT_MCS (22)
534 GET_HT_MCS (23)
535 GET_HT_MCS (24)
536 GET_HT_MCS (25)
537 GET_HT_MCS (26)
538 GET_HT_MCS (27)
539 GET_HT_MCS (28)
540 GET_HT_MCS (29)
541 GET_HT_MCS (30)
542 GET_HT_MCS (31)
543 #undef GET_HT_MCS
544 
545 WifiMode
546 HtPhy::CreateHtMcs (uint8_t index)
547 {
548  NS_ASSERT_MSG (index <= 31, "HtMcs index must be <= 31!");
549  return WifiModeFactory::CreateWifiMcs ("HtMcs" + std::to_string (index),
550  index,
554  MakeBoundCallback (&GetPhyRate, index),
556  MakeBoundCallback (&GetDataRate, index),
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::IsModeAllowed (uint16_t /* channelWidth */, uint8_t /* nss */)
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 }
double snr
SNR in linear scale.
Definition: phy-entity.h:138
uint8_t GetNssMax(void) const
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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:538
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static void InitializeModes(void)
Initialize all HT modes.
Definition: ht-phy.cc:447
#define GET_HT_MCS(x)
Definition: ht-phy.cc:503
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
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
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ht-phy.cc:357
PhyRxFailureAction actionIfFailure
action to perform in case of failure
Definition: phy-entity.h:115
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
uint8_t GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:178
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
uint8_t GetNumberServiceBits(void) const
Definition: ofdm-phy.cc:262
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1124
static const PpduFormats m_htPpduFormats
HT PPDU formats.
Definition: ht-phy.h:553
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1703
WifiPhyRxfailureReason reason
failure reason
Definition: phy-entity.h:114
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
Definition: ht-phy.cc:335
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:633
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:563
#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_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
bool IsStbc(void) const
Check if STBC is used or not.
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
Definition: ht-phy.cc:184
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...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
uint8_t GetNess(void) const
#define HT_PHY
This defines the BSS membership value for HT PHY.
Definition: ht-phy.h:38
uint16_t GetGuardInterval(void) const
static class anonymous_namespace{ht-phy.cc}::ConstructorHt g_constructor_ht
the constructor for HT modes
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.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:47
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
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
MpduType
The type of an MPDU.
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:407
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...
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:261
WifiPreamble GetPreambleType(void) const
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP, HT-GF-STF + HT-GF-LTF1 fields for HT-GF, L-STF + L-LTF fields otherwise.
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
Definition: phy-entity.cc:1067
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
Definition: ht-phy.h:551
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, PhyRateFromTxVectorCallback phyRateFromTxVectorCallback, DataRateCallback dataRateCallback, DataRateFromTxVectorCallback dataRateFromTxVectorCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, ModeAllowedCallback isModeAllowedCallback)
Definition: wifi-mode.cc:291
The MPDU is not part of an A-MPDU.
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate...
Constructor class for HT modes.
Definition: ht-phy.cc:784
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
Definition: ht-phy.cc:245
virtual WifiMode GetHtSigMode(void) const
Definition: ht-phy.cc:152
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy&#39;s InterferenceHelper class.
Definition: phy-entity.cc:250
virtual Time GetLSigDuration(WifiPreamble preamble) const
Definition: ht-phy.cc:239
Status of the reception of the PPDU field.
Definition: phy-entity.h:110
virtual ~HtPhy()
Destructor for HT PHY.
Definition: ht-phy.cc:63
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1313
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
Definition: ht-phy.cc:48
static bool IsModeAllowed(uint16_t channelWidth, uint8_t nss)
Check whether the combination of <MCS, channel width, NSS> is allowed.
Definition: ht-phy.cc:766
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:329
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ht-phy.cc:434
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate...
virtual void BuildModeList(void)
Build mode list.
Definition: ht-phy.cc:69
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:382
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:282
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
Definition: ht-phy.cc:349
WifiPpduField
The type of PPDU field (grouped for convenience)
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
Definition: ht-phy.cc:105
Time GetSignalExtension(WifiPhyBand band) const
Definition: ofdm-phy.cc:268
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: ht-phy.cc:417
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:654
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
Definition: ht-phy.h:527
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:176
virtual uint64_t ObtainNextUid(const WifiTxVector &txVector)
Obtain the next UID for the PPDU to transmit.
Definition: phy-entity.cc:1021
virtual Time GetHtSigDuration(void) const
Definition: ht-phy.cc:255
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:1028
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Calculates data rate from the supplied parameters.
Definition: ofdm-phy.cc:573
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
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:136
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:199
const uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
uint8_t GetBssMembershipSelector(void) const
Definition: ht-phy.cc:158
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:365
Declaration of ns3::HtPhy class.
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:141
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:392
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
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:886
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
Definition: ht-phy.h:528
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
Definition: ht-phy.cc:118
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:164
drop PPDU and set CCA_BUSY
Definition: phy-entity.h:102
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:53
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:546
PHY entity for OFDM (11a)This class is also used for the 10 MHz and 5 MHz bandwidth variants addressi...
Definition: ofdm-phy.h:60
#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
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7, since HT MCS index > 8 is used for higher NSS.
Definition: ht-phy.cc:569
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
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:32
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ht-phy.cc:772
static WifiMode GetLSigMode(void)
Definition: ht-phy.cc:146
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:591
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define CASE(x)
bool IsHt(WifiPreamble preamble)
Return whether the preamble is a HT format preamble.
Definition: wifi-utils.cc:277
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:477
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
STF + LTF fields (excluding those in preamble for HT-GF)
double GetRandomValue(void) const
Obtain a random value from the WifiPhy&#39;s generator.
Definition: phy-entity.cc:991
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: ht-phy.cc:124
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:130
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
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
uint16_t GetChannelWidth(void) const
uint8_t m_bssMembershipSelector
the BSS membership selector
Definition: ht-phy.h:529
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1329
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:400
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
The MPDU is a single MPDU.
Declaration of ns3::HtPpdu class.
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:137
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
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
Definition: phy-entity.cc:90
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
Definition: ht-phy.cc:684
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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:1642
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
Definition: ht-phy.cc:89
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:456
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1421
std::list< WifiMode > m_modeList
the list of supported modes
Definition: phy-entity.h:786
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
Definition: phy-entity.h:783
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
Definition: phy-entity.cc:1061