21 #include "ns3/wifi-phy-operating-channel.h"
52 void RunOne(uint8_t primary20,
55 const std::set<uint8_t>& indices);
58 void DoRun()
override;
64 :
TestCase(
"Check computation of the indices of the 20 MHz channels covering an RU")
72 const std::set<uint8_t>& indices)
74 auto printToStr = [](
const std::set<uint8_t>& s) {
77 for (
const auto& index : s)
91 <<
" MHz, p20Index=" << +primary20 <<
" , RU=" << ru
92 <<
". Expected indices " << printToStr(indices)
93 <<
" differs from actual " << printToStr(actualIndices));
106 const uint16_t width = 20;
107 const uint8_t p20Index = 0;
110 for (std::size_t idx = 1; idx <= 9; idx++)
115 for (std::size_t idx = 1; idx <= 4; idx++)
120 for (std::size_t idx = 1; idx <= 2; idx++)
134 for (uint8_t p20Index = 0; p20Index < 2; p20Index++)
136 const uint16_t width = 20;
139 for (std::size_t idx = 1; idx <= 9; idx++)
144 for (std::size_t idx = 1; idx <= 4; idx++)
149 for (std::size_t idx = 1; idx <= 2; idx++)
158 for (uint8_t p20Index = 0; p20Index < 2; p20Index++)
160 const uint16_t width = 40;
163 for (std::size_t idx = 1; idx <= 9; idx++)
168 for (std::size_t idx = 10; idx <= 18; idx++)
173 for (std::size_t idx = 1; idx <= 4; idx++)
178 for (std::size_t idx = 5; idx <= 8; idx++)
183 for (std::size_t idx = 1; idx <= 2; idx++)
188 for (std::size_t idx = 3; idx <= 4; idx++)
206 for (uint8_t p20Index = 0; p20Index < 4; p20Index++)
208 const uint16_t width = 20;
211 for (std::size_t idx = 1; idx <= 9; idx++)
216 for (std::size_t idx = 1; idx <= 4; idx++)
221 for (std::size_t idx = 1; idx <= 2; idx++)
230 for (uint8_t p20Index = 0; p20Index < 4; p20Index++)
232 const uint16_t width = 40;
234 const uint8_t p40Index = p20Index / 2;
236 const uint8_t ch20Index0 = p40Index * 2;
237 const uint8_t ch20Index1 = p40Index * 2 + 1;
240 for (std::size_t idx = 1; idx <= 9; idx++)
245 for (std::size_t idx = 10; idx <= 18; idx++)
250 for (std::size_t idx = 1; idx <= 4; idx++)
255 for (std::size_t idx = 5; idx <= 8; idx++)
260 for (std::size_t idx = 1; idx <= 2; idx++)
265 for (std::size_t idx = 3; idx <= 4; idx++)
274 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_484_TONE, 1,
true), width, {ch20Index0, ch20Index1});
278 for (uint8_t p20Index = 0; p20Index < 4; p20Index++)
280 const uint16_t width = 80;
283 for (std::size_t idx = 1; idx <= 9; idx++)
288 for (std::size_t idx = 10; idx <= 18; idx++)
295 for (std::size_t idx = 20; idx <= 28; idx++)
300 for (std::size_t idx = 29; idx <= 37; idx++)
305 for (std::size_t idx = 1; idx <= 4; idx++)
310 for (std::size_t idx = 5; idx <= 8; idx++)
315 for (std::size_t idx = 9; idx <= 12; idx++)
320 for (std::size_t idx = 13; idx <= 16; idx++)
325 for (std::size_t idx = 1; idx <= 2; idx++)
330 for (std::size_t idx = 3; idx <= 4; idx++)
335 for (std::size_t idx = 5; idx <= 6; idx++)
340 for (std::size_t idx = 7; idx <= 8; idx++)
366 for (uint8_t p20Index = 0; p20Index < 8; p20Index++)
368 const uint16_t width = 20;
371 for (std::size_t idx = 1; idx <= 9; idx++)
376 for (std::size_t idx = 1; idx <= 4; idx++)
381 for (std::size_t idx = 1; idx <= 2; idx++)
390 for (uint8_t p20Index = 0; p20Index < 8; p20Index++)
392 const uint16_t width = 40;
394 const uint8_t p40Index = p20Index / 2;
396 const uint8_t ch20Index0 = p40Index * 2;
397 const uint8_t ch20Index1 = p40Index * 2 + 1;
400 for (std::size_t idx = 1; idx <= 9; idx++)
405 for (std::size_t idx = 10; idx <= 18; idx++)
410 for (std::size_t idx = 1; idx <= 4; idx++)
415 for (std::size_t idx = 5; idx <= 8; idx++)
420 for (std::size_t idx = 1; idx <= 2; idx++)
425 for (std::size_t idx = 3; idx <= 4; idx++)
434 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_484_TONE, 1,
true), width, {ch20Index0, ch20Index1});
438 for (uint8_t p20Index = 0; p20Index < 8; p20Index++)
440 const uint16_t width = 80;
442 const uint8_t p80Index = p20Index / 4;
444 const uint8_t ch20Index0 = p80Index * 4;
445 const uint8_t ch20Index1 = p80Index * 4 + 1;
446 const uint8_t ch20Index2 = p80Index * 4 + 2;
447 const uint8_t ch20Index3 = p80Index * 4 + 3;
450 for (std::size_t idx = 1; idx <= 9; idx++)
455 for (std::size_t idx = 10; idx <= 18; idx++)
460 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_26_TONE, 19,
true), width, {ch20Index1, ch20Index2});
462 for (std::size_t idx = 20; idx <= 28; idx++)
467 for (std::size_t idx = 29; idx <= 37; idx++)
472 for (std::size_t idx = 1; idx <= 4; idx++)
477 for (std::size_t idx = 5; idx <= 8; idx++)
482 for (std::size_t idx = 9; idx <= 12; idx++)
487 for (std::size_t idx = 13; idx <= 16; idx++)
492 for (std::size_t idx = 1; idx <= 2; idx++)
497 for (std::size_t idx = 3; idx <= 4; idx++)
502 for (std::size_t idx = 5; idx <= 6; idx++)
507 for (std::size_t idx = 7; idx <= 8; idx++)
520 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_484_TONE, 1,
true), width, {ch20Index0, ch20Index1});
522 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_484_TONE, 2,
true), width, {ch20Index2, ch20Index3});
527 {ch20Index0, ch20Index1, ch20Index2, ch20Index3});
531 for (uint8_t p20Index = 0; p20Index < 8; p20Index++)
533 const uint16_t width = 160;
535 for (
auto primary80MHz : {
true,
false})
539 const uint8_t p80Index = (primary80MHz == (p20Index < 4)) ? 0 : 1;
540 const uint8_t ch20Index0 = p80Index * 4;
541 const uint8_t ch20Index1 = p80Index * 4 + 1;
542 const uint8_t ch20Index2 = p80Index * 4 + 2;
543 const uint8_t ch20Index3 = p80Index * 4 + 3;
546 for (std::size_t idx = 1; idx <= 9; idx++)
554 for (std::size_t idx = 10; idx <= 18; idx++)
565 {ch20Index1, ch20Index2});
567 for (std::size_t idx = 20; idx <= 28; idx++)
575 for (std::size_t idx = 29; idx <= 37; idx++)
583 for (std::size_t idx = 1; idx <= 4; idx++)
591 for (std::size_t idx = 5; idx <= 8; idx++)
599 for (std::size_t idx = 9; idx <= 12; idx++)
607 for (std::size_t idx = 13; idx <= 16; idx++)
615 for (std::size_t idx = 1; idx <= 2; idx++)
623 for (std::size_t idx = 3; idx <= 4; idx++)
631 for (std::size_t idx = 5; idx <= 6; idx++)
639 for (std::size_t idx = 7; idx <= 8; idx++)
647 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_242_TONE, 1, primary80MHz), width, {ch20Index0});
649 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_242_TONE, 2, primary80MHz), width, {ch20Index1});
651 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_242_TONE, 3, primary80MHz), width, {ch20Index2});
653 RunOne(p20Index,
HeRu::RuSpec(HeRu::RU_242_TONE, 4, primary80MHz), width, {ch20Index3});
658 {ch20Index0, ch20Index1});
663 {ch20Index2, ch20Index3});
668 {ch20Index0, ch20Index1, ch20Index2, ch20Index3});
674 {0, 1, 2, 3, 4, 5, 6, 7});
Test the WifiPhyOperatingChannel::Get20MHzIndicesCoveringRu() method.
void RunOne(uint8_t primary20, HeRu::RuSpec ru, uint16_t width, const std::set< uint8_t > &indices)
Check that the indices of the 20 MHz channels covering the given RU as computed by WifiPhyOperatingCh...
WifiPhyOperatingChannel m_channel
operating channel
~Wifi20MHzIndicesCoveringRuTest() override=default
void DoRun() override
Implementation to actually run this TestCase.
Wifi20MHzIndicesCoveringRuTest()
Constructor.
wifi primary channels test suite
WifiRuAllocationTestSuite()
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Class that keeps track of all information about the current PHY operating channel.
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
void SetDefault(uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given standard and band.
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
std::set< uint8_t > Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, uint16_t width) const
Get the channel indices of the minimum subset of 20 MHz channels containing the given RU.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#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.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static WifiRuAllocationTestSuite g_wifiRuAllocationTestSuite
the test suite