9#include "ns3/ap-wifi-mac.h"
10#include "ns3/boolean.h"
11#include "ns3/constant-position-mobility-model.h"
12#include "ns3/he-configuration.h"
13#include "ns3/he-phy.h"
14#include "ns3/interference-helper.h"
16#include "ns3/mobility-helper.h"
17#include "ns3/multi-model-spectrum-channel.h"
18#include "ns3/nist-error-rate-model.h"
20#include "ns3/non-communicating-net-device.h"
21#include "ns3/pointer.h"
22#include "ns3/rng-seed-manager.h"
23#include "ns3/simulator.h"
24#include "ns3/spectrum-wifi-helper.h"
25#include "ns3/spectrum-wifi-phy.h"
26#include "ns3/sta-wifi-mac.h"
27#include "ns3/string.h"
30#include "ns3/waveform-generator.h"
31#include "ns3/wifi-mac-header.h"
32#include "ns3/wifi-net-device.h"
33#include "ns3/wifi-psdu.h"
34#include "ns3/wifi-spectrum-signal-parameters.h"
35#include "ns3/wifi-spectrum-value-helper.h"
36#include "ns3/wifi-utils.h"
197 using StasParams = std::vector<std::tuple<WifiStandard, MHz_u, uint8_t>>;
213 std::vector<bool> per20MhzInterference = {});
218 void DoRun()
override;
232 std::vector<bool> statusPerMpdu);
289 std::vector<Ptr<WaveformGenerator>>
298 std::vector<bool> per20MhzInterference)
299 :
TestCase{
"non-HT duplicate PHY reception test"},
300 m_apStandard{apStandard},
301 m_apFrequency{apFrequency},
302 m_apP20Index{apP20Index},
303 m_stasParams{stasParams},
304 m_per20MhzInterference{per20MhzInterference},
305 m_countRxSuccessStas{},
306 m_countRxFailureStas{},
346 m_phyAp->CalculateTxDuration(psdu->GetSize(), txVector,
m_phyAp->GetPhyBand());
357 interferer->SetTxPowerSpectralDensity(interferencePsd);
358 interferer->SetPeriod(duration);
381 const auto expectedWidth =
382 std::min(
m_phyAp->GetChannelWidth(),
m_phyStas.at(index)->GetChannelWidth());
385 "Incorrect channel width in TXVECTOR");
401 NS_LOG_FUNCTION(
this << index << expectedRxSuccess << expectedRxFailure);
404 "The number of successfully received packets by STA "
405 << index <<
" is not correct!");
408 "The number of unsuccessfully received packets by STA "
409 << index <<
" is not correct!");
418 spectrumChannel->AddPropagationLossModel(lossModel);
420 spectrumChannel->SetPropagationDelayModel(delayModel);
426 m_phyAp->SetInterferenceHelper(apInterferenceHelper);
428 m_phyAp->SetErrorRateModel(apErrorModel);
430 m_phyAp->AddChannel(spectrumChannel);
433 m_phyAp->SetMobility(apMobility);
435 apNode->AggregateObject(apMobility);
436 apNode->AddDevice(apDev);
444 staPhy->SetInterferenceHelper(sta1InterferenceHelper);
446 staPhy->SetErrorRateModel(sta1ErrorModel);
447 staPhy->SetDevice(staDev);
448 staPhy->AddChannel(spectrumChannel);
449 staPhy->ConfigureStandard(std::get<0>(staParams));
450 staPhy->SetReceiveOkCallback(
452 staPhy->SetReceiveErrorCallback(
455 staPhy->SetMobility(staMobility);
456 staDev->SetPhy(staPhy);
457 staNode->AggregateObject(staMobility);
458 staNode->AddDevice(staDev);
471 [[maybe_unused]]
const std::size_t num20MhzSubchannels = channelInfo.width / 20;
478 phyInterferer->SetDevice(interfererDev);
479 phyInterferer->SetChannel(spectrumChannel);
480 phyInterferer->SetDutyCycle(1);
481 interfererNode->AddDevice(interfererDev);
499 phyInterferer->Dispose();
500 phyInterferer =
nullptr;
509 int64_t streamNumber = 0;
510 m_phyAp->AssignStreams(streamNumber);
513 phySta->AssignStreams(streamNumber);
527 for (
const auto& [staStandard, staFrequency, staP20Index] :
m_stasParams)
535 stachannelInfo.width,
541 const auto minApCenterFrequency =
542 m_phyAp->GetFrequency() - (
m_phyAp->GetChannelWidth() / 2) + (20 / 2);
543 for (
auto channelWidth = 20; channelWidth <= apchannelInfo.width; channelWidth *= 2, ++index)
554 bandInfo.
fc = (minApCenterFrequency + (i * 20)) * 1e6;
555 bandInfo.
fl = bandInfo.
fc - (5 * 1e6);
556 bandInfo.
fh = bandInfo.
fc + (5 * 1e6);
558 bands.push_back(bandInfo);
561 Watt_u interferencePower = 0.005;
563 *interferencePsd = interferencePower / 10e6;
572 const auto apCenterFreq =
573 m_phyAp->GetOperatingChannel().GetPrimaryChannelCenterFrequency(channelWidth);
574 const auto apMinFreq = apCenterFreq - (channelWidth / 2);
575 const auto apMaxFreq = apCenterFreq + (channelWidth / 2);
582 const auto p20Width = 20;
583 const auto staP20Freq =
584 m_phyStas.at(i)->GetOperatingChannel().GetPrimaryChannelCenterFrequency(p20Width);
585 const auto staP20MinFreq = staP20Freq - (p20Width / 2);
586 const auto staP20MaxFreq = staP20Freq + (p20Width / 2);
587 bool expectRx = (staP20MinFreq >= apMinFreq && staP20MaxFreq <= apMaxFreq);
588 bool expectSuccess =
true;
591 const auto index20MhzSubBand = ((staP20Freq - minApCenterFrequency) / 20);
598 expectRx ? expectSuccess : 0,
599 expectRx ? !expectSuccess : 0);
642 void DoRun()
override;
668 std::vector<bool> statusPerMpdu);
700 const std::vector<CtsTxInfos>& ctsTxInfosPerSta)
701 :
TestCase{
"test PHY reception of multiple CTS frames following a MU-RTS frame"},
702 m_ctsTxInfosPerSta{ctsTxInfosPerSta},
703 m_countApRxCtsSuccess{0},
704 m_countApRxCtsFailure{0},
705 m_countStaRxCtsSuccess{0},
706 m_countStaRxCtsFailure{0},
719 [](
const auto& lhs,
const auto& rhs) { return lhs.bw < rhs.bw; })
731 phySta->SetPpduUid(0);
771 m_phyStas.at(phyIndex)->Send(psdu, txVector);
781 NS_LOG_FUNCTION(
this << phyIndex << *psdu << rxSignalInfo << txVector);
782 std::vector<CtsTxInfos> successfulCtsInfos{};
785 std::back_inserter(successfulCtsInfos),
786 [](
const auto& info) { return !info.discard; });
787 const auto isAp = (phyIndex == 0);
793 "RX power is not correct!");
796 std::max_element(successfulCtsInfos.cbegin(),
797 successfulCtsInfos.cend(),
798 [](
const auto& lhs,
const auto& rhs) { return lhs.bw < rhs.bw; })
806 "Incorrect channel width in TXVECTOR");
821 const auto isAp = (phyIndex == 0);
837 "The number of successfully received CTS frames by AP is not correct!");
841 "The number of successfully received CTS frames by non-participating STAs is not correct!");
844 "The number of unsuccessfully received CTS frames by AP is not correct!");
847 "The number of unsuccessfully received CTS frames by non-participating "
848 "STAs is not correct!");
856 int64_t streamNumber = 0;
861 spectrumChannel->AddPropagationLossModel(lossModel);
863 spectrumChannel->SetPropagationDelayModel(delayModel);
870 apMac->SetAttribute(
"BeaconGeneration",
BooleanValue(
false));
871 apDev->SetMac(apMac);
891 [](
const auto& lhs,
const auto& rhs) { return lhs.bw < rhs.bw; })
905 apNode->AggregateObject(apMobility);
906 apNode->AddDevice(apDev);
914 phySta->SetInterferenceHelper(staInterferenceHelper);
916 phySta->SetErrorRateModel(staErrorModel);
917 phySta->SetDevice(staDev);
918 phySta->AddChannel(spectrumChannel);
920 phySta->AssignStreams(streamNumber);
931 phySta->SetOperatingChannel(
935 phySta->SetMobility(staMobility);
936 staDev->SetPhy(phySta);
939 staNode->AggregateObject(staMobility);
940 staNode->AddDevice(staDev);
948 nonParticipatingHePhySta->SetInterferenceHelper(nonParticipatingHeStaInterferenceHelper);
950 nonParticipatingHePhySta->SetErrorRateModel(nonParticipatingHeStaErrorModel);
951 nonParticipatingHePhySta->SetDevice(nonParticipatingHeStaDev);
952 nonParticipatingHePhySta->AddChannel(spectrumChannel);
955 nonParticipatingHePhySta->SetOperatingChannel(
959 nonParticipatingHePhySta->SetMobility(nonParticipatingHeStaMobility);
960 nonParticipatingHeStaDev->SetPhy(nonParticipatingHePhySta);
963 nonParticipatingHePhySta->AssignStreams(streamNumber);
964 nonParticipatingHeStaNode->AggregateObject(nonParticipatingHeStaMobility);
965 nonParticipatingHeStaNode->AddDevice(nonParticipatingHeStaDev);
967 nonParticipatingHePhySta->SetReceiveOkCallback(
969 nonParticipatingHePhySta->SetReceiveErrorCallback(
978 nonHePhySta->SetInterferenceHelper(nonHeStaInterferenceHelper);
980 nonHePhySta->SetErrorRateModel(nonHeStaErrorModel);
981 nonHePhySta->SetDevice(nonHeStaDev);
982 nonHePhySta->AddChannel(spectrumChannel);
984 nonHePhySta->SetOperatingChannel(
987 nonHePhySta->SetMobility(nonHeStaMobility);
988 nonHeStaDev->SetPhy(nonHePhySta);
990 nonHePhySta->AssignStreams(streamNumber);
991 nonHeStaNode->AggregateObject(nonHeStaMobility);
992 nonHeStaNode->AddDevice(nonHeStaDev);
1014 for (std::size_t index = 0; index <
m_phyStas.size(); ++index)
1018 const auto delay = (index + 1) *
NanoSeconds(1.0);
1088 TestCase::Duration::QUICK);
1096 {
false,
true,
false,
false}),
1097 TestCase::Duration::QUICK);
1101 TestCase::Duration::QUICK);
1104 TestCase::Duration::QUICK);
1107 TestCase::Duration::QUICK);
1110 TestCase::Duration::QUICK);
1114 TestCase::Duration::QUICK);
1118 TestCase::Duration::QUICK);
1122 TestCase::Duration::QUICK);
1126 TestCase::Duration::QUICK);
1130 TestCase::Duration::QUICK);
1134 TestCase::Duration::QUICK);
HE PHY used for testing MU-RTS/CTS.
void SetPreviousTxPpduUid(uint64_t uid)
Set the previous TX PPDU UID counter.
void SetMuRtsTxVector(const WifiTxVector &muRtsTxVector)
Set the TXVECTOR of the previously transmitted MU-RTS.
~MuRtsCtsHePhy() override
Spectrum PHY used for testing MU-RTS/CTS.
void DoDispose() override
Destructor implementation.
MuRtsCtsSpectrumWifiPhy()
~MuRtsCtsSpectrumWifiPhy() override
Ptr< MuRtsCtsHePhy > m_muRtsCtsHePhy
Pointer to HE PHY instance used for MU-RTS/CTS PHY test.
void SetPpduUid(uint64_t uid)
Set the global PPDU UID counter.
void SetMuRtsTxVector(const WifiTxVector &muRtsTxVector)
Set the TXVECTOR of the previously transmitted MU-RTS.
void DoInitialize() override
Initialize() implementation.
static TypeId GetTypeId()
Get the type ID.
test PHY reception of multiple CTS frames as a response to a MU-RTS frame.
TestMultipleCtsResponsesFromMuRts(const std::vector< CtsTxInfos > &ctsTxInfosPerSta)
Constructor.
std::size_t m_countApRxCtsFailure
count the number of unsuccessfully received CTS frames by the AP
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::size_t m_countStaRxCtsFailure
count the number of unsuccessfully received CTS frames by the non-participating STA
dBm_u m_stasTxPower
TX power configured for the STAs.
void RxCtsSuccess(std::size_t phyIndex, Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
CTS RX success function.
void FakePreviousMuRts()
Function called to fake the transmission of a MU-RTS.
std::vector< CtsTxInfos > m_ctsTxInfosPerSta
information about CTS responses
std::vector< Ptr< MuRtsCtsSpectrumWifiPhy > > m_phyStas
STAs PHYs.
void TxNonHtDuplicateCts(std::size_t phyIndex)
Function called to trigger a CTS frame sent by a STA using non-HT duplicate.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
std::size_t m_countApRxCtsSuccess
count the number of successfully received CTS frames by the AP
Ptr< MuRtsCtsSpectrumWifiPhy > m_phyAp
AP PHY.
void RxCtsFailure(std::size_t phyIndex, Ptr< const WifiPsdu > psdu)
CTS RX failure function.
std::size_t m_countStaRxCtsSuccess
count the number of successfully received CTS frames by the non-participating STA
void CheckResults()
Check the results.
non-HT duplicate PHY reception test The test consists in an AP sending a single non-HT duplicate PPDU...
MHz_u m_apFrequency
the center frequency of the AP
void GenerateInterference(Ptr< WaveformGenerator > interferer, Ptr< SpectrumValue > interferencePsd, Time duration)
Generate interference function.
std::vector< bool > m_per20MhzInterference
flags per 20 MHz subchannel whether an interference should be generated on that subchannel
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
TestNonHtDuplicatePhyReception(WifiStandard apStandard, MHz_u apFrequency, uint8_t apP20Index, StasParams stasParams, std::vector< bool > per20MhzInterference={})
Constructor.
void ResetResults()
Reset the results.
std::vector< Ptr< SpectrumWifiPhy > > m_phyStas
PHYs of STAs.
void RxFailure(std::size_t index, Ptr< const WifiPsdu > psdu)
Receive failure function.
std::vector< std::tuple< WifiStandard, MHz_u, uint8_t > > StasParams
A vector containing parameters per STA: the standard, the center frequency and the P20 index.
std::vector< uint32_t > m_countRxFailureStas
count RX failure for STAs
StasParams m_stasParams
the parameters of the STAs
void SendNonHtDuplicatePpdu(MHz_u channelWidth)
Send non-HT duplicate PPDU function.
void CheckResults(std::size_t index, uint32_t expectedRxSuccess, uint32_t expectedRxFailure)
Check the results.
void StopInterference(Ptr< WaveformGenerator > interferer)
Stop interference function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void RxSuccess(std::size_t index, Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Receive success function.
WifiStandard m_apStandard
the standard to use for the AP
Ptr< SpectrumWifiPhy > m_phyAp
PHY of AP.
uint8_t m_apP20Index
the index of the primary 20 MHz channel of the AP
void DoRun() override
Implementation to actually run this TestCase.
std::vector< uint32_t > m_countRxSuccessStas
count RX success for STAs
std::vector< Ptr< WaveformGenerator > > m_phyInterferers
PHYs of interferers (1 interferer per 20 MHz subchannel)
wifi non-HT duplicate Test Suite
WifiNonHtDuplicateTestSuite()
std::optional< WifiTxVector > m_currentTxVector
If the STA is an AP STA, this holds the TXVECTOR of the PPDU that has been sent.
uint64_t m_previouslyTxPpduUid
UID of the previously sent PPDU, used by AP to recognize response HE TB PPDUs.
void Dispose()
Dispose of this Object.
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54 Mbps.
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24 Mbps.
void SetOwner(Ptr< WifiPhy > wifiPhy)
Set the WifiPhy owning this PHY entity.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
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 SetDevice(const Ptr< WifiNetDevice > device) override
Sets the device this PHY is associated with.
void DoInitialize() override
Initialize() implementation.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
Attach a SpectrumChannel to use for a given frequency range.
void DoDispose() override
Destructor implementation.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
std::tuple< uint8_t, MHz_u, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying a segment of an operating channel.
void SetReceiveErrorCallback(RxErrorCallback callback)
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
void SetOperatingChannel(const WifiPhyOperatingChannel &channel)
If the standard for this object has not been set yet, store the channel settings corresponding to the...
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void SetReceiveOkCallback(RxOkCallback callback)
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static ConstIterator FindFirst(uint8_t number, MHz_u frequency, MHz_u width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first frequency segment matching the specified parameters.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetTriggerResponding(bool triggerResponding)
Set the Trigger Responding parameter to the given value.
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
MHz_u GetChannelWidth() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#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 ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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::vector< BandInfo > Bands
Container of BandInfo.
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Information about CTS responses to expect in the test.
MHz_u bw
the width of the CTS response
bool discard
flag whether the CTS response shall be discarded
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband
RxSignalInfo structure containing info on the received signal.
constexpr MHz_u DEFAULT_FREQUENCY
static WifiNonHtDuplicateTestSuite wifiNonHtDuplicateTestSuite
the test suite