9#include "ns3/ap-wifi-mac.h"
10#include "ns3/assert.h"
11#include "ns3/attribute-container.h"
12#include "ns3/boolean.h"
13#include "ns3/emlsr-manager.h"
14#include "ns3/frame-exchange-manager.h"
16#include "ns3/mac48-address.h"
17#include "ns3/multi-model-spectrum-channel.h"
18#include "ns3/node-container.h"
19#include "ns3/rng-seed-manager.h"
20#include "ns3/simulator.h"
21#include "ns3/spectrum-wifi-helper.h"
22#include "ns3/sta-wifi-mac.h"
23#include "ns3/string.h"
25#include "ns3/wifi-mac-header.h"
26#include "ns3/wifi-mac-helper.h"
27#include "ns3/wifi-mac.h"
28#include "ns3/wifi-net-device.h"
29#include "ns3/wifi-static-setup-helper.h"
30#include "ns3/wifi-utils.h"
35#include <unordered_map>
62const std::string
CHANNEL_0 =
"{42, 80, BAND_5GHZ, 0}";
63const std::string
CHANNEL_1 =
"{23, 80, BAND_6GHZ, 0}";
64const std::string
CHANNEL_2 =
"{2, 0, BAND_2_4GHZ, 0}";
66using ChannelMap = std::unordered_map<WifiPhyBand, Ptr<MultiModelSpectrumChannel>>;
79 std::vector<WifiPowerManagementMode>
pmModes;
115 const std::vector<std::string>& settings,
125 void DoRun()
override;
151 "ns3::ConstantRateWifiManager",
168 for (
const auto& str : settings)
173 auto phyBand = channelConfig.front().band;
176 helper.
AddChannel(channelMap.at(phyBand), freqRange);
189 macHelper.
SetType(
"ns3::ApWifiMac",
206 "AuxPhyChannelWidth",
214 for (std::size_t
id = 0;
const auto pmMode :
m_testVec.pmModes)
216 s += std::to_string(
id++) + (pmMode ==
WIFI_PM_POWERSAVE ?
" true, " :
" false, ");
236 auto netDev = wifiHelper.Install(phyHelper, macHelper, node);
255 "PM modes (" <<
m_testVec.pmModes.size() <<
") and link (" <<
m_testVec.clientChs.size()
275 auto setupLinks = clientMac->GetSetupLinkIds();
276 auto isMldAssoc = (setupLinks.size() > 1);
278 auto emlsrManager = clientMac->GetEmlsrManager();
280 auto clientEmlsrLinks = emlsrManager->GetEmlsrLinks();
281 auto match = (clientEmlsrLinks ==
m_testVec.emlsrLinks);
285 for (
auto linkId : setupLinks)
287 auto expectedState = clientEmlsrLinks.contains(linkId);
288 auto clientLinkAddr = clientMac->GetFrameExchangeManager(linkId)->GetAddress();
289 auto apManager =
m_apDev->GetRemoteStationManager(linkId);
290 auto actualState = apManager->GetEmlsrEnabled(clientLinkAddr);
293 "EMLSR state mismatch on client link ID " << +linkId);
296 auto actualDelay = clientMac->GetWifiPhy(linkId)->GetChannelSwitchDelay();
299 "Channel switch delay mismatch on client link ID " << +linkId);
308 const auto& clientLinkIds = clientMac->GetLinkIds();
311 auto pmModes = !
m_testVec.pmModes.empty()
313 : std::vector<WifiPowerManagementMode>(clientLinkIds.size(),
WIFI_PM_ACTIVE);
316 for (std::size_t
id = 0;
const auto pmMode : pmModes)
320 "Non-AP MLD did not have link " <<
id <<
" before association");
323 clientMac->GetPmMode(linkId),
325 "Unexpected PM mode for STA affiliated with the non-AP MLD and operating on link "
326 << +linkId <<
"(non-AP MLD side)");
329 apMac->GetWifiRemoteStationManager(linkId)->IsInPsMode(clientMac->GetAddress()),
331 "Unexpected PM mode for STA affiliated with the non-AP MLD and operating on link "
332 << +linkId <<
"(AP MLD side)");
336 "AP is tracking an unexpected number of STAs in PS mode on link "
374 for (
const std::vector<WifiStaticEmlsrTestVector> inputs{
375 {
"Setup-2-link-EMLSR-2-link",
382 {
"Setup-3-link-EMLSR-2-link",
389 {
"Setup-3-link-EMLSR-2-link-Diff",
396 {
"Setup-3-link-EMLSR-2-link-Diff-2",
403 {
"Setup-3-link-EMLSR-3-link",
410 {
"Setup-2-link-EMLSR-2-link-Diff-Set",
411 CHANNELS_2_LINKS_ALT,
417 {
"EMLSR-2-link-16us-delay",
424 {
"EMLSR-2-link-32us-delay",
431 {
"EMLSR-2-link-80MHz-AuxPhy",
438 {
"EMLSR-2-link-Switch-Aux-PHY",
445 {
"EMLSR-2-link-80MHz-AuxPhy-Switch",
452 const auto& input : inputs)
Test static setup of the EMLSR mode.
WifiStaticEmlsrTestVector m_testVec
Test vector.
WifiMacHelper GetApMacHelper() const
SpectrumWifiPhyHelper GetPhyHelper(const std::vector< std::string > &settings, const WifiStaticEmlsrTestConstants::ChannelMap &channelMap) const
Construct PHY helper based on input operating channels.
Ptr< WifiNetDevice > m_apDev
AP WiFi device.
Ptr< WifiNetDevice > GetWifiNetDevice(bool isAp, const WifiStaticEmlsrTestConstants::ChannelMap &channelMap)
Construct WifiNetDevice.
std::map< linkId_t, linkId_t > m_linkIdMap
non-AP MLD link ID to AP MLD link ID mapping
void ValidatePmMode(Ptr< ApWifiMac > apMac, Ptr< StaWifiMac > clientMac)
Validate the configured PM mode for the STA(s) affiliated with the client device.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
WifiMacHelper GetClientMacHelper() const
WifiStaticEmlsrTest(const WifiStaticEmlsrTestVector &testVec)
Constructor.
WifiHelper GetWifiHelper() const
void ValidateEmlsr()
Validate EMLSR setup.
Ptr< WifiNetDevice > m_clientDev
client WiFi device
EMLSR static setup test suite.
WifiStaticEmlsrTestSuite()
A container for one type of attribute.
AttributeValue implementation for Boolean.
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.
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
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
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.
void ConfigEhtOptions(Args &&... args)
Helper function used to configure the EHT options listed as attributes of the EhtConfiguration class.
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 SetPowerSaveManager(std::string type, Args &&... args)
Helper function used to set the Power Save Manager.
void SetEmlsrManager(std::string type, Args &&... args)
Helper function used to set the EMLSR Manager that can be installed on an EHT non-AP MLD.
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 std::map< linkId_t, linkId_t > GetLinkIdMap(Ptr< WifiNetDevice > apDev, Ptr< WifiNetDevice > clientDev)
Construct non-AP MLD link ID to AP MLD link ID mapping based on PHY channel settings.
static void SetStaticEmlsr(Ptr< WifiNetDevice > apDev, const NetDeviceContainer &clientDevs)
Bypass EML Operating Mode Notification exchange sequence between AP MLD and input non-AP devices.
#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.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
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.
const std::vector< std::string > DEFAULT_AP_CHS
const auto DEFAULT_BEACON_GEN
const std::string CHANNEL_0
const auto DEFAULT_STREAM_INDEX
const auto DEFAULT_SWITCH_DELAY
const std::string CHANNEL_2
std::unordered_map< WifiPhyBand, Ptr< MultiModelSpectrumChannel > > ChannelMap
const auto DEFAULT_RNG_RUN
const auto DEFAULT_WIFI_STANDARD
const auto DEFAULT_DATA_MODE
const auto DEFAULT_SIM_STOP_TIME
const auto DEFAULT_SWITCH_AUX_PHY
const auto DEFAULT_RNG_SEED
const auto DEFAULT_AUX_PHY_CH_WIDTH
const auto DEFAULT_CONTROL_MODE
const std::string CHANNEL_1
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.
double MHz_u
MHz weak type.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
MHz_u auxPhyWidth
Aux PHY channel width.
std::vector< WifiPowerManagementMode > pmModes
if non-empty, PM mode for each STA affiliated with the client in increasing order of client link ID (...
std::vector< std::string > clientChs
Channel settings for client device.
std::set< uint8_t > emlsrLinks
EMLSR mode links.
std::string name
Test case name.
Time switchDelay
Radio Switch Delay.
bool switchAuxPhy
Switch Aux PHY.
static WifiChannelConfig FromString(const std::string &settings, WifiStandard standard=WIFI_STANDARD_UNSPECIFIED)
Get the wifi channel config from a WifiPhy::ChannelSettings string.
static WifiStaticEmlsrTestSuite g_wifiStaticEmlsrTestSuite