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
30namespace ns3 {
31
33
34/*******************************************************
35 * HT PHY (IEEE 802.11-2016, clause 19)
36 *******************************************************/
37
38/* *NS_CHECK_STYLE_OFF* */
43 WIFI_PPDU_FIELD_TRAINING, //HT-STF + HT-LTFs
45};
46/* *NS_CHECK_STYLE_ON* */
47
48HtPhy::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");
60 }
61}
62
64{
65 NS_LOG_FUNCTION (this);
66}
67
68void
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
89HtPhy::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
104bool
105HtPhy::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
117bool
119{
120 return true;
121}
122
125{
126 return m_htPpduFormats;
127}
128
130HtPhy::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
147{
148 return GetOfdmRate6Mbps ();
149}
150
153{
154 return GetLSigMode (); //same number of data tones as OFDM (i.e. 48)
155}
156
157uint8_t
159{
161}
162
163void
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");
172 m_modeList.clear ();
173 BuildModeList ();
174 }
175}
176
177uint8_t
179{
181}
182
183void
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
198Time
199HtPhy::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
238Time
240{
241 return MicroSeconds (4);
242}
243
244Time
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
254Time
256{
257 return MicroSeconds (8); //HT-SIG
258}
259
260Time
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
334uint8_t
336{
344 double maxRatePerCoder = (txVector.GetGuardInterval () == 800) ? 320e6 : 350e6;
345 return ceil (txVector.GetMode ().GetDataRate (txVector) / maxRatePerCoder);
346}
347
348Time
350{
351 uint16_t gi = txVector.GetGuardInterval ();
352 NS_ASSERT (gi == 400 || gi == 800);
353 return NanoSeconds (3200 + gi);
354}
355
357HtPhy::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 (event->GetTxVector ().GetPreambleType () == WIFI_PREAMBLE_HT_MF);
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
406bool
408{
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
416bool
418{
419 const WifiTxVector& txVector = ppdu->GetTxVector ();
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
446void
448{
449 for (uint8_t i = 0; i < 32; ++i)
450 {
451 GetHtMcs (i);
452 }
453}
454
456HtPhy::GetHtMcs (uint8_t index)
457{
458#define CASE(x) \
459case 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) \
504WifiMode \
505HtPhy::GetHtMcs ## x (void) \
506{ \
507 static WifiMode mcs = CreateHtMcs (x); \
508 return mcs; \
509}; \
510
511GET_HT_MCS (0)
512GET_HT_MCS (1)
513GET_HT_MCS (2)
514GET_HT_MCS (3)
515GET_HT_MCS (4)
516GET_HT_MCS (5)
517GET_HT_MCS (6)
518GET_HT_MCS (7)
519GET_HT_MCS (8)
520GET_HT_MCS (9)
521GET_HT_MCS (10)
522GET_HT_MCS (11)
523GET_HT_MCS (12)
524GET_HT_MCS (13)
525GET_HT_MCS (14)
526GET_HT_MCS (15)
527GET_HT_MCS (16)
528GET_HT_MCS (17)
529GET_HT_MCS (18)
530GET_HT_MCS (19)
531GET_HT_MCS (20)
532GET_HT_MCS (21)
533GET_HT_MCS (22)
534GET_HT_MCS (23)
535GET_HT_MCS (24)
536GET_HT_MCS (25)
537GET_HT_MCS (26)
538GET_HT_MCS (27)
539GET_HT_MCS (28)
540GET_HT_MCS (29)
541GET_HT_MCS (30)
542GET_HT_MCS (31)
543#undef GET_HT_MCS
544
545WifiMode
546HtPhy::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,
552 false,
559}
560
562HtPhy::GetHtCodeRate (uint8_t mcsValue)
563{
564 return GetCodeRate (mcsValue % 8);
565}
566
568HtPhy::GetCodeRate (uint8_t mcsValue)
569{
570 switch (mcsValue)
571 {
572 case 0:
573 case 1:
574 case 3:
575 return WIFI_CODE_RATE_1_2;
576 case 2:
577 case 4:
578 case 6:
579 return WIFI_CODE_RATE_3_4;
580 case 5:
581 return WIFI_CODE_RATE_2_3;
582 case 7:
583 return WIFI_CODE_RATE_5_6;
584 default:
586 }
587}
588
589uint16_t
591{
592 return GetConstellationSize (mcsValue % 8);
593}
594
595uint16_t
597{
598 switch (mcsValue)
599 {
600 case 0:
601 return 2;
602 case 1:
603 case 2:
604 return 4;
605 case 3:
606 case 4:
607 return 16;
608 case 5:
609 case 6:
610 case 7:
611 return 64;
612 default:
613 return 0;
614 }
615}
616
617uint64_t
618HtPhy::GetPhyRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
619{
620 WifiCodeRate codeRate = GetHtCodeRate (mcsValue);
621 uint64_t dataRate = GetDataRate (mcsValue, channelWidth, guardInterval, nss);
622 return CalculatePhyRate (codeRate, dataRate);
623}
624
625uint64_t
626HtPhy::CalculatePhyRate (WifiCodeRate codeRate, uint64_t dataRate)
627{
628 return (dataRate / GetCodeRatio (codeRate));
629}
630
631uint64_t
632HtPhy::GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
633{
634 return GetPhyRate (txVector.GetMode ().GetMcsValue (),
635 txVector.GetChannelWidth (),
636 txVector.GetGuardInterval (),
637 txVector.GetNss ());
638}
639
640double
642{
643 switch (codeRate)
644 {
646 return (5.0 / 6.0);
647 default:
648 return OfdmPhy::GetCodeRatio (codeRate);
649 }
650}
651
652uint64_t
653HtPhy::GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t /* staId */)
654{
655 return GetDataRate (txVector.GetMode ().GetMcsValue (),
656 txVector.GetChannelWidth (),
657 txVector.GetGuardInterval (),
658 txVector.GetNss ());
659}
660
661uint64_t
662HtPhy::GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
663{
664 NS_ASSERT (guardInterval == 800 || guardInterval == 400);
665 NS_ASSERT (nss <= 4);
666 return CalculateDataRate (3.2, guardInterval,
667 GetUsableSubcarriers (channelWidth),
668 static_cast<uint16_t> (log2 (GetHtConstellationSize (mcsValue))),
669 GetCodeRatio (GetHtCodeRate (mcsValue)), nss);
670}
671
672uint64_t
673HtPhy::CalculateDataRate (double symbolDuration, uint16_t guardInterval,
674 uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
675 double codingRate, uint8_t nss)
676{
677 return nss * OfdmPhy::CalculateDataRate (symbolDuration, guardInterval,
678 usableSubCarriers, numberOfBitsPerSubcarrier,
679 codingRate);
680}
681
682uint16_t
683HtPhy::GetUsableSubcarriers (uint16_t channelWidth)
684{
685 return (channelWidth == 40) ? 108 : 52;
686}
687
688uint64_t
690{
691 WifiCodeRate codeRate = GetHtCodeRate (mcsValue);
692 uint16_t constellationSize = GetHtConstellationSize (mcsValue);
693 return CalculateNonHtReferenceRate (codeRate, constellationSize);
694}
695
696uint64_t
697HtPhy::CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellationSize)
698{
699 uint64_t dataRate;
700 switch (constellationSize)
701 {
702 case 2:
703 if (codeRate == WIFI_CODE_RATE_1_2)
704 {
705 dataRate = 6000000;
706 }
707 else if (codeRate == WIFI_CODE_RATE_3_4)
708 {
709 dataRate = 9000000;
710 }
711 else
712 {
713 NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
714 }
715 break;
716 case 4:
717 if (codeRate == WIFI_CODE_RATE_1_2)
718 {
719 dataRate = 12000000;
720 }
721 else if (codeRate == WIFI_CODE_RATE_3_4)
722 {
723 dataRate = 18000000;
724 }
725 else
726 {
727 NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
728 }
729 break;
730 case 16:
731 if (codeRate == WIFI_CODE_RATE_1_2)
732 {
733 dataRate = 24000000;
734 }
735 else if (codeRate == WIFI_CODE_RATE_3_4)
736 {
737 dataRate = 36000000;
738 }
739 else
740 {
741 NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
742 }
743 break;
744 case 64:
745 if (codeRate == WIFI_CODE_RATE_1_2 || codeRate == WIFI_CODE_RATE_2_3)
746 {
747 dataRate = 48000000;
748 }
749 else if (codeRate == WIFI_CODE_RATE_3_4 || codeRate == WIFI_CODE_RATE_5_6)
750 {
751 dataRate = 54000000;
752 }
753 else
754 {
755 NS_FATAL_ERROR ("Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
756 }
757 break;
758 default:
759 NS_FATAL_ERROR ("Wrong constellation size");
760 }
761 return dataRate;
762}
763
764bool
765HtPhy::IsAllowed (const WifiTxVector& /*txVector*/)
766{
767 return true;
768}
769
772{
773 return 65535;
774}
775
776} //namespace ns3
777
778namespace {
779
783static class ConstructorHt
784{
785public:
787 {
789 ns3::WifiPhy::AddStaticPhyEntity (ns3::WIFI_MOD_CLASS_HT, ns3::Create<ns3::HtPhy> ()); //dummy Nss
790 }
792
793}
Constructor class for HT modes.
Definition: ht-phy.cc:784
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:626
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:596
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:365
uint8_t GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:178
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ht-phy.cc:771
uint8_t GetBssMembershipSelector(void) const
Definition: ht-phy.cc:158
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:590
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:407
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
Definition: ht-phy.cc:48
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:653
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:662
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:562
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:697
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
Definition: ht-phy.cc:245
virtual ~HtPhy()
Destructor for HT PHY.
Definition: ht-phy.cc:63
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 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
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
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: ht-phy.cc:765
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:632
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
Definition: ht-phy.cc:89
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
Definition: ht-phy.cc:335
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:689
virtual Time GetLSigDuration(WifiPreamble preamble) const
Definition: ht-phy.cc:239
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:618
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:164
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:456
virtual WifiMode GetHtSigMode(void) const
Definition: ht-phy.cc:152
static WifiMode GetLSigMode(void)
Definition: ht-phy.cc:146
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:546
static void InitializeModes(void)
Initialize all HT modes.
Definition: ht-phy.cc:447
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:673
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:568
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
virtual void BuildModeList(void)
Build mode list.
Definition: ht-phy.cc:69
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
Definition: ht-phy.cc:118
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ht-phy.cc:434
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
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ht-phy.cc:357
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:641
static const PpduFormats m_htPpduFormats
HT PPDU formats.
Definition: ht-phy.h:551
virtual Time GetHtSigDuration(void) const
Definition: ht-phy.cc:255
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
Definition: ht-phy.cc:184
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
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: ht-phy.cc:124
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
Definition: ht-phy.cc:683
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:349
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:262
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
Calculates data rate from the supplied parameters.
Definition: ofdm-phy.cc:567
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
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
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:534
Time GetSignalExtension(WifiPhyBand band) const
Definition: ofdm-phy.cc:268
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:1026
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:996
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
Definition: phy-entity.cc:1079
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:141
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
Definition: phy-entity.cc:1073
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
Definition: phy-entity.cc:90
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:250
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:1033
@ 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:870
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1117
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:635
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:503
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
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