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,
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 * Also, it is verified that, when the AP MLD receives the Ack following the Association Response:
356 * (i) the AP MLD considers the STA affiliated with the non-AP MLD and operating on the link used
357 * for association as in active mode and the other STAs affiliated with the non-AP MLD as in
358 * PowerSave mode; (ii) the STA affiliated with the non-AP MLD and operating on the link used for
359 * association is in active mode, while the other STAs affiliated with the non-AP MLD are switching
360 * to active mode, as they were in PowerSave mode and scheduled the transmission of a Data Null
361 * frame to switch to active mode.
362 *
363 * The negotiated TID-to-link mapping is tested by verifying that generated QoS data frames of
364 * a given TID are transmitted on links which the TID is mapped to. Specifically, the following
365 * operations are performed separately for each direction (downlink and uplink). A first TID
366 * is searched such that it is not mapped on all the setup links. If no such TID is found, only
367 * QoS frames of TID 0 are generated. Otherwise, we also search for a second TID that is mapped
368 * to a link set that is disjoint with the link set to which the first TID is mapped. If such a
369 * TID is found, QoS frames of both the first TID and the second TID are generated; otherwise,
370 * only QoS frames of the first TID are generated. For each TID, a number of QoS frames equal
371 * to the number of setup links is generated. For each TID, we check that the first N QoS frames,
372 * where N is the size of the link set to which the TID is mapped, are transmitted concurrently,
373 * while the following QoS frames are sent after the first QoS frame sent on the same link. We
374 * also check that all the QoS frames are sent on a link belonging to the link set to which the
375 * TID is mapped. If QoS frames of two TIDs are generated, we also check that the first N QoS
376 * frames of a TID, where N is the size of the link set to which that TID is mapped, are sent
377 * concurrently with the first M QoS frames of the other TID, where M is the size of the link
378 * set to which the other TID is mapped.
379 */
381{
382 public:
383 /**
384 * Constructor
385 *
386 * @param baseParams common configuration parameters
387 * @param scanType the scan type (active or passive)
388 * @param setupLinks a list of IDs (as seen by the AP device) of the links that are expected
389 * to be setup
390 * @param staSetupLinks a list of IDs (as seen by the non-AP device) of the links that are
391 * expected to be setup. This list shall be left empty (indicating that
392 * it equals the setupLinks argument) when ML setup is performed
393 * @param apNegSupport TID-to-Link Mapping negotiation supported by the AP MLD (0, 1, or 3)
394 * @param dlTidToLinkMapping DL TID-to-Link Mapping for EHT configuration of non-AP MLD
395 * @param ulTidToLinkMapping UL TID-to-Link Mapping for EHT configuration of non-AP MLD
396 * @param support160MHzOp whether non-AP MLDs support 160 MHz operations
397 */
398 MultiLinkSetupTest(const BaseParams& baseParams,
399 WifiScanType scanType,
400 const std::vector<uint8_t>& setupLinks,
401 const std::vector<uint8_t>& staSetupLinks,
403 const std::string& dlTidToLinkMapping,
404 const std::string& ulTidToLinkMapping,
405 bool support160MHzOp = true);
406 ~MultiLinkSetupTest() override = default;
407
408 protected:
409 void DoSetup() override;
410 void DoRun() override;
411
412 private:
413 void StartTraffic() override;
414
415 /**
416 * Check correctness of Multi-Link Setup procedure.
417 */
418 void CheckMlSetup();
419
420 /**
421 * This function is connected to the ApWifiMac's AssociatedSta trace source and checks that:
422 * (i) the AP MLD considers the STA affiliated with the non-AP MLD and operating on the link
423 * used for association as in active mode and the other STAs affiliated with the non-AP MLD as
424 * in PowerSave mode; (ii) the STA affiliated with the non-AP MLD and operating on the link used
425 * for association is in active mode, while the other STAs affiliated with the non-AP MLD are
426 * switching to active mode, as they were in PowerSave mode and scheduled the transmission of a
427 * Data Null frame to switch to active mode.
428 *
429 * @param aid the AID assigned to the associated STA
430 * @param staAddr the MAC link address of the associated STA
431 */
432 void CheckPmMode(uint16_t aid, Mac48Address staAddr);
433
434 /**
435 * Check that links that are not setup on the non-AP MLD are disabled. Also, on the AP side,
436 * check that the queue storing QoS data frames destined to the non-AP MLD has a mask for a
437 * link if and only if the link has been setup by the non-AO MLD.
438 */
439 void CheckDisabledLinks();
440
441 /**
442 * Check correctness of the given Beacon frame.
443 *
444 * @param mpdu the given Beacon frame
445 * @param linkId the ID of the link on which the Beacon frame was transmitted
446 */
447 void CheckBeacon(Ptr<WifiMpdu> mpdu, uint8_t linkId);
448
449 /**
450 * Check correctness of the given Probe Response frame.
451 *
452 * @param mpdu the given Probe Response frame
453 * @param linkId the ID of the link on which the Probe Response frame was transmitted
454 */
455 void CheckProbeResponse(Ptr<WifiMpdu> mpdu, uint8_t linkId);
456
457 /**
458 * Check correctness of the given Association Request frame.
459 *
460 * @param mpdu the given Association Request frame
461 * @param linkId the ID of the link on which the Association Request frame was transmitted
462 */
463 void CheckAssocRequest(Ptr<WifiMpdu> mpdu, uint8_t linkId);
464
465 /**
466 * Check correctness of the given Association Response frame.
467 *
468 * @param mpdu the given Association Response frame
469 * @param linkId the ID of the link on which the Association Response frame was transmitted
470 */
471 void CheckAssocResponse(Ptr<WifiMpdu> mpdu, uint8_t linkId);
472
473 /**
474 * Check that QoS data frames are sent on links their TID is mapped to and with the
475 * correct TX width.
476 *
477 * @param mpdu the given QoS data frame
478 * @param txvector the TXVECTOR used to send the QoS data frame
479 * @param linkId the ID of the link on which the QoS data frame was transmitted
480 * @param index index of the QoS data frame in the vector of transmitted PSDUs
481 */
482 void CheckQosData(Ptr<WifiMpdu> mpdu,
483 const WifiTxVector& txvector,
484 uint8_t linkId,
485 std::size_t index);
486
487 const std::vector<uint8_t> m_setupLinks; //!< IDs (as seen by the AP device) of the expected
488 //!< links to setup
489 const std::vector<uint8_t> m_staSetupLinks; //!< IDs (as seen by the non-AP device) of the
490 //!< expected links to setup
491 WifiScanType m_scanType; //!< the scan type (active or passive)
492 std::size_t m_nProbeResp; //!< number of Probe Responses received by the non-AP MLD
494 m_apNegSupport; //!< TID-to-Link Mapping negotiation supported by the AP MLD
495 std::string m_dlTidLinkMappingStr; //!< DL TID-to-Link Mapping for non-AP MLD EHT configuration
496 std::string m_ulTidLinkMappingStr; //!< UL TID-to-Link Mapping for non-AP MLD EHT configuration
497 WifiTidLinkMapping m_dlTidLinkMapping; //!< expected DL TID-to-Link Mapping requested by non-AP
498 //!< MLD and accepted by AP MLD
499 WifiTidLinkMapping m_ulTidLinkMapping; //!< expected UL TID-to-Link Mapping requested by non-AP
500 //!< MLD and accepted by AP MLD
501 uint8_t m_dlTid1; //!< the TID of the first set of DL QoS data frames
502 uint8_t m_ulTid1; //!< the TID of the first set of UL QoS data frames
503 std::optional<uint8_t> m_dlTid2; //!< the TID of the optional set of DL QoS data frames
504 std::optional<uint8_t> m_ulTid2; //!< the TID of the optional set of UL QoS data frames
505 std::vector<std::size_t>
506 m_qosFrames1; //!< indices of QoS frames of the first set in the vector of TX PSDUs
507 std::vector<std::size_t>
508 m_qosFrames2; //!< indices of QoS frames of the optional set in the vector of TX PSDUs
509 bool m_support160MHzOp; //!< whether non-AP MLDs support 160 MHz operations
510 bool m_assocCompleted; //!< whether non-AP MLD has completed association
511};
512
513/**
514 * Tested traffic patterns.
515 */
524
525/**
526 * Block Ack agreement enabled/disabled
527 */
528enum class WifiBaEnabled : uint8_t
529{
530 NO = 0,
532};
533
534/**
535 * Whether to send a BlockAckReq after a missed BlockAck
536 */
537enum class WifiUseBarAfterMissedBa : uint8_t
538{
539 NO = 0,
541};
542
543/**
544 * @ingroup wifi-test
545 * @ingroup tests
546 *
547 * @brief Test data transmission between two MLDs.
548 *
549 * This test sets up an AP MLD and two non-AP MLDs having a variable number of links.
550 * The RF channels to set each link to are provided as input parameters through the test
551 * case constructor, along with the identifiers (starting at 0) of the links that cannot
552 * switch PHY band (if any). This test aims at veryfing the successful transmission of both
553 * unicast QoS data frames (from one station to another, from one station to the AP, from
554 * the AP to the station) and broadcast QoS data frames (from the AP or from one station).
555 * In the scenarios in which the AP forwards frames (i.e., from one station to another and
556 * from one station to broadcast) the client application generates only 4 packets, in order
557 * to limit the probability of collisions. In the other scenarios, 8 packets are generated.
558 * When BlockAck agreements are enabled, the maximum A-MSDU size is set such that two
559 * packets can be aggregated in an A-MSDU. The MPDU with sequence number equal to 1 is
560 * corrupted (once, by using a post reception error model) to test its successful
561 * re-transmission, unless the traffic scenario is from the AP to broadcast (broadcast frames
562 * are not retransmitted) or is a scenario where the AP forwards frame (to limit the
563 * probability of collisions).
564 *
565 * When BlockAck agreements are enabled, we also corrupt a BlockAck frame, so as to simulate
566 * the case of BlockAck timeout. Both the case where a BlockAckReq is sent and the case where
567 * data frame are retransmitted are tested. Finally, when BlockAck agreements are enabled, we
568 * also enable the concurrent transmission of data frames over two links and check that at
569 * least one MPDU is concurrently transmitted over two links.
570 */
572{
573 public:
574 /**
575 * Constructor
576 *
577 * @param baseParams common configuration parameters
578 * @param trafficPattern the pattern of traffic to generate
579 * @param baEnabled whether BA agreement is enabled or disabled
580 * @param useBarAfterMissedBa whether a BAR or Data frames are sent after missed BlockAck
581 * @param nMaxInflight the max number of links on which an MPDU can be simultaneously inflight
582 * (unused if Block Ack agreements are not established)
583 */
584 MultiLinkTxTest(const BaseParams& baseParams,
585 WifiTrafficPattern trafficPattern,
586 WifiBaEnabled baEnabled,
587 WifiUseBarAfterMissedBa useBarAfterMissedBa,
588 uint8_t nMaxInflight);
589 ~MultiLinkTxTest() override = default;
590
591 protected:
592 /**
593 * Check the content of a received BlockAck frame when the max number of links on which
594 * an MPDU can be inflight is one.
595 *
596 * @param psdu the PSDU containing the BlockAck
597 * @param txVector the TXVECTOR used to transmit the BlockAck
598 * @param linkId the ID of the link on which the BlockAck was transmitted
599 */
600 void CheckBlockAck(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, uint8_t linkId);
601
602 void Transmit(Ptr<WifiMac> mac,
603 uint8_t phyId,
604 WifiConstPsduMap psduMap,
605 WifiTxVector txVector,
606 double txPowerW) override;
607 void DoSetup() override;
608 void DoRun() override;
609
610 private:
611 void StartTraffic() override;
612
613 /// Receiver address-indexed map of list error models
614 using RxErrorModelMap = std::unordered_map<Mac48Address, Ptr<ListErrorModel>, WifiAddressHash>;
615
616 RxErrorModelMap m_errorModels; ///< error rate models to corrupt packets
617 std::list<uint64_t> m_uidList; ///< list of UIDs of packets to corrupt
618 bool m_dataCorrupted{false}; ///< whether second data frame has been already corrupted
619 WifiTrafficPattern m_trafficPattern; ///< the pattern of traffic to generate
620 bool m_baEnabled; ///< whether BA agreement is enabled or disabled
621 bool m_useBarAfterMissedBa; ///< whether to send BAR after missed BlockAck
622 std::size_t m_nMaxInflight; ///< max number of links on which an MPDU can be inflight
623 std::size_t m_nPackets; ///< number of application packets to generate
624 std::size_t m_blockAckCount{0}; ///< transmitted BlockAck counter
625 std::size_t m_blockAckReqCount{0}; ///< transmitted BlockAckReq counter
626 std::map<uint16_t, std::size_t> m_inflightCount; ///< seqNo-indexed max number of simultaneous
627 ///< transmissions of a data frame
628 Ptr<WifiMac> m_sourceMac; ///< MAC of the node sending application packets
629};
630
631/**
632 * Tested MU traffic patterns.
633 */
641
642/**
643 * @ingroup wifi-test
644 * @ingroup tests
645 *
646 * @brief Test data transmission between MLDs using OFDMA MU transmissions
647 *
648 * This test sets up an AP MLD and two non-AP MLDs having a variable number of links.
649 * The RF channels to set each link to are provided as input parameters through the test
650 * case constructor, along with the identifiers (starting at 0) of the links that cannot
651 * switch PHY band (if any). This test aims at veryfing the successful transmission of both
652 * DL MU and UL MU frames. In the DL MU scenarios, the client applications installed on the
653 * AP generate 8 packets addressed to each of the stations (plus 3 packets to trigger the
654 * establishment of BlockAck agreements). In the UL MU scenario, client applications
655 * installed on the stations generate 4 packets each (plus 3 packets to trigger the
656 * establishment of BlockAck agreements).
657 *
658 * The maximum A-MSDU size is set such that two packets can be aggregated in an A-MSDU.
659 * The MPDU with sequence number equal to 3 is corrupted (by using a post reception error
660 * model) once and for a single station, to test its successful re-transmission.
661 *
662 * Also, we enable the concurrent transmission of data frames over two links and check that at
663 * least one MPDU is concurrently transmitted over two links.
664 */
666{
667 public:
668 /**
669 * Constructor
670 *
671 * @param baseParams common configuration parameters
672 * @param muTrafficPattern the pattern of traffic to generate
673 * @param useBarAfterMissedBa whether a BAR or Data frames are sent after missed BlockAck
674 * @param nMaxInflight the max number of links on which an MPDU can be simultaneously inflight
675 * (unused if Block Ack agreements are not established)
676 */
677 MultiLinkMuTxTest(const BaseParams& baseParams,
678 WifiMuTrafficPattern muTrafficPattern,
679 WifiUseBarAfterMissedBa useBarAfterMissedBa,
680 uint8_t nMaxInflight);
681 ~MultiLinkMuTxTest() override = default;
682
683 protected:
684 /**
685 * Check the content of a received BlockAck frame when the max number of links on which
686 * an MPDU can be inflight is one.
687 *
688 * @param psdu the PSDU containing the BlockAck
689 * @param txVector the TXVECTOR used to transmit the BlockAck
690 * @param linkId the ID of the link on which the BlockAck was transmitted
691 */
692 void CheckBlockAck(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector, uint8_t linkId);
693
694 void Transmit(Ptr<WifiMac> mac,
695 uint8_t phyId,
696 WifiConstPsduMap psduMap,
697 WifiTxVector txVector,
698 double txPowerW) override;
699 void DoSetup() override;
700 void DoRun() override;
701
702 private:
703 void StartTraffic() override;
704
705 /// Receiver address-indexed map of list error models
706 using RxErrorModelMap = std::unordered_map<Mac48Address, Ptr<ListErrorModel>, WifiAddressHash>;
707
708 /// A pair of a MAC address (the address of the receiver for DL frames and the address of
709 /// the sender for UL frames) and a sequence number identifying a transmitted QoS data frame
710 using AddrSeqNoPair = std::pair<Mac48Address, uint16_t>;
711
712 RxErrorModelMap m_errorModels; ///< error rate models to corrupt packets
713 std::list<uint64_t> m_uidList; ///< list of UIDs of packets to corrupt
714 std::optional<Mac48Address> m_dataCorruptedSta; ///< MAC address of the station that received
715 ///< MPDU with SeqNo=2 corrupted
716 bool m_waitFirstTf{true}; ///< whether we are waiting for the first Basic Trigger Frame
717 WifiMuTrafficPattern m_muTrafficPattern; ///< the pattern of traffic to generate
718 bool m_useBarAfterMissedBa; ///< whether to send BAR after missed BlockAck
719 std::size_t m_nMaxInflight; ///< max number of links on which an MPDU can be inflight
720 std::vector<PacketSocketAddress> m_sockets; ///< packet socket addresses for STAs
721 std::size_t m_nPackets; ///< number of application packets to generate
722 std::size_t m_blockAckCount{0}; ///< transmitted BlockAck counter
723 std::size_t m_tfCount{0}; ///< transmitted Trigger Frame counter
724 // std::size_t m_blockAckReqCount{0}; ///< transmitted BlockAckReq counter
725 std::map<AddrSeqNoPair, std::size_t> m_inflightCount; ///< max number of simultaneous
726 ///< transmissions of each data frame
727 Ptr<WifiMac> m_sourceMac; ///< MAC of the node sending application packets
728};
729
730/**
731 * @ingroup wifi-test
732 * @ingroup tests
733 *
734 * @brief Test release of sequence numbers upon CTS timeout in multi-link operations
735 *
736 * In this test, an AP MLD and a non-AP MLD setup 3 links. Usage of RTS/CTS protection is
737 * enabled for frames whose length is at least 1000 bytes. The AP MLD receives a first set
738 * of 4 packets from the upper layer and sends an RTS frame, which is corrupted at the
739 * receiver, on a first link. When the RTS frame is transmitted, the AP MLD receives another
740 * set of 4 packets, which are transmitted after a successful RTS/CTS exchange on a second
741 * link. In the meantime, a new RTS/CTS exchange is successfully carried out (on the first
742 * link or on the third link) to transmit the first set of 4 packets. When the transmission
743 * of the first set of 4 packets starts, the AP MLD receives the third set of 4 packets from
744 * the upper layer, which are transmitted after a successful RTS/CTS exchange.
745 *
746 * This test checks that sequence numbers are correctly assigned to all the MPDUs carrying data.
747 */
749{
750 public:
753
754 protected:
755 void DoSetup() override;
756 void DoRun() override;
757 void Transmit(Ptr<WifiMac> mac,
758 uint8_t phyId,
759 WifiConstPsduMap psduMap,
760 WifiTxVector txVector,
761 double txPowerW) override;
762
763 private:
764 void StartTraffic() override;
765
766 PacketSocketAddress m_sockAddr; //!< packet socket address
767 std::size_t m_nQosDataFrames; //!< counter for transmitted QoS data frames
768 Ptr<ListErrorModel> m_errorModel; //!< error rate model to corrupt first RTS frame
769 bool m_rtsCorrupted; //!< whether the first RTS frame has been corrupted
770};
771
772/**
773 * @ingroup wifi-test
774 * @ingroup tests
775 *
776 * @brief Test update of BA starting sequence number after ADDBA Response timeout in
777 * multi-link operations
778 *
779 * In this test, an AP MLD and a non-AP MLD setup 2 links. The AP MLD has a QoS data frame to
780 * transmit to the non-AP MLD, which triggers the establishment of a BA agreement. When the ADDBA
781 * Request frame is received by the non-AP MLD, transmissions of the non-AP MLD are blocked to put
782 * the transmission of the ADDBA Response on hold. The goal is to mimic a delay in getting channel
783 * access due to, e.g., other devices grabbing the medium. When the ADDBA Response timer at the AP
784 * MLD expires, transmissions of the non-AP MLD are unblocked, so that the AP MLD sends the QoS data
785 * frame (protected by RTS, but the test works without RTS as well, and using Normal acknowledgment)
786 * on one link and the non-AP MLD sends the ADDBA Response on the other link. The transmission of
787 * the QoS data frame is then corrupted. We verify that:
788 *
789 * - when the AP MLD receives the ADDBA Response, the BA starting sequence number is set to the
790 * sequence number of the QoS data frame which is inflight
791 * - the QoS data frame is retransmitted and received by the non-AP MLD
792 */
794{
795 public:
797
798 private:
799 void DoSetup() override;
800 void DoRun() override;
801 void Transmit(Ptr<WifiMac> mac,
802 uint8_t phyId,
803 WifiConstPsduMap psduMap,
804 WifiTxVector txVector,
805 double txPowerW) override;
806 void StartTraffic() override;
807
808 PacketSocketAddress m_sockAddr; //!< packet socket address
809 std::size_t m_nQosDataCount; //!< counter for transmitted QoS data frames
810 Ptr<ListErrorModel> m_staErrorModel; //!< error rate model to corrupt frames at the non-AP MLD
811};
812
813/**
814 * @ingroup wifi-test
815 * @ingroup tests
816 *
817 * @brief Test BlockAckReq frame sent by a Block Ack originator after dropping QoS data frames
818 *
819 * In this test, a non-AP STA associates with an AP MLD with 2 links using either legacy association
820 * or ML setup. A Block Ack agreement is established first in the downlink direction; the AP MLD
821 * sends 2 data frames, which are both corrupted. When a timeout occurs at the AP MLD, the 2 data
822 * frames are dropped, thus the AP MLD sends a BlockAckReq to advance the recipient window. It is
823 * checked that the BlockAckReq has the correct link addresses and that the non-AP STA replies with
824 * a BlockAck having correct link addresses. Then, a Block Ack agreement is established in the
825 * uplink direction and the same pattern of actions are repeated (in the inverse direction).
826 */
828{
829 public:
830 /**
831 * Constructor.
832 *
833 * @param assocType the association type
834 */
836
837 protected:
838 void DoSetup() override;
839 void DoRun() override;
840 void Transmit(Ptr<WifiMac> mac,
841 uint8_t phyId,
842 WifiConstPsduMap psduMap,
843 WifiTxVector txVector,
844 double txPowerW) override;
845
846 /// Actions and checks to perform upon the transmission of each frame
847 struct Events
848 {
849 /**
850 * Constructor.
851 *
852 * @param type the frame MAC header type
853 * @param f function to perform actions and checks
854 */
856 std::function<void(Ptr<const WifiPsdu>, const WifiTxVector&, uint8_t)>&& f = {})
857 : hdrType(type),
858 func(f)
859 {
860 }
861
862 WifiMacType hdrType; ///< MAC header type of frame being transmitted
863 std::function<void(Ptr<const WifiPsdu>, const WifiTxVector&, uint8_t)>
864 func; ///< function to perform actions and checks
865 };
866
867 /// Insert elements in the list of expected events (transmitted frames)
868 void InsertEvents();
869
870 private:
871 void StartTraffic() override;
872
873 bool m_setupDone{false}; //!< whether association has been completed
874 std::list<Events> m_events; //!< list of events for a test run
875 std::size_t m_processedEvents{0}; //!< number of processed events
876 Ptr<ListErrorModel> m_staErrorModel; //!< error rate model to corrupt frames at the non-AP STA
877 Ptr<ListErrorModel> m_apErrorModel; //!< error rate model to corrupt frames at the AP MLD
878};
879
880/**
881 * @ingroup wifi-test
882 * @ingroup tests
883 *
884 * @brief wifi 11be MLD Test Suite
885 */
891
892#endif /* WIFI_MLO_TEST_H */
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
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.
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.
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:114
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.
Definition ptr.h:70
Make it easy to create and manage PHY objects for the spectrum model.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
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
a unique identifier for an interface.
Definition type-id.h:50
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
Definition wifi-mac.cc:1111
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:1192
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:1273
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.
WifiMacType
Combination of valid MAC header type/subtype.
std::map< tid_t, std::set< linkId_t > > WifiTidLinkMapping
TID-indexed map of the link set to which the TID is mapped.
Definition wifi-utils.h:77
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
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:47
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.