11#include "ns3/advanced-emlsr-manager.h"
12#include "ns3/boolean.h"
13#include "ns3/config.h"
14#include "ns3/ctrl-headers.h"
16#include "ns3/mgt-action-headers.h"
17#include "ns3/qos-txop.h"
18#include "ns3/simulator.h"
19#include "ns3/string.h"
20#include "ns3/wifi-net-device.h"
21#include "ns3/wifi-phy.h"
33 "Check serialization and deserialization of the EML Operating Mode Notification frame")
55 "Unexpected link bitmap");
72 "Unexpected EMLSR Padding Delay");
76 "Unexpected EMLSR Transition Delay");
80 Time transitionTimeout)
82 m_checkEmlsrLinksCount(0),
83 m_emlNotificationDroppedCount(0)
98 for (std::size_t linkId = 0; linkId <
m_apMac->GetNLinks(); linkId++)
103 m_staMacs[0]->TraceConnectWithoutContext(
"AckedMpdu",
105 m_staMacs[0]->TraceConnectWithoutContext(
"DroppedMpdu",
119 auto psdu = psduMap.begin()->second;
121 switch (psdu->GetHeader(0).GetType())
135 action.protectedEhtAction ==
141 m_staMacs[0]->GetLinkIdByAddress(psdu->GetAddr2()) == linkId)
144 m_uidList.push_front(psdu->GetPacket()->GetUid());
160 mpdu->GetPacket()->PeekHeader(frame);
167 "Multi-Link Element in AssocReq must have EML Capabilities");
170 "EML Support subfield of EML Capabilities in AssocReq must be set to 1");
173 "Unexpected Padding Delay in EML Capabilities included in AssocReq");
176 "Unexpected Transition Delay in EML Capabilities included in AssocReq");
184 bool sentToEmlsrClient =
185 (
m_staMacs[0]->GetLinkIdByAddress(mpdu->GetHeader().GetAddr1()) == linkId);
187 if (!sentToEmlsrClient)
194 mpdu->GetPacket()->PeekHeader(frame);
201 "Multi-Link Element in AssocResp must have EML Capabilities");
204 "EML Support subfield of EML Capabilities in AssocResp must be set to 1");
206 mle->GetTransitionTimeout(),
208 "Unexpected Transition Timeout in EML Capabilities included in AssocResp");
217 auto mpdu = *psdu->begin();
218 auto pkt = mpdu->GetPacket()->Copy();
220 pkt->RemoveHeader(frame);
223 bool sentbyNonApMld =
m_staMacs[0]->GetLinkIdByAddress(mpdu->GetHeader().GetAddr2()) == linkId;
227 "EMLSR Mode subfield should be set to 1 (frame sent by non-AP MLD: "
228 << std::boolalpha << sentbyNonApMld <<
")");
232 "EMLMR Mode subfield should be set to 0 (frame sent by non-AP MLD: "
233 << std::boolalpha << sentbyNonApMld <<
")");
237 "Link Bitmap subfield should be present (frame sent by non-AP MLD: "
238 << std::boolalpha << sentbyNonApMld <<
")");
240 auto setupLinks =
m_staMacs[0]->GetSetupLinkIds();
241 std::list<uint8_t> expectedEmlsrLinks;
242 std::set_intersection(setupLinks.begin(),
246 std::back_inserter(expectedEmlsrLinks));
250 "Unexpected Link Bitmap subfield (frame sent by non-AP MLD: "
251 << std::boolalpha << sentbyNonApMld <<
")");
259 "EMLSR Parameter Update Control should be set to 0 in frames sent by the AP MLD");
264 m_staMacs[0]->GetWifiPhy(linkId)->GetPhyBand()) +
271 "EML Notification received on unexpected link (frame sent by non-AP MLD: "
272 << std::boolalpha << sentbyNonApMld <<
")");
278 const auto& hdr = mpdu->GetHeader();
280 if (hdr.IsMgt() && hdr.IsAction())
284 action.protectedEhtAction ==
299 const auto& hdr = mpdu->GetHeader();
301 if (hdr.IsMgt() && hdr.IsAction())
305 action.protectedEhtAction ==
320 auto setupLinks =
m_staMacs[0]->GetSetupLinkIds();
321 std::set<uint8_t> expectedEmlsrLinks;
322 std::set_intersection(setupLinks.begin(),
326 std::inserter(expectedEmlsrLinks, expectedEmlsrLinks.end()));
330 "Unexpected set of EMLSR links)");
341 "Unexpected number of times CheckEmlsrLinks() is called");
345 "Unexpected number of times the EML Notification frame is dropped due to max retry limit");
358 TestCase::Duration::QUICK);
Test the exchange of EML Operating Mode Notification frames.
void CheckEmlCapabilitiesInAssocResp(Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector, uint8_t linkId)
Check the content of the EML Capabilities subfield of the Multi-Link Element included in the Associat...
void TxOk(Ptr< const WifiMpdu > mpdu)
Callback invoked when the non-AP MLD receives the acknowledgment for a transmitted MPDU.
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
void DoSetup() override
Implementation to do any local setup required for this TestCase.
EmlOmnExchangeTest(const std::set< uint8_t > &linksToEnableEmlsrOn, Time transitionTimeout)
Constructor.
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...
void CheckEmlsrLinks()
Check that the EMLSR mode has been enabled on the expected EMLSR links.
void CheckEmlCapabilitiesInAssocReq(Ptr< const WifiMpdu > mpdu, const WifiTxVector &txVector, uint8_t linkId)
Check the content of the EML Capabilities subfield of the Multi-Link Element included in the Associat...
void TxDropped(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Callback invoked when the non-AP MLD drops the given MPDU for the given reason.
void CheckEmlNotification(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, uint8_t linkId)
Check the content of a received EML Operating Mode Notification frame.
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 EML Operating Mode Notification frame serialization and deserialization.
EmlOperatingModeNotificationTest()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Base class for EMLSR Operations tests.
std::size_t m_nNonEmlsrStations
number of stations to create that do not activate EMLSR
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
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
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.
Time m_transitionTimeout
Transition Timeout advertised by the AP MLD.
std::vector< Ptr< StaWifiMac > > m_staMacs
MACs of the non-AP MLDs.
wifi EMLSR suite to test the procedure for enabling EMLSR mode
WifiEmlsrEnablingTestSuite()
void SetList(const std::list< uint64_t > &packetlist)
Implement the header for Action frames of type EML Operating Mode Notification.
void SetLinkIdInBitmap(uint8_t linkId)
Set the bit position in the link bitmap corresponding to the given link.
EmlControl m_emlControl
EML Control field.
std::optional< EmlsrParamUpdate > m_emlsrParamUpdate
EMLSR Parameter Update field.
std::list< uint8_t > GetLinkBitmap() const
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 void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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 NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiMacDropReason
The reason why an MPDU was dropped.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
static uint8_t EncodeEmlsrTransitionDelay(Time delay)
static Time DecodeEmlsrTransitionDelay(uint8_t value)
static Time DecodeEmlsrPaddingDelay(uint8_t value)
static uint8_t EncodeEmlsrPaddingDelay(Time delay)
uint8_t emlsrMode
EMLSR Mode.
uint8_t emlsrParamUpdateCtrl
EMLSR Parameter Update Control.
uint8_t emlmrMode
EMLMR Mode.
std::optional< uint16_t > linkBitmap
EMLSR/EMLMR Link Bitmap.
EMLSR Parameter Update field.
static WifiEmlsrEnablingTestSuite g_wifiEmlsrEnablingTestSuite
the test suite