11#include "ns3/ap-wifi-mac.h"
12#include "ns3/boolean.h"
13#include "ns3/emlsr-manager.h"
15#include "ns3/packet-socket-client.h"
16#include "ns3/qos-txop.h"
17#include "ns3/simulator.h"
18#include "ns3/sta-wifi-mac.h"
19#include "ns3/string.h"
21#include "ns3/wifi-mac-queue-scheduler.h"
22#include "ns3/wifi-net-device.h"
23#include "ns3/wifi-phy.h"
24#include "ns3/wifi-remote-station-manager.h"
25#include "ns3/wifi-utils.h"
137 void DoRun()
override;
142 double txPowerW)
override;
162 std::optional<uint8_t> phy = std::nullopt,
222 "{36, 20, BAND_5GHZ, 0}"s,
223 "{1, 20, BAND_6GHZ, 0}"s};
236 std::vector<Ptr<WifiMac>> macs{
m_apMac};
238 for (
const auto& mac : macs)
242 mac->GetWifiRemoteStationManager(linkId)->SetAttribute(
"DataMode",
244 mac->GetWifiRemoteStationManager(linkId)->SetAttribute(
"ControlMode",
247 for (uint8_t phyId = 0; phyId < mac->GetDevice()->GetNPhys(); ++phyId)
249 mac->GetDevice()->GetPhy(phyId)->SetAttribute(
"ChannelSwitchDelay",
278 const std::vector<uint32_t> zeroCws(staMac->GetNLinks(), 0);
281 staMac->GetQosTxop(aci)->SetMinCws(zeroCws);
282 staMac->GetQosTxop(aci)->SetMaxCws(zeroCws);
285 for (std::size_t i : {1, 2})
293 const auto apMld =
m_apMac->GetAddress();
303 m_staMacs.at(2)->GetDevice()->GetNode()->AddApplication(
309 m_staMacs.at(0)->GetDevice()->GetNode()->AddApplication(
317 const auto client1Mld =
m_staMacs.at(0)->GetAddress();
318 const auto client2Mld =
m_staMacs.at(1)->GetAddress();
326 "Client 2 holds a TXOP on link 1");
332 "Client 2 holds a TXOP on link 1");
343 "Client 1's TXOP has ended");
356 "The transition delay of client 1 has elapsed");
363 "Client 2 still holds a TXOP on link 1");
389 m_staMacs.at(0)->GetDevice()->GetNode()->AddApplication(
392 m_staMacs.at(1)->GetDevice()->GetNode()->AddApplication(
416 m_staMacs.at(2)->GetDevice()->GetNode()->AddApplication(
434 m_staMacs.at(1)->GetDevice()->GetNode()->AddApplication(
453 "Client 1 closes its TXOP");
472 "Client 2 starts transmitting the RTS while the "
473 "TXOP end event for client 1's TXOP is pending");
510 const auto linkId = mac->GetLinkForPhy(phyId);
512 const auto& hdr = psduMap.cbegin()->second->GetHeader(0);
518 return event.linkId == *linkId;
522 "Unexpected frame of type "
523 << hdr.GetTypeString() <<
" transmitted on link " << +linkId.value()
529 "Unexpected MAC header type for frame transmitted on link "
534 "Unexpected transmitter for frame of type "
535 << hdr.GetTypeString() <<
" transmitted on link " << +linkId.value()
537 if (it->phyId.has_value())
541 "Unexpected transmitting PHY for frame of type "
542 << hdr.GetTypeString() <<
" transmitted on link "
543 << +linkId.value() <<
" at time "
550 it->func(psduMap, txVector);
std::size_t m_nNonEmlsrStations
number of stations to create that do not activate EMLSR
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< 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.
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
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.
std::vector< Time > m_transitionDelay
Transition Delay advertised by the non-AP MLD.
std::array< std::string, 3 > m_channelsStr
array of strings defining the channels for the MLD links
std::vector< Ptr< StaWifiMac > > m_staMacs
MACs of the non-AP MLDs.
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.
Test that a new EMLSR TXOP finalizes the tracking of the previous TXOP.
static constexpr uint8_t AUX_PHY_ID
ID of the aux PHY of the EMLSR clients operating on AUX_LINK.
static constexpr AcIndex TXOP_AC
AC of TXOP_TID, whose TXOP limit is set.
void InsertEvents()
Insert elements in the list of expected events (transmitted frames).
void CheckQueuesAfterTakeover()
Check the AP MLD's blocked queues after the takeover of the ended TXOP: client 2's other link must be...
std::list< Events > m_events
list of events for the test run
static constexpr tid_t TXOP_TID
TID of the packets transmitted in the TXOPs under test and of the background station's second packet.
static constexpr tid_t BG_STA_TID
TID of the background station's first packet.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
static constexpr linkId_t MAIN_LINK
EMLSR link on which the main PHYs operate (5 GHz).
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.
static constexpr uint8_t MAIN_PHY_ID
ID of the main PHY of the EMLSR clients (initially operating on MAIN_LINK).
static constexpr linkId_t AUX_LINK
EMLSR link on which the aux PHYs operate (6 GHz).
const Time m_txopLimit
TXOP limit for TXOP_AC: sized so that client 1's TXOP comprises two frame exchanges and its closing A...
void StartTraffic() override
Start the generation of traffic (needs to be overridden).
void DoRun() override
Implementation to actually run this TestCase.
bool m_trafficStarted
whether the traffic of the test run has started
wifi EMLSR TXOP end tracking Test Suite
WifiEmlsrTxopEndTrackingTestSuite()
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Simulation virtual time values and global simulation resolution.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
@ WAITING_EMLSR_TRANSITION_DELAY
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t tid_t
IEEE 802.11-2020 9.2.4.5.2 TID subfield.
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.
uint8_t linkId_t
IEEE 802.11be D7.0 Figure 9-207e—Link ID Info field format.
const std::map< AcIndex, WifiAc > wifiAcList
Map containing the four ACs in increasing order of priority (according to Table 10-1 "UP-to-AC Mappin...
Actions and checks to perform upon the transmission of each frame.
linkId_t linkId
ID of the link on which the frame is expected.
Events(WifiMacType type, linkId_t id, Ptr< WifiMac > tx, std::optional< uint8_t > phy=std::nullopt, std::function< void(const WifiConstPsduMap &, const WifiTxVector &)> &&f={})
Constructor.
std::function< void(const WifiConstPsduMap &, const WifiTxVector &)> func
actions and checks to perform
WifiMacType hdrType
MAC header type of the frame.
Ptr< WifiMac > txMac
MAC of the device expected to transmit the frame.
std::optional< uint8_t > phyId
ID of the PHY expected to transmit the frame, if any.
static WifiEmlsrTxopEndTrackingTestSuite g_wifiEmlsrTxopEndTrackingTestSuite
the test suite