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" 30 #include "ns3/wifi-net-device.h" 31 #include "ns3/wifi-psdu.h" 32 #include "ns3/wifi-ppdu.h" 33 #include "ns3/wifi-utils.h" 70 virtual void DoSetup (
void);
82 void SendSignal (
double txPowerWatts);
99 virtual void DoRun (
void);
103 :
TestCase (
"SpectrumWifiPhy test case receives one packet"),
133 txParams->
psd = txPowerSpectrum;
136 txParams->
ppdu = ppdu;
171 m_phy = CreateObject<SpectrumWifiPhy> ();
185 double txPowerWatts = 0.010;
194 Simulator::Destroy ();
281 virtual void DoRun (
void);
305 double txPowerWatts = 0.010;
314 Simulator::Destroy ();
338 virtual void DoRun (
void);
366 :
TestCase (
"SpectrumWifiPhy test RX filters"),
367 m_txChannelWidth (20),
368 m_rxChannelWidth (20)
386 hdr.SetSequenceNumber (1);
400 for (
auto const& pair : rxPowersW)
402 NS_LOG_INFO (
"band: (" << pair.first.first <<
";" << pair.first.second <<
") -> powerW=" << pair.second <<
" (" <<
WToDbm (pair.second) <<
" dBm)");
405 size_t numBands = rxPowersW.size ();
412 expectedNumBands += 9;
413 expectedNumBands += 4;
414 expectedNumBands += 2;
415 expectedNumBands += 1;
419 expectedNumBands += 18;
420 expectedNumBands += 8;
421 expectedNumBands += 4;
422 expectedNumBands += 2;
423 expectedNumBands += 1;
438 NS_TEST_ASSERT_MSG_EQ (numBands, expectedNumBands,
"Total number of bands handled by the receiver is incorrect");
442 auto it = rxPowersW.find (band);
443 NS_LOG_INFO (
"powerW total band: " << it->second <<
" (" <<
WToDbm (it->second) <<
" dBm)");
444 int totalRxPower =
static_cast<int> (
WToDbm (it->second) + 0.5);
445 int expectedTotalRxPower;
449 expectedTotalRxPower = 16;
461 it = rxPowersW.find (band);
462 NS_LOG_INFO (
"powerW in primary 20 MHz channel: " << it->second <<
" (" <<
WToDbm (it->second) <<
" dBm)");
463 int rxPowerPrimaryChannel20 =
static_cast<int> (
WToDbm (it->second) + 0.5);
464 int expectedRxPowerPrimaryChannel20 = 16 -
static_cast<int> (
RatioToDb (channelWidth / 20));
465 NS_TEST_ASSERT_MSG_EQ (rxPowerPrimaryChannel20, expectedRxPowerPrimaryChannel20,
"Received power in the primary 20 MHz band is not correct");
477 lossModel->SetFrequency (5.180e9);
482 Ptr<Node> txNode = CreateObject<Node> ();
484 m_txPhy = CreateObject<ExtSpectrumWifiPhy> ();
497 Ptr<Node> rxNode = CreateObject<Node> ();
499 m_rxPhy = CreateObject<ExtSpectrumWifiPhy> ();
516 uint16_t txFrequency;
536 uint16_t rxFrequency;
627 Simulator::Destroy ();
643 :
TestSuite (
"wifi-spectrum-wifi-phy", UNIT)
static SpectrumWifiPhyTestSuite spectrumWifiPhyTestSuite
the test suite
uint32_t m_notifyMaybeCcaBusyStart
notify maybe CCA busy start
Simulation virtual time values and global simulation resolution.
void RxCallback(Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
#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.
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
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
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)
virtual ~SpectrumWifiPhyListenerTest()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static const uint32_t FREQUENCY
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
uint16_t m_rxChannelWidth
RX channel width (MHz)
static const uint16_t CHANNEL_WIDTH
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.
virtual void SetChannelNumber(uint8_t id)
Set channel number.
void SpectrumWifiPhyRxSuccess(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
virtual ~TestPhyListener()
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Spectrum Wifi Phy Basic Test.
uint32_t m_notifyRxEndOk
notify receive end OK
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
void SendSignal(double txPowerWatts)
Send signal function.
virtual void NotifyWakeup(void)
Notify listeners that we woke up.
virtual ~SpectrumWifiPhyFilterTest()
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
receive notifications about PHY events.
SpectrumWifiPhyBasicTest()
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.
SpectrumWifiPhyTestSuite()
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 ~SpectrumWifiPhyBasicTest()
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 SetFrequency(uint16_t freq)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
SpectrumWifiPhyFilterTest()
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
virtual void SetChannelWidth(uint16_t channelwidth)
Ptr< ExtSpectrumWifiPhy > m_txPhy
TX PHY.
double RatioToDb(double ratio)
Convert from ratio to dB.
Spectrum Wifi Phy Filter Test.
virtual void NotifyOn(void)
Notify listeners that we went to switch on.
Spectrum Wifi Phy Test Suite.
void SetReceiveOkCallback(RxOkCallback callback)
void RegisterListener(WifiPhyListener *listener)
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
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.
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.
SpectrumWifiPhyListenerTest()
TestPhyListener(void)
Create a test PhyListener.
void Send(Ptr< const WifiPsdu > psdu, WifiTxVector txVector)
Time duration
The duration of the packet transmission.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Spectrum Wifi Phy Listener Test.
static Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
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)
uint32_t m_notifyRxStart
notify receive start
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...
static const uint8_t CHANNEL_NUMBER
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...