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  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand);
308  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
309  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << Integral (filteredSignal));
310  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
311  totalRxPowerW += rxPowerPerBandW;
312  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
313  NS_LOG_DEBUG ("Signal power received after antenna gain for " << channelWidth << " MHz channel: " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
314  }
315 
316  for (uint16_t bw = 160; bw > 20; bw = bw / 2) //20 MHz is handled apart since the totalRxPowerW is computed through it
317  {
318  for (uint8_t i = 0; i < (channelWidth / bw); i++)
319  {
320  NS_ASSERT (channelWidth >= bw);
321  WifiSpectrumBand filteredBand = GetBand (bw, i);
322  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand);
323  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
324  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for " << bw << " MHz channel band " << +i << ": " << Integral (filteredSignal));
325  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
326  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
327  NS_LOG_DEBUG ("Signal power received after antenna gain for " << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
328  }
329  }
330 
331 
332  for (uint8_t i = 0; i < (channelWidth / 20); i++)
333  {
334  WifiSpectrumBand filteredBand = GetBand (20, i);
335  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand);
336  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
337  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for 20 MHz channel band " << +i << ": " << Integral (filteredSignal));
338  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
339  totalRxPowerW += rxPowerPerBandW;
340  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
341  NS_LOG_DEBUG ("Signal power received after antenna gain for 20 MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
342  }
343 
345  {
346  NS_ASSERT (!m_ruBands[channelWidth].empty ());
347  for (const auto& bandRuPair : m_ruBands[channelWidth])
348  {
349  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), bandRuPair.first);
350  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
351  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 << "): " << Integral (filteredSignal));
352  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
353  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)");
354  rxPowerW.insert ({bandRuPair.first, rxPowerPerBandW});
355  }
356  }
357 
358  NS_LOG_DEBUG ("Total signal power received after antenna gain: " << totalRxPowerW << " W (" << WToDbm (totalRxPowerW) << " dBm)");
359 
360  Ptr<WifiSpectrumSignalParameters> wifiRxParams = DynamicCast<WifiSpectrumSignalParameters> (rxParams);
361 
362  // Log the signal arrival to the trace source
363  m_signalCb (wifiRxParams ? true : false, senderNodeId, WToDbm (totalRxPowerW), rxDuration);
364 
365  if (wifiRxParams == 0)
366  {
367  NS_LOG_INFO ("Received non Wi-Fi signal");
368  m_interference.AddForeignSignal (rxDuration, rxPowerW);
370  return;
371  }
372  if (wifiRxParams && m_disableWifiReception)
373  {
374  NS_LOG_INFO ("Received Wi-Fi signal but blocked from syncing");
375  m_interference.AddForeignSignal (rxDuration, rxPowerW);
377  return;
378  }
379  // Do no further processing if signal is too weak
380  // Current implementation assumes constant RX power over the PPDU duration
381  // Compare received TX power per MHz to normalized RX sensitivity
382  uint16_t txWidth = wifiRxParams->ppdu->GetTransmissionChannelWidth ();
383  if (totalRxPowerW < DbmToW (GetRxSensitivity ()) * (txWidth / 20.0))
384  {
385  NS_LOG_INFO ("Received signal too weak to process: " << WToDbm (totalRxPowerW) << " dBm");
386  return;
387  }
388 
389  // Unless we are receiving a TB PPDU, do not sync with this signal if the PPDU
390  // does not overlap with the receiver's primary20 channel
391  if (wifiRxParams->txPhy != 0)
392  {
393  Ptr<WifiNetDevice> dev = DynamicCast<WifiNetDevice> (rxParams->txPhy->GetDevice ());
394  NS_ASSERT (dev != 0);
395  Ptr<WifiPhy> txPhy = dev->GetPhy ();
396  NS_ASSERT (txPhy != 0);
397  uint16_t txChannelWidth = wifiRxParams->ppdu->GetTxVector ().GetChannelWidth ();
398  uint16_t txCenterFreq = txPhy->GetOperatingChannel ().GetPrimaryChannelCenterFrequency (txChannelWidth);
399 
400  // if the channel width is a multiple of 20 MHz, then we consider the primary20 channel
401  uint16_t width = (GetChannelWidth () % 20 == 0 ? 20 : GetChannelWidth ());
402  uint16_t p20MinFreq =
404  uint16_t p20MaxFreq =
406 
407  if (!wifiRxParams->ppdu->CanBeReceived (txCenterFreq, p20MinFreq, p20MaxFreq))
408  {
409  NS_LOG_INFO ("Cannot receive the PPDU, consider it as interference");
410  m_interference.Add (wifiRxParams->ppdu, wifiRxParams->ppdu->GetTxVector (),
411  rxDuration, rxPowerW);
412  SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (wifiRxParams->ppdu));
413  return;
414  }
415  }
416 
417  NS_LOG_INFO ("Received Wi-Fi signal");
418  Ptr<WifiPpdu> ppdu = wifiRxParams->ppdu->Copy ();
419  StartReceivePreamble (ppdu, rxPowerW, rxDuration);
420 }
421 
424 {
425  return m_antenna;
426 }
427 
428 void
430 {
431  NS_LOG_FUNCTION (this << a);
432  m_antenna = a;
433 }
434 
435 void
437 {
438  NS_LOG_FUNCTION (this << device);
439  m_wifiSpectrumPhyInterface = CreateObject<WifiSpectrumPhyInterface> ();
440  m_wifiSpectrumPhyInterface->SetSpectrumWifiPhy (this);
441  m_wifiSpectrumPhyInterface->SetDevice (device);
442 }
443 
444 void
446 {
447  NS_LOG_FUNCTION (this << ppdu);
448  GetPhyEntity (ppdu->GetModulation ())->StartTx (ppdu);
449 }
450 
451 void
453 {
454  NS_LOG_FUNCTION (this << txParams);
455 
456  //Finish configuration
457  NS_ASSERT_MSG (m_wifiSpectrumPhyInterface, "SpectrumPhy() is not set; maybe forgot to call CreateWifiSpectrumPhyInterface?");
458  txParams->txPhy = m_wifiSpectrumPhyInterface->GetObject<SpectrumPhy> ();
459  txParams->txAntenna = m_antenna;
460 
461  m_channel->StartTx (txParams);
462 }
463 
464 uint32_t
466 {
467  uint32_t bandBandwidth = 0;
468  switch (GetPhyStandard ())
469  {
475  // Use OFDM subcarrier width of 312.5 KHz as band granularity
476  bandBandwidth = 312500;
477  break;
479  if (GetChannelWidth () == 5)
480  {
481  // Use OFDM subcarrier width of 78.125 KHz as band granularity
482  bandBandwidth = 78125;
483  }
484  else
485  {
486  // Use OFDM subcarrier width of 156.25 KHz as band granularity
487  bandBandwidth = 156250;
488  }
489  break;
491  // Use OFDM subcarrier width of 78.125 KHz as band granularity
492  bandBandwidth = 78125;
493  break;
494  default:
495  NS_FATAL_ERROR ("Standard unknown: " << GetPhyStandard ());
496  break;
497  }
498  return bandBandwidth;
499 }
500 
501 uint16_t
502 SpectrumWifiPhy::GetGuardBandwidth (uint16_t currentChannelWidth) const
503 {
504  uint16_t guardBandwidth = 0;
505  if (currentChannelWidth == 22)
506  {
507  //handle case of DSSS transmission
508  guardBandwidth = 10;
509  }
510  else
511  {
512  //In order to properly model out of band transmissions for OFDM, the guard
513  //band has been configured so as to expand the modeled spectrum up to the
514  //outermost referenced point in "Transmit spectrum mask" sections' PSDs of
515  //each PHY specification of 802.11-2016 standard. It thus ultimately corresponds
516  //to the currently considered channel bandwidth (which can be different from
517  //supported channel width).
518  guardBandwidth = currentChannelWidth;
519  }
520  return guardBandwidth;
521 }
522 
524 SpectrumWifiPhy::GetBand (uint16_t bandWidth, uint8_t bandIndex)
525 {
526  uint16_t channelWidth = GetChannelWidth ();
527  uint32_t bandBandwidth = GetBandBandwidth ();
528  size_t numBandsInChannel = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
529  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / bandBandwidth);
530  if (numBandsInBand % 2 == 0)
531  {
532  numBandsInChannel += 1; // symmetry around center frequency
533  }
534  size_t totalNumBands = GetRxSpectrumModel ()->GetNumBands ();
535  NS_ASSERT_MSG ((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1), "Should have odd number of bands");
536  NS_ASSERT_MSG ((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
537  WifiSpectrumBand band;
538  band.first = ((totalNumBands - numBandsInChannel) / 2) + (bandIndex * numBandsInBand);
539  if (band.first >= totalNumBands / 2)
540  {
541  //step past DC
542  band.first += 1;
543  }
544  band.second = band.first + numBandsInBand - 1;
545  return band;
546 }
547 
549 SpectrumWifiPhy::ConvertHeRuSubcarriers (uint16_t bandWidth, uint16_t guardBandwidth,
550  HeRu::SubcarrierRange range, uint8_t bandIndex) const
551 {
552  WifiSpectrumBand convertedSubcarriers;
553  uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / GetBandBandwidth ()) + 0.5);
554  uint32_t centerFrequencyIndex = 0;
555  switch (bandWidth)
556  {
557  case 20:
558  centerFrequencyIndex = (nGuardBands / 2) + 6 + 122;
559  break;
560  case 40:
561  centerFrequencyIndex = (nGuardBands / 2) + 12 + 244;
562  break;
563  case 80:
564  centerFrequencyIndex = (nGuardBands / 2) + 12 + 500;
565  break;
566  case 160:
567  centerFrequencyIndex = (nGuardBands / 2) + 12 + 1012;
568  break;
569  default:
570  NS_FATAL_ERROR ("ChannelWidth " << bandWidth << " unsupported");
571  break;
572  }
573 
574  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / GetBandBandwidth ());
575  centerFrequencyIndex += numBandsInBand * bandIndex;
576 
577  convertedSubcarriers.first = centerFrequencyIndex + range.first;
578  convertedSubcarriers.second = centerFrequencyIndex + range.second;
579  return convertedSubcarriers;
580 }
581 
582 std::tuple<double, double, double>
584 {
585  return std::make_tuple (m_txMaskInnerBandMinimumRejection,
588 }
589 
590 } //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.
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.
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
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.
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
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
static Ptr< SpectrumValue > CreateRfFilter(uint32_t centerFrequency, uint16_t totalChannelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth, WifiSpectrumBand band)
Create a spectral density corresponding to the RF filter.
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)
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1894
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
uint32_t GetBandBandwidth(void) const
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...
void AddForeignSignal(Time duration, RxPowerWattPerChannelBand rxPower)
Add a non-Wifi signal to interference helper.
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
Set of values corresponding to a given SpectrumModel.
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