|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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/ofdm-ppdu.h"
33 #include "ns3/wifi-utils.h"
34 #include "ns3/he-phy.h"
71 void DoSetup (
void)
override;
72 void DoTeardown (
void)
override;
84 void SendSignal (
double txPowerWatts);
102 void DoRun (
void)
override;
138 txParams->
psd = txPowerSpectrum;
141 txParams->
ppdu = ppdu;
177 m_phy = CreateObject<SpectrumWifiPhy> ();
198 double txPowerWatts = 0.010;
207 Simulator::Destroy ();
293 void DoRun (
void)
override;
317 double txPowerWatts = 0.010;
326 Simulator::Destroy ();
351 void DoRun (
void)
override;
380 :
TestCase (
"SpectrumWifiPhy test RX filters"),
381 m_txChannelWidth (20),
382 m_rxChannelWidth (20)
414 for (
auto const& pair : rxPowersW)
416 NS_LOG_INFO (
"band: (" << pair.first.first <<
";" << pair.first.second <<
") -> powerW=" << pair.second <<
" (" <<
WToDbm (pair.second) <<
" dBm)");
419 size_t numBands = rxPowersW.size ();
426 NS_TEST_ASSERT_MSG_EQ (numBands, expectedNumBands,
"Total number of bands handled by the receiver is incorrect");
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;
437 expectedTotalRxPower = 16;
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");
470 Ptr<Node> txNode = CreateObject<Node> ();
472 m_txPhy = CreateObject<ExtSpectrumWifiPhy> ();
485 Ptr<Node> rxNode = CreateObject<Node> ();
487 m_rxPhy = CreateObject<ExtSpectrumWifiPhy> ();
512 uint16_t txFrequency;
531 uint16_t rxFrequency;
551 for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
555 for (
unsigned int type = 0; type < 7; type++)
558 for (std::size_t index = 1; index <= HeRu::GetNRus (bw, ruType); index++)
642 Simulator::Destroy ();
658 :
TestSuite (
"wifi-spectrum-wifi-phy", UNIT)
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Spectrum Wifi Phy Basic Test.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
TestPhyListener(void)
Create a test PhyListener.
static SpectrumWifiPhyTestSuite spectrumWifiPhyTestSuite
the test suite
Spectrum Wifi Phy Test Suite.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void Dispose(void)
Dispose of this Object.
Ptr< ExtSpectrumWifiPhy > m_rxPhy
RX PHY.
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
void RunOne()
Run one function.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
void SetChannelNumber(uint8_t id) override
Set channel number.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
static const uint16_t GUARD_WIDTH
WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the start band index and the stop band index for a given band.
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
receive notifications about PHY events.
void SpectrumWifiPhyRxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
uint32_t m_notifyRxEndOk
notify receive end OK
Spectrum Wifi Phy Listener Test.
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
void SendPpdu(void)
Send PPDU function.
uint64_t m_uid
the UID to use for the PPDU
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
double WToDbm(double w)
Convert from Watts to dBm.
Spectrum Wifi Phy Filter Test.
uint32_t m_notifyMaybeCcaBusyStart
notify maybe CCA busy start
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetReceiveOkCallback(RxOkCallback callback)
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
static const uint8_t CHANNEL_NUMBER
void NotifySwitchingStart(Time duration) override
void RxCallback(Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Ptr< SpectrumSignalParameters > MakeSignal(double txPowerWatts)
Make signal function.
uint16_t m_rxChannelWidth
RX channel width (MHz)
uint32_t m_notifyRxStart
notify receive start
void RegisterListener(WifiPhyListener *listener)
virtual ~SpectrumWifiPhyListenerTest()
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
void CreateWifiSpectrumPhyInterface(Ptr< NetDevice > device)
Method to encapsulate the creation of the WifiSpectrumPhyInterface object (used to bind the WifiSpect...
void NotifyOff(void) override
Notify listeners that we went to switch off.
void SendSignal(double txPowerWatts)
Send signal function.
std::set< WifiSpectrumBand > m_ruBands
spectrum bands associated to all the RUs
virtual ~SpectrumWifiPhyBasicTest()
Ptr< ExtSpectrumWifiPhy > m_txPhy
TX PHY.
void SetReceiveErrorCallback(RxErrorCallback callback)
SpectrumWifiPhyBasicTest()
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
SpectrumWifiPhyTestSuite()
void NotifyWakeup(void) override
Notify listeners that we woke up.
void SetFrequency(double frequency)
RuType
The different HE Resource Unit (RU) types.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
void NotifyTxStart(Time duration, double txPowerDbm) override
void NotifySleep(void) override
Notify listeners that we went to sleep.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
Simulation virtual time values and global simulation resolution.
void NotifyRxStart(Time duration) override
Time duration
The duration of the packet transmission.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint16_t m_txChannelWidth
TX channel width (MHz)
void DoRun(void) override
Implementation to actually run this TestCase.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void DoRun(void) override
Implementation to actually run this TestCase.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
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...
double RatioToDb(double ratio)
Convert from ratio to dB.
@ WIFI_PHY_STANDARD_80211n
HT PHY (clause 20)
uint32_t m_notifyRxEndError
notify receive end error
#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.
TestPhyListener * m_listener
listener
void DoRun(void) override
Implementation to actually run this TestCase.
RxSignalInfo structure containing info on the received signal.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual ~TestPhyListener()
static const uint16_t CHANNEL_WIDTH
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void NotifyRxEndError(void) override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
SpectrumWifiPhyListenerTest()
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...
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const override
void SpectrumWifiPhyRxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
void NotifyOn(void) override
Notify listeners that we went to switch on.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void NotifyMaybeCcaBusyStart(Time duration) override
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
SpectrumWifiPhyFilterTest()
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.
void NotifyRxEndOk(void) override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
void SetPhy(const Ptr< WifiPhy > phy)
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
static const uint32_t FREQUENCY
virtual ~SpectrumWifiPhyFilterTest()