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  return;
383  }
384 
385  // Unless we are receiving a TB PPDU, do not sync with this signal if the PPDU
386  // does not overlap with the receiver's primary20 channel
387  if (wifiRxParams->txPhy != 0)
388  {
389  Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (rxParams->txPhy->GetDevice ());
390  NS_ASSERT (dev != 0);
391  Ptr<WifiPhy> txPhy = dev->GetPhy ();
392  NS_ASSERT (txPhy != 0);
393  uint16_t txChannelWidth = wifiRxParams->ppdu->GetTxVector ().GetChannelWidth ();
394  uint16_t txCenterFreq = txPhy->GetOperatingChannel ().GetPrimaryChannelCenterFrequency (txChannelWidth);
395 
396  // if the channel width is a multiple of 20 MHz, then we consider the primary20 channel
397  uint16_t width = (GetChannelWidth () % 20 == 0 ? 20 : GetChannelWidth ());
398  uint16_t p20MinFreq =
400  uint16_t p20MaxFreq =
402 
403  if (!wifiRxParams->ppdu->CanBeReceived (txCenterFreq, p20MinFreq, p20MaxFreq))
404  {
405  NS_LOG_INFO ("Cannot receive the PPDU, consider it as interference");
406  m_interference.Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (),
407  rxDuration, rxPowerW);
408  SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (wifiRxParams->ppdu));
409  return;
410  }
411  }
412 
413  NS_LOG_INFO ("Received Wi-Fi signal");
414  Ptr<WifiPpdu> ppdu = wifiRxParams->ppdu->Copy ();
415  StartReceivePreamble (ppdu, rxPowerW, rxDuration);
416 }
417 
420 {
421  return m_antenna;
422 }
423 
424 void
426 {
427  NS_LOG_FUNCTION (this << a);
428  m_antenna = a;
429 }
430 
431 void
433 {
434  NS_LOG_FUNCTION (this << device);
435  m_wifiSpectrumPhyInterface = CreateObject<WifiSpectrumPhyInterface> ();
436  m_wifiSpectrumPhyInterface->SetSpectrumWifiPhy (this);
437  m_wifiSpectrumPhyInterface->SetDevice (device);
438 }
439 
440 void
442 {
443  NS_LOG_FUNCTION (this << ppdu);
444  GetPhyEntity (ppdu->GetModulation ())->StartTx (ppdu);
445 }
446 
447 void
449 {
450  NS_LOG_FUNCTION (this << txParams);
451 
452  //Finish configuration
453  NS_ASSERT_MSG (m_wifiSpectrumPhyInterface, "SpectrumPhy() is not set; maybe forgot to call CreateWifiSpectrumPhyInterface?");
454  txParams->txPhy = m_wifiSpectrumPhyInterface->GetObject<SpectrumPhy> ();
455  txParams->txAntenna = m_antenna;
456 
457  m_channel->StartTx (txParams);
458 }
459 
460 uint32_t
462 {
463  uint32_t bandBandwidth = 0;
464  switch (GetPhyStandard ())
465  {
471  // Use OFDM subcarrier width of 312.5 KHz as band granularity
472  bandBandwidth = 312500;
473  break;
475  if (GetChannelWidth () == 5)
476  {
477  // Use OFDM subcarrier width of 78.125 KHz as band granularity
478  bandBandwidth = 78125;
479  }
480  else
481  {
482  // Use OFDM subcarrier width of 156.25 KHz as band granularity
483  bandBandwidth = 156250;
484  }
485  break;
487  // Use OFDM subcarrier width of 78.125 KHz as band granularity
488  bandBandwidth = 78125;
489  break;
490  default:
491  NS_FATAL_ERROR ("Standard unknown: " << GetPhyStandard ());
492  break;
493  }
494  return bandBandwidth;
495 }
496 
497 uint16_t
498 SpectrumWifiPhy::GetGuardBandwidth (uint16_t currentChannelWidth) const
499 {
500  uint16_t guardBandwidth = 0;
501  if (currentChannelWidth == 22)
502  {
503  //handle case of DSSS transmission
504  guardBandwidth = 10;
505  }
506  else
507  {
508  //In order to properly model out of band transmissions for OFDM, the guard
509  //band has been configured so as to expand the modeled spectrum up to the
510  //outermost referenced point in "Transmit spectrum mask" sections' PSDs of
511  //each PHY specification of 802.11-2016 standard. It thus ultimately corresponds
512  //to the currently considered channel bandwidth (which can be different from
513  //supported channel width).
514  guardBandwidth = currentChannelWidth;
515  }
516  return guardBandwidth;
517 }
518 
520 SpectrumWifiPhy::GetBand (uint16_t bandWidth, uint8_t bandIndex)
521 {
522  uint16_t channelWidth = GetChannelWidth ();
523  uint32_t bandBandwidth = GetBandBandwidth ();
524  size_t numBandsInChannel = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
525  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / bandBandwidth);
526  if (numBandsInBand % 2 == 0)
527  {
528  numBandsInChannel += 1; // symmetry around center frequency
529  }
530  size_t totalNumBands = GetRxSpectrumModel ()->GetNumBands ();
531  NS_ASSERT_MSG ((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1), "Should have odd number of bands");
532  NS_ASSERT_MSG ((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
533  WifiSpectrumBand band;
534  band.first = ((totalNumBands - numBandsInChannel) / 2) + (bandIndex * numBandsInBand);
535  if (band.first >= totalNumBands / 2)
536  {
537  //step past DC
538  band.first += 1;
539  }
540  band.second = band.first + numBandsInBand - 1;
541  return band;
542 }
543 
545 SpectrumWifiPhy::ConvertHeRuSubcarriers (uint16_t bandWidth, uint16_t guardBandwidth,
546  HeRu::SubcarrierRange range, uint8_t bandIndex) const
547 {
548  WifiSpectrumBand convertedSubcarriers;
549  uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / GetBandBandwidth ()) + 0.5);
550  uint32_t centerFrequencyIndex = 0;
551  switch (bandWidth)
552  {
553  case 20:
554  centerFrequencyIndex = (nGuardBands / 2) + 6 + 122;
555  break;
556  case 40:
557  centerFrequencyIndex = (nGuardBands / 2) + 12 + 244;
558  break;
559  case 80:
560  centerFrequencyIndex = (nGuardBands / 2) + 12 + 500;
561  break;
562  case 160:
563  centerFrequencyIndex = (nGuardBands / 2) + 12 + 1012;
564  break;
565  default:
566  NS_FATAL_ERROR ("ChannelWidth " << bandWidth << " unsupported");
567  break;
568  }
569 
570  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / GetBandBandwidth ());
571  centerFrequencyIndex += numBandsInBand * bandIndex;
572 
573  convertedSubcarriers.first = centerFrequencyIndex + range.first;
574  convertedSubcarriers.second = centerFrequencyIndex + range.second;
575  return convertedSubcarriers;
576 }
577 
578 std::tuple<double, double, double>
580 {
581  return std::make_tuple (m_txMaskInnerBandMinimumRejection,
584 }
585 
586 } //namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
size_t GetNumBands() const
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the start band index and the stop band index for a given band.
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...
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
nanosecond
Definition: nstime.h:118
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
TracedCallback< bool, uint32_t, double, Time > m_signalCb
Signal callback.
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition: he-ru.h:56
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
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:45
RU Specification.
Definition: he-ru.h:67
AttributeValue implementation for Boolean.
Definition: boolean.h:36
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:758
double Integral(const SpectrumValue &arg)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void RemoveBands(void)
Remove the frequency bands.
static double GetBandPowerW(Ptr< SpectrumValue > psd, const WifiSpectrumBand &band)
Calculate the power of the specified band composed of uniformly-sized sub-bands.
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
802.11 PHY layer model
Definition: wifi-phy.h:48
Ptr< const SpectrumModel > GetRxSpectrumModel()
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:41
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
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1069
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:596
void DoDispose(void) override
Destructor implementation.
#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
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
static TypeId GetTypeId(void)
Get the type ID.
bool m_disableWifiReception
forces this PHY to fail to sync on any signal
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
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
void StartTx(Ptr< WifiPpdu > ppdu) override
void SetAntenna(const Ptr< AntennaModel > antenna)
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition: he-ru.h:53
channel
Definition: third.py:92
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:672
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1894
Ptr< SpectrumChannel > m_channel
SpectrumChannel that this SpectrumWifiPhy is connected to.
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1233
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:2155
void Transmit(Ptr< WifiSpectrumSignalParameters > txParams)
This function is sending the signal to the Spectrum channel after finishing the configuration of the ...
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
make Callback use a separate empty type
Definition: empty.h:33
double m_txMaskOuterBandMaximumRejection
The maximum rejection (in dBr) for the outer band of the transmit spectrum mask.
double m_txMaskOuterBandMinimumRejection
The minimum rejection (in dBr) for the outer band of the transmit spectrum mask.
void SetPhyIndex(uint16_t bw, uint8_t p20Index)
Set the RU PHY index.
Definition: he-ru.cc:188
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
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand &rxPower)
Add a non-Wifi signal to interference helper.
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
Definition: wifi-phy.cc:2266
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
void DoInitialize(void) override
Initialize() implementation.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
802.11 PHY layer modelThis PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy model.
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
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
WifiPhyStandard GetPhyStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1131
Ptr< WifiPhy > GetPhy(void) const
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
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...
OFDM PHY (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1168
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
uint32_t GetBandBandwidth(void) const
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.
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1174
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:35
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const override
Ptr< Channel > GetChannel(void) const override
Return the Channel this WifiPhy is connected to.
#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
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
void AddBand(WifiSpectrumBand band)
Add a frequency band.
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:32
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:77
void UpdateInterferenceHelperBands(void)
This function is called to update the bands handled by the InterferenceHelper.
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...
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...
Ptr< AntennaModel > GetRxAntenna(void) const
Get the antenna model used for reception.
InterferenceHelper m_interference
the class handling interference computations
Definition: wifi-phy.h:1162
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
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Ptr< AntennaModel > m_antenna
antenna model
void SetChannelNumber(uint8_t id) override
Set channel number.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
Spectrum PHY interface.
void ResetSpectrumModel(void)
Perform run-time spectrum model change.
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:1137
double m_txMaskInnerBandMinimumRejection
The minimum rejection (in dBr) for the inner band of the transmit spectrum mask.
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const override
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
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...
a unique identifier for an interface.
Definition: type-id.h:58
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
std::size_t GetPhyIndex(void) const
Get the RU PHY index.
Definition: he-ru.cc:212