diff --git a/src/wifi/test/wifi-aggregation-test.cc b/src/wifi/test/wifi-aggregation-test.cc index 67583f528..de4933c54 100644 --- a/src/wifi/test/wifi-aggregation-test.cc +++ b/src/wifi/test/wifi-aggregation-test.cc @@ -17,6 +17,7 @@ * Author: Sébastien Deronne */ +#include "ns3/eht-configuration.h" #include "ns3/fcfs-wifi-queue-scheduler.h" #include "ns3/he-configuration.h" #include "ns3/ht-configuration.h" @@ -27,6 +28,7 @@ #include "ns3/mobility-helper.h" #include "ns3/mpdu-aggregator.h" #include "ns3/msdu-aggregator.h" +#include "ns3/multi-link-element.h" #include "ns3/node-container.h" #include "ns3/packet-socket-client.h" #include "ns3/packet-socket-helper.h" @@ -48,6 +50,7 @@ #include #include +#include using namespace ns3; @@ -66,6 +69,7 @@ class AmpduAggregationTest : public TestCase struct Params { WifiStandard standard; //!< the standard of the device + uint8_t nLinks; //!< number of links (>1 only for EHT) std::string dataMode; //!< data mode uint16_t bufferSize; //!< the size (in number of MPDUs) of the BlockAck buffer uint16_t maxAmsduSize; //!< maximum A-MSDU size (bytes) @@ -110,9 +114,9 @@ class AmpduAggregationTest : public TestCase */ void DequeueMpdus(const std::vector>& mpduList); - Ptr m_mac; ///< Mac - Ptr m_phy; ///< Phy - Params m_params; //!< test parameters + Ptr m_mac; ///< Mac + std::vector> m_phys; ///< Phys + Params m_params; //!< test parameters private: /** @@ -127,15 +131,16 @@ class AmpduAggregationTest : public TestCase void DoRun() override; void DoTeardown() override; - Ptr m_device; ///< WifiNetDevice - Ptr m_manager; ///< remote station manager - ObjectFactory m_factory; ///< factory - bool m_discarded; ///< whether the packet should be discarded + Ptr m_device; ///< WifiNetDevice + std::vector> m_managers; ///< remote station managers + ObjectFactory m_factory; ///< factory + bool m_discarded; ///< whether the packet should be discarded }; AmpduAggregationTest::AmpduAggregationTest() : AmpduAggregationTest("Check the correctness of MPDU aggregation operations", Params{.standard = WIFI_STANDARD_80211n, + .nLinks = 1, .dataMode = "HtMcs7", .bufferSize = 64, .maxAmsduSize = 0, @@ -174,16 +179,24 @@ AmpduAggregationTest::DoSetup() auto heConfiguration = CreateObject(); m_device->SetHeConfiguration(heConfiguration); } + if (m_params.standard >= WIFI_STANDARD_80211be) + { + auto ehtConfiguration = CreateObject(); + m_device->SetEhtConfiguration(ehtConfiguration); + } /* * Create and configure phy layer. */ - m_phy = CreateObject(); - auto interferenceHelper = CreateObject(); - m_phy->SetInterferenceHelper(interferenceHelper); - m_phy->SetDevice(m_device); - m_phy->ConfigureStandard(m_params.standard); - m_device->SetPhy(m_phy); + for (uint8_t i = 0; i < m_params.nLinks; i++) + { + m_phys.emplace_back(CreateObject()); + auto interferenceHelper = CreateObject(); + m_phys.back()->SetInterferenceHelper(interferenceHelper); + m_phys.back()->SetDevice(m_device); + m_phys.back()->ConfigureStandard(m_params.standard); + } + m_device->SetPhys(m_phys); /* * Create and configure manager. @@ -191,49 +204,111 @@ AmpduAggregationTest::DoSetup() m_factory = ObjectFactory(); m_factory.SetTypeId("ns3::ConstantRateWifiManager"); m_factory.Set("DataMode", StringValue(m_params.dataMode)); - m_manager = m_factory.Create(); - m_manager->SetupPhy(m_phy); - m_device->SetRemoteStationManager(m_manager); + for (uint8_t i = 0; i < m_params.nLinks; i++) + { + m_managers.emplace_back(m_factory.Create()); + m_managers.back()->SetupPhy(m_phys.at(i)); + } + m_device->SetRemoteStationManagers(m_managers); /* * Create and configure mac layer. */ m_mac = CreateObjectWithAttributes("QosSupported", BooleanValue(true)); m_mac->SetDevice(m_device); - m_mac->SetWifiRemoteStationManager(m_manager); + m_mac->SetWifiRemoteStationManagers(m_managers); m_mac->SetAddress(Mac48Address("00:00:00:00:00:01")); - m_mac->SetWifiPhys({m_phy}); - m_mac->ConfigureStandard(m_params.standard); - auto fem = m_mac->GetFrameExchangeManager(); - auto protectionManager = CreateObject(); - protectionManager->SetWifiMac(m_mac); - fem->SetProtectionManager(protectionManager); - auto ackManager = CreateObject(); - ackManager->SetWifiMac(m_mac); - fem->SetAckManager(ackManager); m_device->SetMac(m_mac); + m_mac->SetWifiPhys(m_phys); + m_mac->ConfigureStandard(m_params.standard); + for (uint8_t i = 0; i < m_params.nLinks; i++) + { + auto fem = m_mac->GetFrameExchangeManager(i); + auto protectionManager = CreateObject(); + protectionManager->SetWifiMac(m_mac); + fem->SetProtectionManager(protectionManager); + auto ackManager = CreateObject(); + ackManager->SetWifiMac(m_mac); + fem->SetAckManager(ackManager); + // here we should assign link addresses in case of MLDs, but we don't actually use link + // addresses in this test + } m_mac->SetState(StaWifiMac::ASSOCIATED); + if (m_params.nLinks > 1) + { + // the bssid field of StaLinkEntity must hold a value + for (const auto& [id, link] : m_mac->GetLinks()) + { + static_cast(*link).bssid = Mac48Address::GetBroadcast(); + } + } m_mac->SetMacQueueScheduler(CreateObject()); /* * Configure A-MSDU and A-MPDU aggregation. */ + // Make sure that at least 1024 MPDUs are buffered (to test aggregation on EHT devices) + m_mac->GetTxopQueue(AC_BE)->SetAttribute("MaxSize", StringValue("2000p")); m_mac->SetAttribute("BE_MaxAmsduSize", UintegerValue(m_params.maxAmsduSize)); m_mac->SetAttribute("BE_MaxAmpduSize", UintegerValue(m_params.maxAmpduSize)); GetBeQueue()->SetAttribute( "TxopLimits", - AttributeContainerValue(std::vector