From 8de21d45e78545dda4d586b8da3474ce3761ef26 Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Sun, 8 May 2022 16:25:14 +0200 Subject: [PATCH] wifi: Add test that verifies WifiTxVector content for DL MU transmissions --- src/wifi/CMakeLists.txt | 1 + src/wifi/test/wifi-phy-mu-mimo-test.cc | 180 +++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 src/wifi/test/wifi-phy-mu-mimo-test.cc diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index 93493c15d..02ac7826d 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -354,4 +354,5 @@ build_lib( test/wifi-txop-test.cc test/wifi-phy-cca-test.cc test/wifi-non-ht-dup-test.cc + test/wifi-phy-mu-mimo-test.cc ) diff --git a/src/wifi/test/wifi-phy-mu-mimo-test.cc b/src/wifi/test/wifi-phy-mu-mimo-test.cc new file mode 100644 index 000000000..e3b28fd83 --- /dev/null +++ b/src/wifi/test/wifi-phy-mu-mimo-test.cc @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2022 DERONNE SOFTWARE ENGINEERING + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Sébastien Deronne + */ + +#include "ns3/he-phy.h" +#include "ns3/log.h" +#include "ns3/simulator.h" +#include "ns3/test.h" +#include "ns3/wifi-tx-vector.h" + +#include + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE("WifiPhyMuMimoTest"); + +/** + * \ingroup wifi-test + * \ingroup tests + * + * \brief DL MU TX-VECTOR test + */ +class TestDlMuTxVector : public TestCase +{ + public: + TestDlMuTxVector(); + + private: + void DoRun() override; + + /** + * Build a TXVECTOR for DL MU with the given bandwidth and user information. + * + * \param bw the channel width of the PPDU in MHz + * \param userInfos the list of HE MU specific user transmission parameters + * + * \return the configured MU TXVECTOR + */ + static WifiTxVector BuildTxVector(uint16_t bw, std::list userInfos); +}; + +TestDlMuTxVector::TestDlMuTxVector() + : TestCase("Check for valid combinations of MU TX-VECTOR") +{ +} + +WifiTxVector +TestDlMuTxVector::BuildTxVector(uint16_t bw, std::list userInfos) +{ + WifiTxVector txVector; + txVector.SetPreambleType(WIFI_PREAMBLE_HE_MU); + txVector.SetChannelWidth(bw); + std::list staIds; + uint16_t staId = 1; + for (const auto& userInfo : userInfos) + { + txVector.SetHeMuUserInfo(staId, userInfo); + staIds.push_back(staId++); + } + return txVector; +} + +void +TestDlMuTxVector::DoRun() +{ + // Verify TxVector is OFDMA + std::list userInfos; + userInfos.push_back({{HeRu::RU_106_TONE, 1, true}, 11, 1}); + userInfos.push_back({{HeRu::RU_106_TONE, 2, true}, 10, 2}); + WifiTxVector txVector = BuildTxVector(20, userInfos); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlOfdma(), + true, + "TX-VECTOR should indicate an OFDMA transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlMuMimo(), + false, + "TX-VECTOR should not indicate a MU-MIMO transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsSigBCompression(), + false, + "TX-VECTOR should not indicate a SIG-B compression"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsValid(), + true, + "TX-VECTOR should indicate all checks are passed"); + userInfos.clear(); + + // Verify TxVector is a full BW MU-MIMO + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 11, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 10, 2}); + txVector = BuildTxVector(20, userInfos); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlOfdma(), + false, + "TX-VECTOR should indicate a MU-MIMO transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlMuMimo(), + true, + "TX-VECTOR should not indicate an OFDMA transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsSigBCompression(), + true, + "TX-VECTOR should indicate a SIG-B compression"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsValid(), + true, + "TX-VECTOR should indicate all checks are passed"); + userInfos.clear(); + + // Verify TxVector is not valid if there are more than 8 STAs using the same RU + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 11, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 10, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 9, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 8, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 7, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 6, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 5, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 4, 1}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 3, 1}); + txVector = BuildTxVector(20, userInfos); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlOfdma(), + false, + "TX-VECTOR should indicate a MU-MIMO transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlMuMimo(), + true, + "TX-VECTOR should not indicate an OFDMA transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsSigBCompression(), + true, + "TX-VECTOR should indicate a SIG-B compression"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsValid(), + false, + "TX-VECTOR should not indicate all checks are passed"); + + // Verify TxVector is not valid if the total number of antennas in a full BW MU-MIMO is above 8 + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 11, 2}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 10, 2}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 9, 3}); + userInfos.push_back({{HeRu::RU_242_TONE, 1, true}, 8, 3}); + txVector = BuildTxVector(20, userInfos); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlOfdma(), + false, + "TX-VECTOR should indicate a MU-MIMO transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsDlMuMimo(), + true, + "TX-VECTOR should not indicate an OFDMA transmission"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsSigBCompression(), + true, + "TX-VECTOR should indicate a SIG-B compression"); + NS_TEST_EXPECT_MSG_EQ(txVector.IsValid(), + false, + "TX-VECTOR should not indicate all checks are passed"); +} + +/** + * \ingroup wifi-test + * \ingroup tests + * + * \brief wifi PHY MU-MIMO Test Suite + */ +class WifiPhyMuMimoTestSuite : public TestSuite +{ + public: + WifiPhyMuMimoTestSuite(); +}; + +WifiPhyMuMimoTestSuite::WifiPhyMuMimoTestSuite() + : TestSuite("wifi-phy-mu-mimo", UNIT) +{ + AddTestCase(new TestDlMuTxVector, TestCase::QUICK); +} + +static WifiPhyMuMimoTestSuite WifiPhyMuMimoTestSuite; ///< the test suite