9#include "ns3/ap-wifi-mac.h"
10#include "ns3/assert.h"
11#include "ns3/boolean.h"
12#include "ns3/frame-exchange-manager.h"
14#include "ns3/mac48-address.h"
15#include "ns3/multi-model-spectrum-channel.h"
16#include "ns3/node-container.h"
17#include "ns3/rng-seed-manager.h"
18#include "ns3/rr-multi-user-scheduler.h"
19#include "ns3/simulator.h"
20#include "ns3/spectrum-wifi-helper.h"
21#include "ns3/sta-wifi-mac.h"
22#include "ns3/string.h"
24#include "ns3/wifi-mac-header.h"
25#include "ns3/wifi-mac-helper.h"
26#include "ns3/wifi-mac.h"
27#include "ns3/wifi-net-device.h"
28#include "ns3/wifi-ns3-constants.h"
29#include "ns3/wifi-static-setup-helper.h"
30#include "ns3/wifi-utils.h"
34#include <unordered_map>
71using ChannelMap = std::unordered_map<WifiPhyBand, Ptr<MultiModelSpectrumChannel>>;
139 void DoRun()
override;
175 for (
const auto& str : settings)
180 auto phyBand = channelConfig.front().band;
183 helper.
AddChannel(channelMap.at(phyBand), freqRange);
196 macHelper.
SetType(
"ns3::ApWifiMac",
214 macHelper.
SetType(
"ns3::StaWifiMac",
230 auto netDev = wifiHelper.Install(phyHelper, macHelper, node);
251 if (
auto multicastIp =
m_testVec.apMulticastIp)
254 "Assigned IP " << multicastIp.value() <<
" is not multicast");
269 const auto isMldAssoc = (apMac->GetNLinks() > 1) && (clientMac->GetNLinks() > 1);
270 const auto apLinkId = clientLinkId;
271 const auto clientFem = clientMac->GetFrameExchangeManager(clientLinkId);
272 const auto apFem = apMac->GetFrameExchangeManager(apLinkId);
273 const auto staAddr = clientFem->GetAddress();
274 const auto apAddr = apFem->GetAddress();
275 const auto staRemoteMgr = clientMac->GetWifiRemoteStationManager(clientLinkId);
276 const auto apRemoteMgr = apMac->GetWifiRemoteStationManager(apLinkId);
280 "Unexpected BSSID for STA link ID " << +clientLinkId);
283 "Expecting STA " << staAddr <<
" to be associated on AP link "
286 const auto aid = apMac->GetAssociationId(staAddr, apLinkId);
289 "STA " << staAddr <<
" not found in list of associated STAs");
298 "Incorrect MLD address stored by STA on link ID " << +clientLinkId);
301 "Incorrect affiliated address stored by STA on link ID "
306 "Incorrect MLD address stored by AP on link ID " << +apLinkId);
308 (apRemoteMgr->GetAffiliatedStaAddress(clientMac->GetAddress()) == staAddr),
310 "Incorrect affiliated address stored by AP on link ID " << +apLinkId);
318 auto clientList = muScheduler->GetUlMuStas();
319 std::size_t expectedSize =
m_testVec.ulMuDataDisable ? 0 : 1;
320 if (expectedSize == 0)
324 auto clientAddr = clientList.front().address;
325 auto expectedAddr = clientMac->GetAddress();
332 auto isMldAssoc = (apMac->GetNLinks() > 1) && (clientMac->GetNLinks() > 1);
333 auto setupLinks = clientMac->GetSetupLinkIds();
334 auto linkId = *(setupLinks.begin());
336 isMldAssoc ? apMac->GetAddress() : clientMac->GetFrameExchangeManager(linkId)->GetBssid();
337 auto clientAddr = isMldAssoc ? clientMac->GetAddress()
338 : clientMac->GetFrameExchangeManager(linkId)->GetAddress();
340 auto expectedBufferSize = std::min(
m_testVec.apBufferSize,
m_testVec.clientBufferSize);
343 auto baApOrig = apMac->GetBaAgreementEstablishedAsOriginator(clientAddr,
348 "BA Agreement not established at AP as originator");
351 "BA Agreement buffer size mismatch");
356 "BA Agreement not established at AP as recipient");
359 "BA Agreement buffer size mismatch");
366 "BA Agreement not established at client as originator");
369 "BA Agreement buffer size mismatch");
370 auto baClientRecip = clientMac->GetBaAgreementEstablishedAsRecipient(apAddr,
375 "BA Agreement not established at client as recipient");
378 "BA Agreement buffer size mismatch");
390 const auto nClientLinks =
m_testVec.clientChs.size();
391 auto clientLinkIds = clientMac->GetLinkIds();
393 for (
auto linkId : clientLinkIds)
426 for (
const std::vector<WifiStaticInfraBssTestVector> inputs{
427 {
"AP-1-link-Client-1-link",
428 {
"{36, 0, BAND_5GHZ, 0}"},
429 {
"{36, 0, BAND_5GHZ, 0}"},
434 {
"AP-1-link-Client-1-link-multicast",
435 {
"{36, 0, BAND_5GHZ, 0}"},
436 {
"{36, 0, BAND_5GHZ, 0}"},
441 {
"AP-2-link-Client-1-link",
442 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}"},
443 {
"{36, 0, BAND_5GHZ, 0}"},
448 {
"AP-2-link-Client-1-link-Diff-Order",
449 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}"},
450 {
"{2, 0, BAND_2_4GHZ, 0}"},
455 {
"AP-3-link-Client-2-link",
456 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
457 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
462 {
"AP-3-link-Client-2-link-Diff-Order",
463 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
464 {
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}"},
469 {
"AP-3-link-Client-3-link",
470 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
471 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
476 {
"AP-80MHz-Client-20MHz",
477 {
"{42, 80, BAND_5GHZ, 0}"},
478 {
"{36, 20, BAND_5GHZ, 0}"},
483 {
"Single-linkBuffer-Size-Test",
484 {
"{36, 0, BAND_5GHZ, 0}"},
485 {
"{36, 0, BAND_5GHZ, 0}"},
490 {
"Single-linkBuffer-Size-Test-Alt",
491 {
"{36, 0, BAND_5GHZ, 0}"},
492 {
"{36, 0, BAND_5GHZ, 0}"},
497 {
"Multi-link-Buffer-Size-Test",
498 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
499 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
504 {
"Multi-link-Buffer-Size-Test-Alt",
505 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
506 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
511 {
"Single-link-UL-MU-Disable",
512 {
"{36, 0, BAND_5GHZ, 0}"},
513 {
"{36, 0, BAND_5GHZ, 0}"},
518 {
"2-link-UL-MU-Disable",
519 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
520 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
526 const auto& input : inputs)
Test static setup of an infrastructure BSS.
SpectrumWifiPhyHelper GetPhyHelper(const StringVector &settings, const ChannelMap &channelMap) const
Construct PHY helper based on input operating channels.
void ValidateAssocForLink(linkId_t clientLinkId, Ptr< ApWifiMac > apMac, Ptr< StaWifiMac > clientMac)
Validate association state machine at AP and client for input link.
WifiMacHelper GetClientMacHelper() const
WifiMacHelper GetApMacHelper() const
Ptr< WifiNetDevice > m_apDev
AP WiFi device.
WifiHelper GetWifiHelper() const
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::optional< Mac48Address > m_apGcrGroupAddr
GCR group address.
Ptr< WifiNetDevice > GetWifiNetDevice(bool isAp, const ChannelMap &channelMap)
Construct WifiNetDevice.
WifiStaticInfraBssTestVector m_testVec
Test vector.
void ValidateMuScheduler(Ptr< ApWifiMac > apMac, Ptr< StaWifiMac > clientMac)
Validate Multi-user scheduler setup.
void ValidateBaAgr(Ptr< ApWifiMac > apMac, Ptr< StaWifiMac > clientMac)
Validate Block ACK Agreement at AP and client.
WifiStaticInfraBssTest(const WifiStaticInfraBssTestVector &testVec)
Constructor.
Ptr< WifiNetDevice > m_clientDev
client WiFi device
void ValidateAssoc()
Validate Association.
void DoRun() override
Implementation to actually run this TestCase.
WifiStaticSetupHelper test suite.
WifiStaticInfraBssTestSuite()
AttributeValue implementation for Boolean.
static Mac48Address ConvertFrom(const Address &address)
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
RrMultiUserScheduler is a simple OFDMA scheduler that indicates to perform a DL OFDMA transmission if...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Make it easy to create and manage PHY objects for the spectrum model.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
void AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange &freqRange)
Add a given spectrum PHY interface to the PHY instance corresponding of a given link.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
virtual void SetStandard(WifiStandard standard)
create MAC layers for a ns3::WifiNetDevice.
void SetMultiUserScheduler(std::string type, Args &&... args)
Helper function used to set the Multi User Scheduler that can be aggregated to an HE AP's MAC.
void SetType(std::string type, Args &&... args)
void Set(std::string name, const AttributeValue &v)
static void SetStaticAssociation(Ptr< WifiNetDevice > bssDev, const NetDeviceContainer &clientDevs)
Bypass static capabilities exchange for input devices.
static void SetStaticBlockAck(Ptr< WifiNetDevice > apDev, const NetDeviceContainer &clientDevs, const std::set< tid_t > &tids, std::optional< Mac48Address > gcrGroupAddr=std::nullopt)
Bypass ADDBA Request-Response exchange sequence between AP and STAs for given TIDs.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Constants used in test suite.
const auto DEFAULT_DATA_MODE
default data mode
const uint16_t DEFAULT_BA_BUFFER_SIZE
default MPDU buffer size
const auto DEFAULT_RNG_SEED
default RNG seed
const auto DEFAULT_STREAM_INDEX
default stream index
const auto DEFAULT_SIM_STOP_TIME
default simulation stop time
const tid_t DEFAULT_TEST_TID
default TID
const uint8_t DEFAULT_WIFI_UL_MU_NUM_RU
default number of RUs in UL MU PPDUs
const auto DEFAULT_CONTROL_MODE
default control mode
const auto DEFAULT_WIFI_STANDARD
default Wi-Fi standard
const auto DEFAULT_SSID
default SSID
const auto DEFAULT_BEACON_GEN
default beacon generation value
const auto DEFAULT_RNG_RUN
default RNG run
Every class exported by the ns3 library is enclosed in the ns3 namespace.
FrequencyRange GetFrequencyRange(WifiPhyBand band)
Get the frequency range corresponding to the given PHY band.
static constexpr bool DEFAULT_WIFI_UL_MU_DATA_DISABLE
UL MU Data Disable flag at non-AP STA.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
uint8_t tid_t
IEEE 802.11-2020 9.2.4.5.2 TID subfield.
uint8_t linkId_t
IEEE 802.11be D7.0 Figure 9-207e—Link ID Info field format.
std::vector< std::string > StringVector
Return type of SplitString.
bool ulMuDataDisable
UL MU Data Disable.
StringVector apChs
Channel setting for AP device.
std::optional< Ipv4Address > apMulticastIp
AP multicast IP.
StringVector clientChs
Channel settings for client device.
uint16_t apBufferSize
Originator Buffer Size.
std::string name
Test case name.
uint16_t clientBufferSize
Recipient Buffer Size.
static WifiChannelConfig FromString(const std::string &settings, WifiStandard standard=WIFI_STANDARD_UNSPECIFIED)
Get the wifi channel config from a WifiPhy::ChannelSettings string.
static WifiStaticInfraBssTestSuite g_wifiStaticInfraBssTestSuite
std::unordered_map< WifiPhyBand, Ptr< MultiModelSpectrumChannel > > ChannelMap
channel map typedef