A Discrete-Event Network Simulator
API
wifi-emlsr-test.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Stefano Avallone <stavallo@unina.it>
18  */
19 
20 #ifndef WIFI_EMLSR_TEST_H
21 #define WIFI_EMLSR_TEST_H
22 
23 #include "ns3/ap-wifi-mac.h"
24 #include "ns3/error-model.h"
25 #include "ns3/header-serialization-test.h"
26 #include "ns3/packet-socket-address.h"
27 #include "ns3/packet-socket-client.h"
28 #include "ns3/sta-wifi-mac.h"
29 #include "ns3/test.h"
30 #include "ns3/wifi-mac-queue-scheduler.h"
31 #include "ns3/wifi-mac.h"
32 #include "ns3/wifi-ppdu.h"
33 #include "ns3/wifi-psdu.h"
34 
35 using namespace ns3;
36 
44 {
45  public:
50  ~EmlOperatingModeNotificationTest() override = default;
51 
52  private:
53  void DoRun() override;
54 };
55 
72 {
73  public:
79  EmlsrOperationsTestBase(const std::string& name);
80  ~EmlsrOperationsTestBase() override = default;
81 
83  enum TrafficDirection : uint8_t
84  {
85  DOWNLINK = 0,
86  UPLINK
87  };
88 
89  protected:
99  virtual void Transmit(Ptr<WifiMac> mac,
100  uint8_t phyId,
101  WifiConstPsduMap psduMap,
102  WifiTxVector txVector,
103  double txPowerW);
104 
113  Ptr<PacketSocketClient> GetApplication(TrafficDirection dir,
114  std::size_t staId,
115  std::size_t count,
116  std::size_t pktSize) const;
117 
131  void CheckBlockedLink(Ptr<WifiMac> mac,
132  Mac48Address dest,
133  uint8_t linkId,
134  WifiQueueBlockedReason reason,
135  bool blocked,
136  std::string description,
137  bool testUnblockedForOtherReasons = true);
138 
139  void DoSetup() override;
140 
142  struct FrameInfo
143  {
147  uint8_t linkId;
148  uint8_t phyId;
149  };
150 
151  uint8_t m_mainPhyId{0};
152  std::set<uint8_t> m_linksToEnableEmlsrOn;
154  std::size_t m_nEmlsrStations{1};
155  std::size_t m_nNonEmlsrStations{0};
157  Time m_transitionTimeout{MicroSeconds(128)};
158  std::vector<Time> m_paddingDelay{
159  {MicroSeconds(32)}};
160  std::vector<Time> m_transitionDelay{
161  {MicroSeconds(16)}};
162  bool m_establishBaDl{false};
164  bool m_establishBaUl{false};
166  std::vector<FrameInfo> m_txPsdus;
168  std::vector<Ptr<StaWifiMac>> m_staMacs;
169  std::vector<PacketSocketAddress> m_dlSockets;
170  std::vector<PacketSocketAddress> m_ulSockets;
171  uint16_t m_lastAid{0};
172  Time m_duration{0};
173 
174  private:
182  void SetSsid(uint16_t aid, Mac48Address /* addr */);
183 
187  virtual void StartTraffic()
188  {
189  }
190 };
191 
215 {
216  public:
223  EmlOmnExchangeTest(const std::set<uint8_t>& linksToEnableEmlsrOn, Time transitionTimeout);
224  ~EmlOmnExchangeTest() override = default;
225 
226  protected:
227  void DoSetup() override;
228  void DoRun() override;
229  void Transmit(Ptr<WifiMac> mac,
230  uint8_t phyId,
231  WifiConstPsduMap psduMap,
232  WifiTxVector txVector,
233  double txPowerW) override;
234 
240  void TxOk(Ptr<const WifiMpdu> mpdu);
247  void TxDropped(WifiMacDropReason reason, Ptr<const WifiMpdu> mpdu);
248 
257  void CheckEmlCapabilitiesInAssocReq(Ptr<const WifiMpdu> mpdu,
258  const WifiTxVector& txVector,
259  uint8_t linkId);
268  void CheckEmlCapabilitiesInAssocResp(Ptr<const WifiMpdu> mpdu,
269  const WifiTxVector& txVector,
270  uint8_t linkId);
278  void CheckEmlNotification(Ptr<const WifiPsdu> psdu,
279  const WifiTxVector& txVector,
280  uint8_t linkId);
284  void CheckEmlsrLinks();
285 
286  private:
295  std::list<uint64_t> m_uidList;
296 };
297 
350 {
351  public:
355  struct Params
356  {
357  std::size_t nEmlsrStations;
358  std::size_t nNonEmlsrStations;
359  std::set<uint8_t>
361  std::vector<Time> paddingDelay;
363  std::vector<Time>
367  };
368 
374  EmlsrDlTxopTest(const Params& params);
375  ~EmlsrDlTxopTest() override = default;
376 
377  protected:
378  void DoSetup() override;
379  void DoRun() override;
380  void Transmit(Ptr<WifiMac> mac,
381  uint8_t phyId,
382  WifiConstPsduMap psduMap,
383  WifiTxVector txVector,
384  double txPowerW) override;
385 
389  void CheckResults();
390 
397  void CheckPmModeAfterAssociation(const Mac48Address& address);
398 
407  void CheckEmlNotificationFrame(Ptr<const WifiMpdu> mpdu,
408  const WifiTxVector& txVector,
409  uint8_t linkId);
410 
419  void CheckInitialControlFrame(Ptr<const WifiMpdu> mpdu,
420  const WifiTxVector& txVector,
421  uint8_t linkId);
422 
431  void CheckQosFrames(const WifiConstPsduMap& psduMap,
432  const WifiTxVector& txVector,
433  uint8_t linkId);
434 
443  void CheckBlockAck(const WifiConstPsduMap& psduMap,
444  const WifiTxVector& txVector,
445  uint8_t phyId);
446 
447  private:
448  void StartTraffic() override;
449 
453  void EnableEmlsrMode();
454 
455  std::set<uint8_t> m_emlsrLinks;
459  std::size_t m_countQoSframes;
460  std::size_t m_countBlockAck;
462 };
463 
510 {
511  public:
515  struct Params
516  {
517  std::set<uint8_t>
519  uint16_t channelWidth;
522  uint8_t msdMaxNTxops;
528  };
529 
535  EmlsrUlTxopTest(const Params& params);
536  ~EmlsrUlTxopTest() override = default;
537 
538  protected:
539  void DoSetup() override;
540  void DoRun() override;
541  void Transmit(Ptr<WifiMac> mac,
542  uint8_t phyId,
543  WifiConstPsduMap psduMap,
544  WifiTxVector txVector,
545  double txPowerW) override;
546 
550  void CheckResults();
551 
560  void CheckRtsFrames(Ptr<const WifiMpdu> mpdu, const WifiTxVector& txVector, uint8_t linkId);
561 
570  void CheckCtsFrames(Ptr<const WifiMpdu> mpdu, const WifiTxVector& txVector, uint8_t linkId);
571 
580  void CheckQosFrames(const WifiConstPsduMap& psduMap,
581  const WifiTxVector& txVector,
582  uint8_t linkId);
583 
592  void CheckBlockAck(const WifiConstPsduMap& psduMap,
593  const WifiTxVector& txVector,
594  uint8_t linkId);
595 
596  private:
597  void StartTraffic() override;
598 
605  void BackoffGenerated(uint32_t backoff, uint8_t linkId);
606 
607  std::set<uint8_t> m_emlsrLinks;
608  uint16_t m_channelWidth;
611  uint8_t m_msdMaxNTxops;
614  std::optional<uint8_t> m_nonEmlsrLink;
622  std::optional<Time> m_backoffEndTime;
624  std::size_t m_countQoSframes;
625  std::size_t m_countBlockAck;
626  std::size_t m_countRtsframes;
630  std::optional<bool> m_corruptCts;
631 };
632 
650 {
651  public:
655  struct Params
656  {
657  bool
662  uint16_t auxPhyMaxChWidth;
663  };
664 
671 
672  ~EmlsrLinkSwitchTest() override = default;
673 
674  protected:
675  void DoSetup() override;
676  void DoRun() override;
677  void Transmit(Ptr<WifiMac> mac,
678  uint8_t phyId,
679  WifiConstPsduMap psduMap,
680  WifiTxVector txVector,
681  double txPowerW) override;
682 
686  void CheckResults();
687 
696  void CheckInitialControlFrame(const WifiConstPsduMap& psduMap,
697  const WifiTxVector& txVector,
698  uint8_t linkId);
699 
708  void CheckQosFrames(const WifiConstPsduMap& psduMap,
709  const WifiTxVector& txVector,
710  uint8_t linkId);
711 
712  private:
718  std::size_t m_countQoSframes;
719  std::size_t m_txPsdusPos;
720 };
721 
729 {
730  public:
732 };
733 
734 #endif /* WIFI_EMLSR_TEST_H */
Test the exchange of EML Operating Mode Notification frames.
std::list< uint64_t > m_uidList
list of UIDs of packets to corrupt
std::size_t m_checkEmlsrLinksCount
counter for the number of times CheckEmlsrLinks is called (should be two: when the transition timeout...
Ptr< ListErrorModel > m_errorModel
error rate model to corrupt packets at AP MLD
std::size_t m_emlNotificationDroppedCount
counter for the number of times the EML Notification frame sent by the non-AP MLD has been dropped du...
~EmlOmnExchangeTest() override=default
Test EML Operating Mode Notification frame serialization and deserialization.
~EmlOperatingModeNotificationTest() override=default
Test the transmission of DL frames to EMLSR clients.
const Time m_fe2to3delay
time interval between 2nd and 3rd frame exchange sequences after the enablement of EMLSR mode
Ptr< ListErrorModel > m_errorModel
error rate model to corrupt BlockAck at AP MLD
std::size_t m_countQoSframes
counter for QoS frames (transition delay test)
~EmlsrDlTxopTest() override=default
Time m_emlsrEnabledTime
when EMLSR mode has been enabled on all EMLSR clients
std::set< uint8_t > m_emlsrLinks
IDs of the links on which EMLSR mode has to be enabled.
std::size_t m_countBlockAck
counter for BlockAck frames (transition delay test)
Base class for EMLSR Operations tests.
std::vector< PacketSocketAddress > m_dlSockets
packet socket address for DL traffic
std::set< uint8_t > m_linksToEnableEmlsrOn
IDs of the links on which EMLSR mode has to be enabled.
Ptr< ApWifiMac > m_apMac
AP wifi MAC.
~EmlsrOperationsTestBase() override=default
TrafficDirection
Enumeration for traffic directions.
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
std::vector< PacketSocketAddress > m_ulSockets
packet socket address for UL traffic
std::vector< Ptr< StaWifiMac > > m_staMacs
MACs of the non-AP MLDs.
virtual void StartTraffic()
Start the generation of traffic (needs to be overridden)
Test the transmission of UL frames from EMLSR clients.
std::size_t m_countQoSframes
counter for QoS frames
Time m_emlsrEnabledTime
when EMLSR mode has been enabled on all EMLSR clients
const Time m_unblockMainPhyLinkDelay
delay between the time the first two UL packets are generated and the time transmissions are unblocke...
Ptr< ListErrorModel > m_errorModel
error rate model to corrupt packets
uint16_t m_channelWidth
width (MHz) of the channels used by MLDs
std::optional< uint8_t > m_nonEmlsrLink
ID of the non-EMLSR link (if any)
Time m_lastMsdExpiryTime
expiry time of the last MediumSyncDelay timer
std::size_t m_countRtsframes
counter for RTS frames
Time m_firstUlPktsGenTime
generation time of the first two UL packets
std::optional< bool > m_corruptCts
whether the transmitted CTS must be corrupted
~EmlsrUlTxopTest() override=default
std::optional< Time > m_backoffEndTime
expected backoff end time on main PHY link
std::set< uint8_t > m_emlsrLinks
IDs of the links on which EMLSR mode has to be enabled.
Time m_mediumSyncDuration
duration of the MediumSyncDelay timer
bool m_genBackoffIfTxopWithoutTx
whether the backoff should be invoked when the AC gains the right to start a TXOP but it does not tra...
bool m_checkBackoffStarted
whether we are checking the generated backoff values
std::size_t m_countBlockAck
counter for BlockAck frames
uint8_t m_msdMaxNTxops
Max number of TXOPs that an EMLSR client is allowed to attempt to initiate while the MediumSyncDelay ...
uint16_t m_auxPhyChannelWidth
max width (MHz) supported by aux PHYs
wifi EMLSR Test Suite
Subclass of TestCase class adding the ability to test the serialization and deserialization of a Head...
an EUI-48 address
Definition: mac48-address.h:46
encapsulates test code
Definition: test.h:1060
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
WifiMacDropReason
The reason why an MPDU was dropped.
Definition: wifi-mac.h:77
WifiQueueBlockedReason
Enumeration of the reasons to block container queues.
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
mac
Definition: third.py:92
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
Parameters for the EMLSR DL TXOP test.
std::vector< Time > paddingDelay
vector (whose size equals nEmlsrStations) of the padding delay values advertised by non-AP MLDs
std::size_t nNonEmlsrStations
number of non-AP MLDs that do not support EMLSR
std::set< uint8_t > linksToEnableEmlsrOn
IDs of links on which EMLSR mode should be enabled.
Time transitionTimeout
the Transition Timeout advertised by the AP MLD
std::vector< Time > transitionDelay
vector (whose size equals nEmlsrStations) of transition the delay values advertised by non-AP MLDs
std::size_t nEmlsrStations
number of non-AP MLDs that support EMLSR
Information about transmitted frames.
WifiConstPsduMap psduMap
transmitted PSDU map
uint8_t phyId
ID of the transmitting PHY.
Parameters for the EMLSR UL TXOP test.
uint16_t auxPhyChannelWidth
max width (MHz) supported by aux PHYs
bool genBackoffIfTxopWithoutTx
whether the backoff should be invoked when the AC gains the right to start a TXOP but it does not tra...
uint8_t msdMaxNTxops
Max number of TXOPs that an EMLSR client is allowed to attempt to initiate while the MediumSyncDelay ...
uint16_t channelWidth
width (MHz) of the channels used by MLDs
Time mediumSyncDuration
duration of the MediumSyncDelay timer
std::set< uint8_t > linksToEnableEmlsrOn
IDs of links on which EMLSR mode should be enabled.
std::string dir
uint32_t pktSize
packet size used for the simulation (in bytes)