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  virtual void DoSetup (void);
72  virtual void DoTeardown (void);
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  virtual void DoRun (void);
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  virtual void NotifyRxStart (Time duration)
236  {
237  NS_LOG_FUNCTION (this << duration);
238  ++m_notifyRxStart;
239  }
240  virtual void NotifyRxEndOk (void)
241  {
242  NS_LOG_FUNCTION (this);
243  ++m_notifyRxEndOk;
244  }
245  virtual void NotifyRxEndError (void)
246  {
247  NS_LOG_FUNCTION (this);
249  }
250  virtual void NotifyTxStart (Time duration, double txPowerDbm)
251  {
252  NS_LOG_FUNCTION (this << duration << txPowerDbm);
253  }
254  virtual void NotifyMaybeCcaBusyStart (Time duration)
255  {
256  NS_LOG_FUNCTION (this);
258  }
259  virtual void NotifySwitchingStart (Time duration)
260  {
261  }
262  virtual void NotifySleep (void)
263  {
264  }
265  virtual void NotifyOff (void)
266  {
267  }
268  virtual void NotifyWakeup (void)
269  {
270  }
271  virtual void NotifyOn (void)
272  {
273  }
274  uint32_t m_notifyRxStart;
275  uint32_t m_notifyRxEndOk;
278 private:
279 };
280 
288 {
289 public:
291  virtual ~SpectrumWifiPhyListenerTest ();
292 private:
293  virtual void DoSetup (void);
294  virtual void DoRun (void);
296 };
297 
299  : SpectrumWifiPhyBasicTest ("SpectrumWifiPhy test operation of WifiPhyListener")
300 {
301 }
302 
304 {
305 }
306 
307 void
309 {
313 }
314 
315 void
317 {
318  double txPowerWatts = 0.010;
319  Simulator::Schedule (Seconds (1), &SpectrumWifiPhyListenerTest::SendSignal, this, txPowerWatts);
320  Simulator::Run ();
321 
322  NS_TEST_ASSERT_MSG_EQ (m_count, 1, "Didn't receive right number of packets");
323  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)");
324  NS_TEST_ASSERT_MSG_EQ (m_listener->m_notifyRxStart, 1, "Didn't receive NotifyRxStart");
325  NS_TEST_ASSERT_MSG_EQ (m_listener->m_notifyRxEndOk, 1, "Didn't receive NotifyRxEnd");
326 
327  Simulator::Destroy ();
328  delete m_listener;
329 }
330 
338 {
339 public:
346  SpectrumWifiPhyFilterTest (std::string name);
347  virtual ~SpectrumWifiPhyFilterTest ();
348 
349 private:
350  virtual void DoSetup (void);
351  virtual void DoTeardown (void);
352  virtual void DoRun (void);
353 
357  void RunOne ();
358 
362  void SendPpdu (void);
363 
371 
374 
375  uint16_t m_txChannelWidth;
376  uint16_t m_rxChannelWidth;
377 
378  std::set<WifiSpectrumBand> m_ruBands;
379 };
380 
382  : TestCase ("SpectrumWifiPhy test RX filters"),
383  m_txChannelWidth (20),
384  m_rxChannelWidth (20)
385 {
386 }
387 
389  : TestCase (name)
390 {
391 }
392 
393 void
395 {
396  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs0 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, m_txChannelWidth, false, false);
397  Ptr<Packet> pkt = Create<Packet> (1000);
398  WifiMacHeader hdr;
400  hdr.SetQosTid (0);
401  hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:01"));
402  hdr.SetSequenceNumber (1);
403  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
404  m_txPhy->Send (WifiConstPsduMap ({std::make_pair (SU_STA_ID, psdu)}), txVector);
405 }
406 
408 {
409  m_txPhy = 0;
410  m_rxPhy = 0;
411 }
412 
413 void
415 {
416  for (auto const& pair : rxPowersW)
417  {
418  NS_LOG_INFO ("band: (" << pair.first.first << ";" << pair.first.second << ") -> powerW=" << pair.second << " (" << WToDbm (pair.second) << " dBm)");
419  }
420 
421  size_t numBands = rxPowersW.size ();
422  size_t expectedNumBands = std::max (1, (m_rxChannelWidth / 20));
423  expectedNumBands += (m_rxChannelWidth / 40);
424  expectedNumBands += (m_rxChannelWidth / 80);
425  expectedNumBands += (m_rxChannelWidth / 160);
426  expectedNumBands += m_ruBands.size ();
427 
428  NS_TEST_ASSERT_MSG_EQ (numBands, expectedNumBands, "Total number of bands handled by the receiver is incorrect");
429 
430  uint16_t channelWidth = std::min (m_txChannelWidth, m_rxChannelWidth);
431  WifiSpectrumBand band = m_rxPhy->GetBand (channelWidth, 0);
432  auto it = rxPowersW.find (band);
433  NS_LOG_INFO ("powerW total band: " << it->second << " (" << WToDbm (it->second) << " dBm)");
434  int totalRxPower = static_cast<int> (WToDbm (it->second) + 0.5);
435  int expectedTotalRxPower;
437  {
438  //PHY sends at 16 dBm, and since there is no loss, this should be the total power at the receiver.
439  expectedTotalRxPower = 16;
440  }
441  else
442  {
443  //Only a part of the transmitted power is received
444  expectedTotalRxPower = 16 - static_cast<int> (RatioToDb (m_txChannelWidth / m_rxChannelWidth));
445  }
446  NS_TEST_ASSERT_MSG_EQ (totalRxPower, expectedTotalRxPower, "Total received power is not correct");
447 
448  if ((m_txChannelWidth <= m_rxChannelWidth) && (channelWidth >= 20))
449  {
450  band = m_rxPhy->GetBand (20, 0); //primary 20 MHz
451  it = rxPowersW.find (band);
452  NS_LOG_INFO ("powerW in primary 20 MHz channel: " << it->second << " (" << WToDbm (it->second) << " dBm)");
453  int rxPowerPrimaryChannel20 = static_cast<int> (WToDbm (it->second) + 0.5);
454  int expectedRxPowerPrimaryChannel20 = 16 - static_cast<int> (RatioToDb (channelWidth / 20));
455  NS_TEST_ASSERT_MSG_EQ (rxPowerPrimaryChannel20, expectedRxPowerPrimaryChannel20, "Received power in the primary 20 MHz band is not correct");
456  }
457 }
458 
459 void
461 {
462  //WifiHelper::EnableLogComponents ();
463  //LogComponentEnable ("SpectrumWifiPhyBasicTest", LOG_LEVEL_ALL);
464 
465  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
466  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
467  lossModel->SetFrequency (5.180e9);
468  spectrumChannel->AddPropagationLossModel (lossModel);
469  Ptr<ConstantSpeedPropagationDelayModel> delayModel = CreateObject<ConstantSpeedPropagationDelayModel> ();
470  spectrumChannel->SetPropagationDelayModel (delayModel);
471 
472  Ptr<Node> txNode = CreateObject<Node> ();
473  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
474  m_txPhy = CreateObject<ExtSpectrumWifiPhy> ();
477  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
478  m_txPhy->SetErrorRateModel (error);
479  m_txPhy->SetDevice (txDev);
480  m_txPhy->SetChannel (spectrumChannel);
481  Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionMobilityModel> ();
482  m_txPhy->SetMobility (apMobility);
483  txDev->SetPhy (m_txPhy);
484  txNode->AggregateObject (apMobility);
485  txNode->AddDevice (txDev);
486 
487  Ptr<Node> rxNode = CreateObject<Node> ();
488  Ptr<WifiNetDevice> rxDev = CreateObject<WifiNetDevice> ();
489  m_rxPhy = CreateObject<ExtSpectrumWifiPhy> ();
492  m_rxPhy->SetErrorRateModel (error);
493  m_rxPhy->SetChannel (spectrumChannel);
494  Ptr<ConstantPositionMobilityModel> sta1Mobility = CreateObject<ConstantPositionMobilityModel> ();
495  m_rxPhy->SetMobility (sta1Mobility);
496  rxDev->SetPhy (m_rxPhy);
497  rxNode->AggregateObject (sta1Mobility);
498  rxNode->AddDevice (rxDev);
500 }
501 
502 void
504 {
505  m_txPhy->Dispose ();
506  m_txPhy = 0;
507  m_rxPhy->Dispose ();
508  m_rxPhy = 0;
509 }
510 
511 void
513 {
514  uint16_t txFrequency;
515  switch (m_txChannelWidth)
516  {
517  case 20:
518  default:
519  txFrequency = 5180;
520  break;
521  case 40:
522  txFrequency = 5190;
523  break;
524  case 80:
525  txFrequency = 5210;
526  break;
527  case 160:
528  txFrequency = 5250;
529  break;
530  }
531  m_txPhy->SetFrequency (txFrequency);
532 
533  uint16_t rxFrequency;
534  switch (m_rxChannelWidth)
535  {
536  case 20:
537  default:
538  rxFrequency = 5180;
539  break;
540  case 40:
541  rxFrequency = 5190;
542  break;
543  case 80:
544  rxFrequency = 5210;
545  break;
546  case 160:
547  rxFrequency = 5250;
548  break;
549  }
550  m_rxPhy->SetFrequency (rxFrequency);
551 
552  m_ruBands.clear ();
553  for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
554  {
555  for (uint8_t i = 0; i < (m_rxChannelWidth / bw); ++i)
556  {
557  for (unsigned int type = 0; type < 7; type++)
558  {
559  HeRu::RuType ruType = static_cast <HeRu::RuType> (type);
560  for (std::size_t index = 1; index <= HeRu::GetNRus (bw, ruType); index++)
561  {
562  HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (bw, ruType, index);
563  HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second);
564  WifiSpectrumBand band = m_rxPhy->ConvertHeRuSubcarriers (bw, m_rxPhy->GetGuardBandwidth (m_rxChannelWidth),
565  range, i);
566  m_ruBands.insert (band);
567  }
568  }
569  }
570  }
571 
572  Simulator::Schedule (Seconds (1), &SpectrumWifiPhyFilterTest::SendPpdu, this);
573 
574  Simulator::Run ();
575 }
576 
577 void
579 {
580  m_txChannelWidth = 20;
581  m_rxChannelWidth = 20;
582  RunOne ();
583 
584  m_txChannelWidth = 40;
585  m_rxChannelWidth = 40;
586  RunOne ();
587 
588  m_txChannelWidth = 80;
589  m_rxChannelWidth = 80;
590  RunOne ();
591 
592  m_txChannelWidth = 160;
593  m_rxChannelWidth = 160;
594  RunOne ();
595 
596  m_txChannelWidth = 20;
597  m_rxChannelWidth = 40;
598  RunOne ();
599 
600  m_txChannelWidth = 20;
601  m_rxChannelWidth = 80;
602  RunOne ();
603 
604  m_txChannelWidth = 40;
605  m_rxChannelWidth = 80;
606  RunOne ();
607 
608  m_txChannelWidth = 20;
609  m_rxChannelWidth = 160;
610  RunOne ();
611 
612  m_txChannelWidth = 40;
613  m_rxChannelWidth = 160;
614  RunOne ();
615 
616  m_txChannelWidth = 80;
617  m_rxChannelWidth = 160;
618  RunOne ();
619 
620  m_txChannelWidth = 40;
621  m_rxChannelWidth = 20;
622  RunOne ();
623 
624  m_txChannelWidth = 80;
625  m_rxChannelWidth = 20;
626  RunOne ();
627 
628  m_txChannelWidth = 80;
629  m_rxChannelWidth = 40;
630  RunOne ();
631 
632  m_txChannelWidth = 160;
633  m_rxChannelWidth = 20;
634  RunOne ();
635 
636  m_txChannelWidth = 160;
637  m_rxChannelWidth = 40;
638  RunOne ();
639 
640  m_txChannelWidth = 160;
641  m_rxChannelWidth = 80;
642  RunOne ();
643 
644  Simulator::Destroy ();
645 }
646 
654 {
655 public:
657 };
658 
660  : TestSuite ("wifi-spectrum-wifi-phy", UNIT)
661 {
662  AddTestCase (new SpectrumWifiPhyBasicTest, TestCase::QUICK);
663  AddTestCase (new SpectrumWifiPhyListenerTest, TestCase::QUICK);
664  AddTestCase (new SpectrumWifiPhyFilterTest, TestCase::QUICK);
665 }
666 
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
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
#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...
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition: wifi-ppdu.h:38
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1124
virtual void DoRun(void)
Implementation to actually run this TestCase.
A suite of tests to run.
Definition: test.h:1343
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
virtual void NotifySleep(void)
Notify listeners that we went to sleep.
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.
virtual void NotifyMaybeCcaBusyStart(Time duration)
virtual void DoRun(void)
Implementation to actually run this TestCase.
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
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:1616
uint32_t m_notifyRxEndOk
notify receive end OK
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:66
void SendSignal(double txPowerWatts)
Send signal function.
virtual void NotifyWakeup(void)
Notify listeners that we woke up.
#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.
Ptr< SpectrumSignalParameters > MakeSignal(double txPowerWatts)
Make signal function.
virtual void NotifySwitchingStart(Time duration)
#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
virtual void NotifyRxStart(Time duration)
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
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
802.11 PHY layer modelThis PHY implements a spectrum-aware enhancement of the 802.11 SpectrumWifiPhy model.
TestPhyListener * m_listener
listener
virtual void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
virtual void DoTeardown(void)
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
virtual 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
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
void RunOne()
Run one function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
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.
virtual void NotifyOn(void)
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
virtual 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.
virtual void NotifyOff(void)
Notify listeners that we went to switch off.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
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
virtual void SetChannelNumber(uint8_t id) override
Set channel number.
TestPhyListener(void)
Create a test PhyListener.
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:1774
Time duration
The duration of the packet transmission.
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.
virtual void NotifyTxStart(Time duration, double txPowerDbm)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
uint32_t m_notifyRxStart
notify receive start
#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 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