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>>;
111 const std::vector<std::string>& settings,
121 void DoRun()
override;
141 "ns3::ConstantRateWifiManager",
158 for (
const auto& str : settings)
163 auto phyBand = channelConfig.front().band;
166 helper.
AddChannel(channelMap.at(phyBand), freqRange);
179 macHelper.
SetType(
"ns3::ApWifiMac",
196 "AuxPhyChannelWidth",
212 auto netDev = wifiHelper.Install(phyHelper, macHelper, node);
243 auto setupLinks = clientMac->GetSetupLinkIds();
244 auto isMldAssoc = (setupLinks.size() > 1);
246 auto emlsrManager = clientMac->GetEmlsrManager();
248 auto clientEmlsrLinks = emlsrManager->GetEmlsrLinks();
249 auto match = (clientEmlsrLinks ==
m_testVec.emlsrLinks);
251 for (
auto linkId : setupLinks)
253 auto expectedState = clientEmlsrLinks.contains(linkId);
254 auto clientLinkAddr = clientMac->GetFrameExchangeManager(linkId)->GetAddress();
255 auto apManager =
m_apDev->GetRemoteStationManager(linkId);
256 auto actualState = apManager->GetEmlsrEnabled(clientLinkAddr);
259 "EMLSR state mismatch on client link ID " << +linkId);
262 auto actualDelay = clientMac->GetWifiPhy(linkId)->GetChannelSwitchDelay();
265 "Channel switch delay mismatch on client link ID " << +linkId);
301 for (
const std::vector<WifiStaticEmlsrTestVector> inputs{
302 {
"Setup-2-link-EMLSR-2-link",
308 {
"Setup-3-link-EMLSR-2-link",
314 {
"Setup-3-link-EMLSR-2-link-Diff",
320 {
"Setup-3-link-EMLSR-2-link-Diff-2",
326 {
"Setup-3-link-EMLSR-3-link",
332 {
"Setup-2-link-EMLSR-2-link-Diff-Set",
333 CHANNELS_2_LINKS_ALT,
338 {
"EMLSR-2-link-16us-delay",
344 {
"EMLSR-2-link-32us-delay",
350 {
"EMLSR-2-link-80MHz-AuxPhy",
356 {
"EMLSR-2-link-Switch-Aux-PHY",
362 {
"EMLSR-2-link-80MHz-AuxPhy-Switch",
368 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.
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
@ UNIT
This test suite implements a Unit Test.
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 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 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.
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< 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