A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mlo-test.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 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
9#ifndef WIFI_MLO_TEST_H
10#define WIFI_MLO_TEST_H
11
12#include "ns3/ap-wifi-mac.h"
13#include "ns3/constant-rate-wifi-manager.h"
14#include "ns3/frame-exchange-manager.h"
15#include "ns3/mgt-action-headers.h"
16#include "ns3/mgt-headers.h"
17#include "ns3/multi-model-spectrum-channel.h"
18#include "ns3/packet-socket-client.h"
19#include "ns3/packet-socket-server.h"
20#include "ns3/qos-utils.h"
21#include "ns3/spectrum-wifi-helper.h"
22#include "ns3/sta-wifi-mac.h"
23#include "ns3/test.h"
24#include "ns3/wifi-psdu.h"
25
26#include <optional>
27#include <vector>
28
29using namespace ns3;
30
31/**
32 * @ingroup wifi-test
33 * @ingroup tests
34 *
35 * @brief Test the implementation of WifiAssocManager::GetNextAffiliatedAp(), which
36 * searches a given RNR element for APs affiliated to the same AP MLD as the
37 * reporting AP that sent the frame containing the element.
38 */
40{
41 public:
42 /**
43 * Constructor
44 */
46 ~GetRnrLinkInfoTest() override = default;
47
48 private:
49 void DoRun() override;
50};
51
52/**
53 * @ingroup wifi-test
54 * @ingroup tests
55 *
56 * Test the WifiMac::SwapLinks() method.
57 */
59{
60 /**
61 * Test WifiMac subclass used to access the SwapLinks method.
62 */
63 class TestWifiMac : public WifiMac
64 {
65 public:
66 ~TestWifiMac() override = default;
67
68 /// @return the object TypeId
69 static TypeId GetTypeId();
70
73
74 bool CanForwardPacketsTo(Mac48Address to) const override
75 {
76 return true;
77 }
78
79 private:
80 void DoCompleteConfig() override
81 {
82 }
83
84 void Enqueue(Ptr<WifiMpdu> mpdu, Mac48Address to, Mac48Address from) override
85 {
86 }
87 };
88
89 /**
90 * Test FrameExchangeManager subclass to access m_linkId
91 */
93 {
94 public:
95 /// @return the link ID stored by this object
96 uint8_t GetLinkId() const
97 {
98 return m_linkId;
99 }
100 };
101
102 /**
103 * Test RemoteStationManager subclass to access m_linkId
104 */
106 {
107 public:
108 /// @return the link ID stored by this object
109 uint8_t GetLinkId() const
110 {
111 return m_linkId;
112 }
113 };
114
115 public:
117 ~MldSwapLinksTest() override = default;
118
119 protected:
120 void DoRun() override;
121
122 private:
123 /**
124 * Run a single test case.
125 *
126 * @param text string identifying the test case
127 * @param nLinks the number of links of the MLD
128 * @param links a set of pairs (from, to) each mapping a current link ID to the
129 * link ID it has to become (i.e., link 'from' becomes link 'to')
130 * @param expected maps each link ID to the id of the PHY that is expected
131 * to operate on that link after the swap
132 */
133 void RunOne(std::string text,
134 std::size_t nLinks,
135 const std::map<uint8_t, uint8_t>& links,
136 const std::map<uint8_t, uint8_t>& expected);
137};
138
139/**
140 * @ingroup wifi-test
141 * @ingroup tests
142 *
143 * Test that the AIDs that an AP MLD assigns to SLDs and MLDs are all unique.
144 */
146{
147 public:
148 /**
149 * Constructor.
150 *
151 * @param linkIds A vector specifying the set of link IDs each STA will setup
152 * @param assocType the type of association procedure for non-AP devices
153 */
154 AidAssignmentTest(const std::vector<std::set<uint8_t>>& linkIds, WifiAssocType assocType);
155
156 private:
157 void DoSetup() override;
158 void DoRun() override;
159
160 /**
161 * Set the SSID on the next station that needs to start the association procedure.
162 * This method is triggered every time a STA completes its association.
163 *
164 * @param staMac the MAC of the STA that completed association
165 */
166 void SetSsid(Ptr<StaWifiMac> staMac, Mac48Address /* apAddr */);
167
168 const std::vector<std::string> m_linkChannels; //!< channels for all AP links
169 const std::vector<std::set<uint8_t>> m_linkIds; //!< link IDs for all non-AP STAs/MLDs
170 WifiAssocType m_assocType; //!< association type
171 NetDeviceContainer m_staDevices; //!< non-AP STAs/MLDs devices
172 uint16_t m_startAid; //!< first AID to allocate to stations
173 uint16_t m_expectedAid; //!< expected AID for current non-AP STA/MLD
174};
175
176/**
177 * @ingroup wifi-test
178 * @ingroup tests
179 *
180 * @brief Base class for Multi-Link Operations tests
181 *
182 * Three spectrum channels are created, one for each band (2.4 GHz, 5 GHz and 6 GHz).
183 * Each PHY object is attached to the spectrum channel corresponding to the PHY band
184 * in which it is operating.
185 */
187{
188 public:
189 /**
190 * Configuration parameters common to all subclasses
191 */
193 {
194 std::vector<std::string>
195 staChannels; //!< the strings specifying the operating channels for the non-AP MLD
196 std::vector<std::string>
197 apChannels; //!< the strings specifying the operating channels for the AP MLD
198 std::vector<uint8_t>
199 fixedPhyBands; //!< list of IDs of non-AP MLD PHYs that cannot switch band
200 WifiAssocType assocType{}; //!< type of the association procedure used by non-AP devices
201 };
202
203 /**
204 * Constructor
205 *
206 * @param name The name of the new TestCase created
207 * @param nStations the number of stations to create
208 * @param baseParams common configuration parameters
209 */
210 MultiLinkOperationsTestBase(const std::string& name,
211 uint8_t nStations,
212 const BaseParams& baseParams);
213 ~MultiLinkOperationsTestBase() override = default;
214
215 protected:
216 /**
217 * Callback invoked when a FEM passes PSDUs to the PHY.
218 *
219 * @param mac the MAC transmitting the PSDUs
220 * @param phyId the ID of the PHY transmitting the PSDUs
221 * @param psduMap the PSDU map
222 * @param txVector the TX vector
223 * @param txPowerW the tx power in Watts
224 */
225 virtual void Transmit(Ptr<WifiMac> mac,
226 uint8_t phyId,
227 WifiConstPsduMap psduMap,
228 WifiTxVector txVector,
229 double txPowerW);
230
231 /**
232 * Check that the expected Capabilities information elements are present in the given
233 * management frame based on the band in which the given link is operating.
234 *
235 * @param mpdu the given management frame
236 * @param mac the MAC transmitting the management frame
237 * @param phyId the ID of the PHY transmitting the management frame
238 */
239 void CheckCapabilities(Ptr<WifiMpdu> mpdu, Ptr<WifiMac> mac, uint8_t phyId);
240
241 /**
242 * Function to trace packets received by the server application
243 * @param nodeId the ID of the node that received the packet
244 * @param p the packet
245 * @param addr the address
246 */
247 virtual void L7Receive(uint8_t nodeId, Ptr<const Packet> p, const Address& addr);
248
249 /**
250 * @param sockAddr the packet socket address identifying local outgoing interface
251 * and remote address
252 * @param count the number of packets to generate
253 * @param pktSize the size of the packets to generate
254 * @param delay the delay with which traffic generation starts
255 * @param priority user priority for generated packets
256 * @return an application generating the given number packets of the given size destined
257 * to the given packet socket address
258 */
260 std::size_t count,
261 std::size_t pktSize,
262 Time delay = Seconds(0),
263 uint8_t priority = 0) const;
264
265 void DoSetup() override;
266
267 /// PHY band-indexed map of spectrum channels
268 using ChannelMap = std::map<FrequencyRange, Ptr<MultiModelSpectrumChannel>>;
269
270 /**
271 * Uplink or Downlink direction
272 */
274 {
275 DL = 0,
276 UL
277 };
278
279 /**
280 * Check that the Address 1 and Address 2 fields of the given PSDU contain device MAC addresses.
281 *
282 * @param psdu the given PSDU
283 * @param direction indicates direction for management frames (DL or UL)
284 */
286 std::optional<Direction> direction = std::nullopt);
287
288 /// Information about transmitted frames
290 {
291 Time startTx; ///< TX start time
292 WifiConstPsduMap psduMap; ///< transmitted PSDU map
293 WifiTxVector txVector; ///< TXVECTOR
294 uint8_t linkId; ///< link ID
295 uint8_t phyId; ///< ID of the transmitting PHY
296 };
297
298 std::vector<FrameInfo> m_txPsdus; ///< transmitted PSDUs
299 const std::vector<std::string> m_staChannels; ///< strings specifying channels for STA
300 const std::vector<std::string> m_apChannels; ///< strings specifying channels for AP
301 const std::vector<uint8_t> m_fixedPhyBands; ///< links on non-AP MLD with fixed PHY band
302 WifiAssocType m_assocType; ///< type of the association procedure used by non-AP devices
303 Ptr<ApWifiMac> m_apMac; ///< AP wifi MAC
304 std::vector<Ptr<StaWifiMac>> m_staMacs; ///< STA wifi MACs
305 uint8_t m_nStations; ///< number of stations to create
306 uint16_t m_startAid; ///< first AID to allocate to stations
307 uint16_t m_lastAid; ///< AID of last associated station
308 Time m_duration{Seconds(1)}; ///< simulation duration
309 std::vector<std::size_t> m_rxPkts; ///< number of packets received at application layer
310 ///< by each node (index is node ID)
311
312 /**
313 * Reset the given PHY helper, use the given strings to set the ChannelSettings
314 * attribute of the PHY objects to create, and attach them to the given spectrum
315 * channels appropriately.
316 *
317 * @param helper the given PHY helper
318 * @param channels the strings specifying the operating channels to configure
319 * @param channelMap the created spectrum channels
320 */
322 const std::vector<std::string>& channels,
323 const ChannelMap& channelMap);
324
325 /**
326 * Set the SSID on the next station that needs to start the association procedure.
327 * This method is connected to the ApWifiMac's AssociatedSta trace source.
328 * Start generating traffic (if needed) when all stations are associated.
329 *
330 * @param aid the AID assigned to the previous associated STA
331 */
332 void SetSsid(uint16_t aid, Mac48Address /* addr */);
333
334 private:
335 /**
336 * Start the generation of traffic (needs to be overridden)
337 */
338 virtual void StartTraffic()
339 {
340 }
341};
342
343/**
344 * @ingroup wifi-test
345 * @ingroup tests
346 *
347 * @brief Multi-Link Discovery & Setup test.
348 *
349 * This test sets up an AP MLD and a non-AP MLD having a variable number of links.
350 * The RF channels to set each link to are provided as input parameters through the test
351 * case constructor, along with the identifiers (starting at 0) of the links that cannot
352 * switch PHY band (if any). The links that are expected to be setup are also provided as input
353 * parameters. This test verifies that the management frames exchanged during ML discovery
354 * and ML setup contain the expected values and that the two MLDs setup the expected links.
355 *
356 * The negotiated TID-to-link mapping is tested by verifying that generated QoS data frames of
357 * a given TID are transmitted on links which the TID is mapped to. Specifically, the following
358 * operations are performed separately for each direction (downlink and uplink). A first TID
359 * is searched such that it is not mapped on all the setup links. If no such TID is found, only
360 * QoS frames of TID 0 are generated. Otherwise, we also search for a second TID that is mapped
361 * to a link set that is disjoint with the link set to which the first TID is mapped. If such a
362 * TID is found, QoS frames of both the first TID and the second TID are generated; otherwise,
363 * only QoS frames of the first TID are generated. For each TID, a number of QoS frames equal
364 * to the number of setup links is generated. For each TID, we check that the first N QoS frames,
365 * where N is the size of the link set to which the TID is mapped, are transmitted concurrently,
366 * while the following QoS frames are sent after the first QoS frame sent on the same link. We
367 * also check that all the QoS frames are sent on a link belonging to the link set to which the
368 * TID is mapped. If QoS frames of two TIDs are generated, we also check that the first N QoS
369 * frames of a TID, where N is the size of the link set to which that TID is mapped, are sent
370 * concurrently with the first M QoS frames of the other TID, where M is the size of the link
371 * set to which the other TID is mapped.
372 */
374{
375 public:
376 /**
377 * Constructor
378 *
379 * @param baseParams common configuration parameters
380 * @param scanType the scan type (active or passive)
381 * @param setupLinks a list of IDs (as seen by the AP device) of the links that are expected
382 * to be setup
383 * @param staSetupLinks a list of IDs (as seen by the non-AP device) of the links that are
384 * expected to be setup. This list shall be left empty (indicating that
385 * it equals the setupLinks argument) when ML setup is performed
386 * @param apNegSupport TID-to-Link Mapping negotiation supported by the AP MLD (0, 1, or 3)
387 * @param dlTidToLinkMapping DL TID-to-Link Mapping for EHT configuration of non-AP MLD
388 * @param ulTidToLinkMapping UL TID-to-Link Mapping for EHT configuration of non-AP MLD
389 * @param support160MHzOp whether non-AP MLDs support 160 MHz operations
390 */
391 MultiLinkSetupTest(const BaseParams& baseParams,
392 WifiScanType scanType,
393 const std::vector<uint8_t>& setupLinks,
394 const std::vector<uint8_t>& staSetupLinks,
396 const std::string& dlTidToLinkMapping,
397 const std::string& ulTidToLinkMapping,
398 bool support160MHzOp = true);
399 ~MultiLinkSetupTest() override = default;
400
401 protected:
402 void DoSetup() override;
403 void DoRun() override;
404
405 private:
406 void StartTraffic() override;
407
408 /**
409 * Check correctness of Multi-Link Setup procedure.
410 */
411 void CheckMlSetup();
412
413 /**
414 * Check that links that are not setup on the non-AP MLD are disabled. Also, on the AP side,
415 * check that the queue storing QoS data frames destined to the non-AP MLD has a mask for a
416 * link if and only if the link has been setup by the non-AO MLD.
417 */
418 void CheckDisabledLinks();
419
420 /**
421 * Check correctness of the given Beacon frame.
422 *
423 * @param mpdu the given Beacon frame
424 * @param linkId the ID of the link on which the Beacon frame was transmitted
425 */
426 void CheckBeacon(Ptr<WifiMpdu> mpdu, uint8_t linkId);
427
428 /**
429 * Check correctness of the given Probe Response frame.
430 *
431 * @param mpdu the given Probe Response frame
432 * @param linkId the ID of the link on which the Probe Response frame was transmitted
433 */
434 void CheckProbeResponse(Ptr<WifiMpdu> mpdu, uint8_t linkId);
435
436 /**
437 * Check correctness of the given Association Request frame.
438 *
439 * @param mpdu the given Association Request frame
440 * @param linkId the ID of the link on which the Association Request frame was transmitted
441 */
442 void CheckAssocRequest(Ptr<WifiMpdu> mpdu, uint8_t linkId);
443
444 /**
445 * Check correctness of the given Association Response frame.
446 *
447 * @param mpdu the given Association Response frame
448 * @param linkId the ID of the link on which the Association Response frame was transmitted
449 */
450 void CheckAssocResponse(Ptr<WifiMpdu> mpdu, uint8_t linkId);
451
452 /**
453 * Check that QoS data frames are sent on links their TID is mapped to and with the
454 * correct TX width.
455 *
456 * @param mpdu the given QoS data frame
457 * @param txvector the TXVECTOR used to send the QoS data frame
458 * @param linkId the ID of the link on which the QoS data frame was transmitted
459 * @param index index of the QoS data frame in the vector of transmitted PSDUs
460 */
461 void CheckQosData(Ptr<WifiMpdu> mpdu,
462 const WifiTxVector& txvector,
463 uint8_t linkId,
464 std::size_t index);
465
466 const std::vector<uint8_t> m_setupLinks; //!< IDs (as seen by the AP device) of the expected
467 //!< links to setup
468 const std::vector<uint8_t> m_staSetupLinks; //!< IDs (as seen by the non-AP device) of the
469 //!< expected links to setup
470 WifiScanType m_scanType; //!< the scan type (active or passive)
471 std::size_t m_nProbeResp; //!< number of Probe Responses received by the non-AP MLD
473 m_apNegSupport; //!< TID-to-Link Mapping negotiation supported by the AP MLD
474 std::string m_dlTidLinkMappingStr; //!< DL TID-to-Link Mapping for non-AP MLD EHT configuration
475 std::string m_ulTidLinkMappingStr; //!< UL TID-to-Link Mapping for non-AP MLD EHT configuration
476 WifiTidLinkMapping m_dlTidLinkMapping; //!< expected DL TID-to-Link Mapping requested by non-AP
477 //!< MLD and accepted by AP MLD
478 WifiTidLinkMapping m_ulTidLinkMapping; //!< expected UL TID-to-Link Mapping requested by non-AP
479 //!< MLD and accepted by AP MLD
480 uint8_t m_dlTid1; //!< the TID of the first set of DL QoS data frames
481 uint8_t m_ulTid1; //!< the TID of the first set of UL QoS data frames
482 std::optional<uint8_t> m_dlTid2; //!< the TID of the optional set of DL QoS data frames
483 std::optional<uint8_t> m_ulTid2; //!< the TID of the optional set of UL QoS data frames
484 std::vector<std::size_t>
485 m_qosFrames1; //!< indices of QoS frames of the first set in the vector of TX PSDUs
486 std::vector<std::size_t>
487 m_qosFrames2; //!< indices of QoS frames of the optional set in the vector of TX PSDUs
488 bool m_support160MHzOp; //!< whether non-AP MLDs support 160 MHz operations
489};
490
491/**
492 * Tested traffic patterns.
493 */
494enum class WifiTrafficPattern : uint8_t
495{
496 STA_TO_STA = 0,
497 STA_TO_AP,
498 AP_TO_STA,
501};
502
503/**
504 * Block Ack agreement enabled/disabled
505 */
506enum class WifiBaEnabled : uint8_t
507{
508 NO = 0,
509 YES
510};
511
512/**
513 * Whether to send a BlockAckReq after a missed BlockAck
514 */
515enum class WifiUseBarAfterMissedBa : uint8_t
516{
517 NO = 0,
518 YES
519};
520
521/**
522 * @ingroup wifi-test
523 * @ingroup tests
524 *
525 * @brief Test data transmission between two MLDs.
526 *
527 * This test sets up an AP MLD and two non-AP MLDs having a variable number of links.
528 * The RF channels to set each link to are provided as input parameters through the test
529 * case constructor, along with the identifiers (starting at 0) of the links that cannot
530 * switch PHY band (if any). This test aims at veryfing the successful transmission of both
531 * unicast QoS data frames (from one station to another, from one station to the AP, from
532 * the AP to the station) and broadcast QoS data frames (from the AP or from one station).
533 * In the scenarios in which the AP forwards frames (i.e., from one station to another and
534 * from one station to broadcast) the client application generates only 4 packets, in order
535 * to limit the probability of collisions. In the other scenarios, 8 packets are generated.
536 * When BlockAck agreements are enabled, the maximum A-MSDU size is set such that two
537 * packets can be aggregated in an A-MSDU. The MPDU with sequence number equal to 1 is
538 * corrupted (once, by using a post reception error model) to test its successful
539 * re-transmission, unless the traffic scenario is from the AP to broadcast (broadcast frames
540 * are not retransmitted) or is a scenario where the AP forwards frame (to limit the
541 * probability of collisions).
542 *
543 * When BlockAck agreements are enabled, we also corrupt a BlockAck frame, so as to simulate
544 * the case of BlockAck timeout. Both the case where a BlockAckReq is sent and the case where
545 * data frame are retransmitted are tested. Finally, when BlockAck agreements are enabled, we
546 * also enable the concurrent transmission of data frames over two links and check that at
547 * least one MPDU is concurrently transmitted over two links.
548 */
550{
551 public:
552 /**
553 * Constructor
554 *
555 * @param baseParams common configuration parameters
556 * @param trafficPattern the pattern of traffic to generate
557 * @param baEnabled whether BA agreement is enabled or disabled
558 * @param useBarAfterMissedBa whether a BAR or Data frames are sent after missed BlockAck
559 * @param nMaxInflight the max number of links on which an MPDU can be simultaneously inflight
560 * (unused if Block Ack agreements are not established)
561 */
562 MultiLinkTxTest(const BaseParams& baseParams,
563 WifiTrafficPattern trafficPattern,
564 WifiBaEnabled baEnabled,
565 WifiUseBarAfterMissedBa useBarAfterMissedBa,
566 uint8_t nMaxInflight);
567 ~MultiLinkTxTest() override = default;
568
569 protected:
570 /**
571 * Check the content of a received BlockAck frame when the max number of links on which
572 * an MPDU can be inflight is one.
573 *
574 * @param psdu the PSDU containing the BlockAck
575 * @param txVector the TXVECTOR used to transmit the BlockAck
576 * @param linkId the ID of the link on which the BlockAck was transmitted
577 */
578 void CheckBlockAck(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, uint8_t linkId);
579
580 void Transmit(Ptr<WifiMac> mac,
581 uint8_t phyId,
582 WifiConstPsduMap psduMap,
583 WifiTxVector txVector,
584 double txPowerW) override;
585 void DoSetup() override;
586 void DoRun() override;
587
588 private:
589 void StartTraffic() override;
590
591 /// Receiver address-indexed map of list error models
592 using RxErrorModelMap = std::unordered_map<Mac48Address, Ptr<ListErrorModel>, WifiAddressHash>;
593
594 RxErrorModelMap m_errorModels; ///< error rate models to corrupt packets
595 std::list<uint64_t> m_uidList; ///< list of UIDs of packets to corrupt
596 bool m_dataCorrupted{false}; ///< whether second data frame has been already corrupted
597 WifiTrafficPattern m_trafficPattern; ///< the pattern of traffic to generate
598 bool m_baEnabled; ///< whether BA agreement is enabled or disabled
599 bool m_useBarAfterMissedBa; ///< whether to send BAR after missed BlockAck
600 std::size_t m_nMaxInflight; ///< max number of links on which an MPDU can be inflight
601 std::size_t m_nPackets; ///< number of application packets to generate
602 std::size_t m_blockAckCount{0}; ///< transmitted BlockAck counter
603 std::size_t m_blockAckReqCount{0}; ///< transmitted BlockAckReq counter
604 std::map<uint16_t, std::size_t> m_inflightCount; ///< seqNo-indexed max number of simultaneous
605 ///< transmissions of a data frame
606 Ptr<WifiMac> m_sourceMac; ///< MAC of the node sending application packets
607};
608
609/**
610 * Tested MU traffic patterns.
611 */
612enum class WifiMuTrafficPattern : uint8_t
613{
617 UL_MU
618};
619
620/**
621 * @ingroup wifi-test
622 * @ingroup tests
623 *
624 * @brief Test data transmission between MLDs using OFDMA MU transmissions
625 *
626 * This test sets up an AP MLD and two non-AP MLDs having a variable number of links.
627 * The RF channels to set each link to are provided as input parameters through the test
628 * case constructor, along with the identifiers (starting at 0) of the links that cannot
629 * switch PHY band (if any). This test aims at veryfing the successful transmission of both
630 * DL MU and UL MU frames. In the DL MU scenarios, the client applications installed on the
631 * AP generate 8 packets addressed to each of the stations (plus 3 packets to trigger the
632 * establishment of BlockAck agreements). In the UL MU scenario, client applications
633 * installed on the stations generate 4 packets each (plus 3 packets to trigger the
634 * establishment of BlockAck agreements).
635 *
636 * The maximum A-MSDU size is set such that two packets can be aggregated in an A-MSDU.
637 * The MPDU with sequence number equal to 3 is corrupted (by using a post reception error
638 * model) once and for a single station, to test its successful re-transmission.
639 *
640 * Also, we enable the concurrent transmission of data frames over two links and check that at
641 * least one MPDU is concurrently transmitted over two links.
642 */
644{
645 public:
646 /**
647 * Constructor
648 *
649 * @param baseParams common configuration parameters
650 * @param muTrafficPattern the pattern of traffic to generate
651 * @param useBarAfterMissedBa whether a BAR or Data frames are sent after missed BlockAck
652 * @param nMaxInflight the max number of links on which an MPDU can be simultaneously inflight
653 * (unused if Block Ack agreements are not established)
654 */
655 MultiLinkMuTxTest(const BaseParams& baseParams,
656 WifiMuTrafficPattern muTrafficPattern,
657 WifiUseBarAfterMissedBa useBarAfterMissedBa,
658 uint8_t nMaxInflight);
659 ~MultiLinkMuTxTest() override = default;
660
661 protected:
662 /**
663 * Check the content of a received BlockAck frame when the max number of links on which
664 * an MPDU can be inflight is one.
665 *
666 * @param psdu the PSDU containing the BlockAck
667 * @param txVector the TXVECTOR used to transmit the BlockAck
668 * @param linkId the ID of the link on which the BlockAck was transmitted
669 */
670 void CheckBlockAck(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, uint8_t linkId);
671
672 void Transmit(Ptr<WifiMac> mac,
673 uint8_t phyId,
674 WifiConstPsduMap psduMap,
675 WifiTxVector txVector,
676 double txPowerW) override;
677 void DoSetup() override;
678 void DoRun() override;
679
680 private:
681 void StartTraffic() override;
682
683 /// Receiver address-indexed map of list error models
684 using RxErrorModelMap = std::unordered_map<Mac48Address, Ptr<ListErrorModel>, WifiAddressHash>;
685
686 /// A pair of a MAC address (the address of the receiver for DL frames and the address of
687 /// the sender for UL frames) and a sequence number identifying a transmitted QoS data frame
688 using AddrSeqNoPair = std::pair<Mac48Address, uint16_t>;
689
690 RxErrorModelMap m_errorModels; ///< error rate models to corrupt packets
691 std::list<uint64_t> m_uidList; ///< list of UIDs of packets to corrupt
692 std::optional<Mac48Address> m_dataCorruptedSta; ///< MAC address of the station that received
693 ///< MPDU with SeqNo=2 corrupted
694 bool m_waitFirstTf{true}; ///< whether we are waiting for the first Basic Trigger Frame
695 WifiMuTrafficPattern m_muTrafficPattern; ///< the pattern of traffic to generate
696 bool m_useBarAfterMissedBa; ///< whether to send BAR after missed BlockAck
697 std::size_t m_nMaxInflight; ///< max number of links on which an MPDU can be inflight
698 std::vector<PacketSocketAddress> m_sockets; ///< packet socket addresses for STAs
699 std::size_t m_nPackets; ///< number of application packets to generate
700 std::size_t m_blockAckCount{0}; ///< transmitted BlockAck counter
701 std::size_t m_tfCount{0}; ///< transmitted Trigger Frame counter
702 // std::size_t m_blockAckReqCount{0}; ///< transmitted BlockAckReq counter
703 std::map<AddrSeqNoPair, std::size_t> m_inflightCount; ///< max number of simultaneous
704 ///< transmissions of each data frame
705 Ptr<WifiMac> m_sourceMac; ///< MAC of the node sending application packets
706};
707
708/**
709 * @ingroup wifi-test
710 * @ingroup tests
711 *
712 * @brief Test release of sequence numbers upon CTS timeout in multi-link operations
713 *
714 * In this test, an AP MLD and a non-AP MLD setup 3 links. Usage of RTS/CTS protection is
715 * enabled for frames whose length is at least 1000 bytes. The AP MLD receives a first set
716 * of 4 packets from the upper layer and sends an RTS frame, which is corrupted at the
717 * receiver, on a first link. When the RTS frame is transmitted, the AP MLD receives another
718 * set of 4 packets, which are transmitted after a successful RTS/CTS exchange on a second
719 * link. In the meantime, a new RTS/CTS exchange is successfully carried out (on the first
720 * link or on the third link) to transmit the first set of 4 packets. When the transmission
721 * of the first set of 4 packets starts, the AP MLD receives the third set of 4 packets from
722 * the upper layer, which are transmitted after a successful RTS/CTS exchange.
723 *
724 * This test checks that sequence numbers are correctly assigned to all the MPDUs carrying data.
725 */
727{
728 public:
731
732 protected:
733 void DoSetup() override;
734 void DoRun() override;
735 void Transmit(Ptr<WifiMac> mac,
736 uint8_t phyId,
737 WifiConstPsduMap psduMap,
738 WifiTxVector txVector,
739 double txPowerW) override;
740
741 private:
742 void StartTraffic() override;
743
744 PacketSocketAddress m_sockAddr; //!< packet socket address
745 std::size_t m_nQosDataFrames; //!< counter for transmitted QoS data frames
746 Ptr<ListErrorModel> m_errorModel; //!< error rate model to corrupt first RTS frame
747 bool m_rtsCorrupted; //!< whether the first RTS frame has been corrupted
748};
749
750/**
751 * @ingroup wifi-test
752 * @ingroup tests
753 *
754 * @brief Test update of BA starting sequence number after ADDBA Response timeout in
755 * multi-link operations
756 *
757 * In this test, an AP MLD and a non-AP MLD setup 2 links. The AP MLD has a QoS data frame to
758 * transmit to the non-AP MLD, which triggers the establishment of a BA agreement. When the ADDBA
759 * Request frame is received by the non-AP MLD, transmissions of the non-AP MLD are blocked to put
760 * the transmission of the ADDBA Response on hold. The goal is to mimic a delay in getting channel
761 * access due to, e.g., other devices grabbing the medium. When the ADDBA Response timer at the AP
762 * MLD expires, transmissions of the non-AP MLD are unblocked, so that the AP MLD sends the QoS data
763 * frame (protected by RTS, but the test works without RTS as well, and using Normal acknowledgment)
764 * on one link and the non-AP MLD sends the ADDBA Response on the other link. The transmission of
765 * the QoS data frame is then corrupted. We verify that:
766 *
767 * - when the AP MLD receives the ADDBA Response, the BA starting sequence number is set to the
768 * sequence number of the QoS data frame which is inflight
769 * - the QoS data frame is retransmitted and received by the non-AP MLD
770 */
772{
773 public:
775
776 private:
777 void DoSetup() override;
778 void DoRun() override;
779 void Transmit(Ptr<WifiMac> mac,
780 uint8_t phyId,
781 WifiConstPsduMap psduMap,
782 WifiTxVector txVector,
783 double txPowerW) override;
784 void StartTraffic() override;
785
786 PacketSocketAddress m_sockAddr; //!< packet socket address
787 std::size_t m_nQosDataCount; //!< counter for transmitted QoS data frames
788 Ptr<ListErrorModel> m_staErrorModel; //!< error rate model to corrupt frames at the non-AP MLD
789};
790
791/**
792 * @ingroup wifi-test
793 * @ingroup tests
794 *
795 * @brief Test BlockAckReq frame sent by a Block Ack originator after dropping QoS data frames
796 *
797 * In this test, a non-AP STA associates with an AP MLD with 2 links using either legacy association
798 * or ML setup. A Block Ack agreement is established first in the downlink direction; the AP MLD
799 * sends 2 data frames, which are both corrupted. When a timeout occurs at the AP MLD, the 2 data
800 * frames are dropped, thus the AP MLD sends a BlockAckReq to advance the recipient window. It is
801 * checked that the BlockAckReq has the correct link addresses and that the non-AP STA replies with
802 * a BlockAck having correct link addresses. Then, a Block Ack agreement is established in the
803 * uplink direction and the same pattern of actions are repeated (in the inverse direction).
804 */
806{
807 public:
808 /**
809 * Constructor.
810 *
811 * @param assocType the association type
812 */
814
815 protected:
816 void DoSetup() override;
817 void DoRun() override;
818 void Transmit(Ptr<WifiMac> mac,
819 uint8_t phyId,
820 WifiConstPsduMap psduMap,
821 WifiTxVector txVector,
822 double txPowerW) override;
823
824 /// Actions and checks to perform upon the transmission of each frame
825 struct Events
826 {
827 /**
828 * Constructor.
829 *
830 * @param type the frame MAC header type
831 * @param f function to perform actions and checks
832 */
834 std::function<void(Ptr<const WifiPsdu>, const WifiTxVector&, uint8_t)>&& f = {})
835 : hdrType(type),
836 func(f)
837 {
838 }
839
840 WifiMacType hdrType; ///< MAC header type of frame being transmitted
841 std::function<void(Ptr<const WifiPsdu>, const WifiTxVector&, uint8_t)>
842 func; ///< function to perform actions and checks
843 };
844
845 /// Insert elements in the list of expected events (transmitted frames)
846 void InsertEvents();
847
848 private:
849 void StartTraffic() override;
850
851 bool m_setupDone{false}; //!< whether association has been completed
852 std::list<Events> m_events; //!< list of events for a test run
853 std::size_t m_processedEvents{0}; //!< number of processed events
854 Ptr<ListErrorModel> m_staErrorModel; //!< error rate model to corrupt frames at the non-AP STA
855 Ptr<ListErrorModel> m_apErrorModel; //!< error rate model to corrupt frames at the AP MLD
856};
857
858/**
859 * @ingroup wifi-test
860 * @ingroup tests
861 *
862 * @brief wifi 11be MLD Test Suite
863 */
869
870#endif /* WIFI_MLO_TEST_H */
Test that the AIDs that an AP MLD assigns to SLDs and MLDs are all unique.
WifiAssocType m_assocType
association type
AidAssignmentTest(const std::vector< std::set< uint8_t > > &linkIds, WifiAssocType assocType)
Constructor.
const std::vector< std::set< uint8_t > > m_linkIds
link IDs for all non-AP STAs/MLDs
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void SetSsid(Ptr< StaWifiMac > staMac, Mac48Address)
Set the SSID on the next station that needs to start the association procedure.
uint16_t m_startAid
first AID to allocate to stations
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_expectedAid
expected AID for current non-AP STA/MLD
const std::vector< std::string > m_linkChannels
channels for all AP links
NetDeviceContainer m_staDevices
non-AP STAs/MLDs devices
Test BlockAckReq frame sent by a Block Ack originator after dropping QoS data frames.
Ptr< ListErrorModel > m_apErrorModel
error rate model to corrupt frames at the AP MLD
void InsertEvents()
Insert elements in the list of expected events (transmitted frames)
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) override
Callback invoked when a FEM passes PSDUs to the PHY.
std::list< Events > m_events
list of events for a test run
bool m_setupDone
whether association has been completed
void StartTraffic() override
Start the generation of traffic (needs to be overridden)
std::size_t m_processedEvents
number of processed events
Ptr< ListErrorModel > m_staErrorModel
error rate model to corrupt frames at the non-AP STA
BarAfterDroppedMpduTest(WifiAssocType assocType)
Constructor.
Test release of sequence numbers upon CTS timeout in multi-link operations.
PacketSocketAddress m_sockAddr
packet socket address
Ptr< ListErrorModel > m_errorModel
error rate model to corrupt first RTS frame
std::size_t m_nQosDataFrames
counter for transmitted QoS data frames
void StartTraffic() override
Start the generation of traffic (needs to be overridden)
bool m_rtsCorrupted
whether the first RTS frame has been corrupted
void DoSetup() override
Implementation to do any local setup required for this TestCase.
~ReleaseSeqNoAfterCtsTimeoutTest() override=default
void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) override
Callback invoked when a FEM passes PSDUs to the PHY.
void DoRun() override
Implementation to actually run this TestCase.
Test update of BA starting sequence number after ADDBA Response timeout in multi-link operations.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
PacketSocketAddress m_sockAddr
packet socket address
std::size_t m_nQosDataCount
counter for transmitted QoS data frames
void StartTraffic() override
Start the generation of traffic (needs to be overridden)
void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) override
Callback invoked when a FEM passes PSDUs to the PHY.
Ptr< ListErrorModel > m_staErrorModel
error rate model to corrupt frames at the non-AP MLD
a polymophic address class
Definition address.h:90
use constant rates for data and RTS transmissions
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
uint8_t m_linkId
the ID of the link this object is associated with
an EUI-48 address
holds a vector of ns3::NetDevice pointers
an address for a packet socket
Smart pointer class similar to boost::intrusive_ptr.
Make it easy to create and manage PHY objects for the spectrum model.
encapsulates test code
Definition test.h:1050
A suite of tests to run.
Definition test.h:1267
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
base class for all MAC-level wifi objects.
Definition wifi-mac.h:90
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition wifi-mac.cc:1091
void SwapLinks(std::map< uint8_t, uint8_t > links)
Swap the links based on the information included in the given map.
Definition wifi-mac.cc:1172
uint8_t m_linkId
the ID of the link this object is associated with
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1345
WifiScanType
Scan type (active or passive)
WifiAssocType
Type of association performed by this device (provided that it is supported by the standard configure...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiTidToLinkMappingNegSupport
TID-to-Link Mapping Negotiation Support.
std::map< uint8_t, std::set< uint8_t > > WifiTidLinkMapping
TID-indexed map of the link set to which the TID is mapped.
Definition wifi-utils.h:68
WifiMacType
Combination of valid MAC header type/subtype.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
Actions and checks to perform upon the transmission of each frame.
std::function< void(Ptr< const WifiPsdu >, const WifiTxVector &, uint8_t)> func
function to perform actions and checks
Events(WifiMacType type, std::function< void(Ptr< const WifiPsdu >, const WifiTxVector &, uint8_t)> &&f={})
Constructor.
WifiMacType hdrType
MAC header type of frame being transmitted.
Function object to compute the hash of a MAC address.
Definition qos-utils.h:45
uint32_t pktSize
packet size used for the simulation (in bytes)
WifiMuTrafficPattern
Tested MU traffic patterns.
WifiTrafficPattern
Tested traffic patterns.
WifiUseBarAfterMissedBa
Whether to send a BlockAckReq after a missed BlockAck.
WifiBaEnabled
Block Ack agreement enabled/disabled.