A Discrete-Event Network Simulator
API
spectrum-wifi-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Ghada Badawy <gbadawy@gmail.com>
19 * Sébastien Deronne <sebastien.deronne@gmail.com>
20 *
21 * Ported from yans-wifi-phy.cc by several contributors starting
22 * with Nicola Baldo and Dean Armstrong
23 */
24
25#include "spectrum-wifi-phy.h"
26
27#include "interference-helper.h"
28#include "wifi-psdu.h"
31#include "wifi-utils.h"
32
33#include "ns3/boolean.h"
34#include "ns3/double.h"
35#include "ns3/log.h"
36#include "ns3/node.h"
37#include "ns3/simulator.h"
38#include "ns3/wifi-net-device.h"
39
40namespace ns3
41{
42
43NS_LOG_COMPONENT_DEFINE("SpectrumWifiPhy");
44
45NS_OBJECT_ENSURE_REGISTERED(SpectrumWifiPhy);
46
47TypeId
49{
50 static TypeId tid =
51 TypeId("ns3::SpectrumWifiPhy")
53 .SetGroupName("Wifi")
54 .AddConstructor<SpectrumWifiPhy>()
55 .AddAttribute("DisableWifiReception",
56 "Prevent Wi-Fi frame sync from ever happening",
57 BooleanValue(false),
60 .AddAttribute(
61 "TxMaskInnerBandMinimumRejection",
62 "Minimum rejection (dBr) for the inner band of the transmit spectrum mask",
63 DoubleValue(-20.0),
65 MakeDoubleChecker<double>())
66 .AddAttribute(
67 "TxMaskOuterBandMinimumRejection",
68 "Minimum rejection (dBr) for the outer band of the transmit spectrum mask",
69 DoubleValue(-28.0),
71 MakeDoubleChecker<double>())
72 .AddAttribute(
73 "TxMaskOuterBandMaximumRejection",
74 "Maximum rejection (dBr) for the outer band of the transmit spectrum mask",
75 DoubleValue(-40.0),
77 MakeDoubleChecker<double>())
78 .AddTraceSource("SignalArrival",
79 "Signal arrival",
81 "ns3::SpectrumWifiPhy::SignalArrivalCallback");
82 return tid;
83}
84
86{
87 NS_LOG_FUNCTION(this);
88}
89
91{
92 NS_LOG_FUNCTION(this);
93}
94
95void
97{
98 NS_LOG_FUNCTION(this);
99 m_channel = nullptr;
101 m_antenna = nullptr;
102 m_rxSpectrumModel = nullptr;
103 m_ruBands.clear();
105}
106
107void
109{
110 NS_LOG_FUNCTION(this);
112 // This connection is deferred until frequency and channel width are set
114 {
116 }
117 else
118 {
119 NS_FATAL_ERROR("SpectrumWifiPhy misses channel and WifiSpectrumPhyInterface objects at "
120 "initialization time");
121 }
122}
123
126{
127 NS_LOG_FUNCTION(this);
129 {
130 return m_rxSpectrumModel;
131 }
132 else
133 {
134 if (GetFrequency() == 0)
135 {
136 NS_LOG_DEBUG("Frequency is not set; returning 0");
137 return nullptr;
138 }
139 else
140 {
141 uint16_t channelWidth = GetChannelWidth();
142 NS_LOG_DEBUG("Creating spectrum model from frequency/width pair of ("
143 << GetFrequency() << ", " << channelWidth << ")");
146 channelWidth,
148 GetGuardBandwidth(channelWidth));
150 }
151 }
152 return m_rxSpectrumModel;
153}
154
155void
157{
158 NS_LOG_FUNCTION(this);
159 uint16_t channelWidth = GetChannelWidth();
160 m_interference->RemoveBands();
161 if (channelWidth < 20)
162 {
163 WifiSpectrumBand band = GetBand(channelWidth);
164 m_interference->AddBand(band);
165 }
166 else
167 {
168 for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
169 {
170 for (uint32_t i = 0; i < (channelWidth / bw); ++i)
171 {
172 m_interference->AddBand(GetBand(bw, i));
173 }
174 }
175 }
177 {
178 // For a given RU type, some RUs over a channel occupy the same tones as
179 // the corresponding RUs over a subchannel, while some others not. For instance,
180 // the first nine 26-tone RUs over an 80 MHz channel occupy the same tones as
181 // the first nine 26-tone RUs over the lowest 40 MHz subchannel. Therefore, we
182 // need to store all the bands in a set (which removes duplicates) and then
183 // pass the elements in the set to AddBand (to which we cannot pass duplicates)
184 if (m_ruBands[channelWidth].empty())
185 {
186 for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
187 {
188 for (uint32_t i = 0; i < (channelWidth / bw); ++i)
189 {
190 for (uint32_t type = 0; type < 7; type++)
191 {
192 HeRu::RuType ruType = static_cast<HeRu::RuType>(type);
193 std::size_t nRus = HeRu::GetNRus(bw, ruType);
194 for (std::size_t phyIndex = 1; phyIndex <= nRus; phyIndex++)
195 {
197 HeRu::GetSubcarrierGroup(bw, ruType, phyIndex);
199 std::make_pair(group.front().first, group.back().second);
200 WifiSpectrumBand band =
202 GetGuardBandwidth(channelWidth),
203 range,
204 i);
205 std::size_t index =
206 (bw == 160 && phyIndex > nRus / 2 ? phyIndex - nRus / 2 : phyIndex);
207 bool primary80IsLower80 =
209 bool primary80 = (bw < 160 || ruType == HeRu::RU_2x996_TONE ||
210 (primary80IsLower80 && phyIndex <= nRus / 2) ||
211 (!primary80IsLower80 && phyIndex > nRus / 2));
212 HeRu::RuSpec ru(ruType, index, primary80);
213 ru.SetPhyIndex(bw, GetOperatingChannel().GetPrimaryChannelIndex(20));
214 NS_ABORT_IF(ru.GetPhyIndex() != phyIndex);
215 m_ruBands[channelWidth].insert({band, ru});
216 }
217 }
218 }
219 }
220 }
221 for (const auto& bandRuPair : m_ruBands[channelWidth])
222 {
223 m_interference->AddBand(bandRuPair.first);
224 }
225 }
226}
227
230{
231 return m_channel;
232}
233
234void
236{
238}
239
240void
242{
243 NS_LOG_FUNCTION(this);
244 NS_ASSERT_MSG(IsInitialized(), "Executing method before run-time");
245 uint16_t channelWidth = GetChannelWidth();
246 NS_LOG_DEBUG("Run-time change of spectrum model from frequency/width pair of ("
247 << GetFrequency() << ", " << channelWidth << ")");
248 // Replace existing spectrum model with new one, and must call AddRx ()
249 // on the SpectrumChannel to provide this new spectrum model to it
251 channelWidth,
253 GetGuardBandwidth(channelWidth));
256}
257
258void
260{
261 NS_LOG_FUNCTION(this);
263 if (IsInitialized())
264 {
266 }
267}
268
269void
271{
272 NS_LOG_FUNCTION(this << rxParams);
273 Time rxDuration = rxParams->duration;
274 Ptr<SpectrumValue> receivedSignalPsd = rxParams->psd;
275 NS_LOG_DEBUG("Received signal with PSD " << *receivedSignalPsd << " and duration "
276 << rxDuration.As(Time::NS));
277 uint32_t senderNodeId = 0;
278 if (rxParams->txPhy)
279 {
280 senderNodeId = rxParams->txPhy->GetDevice()->GetNode()->GetId();
281 }
282 NS_LOG_DEBUG("Received signal from " << senderNodeId << " with unfiltered power "
283 << WToDbm(Integral(*receivedSignalPsd)) << " dBm");
284
285 // Integrate over our receive bandwidth (i.e., all that the receive
286 // spectral mask representing our filtering allows) to find the
287 // total energy apparent to the "demodulator".
288 // This is done per 20 MHz channel band.
289 uint16_t channelWidth = GetChannelWidth();
290 double totalRxPowerW = 0;
292
293 if ((channelWidth == 5) || (channelWidth == 10))
294 {
295 WifiSpectrumBand filteredBand = GetBand(channelWidth);
296 double rxPowerPerBandW =
297 WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand);
298 NS_LOG_DEBUG("Signal power received (watts) before antenna gain: " << rxPowerPerBandW);
299 rxPowerPerBandW *= DbToRatio(GetRxGain());
300 totalRxPowerW += rxPowerPerBandW;
301 rxPowerW.insert({filteredBand, rxPowerPerBandW});
302 NS_LOG_DEBUG("Signal power received after antenna gain for "
303 << channelWidth << " MHz channel: " << rxPowerPerBandW << " W ("
304 << WToDbm(rxPowerPerBandW) << " dBm)");
305 }
306
307 // 20 MHz is handled apart since the totalRxPowerW is computed through it
308 for (uint16_t bw = 160; bw > 20; bw = bw / 2)
309 {
310 for (uint32_t i = 0; i < (channelWidth / bw); i++)
311 {
312 NS_ASSERT(channelWidth >= bw);
313 WifiSpectrumBand filteredBand = GetBand(bw, i);
314 double rxPowerPerBandW =
315 WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand);
316 NS_LOG_DEBUG("Signal power received (watts) before antenna gain for "
317 << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW);
318 rxPowerPerBandW *= DbToRatio(GetRxGain());
319 rxPowerW.insert({filteredBand, rxPowerPerBandW});
320 NS_LOG_DEBUG("Signal power received after antenna gain for "
321 << bw << " MHz channel band " << +i << ": " << rxPowerPerBandW << " W ("
322 << WToDbm(rxPowerPerBandW) << " dBm)");
323 }
324 }
325
326 for (uint32_t i = 0; i < (channelWidth / 20); i++)
327 {
328 WifiSpectrumBand filteredBand = GetBand(20, i);
329 double rxPowerPerBandW =
330 WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, filteredBand);
331 NS_LOG_DEBUG("Signal power received (watts) before antenna gain for 20 MHz channel band "
332 << +i << ": " << rxPowerPerBandW);
333 rxPowerPerBandW *= DbToRatio(GetRxGain());
334 totalRxPowerW += rxPowerPerBandW;
335 rxPowerW.insert({filteredBand, rxPowerPerBandW});
336 NS_LOG_DEBUG("Signal power received after antenna gain for 20 MHz channel band "
337 << +i << ": " << rxPowerPerBandW << " W (" << WToDbm(rxPowerPerBandW)
338 << " dBm)");
339 }
340
342 {
343 NS_ASSERT(!m_ruBands[channelWidth].empty());
344 for (const auto& bandRuPair : m_ruBands[channelWidth])
345 {
346 double rxPowerPerBandW =
347 WifiSpectrumValueHelper::GetBandPowerW(receivedSignalPsd, bandRuPair.first);
348 NS_LOG_DEBUG("Signal power received (watts) before antenna gain for RU with type "
349 << bandRuPair.second.GetRuType() << " and index "
350 << bandRuPair.second.GetIndex() << " -> (" << bandRuPair.first.first
351 << "; " << bandRuPair.first.second << "): " << rxPowerPerBandW);
352 rxPowerPerBandW *= DbToRatio(GetRxGain());
353 NS_LOG_DEBUG("Signal power received after antenna gain for RU with type "
354 << bandRuPair.second.GetRuType() << " and index "
355 << bandRuPair.second.GetIndex() << " -> (" << bandRuPair.first.first
356 << "; " << bandRuPair.first.second << "): " << rxPowerPerBandW << " W ("
357 << WToDbm(rxPowerPerBandW) << " dBm)");
358 rxPowerW.insert({bandRuPair.first, rxPowerPerBandW});
359 }
360 }
361
362 NS_LOG_DEBUG("Total signal power received after antenna gain: "
363 << totalRxPowerW << " W (" << WToDbm(totalRxPowerW) << " dBm)");
364
366 DynamicCast<WifiSpectrumSignalParameters>(rxParams);
367
368 // Log the signal arrival to the trace source
369 m_signalCb(bool(wifiRxParams), senderNodeId, WToDbm(totalRxPowerW), rxDuration);
370
371 if (!wifiRxParams)
372 {
373 NS_LOG_INFO("Received non Wi-Fi signal");
374 m_interference->AddForeignSignal(rxDuration, rxPowerW);
375 SwitchMaybeToCcaBusy(nullptr);
376 return;
377 }
378 if (wifiRxParams && m_disableWifiReception)
379 {
380 NS_LOG_INFO("Received Wi-Fi signal but blocked from syncing");
381 m_interference->AddForeignSignal(rxDuration, rxPowerW);
382 SwitchMaybeToCcaBusy(nullptr);
383 return;
384 }
385 // Do no further processing if signal is too weak
386 // Current implementation assumes constant RX power over the PPDU duration
387 // Compare received TX power per MHz to normalized RX sensitivity
388 uint16_t txWidth = wifiRxParams->ppdu->GetTransmissionChannelWidth();
389 if (totalRxPowerW < DbmToW(GetRxSensitivity()) * (txWidth / 20.0))
390 {
391 NS_LOG_INFO("Received signal too weak to process: " << WToDbm(totalRxPowerW) << " dBm");
392 m_interference->Add(wifiRxParams->ppdu,
393 wifiRxParams->ppdu->GetTxVector(),
394 rxDuration,
395 rxPowerW);
396 SwitchMaybeToCcaBusy(nullptr);
397 return;
398 }
399
400 // Unless we are receiving a TB PPDU, do not sync with this signal if the PPDU
401 // does not overlap with the receiver's primary20 channel
402 if (wifiRxParams->txPhy)
403 {
404 // if the channel width is a multiple of 20 MHz, then we consider the primary20 channel
405 uint16_t width = (GetChannelWidth() % 20 == 0 ? 20 : GetChannelWidth());
406 uint16_t p20MinFreq =
408 uint16_t p20MaxFreq =
410
411 if (!wifiRxParams->ppdu->CanBeReceived(p20MinFreq, p20MaxFreq))
412 {
413 NS_LOG_INFO("Cannot receive the PPDU, consider it as interference");
414 m_interference->Add(wifiRxParams->ppdu,
415 wifiRxParams->ppdu->GetTxVector(),
416 rxDuration,
417 rxPowerW);
418 SwitchMaybeToCcaBusy(wifiRxParams->ppdu);
419 return;
420 }
421 }
422
423 NS_LOG_INFO("Received Wi-Fi signal");
424 Ptr<WifiPpdu> ppdu = wifiRxParams->ppdu->Copy();
425 StartReceivePreamble(ppdu, rxPowerW, rxDuration);
426}
427
430{
431 return m_antenna;
432}
433
434void
436{
437 NS_LOG_FUNCTION(this << a);
438 m_antenna = a;
439}
440
441void
443{
444 NS_LOG_FUNCTION(this << device);
445 m_wifiSpectrumPhyInterface = CreateObject<WifiSpectrumPhyInterface>();
446 m_wifiSpectrumPhyInterface->SetSpectrumWifiPhy(this);
447 m_wifiSpectrumPhyInterface->SetDevice(device);
448}
449
450void
452{
453 NS_LOG_FUNCTION(this << ppdu);
454 GetPhyEntity(ppdu->GetModulation())->StartTx(ppdu, txVector);
455}
456
457void
459{
460 NS_LOG_FUNCTION(this << txParams);
461
462 // Finish configuration
464 "SpectrumPhy() is not set; maybe forgot to call CreateWifiSpectrumPhyInterface?");
465 txParams->txPhy = m_wifiSpectrumPhyInterface->GetObject<SpectrumPhy>();
466 txParams->txAntenna = m_antenna;
467
468 m_channel->StartTx(txParams);
469}
470
473{
474 uint32_t bandBandwidth = 0;
475 switch (GetStandard())
476 {
482 // Use OFDM subcarrier width of 312.5 KHz as band granularity
483 bandBandwidth = 312500;
484 break;
486 if (GetChannelWidth() == 5)
487 {
488 // Use OFDM subcarrier width of 78.125 KHz as band granularity
489 bandBandwidth = 78125;
490 }
491 else
492 {
493 // Use OFDM subcarrier width of 156.25 KHz as band granularity
494 bandBandwidth = 156250;
495 }
496 break;
499 // Use OFDM subcarrier width of 78.125 KHz as band granularity
500 bandBandwidth = 78125;
501 break;
502 default:
503 NS_FATAL_ERROR("Standard unknown: " << GetStandard());
504 break;
505 }
506 return bandBandwidth;
507}
508
509uint16_t
510SpectrumWifiPhy::GetGuardBandwidth(uint16_t currentChannelWidth) const
511{
512 uint16_t guardBandwidth = 0;
513 if (currentChannelWidth == 22)
514 {
515 // handle case of DSSS transmission
516 guardBandwidth = 10;
517 }
518 else
519 {
520 // In order to properly model out of band transmissions for OFDM, the guard
521 // band has been configured so as to expand the modeled spectrum up to the
522 // outermost referenced point in "Transmit spectrum mask" sections' PSDs of
523 // each PHY specification of 802.11-2016 standard. It thus ultimately corresponds
524 // to the currently considered channel bandwidth (which can be different from
525 // supported channel width).
526 guardBandwidth = currentChannelWidth;
527 }
528 return guardBandwidth;
529}
530
532SpectrumWifiPhy::GetBand(uint16_t bandWidth, uint8_t bandIndex)
533{
534 uint16_t channelWidth = GetChannelWidth();
535 uint32_t bandBandwidth = GetBandBandwidth();
536 size_t numBandsInChannel = static_cast<size_t>(channelWidth * 1e6 / bandBandwidth);
537 size_t numBandsInBand = static_cast<size_t>(bandWidth * 1e6 / bandBandwidth);
538 if (numBandsInBand % 2 == 0)
539 {
540 numBandsInChannel += 1; // symmetry around center frequency
541 }
542 size_t totalNumBands = GetRxSpectrumModel()->GetNumBands();
543 NS_ASSERT_MSG((numBandsInChannel % 2 == 1) && (totalNumBands % 2 == 1),
544 "Should have odd number of bands");
545 NS_ASSERT_MSG((bandIndex * bandWidth) < channelWidth, "Band index is out of bound");
546 WifiSpectrumBand band;
547 band.first = ((totalNumBands - numBandsInChannel) / 2) + (bandIndex * numBandsInBand);
548 band.second = band.first + numBandsInBand - 1;
549 if (band.first >= totalNumBands / 2)
550 {
551 // step past DC
552 band.first += 1;
553 }
554 return band;
555}
556
559 uint16_t guardBandwidth,
561 uint8_t bandIndex) const
562{
563 WifiSpectrumBand convertedSubcarriers;
564 uint32_t nGuardBands =
565 static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / GetBandBandwidth()) + 0.5);
566 uint32_t centerFrequencyIndex = 0;
567 switch (bandWidth)
568 {
569 case 20:
570 centerFrequencyIndex = (nGuardBands / 2) + 6 + 122;
571 break;
572 case 40:
573 centerFrequencyIndex = (nGuardBands / 2) + 12 + 244;
574 break;
575 case 80:
576 centerFrequencyIndex = (nGuardBands / 2) + 12 + 500;
577 break;
578 case 160:
579 centerFrequencyIndex = (nGuardBands / 2) + 12 + 1012;
580 break;
581 default:
582 NS_FATAL_ERROR("ChannelWidth " << bandWidth << " unsupported");
583 break;
584 }
585
586 size_t numBandsInBand = static_cast<size_t>(bandWidth * 1e6 / GetBandBandwidth());
587 centerFrequencyIndex += numBandsInBand * bandIndex;
588
589 convertedSubcarriers.first = centerFrequencyIndex + range.first;
590 convertedSubcarriers.second = centerFrequencyIndex + range.second;
591 return convertedSubcarriers;
592}
593
594std::tuple<double, double, double>
596{
597 return std::make_tuple(m_txMaskInnerBandMinimumRejection,
600}
601
602} // namespace ns3
AttributeValue implementation for Boolean.
Definition: boolean.h:37
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
RU Specification.
Definition: he-ru.h:66
std::size_t GetPhyIndex() const
Get the RU PHY index.
Definition: he-ru.cc:478
void SetPhyIndex(uint16_t bw, uint8_t p20Index)
Set the RU PHY index.
Definition: he-ru.cc:456
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:581
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:485
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition: he-ru.h:55
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition: he-ru.h:52
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
@ RU_2x996_TONE
Definition: he-ru.h:48
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
bool IsInitialized() const
Check if the object has been initialized.
Definition: object.cc:212
size_t GetNumBands() const
Abstract base class for Spectrum-aware PHY layers.
Definition: spectrum-phy.h:46
virtual Ptr< NetDevice > GetDevice() const =0
Get the associated NetDevice instance.
802.11 PHY layer model
TracedCallback< bool, uint32_t, double, Time > m_signalCb
Signal callback.
std::tuple< double, double, double > GetTxMaskRejectionParams() const override
void Transmit(Ptr< WifiSpectrumSignalParameters > txParams)
This function is sending the signal to the Spectrum channel after finishing the configuration of the ...
void DoInitialize() override
Initialize() implementation.
void StartTx(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector) override
Ptr< SpectrumChannel > m_channel
SpectrumChannel that this SpectrumWifiPhy is connected to.
Ptr< AntennaModel > m_antenna
antenna model
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...
void ResetSpectrumModel()
Perform run-time spectrum model change.
Ptr< Channel > GetChannel() const override
Return the Channel this WifiPhy is connected to.
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
Ptr< WifiSpectrumPhyInterface > m_wifiSpectrumPhyInterface
Spectrum PHY interface.
double m_txMaskInnerBandMinimumRejection
The minimum rejection (in dBr) for the inner band of the transmit spectrum mask.
double m_txMaskOuterBandMinimumRejection
The minimum rejection (in dBr) for the outer band of the transmit spectrum mask.
void DoDispose() override
Destructor implementation.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
uint32_t GetBandBandwidth() const
static TypeId GetTypeId()
Get the type ID.
void SetAntenna(const Ptr< AntennaModel > antenna)
double m_txMaskOuterBandMaximumRejection
The maximum rejection (in dBr) for the outer band of the transmit spectrum mask.
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const override
bool m_disableWifiReception
forces this PHY to fail to sync on any signal
Ptr< const SpectrumModel > GetRxSpectrumModel()
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the start band index and the stop band index for a given band.
Ptr< Object > GetAntenna() const
Get the antenna model used for reception.
void UpdateInterferenceHelperBands()
This function is called to update the bands handled by the InterferenceHelper.
Ptr< const SpectrumModel > m_rxSpectrumModel
receive spectrum model
void DoChannelSwitch() override
Actually switch channel based on the stored channel settings.
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
@ NS
nanosecond
Definition: nstime.h:119
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:417
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
802.11 PHY layer model
Definition: wifi-phy.h:51
uint16_t GetChannelWidth() const
Definition: wifi-phy.cc:980
double GetRxSensitivity() const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:454
uint16_t GetFrequency() const
Definition: wifi-phy.cc:968
double GetRxGain() const
Return the reception gain (dB).
Definition: wifi-phy.cc:556
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:685
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1758
void DoDispose() override
Destructor implementation.
Definition: wifi-phy.cc:367
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
Definition: wifi-phy.cc:1094
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition: wifi-phy.h:1173
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:956
void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
Definition: wifi-phy.cc:1998
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:962
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...
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
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.
static double GetBandPowerW(Ptr< SpectrumValue > psd, const WifiSpectrumBand &band)
Calculate the power of the specified band composed of uniformly-sized sub-bands.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Empty class, used as a default parent class for SimpleRefCount.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#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:86
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:86
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:76
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211be
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:46
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
double Integral(const SpectrumValue &arg)
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:40
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:78
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:34
channel
Definition: third.py:81
Time duration
The duration of the packet transmission.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.