10#include "ns3/he-ppdu.h"
11#include "ns3/interference-helper.h"
13#include "ns3/multi-model-spectrum-channel.h"
14#include "ns3/nist-error-rate-model.h"
16#include "ns3/spectrum-wifi-phy.h"
17#include "ns3/string.h"
19#include "ns3/wifi-net-device.h"
20#include "ns3/wifi-phy-operating-channel.h"
21#include "ns3/wifi-psdu.h"
22#include "ns3/wifi-utils.h"
44 void DoRun()
override;
58 const std::vector<FrequencyChannelInfo>&
segments,
69 :
TestCase(
"Check configuration of the operating channel")
75 const std::vector<FrequencyChannelInfo>&
segments,
89 catch (
const std::runtime_error&)
95 "Exception thrown mismatch for run: " <<
runInfo);
101 "Operating channel has an incorrect channel width type for run: " <<
runInfo);
104 "Incorrect number of frequency segments for run: " <<
runInfo);
110 "Operating channel has an incorrect channel number at segment "
114 "Operating channel has an incorrect center frequency at segment "
118 "Operating channel has an incorrect channel width at segment "
122 "Operating channel has an incorrect band for run: " <<
runInfo);
130 RunOne(
"dummy channel with all inputs unset",
136 RunOne(
"default 20 MHz OFDM channel operating on channel 36",
141 WifiChannelWidthType::CW_20MHZ,
144 RunOne(
"default 40 MHz OFDM channel operating on channel 38",
149 WifiChannelWidthType::CW_40MHZ,
152 RunOne(
"default 80 MHz OFDM channel operating on channel 42",
157 WifiChannelWidthType::CW_80MHZ,
160 RunOne(
"default 160 MHz (contiguous) OFDM channel operating on channel 50",
165 WifiChannelWidthType::CW_160MHZ,
168 RunOne(
"valid 80+80 MHz (non-contiguous) OFDM channel operating on channels 42 and 106",
174 WifiChannelWidthType::CW_80_PLUS_80MHZ,
178 RunOne(
"invalid 80+80 MHz (non-contiguous) OFDM channel higher channel not being 80 MHz",
185 RunOne(
"invalid 80+80 MHz (non-contiguous) OFDM channel lower channel not being 80 MHz",
192 RunOne(
"invalid 80+80 MHz (non-contiguous) OFDM channel with both segments configured on the "
200 RunOne(
"invalid 80+80 MHz (non-contiguous) OFDM channel with segments configured to be "
201 "contiguous (lower before higher)",
208 RunOne(
"invalid 80+80 MHz (non-contiguous) OFDM channel with segments configured to be "
209 "contiguous (higher before lower)",
216 RunOne(
"invalid 80+80 MHz (non-contiguous) OFDM channel with each segments configured on a "
243 void DoRun()
override;
261 :
TestCase(
"Check conversion from attribute to the operating channel")
275 m_phy->SetErrorRateModel(error);
276 m_phy->SetDevice(dev);
280 node->AddDevice(dev);
304 catch (
const std::runtime_error&)
318 m_phy->GetOperatingChannel().GetWidthType(),
320 "Operating channel has an incorrect channel width type for channel settings "
327 "Operating channel has an incorrect number of segments for channel settings "
334 "Operating channel has an incorrect channel number at segment "
338 "Operating channel has an incorrect center frequency at segment "
342 "Operating channel has an incorrect channel width at segment "
346 "Operating channel has an incorrect band for channel settings "
352 "Operating channel has an incorrect P20 index for channel settings "
360 RunOne(
"{36, 40, BAND_UNSPECIFIED, 0}", WifiChannelWidthType::UNKNOWN, {}, 0);
363 RunOne(
"{0, 0, BAND_UNSPECIFIED, 0}",
364 WifiChannelWidthType::CW_80MHZ,
369 RunOne(
"{0, 0, BAND_UNSPECIFIED, 0};{0, 0, BAND_UNSPECIFIED, 0}",
370 WifiChannelWidthType::CW_80_PLUS_80MHZ,
376 RunOne(
"{42, 0, BAND_UNSPECIFIED, 0};{0, 0, BAND_UNSPECIFIED, 0}",
377 WifiChannelWidthType::CW_80_PLUS_80MHZ,
383 RunOne(
"{0, 0, BAND_UNSPECIFIED, 0};{42, 0, BAND_UNSPECIFIED, 0}",
384 WifiChannelWidthType::UNKNOWN,
389 RunOne(
"{106, 0, BAND_UNSPECIFIED, 0};{0, 0, BAND_UNSPECIFIED, 0}",
390 WifiChannelWidthType::CW_80_PLUS_80MHZ,
396 RunOne(
"{36, 0, BAND_UNSPECIFIED, 0}",
397 WifiChannelWidthType::CW_20MHZ,
402 RunOne(
"{38, 0, BAND_UNSPECIFIED, 0}",
403 WifiChannelWidthType::CW_40MHZ,
408 RunOne(
"{42, 0, BAND_UNSPECIFIED, 0}",
409 WifiChannelWidthType::CW_80MHZ,
414 RunOne(
"{50, 0, BAND_UNSPECIFIED, 0}",
415 WifiChannelWidthType::CW_160MHZ,
420 RunOne(
"{42, 0, BAND_UNSPECIFIED, 0};{106, 0, BAND_UNSPECIFIED, 0}",
421 WifiChannelWidthType::CW_80_PLUS_80MHZ,
427 RunOne(
"{42, 0, BAND_UNSPECIFIED, 1};{106, 0, BAND_UNSPECIFIED, 2}",
428 WifiChannelWidthType::CW_80_PLUS_80MHZ,
434 RunOne(
"{0, 20, BAND_UNSPECIFIED, 0}",
435 WifiChannelWidthType::CW_20MHZ,
440 RunOne(
"{0, 40, BAND_UNSPECIFIED, 0}",
441 WifiChannelWidthType::CW_40MHZ,
446 RunOne(
"{0, 80, BAND_UNSPECIFIED, 0}",
447 WifiChannelWidthType::CW_80MHZ,
452 RunOne(
"{0, 160, BAND_UNSPECIFIED, 0}",
453 WifiChannelWidthType::CW_160MHZ,
458 RunOne(
"{0, 80, BAND_UNSPECIFIED, 0};{0, 80, BAND_UNSPECIFIED, 0}",
459 WifiChannelWidthType::CW_80_PLUS_80MHZ,
481 void DoRun()
override;
501 :
TestCase(
"Check operating channel functions for 80+80MHz")
554 "Secondary 80 MHz channel shall have index 1");
558 "Secondary 40 MHz channel shall have index 0");
562 "Secondary 20 MHz channel shall have index 2");
568 "Primary 80 MHz channel center frequency shall be 5210 MHz");
573 "Primary 40 MHz channel center frequency shall be 5230 MHz");
578 "Primary 20 MHz channel center frequency shall be 5240 MHz");
584 "Secondary 80 MHz channel center frequency shall be 5530 MHz");
589 "Secondary 40 MHz channel center frequency shall be 5190 MHz");
594 "Secondary 20 MHz channel center frequency shall be 5220 MHz");
600 "Primary 80 MHz channel number shall be 42");
605 "Primary 40 MHz channel number shall be 46");
610 "Primary 20 MHz channel number shall be 48");
617 "Center frequency of first segment shall be 5210 MHz");
620 "Center frequency of second segment shall be 5530 MHz");
626 "Center frequency for 80 MHz shall be 5210 MHz");
632 "Center frequency for 40 MHz shall be 5230 MHz");
638 "Center frequency for 20 MHz shall be 5240 MHz");
660 "Secondary 80 MHz channel shall have index 0");
664 "Secondary 40 MHz channel shall have index 3");
668 "Secondary 20 MHz channel shall have index 5");
674 "Primary 80 MHz channel center frequency shall be 5530 MHz");
679 "Primary 40 MHz channel center frequency shall be 5510 MHz");
684 "Primary 20 MHz channel center frequency shall be 5500 MHz");
690 "Secondary 80 MHz channel center frequency shall be 5210 MHz");
695 "Secondary 40 MHz channel center frequency shall be 5550 MHz");
700 "Secondary 20 MHz channel center frequency shall be 5520 MHz");
706 "Primary 80 MHz channel number shall be 106");
711 "Primary 40 MHz channel number shall be 102");
716 "Primary 20 MHz channel number shall be 100");
723 "Center frequency of first segment shall be 5530 MHz");
726 "Center frequency of second segment shall be 5210 MHz");
732 "Center frequency for 80 MHz shall be 5530 MHz");
738 "Center frequency for 40 MHz shall be 5510 MHz");
744 "Center frequency for 20 MHz shall be 5500 MHz");
766 "Secondary 80 MHz channel shall have index 1");
770 "Secondary 40 MHz channel shall have index 0");
774 "Secondary 20 MHz channel shall have index 2");
780 "Primary 80 MHz channel center frequency shall be 5210 MHz");
785 "Primary 40 MHz channel center frequency shall be 5230 MHz");
790 "Primary 20 MHz channel center frequency shall be 5240 MHz");
796 "Secondary 80 MHz channel center frequency shall be 5530 MHz");
801 "Secondary 40 MHz channel center frequency shall be 5190 MHz");
806 "Secondary 20 MHz channel center frequency shall be 5220 MHz");
812 "Primary 80 MHz channel number shall be 42");
817 "Primary 40 MHz channel number shall be 46");
822 "Primary 20 MHz channel number shall be 48");
829 "Center frequency of first segment shall be 5210 MHz");
832 "Center frequency of second segment shall be 5530 MHz");
838 "Center frequency for 80 MHz shall be 5210 MHz");
844 "Center frequency for 40 MHz shall be 5230 MHz");
850 "Center frequency for 20 MHz shall be 5240 MHz");
872 "Secondary 80 MHz channel shall have index 0");
876 "Secondary 40 MHz channel shall have index 3");
880 "Secondary 20 MHz channel shall have index 5");
886 "Primary 80 MHz channel center frequency shall be 5530 MHz");
891 "Primary 40 MHz channel center frequency shall be 5510 MHz");
896 "Primary 20 MHz channel center frequency shall be 5500 MHz");
902 "Secondary 80 MHz channel center frequency shall be 5210 MHz");
907 "Secondary 40 MHz channel center frequency shall be 5550 MHz");
912 "Secondary 20 MHz channel center frequency shall be 5520 MHz");
918 "Primary 80 MHz channel number shall be 106");
923 "Primary 40 MHz channel number shall be 102");
928 "Primary 20 MHz channel number shall be 100");
935 "Center frequency of first segment shall be 5530 MHz");
938 "Center frequency of second segment shall be 5210 MHz");
944 "Center frequency for 80 MHz shall be 5530 MHz");
950 "Center frequency for 40 MHz shall be 5510 MHz");
956 "Center frequency for 20 MHz shall be 5500 MHz");
Test the conversion from PHY ChannelSettings attribute to WifiPhyOperatingChannel.
~PhyChannelSettingsToOperatingChannelTest() override=default
void DoRun() override
Implementation to actually run this TestCase.
PhyChannelSettingsToOperatingChannelTest()
Constructor.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void RunOne(const std::string &channelSettings, WifiChannelWidthType expectedWidthType, const std::vector< FrequencyChannelInfo > &expectedSegments, uint8_t expectedP20Index)
Run one function.
Ptr< SpectrumWifiPhy > m_phy
the PHY
Test the WifiPhyOperatingChannel::Set() method.
WifiPhyOperatingChannel m_channel
operating channel
SetWifiOperatingChannelTest()
Constructor.
~SetWifiOperatingChannelTest() override=default
void DoRun() override
Implementation to actually run this TestCase.
void RunOne(const std::string &runInfo, const std::vector< FrequencyChannelInfo > &segments, WifiStandard standard, WifiPhyBand band, bool expectExceptionThrown, WifiChannelWidthType expectedWidth=WifiChannelWidthType::UNKNOWN, const std::vector< FrequencyChannelInfo > &expectedSegments={})
Run one function.
wifi operating channel test suite
WifiOperatingChannelTestSuite()
Test the operating channel functions for 80+80MHz.
Ptr< HePpdu > CreateDummyHePpdu(MHz_u bandwidth, const WifiPhyOperatingChannel &channel)
Create a HE PPDU.
Ptr< WifiPsdu > CreateDummyPsdu()
Create a dummy PSDU whose payload is 1000 bytes.
WifiPhyOperatingChannel m_channel
operating channel
~WifiPhyChannel80Plus80Test() override=default
void DoRun() override
Implementation to actually run this TestCase.
WifiPhyChannel80Plus80Test()
Constructor.
static WifiMode GetHeMcs0()
Return MCS 0 from HE MCS values.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Class that keeps track of all information about the current PHY operating channel.
uint8_t GetNumber(std::size_t segment=0) const
Return the channel number for a given frequency segment.
WifiChannelWidthType GetWidthType() const
Return the width type of the operating channel.
MHz_u GetSecondaryChannelCenterFrequency(MHz_u secondaryChannelWidth) const
Get the center frequency of the secondary channel of the given width.
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
uint8_t GetSecondaryChannelIndex(MHz_u secondaryChannelWidth) const
If the operating channel width is made of a multiple of 20 MHz, return the index of the secondary cha...
std::size_t GetNSegments() const
Get the number of frequency segments in the operating channel.
void Set(const std::vector< FrequencyChannelInfo > &segments, WifiStandard standard)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
MHz_u GetWidth(std::size_t segment=0) const
Return the channel width for a given frequency segment.
uint8_t GetPrimaryChannelIndex(MHz_u primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
MHz_u GetPrimaryChannelCenterFrequency(MHz_u primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
MHz_u GetFrequency(std::size_t segment=0) const
Return the center frequency for a given frequency segment.
WifiPhyBand GetPhyBand() const
Return the PHY band of the operating channel.
uint8_t GetPrimaryChannelNumber(MHz_u primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
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 ",...
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyBand
Identifies the PHY band.
WifiChannelWidthType
Enumeration of the possible channel widths.
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static WifiOperatingChannelTestSuite g_wifiOperatingChannelTestSuite
the test suite