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/net-device.h"
30 #include "ns3/node.h"
31 #include "spectrum-wifi-phy.h"
34 #include "wifi-utils.h"
35 #include "wifi-ppdu.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;
96 }
97 
98 void
100 {
101  NS_LOG_FUNCTION (this);
103  // This connection is deferred until frequency and channel width are set
105  {
107  }
108  else
109  {
110  NS_FATAL_ERROR ("SpectrumWifiPhy misses channel and WifiSpectrumPhyInterface objects at initialization time");
111  }
112 }
113 
116 {
117  NS_LOG_FUNCTION (this);
118  if (m_rxSpectrumModel)
119  {
120  return m_rxSpectrumModel;
121  }
122  else
123  {
124  if (GetFrequency () == 0)
125  {
126  NS_LOG_DEBUG ("Frequency is not set; returning 0");
127  return 0;
128  }
129  else
130  {
131  uint16_t channelWidth = GetChannelWidth ();
132  NS_LOG_DEBUG ("Creating spectrum model from frequency/width pair of (" << GetFrequency () << ", " << channelWidth << ")");
135  }
136  }
137  return m_rxSpectrumModel;
138 }
139 
140 void
142 {
143  NS_LOG_FUNCTION (this);
144  uint16_t channelWidth = GetChannelWidth ();
146  if (channelWidth < 20)
147  {
148  WifiSpectrumBand band = GetBand (channelWidth);
149  m_interference.AddBand (band);
150  }
151  else
152  {
153  for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
154  {
155  for (uint8_t i = 0; i < (channelWidth / bw); ++i)
156  {
157  m_interference.AddBand (GetBand (bw, i));
158  }
159  }
160  }
162  {
163  for (unsigned int type = 0; type < 7; type++)
164  {
165  HeRu::RuType ruType = static_cast <HeRu::RuType> (type);
166  for (std::size_t index = 1; index <= HeRu::GetNRus (channelWidth, ruType); index++)
167  {
168  HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (channelWidth, ruType, index);
169  HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second);
170  WifiSpectrumBand band = ConvertHeRuSubcarriers (channelWidth, range);
171  m_interference.AddBand (band);
172  }
173  }
174  }
175 }
176 
179 {
180  return m_channel;
181 }
182 
183 void
185 {
186  m_channel = channel;
187 }
188 
189 void
191 {
192  NS_LOG_FUNCTION (this);
193  NS_ASSERT_MSG (IsInitialized (), "Executing method before run-time");
194  uint16_t channelWidth = GetChannelWidth ();
195  NS_LOG_DEBUG ("Run-time change of spectrum model from frequency/width pair of (" << GetFrequency () << ", " << channelWidth << ")");
196  // Replace existing spectrum model with new one, and must call AddRx ()
197  // on the SpectrumChannel to provide this new spectrum model to it
201 }
202 
203 void
205 {
206  NS_LOG_FUNCTION (this << +nch);
208  if (IsInitialized ())
209  {
211  }
212 }
213 
214 void
216 {
217  NS_LOG_FUNCTION (this << freq);
218  WifiPhy::SetFrequency (freq);
219  if (IsInitialized ())
220  {
222  }
223 }
224 
225 void
226 SpectrumWifiPhy::SetChannelWidth (uint16_t channelwidth)
227 {
228  NS_LOG_FUNCTION (this << channelwidth);
229  WifiPhy::SetChannelWidth (channelwidth);
230  if (IsInitialized ())
231  {
233  }
234 }
235 
236 void
238 {
239  NS_LOG_FUNCTION (this << standard << band);
240  WifiPhy::ConfigureStandardAndBand (standard, band);
241  if (IsInitialized ())
242  {
244  }
245 }
246 
247 void
249 {
250  NS_LOG_FUNCTION (this << rxParams);
251  Time rxDuration = rxParams->duration;
252  Ptr<SpectrumValue> receivedSignalPsd = rxParams->psd;
253  NS_LOG_DEBUG ("Received signal with PSD " << *receivedSignalPsd << " and duration " << rxDuration.As (Time::NS));
254  uint32_t senderNodeId = 0;
255  if (rxParams->txPhy)
256  {
257  senderNodeId = rxParams->txPhy->GetDevice ()->GetNode ()->GetId ();
258  }
259  NS_LOG_DEBUG ("Received signal from " << senderNodeId << " with unfiltered power " << WToDbm (Integral (*receivedSignalPsd)) << " dBm");
260 
261  // Integrate over our receive bandwidth (i.e., all that the receive
262  // spectral mask representing our filtering allows) to find the
263  // total energy apparent to the "demodulator".
264  // This is done per 20 MHz channel band.
265  uint16_t channelWidth = GetChannelWidth ();
266  double totalRxPowerW = 0;
267  RxPowerWattPerChannelBand rxPowerW;
268 
269  if ((channelWidth == 5) || (channelWidth == 10))
270  {
271  WifiSpectrumBand filteredBand = GetBand (channelWidth);
272  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand);
273  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
274  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << Integral (filteredSignal));
275  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
276  totalRxPowerW += rxPowerPerBandW;
277  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
278  NS_LOG_DEBUG ("Signal power received after antenna gain for " << channelWidth << " MHz channel: " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
279  }
280 
281  for (uint16_t bw = 160; bw > 20; bw = bw / 2) //20 MHz is handled apart since the totalRxPowerW is computed through it
282  {
283  for (uint8_t i = 0; i < (channelWidth / bw); i++)
284  {
285  NS_ASSERT (channelWidth >= bw);
286  WifiSpectrumBand filteredBand = GetBand (bw, i);
287  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand);
288  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
289  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for" << bw << " MHz channel band " << +i << ": " << Integral (filteredSignal));
290  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
291  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
292  NS_LOG_DEBUG ("Signal power received after antenna gain for" << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
293  }
294  }
295 
296 
297  for (uint8_t i = 0; i < (channelWidth / 20); i++)
298  {
299  WifiSpectrumBand filteredBand = GetBand (20, i);
300  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), filteredBand);
301  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
302  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for 20 MHz channel band " << +i << ": " << Integral (filteredSignal));
303  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
304  totalRxPowerW += rxPowerPerBandW;
305  rxPowerW.insert ({filteredBand, rxPowerPerBandW});
306  NS_LOG_DEBUG ("Signal power received after antenna gain for 20 MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
307  }
308 
310  {
311  for (unsigned int type = 0; type < 7; type++)
312  {
313  HeRu::RuType ruType = static_cast <HeRu::RuType> (type);
314  for (std::size_t index = 1; index <= HeRu::GetNRus (channelWidth, ruType); index++)
315  {
316  HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (channelWidth, ruType, index);
317  HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second);
318  WifiSpectrumBand band = ConvertHeRuSubcarriers (channelWidth, range);
320  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
321  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for RU with type " << ruType << " and range (" << range.first << "; " << range.second << ") -> (" << band.first << "; " << band.second << "): " << Integral (filteredSignal));
322  double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ());
323  NS_LOG_DEBUG ("Signal power received after antenna gain for RU with type " << ruType << " and range (" << range.first << "; " << range.second << ") -> (" << band.first << "; " << band.second << "): " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)");
324  rxPowerW.insert ({band, rxPowerPerBandW});
325  }
326  }
327  }
328 
329  NS_LOG_DEBUG ("Total signal power received after antenna gain: " << totalRxPowerW << " W (" << WToDbm (totalRxPowerW) << " dBm)");
330 
331  Ptr<WifiSpectrumSignalParameters> wifiRxParams = DynamicCast<WifiSpectrumSignalParameters> (rxParams);
332 
333  // Log the signal arrival to the trace source
334  m_signalCb (wifiRxParams ? true : false, senderNodeId, WToDbm (totalRxPowerW), rxDuration);
335 
336  // Do no further processing if signal is too weak
337  // Current implementation assumes constant RX power over the PPDU duration
338  if (WToDbm (totalRxPowerW) < GetRxSensitivity ())
339  {
340  NS_LOG_INFO ("Received signal too weak to process: " << WToDbm (totalRxPowerW) << " dBm");
341  return;
342  }
343  if (wifiRxParams == 0)
344  {
345  NS_LOG_INFO ("Received non Wi-Fi signal");
346  m_interference.AddForeignSignal (rxDuration, rxPowerW);
348  return;
349  }
350  if (wifiRxParams && m_disableWifiReception)
351  {
352  NS_LOG_INFO ("Received Wi-Fi signal but blocked from syncing");
353  m_interference.AddForeignSignal (rxDuration, rxPowerW);
355  return;
356  }
357 
358  NS_LOG_INFO ("Received Wi-Fi signal");
359  Ptr<WifiPpdu> ppdu = Copy (wifiRxParams->ppdu);
360  StartReceivePreamble (ppdu, rxPowerW);
361 }
362 
365 {
366  return m_antenna;
367 }
368 
369 void
371 {
372  NS_LOG_FUNCTION (this << a);
373  m_antenna = a;
374 }
375 
376 void
378 {
379  NS_LOG_FUNCTION (this << device);
380  m_wifiSpectrumPhyInterface = CreateObject<WifiSpectrumPhyInterface> ();
381  m_wifiSpectrumPhyInterface->SetSpectrumWifiPhy (this);
382  m_wifiSpectrumPhyInterface->SetDevice (device);
383 }
384 
386 SpectrumWifiPhy::GetTxPowerSpectralDensity (uint16_t centerFrequency, uint16_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const
387 {
388  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
390  switch (modulationClass)
391  {
392  case WIFI_MOD_CLASS_OFDM:
394  v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
396  break;
397  case WIFI_MOD_CLASS_DSSS:
399  NS_ABORT_MSG_IF (channelWidth != 22, "Invalid channel width for DSSS");
400  v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (centerFrequency, txPowerW, GetGuardBandwidth (channelWidth));
401  break;
402  case WIFI_MOD_CLASS_HT:
403  case WIFI_MOD_CLASS_VHT:
404  v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
406  break;
407  case WIFI_MOD_CLASS_HE:
408  v = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth (channelWidth),
410  break;
411  default:
412  NS_FATAL_ERROR ("modulation class unknown: " << modulationClass);
413  break;
414  }
415  return v;
416 }
417 
418 uint16_t
420 {
421  NS_LOG_FUNCTION (this << txVector);
422  uint16_t centerFrequencyForSupportedWidth = GetFrequency ();
423  uint16_t supportedWidth = GetChannelWidth ();
424  uint16_t currentWidth = txVector.GetChannelWidth ();
425  if (currentWidth != supportedWidth)
426  {
427  uint16_t startingFrequency = centerFrequencyForSupportedWidth - (supportedWidth / 2);
428  return startingFrequency + (currentWidth / 2); // primary channel is in the lower part (for the time being)
429  }
430  return centerFrequencyForSupportedWidth;
431 }
432 
433 void
435 {
436  NS_LOG_FUNCTION (this << ppdu);
437  WifiTxVector txVector = ppdu->GetTxVector ();
438  double txPowerDbm = GetTxPowerForTransmission (txVector) + GetTxGain ();
439  NS_LOG_DEBUG ("Start transmission: signal power before antenna gain=" << txPowerDbm << "dBm");
440  double txPowerWatts = DbmToW (txPowerDbm);
441  Ptr<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetCenterFrequencyForChannelWidth (txVector), txVector.GetChannelWidth (), txPowerWatts, ppdu->GetModulation ());
442  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
443  txParams->duration = ppdu->GetTxDuration ();
444  txParams->psd = txPowerSpectrum;
445  NS_ASSERT_MSG (m_wifiSpectrumPhyInterface, "SpectrumPhy() is not set; maybe forgot to call CreateWifiSpectrumPhyInterface?");
446  txParams->txPhy = m_wifiSpectrumPhyInterface->GetObject<SpectrumPhy> ();
447  txParams->txAntenna = m_antenna;
448  txParams->ppdu = ppdu;
449  NS_LOG_DEBUG ("Starting transmission with power " << WToDbm (txPowerWatts) << " dBm on channel " << +GetChannelNumber ());
450  NS_LOG_DEBUG ("Starting transmission with integrated spectrum power " << WToDbm (Integral (*txPowerSpectrum)) << " dBm; spectrum model Uid: " << txPowerSpectrum->GetSpectrumModel ()->GetUid ());
451  m_channel->StartTx (txParams);
452 }
453 
454 uint32_t
456 {
457  uint32_t bandBandwidth = 0;
458  switch (GetPhyStandard ())
459  {
466  // Use OFDM subcarrier width of 312.5 KHz as band granularity
467  bandBandwidth = 312500;
468  break;
470  if (GetChannelWidth () == 5)
471  {
472  // Use OFDM subcarrier width of 78.125 KHz as band granularity
473  bandBandwidth = 78125;
474  }
475  else
476  {
477  // Use OFDM subcarrier width of 156.25 KHz as band granularity
478  bandBandwidth = 156250;
479  }
480  break;
482  // Use OFDM subcarrier width of 78.125 KHz as band granularity
483  bandBandwidth = 78125;
484  break;
485  default:
486  NS_FATAL_ERROR ("Standard unknown: " << GetPhyStandard ());
487  break;
488  }
489  return bandBandwidth;
490 }
491 
492 uint16_t
493 SpectrumWifiPhy::GetGuardBandwidth (uint16_t currentChannelWidth) const
494 {
495  uint16_t guardBandwidth = 0;
496  if (currentChannelWidth == 22)
497  {
498  //handle case of DSSS transmission
499  guardBandwidth = 10;
500  }
501  else
502  {
503  //In order to properly model out of band transmissions for OFDM, the guard
504  //band has been configured so as to expand the modeled spectrum up to the
505  //outermost referenced point in "Transmit spectrum mask" sections' PSDs of
506  //each PHY specification of 802.11-2016 standard. It thus ultimately corresponds
507  //to the currently considered channel bandwidth (which can be different from
508  //supported channel width).
509  guardBandwidth = currentChannelWidth;
510  }
511  return guardBandwidth;
512 }
513 
515 SpectrumWifiPhy::GetBand (uint16_t bandWidth, uint8_t bandIndex)
516 {
517  uint16_t channelWidth = GetChannelWidth ();
518  uint32_t bandBandwidth = GetBandBandwidth ();
519  size_t numBandsInChannel = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
520  size_t numBandsInBand = static_cast<size_t> (bandWidth * 1e6 / bandBandwidth);
521  if (numBandsInBand % 2 == 0)
522  {
523  numBandsInChannel += 1; // symmetry around center frequency
524  }
525  size_t totalNumBands = GetRxSpectrumModel ()->GetNumBands ();
526  NS_ASSERT_MSG ((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1), "Should have odd number of bands");
527  NS_ASSERT_MSG ((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
528  WifiSpectrumBand band;
529  band.first = ((totalNumBands - numBandsInChannel) / 2) + (bandIndex * numBandsInBand);
530  if (band.first >= totalNumBands / 2)
531  {
532  //step past DC
533  band.first += 1;
534  }
535  band.second = band.first + numBandsInBand - 1;
536  return band;
537 }
538 
541 {
542  WifiSpectrumBand convertedSubcarriers;
543  uint32_t nGuardBands = static_cast<uint32_t> (((2 * GetGuardBandwidth (channelWidth) * 1e6) / GetBandBandwidth ()) + 0.5);
544  uint32_t centerFrequencyIndex = 0;
545  switch (channelWidth)
546  {
547  case 20:
548  centerFrequencyIndex = (nGuardBands / 2) + 6 + 122;
549  break;
550  case 40:
551  centerFrequencyIndex = (nGuardBands / 2) + 12 + 244;
552  break;
553  case 80:
554  centerFrequencyIndex = (nGuardBands / 2) + 12 + 500;
555  break;
556  case 160:
557  centerFrequencyIndex = (nGuardBands / 2) + 12 + 1012;
558  break;
559  default:
560  NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
561  break;
562  }
563  convertedSubcarriers.first = centerFrequencyIndex + range.first;
564  convertedSubcarriers.second = centerFrequencyIndex + range.second;
565  return convertedSubcarriers;
566 }
567 
568 } //namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
size_t GetNumBands() const
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
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
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
#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
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:56
AttributeValue implementation for Boolean.
Definition: boolean.h:36
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:734
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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 StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand rxPowersW)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:2896
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:144
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:1373
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:546
#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
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM High Throughput (HT) (802...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
VHT PHY (Clause 22)
Definition: wifi-mode.h:62
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:50
static Ptr< SpectrumValue > CreateDsssTxPowerSpectralDensity(uint32_t centerFrequency, double txPowerW, uint16_t guardBandwidth)
Create a transmit power spectral density corresponding to DSSS.
void StartTx(Ptr< WifiPpdu > ppdu)
double GetTxPowerForTransmission(WifiTxVector txVector) const
Compute the transmit power (in dBm) for the next transmission.
Definition: wifi-phy.cc:4648
virtual void SetFrequency(uint16_t freq)
Definition: wifi-phy.cc:1439
void SetAntenna(const Ptr< AntennaModel > antenna)
virtual void SetChannelNumber(uint8_t id)
Set channel number.
SpectrumModelUid_t GetUid() const
void DoInitialize(void)
Initialize() implementation.
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:648
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.
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t channelWidth, HeRu::SubcarrierRange range) const
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1516
Ptr< SpectrumValue > GetTxPowerSpectralDensity(uint16_t centerFrequency, uint16_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
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.
HT PHY (Clause 20)
Definition: wifi-mode.h:60
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
void DoDispose(void)
Destructor 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 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.
static Ptr< SpectrumValue > CreateHeOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM High Efficiency (HE) (802...
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
virtual void SetFrequency(uint16_t freq)
WifiPhyStandard GetPhyStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1433
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
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:1496
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< const SpectrumModel > GetSpectrumModel() const
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1614
static SubcarrierGroup GetSubcarrierGroup(uint8_t bw, RuType ruType, std::size_t index)
Get the subcarrier group of the RU having the given index among all the RUs of the given type (number...
Definition: he-ru.cc:172
virtual void DoInitialize(void)
Initialize() implementation.
Definition: wifi-phy.cc:564
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1667
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:35
virtual void SetChannelWidth(uint16_t channelwidth)
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
#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:30
void UpdateInterferenceHelperBands(void)
This function is called to update the bands handled by the InterferenceHelper.
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
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
Pointer to InterferenceHelper.
Definition: wifi-phy.h:1802
virtual void SetChannelWidth(uint16_t channelWidth)
Definition: wifi-phy.cc:1502
#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
OFDM PHY (Clause 17)
Definition: wifi-mode.h:58
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
uint16_t GetCenterFrequencyForChannelWidth(WifiTxVector txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
Spectrum PHY interface.
void ResetSpectrumModel(void)
Perform run-time spectrum model change.
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:721
static std::size_t GetNRus(uint8_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:152
uint16_t GetChannelWidth(void) const
double m_txMaskInnerBandMinimumRejection
The minimum rejection (in dBr) for the inner band of the transmit spectrum mask.
Ptr< Channel > GetChannel(void) const
Return the Channel this WifiPhy is connected to.
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.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr.
Definition: ptr.h:536
void SwitchMaybeToCcaBusy(void)
Check if PHY state should move to CCA busy state based on current state of interference tracker...
Definition: wifi-phy.cc:4593
HE PHY (Clause 26)
Definition: wifi-mode.h:64
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
DSSS PHY (Clause 15)
Definition: wifi-mode.h:48
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...