A Discrete-Event Network Simulator
API
spectrum-wifi-phy-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015 University of Washington
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 
19 #include "ns3/test.h"
20 #include "ns3/constant-position-mobility-model.h"
21 #include "ns3/spectrum-wifi-helper.h"
22 #include "ns3/wifi-spectrum-value-helper.h"
23 #include "ns3/multi-model-spectrum-channel.h"
24 #include "ns3/spectrum-wifi-phy.h"
25 #include "ns3/nist-error-rate-model.h"
26 #include "ns3/wifi-mac-header.h"
27 #include "ns3/wifi-spectrum-signal-parameters.h"
28 #include "ns3/wifi-phy-listener.h"
29 #include "ns3/log.h"
30 #include "ns3/wifi-net-device.h"
31 #include "ns3/wifi-psdu.h"
32 #include "ns3/ofdm-ppdu.h"
33 #include "ns3/wifi-utils.h"
34 #include "ns3/he-phy.h" //includes OFDM PHY
35 
36 using namespace ns3;
37 
38 NS_LOG_COMPONENT_DEFINE ("SpectrumWifiPhyBasicTest");
39 
40 static const uint8_t CHANNEL_NUMBER = 36;
41 static const uint32_t FREQUENCY = 5180; // MHz
42 static const uint16_t CHANNEL_WIDTH = 20; // MHz
43 static const uint16_t GUARD_WIDTH = CHANNEL_WIDTH; // MHz (expanded to channel width to model spectrum mask)
44 
46 {
47 public:
50 };
51 
59 {
60 public:
67  SpectrumWifiPhyBasicTest (std::string name);
68  virtual ~SpectrumWifiPhyBasicTest ();
69 
70 protected:
71  void DoSetup (void) override;
72  void DoTeardown (void) override;
74 
79  Ptr<SpectrumSignalParameters> MakeSignal (double txPowerWatts);
84  void SendSignal (double txPowerWatts);
92  void SpectrumWifiPhyRxSuccess (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
93  WifiTxVector txVector, std::vector<bool> statusPerMpdu);
98  void SpectrumWifiPhyRxFailure (Ptr<WifiPsdu> psdu);
99  uint32_t m_count;
100 
101 private:
102  void DoRun (void) override;
103 
104  uint64_t m_uid;
105 };
106 
108  : SpectrumWifiPhyBasicTest ("SpectrumWifiPhy test case receives one packet")
109 {
110 }
111 
113  : TestCase (name),
114  m_count (0),
115  m_uid (0)
116 {
117 }
118 
119 // Make a Wi-Fi signal to inject directly to the StartRx() method
122 {
123  WifiTxVector txVector = WifiTxVector (OfdmPhy::GetOfdmRate6Mbps (), 0, WIFI_PREAMBLE_LONG, 800, 1, 1, 0, 20, false);
124 
125  Ptr<Packet> pkt = Create<Packet> (1000);
126  WifiMacHeader hdr;
127 
129  hdr.SetQosTid (0);
130 
131  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
132  Time txDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand ());
133 
134  Ptr<WifiPpdu> ppdu = Create<OfdmPpdu> (psdu, txVector, WIFI_PHY_BAND_5GHZ, m_uid++);
135 
136  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts, GUARD_WIDTH);
137  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
138  txParams->psd = txPowerSpectrum;
139  txParams->txPhy = 0;
140  txParams->duration = txDuration;
141  txParams->ppdu = ppdu;
142 
143  return txParams;
144 }
145 
146 // Make a Wi-Fi signal to inject directly to the StartRx() method
147 void
149 {
150  m_phy->StartRx (MakeSignal (txPowerWatts));
151 }
152 
153 void
155  WifiTxVector txVector, std::vector<bool> statusPerMpdu)
156 {
157  NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector);
158  m_count++;
159 }
160 
161 void
163 {
164  NS_LOG_FUNCTION (this << *psdu);
165  m_count++;
166 }
167 
169 {
170 }
171 
172 // Create necessary objects, and inject signals. Test that the expected
173 // number of packet receptions occur.
174 void
176 {
177  m_phy = CreateObject<SpectrumWifiPhy> ();
179  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
180  m_phy->SetErrorRateModel (error);
185 }
186 
187 void
189 {
190  m_phy->Dispose ();
191  m_phy = 0;
192 }
193 
194 // Test that the expected number of packet receptions occur.
195 void
197 {
198  double txPowerWatts = 0.010;
199  // Send packets spaced 1 second apart; all should be received
200  Simulator::Schedule (Seconds (1), &SpectrumWifiPhyBasicTest::SendSignal, this, txPowerWatts);
201  Simulator::Schedule (Seconds (2), &SpectrumWifiPhyBasicTest::SendSignal, this, txPowerWatts);
202  Simulator::Schedule (Seconds (3), &SpectrumWifiPhyBasicTest::SendSignal, this, txPowerWatts);
203  // Send packets spaced 1 microsecond second apart; none should be received (PHY header reception failure)
204  Simulator::Schedule (MicroSeconds (4000000), &SpectrumWifiPhyBasicTest::SendSignal, this, txPowerWatts);
205  Simulator::Schedule (MicroSeconds (4000001), &SpectrumWifiPhyBasicTest::SendSignal, this, txPowerWatts);
206  Simulator::Run ();
207  Simulator::Destroy ();
208 
209  NS_TEST_ASSERT_MSG_EQ (m_count, 3, "Didn't receive right number of packets");
210 }
211 
219 {
220 public:
226  : m_notifyRxStart (0),
227  m_notifyRxEndOk (0),
228  m_notifyRxEndError (0),
230  {
231  }
232  virtual ~TestPhyListener ()
233  {
234  }
235  void NotifyRxStart (Time duration) override
236  {
237  NS_LOG_FUNCTION (this << duration);
238  ++m_notifyRxStart;
239  }
240  void NotifyRxEndOk (void) override
241  {
242  NS_LOG_FUNCTION (this);
243  ++m_notifyRxEndOk;
244  }
245  void NotifyRxEndError (void) override
246  {
247  NS_LOG_FUNCTION (this);
249  }
250  void NotifyTxStart (Time duration, double txPowerDbm) override
251  {
252  NS_LOG_FUNCTION (this << duration << txPowerDbm);
253  }
254  void NotifyMaybeCcaBusyStart (Time duration) override
255  {
256  NS_LOG_FUNCTION (this);
258  }
259  void NotifySwitchingStart (Time duration) override
260  {
261  }
262  void NotifySleep (void) override
263  {
264  }
265  void NotifyOff (void) override
266  {
267  }
268  void NotifyWakeup (void) override
269  {
270  }
271  void NotifyOn (void) override
272  {
273  }
274  uint32_t m_notifyRxStart;
275  uint32_t m_notifyRxEndOk;
278 };
279 
287 {
288 public:
290  virtual ~SpectrumWifiPhyListenerTest ();
291 private:
292  void DoSetup (void) override;
293  void DoRun (void) override;
295 };
296 
298  : SpectrumWifiPhyBasicTest ("SpectrumWifiPhy test operation of WifiPhyListener")
299 {
300 }
301 
303 {
304 }
305 
306 void
308 {
312 }
313 
314 void
316 {
317  double txPowerWatts = 0.010;
318  Simulator::Schedule (Seconds (1), &SpectrumWifiPhyListenerTest::SendSignal, this, txPowerWatts);
319  Simulator::Run ();
320 
321  NS_TEST_ASSERT_MSG_EQ (m_count, 1, "Didn't receive right number of packets");
322  NS_TEST_ASSERT_MSG_EQ (m_listener->m_notifyMaybeCcaBusyStart, 2, "Didn't receive NotifyMaybeCcaBusyStart (once preamble is detected + prolonged by L-SIG reception, then switched to Rx by at the beginning of data)");
323  NS_TEST_ASSERT_MSG_EQ (m_listener->m_notifyRxStart, 1, "Didn't receive NotifyRxStart");
324  NS_TEST_ASSERT_MSG_EQ (m_listener->m_notifyRxEndOk, 1, "Didn't receive NotifyRxEnd");
325 
326  Simulator::Destroy ();
327  delete m_listener;
328 }
329 
337 {
338 public:
345  SpectrumWifiPhyFilterTest (std::string name);
346  virtual ~SpectrumWifiPhyFilterTest ();
347 
348 private:
349  void DoSetup (void) override;
350  void DoTeardown (void) override;
351  void DoRun (void) override;
352 
356  void RunOne ();
357 
361  void SendPpdu (void);
362 
369 
372 
373  uint16_t m_txChannelWidth;
374  uint16_t m_rxChannelWidth;
375 
376  std::set<WifiSpectrumBand> m_ruBands;
377 };
378 
380  : TestCase ("SpectrumWifiPhy test RX filters"),
381  m_txChannelWidth (20),
382  m_rxChannelWidth (20)
383 {
384 }
385 
387  : TestCase (name)
388 {
389 }
390 
391 void
393 {
394  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs0 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, m_txChannelWidth, false, false);
395  Ptr<Packet> pkt = Create<Packet> (1000);
396  WifiMacHeader hdr;
398  hdr.SetQosTid (0);
399  hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:01"));
400  hdr.SetSequenceNumber (1);
401  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
402  m_txPhy->Send (WifiConstPsduMap ({std::make_pair (SU_STA_ID, psdu)}), txVector);
403 }
404 
406 {
407  m_txPhy = 0;
408  m_rxPhy = 0;
409 }
410 
411 void
413 {
414  for (auto const& pair : rxPowersW)
415  {
416  NS_LOG_INFO ("band: (" << pair.first.first << ";" << pair.first.second << ") -> powerW=" << pair.second << " (" << WToDbm (pair.second) << " dBm)");
417  }
418 
419  size_t numBands = rxPowersW.size ();
420  size_t expectedNumBands = std::max (1, (m_rxChannelWidth / 20));
421  expectedNumBands += (m_rxChannelWidth / 40);
422  expectedNumBands += (m_rxChannelWidth / 80);
423  expectedNumBands += (m_rxChannelWidth / 160);
424  expectedNumBands += m_ruBands.size ();
425 
426  NS_TEST_ASSERT_MSG_EQ (numBands, expectedNumBands, "Total number of bands handled by the receiver is incorrect");
427 
428  uint16_t channelWidth = std::min (m_txChannelWidth, m_rxChannelWidth);
429  WifiSpectrumBand band = m_rxPhy->GetBand (channelWidth, 0);
430  auto it = rxPowersW.find (band);
431  NS_LOG_INFO ("powerW total band: " << it->second << " (" << WToDbm (it->second) << " dBm)");
432  int totalRxPower = static_cast<int> (WToDbm (it->second) + 0.5);
433  int expectedTotalRxPower;
435  {
436  //PHY sends at 16 dBm, and since there is no loss, this should be the total power at the receiver.
437  expectedTotalRxPower = 16;
438  }
439  else
440  {
441  //Only a part of the transmitted power is received
442  expectedTotalRxPower = 16 - static_cast<int> (RatioToDb (m_txChannelWidth / m_rxChannelWidth));
443  }
444  NS_TEST_ASSERT_MSG_EQ (totalRxPower, expectedTotalRxPower, "Total received power is not correct");
445 
446  if ((m_txChannelWidth <= m_rxChannelWidth) && (channelWidth >= 20))
447  {
448  band = m_rxPhy->GetBand (20, 0); //primary 20 MHz
449  it = rxPowersW.find (band);
450  NS_LOG_INFO ("powerW in primary 20 MHz channel: " << it->second << " (" << WToDbm (it->second) << " dBm)");
451  int rxPowerPrimaryChannel20 = static_cast<int> (WToDbm (it->second) + 0.5);
452  int expectedRxPowerPrimaryChannel20 = 16 - static_cast<int> (RatioToDb (channelWidth / 20));
453  NS_TEST_ASSERT_MSG_EQ (rxPowerPrimaryChannel20, expectedRxPowerPrimaryChannel20, "Received power in the primary 20 MHz band is not correct");
454  }
455 }
456 
457 void
459 {
460  //WifiHelper::EnableLogComponents ();
461  //LogComponentEnable ("SpectrumWifiPhyBasicTest", LOG_LEVEL_ALL);
462 
463  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
464  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
465  lossModel->SetFrequency (5.180e9);
466  spectrumChannel->AddPropagationLossModel (lossModel);
467  Ptr<ConstantSpeedPropagationDelayModel> delayModel = CreateObject<ConstantSpeedPropagationDelayModel> ();
468  spectrumChannel->SetPropagationDelayModel (delayModel);
469 
470  Ptr<Node> txNode = CreateObject<Node> ();
471  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
472  m_txPhy = CreateObject<ExtSpectrumWifiPhy> ();
475  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
476  m_txPhy->SetErrorRateModel (error);
477  m_txPhy->SetDevice (txDev);
478  m_txPhy->SetChannel (spectrumChannel);
479  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
480  m_txPhy->SetMobility (apMobility);
481  txDev->SetPhy (m_txPhy);
482  txNode->AggregateObject (apMobility);
483  txNode->AddDevice (txDev);
484 
485  Ptr<Node> rxNode = CreateObject<Node> ();
486  Ptr<WifiNetDevice> rxDev = CreateObject<WifiNetDevice> ();
487  m_rxPhy = CreateObject<ExtSpectrumWifiPhy> ();
490  m_rxPhy->SetErrorRateModel (error);
491  m_rxPhy->SetChannel (spectrumChannel);
492  Ptr<ConstantPositionMobilityModel> sta1Mobility = CreateObject<ConstantPositionMobilityModel> ();
493  m_rxPhy->SetMobility (sta1Mobility);
494  rxDev->SetPhy (m_rxPhy);
495  rxNode->AggregateObject (sta1Mobility);
496  rxNode->AddDevice (rxDev);
498 }
499 
500 void
502 {
503  m_txPhy->Dispose ();
504  m_txPhy = 0;
505  m_rxPhy->Dispose ();
506  m_rxPhy = 0;
507 }
508 
509 void
511 {
512  uint16_t txFrequency;
513  switch (m_txChannelWidth)
514  {
515  case 20:
516  default:
517  txFrequency = 5180;
518  break;
519  case 40:
520  txFrequency = 5190;
521  break;
522  case 80:
523  txFrequency = 5210;
524  break;
525  case 160:
526  txFrequency = 5250;
527  break;
528  }
529  m_txPhy->SetFrequency (txFrequency);
530 
531  uint16_t rxFrequency;
532  switch (m_rxChannelWidth)
533  {
534  case 20:
535  default:
536  rxFrequency = 5180;
537  break;
538  case 40:
539  rxFrequency = 5190;
540  break;
541  case 80:
542  rxFrequency = 5210;
543  break;
544  case 160:
545  rxFrequency = 5250;
546  break;
547  }
548  m_rxPhy->SetFrequency (rxFrequency);
549 
550  m_ruBands.clear ();
551  for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
552  {
553  for (uint8_t i = 0; i < (m_rxChannelWidth / bw); ++i)
554  {
555  for (unsigned int type = 0; type < 7; type++)
556  {
557  HeRu::RuType ruType = static_cast <HeRu::RuType> (type);
558  for (std::size_t index = 1; index <= HeRu::GetNRus (bw, ruType); index++)
559  {
560  HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (bw, ruType, index);
561  HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second);
562  WifiSpectrumBand band = m_rxPhy->ConvertHeRuSubcarriers (bw, m_rxPhy->GetGuardBandwidth (m_rxChannelWidth),
563  range, i);
564  m_ruBands.insert (band);
565  }
566  }
567  }
568  }
569 
570  Simulator::Schedule (Seconds (1), &SpectrumWifiPhyFilterTest::SendPpdu, this);
571 
572  Simulator::Run ();
573 }
574 
575 void
577 {
578  m_txChannelWidth = 20;
579  m_rxChannelWidth = 20;
580  RunOne ();
581 
582  m_txChannelWidth = 40;
583  m_rxChannelWidth = 40;
584  RunOne ();
585 
586  m_txChannelWidth = 80;
587  m_rxChannelWidth = 80;
588  RunOne ();
589 
590  m_txChannelWidth = 160;
591  m_rxChannelWidth = 160;
592  RunOne ();
593 
594  m_txChannelWidth = 20;
595  m_rxChannelWidth = 40;
596  RunOne ();
597 
598  m_txChannelWidth = 20;
599  m_rxChannelWidth = 80;
600  RunOne ();
601 
602  m_txChannelWidth = 40;
603  m_rxChannelWidth = 80;
604  RunOne ();
605 
606  m_txChannelWidth = 20;
607  m_rxChannelWidth = 160;
608  RunOne ();
609 
610  m_txChannelWidth = 40;
611  m_rxChannelWidth = 160;
612  RunOne ();
613 
614  m_txChannelWidth = 80;
615  m_rxChannelWidth = 160;
616  RunOne ();
617 
618  m_txChannelWidth = 40;
619  m_rxChannelWidth = 20;
620  RunOne ();
621 
622  m_txChannelWidth = 80;
623  m_rxChannelWidth = 20;
624  RunOne ();
625 
626  m_txChannelWidth = 80;
627  m_rxChannelWidth = 40;
628  RunOne ();
629 
630  m_txChannelWidth = 160;
631  m_rxChannelWidth = 20;
632  RunOne ();
633 
634  m_txChannelWidth = 160;
635  m_rxChannelWidth = 40;
636  RunOne ();
637 
638  m_txChannelWidth = 160;
639  m_rxChannelWidth = 80;
640  RunOne ();
641 
642  Simulator::Destroy ();
643 }
644 
652 {
653 public:
655 };
656 
658  : TestSuite ("wifi-spectrum-wifi-phy", UNIT)
659 {
660  AddTestCase (new SpectrumWifiPhyBasicTest, TestCase::QUICK);
661  AddTestCase (new SpectrumWifiPhyListenerTest, TestCase::QUICK);
662  AddTestCase (new SpectrumWifiPhyFilterTest, TestCase::QUICK);
663 }
664 
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the start band index and the stop band index for a given band.
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
static SpectrumWifiPhyTestSuite spectrumWifiPhyTestSuite
the test suite
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
uint32_t m_notifyMaybeCcaBusyStart
notify maybe CCA busy start
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void RxCallback(Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Definition: he-ru.h:56
void NotifySleep(void) override
Notify listeners that we went to sleep.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Ptr< ExtSpectrumWifiPhy > m_rxPhy
RX PHY.
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
#define min(a, b)
Definition: 80211b.c:42
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1124
A suite of tests to run.
Definition: test.h:1343
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
uint32_t m_notifyRxEndError
notify receive end error
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:641
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
static const uint32_t FREQUENCY
Test Phy Listener.
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:789
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
uint16_t m_rxChannelWidth
RX channel width (MHz)
void SpectrumWifiPhyRxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
The 5 GHz band.
Definition: wifi-phy-band.h:37
static const uint16_t CHANNEL_WIDTH
encapsulates test code
Definition: test.h:1153
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
uint64_t m_uid
the UID to use for the PPDU
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition: he-ru.h:53
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
Definition: wifi-psdu.cc:260
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:777
void NotifyTxStart(Time duration, double txPowerDbm) override
Spectrum Wifi Phy Basic Test.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1610
uint32_t m_notifyRxEndOk
notify receive end OK
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:66
void NotifyRxEndError(void) override
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
void SendSignal(double txPowerWatts)
Send signal function.
#define max(a, b)
Definition: 80211b.c:43
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
receive notifications about PHY events.
void NotifyRxStart(Time duration) override
Ptr< SpectrumSignalParameters > MakeSignal(double txPowerWatts)
Make signal function.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:166
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
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.
TestPhyListener * m_listener
listener
void NotifyRxEndOk(void) override
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
void NotifyMaybeCcaBusyStart(Time duration) override
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:808
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
Every class exported by the ns3 library is enclosed in the ns3 namespace.
RuType
The different HE Resource Unit (RU) types.
Definition: he-ru.h:41
an EUI-48 address
Definition: mac48-address.h:43
void RunOne()
Run one function.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Ptr< SpectrumWifiPhy > m_phy
Phy.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
void DoRun(void) override
Implementation to actually run this TestCase.
Ptr< ExtSpectrumWifiPhy > m_txPhy
TX PHY.
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:53
Spectrum Wifi Phy Filter Test.
void NotifyOn(void) override
Notify listeners that we went to switch on.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
Spectrum Wifi Phy Test Suite.
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:635
void RegisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:647
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...
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
uint16_t m_txChannelWidth
TX channel width (MHz)
void SendPpdu(void)
Send PPDU function.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
void SetChannelNumber(uint8_t id) override
Set channel number.
void DoRun(void) override
Implementation to actually run this TestCase.
TestPhyListener(void)
Create a test PhyListener.
void DoRun(void) override
Implementation to actually run this TestCase.
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument...
Definition: wifi-phy.cc:1768
void NotifySwitchingStart(Time duration) override
Time duration
The duration of the packet transmission.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
Spectrum Wifi Phy Listener Test.
void SpectrumWifiPhyRxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
static const uint16_t GUARD_WIDTH
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
void NotifyWakeup(void) override
Notify listeners that we woke up.
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
uint32_t m_notifyRxStart
notify receive start
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
#define SU_STA_ID
Definition: wifi-mode.h:32
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
static const uint8_t CHANNEL_NUMBER
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
Implements the IEEE 802.11 MAC header.
void NotifyOff(void) override
Notify listeners that we went to switch off.
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
std::set< WifiSpectrumBand > m_ruBands
spectrum bands associated to all the RUs