A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-association-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
10
11#include "ns3/config.h"
12#include "ns3/ht-frame-exchange-manager.h"
13#include "ns3/mobility-helper.h"
14#include "ns3/packet-socket-helper.h"
15#include "ns3/packet-socket-server.h"
16#include "ns3/rng-seed-manager.h"
17#include "ns3/wifi-mac-queue.h"
18
19#include <algorithm>
20#include <iomanip>
21
22using namespace ns3;
23
24NS_LOG_COMPONENT_DEFINE("WifiAssocTest");
25
26NS_OBJECT_ENSURE_REGISTERED(WifiTestAssocManager);
27
28/***********************************
29 * WifiTestAssocManager
30 ***********************************/
31
34{
35 static TypeId tid = TypeId("ns3::WifiTestAssocManager")
37 .AddConstructor<WifiTestAssocManager>()
38 .SetGroupName("Wifi");
39 return tid;
40}
41
42void
46
47bool
49{
50 return lhs.m_bssid < rhs.m_bssid;
51}
52
53void
55 const std::list<StaWifiMac::ApInfo::SetupLinksInfo>& setupLinks)
56{
57 m_bestAp = bssid;
58 m_setupLinks = setupLinks;
59}
60
61bool
63{
64 return true;
65}
66
67bool
69{
70 return (apInfo.m_bssid == m_bestAp);
71}
72
73void
75{
76 Simulator::Schedule(GetScanParams().maxChannelTime, [=, this]() mutable {
77 for (const auto& apInfo : GetSortedList())
78 {
79 if (apInfo.m_bssid == m_bestAp)
80 {
81 // this is the AP to return
83 }
84 }
86 });
87}
88
89/***********************************
90 * WifiAssociationTestBase
91 ***********************************/
92
94 const BaseParams& baseParams)
95 : TestCase(name + ", " + (std::ostringstream{} << baseParams).str()),
96 m_baseParams(baseParams)
97{
98}
99
100void
102{
105 int64_t streamNumber = 30;
106
107 NodeContainer nodes(3); // AP 1, AP 2, STA
108 NetDeviceContainer devices;
109
110 WifiHelper wifi;
111 wifi.SetStandard(WIFI_STANDARD_80211be);
112
113 Ssid ssid("wifi-assoc-test");
114 WifiMacHelper mac;
115 mac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
116
117 auto spectrumChannel = CreateObject<MultiModelSpectrumChannel>();
118 spectrumChannel->AddPropagationLossModel(CreateObject<FriisPropagationLossModel>());
119
120 // lambda to create and install wifi netdevices
121 auto install = [&](std::string channels, Ptr<Node> node) {
122 auto strings = SplitString(channels, ";");
123 SpectrumWifiPhyHelper phy{static_cast<uint8_t>(strings.size())};
124 for (std::size_t id = 0; id < strings.size(); ++id)
125 {
126 phy.Set(id, "ChannelSettings", StringValue(strings[id]));
127 }
128 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
129 phy.SetChannel(spectrumChannel);
130 devices.Add(wifi.Install(phy, mac, node));
131 };
132
133 install(m_baseParams.ap1Channels, nodes.Get(0));
134 install(m_baseParams.ap2Channels, nodes.Get(1));
135
136 mac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
137 mac.SetAssocManager(m_assocMgrTypeId);
138
139 install(m_baseParams.staChannels, nodes.Get(2));
140
141 // Assign fixed streams to random variables in use
142 streamNumber += WifiHelper::AssignStreams(devices, streamNumber);
143
144 MobilityHelper mobility;
145 auto positionAlloc = CreateObject<ListPositionAllocator>();
146
147 positionAlloc->Add(Vector(0.0, 0.0, 0.0)); // AP 1
148 positionAlloc->Add(Vector(20.0, 0.0, 0.0)); // AP 2
149 positionAlloc->Add(Vector(10.0, 10.0, 0.0)); // non-AP STA
150 mobility.SetPositionAllocator(positionAlloc);
151
152 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
153 mobility.Install(nodes);
154
158
159 // Trace PSDUs passed to the PHY on all devices
160 for (uint32_t i = 0; i < devices.GetN(); ++i)
161 {
162 auto dev = DynamicCast<WifiNetDevice>(devices.Get(i));
163 for (uint8_t phyId = 0; phyId < dev->GetNPhys(); ++phyId)
164 {
165 dev->GetPhy(phyId)->TraceConnectWithoutContext(
166 "PhyTxPsduBegin",
167 MakeCallback(&WifiAssociationTestBase::Transmit, this).Bind(dev->GetMac(), phyId));
168 }
169 }
170
171 // install packet socket on all nodes
172 PacketSocketHelper packetSocket;
173 packetSocket.Install(nodes);
174
175 // install a packet socket server on all nodes
176 for (uint32_t i = 0; i < nodes.GetN(); ++i)
177 {
178 PacketSocketAddress srvAddr;
179 auto device = DynamicCast<WifiNetDevice>(nodes.Get(i)->GetDevice(0));
180 NS_TEST_ASSERT_MSG_NE(device, nullptr, "Expected a WifiNetDevice");
181 srvAddr.SetSingleDevice(device->GetIfIndex());
182 srvAddr.SetProtocol(1);
183
184 auto server = CreateObject<PacketSocketServer>();
185 server->SetLocal(srvAddr);
186 nodes.Get(i)->AddApplication(server);
187 server->SetStartTime(Seconds(0)); // now
188 server->SetStopTime(m_duration);
189 }
190
191 // set DL and UL packet socket addresses for both APs
192 using enum WifiDirection;
193 for (auto apMac : {m_ap1Mac, m_ap2Mac})
194 {
195 PacketSocketAddress dlAddress;
196 dlAddress.SetSingleDevice(apMac->GetDevice()->GetIfIndex());
197 dlAddress.SetPhysicalAddress(m_staMac->GetDevice()->GetAddress());
198 dlAddress.SetProtocol(1);
199 (apMac == m_ap1Mac ? m_ap1Sockets : m_ap2Sockets)[DOWNLINK] = dlAddress;
200
201 PacketSocketAddress ulAddress;
202 ulAddress.SetSingleDevice(m_staMac->GetDevice()->GetIfIndex());
203 ulAddress.SetPhysicalAddress(apMac->GetDevice()->GetAddress());
204 ulAddress.SetProtocol(1);
205 (apMac == m_ap1Mac ? m_ap1Sockets : m_ap2Sockets)[UPLINK] = ulAddress;
206 }
207
208 // connect (dis)association callbacks
209 m_staMac->TraceConnectWithoutContext(
210 "Assoc",
212 m_staMac->TraceConnectWithoutContext(
213 "DeAssoc",
215
216 m_ap1Mac->TraceConnectWithoutContext(
217 "AssociatedSta",
219 m_ap1Mac->TraceConnectWithoutContext(
220 "DeAssociatedSta",
222
223 m_ap2Mac->TraceConnectWithoutContext(
224 "AssociatedSta",
226 m_ap2Mac->TraceConnectWithoutContext(
227 "DeAssociatedSta",
229}
230
231void
233 uint8_t phyId,
234 WifiConstPsduMap psduMap,
235 WifiTxVector txVector,
236 double txPowerW)
237{
238 auto linkId = mac->GetLinkForPhy(phyId);
239 NS_TEST_ASSERT_MSG_EQ(linkId.has_value(), true, "No link found for PHY ID " << +phyId);
240
241 for (const auto& [aid, psdu] : psduMap)
242 {
243 std::stringstream ss;
244 ss << std::setprecision(10) << " Link ID " << +linkId.value() << " Phy ID " << +phyId
245 << " #MPDUs " << psdu->GetNMpdus();
246 for (auto it = psdu->begin(); it != psdu->end(); ++it)
247 {
248 ss << "\n" << **it;
249 }
250 NS_LOG_INFO(ss.str());
251 }
252 NS_LOG_INFO("TXVECTOR = " << txVector << "\n");
253
254 const auto psdu = psduMap.cbegin()->second;
255 const auto& hdr = psdu->GetHeader(0);
256
257 if (!m_checkTxPsdus || m_framesToSkip.contains(hdr.GetType()))
258 {
259 return;
260 }
261
262 if (!m_events.empty())
263 {
264 // check that the expected frame is being transmitted
266 hdr.GetTypeString(),
267 "Unexpected MAC header type for frame transmitted at time "
268 << Simulator::Now().As(Time::US));
269 // perform actions/checks, if any
270 if (m_events.front().func)
271 {
272 m_events.front().func(psdu, txVector, linkId.value());
273 }
274
275 m_events.pop_front();
276 }
277}
278
281 std::size_t apId,
282 std::size_t count,
283 std::size_t pktSize,
284 uint8_t priority) const
285{
286 auto client = CreateObject<PacketSocketClient>();
287 client->SetAttribute("PacketSize", UintegerValue(pktSize));
288 client->SetAttribute("MaxPackets", UintegerValue(count));
289 client->SetAttribute("Interval", TimeValue(MicroSeconds(0)));
290 client->SetAttribute("Priority", UintegerValue(priority));
291 client->SetRemote(apId == 1 ? m_ap1Sockets.at(dir) : m_ap2Sockets.at(dir));
292 client->SetStartTime(Time{0}); // now
293 client->SetStopTime(m_duration - Simulator::Now());
294
295 return client;
296}
297
298/***********************************
299 * WifiDisassocAndReassocTest
300 ***********************************/
301
303 const Params& params)
304 : WifiAssociationTestBase("Disassociation and reassociation test, " +
305 (std::ostringstream{} << params).str(),
306 baseParams),
307 m_params(params),
310{
311 m_assocMgrTypeId = "ns3::WifiTestAssocManager";
314 m_params.trafficDir == WifiDirection::UPLINK),
315 true,
316 "Unexpected traffic direction: " << m_params.trafficDir);
317}
318
319void
321{
322 Config::SetDefault("ns3::StaWifiMac::AssocType", EnumValue(m_params.assocType));
323
325
326 auto assocManager = DynamicCast<WifiTestAssocManager>(m_staMac->GetAssocManager());
327 NS_TEST_ASSERT_MSG_NE(assocManager, nullptr, "Expected a test association manager");
328
329 // set the AP to associate with first
330
331 std::list<StaWifiMac::ApInfo::SetupLinksInfo> setupLinks;
332 // the association manager provides setup links only in case of ML setup
333 if (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP)
334 {
335 for (const auto& [staLinkId, apLinkId] : m_params.firstSetupLinks)
336 {
337 setupLinks.push_back(
338 {staLinkId, apLinkId, m_ap1Mac->GetFrameExchangeManager(apLinkId)->GetAddress()});
339 }
340 }
341 assocManager->SetBestAp(m_ap1Mac->GetFrameExchangeManager(m_params.firstApLinkId)->GetAddress(),
342 setupLinks);
343
344 // install error models
345 for (std::size_t phyId = 0; phyId < m_staMac->GetNLinks(); ++phyId)
346 {
347 m_staMac->GetDevice()->GetPhy(phyId)->SetPostReceptionErrorModel(m_staErrorModel);
348 }
349 for (std::size_t phyId = 0; phyId < m_ap1Mac->GetNLinks(); ++phyId)
350 {
351 m_ap1Mac->GetDevice()->GetPhy(phyId)->SetPostReceptionErrorModel(m_ap1ErrorModel);
352 }
353}
354
355void
357{
358 NS_LOG_FUNCTION(this << bssid);
359
360 if (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP
361 ? (bssid == m_ap1Mac->GetAddress())
362 : m_ap1Mac->GetLinkIdByAddress(bssid).has_value())
363 {
365 }
366 else if (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP
367 ? (bssid == m_ap2Mac->GetAddress())
368 : m_ap2Mac->GetLinkIdByAddress(bssid).has_value())
369 {
371 }
372 else
373 {
374 NS_TEST_ASSERT_MSG_EQ(true, false, "Unexpected BSSID " << bssid);
375 }
376
379 this,
381}
382
383void
385{
386 NS_LOG_FUNCTION(this << apMac->GetAddress() << aid << staAddress);
387
389 {
390 return; // notification of other links that have been setup
391 }
392
393 const auto assocCount = m_assocSeenByAp1Count + m_assocSeenByAp2Count;
394 if (assocCount == 0)
395 {
396 // first association
397 InsertEvents();
398 }
401 this,
402 (assocCount == 0));
403
404 if (apMac == m_ap1Mac)
405 {
407 }
408 else if (apMac == m_ap2Mac)
409 {
411 }
412 else
413 {
414 NS_TEST_ASSERT_MSG_EQ(true, false, "Unexpected AP " << apMac->GetAddress());
415 }
416
418 m_checkTxPsdus = true; // check transmitted frames
419}
420
421void
423 uint16_t aid,
424 Mac48Address staAddress)
425{
426 const auto addrByAid = apMac->GetMldOrLinkAddressByAid(aid);
427
428 NS_TEST_ASSERT_MSG_EQ(addrByAid.has_value(),
429 true,
430 "AID of disassociated STA not found: " << aid);
431 NS_TEST_EXPECT_MSG_EQ(addrByAid.value(), staAddress, "Retrieved wrong address by AID");
432
433 Simulator::Schedule(TimeStep(1), [this, apMac, aid] {
434 NS_TEST_EXPECT_MSG_EQ(apMac->GetMldOrLinkAddressByAid(aid).has_value(),
435 false,
436 "AID of disassociated STA still found: " << aid);
437 });
438}
439
440void
442{
443 // check that the remote station manager(s) of the AP store the correct status for the STA
444 const auto when = std::string(" after ") + (firstAssoc ? "first" : "second") + " association";
445 const auto apId = (firstAssoc ? m_firstApId : m_params.secondApId);
446 const auto& setupLinks = (firstAssoc ? m_params.firstSetupLinks : m_params.secondSetupLinks);
447 auto apMac = (apId == m_firstApId ? m_ap1Mac : m_ap2Mac);
448 const auto isMlSetup =
449 (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP) && (apMac->GetNLinks() > 1);
450 for (linkId_t linkId = 0; linkId < apMac->GetNLinks(); ++linkId)
451 {
452 auto stationManager = apMac->GetWifiRemoteStationManager(linkId);
453
454 if (std::any_of(setupLinks.cbegin(), setupLinks.cend(), [=](auto&& linkIds) {
455 return linkIds.second == linkId;
456 }))
457 {
458 auto staLinkId = linkId;
459 if (!isMlSetup)
460 {
461 // find the STA link ID corresponding to the link setup by the AP
462 auto it = std::find_if(setupLinks.cbegin(),
463 setupLinks.cend(),
464 [linkId](auto&& pair) { return pair.second == linkId; });
465 NS_TEST_ASSERT_MSG_EQ((it != setupLinks.cend()),
466 true,
467 "AP link ID (" << +linkId
468 << ") not found in given setup links");
469 staLinkId = it->first;
470 }
471 // this link must have been setup
472 NS_TEST_EXPECT_MSG_EQ(stationManager->IsAssociated(
473 m_staMac->GetFrameExchangeManager(staLinkId)->GetAddress()),
474 true,
475 "Expected STA to be associated with AP " << apId << " on link "
476 << +linkId << when);
477 const auto staAddr = stationManager->GetAffiliatedStaAddress(m_staMac->GetAddress());
478 NS_TEST_EXPECT_MSG_EQ(staAddr.has_value(),
479 isMlSetup,
480 "Unexpected value returned by GetAffiliatedStaAddress" << when);
481 if (staAddr.has_value())
482 {
483 NS_TEST_EXPECT_MSG_EQ(staAddr.value(),
484 m_staMac->GetFrameExchangeManager(linkId)->GetAddress(),
485 "Unexpected address returned by GetAffiliatedStaAddress"
486 << when);
487 }
488 }
489 else
490 {
491 // this link must have not been setup, thus every STA link address should not be
492 // reported as associated by the remote station manager of the AP operating on this
493 // link. The exception is the case in which the STA performs legacy association, does
494 // not send a Disassociation frame and re-associates with the same AP on a distinct
495 // link. In such a case, the AP cannot know that the STA requesting association is the
496 // same as the STA previously associated on another link
497 for (const auto staLinkId : m_staMac->GetLinkIds())
498 {
499 const auto isAssociated = !isMlSetup && !m_params.sendDisassoc && !firstAssoc &&
500 (m_params.secondApId == m_firstApId) &&
501 (staLinkId == m_params.firstSetupLinks.front().first) &&
502 (linkId == m_params.firstSetupLinks.front().second);
503
505 stationManager->IsAssociated(
506 m_staMac->GetFrameExchangeManager(staLinkId)->GetAddress()),
507 isAssociated,
508 "Expected STA " << (isAssociated ? "" : "not ") << "to be associated with AP "
509 << apId << " on link " << +linkId << when);
510 }
511 const auto staAddr = stationManager->GetAffiliatedStaAddress(m_staMac->GetAddress());
512 NS_TEST_EXPECT_MSG_EQ(staAddr.has_value(),
513 false,
514 "Unexpected value returned by GetAffiliatedStaAddress for link "
515 << +linkId << when);
516 }
517 }
518}
519
520void
522{
523 const auto when = std::string(" after ") + (firstAssoc ? "first" : "second") + " association";
524 const auto apId = (firstAssoc ? m_firstApId : m_params.secondApId);
525 const auto setupLinks = m_staMac->GetSetupLinkIds();
526 auto apMac = (apId == 1 ? m_ap1Mac : m_ap2Mac);
527 const auto isMlSetup =
528 (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP) && (apMac->GetNLinks() > 1);
529
530 const auto& givenSetupLinks =
531 (firstAssoc ? m_params.firstSetupLinks : m_params.secondSetupLinks);
532 std::set<linkId_t> expectedSetupLinks;
533 for (const auto& [staLinkId, apLinkId] : givenSetupLinks)
534 {
535 expectedSetupLinks.insert(isMlSetup ? apLinkId : staLinkId);
536 }
537
538 for (const auto linkId : m_staMac->GetLinkIds())
539 {
540 NS_TEST_EXPECT_MSG_EQ(setupLinks.contains(linkId),
541 expectedSetupLinks.contains(linkId),
542 "Unexpected setup link (" << +linkId << ")" << when);
543 }
544
545 for (const auto staLinkId : setupLinks)
546 {
547 auto apLinkId = staLinkId;
548 if (!isMlSetup)
549 {
550 // find the AP link ID corresponding to the link setup by the STA
551 auto it = std::find_if(givenSetupLinks.cbegin(),
552 givenSetupLinks.cend(),
553 [staLinkId](auto&& pair) { return pair.first == staLinkId; });
554 NS_TEST_ASSERT_MSG_EQ((it != givenSetupLinks.cend()),
555 true,
556 "STA link ID (" << +staLinkId
557 << ") not found in given setup links");
558 apLinkId = it->second;
559 }
560 NS_TEST_EXPECT_MSG_EQ(m_staMac->GetBssid(staLinkId),
561 apMac->GetFrameExchangeManager(apLinkId)->GetAddress(),
562 "Incorrect BSSID on link " << +staLinkId << when);
563 }
564}
565
566void
568{
569 NS_LOG_FUNCTION(this << "\n");
570
571 auto assocManager = DynamicCast<WifiTestAssocManager>(m_staMac->GetAssocManager());
572 NS_TEST_ASSERT_MSG_NE(assocManager, nullptr, "Expected a test association manager");
573
574 // set the AP to associate with next
575
576 const auto apMac = (m_params.secondApId == 1 ? m_ap1Mac : m_ap2Mac);
577 std::list<StaWifiMac::ApInfo::SetupLinksInfo> setupLinks;
578 // the association manager provides setup links only in case of ML setup
579 if (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP)
580 {
581 for (const auto& [staLinkId, apLinkId] : m_params.secondSetupLinks)
582 {
583 setupLinks.push_back(
584 {staLinkId, apLinkId, apMac->GetFrameExchangeManager(apLinkId)->GetAddress()});
585 }
586 }
587 assocManager->SetBestAp(apMac->GetFrameExchangeManager(m_params.secondApLinkId)->GetAddress(),
588 setupLinks);
589
590 // request the STA to disassociate
591 m_staMac->ForceDisassociation(m_params.sendDisassoc);
592}
593
594void
596{
597 NS_TEST_EXPECT_MSG_EQ(((local == m_staMac) || (local == m_ap1Mac)),
598 true,
599 "Unexpected local MAC");
600 std::string context{(local == m_staMac ? "STA: " : "AP1: ")};
601
602 const auto remote =
604 const auto localIsSender =
605 (local == m_staMac && m_params.trafficDir == WifiDirection::UPLINK) ||
606 (local == m_ap1Mac && m_params.trafficDir == WifiDirection::DOWNLINK);
607
608 Mac48Address addr;
609 const auto wasMlSetup =
610 (m_params.assocType == WifiAssocType::ML_SETUP) && (m_ap1Mac->GetNLinks() > 1);
611
612 // check that queues have been blocked with DISASSOCIATION reason
613 for (const auto& [staLinkId, apLinkId] : m_params.firstSetupLinks)
614 {
615 const auto localLinkId =
616 (wasMlSetup ? apLinkId : (local == m_staMac ? staLinkId : apLinkId));
617 const auto remoteLinkId =
618 (wasMlSetup ? apLinkId : (local == m_staMac ? apLinkId : staLinkId));
619 const auto linkAddr = remote->GetFrameExchangeManager(remoteLinkId)->GetAddress();
620 addr = (wasMlSetup ? remote->GetAddress() : linkAddr);
621
622 for (const auto& [aci, ac] : wifiAcList)
623 {
624 for (const auto& queueId : std::initializer_list<WifiContainerQueueId>{
625 MakeWifiUnicastQueueId(WIFI_QOSDATA_QUEUE, addr, ac.GetLowTid()),
626 MakeWifiUnicastQueueId(WIFI_QOSDATA_QUEUE, addr, ac.GetHighTid()),
629 {
630 if (auto mask =
631 local->GetMacQueueScheduler()->GetQueueLinkMask(aci, queueId, localLinkId))
632 {
633 NS_TEST_EXPECT_MSG_EQ(mask->test(static_cast<std::size_t>(
635 true,
636 context << "Expected transmissions on link "
637 << +localLinkId << " to be blocked for queue "
638 << queueId);
639 }
640 }
641 }
642
643 if (localIsSender)
644 {
645 // check that QoS data frames have not been dropped
646 const auto queueId = MakeWifiUnicastQueueId(WIFI_QOSDATA_QUEUE, addr, 0);
647 NS_TEST_EXPECT_MSG_EQ(local->GetTxopQueue(AC_BE)->GetNPackets(queueId),
649 context << "Unexpected number of QoS data frames queued");
650 }
651 }
652
653 if (local == m_staMac)
654 {
655 NS_TEST_EXPECT_MSG_EQ(m_staMac->IsAssociated(),
656 false,
657 context << "Expected STA in unassociated state");
658 }
659 else if (m_params.sendDisassoc)
660 {
661 NS_TEST_EXPECT_MSG_EQ(m_ap1Mac->IsAssociated(addr).has_value(),
662 false,
663 context << "Expected STA in unassociated state");
664 }
665
666 if (localIsSender)
667 {
668 // check that control queues have been flushed if and only if ML setup was performed and STA
669 // did not notify disassociation to the AP
670 const auto acBe = local->GetTxopQueue(AC_BE);
671 const auto remoteBaLinkAddr = remote->GetFrameExchangeManager(m_baLinkId)->GetAddress();
673 acBe->GetNPackets(MakeWifiUnicastQueueId(WIFI_CTL_QUEUE, remoteBaLinkAddr)),
674 (m_params.sendDisassoc || wasMlSetup ? 0 : 1),
675 context << "Expected BAR to be kept only if legacy association was performed and STA "
676 "did not notify disassociation to the AP");
677 }
678
679 // A Block Ack agreement is still established with the remote device if and only if the STA has
680 // not sent a Disassociation frame
681 NS_TEST_EXPECT_MSG_EQ((localIsSender
682 ? local->GetBaAgreementEstablishedAsOriginator(addr, 0).has_value()
683 : local->GetBaAgreementEstablishedAsRecipient(addr, 0).has_value()),
684 !m_params.sendDisassoc,
685 context << "Unexpected Block Ack agreement state");
686}
687
688void
690{
691 using enum WifiDirection;
692
693 const auto isMlSetup =
694 (m_staMac->GetAssocType() == WifiAssocType::ML_SETUP) && (m_ap1Mac->GetNLinks() > 1);
695
696 // lambda to check that a BAR is queued before disassociation
697 auto checkQueuedBarBeforeDisassoc = [=, this]() {
698 auto staLinkId = m_baLinkId;
699 if (!isMlSetup)
700 {
701 // find the STA link ID corresponding to the link setup by the AP
702 auto it = std::find_if(m_params.firstSetupLinks.cbegin(),
703 m_params.firstSetupLinks.cend(),
704 [this](auto&& pair) { return pair.second == m_baLinkId; });
705 NS_TEST_ASSERT_MSG_EQ((it != m_params.firstSetupLinks.cend()),
706 true,
707 "AP link ID (" << +m_baLinkId
708 << ") not found in given setup links");
709 staLinkId = it->first;
710 }
711 auto mpdu = StaticCast<HtFrameExchangeManager>(m_staMac->GetFrameExchangeManager(staLinkId))
712 ->GetBar(AC_BE);
713 NS_TEST_ASSERT_MSG_NE(mpdu, nullptr, "Expected a BAR before disassociation");
715 m_ap1Mac->GetLinkIdByAddress(mpdu->GetHeader().GetAddr1()).has_value(),
716 true,
717 "Expected BAR to be addressed to an AP link address");
718 };
719
720 if (m_staMac->GetAssocType() == WifiAssocType::LEGACY)
721 {
722 const auto staLinkId = m_params.firstSetupLinks.front().first;
723 m_ap1Sockets[DOWNLINK].SetPhysicalAddress(
724 m_staMac->GetFrameExchangeManager(staLinkId)->GetAddress());
725 }
726
727 const auto nLinks = m_staMac->GetSetupLinkIds().size();
728 NS_TEST_ASSERT_MSG_GT_OR_EQ(nLinks, 1, "No link setup");
729 auto client = (m_params.trafficDir == DOWNLINK ? m_ap1Mac->GetDevice() : m_staMac->GetDevice());
730
731 // After association, Data Null frames are sent on all the links other than the one used for
732 // setup to switch to active mode. Data Null frames have been excluded from the list of events
733 for (std::size_t i = 0; i < nLinks - 1; ++i)
734 {
735 m_events.emplace_back(
737 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
738 // Generate more packets to test correct reception after last Ack
739 if (i == nLinks - 2)
740 {
741 client->GetNode()->AddApplication(
742 GetApplication(m_params.trafficDir, m_firstApId, m_nPackets, 1000));
743 }
744 });
745 }
746
747 if (nLinks == 1)
748 {
749 // no Data Null frame, generate packets directly
750 client->GetNode()->AddApplication(
751 GetApplication(m_params.trafficDir, m_firstApId, m_nPackets, 1000));
752 }
753
754 // BlockAck agreement establishment
755 m_events.emplace_back(WIFI_MAC_MGT_ACTION);
756 m_events.emplace_back(WIFI_MAC_CTL_ACK);
757 m_events.emplace_back(WIFI_MAC_MGT_ACTION);
758 m_events.emplace_back(WIFI_MAC_CTL_ACK);
759
760 // First A-MPDU
761 m_events.emplace_back(
763 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
764 NS_TEST_EXPECT_MSG_EQ(psdu->GetNMpdus(),
766 "Unexpected number of MPDUs in first A-MPDU");
767
768 // in the uplink case, corrupt the first two MPDUs so that the STA does not receive it
769 if (m_params.trafficDir == UPLINK)
770 {
771 m_ap1ErrorModel->SetList(
772 {psdu->GetPayload(0)->GetUid(), psdu->GetPayload(1)->GetUid()});
773 }
774
775 const auto txMac = (m_params.trafficDir == UPLINK ? StaticCast<WifiMac>(m_staMac)
777 const auto rxMac = (m_params.trafficDir == DOWNLINK ? StaticCast<WifiMac>(m_staMac)
780 psdu->GetAddr2(),
781 txMac->GetFrameExchangeManager(linkId)->GetAddress(),
782 "Unexpected TA for first QoS data frames sent after first association");
783 NS_TEST_EXPECT_MSG_EQ(rxMac->GetLinkIdByAddress(psdu->GetAddr1()).has_value(),
784 true,
785 "RA (" << psdu->GetAddr1()
786 << ") does not belong to the expected device");
787 });
788
789 m_events.emplace_back(
791 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
792 const auto txMac = (m_params.trafficDir == UPLINK ? StaticCast<WifiMac>(m_ap1Mac)
794 NS_TEST_EXPECT_MSG_EQ(psdu->GetAddr2(),
795 txMac->GetFrameExchangeManager(linkId)->GetAddress(),
796 "Unexpected TA for first BlockAck sent after first association");
797 m_baLinkId = linkId;
798
799 // in the uplink case, corrupt the BlockAck so that the STA does not receive it
800 if (m_params.trafficDir == UPLINK)
801 {
802 m_staErrorModel->SetList({psdu->GetPayload(0)->GetUid()});
803 // enable reception of the two MPDUs next time they are transmitted
804 m_ap1ErrorModel->SetList({});
805 const auto txDuration =
807 txVector,
808 txMac->GetWifiPhy(linkId)->GetPhyBand());
809
810 // if a Disassociation frame is sent, request disassociation now. Disassociation
811 // actually takes place when the Disassociation frame is acked, but we need to
812 // enqueue the Disassociation frame before the BlockAckReq (enqueued at BlockAck
813 // timeout) to send the Disassociation frame first and be able to test the
814 // situation in which a BlockAckReq is queued when disassociation occurs
815 if (m_params.sendDisassoc)
816 {
817 Simulator::Schedule(txDuration,
819 this);
820 }
821 else
822 {
823 // Disassociation takes place immediately when a Disassociation frame is not
824 // sent, thus wait until after BlockAck timeout (which occurs at the end of the
825 // expected BlockAck reception because the BlockAck is corrupted) to request
826 // disassociation
827 Simulator::Schedule(txDuration + MAX_PROPAGATION_DELAY, [=, this] {
828 checkQueuedBarBeforeDisassoc();
829 StartRoaming();
831 });
832 }
833 }
834 });
835
836 if (m_params.sendDisassoc)
837 {
838 m_events.emplace_back(
840 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
841 NS_TEST_EXPECT_MSG_EQ(psdu->GetAddr2(),
842 m_staMac->GetFrameExchangeManager(linkId)->GetAddress(),
843 "Unexpected TA for Disassociation frame");
844 // the Disassociation frame is sent after BlockAck timeout, thus a BAR should be
845 // already queued
846 checkQueuedBarBeforeDisassoc();
847 });
848
849 m_events.emplace_back(
851 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
853 const auto txDuration =
855 txVector,
856 m_ap1Mac->GetWifiPhy(linkId)->GetPhyBand());
859 this,
860 m_staMac);
861 });
862 }
863
864 // Roaming
866 m_events.emplace_back(
868 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
869 // if the first AP has not received a Disassociation frame and receives an Association
870 // frame, it realizes that the STA is re-associating, thus clears the STA state
871 if (m_params.secondApId == m_firstApId && !m_params.sendDisassoc)
872 {
874 }
875 });
876
877 // STA has not dropped the BlockAckReq frame if and only if STA has not sent a Disassociation
878 // frame (otherwise all control frames are dropped), STA established legacy association and
879 // reassociates with the same AP (and same link)
880 const auto hasBlockAckReq =
881 (!m_params.sendDisassoc && !isMlSetup && (m_params.secondApId == m_firstApId) &&
882 (m_params.firstApLinkId == m_params.secondApLinkId));
883
885 m_events.emplace_back(
887 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
888 // check that STA still has a queued BlockAckReq only in the case described above
889 for (linkId_t i = 0; i < m_ap1Mac->GetNLinks(); ++i)
890 {
891 const auto queueId =
893 m_ap1Mac->GetFrameExchangeManager(i)->GetAddress());
895 (m_staMac->GetTxopQueue(AC_BE)->PeekByQueueId(queueId) == nullptr),
896 !hasBlockAckReq,
897 "Expected" << (hasBlockAckReq ? "" : " no") << " BlockAckReq in queue "
898 << queueId);
899 }
900 });
901
902 // A new BlockAck agreement must be established if STA roams to a different AP or STA destroyed
903 // previous agreement (which occurs when STA sends a Disassociation frame) or legacy association
904 // is performed and STA setups a different link than before
905 if (m_params.secondApId != m_firstApId || m_params.sendDisassoc ||
906 (!isMlSetup && m_params.firstApLinkId != m_params.secondApLinkId))
907 {
908 m_events.emplace_back(WIFI_MAC_MGT_ACTION);
909 m_events.emplace_back(WIFI_MAC_CTL_ACK);
910 m_events.emplace_back(WIFI_MAC_MGT_ACTION);
911 m_events.emplace_back(WIFI_MAC_CTL_ACK);
912 }
913
914 if (hasBlockAckReq)
915 {
916 m_events.emplace_back(WIFI_MAC_CTL_BACKREQ);
917 m_events.emplace_back(WIFI_MAC_CTL_BACKRESP);
918 }
919
920 // First A-MPDU retransmitted
921 m_events.emplace_back(
923 [=, this](Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, linkId_t linkId) {
924 NS_TEST_EXPECT_MSG_EQ(psdu->GetNMpdus(),
925 (hasBlockAckReq ? 2 : m_nPackets),
926 "Unexpected number of MPDUs in first A-MPDU after roaming");
927
928 const auto txMac = (m_params.trafficDir == UPLINK
930 : (m_params.secondApId == 1 ? StaticCast<WifiMac>(m_ap1Mac)
932 const auto rxMac = (m_params.trafficDir == DOWNLINK
934 : (m_params.secondApId == 1 ? StaticCast<WifiMac>(m_ap1Mac)
937 psdu->GetAddr2(),
938 txMac->GetFrameExchangeManager(linkId)->GetAddress(),
939 "Unexpected TA for first QoS data frames sent after second association");
940 NS_TEST_EXPECT_MSG_EQ(rxMac->GetLinkIdByAddress(psdu->GetAddr1()).has_value(),
941 true,
942 "RA (" << psdu->GetAddr1()
943 << ") does not belong to the expected device");
944 });
945
946 m_events.emplace_back(WIFI_MAC_CTL_BACKRESP);
947}
948
949void
951{
954
955 NS_TEST_EXPECT_MSG_EQ(m_events.empty(), true, "Not all events took place");
956
958
959 std::size_t expectedAssocWithAp1Count{0};
960 std::size_t expectedAssocWithAp2Count{0};
961 std::size_t expectedAssocSeenByAp1Count{0};
962 std::size_t expectedAssocSeenByAp2Count{0};
963
964 for (const auto id : {m_firstApId, m_params.secondApId})
965 {
966 switch (id)
967 {
968 case 1:
969 ++expectedAssocWithAp1Count;
970 ++expectedAssocSeenByAp1Count;
971 break;
972 case 2:
973 ++expectedAssocWithAp2Count;
974 ++expectedAssocSeenByAp2Count;
975 break;
976 default:
977 NS_TEST_ASSERT_MSG_EQ(true, false, "Unexpected AP ID " << id);
978 }
979 }
980
982 expectedAssocWithAp1Count,
983 "Unexpected number of associations with AP 1 (seen by STA)");
985 expectedAssocWithAp2Count,
986 "Unexpected number of associations with AP 2 (seen by STA)");
988 expectedAssocSeenByAp1Count,
989 "Unexpected number of associations with AP 1 (seen by AP 1)");
991 expectedAssocSeenByAp2Count,
992 "Unexpected number of associations with AP 2 (seen by AP 2)");
993}
994
996 : TestSuite("wifi-assoc-test", Type::UNIT)
997{
998 for (const auto trafficDir : {WifiDirection::UPLINK})
999 {
1000 for (const auto sendDisassoc : {true, false})
1001 {
1002 using ParamsList = std::list<WifiDisassocAndReassocTest::Params>;
1003
1004 // Single-link devices
1005 // clang-format off
1006 for (const WifiAssociationTestBase::BaseParams baseParams =
1007 {.ap1Channels = "{0,40,BAND_5GHZ,0}",
1008 .ap2Channels = "{0,40,BAND_5GHZ,0}",
1009 .staChannels = "{0,40,BAND_5GHZ,0}"};
1010 const auto& params :
1011 ParamsList{// legacy setup, re-associating to the same AP (distinct link)
1012 {.assocType = WifiAssocType::LEGACY,
1013 .firstApLinkId = 0,
1014 .firstSetupLinks = {{0, 0}},
1015 .secondApId = 1,
1016 .secondApLinkId = 0,
1017 .secondSetupLinks = {{0, 0}},
1018 .trafficDir = trafficDir,
1019 .sendDisassoc = sendDisassoc},
1020 // legacy setup, roaming to a different AP
1021 {.assocType = WifiAssocType::LEGACY,
1022 .firstApLinkId = 0,
1023 .firstSetupLinks = {{0, 0}},
1024 .secondApId = 2,
1025 .secondApLinkId = 0,
1026 .secondSetupLinks = {{0, 0}},
1027 .trafficDir = trafficDir,
1028 .sendDisassoc = sendDisassoc}})
1029 // clang-format on
1030 {
1031 AddTestCase(new WifiDisassocAndReassocTest(baseParams, params),
1033 }
1034
1035 // Multi-link devices using either ML setup or legacy association
1036 // clang-format off
1037 for (const WifiAssociationTestBase::BaseParams baseParams =
1038 {.ap1Channels = "{0,40,BAND_5GHZ,0};{0,40,BAND_6GHZ,0};{0,40,BAND_2_4GHZ,0}",
1039 .ap2Channels = "{0,40,BAND_6GHZ,0};{0,40,BAND_2_4GHZ,0}",
1040 .staChannels = "{0,40,BAND_2_4GHZ,0};{0,40,BAND_5GHZ,0};{0,40,BAND_6GHZ,0}"};
1041 const auto& params :
1042 ParamsList{// ML setup, re-associating to the same AP (distinct links)
1043 {.assocType = WifiAssocType::ML_SETUP,
1044 .firstApLinkId = 0,
1045 .firstSetupLinks = {{1, 0}, {0, 2}}, // STA link 1->0, 0->2
1046 .secondApId = 1,
1047 .secondApLinkId = 1,
1048 .secondSetupLinks = {{1, 1}},
1049 .trafficDir = trafficDir,
1050 .sendDisassoc = sendDisassoc},
1051 // ML setup, roaming to a different AP
1052 {.assocType = WifiAssocType::ML_SETUP,
1053 .firstApLinkId = 0,
1054 .firstSetupLinks = {{1, 0}, {0, 2}}, // STA link 1->0, 0->2
1055 .secondApId = 2,
1056 .secondApLinkId = 0,
1057 .secondSetupLinks = {{1, 0}},
1058 .trafficDir = trafficDir,
1059 .sendDisassoc = sendDisassoc},
1060 // legacy setup, re-associating to the same AP (distinct link)
1061 {.assocType = WifiAssocType::LEGACY,
1062 .firstApLinkId = 0,
1063 .firstSetupLinks = {{1, 0}},
1064 .secondApId = 1,
1065 .secondApLinkId = 1,
1066 .secondSetupLinks = {{2, 1}},
1067 .trafficDir = trafficDir,
1068 .sendDisassoc = sendDisassoc},
1069 // legacy setup, roaming to a different AP
1070 {.assocType = WifiAssocType::LEGACY,
1071 .firstApLinkId = 0,
1072 .firstSetupLinks = {{1, 0}},
1073 .secondApId = 2,
1074 .secondApLinkId = 1,
1075 .secondSetupLinks = {{0, 1}},
1076 .trafficDir = trafficDir,
1077 .sendDisassoc = sendDisassoc}})
1078 // clang-format on
1079 {
1080 AddTestCase(new WifiDisassocAndReassocTest(baseParams, params),
1082 }
1083 }
1084 }
1085}
1086
virtual void DisassocSeenByAp(ApWifiMac *apMac, uint16_t aid, Mac48Address staAddress)
Callback invoked when the given AP detects that the given STA has disassociated.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
virtual void DisassocSeenBySta(Mac48Address bssid)
Callback invoked when a STA transitions to unassociated state.
WifiAssociationTestBase(const std::string &name, const BaseParams &baseParams)
Constructor.
virtual void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when a FEM passes PSDUs to the PHY.
Ptr< ApWifiMac > m_ap1Mac
AP 1 wifi MAC.
Ptr< StaWifiMac > m_staMac
STA wifi MAC.
virtual void AssocSeenBySta(Mac48Address bssid)
Callback invoked when a STA completes association with an AP.
std::string m_assocMgrTypeId
Association Manager type ID.
bool m_checkTxPsdus
whether TX PSDUs should be checked against the list of events
Ptr< PacketSocketClient > GetApplication(WifiDirection dir, std::size_t apId, std::size_t count, std::size_t pktSize, uint8_t priority=0) const
Ptr< ApWifiMac > m_ap2Mac
AP 2 wifi MAC.
BaseParams m_baseParams
configuration parameters
std::map< WifiDirection, PacketSocketAddress > m_ap1Sockets
packet socket addresses for DL/UL traffic from AP1
virtual void AssocSeenByAp(ApWifiMac *apMac, uint16_t aid, Mac48Address staAddress)
Callback invoked when the given AP detects that the given STA has completed association.
std::map< WifiDirection, PacketSocketAddress > m_ap2Sockets
packet socket addresses for DL/UL traffic from AP2
Time m_duration
simulation duration
std::list< Events > m_events
list of events for a test run
std::set< WifiMacType > m_framesToSkip
frames that must not be checked against the list of events
wifi 11be MLD Test Suite
Test association, disassociation and reassociation in various scenarios.
void InsertEvents()
Insert elements in the list of expected events (transmitted frames).
Params m_params
parameters specific for this test
linkId_t m_baLinkId
ID of the link on which the BA is sent before roaming.
Ptr< ListErrorModel > m_ap1ErrorModel
error rate model to install on the first AP
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void StartRoaming()
Take actions connected to roaming.
void AssocSeenByAp(ApWifiMac *apMac, uint16_t aid, Mac48Address staAddress) override
Callback invoked when the given AP detects that the given STA has completed association.
void DisassocSeenByAp(ApWifiMac *apMac, uint16_t aid, Mac48Address staAddress) override
Callback invoked when the given AP detects that the given STA has disassociated.
Time m_assocTime
time at which last association took place
std::size_t m_assocWithAp2Count
number of associations with AP 2 (seen by STA)
void CheckAfterDisassoc(Ptr< WifiMac > local)
Check that the expected operations are performed by the local device after disassociation.
std::size_t m_assocSeenByAp2Count
number of associations with AP 2 (seen by AP 2)
void CheckRemoteApInfo(bool firstAssoc)
Check that the STA stores the expected info about the AP it is expected to be associated with.
void AssocSeenBySta(Mac48Address bssid) override
Callback invoked when a STA completes association with an AP.
WifiDisassocAndReassocTest(const BaseParams &baseParams, const Params &params)
Constructor.
std::size_t m_assocSeenByAp1Count
number of associations with AP 1 (seen by AP 1)
const std::size_t m_firstApId
the ID of the AP (possibly affiliated with an AP MLD) that is the recipient of the first Assoc Reques...
Ptr< ListErrorModel > m_staErrorModel
error rate model to install on the STA
const std::size_t m_nPackets
number of packets generated in a burst
void CheckRemoteStaInfo(bool firstAssoc)
Check that the AP which the STA is expected to be associated with stores the expected info about the ...
std::size_t m_assocWithAp1Count
number of associations with AP 1 (seen by STA)
void DoRun() override
Implementation to actually run this TestCase.
bool CanBeReturned(const StaWifiMac::ApInfo &apInfo) const override
Allow subclasses to choose whether the given ApInfo shall be returned or discarded when the STA wifi ...
void SetBestAp(Mac48Address bssid, const std::list< StaWifiMac::ApInfo::SetupLinksInfo > &setupLinks)
Set the best AP to associate with.
std::list< StaWifiMac::ApInfo::SetupLinksInfo > m_setupLinks
the list of links to setup
void NotifyChannelSwitched(linkId_t linkId) override
Notify that the given link has completed channel switching.
bool Compare(const StaWifiMac::ApInfo &lhs, const StaWifiMac::ApInfo &rhs) const override
Compare two ApInfo objects for the purpose of keeping a sorted list of ApInfo objects.
Mac48Address m_bestAp
the MAC address of the AP to associate with
bool CanBeInserted(const StaWifiMac::ApInfo &apInfo) const override
Allow subclasses to choose whether the given ApInfo shall be considered and hence inserted in the sor...
Wi-Fi AP state machine.
Definition ap-wifi-mac.h:63
std::optional< Mac48Address > GetMldOrLinkAddressByAid(uint16_t aid) const
Hold variables of type enum.
Definition enum.h:52
Provide a list of Packet uids to corrupt.
an EUI-48 address
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.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
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.
Definition simulator.h:580
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:191
static void Run()
Run the simulation.
Definition simulator.cc:161
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:169
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
Definition ssid.h:27
AttributeValue implementation for Ssid.
Definition ssid.h:98
Hold variables of type string.
Definition string.h:45
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:296
@ QUICK
Fast test.
Definition test.h:1057
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
Type
Type of test.
Definition test.h:1271
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:494
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
@ US
microsecond
Definition nstime.h:108
Time TimeStep(uint64_t ts)
Scheduler interface.
Definition nstime.h:1410
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1003
Hold an unsigned integer type.
Definition uinteger.h:34
const SortedList & GetSortedList() const
std::list< StaWifiMac::ApInfo::SetupLinksInfo > & GetSetupLinks(const StaWifiMac::ApInfo &apInfo)
Get a reference to the list of the links to setup with the given AP.
void ScanningTimeout()
Extract the best AP to associate with from the sorted list and return it, if any, to the STA wifi MAC...
const WifiScanParams & GetScanParams() const
WifiAssocManager()
Constructor (protected as this is an abstract base class).
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 ...
Implements the IEEE 802.11 MAC header.
virtual const char * GetTypeString() const
Return a string corresponds to the header type.
create MAC layers for a ns3::WifiNetDevice.
Mac48Address GetAddress() const
Definition wifi-mac.cc:521
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1574
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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...
Definition callback.h:690
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:274
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
#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.
Definition test.h:133
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition test.h:240
#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.
Definition test.h:553
#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.
Definition test.h:904
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1347
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
WifiContainerQueueId MakeWifiUnicastQueueId(WifiContainerQueueType type, Mac48Address addr1, std::optional< tid_t > tid=std::nullopt)
Helper function to create WifiContainerQueueId for unicast queues.
@ WIFI_STANDARD_80211be
@ AC_BE
Best Effort.
Definition qos-utils.h:66
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:501
const Time MAX_PROPAGATION_DELAY
maximum propagation delay
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:643
StringVector SplitString(const std::string &str, const std::string &delim)
Split a string on a delimiter.
Definition string.cc:23
@ WIFI_MAC_CTL_BACKREQ
@ WIFI_MAC_DATA_NULL
@ WIFI_MAC_MGT_BEACON
@ WIFI_MAC_MGT_ACTION
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_CTL_ACK
@ WIFI_MAC_MGT_DISASSOCIATION
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_CTL_BACKRESP
@ WIFI_MAC_CTL_END
@ WIFI_MAC_QOSDATA
WifiDirection
Wifi direction.
Definition wifi-utils.h:42
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:650
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:39
uint8_t linkId_t
IEEE 802.11be D7.0 Figure 9-207e—Link ID Info field format.
Definition wifi-utils.h:76
const std::map< AcIndex, WifiAc > wifiAcList
Map containing the four ACs in increasing order of priority (according to Table 10-1 "UP-to-AC Mappin...
Definition qos-utils.cc:115
STL namespace.
Configuration parameters common to all subclasses.
Configuration parameters specific to this test.
Struct to hold information regarding observed AP through active/passive scanning.
Mac48Address m_bssid
BSSID.
std::string dir
static WifiAssociationTestSuite g_wifiAssociationTestSuite
the test suite