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