9#include "ns3/ap-wifi-mac.h"
10#include "ns3/common-info-probe-req-mle.h"
11#include "ns3/config.h"
12#include "ns3/ctrl-headers.h"
13#include "ns3/eht-configuration.h"
14#include "ns3/error-model.h"
15#include "ns3/frame-exchange-manager.h"
17#include "ns3/mac48-address.h"
18#include "ns3/mgt-headers.h"
19#include "ns3/mobility-helper.h"
20#include "ns3/multi-link-element.h"
21#include "ns3/multi-model-spectrum-channel.h"
22#include "ns3/node-container.h"
23#include "ns3/object-factory.h"
24#include "ns3/rng-seed-manager.h"
25#include "ns3/simulator.h"
26#include "ns3/spectrum-helper.h"
27#include "ns3/spectrum-wifi-helper.h"
28#include "ns3/sta-wifi-mac.h"
29#include "ns3/string.h"
32#include "ns3/wifi-mac-header.h"
33#include "ns3/wifi-mac-helper.h"
34#include "ns3/wifi-mac-queue.h"
35#include "ns3/wifi-mode.h"
36#include "ns3/wifi-net-device.h"
37#include "ns3/wifi-phy-common.h"
38#include "ns3/wifi-psdu.h"
39#include "ns3/wifi-tx-vector.h"
40#include "ns3/wifi-utils.h"
75 std::vector<std::string>
apChs{};
114 using ChannelMap = std::map<FrequencyRange, Ptr<MultiModelSpectrumChannel>>;
143 const std::vector<std::string>& channels,
182 void DoRun()
override;
213 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
229 mac.SetType(
"ns3::ApWifiMac",
238 mac.SetType(
"ns3::StaWifiMac",
243 auto clientDevices = wifi.Install(clientPhyHelper, mac, clientNode);
251 "Too many streams used (" << streamsUsed <<
"), increase the stream increment");
255 "Too many streams used (" << streamsUsed <<
"), increase the stream increment");
260 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
261 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
262 mobility.SetPositionAllocator(positionAlloc);
264 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
265 mobility.Install(apNode);
266 mobility.Install(clientNode);
271 const std::vector<std::string>& channels,
277 for (std::size_t idx = 0; idx != channels.size(); ++idx)
282 for (
const auto& [band, channel] : channelMap)
291 auto mac = dev->GetMac();
293 return mac->GetFrameExchangeManager(linkId)->GetAddress();
299 for (uint8_t idx = 0; idx < dev->GetNPhys(); ++idx)
302 "/DeviceList/*/$ns3::WifiNetDevice/Phys/" + std::to_string(idx) +
315 auto psdu = psduMap.begin()->second;
316 if (psdu->GetHeader(0).IsMgt())
318 m_mgtPsdus.push_back({psdu, txVector, linkId});
332 probeReq = clientMac->GetMultiLinkProbeRequest(reqTxLinkId,
338 probeReq = clientMac->GetProbeRequest(reqTxLinkId);
345 clientMac->EnqueueProbeRequest(probeReq, reqTxLinkId, addr1, addr3);
361 auto psdu = txPsdu.
psdu;
366 "Probe Request transmission link mismatch");
368 auto packet = psdu->GetPayload(0);
370 packet->PeekHeader(probeReq);
374 "Multi-link Element expectation mismatch");
376 if (!mle.has_value())
381 auto nProfiles = mle->GetNPerStaProfileSubelements();
385 for (std::size_t i = 0; i < nProfiles; ++i)
387 auto actualLinkId = mle->GetPerStaProfile(i).GetLinkId();
390 "Per-STA Profile Link ID mismatch");
397 auto psdu = txPsdu.
psdu;
401 "Probe Response expected, actual =" << macHdr);
404 "Probe Response transmission link mismatch");
406 auto packet = psdu->GetPayload(0);
408 packet->PeekHeader(probeResp);
413 "Multi-link Element expectation mismatch");
415 if (!mle.has_value())
420 auto nProfiles = mle->GetNPerStaProfileSubelements();
425 for (std::size_t i = 0; i < nProfiles; ++i)
427 auto actualLinkId = mle->GetPerStaProfile(i).GetLinkId();
430 "Per-STA Profile Link ID mismatch");
481 using ChCfgVec = std::vector<std::string>;
482 ChCfgVec ap1Link{
"{1, 0, BAND_6GHZ, 0}"};
483 ChCfgVec ap1LinkAlt{
"{36, 0, BAND_5GHZ, 0}"};
484 ChCfgVec ap1LinkAlt2{
"{2, 0, BAND_2_4GHZ, 0}"};
485 ChCfgVec ap2Links{
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"};
486 ChCfgVec ap2LinksAlt{
"{2, 0, BAND_2_4GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"};
487 ChCfgVec ap3Links{
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"};
488 ChCfgVec clientChCfg{
"{2, 0, BAND_2_4GHZ, 0}",
"{36, 0, BAND_5GHZ, 0}",
"{1, 0, BAND_6GHZ, 0}"};
489 std::vector<ProbeExchTestVector> vecs{
490 {.name =
"Single link AP, non-AP MLD sends Probe Request on link 2",
492 .clientChs = clientChCfg,
493 .isMultiLinkReq =
false,
500 {.name =
"Single link AP, non-AP MLD sends Probe Request on link 1",
502 .clientChs = clientChCfg,
503 .isMultiLinkReq =
false,
510 {.name =
"Single link AP, non-AP MLD sends Probe Request on link 0",
511 .apChs = ap1LinkAlt2,
512 .clientChs = clientChCfg,
513 .isMultiLinkReq =
false,
520 {.name =
"Non-AP MLD sends Multi-Link Probe Request on link 0 requesting a different link",
522 .clientChs = clientChCfg,
523 .isMultiLinkReq =
true,
530 {.name =
"Non-AP MLD sends Multi-Link Probe Request with broadcast Addr1 and Addr3",
532 .clientChs = clientChCfg,
533 .isMultiLinkReq =
true,
535 .reqLinkIds = {0, 1, 2},
540 {.name =
"Non-AP MLD sends Multi-Link Probe Request on link 2 requesting the same link",
542 .clientChs = clientChCfg,
543 .isMultiLinkReq =
true,
550 {.name =
"Non-AP MLD sends Probe Request to AP MLD",
552 .clientChs = clientChCfg,
553 .isMultiLinkReq =
false,
560 {.name =
"Non-AP MLD sends Multi-Link Probe Request to AP MLD with 3 links requesting all "
563 .clientChs = clientChCfg,
564 .isMultiLinkReq =
true,
566 .reqLinkIds = {0, 1, 2},
570 .respLinkIds = {1, 2}},
571 {.name =
"Non-AP MLD sends Multi-Link Probe Request on link 1 to AP MLD with 2 links "
572 "requesting all links",
574 .clientChs = clientChCfg,
575 .isMultiLinkReq =
true,
577 .reqLinkIds = {0, 1},
582 {.name =
"Non-AP MLD sends Multi-Link Probe Request on link 0 to AP MLD with 2 links "
583 "requesting all links",
584 .apChs = ap2LinksAlt,
585 .clientChs = clientChCfg,
586 .isMultiLinkReq =
true,
588 .reqLinkIds = {0, 1},
593 {.name =
"Non-AP MLD sends Multi-Link Probe Request with no Per-STA-Profile",
595 .clientChs = clientChCfg,
596 .isMultiLinkReq =
true,
602 .respLinkIds = {1, 2}},
603 {.name =
"Non-AP MLD sends Multi-Link Probe Request with broadcast Addr1",
605 .clientChs = clientChCfg,
606 .isMultiLinkReq =
true,
608 .reqLinkIds = {1, 2},
613 {.name =
"Duplicate requested Link IDs",
615 .clientChs = clientChCfg,
616 .isMultiLinkReq =
true,
618 .reqLinkIds = {0, 1, 1, 2, 2},
622 .respLinkIds = {1, 2}},
625 for (
const auto& testVec : vecs)
Probe Request-Probe Response exchange.
void DoRun() override
Implementation to actually run this TestCase.
ProbeExchTestVector m_testVec
Test vector.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::vector< TxPsdu > m_mgtPsdus
Tx PSDUs.
void SetChannels(SpectrumWifiPhyHelper &helper, const std::vector< std::string > &channels, const ChannelMap &channelMap)
Setup the PHY Helper based on input channel settings.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void ValidateTest()
Check expected outcome of test case run.
void ValidateProbeReq(const TxPsdu &txPsdu)
Check Probe Request contents.
void CollectTxTrace(uint8_t linkId, std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Traced callback when FEM passes PSDUs to the PHY.
void SetupDevices()
Setup WifiNetDevices.
void SendProbeReq()
Send Probe Request based on test vector input.
Mac48Address GetLinkMacAddr(Ptr< WifiNetDevice > dev, uint8_t linkId)
Get Link MAC address for input device on specified link.
std::map< FrequencyRange, Ptr< MultiModelSpectrumChannel > > ChannelMap
PHY band-indexed map of spectrum channels.
void SetupTxTrace(Ptr< WifiNetDevice > dev, std::size_t nodeId)
Setup PSDU Tx trace.
void ValidateProbeResp(const TxPsdu &txPsdu)
Check Probe Response contents.
ProbeExchTest(ProbeExchTestVector testVec, std::string testCase)
Constructor.
Ptr< WifiNetDevice > m_apDev
AP MLD WifiNetDevice.
Ptr< WifiNetDevice > m_clientDev
Non-AP MLD WifiNetDevice.
wifi probe exchange Test Suite
AttributeValue implementation for Boolean.
static Mac48Address GetBroadcast()
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.
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 EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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)
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.
helps to create WifiNetDevice objects
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 ...
create MAC layers for a ns3::WifiNetDevice.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void Set(std::string name, const AttributeValue &v)
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#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...
void Connect(std::string path, const CallbackBase &cb)
#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_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to a limit and report and abort if not.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ
Identifier for the frequency range covering the wifi spectrum in the 6 GHz band.
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
information on transmitted PSDU
Ptr< const WifiPsdu > psdu
WifiPsdu.
uint8_t linkId
Tx link ID.
WifiTxVector txVec
TXVECTOR.
Parameters and expected results for a test case.
LinkIds respLinkIds
Expected link IDs included in Multi-link Probe Response if any.
bool addr3Bcast
Flag for Probe Request ADDR3 broadcast.
bool addr1Bcast
Flag for Probe Request ADDR1 broadcast.
std::vector< std::string > clientChs
Non-AP MLD channels.
std::vector< std::string > apChs
AP MLD channels.
bool isMultiLinkReq
Send Multi-link Prpbe Req.
std::string name
Test case name.
LinkIds reqLinkIds
Link IDs included in Multi-link Probe Request if any.
uint8_t reqTxLinkId
Probe Request Tx Link ID.
uint8_t respTxLinkId
Probe Response Tx Link ID.
std::vector< uint8_t > LinkIds
Link identifiers.
const auto DEFAULT_STREAM_INDEX
const auto DEFAULT_PROBE_REQ_TX_TIME
const auto DEFAULT_RNG_RUN
const auto DEFAULT_MULTI_LINK_PROBE_REQ
const uint8_t DEFAULT_AP_MLD_ID
const auto DEFAULT_PROBE_REQ_ADDR3_BCAST
static ProbeExchTestSuite g_probeExchTestSuite
const auto DEFAULT_DATA_MODE
const auto DEFAULT_PROBE_REQ_ADDR1_BCAST
const auto DEFAULT_RNG_SEED
const auto DEFAULT_CONTROL_MODE
const auto DEFAULT_WIFI_STANDARD
const auto DEFAULT_SIM_STOP_TIME
const uint64_t DEFAULT_STREAM_INCREMENT
const uint8_t DEFAULT_PRB_EXCH_LINK_ID