20#include "ns3/ap-wifi-mac.h"
21#include "ns3/config.h"
22#include "ns3/he-configuration.h"
23#include "ns3/he-frame-exchange-manager.h"
24#include "ns3/he-phy.h"
26#include "ns3/mgt-headers.h"
27#include "ns3/mobility-helper.h"
28#include "ns3/multi-link-element.h"
29#include "ns3/multi-model-spectrum-channel.h"
30#include "ns3/packet-socket-client.h"
31#include "ns3/packet-socket-helper.h"
32#include "ns3/packet-socket-server.h"
33#include "ns3/packet.h"
34#include "ns3/pointer.h"
35#include "ns3/qos-utils.h"
36#include "ns3/rng-seed-manager.h"
37#include "ns3/spectrum-wifi-helper.h"
38#include "ns3/sta-wifi-mac.h"
39#include "ns3/string.h"
41#include "ns3/wifi-acknowledgment.h"
42#include "ns3/wifi-assoc-manager.h"
43#include "ns3/wifi-mac-header.h"
44#include "ns3/wifi-net-device.h"
45#include "ns3/wifi-protection.h"
46#include "ns3/wifi-psdu.h"
74 void DoRun()
override;
78 :
TestCase(
"Check the implementation of WifiAssocManager::GetNextAffiliatedAp()")
141 auto ret = WifiAssocManager::GetNextAffiliatedAp(rnr, 0);
147 ret = WifiAssocManager::GetNextAffiliatedAp(rnr, ret->m_nbrApInfoId + 1);
152 "Unexpected neighbor ID of the second reported AP");
155 "Unexpected tbtt ID of the second reported AP");
157 ret = WifiAssocManager::GetNextAffiliatedAp(rnr, ret->m_nbrApInfoId + 1);
161 "Did not expect to find a third suitable reported AP");
164 auto allAps = WifiAssocManager::GetAllAffiliatedAps(rnr);
168 auto apIt = allAps.begin();
171 "Unexpected neighbor ID of the first reported AP");
174 "Unexpected tbtt ID of the first reported AP");
179 "Unexpected neighbor ID of the second reported AP");
182 "Unexpected tbtt ID of the second reported AP");
207 std::initializer_list<std::string> apChannels,
208 std::initializer_list<std::pair<uint8_t, uint8_t>> setupLinks,
209 std::initializer_list<uint8_t> fixedPhyBands = {});
223 const std::vector<std::string>& channels,
280 void DoRun()
override;
294 std::vector<std::pair<uint8_t, uint8_t>>
302 std::initializer_list<std::string> staChannels,
303 std::initializer_list<std::string> apChannels,
304 std::initializer_list<std::pair<uint8_t, uint8_t>> setupLinks,
305 std::initializer_list<uint8_t> fixedPhyBands)
306 :
TestCase(
"Check correctness of Multi-Link Setup"),
307 m_staChannels(staChannels),
308 m_apChannels(apChannels),
309 m_setupLinks(setupLinks),
310 m_fixedPhyBands(fixedPhyBands)
327 std::stringstream ss;
328 ss << std::setprecision(10) <<
"PSDU #" <<
m_txPsdus.size() <<
" Link ID " << +linkId <<
" "
329 << psduMap.begin()->second->GetHeader(0).GetTypeString() <<
" #MPDUs "
330 << psduMap.begin()->second->GetNMpdus() <<
" duration/ID "
331 << psduMap.begin()->second->GetHeader(0).GetDuration()
332 <<
" RA = " << psduMap.begin()->second->GetAddr1()
333 <<
" TA = " << psduMap.begin()->second->GetAddr2();
334 if (psduMap.begin()->second->GetHeader(0).IsQosData())
336 ss <<
" TID = " << +psduMap.begin()->second->GetHeader(0).GetQosTid();
345 const std::vector<std::string>& channels,
352 for (
const auto& str : channels)
364 if (str.find(
"2_4GHZ") != std::string::npos)
368 if (str.find(
"5GHZ") != std::string::npos)
372 if (str.find(
"6GHZ") != std::string::npos)
376 NS_ABORT_MSG(
"Band in channel settings must be specified");
383 RngSeedManager::SetSeed(1);
384 RngSeedManager::SetRun(2);
385 int64_t streamNumber = 100;
396 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
400 std::map<WifiPhyBand, Ptr<MultiModelSpectrumChannel>> channelMap = {
436 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
437 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
438 mobility.SetPositionAllocator(positionAlloc);
440 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
444 m_apMac = DynamicCast<ApWifiMac>(DynamicCast<WifiNetDevice>(
apDevices.Get(0))->GetMac());
445 m_staMac = DynamicCast<StaWifiMac>(DynamicCast<WifiNetDevice>(
staDevices.Get(0))->GetMac());
448 for (uint8_t linkId = 0; linkId < StaticCast<WifiNetDevice>(
apDevices.Get(0))->GetNPhys();
452 std::to_string(linkId) +
"/PhyTxPsduBegin",
455 for (uint8_t linkId = 0; linkId < StaticCast<WifiNetDevice>(
staDevices.Get(0))->GetNPhys();
459 std::to_string(linkId) +
"/PhyTxPsduBegin",
473 const auto& mpdu = *frameInfo.psduMap.begin()->second->begin();
474 const auto& linkId = frameInfo.linkId;
476 switch (mpdu->GetHeader().GetType())
497 Simulator::Destroy();
506 mpdu->GetHeader().GetAddr2(),
507 "TA of Beacon frame is not the address of the link it is transmitted on");
509 mpdu->GetPacket()->PeekHeader(beacon);
517 "RNR Element in Beacon frame from single link AP");
520 "Multi-Link Element in Beacon frame from single link AP");
529 "Unexpected number of Neighbor AP Info fields in RNR");
530 for (std::size_t nbrApInfoId = 0; nbrApInfoId < rnr->GetNNbrApInfoFields(); nbrApInfoId++)
534 "MLD Parameters not present");
537 "Expected only one TBTT Info subfield per Neighbor AP Info");
538 uint8_t nbrLinkId = rnr->GetLinkId(nbrApInfoId, 0);
541 "BSSID advertised in Neighbor AP Info field "
543 <<
" does not match the address configured on the link "
544 "advertised in the same field");
550 "Incorrect MLD address advertised in Multi-Link Element");
553 "Incorrect Link ID advertised in Multi-Link Element");
563 mpdu->GetHeader().GetAddr2(),
564 "TA of Assoc Request frame is not the address of the link it is transmitted on");
566 mpdu->GetPacket()->PeekHeader(assoc);
573 "Multi-Link Element in Assoc Request frame from single link STA");
580 "Incorrect MLD Address advertised in Multi-Link Element");
583 "Incorrect number of Per-STA Profile subelements in Multi-Link Element");
584 for (std::size_t i = 0; i < mle->GetNPerStaProfileSubelements(); i++)
586 auto& perStaProfile = mle->GetPerStaProfile(i);
589 "Per-STA Profile must contain STA MAC address");
593 staLinkId.has_value(),
595 "No link found with the STA MAC address advertised in Per-STA Profile");
599 "The STA that sent the Assoc Request should not be included in a Per-STA Profile");
601 return pair.first == staLinkId.value();
605 "Not expecting to setup STA link ID " << +staLinkId.value());
608 +perStaProfile.GetLinkId(),
609 "Not expecting to request association to AP Link ID in Per-STA Profile");
612 "Missing Association Request in Per-STA Profile");
623 mpdu->GetHeader().GetAddr2(),
624 "TA of Assoc Response frame is not the address of the link it is transmitted on");
626 mpdu->GetPacket()->PeekHeader(assoc);
634 "Multi-Link Element in Assoc Response frame with single link AP or single link STA");
641 "Incorrect MLD Address advertised in Multi-Link Element");
644 "Incorrect number of Per-STA Profile subelements in Multi-Link Element");
645 for (std::size_t i = 0; i < mle->GetNPerStaProfileSubelements(); i++)
647 auto& perStaProfile = mle->GetPerStaProfile(i);
650 "Per-STA Profile must contain STA MAC address");
654 apLinkId.has_value(),
656 "No link found with the STA MAC address advertised in Per-STA Profile");
658 +perStaProfile.GetLinkId(),
659 "Link ID and MAC address advertised in Per-STA Profile do not match");
663 "The AP that sent the Assoc Response should not be included in a Per-STA Profile");
665 return pair.second == apLinkId.value();
669 "Not expecting to setup AP link ID " << +apLinkId.value());
672 "Missing Association Response in Per-STA Profile");
695 "Unexpected BSSID for STA link ID " << +staLinkId);
700 "Incorrect MLD address stored by STA on link ID " << +staLinkId);
704 "Incorrect affiliated address stored by STA on link ID " << +staLinkId);
710 "Expecting STA " << staAddr <<
" to be associated on link "
716 "Incorrect MLD address stored by AP on link ID " << +apLinkId);
720 "Incorrect affiliated address stored by AP on link ID " << +apLinkId);
726 "STA " << staAddr <<
" not found in list of associated STAs");
731 "Incorrect operating channel number for STA on link " << +staLinkId);
734 "Incorrect operating channel frequency for STA on link "
738 "Incorrect operating channel width for STA on link " << +staLinkId);
741 "Incorrect operating PHY band for STA on link " << +staLinkId);
745 "Incorrect operating primary channel index for STA on link " << +staLinkId);
752 for (std::size_t linkId = 0; linkId <
m_staChannels.size(); linkId++)
755 return link.first == linkId;
762 "Link " << +linkId <<
" has not been setup but is not disabled");
775 "Expecting link " << +linkId
776 <<
" to be disabled due to switching PHY band");
783 "Expecting link " << +linkId <<
" to be active");
805 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
806 {
"{36, 0, BAND_5GHZ, 0}",
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
807 {{0, 0}, {1, 1}, {2, 2}}),
811 {
"{108, 0, BAND_5GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"},
812 {
"{36, 0, BAND_5GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}",
"{5, 0, BAND_6GHZ, 0}"},
813 {{1, 0}, {0, 1}, {2, 2}}),
817 {
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}"},
818 {
"{36, 0, BAND_5GHZ, 0}",
"{9, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
819 {{2, 0}, {0, 1}, {1, 2}}),
824 {
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}",
"{8, 20, BAND_2_4GHZ, 0}"},
825 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
833 {
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}",
"{8, 20, BAND_2_4GHZ, 0}"},
834 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
844 {
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}",
"{60, 0, BAND_5GHZ, 0}"},
845 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
851 {
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}"},
852 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
857 {
"{120, 0, BAND_5GHZ, 0}"},
858 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
863 {
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}",
"{120, 0, BAND_5GHZ, 0}"},
864 {
"{120, 0, BAND_5GHZ, 0}"},
Test the implementation of WifiAssocManager::GetNextAffiliatedAp(), which searches a given RNR elemen...
GetRnrLinkInfoTest()
Constructor.
~GetRnrLinkInfoTest() override=default
void DoRun() override
Implementation to actually run this TestCase.
Test Multi-Link Discovery & Setup.
void CheckAssocRequest(Ptr< WifiMpdu > mpdu, uint8_t linkId)
Check correctness of the given Association Request frame.
void CheckMlSetup()
Check correctness of Multi-Link Setup procedure.
MultiLinkSetupTest(std::initializer_list< std::string > staChannels, std::initializer_list< std::string > apChannels, std::initializer_list< std::pair< uint8_t, uint8_t > > setupLinks, std::initializer_list< uint8_t > fixedPhyBands={})
Constructor.
void CheckDisabledLinks()
Check that links that are not setup on the non-AP MLD are disabled.
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
std::vector< uint8_t > m_fixedPhyBands
links on non-AP MLD with fixed PHY band
WifiPhyBand GetPhyBandFromChannelStr(const std::string &str)
std::vector< std::string > m_staChannels
strings specifying channels for STA
std::vector< std::pair< uint8_t, uint8_t > > m_setupLinks
expected links to setup (STA link ID, AP link ID)
Ptr< StaWifiMac > m_staMac
STA wifi MAC.
void DoRun() override
Implementation to actually run this TestCase.
void SetChannels(SpectrumWifiPhyHelper &helper, const std::vector< std::string > &channels, const std::map< WifiPhyBand, Ptr< MultiModelSpectrumChannel > > &channelMap)
Reset the given PHY helper, use the given strings to set the ChannelSettings attribute of the PHY obj...
void CheckAssocResponse(Ptr< WifiMpdu > mpdu, uint8_t linkId)
Check correctness of the given Association Response frame.
std::vector< std::string > m_apChannels
strings specifying channels for AP
Ptr< ApWifiMac > m_apMac
AP wifi MAC.
void Transmit(uint8_t linkId, std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when a FEM passes PSDUs to the PHY.
void CheckBeacon(Ptr< WifiMpdu > mpdu, uint8_t linkId)
Check correctness of the given Beacon frame.
~MultiLinkSetupTest() override
WifiMultiLinkOperationsTestSuite()
uint16_t GetAssociationId(Mac48Address addr, uint8_t linkId) const
const std::map< uint16_t, Mac48Address > & GetStaList(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get a const reference to the map of associated stations on the given link.
AttributeValue implementation for Boolean.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Smart pointer class similar to boost::intrusive_ptr.
The Reduced Neighbor Report element.
std::size_t GetNNbrApInfoFields() const
Get the number of Neighbor AP Information fields.
void SetMldParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t mldId, uint8_t linkId, uint8_t changeSequence)
Set the MLD Parameters subfield of the i-th TBTT Information field of the given Neighbor AP Informati...
std::size_t GetNTbttInformationFields(std::size_t nbrApInfoId) const
Get the number of TBTT Information fields included in the TBTT Information Set field of the given Nei...
void AddNbrApInfoField()
Add a Neighbor AP Information field.
void AddTbttInformationField(std::size_t nbrApInfoId)
Add a TBTT Information fields to the TBTT Information Set field of the given Neighbor AP Information ...
Make it easy to create and manage PHY objects for the spectrum model.
void SetChannel(Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
bool IsAssociated() const
Return whether we are associated with an AP.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Ptr< FrameExchangeManager > GetFrameExchangeManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Frame Exchange Manager associated with the given link.
uint8_t GetNLinks() const
Get the number of links (can be greater than 1 for 11be devices only).
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
virtual std::optional< uint8_t > GetLinkIdByAddress(const Mac48Address &address) const
Get the ID of the link having the given MAC address, if any.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
Mac48Address GetAddress() const
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void Set(std::string name, const AttributeValue &v)
Ptr< WifiPhyStateHelper > GetState() const
Return the WifiPhyStateHelper of this PHY.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
WifiPhyBand GetPhyBand() const
Return the PHY band of the operating channel.
uint8_t GetNumber() const
Return the channel number identifying the whole operating channel.
uint16_t GetFrequency() const
Return the center frequency of the operating channel (in MHz).
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void Connect(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report 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 Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiPhyBand
Identifies the PHY band.
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
Information about transmitted frames.
WifiTxVector txVector
TXVECTOR.
Time startTx
TX start time.
WifiConstPsduMap psduMap
transmitted PSDU map
static WifiMultiLinkOperationsTestSuite g_wifiMultiLinkOperationsTestSuite
the test suite