18#include "ns3/constant-position-mobility-model.h"
19#include "ns3/he-phy.h"
20#include "ns3/interference-helper.h"
22#include "ns3/multi-model-spectrum-channel.h"
23#include "ns3/nist-error-rate-model.h"
24#include "ns3/ofdm-ppdu.h"
25#include "ns3/spectrum-wifi-helper.h"
26#include "ns3/spectrum-wifi-phy.h"
28#include "ns3/wifi-mac-header.h"
29#include "ns3/wifi-net-device.h"
30#include "ns3/wifi-phy-listener.h"
31#include "ns3/wifi-psdu.h"
32#include "ns3/wifi-spectrum-signal-parameters.h"
33#include "ns3/wifi-spectrum-value-helper.h"
34#include "ns3/wifi-utils.h"
96 std::vector<bool> statusPerMpdu);
105 void DoRun()
override;
146 txParams->psd = txPowerSpectrum;
147 txParams->txPhy =
nullptr;
148 txParams->duration = txDuration;
149 txParams->ppdu = ppdu;
166 std::vector<bool> statusPerMpdu)
188 m_phy = CreateObject<SpectrumWifiPhy>();
212 double txPowerWatts = 0.010;
283 const std::vector<Time>& )
override
329 void DoRun()
override;
353 double txPowerWatts = 0.010;
361 "Didn't receive NotifyCcaBusyStart (once preamble is detected + prolonged by L-SIG "
362 "reception, then switched to Rx by at the beginning of data)");
391 void DoRun()
override;
420 :
TestCase(
"SpectrumWifiPhy test RX filters"),
421 m_txChannelWidth(20),
463 for (
const auto& pair : rxPowersW)
465 NS_LOG_INFO(
"band: (" << pair.first.first <<
";" << pair.first.second <<
") -> powerW="
466 << pair.second <<
" (" <<
WToDbm(pair.second) <<
" dBm)");
469 size_t numBands = rxPowersW.size();
478 "Total number of bands handled by the receiver is incorrect");
482 auto it = rxPowersW.find(band);
483 NS_LOG_INFO(
"powerW total band: " << it->second <<
" (" <<
WToDbm(it->second) <<
" dBm)");
484 int totalRxPower =
static_cast<int>(
WToDbm(it->second) + 0.5);
485 int expectedTotalRxPower;
490 expectedTotalRxPower = 16;
495 expectedTotalRxPower =
499 expectedTotalRxPower,
500 "Total received power is not correct");
505 it = rxPowersW.find(band);
506 NS_LOG_INFO(
"powerW in primary 20 MHz channel: " << it->second <<
" (" <<
WToDbm(it->second)
508 int rxPowerPrimaryChannel20 =
static_cast<int>(
WToDbm(it->second) + 0.5);
509 int expectedRxPowerPrimaryChannel20 = 16 -
static_cast<int>(
RatioToDb(channelWidth / 20));
511 expectedRxPowerPrimaryChannel20,
512 "Received power in the primary 20 MHz band is not correct");
524 lossModel->SetFrequency(5.180e9);
525 spectrumChannel->AddPropagationLossModel(lossModel);
527 CreateObject<ConstantSpeedPropagationDelayModel>();
528 spectrumChannel->SetPropagationDelayModel(delayModel);
532 m_txPhy = CreateObject<ExtSpectrumWifiPhy>();
544 txNode->AggregateObject(apMobility);
545 txNode->AddDevice(txDev);
549 m_rxPhy = CreateObject<ExtSpectrumWifiPhy>();
560 rxNode->AggregateObject(sta1Mobility);
561 rxNode->AddDevice(rxDev);
578 uint16_t txFrequency;
603 uint16_t rxFrequency;
629 for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
633 for (
unsigned int type = 0; type < 7; type++)
636 for (std::size_t index = 1; index <=
HeRu::GetNRus(bw, ruType); index++)
640 std::make_pair(group.front().first, group.back().second);
740 :
TestSuite(
"wifi-spectrum-wifi-phy", UNIT)
Spectrum Wifi Phy Basic Test.
void SpectrumWifiPhyRxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
Ptr< SpectrumSignalParameters > MakeSignal(double txPowerWatts)
Make signal function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
~SpectrumWifiPhyBasicTest() override
SpectrumWifiPhyBasicTest()
void SpectrumWifiPhyRxFailure(Ptr< const WifiPsdu > psdu)
Spectrum wifi receive failure function.
void SendSignal(double txPowerWatts)
Send signal function.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
uint64_t m_uid
the UID to use for the PPDU
Ptr< SpectrumWifiPhy > m_phy
Phy.
Spectrum Wifi Phy Filter Test.
void RxCallback(Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
uint16_t m_txChannelWidth
TX channel width (MHz)
~SpectrumWifiPhyFilterTest() override
SpectrumWifiPhyFilterTest()
void DoRun() override
Implementation to actually run this TestCase.
void RunOne()
Run one function.
void SendPpdu()
Send PPDU function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::set< WifiSpectrumBand > m_ruBands
spectrum bands associated to all the RUs
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Ptr< ExtSpectrumWifiPhy > m_rxPhy
RX PHY.
uint16_t m_rxChannelWidth
RX channel width (MHz)
Ptr< ExtSpectrumWifiPhy > m_txPhy
TX PHY.
Spectrum Wifi Phy Listener Test.
TestPhyListener * m_listener
listener
void DoRun() override
Implementation to actually run this TestCase.
~SpectrumWifiPhyListenerTest() override
void DoSetup() override
Implementation to do any local setup required for this TestCase.
SpectrumWifiPhyListenerTest()
Spectrum Wifi Phy Test Suite.
SpectrumWifiPhyTestSuite()
void NotifyWakeup() override
Notify listeners that we woke up.
TestPhyListener()
Create a test PhyListener.
~TestPhyListener() override
void NotifyRxEndOk() override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
void NotifyOff() override
Notify listeners that we went to switch off.
void NotifySleep() override
Notify listeners that we went to sleep.
void NotifySwitchingStart(Time duration) override
uint32_t m_notifyMaybeCcaBusyStart
notify maybe CCA busy start
uint32_t m_notifyRxStart
notify receive start
void NotifyTxStart(Time duration, double txPowerDbm) override
void NotifyCcaBusyStart(Time duration, WifiChannelListType channelType, const std::vector< Time > &) override
void NotifyRxStart(Time duration) override
void NotifyOn() override
Notify listeners that we went to switch on.
uint32_t m_notifyRxEndOk
notify receive end OK
void NotifyRxEndError() override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
uint32_t m_notifyRxEndError
notify receive end error
static WifiMode GetHeMcs0()
Return MCS 0 from HE MCS values.
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...
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...
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
RuType
The different HE Resource Unit (RU) types.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void Dispose()
Dispose of this Object.
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6 Mbps.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
void SetChannel(const Ptr< SpectrumChannel > channel)
Set the SpectrumChannel this SpectrumWifiPhy is to be connected to.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const override
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 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...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
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 SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
void SetReceiveErrorCallback(RxErrorCallback callback)
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void RegisterListener(WifiPhyListener *listener)
void SetReceiveOkCallback(RxOkCallback callback)
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
receive notifications about PHY events.
static ConstIterator FindFirst(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first channel matching the specified parameters.
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#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.
#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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double RatioToDb(double ratio)
Convert from ratio to dB.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double WToDbm(double w)
Convert from Watts to dBm.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
static const uint8_t CHANNEL_NUMBER
static SpectrumWifiPhyTestSuite spectrumWifiPhyTestSuite
the test suite
static const uint16_t GUARD_WIDTH
static const uint16_t CHANNEL_WIDTH
static const uint32_t FREQUENCY
RxSignalInfo structure containing info on the received signal.