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"
130 std::shared_ptr<MuRtsCtsHePhy>
202 using StasParams = std::vector<std::tuple<WifiStandard, MHz_u, uint8_t>>;
218 std::vector<bool> per20MhzInterference = {});
223 void DoRun()
override;
237 const std::vector<bool>& statusPerMpdu);
294 std::vector<Ptr<WaveformGenerator>>
303 std::vector<bool> per20MhzInterference)
304 :
TestCase{
"non-HT duplicate PHY reception test"},
355 interferer->SetTxPowerSpectralDensity(interferencePsd);
356 interferer->SetPeriod(duration);
376 const std::vector<bool>& )
379 const auto expectedWidth =
380 std::min(
m_phyAp->GetChannelWidth(),
m_phyStas.at(index)->GetChannelWidth());
383 "Incorrect channel width in TXVECTOR");
399 NS_LOG_FUNCTION(
this << index << expectedRxSuccess << expectedRxFailure);
402 "The number of successfully received packets by STA "
403 << index <<
" is not correct!");
406 "The number of unsuccessfully received packets by STA "
407 << index <<
" is not correct!");
416 spectrumChannel->AddPropagationLossModel(lossModel);
418 spectrumChannel->SetPropagationDelayModel(delayModel);
424 m_phyAp->SetInterferenceHelper(apInterferenceHelper);
426 m_phyAp->SetErrorRateModel(apErrorModel);
428 m_phyAp->AddChannel(spectrumChannel);
431 m_phyAp->SetMobility(apMobility);
433 apNode->AggregateObject(apMobility);
434 apNode->AddDevice(apDev);
442 staPhy->SetInterferenceHelper(sta1InterferenceHelper);
444 staPhy->SetErrorRateModel(sta1ErrorModel);
445 staPhy->SetDevice(staDev);
446 staPhy->AddChannel(spectrumChannel);
447 staPhy->ConfigureStandard(std::get<0>(staParams));
448 staPhy->SetReceiveOkCallback(
450 staPhy->SetReceiveErrorCallback(
453 staPhy->SetMobility(staMobility);
454 staDev->SetPhy(staPhy);
455 staNode->AggregateObject(staMobility);
456 staNode->AddDevice(staDev);
475 phyInterferer->SetDevice(interfererDev);
476 phyInterferer->SetChannel(spectrumChannel);
477 phyInterferer->SetDutyCycle(1);
478 interfererNode->AddDevice(interfererDev);
496 phyInterferer->Dispose();
497 phyInterferer =
nullptr;
506 int64_t streamNumber = 0;
507 m_phyAp->AssignStreams(streamNumber);
510 phySta->AssignStreams(streamNumber);
524 for (
const auto& [staStandard, staFrequency, staP20Index] :
m_stasParams)
532 stachannelInfo.width,
538 const auto minApCenterFrequency =
540 for (
MHz_u channelWidth{20}; channelWidth <= apchannelInfo.width; channelWidth *= 2, ++index)
555 bands.push_back(bandInfo);
558 Watt_u interferencePower{0.005};
560 *interferencePsd = interferencePower / 10e6;
569 const auto apCenterFreq =
570 m_phyAp->GetOperatingChannel().GetPrimaryChannelCenterFrequency(channelWidth);
571 const auto apMinFreq = apCenterFreq - (channelWidth / 2);
572 const auto apMaxFreq = apCenterFreq + (channelWidth / 2);
579 const MHz_u p20Width{20};
580 const auto staP20Freq =
581 m_phyStas.at(i)->GetOperatingChannel().GetPrimaryChannelCenterFrequency(p20Width);
582 const auto staP20MinFreq = staP20Freq - (p20Width / 2);
583 const auto staP20MaxFreq = staP20Freq + (p20Width / 2);
584 bool expectRx = (staP20MinFreq >= apMinFreq && staP20MaxFreq <= apMaxFreq);
585 bool expectSuccess =
true;
588 const auto index20MhzSubBand =
596 expectRx ? expectSuccess : 0,
597 expectRx ? !expectSuccess : 0);
640 void DoRun()
override;
666 const std::vector<bool>& statusPerMpdu);
698 const std::vector<CtsTxInfos>& ctsTxInfosPerSta)
699 :
TestCase{
"test PHY reception of multiple CTS frames following a MU-RTS frame"},
717 [](
const auto& lhs,
const auto& rhs) { return lhs.bw < rhs.bw; })
723 m_phyAp->SetMuRtsTxVector(txVector);
729 phySta->SetPpduUid(0);
769 m_phyStas.at(phyIndex)->Send(psdu, txVector);
777 const std::vector<bool>& )
779 NS_LOG_FUNCTION(
this << phyIndex << *psdu << rxSignalInfo << txVector);
780 std::vector<CtsTxInfos> successfulCtsInfos{};
783 std::back_inserter(successfulCtsInfos),
784 [](
const auto& info) { return !info.discard; });
785 const auto isAp = (phyIndex == 0);
791 "RX power is not correct!");
794 std::max_element(successfulCtsInfos.cbegin(),
795 successfulCtsInfos.cend(),
796 [](
const auto& lhs,
const auto& rhs) { return lhs.bw < rhs.bw; })
804 "Incorrect channel width in TXVECTOR");
819 const auto isAp = (phyIndex == 0);
835 "The number of successfully received CTS frames by AP is not correct!");
839 "The number of successfully received CTS frames by non-participating STAs is not correct!");
842 "The number of unsuccessfully received CTS frames by AP is not correct!");
845 "The number of unsuccessfully received CTS frames by non-participating "
846 "STAs is not correct!");
854 int64_t streamNumber = 0;
859 spectrumChannel->AddPropagationLossModel(lossModel);
861 spectrumChannel->SetPropagationDelayModel(delayModel);
868 apMac->SetAttribute(
"BeaconGeneration",
BooleanValue(
false));
869 apDev->SetMac(apMac);
873 m_phyAp->SetInterferenceHelper(apInterferenceHelper);
875 m_phyAp->SetErrorRateModel(apErrorModel);
877 m_phyAp->AddChannel(spectrumChannel);
879 m_phyAp->AssignStreams(streamNumber);
883 m_phyAp->SetReceiveErrorCallback(
889 [](
const auto& lhs,
const auto& rhs) { return lhs.bw < rhs.bw; })
901 m_phyAp->SetMobility(apMobility);
906 apNode->AggregateObject(apMobility);
907 apNode->AddDevice(apDev);
915 phySta->SetInterferenceHelper(staInterferenceHelper);
917 phySta->SetErrorRateModel(staErrorModel);
918 phySta->SetDevice(staDev);
919 phySta->AddChannel(spectrumChannel);
921 phySta->AssignStreams(streamNumber);
932 phySta->SetOperatingChannel(
936 phySta->SetMobility(staMobility);
937 staDev->SetPhy(phySta);
940 staNode->AggregateObject(staMobility);
941 staNode->AddDevice(staDev);
949 nonParticipatingHePhySta->SetInterferenceHelper(nonParticipatingHeStaInterferenceHelper);
951 nonParticipatingHePhySta->SetErrorRateModel(nonParticipatingHeStaErrorModel);
952 nonParticipatingHePhySta->SetDevice(nonParticipatingHeStaDev);
953 nonParticipatingHePhySta->AddChannel(spectrumChannel);
956 nonParticipatingHePhySta->SetOperatingChannel(
960 nonParticipatingHePhySta->SetMobility(nonParticipatingHeStaMobility);
961 nonParticipatingHeStaDev->SetPhy(nonParticipatingHePhySta);
964 nonParticipatingHePhySta->AssignStreams(streamNumber);
965 nonParticipatingHeStaNode->AggregateObject(nonParticipatingHeStaMobility);
966 nonParticipatingHeStaNode->AddDevice(nonParticipatingHeStaDev);
968 nonParticipatingHePhySta->SetReceiveOkCallback(
970 nonParticipatingHePhySta->SetReceiveErrorCallback(
979 nonHePhySta->SetInterferenceHelper(nonHeStaInterferenceHelper);
981 nonHePhySta->SetErrorRateModel(nonHeStaErrorModel);
982 nonHePhySta->SetDevice(nonHeStaDev);
983 nonHePhySta->AddChannel(spectrumChannel);
985 nonHePhySta->SetOperatingChannel(
988 nonHePhySta->SetMobility(nonHeStaMobility);
989 nonHeStaDev->SetPhy(nonHePhySta);
991 nonHePhySta->AssignStreams(streamNumber);
992 nonHeStaNode->AggregateObject(nonHeStaMobility);
993 nonHeStaNode->AddDevice(nonHeStaDev);
1015 for (std::size_t index = 0; index <
m_phyStas.size(); ++index)
1097 {
false,
true,
false,
false}),
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
void DoDispose() override
Destructor implementation.
std::shared_ptr< MuRtsCtsHePhy > m_muRtsCtsHePhy
Pointer to HE PHY instance used for MU-RTS/CTS PHY test.
MuRtsCtsSpectrumWifiPhy()
~MuRtsCtsSpectrumWifiPhy() override
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 RxCtsSuccess(std::size_t phyIndex, Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &statusPerMpdu)
CTS RX success function.
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 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.
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.
void RxSuccess(std::size_t index, Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &statusPerMpdu)
Receive success function.
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()
AttributeValue implementation for Boolean.
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.
HePhy(bool buildModeList=true)
Constructor for HE PHY.
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54 Mbps.
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24 Mbps.
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 DoInitialize() override
Initialize() implementation.
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.
TestCase(const TestCase &)=delete
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
static constexpr auto UNIT
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::map< WifiModulationClass, std::shared_ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
std::tuple< uint8_t, MHz_u, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying a segment of an operating channel.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
static ConstIterator FindFirst(uint8_t number, MHz_u frequency, MHz_u width, WifiStandard standard, WifiPhyBand band, ConstIterator start=GetFrequencyChannels().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.
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.
double MHz_u
MHz weak type.
std::size_t Count20MHzSubchannels(MHz_u channelWidth)
Return the number of 20 MHz subchannels covering the channel width.
double dBm_u
dBm weak type
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Hz_u MHzToHz(MHz_u val)
Convert from MHz to Hz.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
double Watt_u
Watt weak type.
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