From 58500c41dc44d7cd875d9363ba5fcad158c49e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 11 Jun 2023 10:54:52 +0200 Subject: [PATCH] wifi: Add tests for 80+80MHz operating channel under different primary 20MHz index and segment orders --- src/wifi/test/wifi-operating-channel-test.cc | 467 +++++++++++++++++++ 1 file changed, 467 insertions(+) diff --git a/src/wifi/test/wifi-operating-channel-test.cc b/src/wifi/test/wifi-operating-channel-test.cc index 5dcbae367..7186188b7 100644 --- a/src/wifi/test/wifi-operating-channel-test.cc +++ b/src/wifi/test/wifi-operating-channel-test.cc @@ -17,8 +17,11 @@ * Author: Sébastien Deronne */ +#include "ns3/he-phy.h" +#include "ns3/he-ppdu.h" #include "ns3/test.h" #include "ns3/wifi-phy-operating-channel.h" +#include "ns3/wifi-psdu.h" using namespace ns3; @@ -214,6 +217,469 @@ SetWifiOperatingChannelTest::DoRun() true); } +/** + * \ingroup wifi-test + * \ingroup tests + * + * \brief Test the operating channel functions for 80+80MHz. + */ +class WifiPhyChannel80Plus80Test : public TestCase +{ + public: + /** + * Constructor + */ + WifiPhyChannel80Plus80Test(); + ~WifiPhyChannel80Plus80Test() override = default; + + private: + void DoRun() override; + + /** + * Create a dummy PSDU whose payload is 1000 bytes + * \return a dummy PSDU whose payload is 1000 bytes + */ + Ptr CreateDummyPsdu(); + + /** + * Create a HE PPDU + * \param bandwidth the bandwidth used for the transmission the PPDU in MHz + * \param channel the operating channel of the PHY used for the transmission + * \return a HE PPDU + */ + Ptr CreateDummyHePpdu(ChannelWidthMhz bandwidth, + const WifiPhyOperatingChannel& channel); + + WifiPhyOperatingChannel m_channel; //!< operating channel +}; + +WifiPhyChannel80Plus80Test::WifiPhyChannel80Plus80Test() + : TestCase("Check operating channel functions for 80+80MHz") +{ +} + +Ptr +WifiPhyChannel80Plus80Test::CreateDummyPsdu() +{ + Ptr pkt = Create(1000); + WifiMacHeader hdr; + hdr.SetType(WIFI_MAC_QOSDATA); + hdr.SetQosTid(0); + return Create(pkt, hdr); +} + +Ptr +WifiPhyChannel80Plus80Test::CreateDummyHePpdu(ChannelWidthMhz bandwidth, + const WifiPhyOperatingChannel& channel) +{ + WifiTxVector txVector = + WifiTxVector(HePhy::GetHeMcs0(), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, bandwidth, false); + Ptr psdu = CreateDummyPsdu(); + return Create(psdu, txVector, channel, MicroSeconds(100), 0); +} + +void +WifiPhyChannel80Plus80Test::DoRun() +{ + // P20 is in first segment and segments are provided in increasing frequency order + { + m_channel.Set({{42, 0, 80, WIFI_PHY_BAND_5GHZ}, {106, 0, 80, WIFI_PHY_BAND_5GHZ}}, + WIFI_STANDARD_UNSPECIFIED); + m_channel.SetPrimary20Index(3); + + const auto indexPrimary160Mhz = m_channel.GetPrimaryChannelIndex(160); + NS_TEST_ASSERT_MSG_EQ(indexPrimary160Mhz, 0, "Primary 160 MHz channel shall have index 0"); + const auto indexPrimary80Mhz = m_channel.GetPrimaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexPrimary80Mhz, 0, "Primary 80 MHz channel shall have index 0"); + const auto indexPrimary40Mhz = m_channel.GetPrimaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexPrimary40Mhz, 1, "Primary 40 MHz channel shall have index 1"); + const auto indexPrimary20Mhz = m_channel.GetPrimaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexPrimary20Mhz, 3, "Primary 20 MHz channel shall have index 3"); + + const auto indexSecondary80Mhz = m_channel.GetSecondaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexSecondary80Mhz, + 1, + "Secondary 80 MHz channel shall have index 1"); + const auto indexSecondary40Mhz = m_channel.GetSecondaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexSecondary40Mhz, + 0, + "Secondary 40 MHz channel shall have index 0"); + const auto indexSecondary20Mhz = m_channel.GetSecondaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexSecondary20Mhz, + 2, + "Secondary 20 MHz channel shall have index 2"); + + const auto primary80MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(primary80MhzCenterFrequency, + 5210, + "Primary 80 MHz channel center frequency shall be 5210 MHz"); + const auto primary40MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(primary40MhzCenterFrequency, + 5230, + "Primary 40 MHz channel center frequency shall be 5230 MHz"); + const auto primary20MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(primary20MhzCenterFrequency, + 5240, + "Primary 20 MHz channel center frequency shall be 5240 MHz"); + + const auto secondary80MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(secondary80MhzCenterFrequency, + 5530, + "Secondary 80 MHz channel center frequency shall be 5530 MHz"); + const auto secondary40MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(secondary40MhzCenterFrequency, + 5190, + "Secondary 40 MHz channel center frequency shall be 5190 MHz"); + const auto secondary20MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(secondary20MhzCenterFrequency, + 5220, + "Secondary 20 MHz channel center frequency shall be 5220 MHz"); + + const auto primary80MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(80, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary80MhzChannelNumber, + 42, + "Primary 80 MHz channel number shall be 42"); + const auto primary40MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(40, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary40MhzChannelNumber, + 46, + "Primary 40 MHz channel number shall be 46"); + const auto primary20MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(20, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary20MhzChannelNumber, + 48, + "Primary 20 MHz channel number shall be 48"); + + auto ppdu160MHz = CreateDummyHePpdu(160, m_channel); + auto txCenterFreqs160MHz = ppdu160MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.size(), 2, "2 segments are covered by 160 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.front(), + 5210, + "Center frequency of first segment shall be 5210 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.back(), + 5530, + "Center frequency of second segment shall be 5530 MHz"); + auto ppdu80MHz = CreateDummyHePpdu(80, m_channel); + auto txCenterFreqs80MHz = ppdu80MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.size(), 1, "1 segment is covered by 80 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.front(), + 5210, + "Center frequency for 80 MHz shall be 5210 MHz"); + auto ppdu40MHz = CreateDummyHePpdu(40, m_channel); + auto txCenterFreqs40MHz = ppdu40MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.size(), 1, "1 segment is covered by 40 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.front(), + 5230, + "Center frequency for 40 MHz shall be 5230 MHz"); + auto ppdu20MHz = CreateDummyHePpdu(20, m_channel); + auto txCenterFreqs20MHz = ppdu20MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.size(), 1, "1 segment is covered by 20 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.front(), + 5240, + "Center frequency for 20 MHz shall be 5240 MHz"); + } + + // P20 is in second segment and segments are provided in increasing frequency order + { + m_channel.Set({{42, 0, 80, WIFI_PHY_BAND_5GHZ}, {106, 0, 80, WIFI_PHY_BAND_5GHZ}}, + WIFI_STANDARD_UNSPECIFIED); + m_channel.SetPrimary20Index(4); + + const auto indexPrimary160Mhz = m_channel.GetPrimaryChannelIndex(160); + NS_TEST_ASSERT_MSG_EQ(indexPrimary160Mhz, 0, "Primary 160 MHz channel shall have index 0"); + const auto indexPrimary80Mhz = m_channel.GetPrimaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexPrimary80Mhz, 1, "Primary 80 MHz channel shall have index 1"); + const auto indexPrimary40Mhz = m_channel.GetPrimaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexPrimary40Mhz, 2, "Primary 40 MHz channel shall have index 2"); + const auto indexPrimary20Mhz = m_channel.GetPrimaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexPrimary20Mhz, 4, "Primary 20 MHz channel shall have index 4"); + + const auto indexSecondary80Mhz = m_channel.GetSecondaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexSecondary80Mhz, + 0, + "Secondary 80 MHz channel shall have index 0"); + const auto indexSecondary40Mhz = m_channel.GetSecondaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexSecondary40Mhz, + 3, + "Secondary 40 MHz channel shall have index 3"); + const auto indexSecondary20Mhz = m_channel.GetSecondaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexSecondary20Mhz, + 5, + "Secondary 20 MHz channel shall have index 5"); + + const auto primary80MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(primary80MhzCenterFrequency, + 5530, + "Primary 80 MHz channel center frequency shall be 5530 MHz"); + const auto primary40MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(primary40MhzCenterFrequency, + 5510, + "Primary 40 MHz channel center frequency shall be 5510 MHz"); + const auto primary20MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(primary20MhzCenterFrequency, + 5500, + "Primary 20 MHz channel center frequency shall be 5500 MHz"); + + const auto secondary80MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(secondary80MhzCenterFrequency, + 5210, + "Secondary 80 MHz channel center frequency shall be 5210 MHz"); + const auto secondary40MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(secondary40MhzCenterFrequency, + 5550, + "Secondary 40 MHz channel center frequency shall be 5550 MHz"); + const auto secondary20MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(secondary20MhzCenterFrequency, + 5520, + "Secondary 20 MHz channel center frequency shall be 5520 MHz"); + + const auto primary80MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(80, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary80MhzChannelNumber, + 106, + "Primary 80 MHz channel number shall be 106"); + const auto primary40MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(40, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary40MhzChannelNumber, + 102, + "Primary 40 MHz channel number shall be 102"); + const auto primary20MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(20, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary20MhzChannelNumber, + 100, + "Primary 20 MHz channel number shall be 100"); + + auto ppdu160MHz = CreateDummyHePpdu(160, m_channel); + auto txCenterFreqs160MHz = ppdu160MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.size(), 2, "2 segments are covered by 160 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.front(), + 5530, + "Center frequency of first segment shall be 5530 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.back(), + 5210, + "Center frequency of second segment shall be 5210 MHz"); + auto ppdu80MHz = CreateDummyHePpdu(80, m_channel); + auto txCenterFreqs80MHz = ppdu80MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.size(), 1, "1 segment is covered by 80 MHz"); + NS_ASSERT(txCenterFreqs80MHz.front() == 5530); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.front(), + 5530, + "Center frequency for 80 MHz shall be 5530 MHz"); + auto ppdu40MHz = CreateDummyHePpdu(40, m_channel); + auto txCenterFreqs40MHz = ppdu40MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.size(), 1, "1 segment is covered by 40 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.front(), + 5510, + "Center frequency for 40 MHz shall be 5510 MHz"); + auto ppdu20MHz = CreateDummyHePpdu(20, m_channel); + auto txCenterFreqs20MHz = ppdu20MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.size(), 1, "1 segment is covered by 20 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.front(), + 5500, + "Center frequency for 20 MHz shall be 5500 MHz"); + } + + // P20 is in first segment and segments are provided in decreasing frequency order + { + m_channel.Set({{106, 0, 80, WIFI_PHY_BAND_5GHZ}, {42, 0, 80, WIFI_PHY_BAND_5GHZ}}, + WIFI_STANDARD_UNSPECIFIED); + m_channel.SetPrimary20Index(3); + + const auto indexPrimary160Mhz = m_channel.GetPrimaryChannelIndex(160); + NS_TEST_ASSERT_MSG_EQ(indexPrimary160Mhz, 0, "Primary 160 MHz channel shall have index 0"); + const auto indexPrimary80Mhz = m_channel.GetPrimaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexPrimary80Mhz, 0, "Primary 80 MHz channel shall have index 0"); + const auto indexPrimary40Mhz = m_channel.GetPrimaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexPrimary40Mhz, 1, "Primary 40 MHz channel shall have index 1"); + const auto indexPrimary20Mhz = m_channel.GetPrimaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexPrimary20Mhz, 3, "Primary 20 MHz channel shall have index 3"); + + const auto indexSecondary80Mhz = m_channel.GetSecondaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexSecondary80Mhz, + 1, + "Secondary 80 MHz channel shall have index 1"); + const auto indexSecondary40Mhz = m_channel.GetSecondaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexSecondary40Mhz, + 0, + "Secondary 40 MHz channel shall have index 0"); + const auto indexSecondary20Mhz = m_channel.GetSecondaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexSecondary20Mhz, + 2, + "Secondary 20 MHz channel shall have index 2"); + + const auto primary80MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(primary80MhzCenterFrequency, + 5210, + "Primary 80 MHz channel center frequency shall be 5210 MHz"); + const auto primary40MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(primary40MhzCenterFrequency, + 5230, + "Primary 40 MHz channel center frequency shall be 5230 MHz"); + const auto primary20MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(primary20MhzCenterFrequency, + 5240, + "Primary 20 MHz channel center frequency shall be 5240 MHz"); + + const auto secondary80MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(secondary80MhzCenterFrequency, + 5530, + "Secondary 80 MHz channel center frequency shall be 5530 MHz"); + const auto secondary40MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(secondary40MhzCenterFrequency, + 5190, + "Secondary 40 MHz channel center frequency shall be 5190 MHz"); + const auto secondary20MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(secondary20MhzCenterFrequency, + 5220, + "Secondary 20 MHz channel center frequency shall be 5220 MHz"); + + const auto primary80MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(80, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary80MhzChannelNumber, + 42, + "Primary 80 MHz channel number shall be 42"); + const auto primary40MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(40, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary40MhzChannelNumber, + 46, + "Primary 40 MHz channel number shall be 46"); + const auto primary20MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(20, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary20MhzChannelNumber, + 48, + "Primary 20 MHz channel number shall be 48"); + + auto ppdu160MHz = CreateDummyHePpdu(160, m_channel); + auto txCenterFreqs160MHz = ppdu160MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.size(), 2, "2 segments are covered by 160 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.front(), + 5210, + "Center frequency of first segment shall be 5210 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.back(), + 5530, + "Center frequency of second segment shall be 5530 MHz"); + auto ppdu80MHz = CreateDummyHePpdu(80, m_channel); + auto txCenterFreqs80MHz = ppdu80MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.size(), 1, "1 segment is covered by 80 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.front(), + 5210, + "Center frequency for 80 MHz shall be 5210 MHz"); + auto ppdu40MHz = CreateDummyHePpdu(40, m_channel); + auto txCenterFreqs40MHz = ppdu40MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.size(), 1, "1 segment is covered by 40 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.front(), + 5230, + "Center frequency for 40 MHz shall be 5230 MHz"); + auto ppdu20MHz = CreateDummyHePpdu(20, m_channel); + auto txCenterFreqs20MHz = ppdu20MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.size(), 1, "1 segment is covered by 20 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.front(), + 5240, + "Center frequency for 20 MHz shall be 5240 MHz"); + } + + // P20 is in second segment and segments are provided in decreasing frequency order + { + m_channel.Set({{106, 0, 80, WIFI_PHY_BAND_5GHZ}, {42, 0, 80, WIFI_PHY_BAND_5GHZ}}, + WIFI_STANDARD_UNSPECIFIED); + m_channel.SetPrimary20Index(4); + + const auto indexPrimary160Mhz = m_channel.GetPrimaryChannelIndex(160); + NS_TEST_ASSERT_MSG_EQ(indexPrimary160Mhz, 0, "Primary 160 MHz channel shall have index 0"); + const auto indexPrimary80Mhz = m_channel.GetPrimaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexPrimary80Mhz, 1, "Primary 80 MHz channel shall have index 1"); + const auto indexPrimary40Mhz = m_channel.GetPrimaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexPrimary40Mhz, 2, "Primary 40 MHz channel shall have index 2"); + const auto indexPrimary20Mhz = m_channel.GetPrimaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexPrimary20Mhz, 4, "Primary 20 MHz channel shall have index 4"); + + const auto indexSecondary80Mhz = m_channel.GetSecondaryChannelIndex(80); + NS_TEST_ASSERT_MSG_EQ(indexSecondary80Mhz, + 0, + "Secondary 80 MHz channel shall have index 0"); + const auto indexSecondary40Mhz = m_channel.GetSecondaryChannelIndex(40); + NS_TEST_ASSERT_MSG_EQ(indexSecondary40Mhz, + 3, + "Secondary 40 MHz channel shall have index 3"); + const auto indexSecondary20Mhz = m_channel.GetSecondaryChannelIndex(20); + NS_TEST_ASSERT_MSG_EQ(indexSecondary20Mhz, + 5, + "Secondary 20 MHz channel shall have index 5"); + + const auto primary80MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(primary80MhzCenterFrequency, + 5530, + "Primary 80 MHz channel center frequency shall be 5530 MHz"); + const auto primary40MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(primary40MhzCenterFrequency, + 5510, + "Primary 40 MHz channel center frequency shall be 5510 MHz"); + const auto primary20MhzCenterFrequency = m_channel.GetPrimaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(primary20MhzCenterFrequency, + 5500, + "Primary 20 MHz channel center frequency shall be 5500 MHz"); + + const auto secondary80MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(80); + NS_TEST_ASSERT_MSG_EQ(secondary80MhzCenterFrequency, + 5210, + "Secondary 80 MHz channel center frequency shall be 5210 MHz"); + const auto secondary40MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(40); + NS_TEST_ASSERT_MSG_EQ(secondary40MhzCenterFrequency, + 5550, + "Secondary 40 MHz channel center frequency shall be 5550 MHz"); + const auto secondary20MhzCenterFrequency = m_channel.GetSecondaryChannelCenterFrequency(20); + NS_TEST_ASSERT_MSG_EQ(secondary20MhzCenterFrequency, + 5520, + "Secondary 20 MHz channel center frequency shall be 5520 MHz"); + + const auto primary80MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(80, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary80MhzChannelNumber, + 106, + "Primary 80 MHz channel number shall be 106"); + const auto primary40MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(40, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary40MhzChannelNumber, + 102, + "Primary 40 MHz channel number shall be 102"); + const auto primary20MhzChannelNumber = + m_channel.GetPrimaryChannelNumber(20, WIFI_STANDARD_80211ax); + NS_TEST_ASSERT_MSG_EQ(primary20MhzChannelNumber, + 100, + "Primary 20 MHz channel number shall be 100"); + + auto ppdu160MHz = CreateDummyHePpdu(160, m_channel); + auto txCenterFreqs160MHz = ppdu160MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.size(), 2, "2 segments are covered by 160 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.front(), + 5530, + "Center frequency of first segment shall be 5530 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs160MHz.back(), + 5210, + "Center frequency of second segment shall be 5210 MHz"); + auto ppdu80MHz = CreateDummyHePpdu(80, m_channel); + auto txCenterFreqs80MHz = ppdu80MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.size(), 1, "1 segment is covered by 80 MHz"); + NS_ASSERT(txCenterFreqs80MHz.front() == 5530); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs80MHz.front(), + 5530, + "Center frequency for 80 MHz shall be 5530 MHz"); + auto ppdu40MHz = CreateDummyHePpdu(40, m_channel); + auto txCenterFreqs40MHz = ppdu40MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.size(), 1, "1 segment is covered by 40 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs40MHz.front(), + 5510, + "Center frequency for 40 MHz shall be 5510 MHz"); + auto ppdu20MHz = CreateDummyHePpdu(20, m_channel); + auto txCenterFreqs20MHz = ppdu20MHz->GetTxCenterFreqs(); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.size(), 1, "1 segment is covered by 20 MHz"); + NS_TEST_ASSERT_MSG_EQ(txCenterFreqs20MHz.front(), + 5500, + "Center frequency for 20 MHz shall be 5500 MHz"); + } +} + /** * \ingroup wifi-test * \ingroup tests @@ -230,6 +696,7 @@ WifiOperatingChannelTestSuite::WifiOperatingChannelTestSuite() : TestSuite("wifi-operating-channel", UNIT) { AddTestCase(new SetWifiOperatingChannelTest(), TestCase::QUICK); + AddTestCase(new WifiPhyChannel80Plus80Test(), TestCase::QUICK); } static WifiOperatingChannelTestSuite g_wifiOperatingChannelTestSuite; ///< the test suite