A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-emlsr-test-base.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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_EMLSR_TEST_H
10#define WIFI_EMLSR_TEST_H
11
12#include "ns3/adhoc-wifi-mac.h"
13#include "ns3/ap-wifi-mac.h"
14#include "ns3/error-model.h"
15#include "ns3/header-serialization-test.h"
16#include "ns3/packet-socket-address.h"
17#include "ns3/packet-socket-client.h"
18#include "ns3/sta-wifi-mac.h"
19#include "ns3/test.h"
20#include "ns3/wifi-mac-queue-scheduler.h"
21#include "ns3/wifi-mac.h"
22#include "ns3/wifi-ppdu.h"
23#include "ns3/wifi-psdu.h"
24
25#include <array>
26#include <map>
27#include <memory>
28#include <optional>
29#include <set>
30#include <vector>
31
32using namespace ns3;
33using namespace std::string_literals;
34
35// forward declaration
36namespace ns3
37{
39}
40
41/**
42 * @ingroup wifi-test
43 * @ingroup tests
44 *
45 * @brief Base class for EMLSR Operations tests
46 *
47 * This base class setups and configures one AP MLD, a variable number of non-AP MLDs with
48 * EMLSR activated and a variable number of non-AP MLD with EMLSR deactivated. Every MLD has
49 * three links, each operating on a distinct PHY band (2.4 GHz, 5 GHz and 6 GHz). Therefore,
50 * it is expected that three links are setup by the non-AP MLD(s). The values for the Padding
51 * Delay, the Transition Delay and the Transition Timeout are provided as argument to the
52 * constructor of this class, along with the IDs of the links on which EMLSR mode must be
53 * enabled for the non-AP MLDs (this information is used to set the EmlsrLinkSet attribute
54 * of the DefaultEmlsrManager installed on the non-AP MLDs).
55 */
57{
58 public:
59 /**
60 * Constructor
61 *
62 * @param name The name of the new TestCase created
63 */
64 EmlsrOperationsTestBase(const std::string& name);
65 ~EmlsrOperationsTestBase() override = default;
66
67 /// Enumeration for traffic directions
68 enum TrafficDirection : uint8_t
69 {
71 UPLINK
72 };
73
74 protected:
75 /**
76 * Callback invoked when a FEM passes PSDUs to the PHY.
77 *
78 * @param mac the MAC transmitting the PSDUs
79 * @param phyId the ID of the PHY transmitting the PSDUs
80 * @param psduMap the PSDU map
81 * @param txVector the TX vector
82 * @param txPowerW the tx power in Watts
83 */
84 virtual void Transmit(Ptr<WifiMac> mac,
85 uint8_t phyId,
86 WifiConstPsduMap psduMap,
87 WifiTxVector txVector,
88 double txPowerW);
89
90 /**
91 * @param dir the traffic direction (downlink/uplink)
92 * @param staId the index (starting at 0) of the non-AP MLD generating/receiving packets
93 * @param count the number of packets to generate
94 * @param pktSize the size of the packets to generate
95 * @param priority user priority for generated packets
96 * @return an application generating the given number packets of the given size from/to the
97 * AP MLD to/from the given non-AP MLD
98 */
100 std::size_t staId,
101 std::size_t count,
102 std::size_t pktSize,
103 uint8_t priority = 0) const;
104
105 /**
106 * Check whether QoS data unicast transmissions addressed to the given destination on the
107 * given link are blocked or unblocked for the given reason on the given device.
108 *
109 * @param mac the MAC of the given device
110 * @param dest the MAC address of the given destination
111 * @param linkId the ID of the given link
112 * @param reason the reason for blocking transmissions to test
113 * @param blocked whether transmissions are blocked for the given reason
114 * @param description text indicating when this check is performed
115 * @param testUnblockedForOtherReasons whether to test if transmissions are unblocked for
116 * all the reasons other than the one provided
117 */
119 Mac48Address dest,
120 uint8_t linkId,
122 bool blocked,
123 std::string description,
124 bool testUnblockedForOtherReasons = true);
125
126 /**
127 * Check whether the MediumSyncDelay timer is running on the given link of the given device.
128 *
129 * @param staMac the MAC of the given device
130 * @param linkId the ID of the given link
131 * @param isRunning whether the MediumSyncDelay timer is running
132 * @param msg message to print in case the check failed
133 */
135 uint8_t linkId,
136 bool isRunning,
137 const std::string& msg);
138
139 /**
140 * Check whether aux PHYs of the given device are in sleep mode/awake.
141 *
142 * @param staMac the MAC of the given device
143 * @param sleep whether aux PHYs should be in sleep mode
144 */
145 void CheckAuxPhysSleepMode(Ptr<StaWifiMac> staMac, bool sleep);
146
147 /**
148 * Callback connected to the EMLSR Manager MainPhySwitch trace source.
149 *
150 * @param index the index of the EMLSR client whose main PHY switch event is logged
151 * @param info the information associated with the main PHY switch event
152 */
153 virtual void MainPhySwitchInfoCallback(std::size_t index, const EmlsrMainPhySwitchTrace& info);
154
155 /**
156 * Check information provided by the EMLSR Manager MainPhySwitch trace.
157 *
158 * @param index the ID of the EMLSR client this check refers to
159 * @param reason the reason for main PHY to switch
160 * @param fromLinkId the ID of the link the main PHY is moving from (if any)
161 * @param toLinkId the ID of the link the main PHY is moving to
162 * @param checkFromLinkId whether to check the given fromLinkId value
163 * @param checkToLinkId whether to check the given toLinkId value
164 */
165 void CheckMainPhyTraceInfo(std::size_t index,
166 std::string_view reason,
167 const std::optional<uint8_t>& fromLinkId,
168 uint8_t toLinkId,
169 bool checkFromLinkId = true,
170 bool checkToLinkId = true);
171
172 void DoSetup() override;
173
174 /// Information about transmitted frames
176 {
177 Time startTx; ///< TX start time
178 WifiConstPsduMap psduMap; ///< transmitted PSDU map
179 WifiTxVector txVector; ///< TXVECTOR
180 uint8_t linkId; ///< link ID
181 uint8_t phyId; ///< ID of the transmitting PHY
182 };
183
184 /// array of strings defining the channels for the MLD links
185 std::array<std::string, 3> m_channelsStr{"{2, 0, BAND_2_4GHZ, 0}"s,
186 "{36, 0, BAND_5GHZ, 0}"s,
187 "{1, 0, BAND_6GHZ, 0}"s};
188
189 /// array of frequency ranges for MLD links
190 const std::array<FrequencyRange, 3> m_freqRanges{WIFI_SPECTRUM_2_4_GHZ,
193
194 uint32_t m_rngSeed{1}; //!< RNG seed value
195 uint64_t m_rngRun{1}; //!< RNG run value
196 int64_t m_streamNo{5}; //!< RNG stream number
197 uint8_t m_mainPhyId{0}; //!< ID of the main PHY
198 std::set<uint8_t> m_linksToEnableEmlsrOn; /**< IDs of the links on which EMLSR mode has to
199 be enabled */
200 std::size_t m_nPhysPerEmlsrDevice{3}; //!< number of PHYs per EMLSR client
201 std::size_t m_nEmlsrStations{1}; ///< number of stations to create that activate EMLSR
202 std::size_t m_nNonEmlsrStations{0}; /**< number of stations to create that do not
203 activate EMLSR */
204 Time m_transitionTimeout{MicroSeconds(128)}; ///< Transition Timeout advertised by the AP MLD
205 std::vector<Time> m_paddingDelay{
206 {MicroSeconds(32)}}; ///< Padding Delay advertised by the non-AP MLD
207 std::vector<Time> m_transitionDelay{
208 {MicroSeconds(16)}}; ///< Transition Delay advertised by the non-AP MLD
209 std::vector<uint8_t> m_establishBaDl{}; /**< the TIDs for which BA needs to be established
210 with the AP as originator */
211 std::vector<uint8_t> m_establishBaUl{}; /**< the TIDs for which BA needs to be established
212 with the AP as recipient */
213 bool m_putAuxPhyToSleep{false}; //!< whether aux PHYs are put to sleep during DL/UL TXOPs
214 std::vector<FrameInfo> m_txPsdus; ///< transmitted PSDUs
215 Ptr<ApWifiMac> m_apMac; ///< AP wifi MAC
216 std::vector<Ptr<StaWifiMac>> m_staMacs; ///< MACs of the non-AP MLDs
217 std::vector<PacketSocketAddress> m_dlSockets; ///< packet socket address for DL traffic
218 std::vector<PacketSocketAddress> m_ulSockets; ///< packet socket address for UL traffic
219 uint16_t m_startAid{1}; ///< first AID to allocate to stations
220 uint16_t m_lastAid{0}; ///< AID of last associated station
221 Time m_duration{0}; ///< simulation duration
222 std::map<std::size_t, std::shared_ptr<EmlsrMainPhySwitchTrace>>
223 m_traceInfo; ///< EMLSR client ID-indexed map of trace info from last main PHY switch
224
225 private:
226 /**
227 * Callback connected to the ApWifiMac's AssociatedSta trace source.
228 * Start generating traffic (if needed) when all stations are associated.
229 *
230 * @param aid the AID assigned to the previous associated STA
231 */
232 void StaAssociated(uint16_t aid, Mac48Address /* addr */);
233
234 /**
235 * Callback connected to the QosTxop's BaEstablished trace source of the AP's BE AC.
236 *
237 * @param recipient the recipient of the established Block Ack agreement
238 * @param tid the TID
239 */
240 void BaEstablishedDl(Mac48Address recipient,
241 uint8_t tid,
242 std::optional<Mac48Address> /* gcrGroup */);
243
244 /**
245 * Callback connected to the QosTxop's BaEstablished trace source of a STA's BE AC.
246 *
247 * @param index the index of the STA which the callback is connected to
248 * @param recipient the recipient of the established Block Ack agreement
249 * @param tid the TID
250 */
251 void BaEstablishedUl(std::size_t index,
252 Mac48Address recipient,
253 uint8_t tid,
254 std::optional<Mac48Address> /* gcrGroup */);
255
256 /**
257 * Set the SSID on the next station that needs to start the association procedure, or start
258 * traffic if no other station left.
259 *
260 * @param count the number of STAs that completed the association procedure
261 */
262 void SetSsid(std::size_t count);
263
264 /**
265 * Start the generation of traffic (needs to be overridden)
266 */
267 virtual void StartTraffic()
268 {
269 }
270};
271
272#endif /* WIFI_EMLSR_TEST_H */
Base class for EMLSR Operations tests.
void BaEstablishedDl(Mac48Address recipient, uint8_t tid, std::optional< Mac48Address >)
Callback connected to the QosTxop's BaEstablished trace source of the AP's BE AC.
virtual void MainPhySwitchInfoCallback(std::size_t index, const EmlsrMainPhySwitchTrace &info)
Callback connected to the EMLSR Manager MainPhySwitch trace source.
std::size_t m_nNonEmlsrStations
number of stations to create that do not activate EMLSR
std::vector< uint8_t > m_establishBaDl
the TIDs for which BA needs to be established with the AP as originator
void CheckBlockedLink(Ptr< WifiMac > mac, Mac48Address dest, uint8_t linkId, WifiQueueBlockedReason reason, bool blocked, std::string description, bool testUnblockedForOtherReasons=true)
Check whether QoS data unicast transmissions addressed to the given destination on the given link are...
std::size_t m_nEmlsrStations
number of stations to create that activate EMLSR
std::vector< PacketSocketAddress > m_dlSockets
packet socket address for DL traffic
std::vector< Time > m_paddingDelay
Padding Delay advertised by the non-AP MLD.
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
bool m_putAuxPhyToSleep
whether aux PHYs are put to sleep during DL/UL TXOPs
void BaEstablishedUl(std::size_t index, Mac48Address recipient, uint8_t tid, std::optional< Mac48Address >)
Callback connected to the QosTxop's BaEstablished trace source of a STA's BE AC.
TrafficDirection
Enumeration for traffic directions.
void CheckMsdTimerRunning(Ptr< StaWifiMac > staMac, uint8_t linkId, bool isRunning, const std::string &msg)
Check whether the MediumSyncDelay timer is running on the given link of the given device.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
uint8_t m_mainPhyId
ID of the main PHY.
Time m_duration
simulation duration
Ptr< PacketSocketClient > GetApplication(TrafficDirection dir, std::size_t staId, std::size_t count, std::size_t pktSize, uint8_t priority=0) const
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
uint32_t m_rngSeed
RNG seed value.
virtual void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when a FEM passes PSDUs to the PHY.
uint16_t m_lastAid
AID of last associated station.
std::vector< Time > m_transitionDelay
Transition Delay advertised by the non-AP MLD.
void CheckMainPhyTraceInfo(std::size_t index, std::string_view reason, const std::optional< uint8_t > &fromLinkId, uint8_t toLinkId, bool checkFromLinkId=true, bool checkToLinkId=true)
Check information provided by the EMLSR Manager MainPhySwitch trace.
uint16_t m_startAid
first AID to allocate to stations
std::array< std::string, 3 > m_channelsStr
array of strings defining the channels for the MLD links
std::map< std::size_t, std::shared_ptr< EmlsrMainPhySwitchTrace > > m_traceInfo
EMLSR client ID-indexed map of trace info from last main PHY switch.
Time m_transitionTimeout
Transition Timeout advertised by the AP MLD.
const std::array< FrequencyRange, 3 > m_freqRanges
array of frequency ranges for MLD links
void SetSsid(std::size_t count)
Set the SSID on the next station that needs to start the association procedure, or start traffic if n...
std::vector< PacketSocketAddress > m_ulSockets
packet socket address for UL traffic
void StaAssociated(uint16_t aid, Mac48Address)
Callback connected to the ApWifiMac's AssociatedSta trace source.
void CheckAuxPhysSleepMode(Ptr< StaWifiMac > staMac, bool sleep)
Check whether aux PHYs of the given device are in sleep mode/awake.
std::vector< Ptr< StaWifiMac > > m_staMacs
MACs of the non-AP MLDs.
std::size_t m_nPhysPerEmlsrDevice
number of PHYs per EMLSR client
virtual void StartTraffic()
Start the generation of traffic (needs to be overridden)
int64_t m_streamNo
RNG stream number.
uint64_t m_rngRun
RNG run value.
std::vector< uint8_t > m_establishBaUl
the TIDs for which BA needs to be established with the AP as recipient
EmlsrOperationsTestBase(const std::string &name)
Constructor.
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
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:1369
WifiQueueBlockedReason
Enumeration of the reasons to block container queues.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ
Identifier for the frequency range covering the wifi spectrum in the 6 GHz band.
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
Information about transmitted frames.
WifiConstPsduMap psduMap
transmitted PSDU map
uint8_t phyId
ID of the transmitting PHY.
Base struct for EMLSR Main PHY switch traces.
std::string dir
uint32_t pktSize
packet size used for the simulation (in bytes)