A Discrete-Event Network Simulator
API
spectrum-wifi-phy.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Ghada Badawy <gbadawy@gmail.com>
20  * Sébastien Deronne <sebastien.deronne@gmail.com>
21  *
22  * Ported from yans-wifi-phy.cc by several contributors starting
23  * with Nicola Baldo and Dean Armstrong
24  */
25 
26 #include "ns3/log.h"
27 #include "ns3/double.h"
28 #include "ns3/boolean.h"
29 #include "ns3/wifi-net-device.h"
30 #include "ns3/node.h"
31 #include "ns3/simulator.h"
32 #include "spectrum-wifi-phy.h"
35 #include "wifi-utils.h"
36 #include "wifi-psdu.h"
37 
38 namespace ns3 {
39 
40 NS_LOG_COMPONENT_DEFINE ("SpectrumWifiPhy");
41 
42 NS_OBJECT_ENSURE_REGISTERED (SpectrumWifiPhy);
43 
44 TypeId
46 {
47  static TypeId tid = TypeId ("ns3::SpectrumWifiPhy")
48  .SetParent<WifiPhy> ()
49  .SetGroupName ("Wifi")
50  .AddConstructor<SpectrumWifiPhy> ()
51  .AddAttribute ("DisableWifiReception",
52  "Prevent Wi-Fi frame sync from ever happening",
53  BooleanValue (false),
56  .AddAttribute ("TxMaskInnerBandMinimumRejection",
57  "Minimum rejection (dBr) for the inner band of the transmit spectrum mask",
58  DoubleValue (-20.0),
60  MakeDoubleChecker<double> ())
61  .AddAttribute ("TxMaskOuterBandMinimumRejection",
62  "Minimum rejection (dBr) for the outer band of the transmit spectrum mask",
63  DoubleValue (-28.0),
65  MakeDoubleChecker<double> ())
66  .AddAttribute ("TxMaskOuterBandMaximumRejection",
67  "Maximum rejection (dBr) for the outer band of the transmit spectrum mask",
68  DoubleValue (-40.0),
70  MakeDoubleChecker<double> ())
71  .AddTraceSource ("SignalArrival",
72  "Signal arrival",
74  "ns3::SpectrumWifiPhy::SignalArrivalCallback")
75  ;
76  return tid;
77 }
78 
80 {
81  NS_LOG_FUNCTION (this);
82 }
83 
85 {
86  NS_LOG_FUNCTION (this);
87 }
88 
89 void
91 {
92  NS_LOG_FUNCTION (this);
93  m_channel = 0;
95  m_antenna = 0;
97  m_ruBands.clear ();
99 }
100 
101 void
103 {
104  NS_LOG_FUNCTION (this);
106  // This connection is deferred until frequency and channel width are set
108  {
110  }
111  else
112  {
113  NS_FATAL_ERROR ("SpectrumWifiPhy misses channel and WifiSpectrumPhyInterface objects at initialization time");
114  }
115 }
116 
119 {
120  NS_LOG_FUNCTION (this);
121  if (m_rxSpectrumModel)
122  {
123  return m_rxSpectrumModel;
124  }
125  else
126  {
127  if (GetFrequency () == 0)
128  {
129  NS_LOG_DEBUG ("Frequency is not set; returning 0");
130  return 0;
131  }
132  else
133  {
134  uint16_t channelWidth = GetChannelWidth ();
135  NS_LOG_DEBUG ("Creating spectrum model from frequency/width pair of (" << GetFrequency () << ", " << channelWidth << ")");
138  }
139  }
140  return m_rxSpectrumModel;
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION (this);
147  uint16_t channelWidth = GetChannelWidth ();
149  if (channelWidth < 20)
150  {
151  WifiSpectrumBand band = GetBand (channelWidth);
152  m_interference.AddBand (band);
153  }
154  else
155  {
156  for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
157  {
158  for (uint8_t i = 0; i < (channelWidth / bw); ++i)
159  {
160  m_interference.AddBand (GetBand (bw, i));
161  }
162  }
163  }
165  {
166  // For a given RU type, some RUs over a channel occupy the same tones as
167  // the corresponding RUs over a subchannel, while some others not. For instance,
168  // the first nine 26-tone RUs over an 80 MHz channel occupy the same tones as
169  // the first nine 26-tone RUs over the lowest 40 MHz subchannel. Therefore, we
170  // need to store all the bands in a set (which removes duplicates) and then
171  // pass the elements in the set to AddBand (to which we cannot pass duplicates)
172  if (m_ruBands[channelWidth].empty ())
173  {
174  for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
175  {
176  for (uint8_t i = 0; i < (channelWidth / bw); ++i)
177  {
178  for (unsigned int type = 0; type < 7; type++)
179  {
180  HeRu::RuType ruType = static_cast <HeRu::RuType> (type);
181  std::size_t nRus = HeRu::GetNRus (bw, ruType);
182  for (std::size_t phyIndex = 1; phyIndex <= nRus; phyIndex++)
183  {
184  HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (bw, ruType, phyIndex);
185  HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second);
186  WifiSpectrumBand band = ConvertHeRuSubcarriers (bw, GetGuardBandwidth (channelWidth),
187  range, i);
188  std::size_t index = (bw == 160 && phyIndex > nRus / 2
189  ? phyIndex - nRus / 2 : phyIndex);
190  bool primary80IsLower80 = (GetOperatingChannel ().GetPrimaryChannelIndex (20)
191  < bw / 40);
192  bool primary80 = (bw < 160
193  || ruType == HeRu::RU_2x996_TONE
194  || (primary80IsLower80 && phyIndex <= nRus / 2)
195  || (!primary80IsLower80 && phyIndex > nRus / 2));
196  HeRu::RuSpec ru (ruType, index, primary80);
197  ru.SetPhyIndex (bw, GetOperatingChannel ().GetPrimaryChannelIndex (20));
198  NS_ABORT_IF (ru.GetPhyIndex () != phyIndex);
199  m_ruBands[channelWidth].insert ({band, ru});
200  }
201  }
202  }
203  }
204  }
205  for (const auto& bandRuPair : m_ruBands[channelWidth])
206  {
207  m_interference.AddBand (bandRuPair.first);
208  }
209  }
210 }
211 
214 {
215  return m_channel;
216 }
217 
218 void
220 {
221  m_channel = channel;
222 }
223 
224 void
226 {
227  NS_LOG_FUNCTION (this);
228  NS_ASSERT_MSG (IsInitialized (), "Executing method before run-time");
229  uint16_t channelWidth = GetChannelWidth ();
230  NS_LOG_DEBUG ("Run-time change of spectrum model from frequency/width pair of (" << GetFrequency () << ", " << channelWidth << ")");
231  // Replace existing spectrum model with new one, and must call AddRx ()
232  // on the SpectrumChannel to provide this new spectrum model to it
236 }
237 
238 void
240 {
241  NS_LOG_FUNCTION (this << +nch);
243  if (IsInitialized ())
244  {
246  }
247 }
248 
249 void
251 {
252  NS_LOG_FUNCTION (this << freq);
253  WifiPhy::SetFrequency (freq);
254  if (IsInitialized ())
255  {
257  }
258 }
259 
260 void
261 SpectrumWifiPhy::SetChannelWidth (uint16_t channelwidth)
262 {
263  NS_LOG_FUNCTION (this << channelwidth);
264  WifiPhy::SetChannelWidth (channelwidth);
265  if (IsInitialized ())
266  {
268  }
269 }
270 
271 void
273 {
274  NS_LOG_FUNCTION (this << standard << band);
275  WifiPhy::ConfigureStandardAndBand (standard, band);
276  if (IsInitialized ())
277  {
279  }
280 }
281 
282 void
284 {
285  NS_LOG_FUNCTION (this << rxParams);
286  Time rxDuration = rxParams->duration;
287  Ptr<SpectrumValue> receivedSignalPsd = rxParams->psd;
288  NS_LOG_DEBUG ("Received signal with PSD " << *receivedSignalPsd << " and duration " << rxDuration.As (Time::NS));
289  uint32_t senderNodeId = 0;
290  if (rxParams->txPhy)
291  {
292  senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
293  }
294  NS_LOG_DEBUG ("Received signal from " << senderNodeId << " with unfiltered power " << WToDbm (Integral (*receivedSignalPsd)) << " dBm");
295 
296  // Integrate over our receive bandwidth (i.e., all that the receive
297  // spectral mask representing our filtering allows) to find the
298  // total energy apparent to the "demodulator".
299  // This is done per 20 MHz channel band.
300  uint16_t channelWidth = GetChannelWidth ();
301  double totalRxPowerW = 0;
302  RxPowerWattPerChannelBand rxPowerW;
303 
304  if ((channelWidth == 5) || (channelWidth == 10))
305  {
306  WifiSpectrumBand filteredBand = GetBand (channelWidth);
307  double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW (receivedSignalPsd, filteredBand);
308  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << rxPowerPerBandW);
309  rxPowerPerBandW *= DbToRatio (GetRxGain ());
310  totalRxPowerW += rxPowerPerBandW;
311  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
312  NS_LOG_DEBUG ("Signal power received after antenna gain for " << channelWidth << " MHz channel: " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
313  }
314 
315  for (uint16_t bw = 160; bw > 20; bw = bw / 2) //20 MHz is handled apart since the totalRxPowerW is computed through it
316  {
317  for (uint8_t i = 0; i < (channelWidth / bw); i++)
318  {
319  NS_ASSERT (channelWidth >= bw);
320  WifiSpectrumBand filteredBand = GetBand (bw, i);
321  double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW (receivedSignalPsd, filteredBand);
322  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for " << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW);
323  rxPowerPerBandW *= DbToRatio (GetRxGain ());
324  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
325  NS_LOG_DEBUG ("Signal power received after antenna gain for " << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
326  }
327  }
328 
329 
330  for (uint8_t i = 0; i < (channelWidth / 20); i++)
331  {
332  WifiSpectrumBand filteredBand = GetBand (20, i);
333  double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW (receivedSignalPsd, filteredBand);
334  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for 20 MHz channel band " << +i << ": " << rxPowerPerBandW);
335  rxPowerPerBandW *= DbToRatio (GetRxGain ());
336  totalRxPowerW += rxPowerPerBandW;
337  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
338  NS_LOG_DEBUG ("Signal power received after antenna gain for 20 MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
339  }
340 
342  {
343  NS_ASSERT (!m_ruBands[channelWidth].empty ());
344  for (const auto& bandRuPair : m_ruBands[channelWidth])
345  {
346  double rxPowerPerBandW = WifiSpectrumValueHelper::GetBandPowerW (receivedSignalPsd, bandRuPair.first);
347  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for RU with type " << bandRuPair.second.GetRuType () << " and index " << bandRuPair.second.GetIndex () << " -> (" << bandRuPair.first.first << "; " << bandRuPair.first.second << "): " << rxPowerPerBandW);
348  rxPowerPerBandW *= DbToRatio (GetRxGain ());
349  NS_LOG_DEBUG ("Signal power received after antenna gain for RU with type " << bandRuPair.second.GetRuType () << " and index " << bandRuPair.second.GetIndex () << " -> (" << bandRuPair.first.first << "; " << bandRuPair.first.second << "): " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
350  rxPowerW.insert ({bandRuPair.first, rxPowerPerBandW});
351  }
352  }
353 
354  NS_LOG_DEBUG ("Total signal power received after antenna gain: " << totalRxPowerW << " W (" << WToDbm (totalRxPowerW) << " dBm)");
355 
356  Ptr<WifiSpectrumSignalParameters> wifiRxParams = DynamicCast<WifiSpectrumSignalParameters> (rxParams);
357 
358  // Log the signal arrival to the trace source
359  m_signalCb (wifiRxParams ? true : false, senderNodeId, WToDbm (totalRxPowerW), rxDuration);
360 
361  if (wifiRxParams == 0)
362  {
363  NS_LOG_INFO ("Received non Wi-Fi signal");
364  m_interference.AddForeignSignal (rxDuration, rxPowerW);
366  return;
367  }
368  if (wifiRxParams && m_disableWifiReception)
369  {
370  NS_LOG_INFO ("Received Wi-Fi signal but blocked from syncing");
371  m_interference.AddForeignSignal (rxDuration, rxPowerW);
373  return;
374  }
375  // Do no further processing if signal is too weak
376  // Current implementation assumes constant RX power over the PPDU duration
377  // Compare received TX power per MHz to normalized RX sensitivity
378  uint16_t txWidth = wifiRxParams->ppdu->GetTransmissionChannelWidth ();
379  if (totalRxPowerW < DbmToW (GetRxSensitivity ()) * (txWidth / 20.0))
380  {
381  NS_LOG_INFO ("Received signal too weak to process: " << WToDbm (totalRxPowerW) << " dBm");
382  m_interference.Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (), rxDuration,
383  rxPowerW);
384  SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (wifiRxParams->ppdu));
385  return;
386  }
387 
388  // Unless we are receiving a TB PPDU, do not sync with this signal if the PPDU
389  // does not overlap with the receiver's primary20 channel
390  if (wifiRxParams->txPhy != 0)
391  {
392  Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (rxParams->txPhy->GetDevice ());
393  NS_ASSERT (dev != 0);
394  Ptr<WifiPhy> txPhy = dev->GetPhy ();
395  NS_ASSERT (txPhy != 0);
396  uint16_t txChannelWidth = wifiRxParams->ppdu->GetTxVector ().GetChannelWidth ();
397  uint16_t txCenterFreq = txPhy->GetOperatingChannel ().GetPrimaryChannelCenterFrequency (txChannelWidth);
398 
399  // if the channel width is a multiple of 20 MHz, then we consider the primary20 channel
400  uint16_t width = (GetChannelWidth () % 20 == 0 ? 20 : GetChannelWidth ());
401  uint16_t p20MinFreq =
403  uint16_t p20MaxFreq =
405 
406  if (!wifiRxParams->ppdu->CanBeReceived (txCenterFreq, p20MinFreq, p20MaxFreq))
407  {
408  NS_LOG_INFO ("Cannot receive the PPDU, consider it as interference");
409  m_interference.Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (),
410  rxDuration, rxPowerW);
411  SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (wifiRxParams->ppdu));
412  return;
413  }
414  }
415 
416  NS_LOG_INFO ("Received Wi-Fi signal");
417  Ptr<WifiPpdu> ppdu = wifiRxParams->ppdu->Copy ();
418  StartReceivePreamble (ppdu, rxPowerW, rxDuration);
419 }
420 
423 {
424  return m_antenna;
425 }
426 
427 void
429 {
430  NS_LOG_FUNCTION (this << a);
431  m_antenna = a;
432 }
433 
434 void
436 {
437  NS_LOG_FUNCTION (this << device);
438  m_wifiSpectrumPhyInterface = CreateObject<WifiSpectrumPhyInterface> ();
439  m_wifiSpectrumPhyInterface->SetSpectrumWifiPhy (this);
440  m_wifiSpectrumPhyInterface->SetDevice (device);
441 }
442 
443 void
445 {
446  NS_LOG_FUNCTION (this << ppdu);
447  GetPhyEntity (ppdu->GetModulation ())->StartTx (ppdu);
448 }
449 
450 void
452 {
453  NS_LOG_FUNCTION (this << txParams);
454 
455  //Finish configuration
456  NS_ASSERT_MSG (m_wifiSpectrumPhyInterface, "SpectrumPhy() is not set; maybe forgot to call CreateWifiSpectrumPhyInterface?");
457  txParams->txPhy = m_wifiSpectrumPhyInterface->GetObject<SpectrumPhy> ();
458  txParams->txAntenna = m_antenna;
459 
460  m_channel->StartTx (txParams);
461 }
462 
463 uint32_t
465 {
466  uint32_t bandBandwidth = 0;
467  switch (GetPhyStandard ())
468  {
474  // Use OFDM subcarrier width of 312.5 KHz as band granularity
475  bandBandwidth = 312500;
476  break;
478  if (GetChannelWidth () == 5)
479  {
480  // Use OFDM subcarrier width of 78.125 KHz as band granularity
481  bandBandwidth = 78125;
482  }
483  else
484  {
485  // Use OFDM subcarrier width of 156.25 KHz as band granularity
486  bandBandwidth = 156250;
487  }
488  break;
490  // Use OFDM subcarrier width of 78.125 KHz as band granularity
491  bandBandwidth = 78125;
492  break;
493  default:
494  NS_FATAL_ERROR ("Standard unknown: " << GetPhyStandard ());
495  break;
496  }
497  return bandBandwidth;
498 }
499 
500 uint16_t
501 SpectrumWifiPhy::GetGuardBandwidth (uint16_t currentChannelWidth) const
502 {
503  uint16_t guardBandwidth = 0;
504  if (currentChannelWidth == 22)
505  {
506  //handle case of DSSS transmission
507  guardBandwidth = 10;
508  }
509  else
510  {
511  //In order to properly model out of band transmissions for OFDM, the guard
512  //band has been configured so as to expand the modeled spectrum up to the
513  //outermost referenced point in "Transmit spectrum mask" sections' PSDs of
514  //each PHY specification of 802.11-2016 standard. It thus ultimately corresponds
515  //to the currently considered channel bandwidth (which can be different from
516  //supported channel width).
517  guardBandwidth = currentChannelWidth;
518  }
519  return guardBandwidth;
520 }
521 
523 SpectrumWifiPhy::GetBand (uint16_t bandWidth, uint8_t bandIndex)
524 {
525  uint16_t channelWidth = GetChannelWidth ();
526  uint32_t bandBandwidth = GetBandBandwidth ();
527  size_t numBandsInChannel = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
528  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / bandBandwidth);
529  if (numBandsInBand % 2 == 0)
530  {
531  numBandsInChannel += 1; // symmetry around center frequency
532  }
533  size_t totalNumBands = GetRxSpectrumModel ()->GetNumBands ();
534  NS_ASSERT_MSG ((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1), "Should have odd number of bands");
535  NS_ASSERT_MSG ((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
536  WifiSpectrumBand band;
537  band.first = ((totalNumBands - numBandsInChannel) / 2) + (bandIndex * numBandsInBand);
538  if (band.first >= totalNumBands / 2)
539  {
540  //step past DC
541  band.first += 1;
542  }
543  band.second = band.first + numBandsInBand - 1;
544  return band;
545 }
546 
548 SpectrumWifiPhy::ConvertHeRuSubcarriers (uint16_t bandWidth, uint16_t guardBandwidth,
549  HeRu::SubcarrierRange range, uint8_t bandIndex) const
550 {
551  WifiSpectrumBand convertedSubcarriers;
552  uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / GetBandBandwidth ()) + 0.5);
553  uint32_t centerFrequencyIndex = 0;
554  switch (bandWidth)
555  {
556  case 20:
557  centerFrequencyIndex = (nGuardBands / 2) + 6 + 122;
558  break;
559  case 40:
560  centerFrequencyIndex = (nGuardBands / 2) + 12 + 244;
561  break;
562  case 80:
563  centerFrequencyIndex = (nGuardBands / 2) + 12 + 500;
564  break;
565  case 160:
566  centerFrequencyIndex = (nGuardBands / 2) + 12 + 1012;
567  break;
568  default:
569  NS_FATAL_ERROR ("ChannelWidth " << bandWidth << " unsupported");
570  break;
571  }
572 
573  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / GetBandBandwidth ());
574  centerFrequencyIndex += numBandsInBand * bandIndex;
575 
576  convertedSubcarriers.first = centerFrequencyIndex + range.first;
577  convertedSubcarriers.second = centerFrequencyIndex + range.second;
578  return convertedSubcarriers;
579 }
580 
581 std::tuple<double, double, double>
583 {
584  return std::make_tuple (m_txMaskInnerBandMinimumRejection,
587 }
588 
589 } //namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::SpectrumWifiPhy::GetChannel
Ptr< Channel > GetChannel(void) const override
Return the Channel this WifiPhy is connected to.
Definition: spectrum-wifi-phy.cc:213
ns3::Integral
double Integral(const SpectrumValue &arg)
Definition: spectrum-value.cc:390
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#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
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
ns3::Time::NS
@ NS
nanosecond
Definition: nstime.h:118
ns3::WifiSpectrumBand
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
Definition: wifi-spectrum-value-helper.h:34
ns3::SpectrumWifiPhy::StartRx
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
Definition: spectrum-wifi-phy.cc:283
ns3::SpectrumWifiPhy::Transmit
void Transmit(Ptr< WifiSpectrumSignalParameters > txParams)
This function is sending the signal to the Spectrum channel after finishing the configuration of the ...
Definition: spectrum-wifi-phy.cc:451
ns3::WifiNetDevice::GetPhy
Ptr< WifiPhy > GetPhy(void) const
Definition: wifi-net-device.cc:207
ns3::SpectrumWifiPhy::SetChannelNumber
void SetChannelNumber(uint8_t id) override
Set channel number.
Definition: spectrum-wifi-phy.cc:239
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SpectrumWifiPhy::GetBand
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the start band index and the stop band index for a given band.
Definition: spectrum-wifi-phy.cc:523
ns3::HeRu::SubcarrierGroup
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition: he-ru.h:56
ns3::WifiSpectrumValueHelper::GetSpectrumModel
static Ptr< SpectrumModel > GetSpectrumModel(uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth)
Return a SpectrumModel instance corresponding to the center frequency and channel width.
Definition: wifi-spectrum-value-helper.cc:86
ns3::SpectrumWifiPhy::m_txMaskOuterBandMinimumRejection
double m_txMaskOuterBandMinimumRejection
The minimum rejection (in dBr) for the outer band of the transmit spectrum mask.
Definition: spectrum-wifi-phy.h:205
ns3::SpectrumWifiPhy::GetRxAntenna
Ptr< AntennaModel > GetRxAntenna(void) const
Get the antenna model used for reception.
Definition: spectrum-wifi-phy.cc:422
third.channel
channel
Definition: third.py:92
ns3::SpectrumWifiPhy::SetChannel
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
Definition: spectrum-wifi-phy.cc:219
ns3::WifiPhy::GetFrequency
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1168
ns3::SpectrumWifiPhy::m_rxSpectrumModel
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
Definition: spectrum-wifi-phy.h:194
ns3::WToDbm
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:43
ns3::SpectrumWifiPhy::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: spectrum-wifi-phy.cc:102
ns3::InterferenceHelper::AddForeignSignal
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand &rxPower)
Add a non-Wifi signal to interference helper.
Definition: interference-helper.cc:198
ns3::SpectrumWifiPhy::ConfigureStandardAndBand
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: spectrum-wifi-phy.cc:272
ns3::SpectrumWifiPhy::ResetSpectrumModel
void ResetSpectrumModel(void)
Perform run-time spectrum model change.
Definition: spectrum-wifi-phy.cc:225
ns3::Time::As
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
ns3::MakeBooleanAccessor
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: boolean.h:85
ns3::WifiPhyStandard
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
Definition: wifi-standards.h:35
ns3::WifiPhy
802.11 PHY layer model
Definition: wifi-phy.h:49
ns3::WifiPhy::SetChannelWidth
virtual void SetChannelWidth(uint16_t channelWidth)
If the operating channel for this object has not been set yet, the given channel width is saved and w...
Definition: wifi-phy.cc:1205
ns3::WifiPhy::GetPhyEntity
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance.
Definition: wifi-phy.cc:878
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::SpectrumWifiPhy
802.11 PHY layer model
Definition: spectrum-wifi-phy.h:55
ns3::HeRu::RuSpec::GetPhyIndex
std::size_t GetPhyIndex(void) const
Get the RU PHY index.
Definition: he-ru.cc:212
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
ns3::HeRu::RU_2x996_TONE
@ RU_2x996_TONE
Definition: he-ru.h:49
ns3::WifiPhy::m_interference
InterferenceHelper m_interference
the class handling interference computations
Definition: wifi-phy.h:1178
wifi-psdu.h
ns3::Ptr< const SpectrumModel >
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::SpectrumWifiPhy::m_txMaskInnerBandMinimumRejection
double m_txMaskInnerBandMinimumRejection
The minimum rejection (in dBr) for the inner band of the transmit spectrum mask.
Definition: spectrum-wifi-phy.h:204
ns3::WIFI_PHY_STANDARD_80211ax
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
Definition: wifi-standards.h:49
ns3::SpectrumWifiPhy::CreateWifiSpectrumPhyInterface
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
Definition: spectrum-wifi-phy.cc:435
ns3::WIFI_PHY_STANDARD_80211p
@ WIFI_PHY_STANDARD_80211p
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
Definition: wifi-standards.h:43
ns3::HeRu::RuSpec
RU Specification.
Definition: he-ru.h:68
ns3::HeRu::GetNRus
static std::size_t GetNRus(uint16_t bw, RuType ruType)
Get the number of distinct RUs of the given type (number of tones) available in a HE PPDU of the give...
Definition: he-ru.cc:219
ns3::SpectrumWifiPhy::m_antenna
Ptr< AntennaModel > m_antenna
antenna model
Definition: spectrum-wifi-phy.h:193
ns3::SpectrumWifiPhy::SetChannelWidth
void SetChannelWidth(uint16_t channelwidth) override
If the operating channel for this object has not been set yet, the given channel width is saved and w...
Definition: spectrum-wifi-phy.cc:261
ns3::WifiPhy::GetPhyStandard
WifiPhyStandard GetPhyStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1131
ns3::SpectrumWifiPhy::m_txMaskOuterBandMaximumRejection
double m_txMaskOuterBandMaximumRejection
The maximum rejection (in dBr) for the outer band of the transmit spectrum mask.
Definition: spectrum-wifi-phy.h:206
wifi-spectrum-signal-parameters.h
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::SpectrumPhy
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:46
ns3::HeRu::RuType
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:42
ns3::WIFI_PHY_STANDARD_80211a
@ WIFI_PHY_STANDARD_80211a
OFDM PHY (Clause 17)
Definition: wifi-standards.h:37
ns3::SpectrumWifiPhy::GetTxMaskRejectionParams
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const override
Definition: spectrum-wifi-phy.cc:582
ns3::MakeBooleanChecker
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
ns3::WifiPhy::SetFrequency
virtual void SetFrequency(uint16_t freq)
If the operating channel for this object has not been set yet, the given center frequency is saved an...
Definition: wifi-phy.cc:1143
ns3::WifiPhy::GetOperatingChannel
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:1137
ns3::WIFI_PHY_STANDARD_80211b
@ WIFI_PHY_STANDARD_80211b
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
Definition: wifi-standards.h:39
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
spectrum-wifi-phy.h
NS_ASSERT_MSG
#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
ns3::SpectrumWifiPhy::SpectrumWifiPhy
SpectrumWifiPhy()
Definition: spectrum-wifi-phy.cc:79
ns3::Object::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
ns3::SpectrumWifiPhy::StartTx
void StartTx(Ptr< WifiPpdu > ppdu) override
Definition: spectrum-wifi-phy.cc:444
ns3::SpectrumWifiPhy::m_ruBands
std::map< uint16_t, RuBand > m_ruBands
For each channel width, store all the distinct spectrum bands associated with every RU in a channel o...
Definition: spectrum-wifi-phy.h:199
ns3::SpectrumWifiPhy::m_signalCb
TracedCallback< bool, uint32_t, double, Time > m_signalCb
Signal callback.
Definition: spectrum-wifi-phy.h:202
ns3::SpectrumWifiPhy::SetAntenna
void SetAntenna(const Ptr< AntennaModel > antenna)
Definition: spectrum-wifi-phy.cc:428
ns3::SpectrumModel::GetNumBands
size_t GetNumBands() const
Definition: spectrum-model.cc:100
ns3::SpectrumWifiPhy::GetGuardBandwidth
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
Definition: spectrum-wifi-phy.cc:501
ns3::WIFI_PHY_STANDARD_80211n
@ WIFI_PHY_STANDARD_80211n
HT PHY (clause 20)
Definition: wifi-standards.h:45
ns3::WIFI_PHY_STANDARD_80211ac
@ WIFI_PHY_STANDARD_80211ac
VHT PHY (clause 22)
Definition: wifi-standards.h:47
NS_ABORT_IF
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:77
ns3::MakeDoubleAccessor
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: double.h:42
ns3::WifiPhy::StartReceivePreamble
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1918
ns3::WifiPhy::SwitchMaybeToCcaBusy
void SwitchMaybeToCcaBusy(uint16_t channelWidth)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
Definition: wifi-phy.cc:2166
ns3::HeRu::RuSpec::SetPhyIndex
void SetPhyIndex(uint16_t bw, uint8_t p20Index)
Set the RU PHY index.
Definition: he-ru.cc:188
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::SpectrumWifiPhy::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: spectrum-wifi-phy.cc:45
ns3::DbmToW
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:37
ns3::InterferenceHelper::AddBand
void AddBand(WifiSpectrumBand band)
Add a frequency band.
Definition: interference-helper.cc:223
wifi-utils.h
ns3::WifiPhy::GetMeasurementChannelWidth
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
Definition: wifi-phy.cc:2277
ns3::WifiPhy::GetRxGain
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:758
ns3::SpectrumWifiPhy::m_channel
Ptr< SpectrumChannel > m_channel
SpectrumChannel that this SpectrumWifiPhy is connected to.
Definition: spectrum-wifi-phy.h:190
wifi-spectrum-phy-interface.h
ns3::WifiPhy::GetRxSensitivity
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:672
ns3::WifiPhy::ConfigureStandardAndBand
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1069
ns3::SpectrumWifiPhy::DoDispose
void DoDispose(void) override
Destructor implementation.
Definition: spectrum-wifi-phy.cc:90
ns3::SpectrumWifiPhy::UpdateInterferenceHelperBands
void UpdateInterferenceHelperBands(void)
This function is called to update the bands handled by the InterferenceHelper.
Definition: spectrum-wifi-phy.cc:144
ns3::WifiPhy::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:596
ns3::InterferenceHelper::Add
Ptr< Event > Add(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &rxPower, bool isStartOfdmaRxing=false)
Add the PPDU-related signal to interference helper.
Definition: interference-helper.cc:190
ns3::WifiPhy::GetChannelWidth
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1233
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::InterferenceHelper::RemoveBands
void RemoveBands(void)
Remove the frequency bands.
Definition: interference-helper.cc:211
ns3::DbToRatio
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:31
ns3::WifiPhyOperatingChannel::GetPrimaryChannelIndex
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
Definition: wifi-phy-operating-channel.cc:151
ns3::SpectrumWifiPhy::SetFrequency
void SetFrequency(uint16_t freq) override
If the operating channel for this object has not been set yet, the given center frequency is saved an...
Definition: spectrum-wifi-phy.cc:250
ns3::RxPowerWattPerChannelBand
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
ns3::SpectrumWifiPhy::GetBandBandwidth
uint32_t GetBandBandwidth(void) const
Definition: spectrum-wifi-phy.cc:464
ns3::SpectrumWifiPhy::GetRxSpectrumModel
Ptr< const SpectrumModel > GetRxSpectrumModel()
Definition: spectrum-wifi-phy.cc:118
ns3::SpectrumWifiPhy::ConvertHeRuSubcarriers
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const override
Definition: spectrum-wifi-phy.cc:548
ns3::WifiPhyBand
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
ns3::HeRu::SubcarrierRange
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition: he-ru.h:53
ns3::SpectrumWifiPhy::m_wifiSpectrumPhyInterface
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
Spectrum PHY interface.
Definition: spectrum-wifi-phy.h:192
ns3::WifiPhy::SetChannelNumber
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1174
ns3::SpectrumWifiPhy::~SpectrumWifiPhy
virtual ~SpectrumWifiPhy()
Definition: spectrum-wifi-phy.cc:84
ns3::WifiSpectrumValueHelper::GetBandPowerW
static double GetBandPowerW(Ptr< SpectrumValue > psd, const WifiSpectrumBand &band)
Calculate the power of the specified band composed of uniformly-sized sub-bands.
Definition: wifi-spectrum-value-helper.cc:644
ns3::HeRu::GetSubcarrierGroup
static SubcarrierGroup GetSubcarrierGroup(uint16_t bw, RuType ruType, std::size_t phyIndex)
Get the subcarrier group of the RU having the given PHY index among all the RUs of the given type (nu...
Definition: he-ru.cc:313
ns3::WifiPhyOperatingChannel::GetPrimaryChannelCenterFrequency
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
Definition: wifi-phy-operating-channel.cc:187
ns3::WIFI_PHY_STANDARD_80211g
@ WIFI_PHY_STANDARD_80211g
ERP-OFDM PHY (Clause 19, Section 19.5)
Definition: wifi-standards.h:41
ns3::empty
make Callback use a separate empty type
Definition: empty.h:34
ns3::SpectrumWifiPhy::m_disableWifiReception
bool m_disableWifiReception
forces this PHY to fail to sync on any signal
Definition: spectrum-wifi-phy.h:201
ns3::Object::IsInitialized
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208