9#include "ns3/ap-wifi-mac.h"
10#include "ns3/boolean.h"
11#include "ns3/config.h"
12#include "ns3/ctrl-headers.h"
15#include "ns3/mobility-helper.h"
16#include "ns3/multi-model-spectrum-channel.h"
17#include "ns3/node-container.h"
18#include "ns3/node-list.h"
19#include "ns3/packet-socket-client.h"
20#include "ns3/packet-socket-helper.h"
21#include "ns3/packet-socket-server.h"
22#include "ns3/packet.h"
23#include "ns3/qos-txop.h"
24#include "ns3/rng-seed-manager.h"
25#include "ns3/simulator.h"
26#include "ns3/spectrum-wifi-helper.h"
28#include "ns3/sta-wifi-mac.h"
29#include "ns3/string.h"
31#include "ns3/wifi-acknowledgment.h"
32#include "ns3/wifi-mac-helper.h"
33#include "ns3/wifi-net-device.h"
34#include "ns3/wifi-phy.h"
35#include "ns3/wifi-psdu.h"
36#include "ns3/wifi-static-setup-helper.h"
151 void DoRun()
override;
193 :
TestCase(
"Check that a DL MU PPDU mixing protected and unprotected receivers gets an MU-RTS")
205 client->SetStartTime(
Time{0});
226 phy.SetChannel(channel);
227 phy.Set(
"ChannelSettings",
StringValue(
"{36, 20, BAND_5GHZ, 0}"));
231 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
238 Ssid ssid(
"mu-rts-test");
239 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
240 auto staDevices = wifi.Install(phy, mac, staNodes);
243 mac.SetMultiUserScheduler(
"ns3::RrMultiUserScheduler",
"EnableUlOfdma",
BooleanValue(
false));
244 auto apDevices = wifi.Install(phy, mac, apNode);
251 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
252 for (std::size_t i = 0; i <
N_STAS; ++i)
254 positionAlloc->Add(Vector(1.0, i * 1.0, 0.0));
256 mobility.SetPositionAllocator(positionAlloc);
257 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
258 mobility.Install(apNode);
259 mobility.Install(staNodes);
262 for (std::size_t i = 0; i <
N_STAS; ++i)
279 dev->GetPhy(0)->TraceConnectWithoutContext(
286 packetSocket.
Install(staNodes);
289 for (std::size_t i = 0; i <
N_STAS; ++i)
297 server->SetLocal(srvAddr);
299 server->SetStartTime(
Time{0});
303 m_dlSockets.back().SetSingleDevice(apDev->GetIfIndex());
304 m_dlSockets.back().SetPhysicalAddress(staDev->GetAddress());
311 const std::set<std::size_t>& staIds)
314 psdu->GetPayload(0)->PeekHeader(trigger);
317 "Expected an MU-RTS Trigger Frame at time "
320 std::set<uint16_t> expectedAids;
321 for (
const auto staId : staIds)
323 expectedAids.insert(
m_staMacs.at(staId)->GetAssociationId());
325 std::set<uint16_t> solicitedAids;
326 for (
const auto& userInfo : trigger)
328 solicitedAids.insert(userInfo.GetAid12());
332 "The MU-RTS must solicit all receivers of the DL MU PPDU");
337 const std::set<std::size_t>& staIds)
339 std::set<Mac48Address> expectedReceivers;
340 for (
const auto staId : staIds)
342 expectedReceivers.insert(
m_staMacs.at(staId)->GetAddress());
344 std::set<Mac48Address> receivers;
345 for (
const auto& [aid, psdu] : psduMap)
347 receivers.insert(psdu->GetAddr1());
351 "Unexpected receiver set for the DL MU PPDU transmitted at time "
373 for (
const auto staId : {std::size_t{1}, std::size_t{2}})
375 m_apMac->GetDevice()->GetNode()->AddApplication(
383 psduMap.cbegin()->second->GetPayload(0)->PeekHeader(trigger);
386 "Expected an MU-BAR Trigger Frame at time "
410 psduMap.cbegin()->second->GetPayload(0)->PeekHeader(trigger);
413 "Expected an MU-BAR Trigger Frame at time "
428 for (
const auto& [aid, psdu] : psduMap)
430 std::stringstream ss;
431 ss <<
" #MPDUs " << psdu->GetNMpdus();
432 for (
auto it = psdu->begin(); it != psdu->end(); ++it)
440 const auto psdu = psduMap.cbegin()->second;
441 const auto& hdr = psdu->GetHeader(0);
445 "Unexpected frame of type " << hdr.GetTypeString()
446 <<
" transmitted at time "
457 "Unexpected MAC header type for frame transmitted at time "
466 "Frame of type " << hdr.GetTypeString()
467 <<
" expected a SIFS after the previous frame");
473 << hdr.GetTypeString()
474 <<
" expected at the same time as the previous frame");
482 if (expectedType == hdr.GetTypeString() &&
m_events.front().func)
484 m_events.front().func(psduMap, txVector);
501 for (
const auto staId : {std::size_t{0}, std::size_t{1}})
Test that a DL MU PPDU mixing protected and unprotected receivers gets an MU-RTS.
static constexpr std::size_t N_STAS
number of contending stations
const Time m_duration
simulation duration
std::vector< Ptr< StaWifiMac > > m_staMacs
station wifi MACs
std::vector< PacketSocketAddress > m_dlSockets
packet socket addresses for DL traffic
void InsertEvents()
Insert elements in the list of expected events (transmitted frames).
void DoRun() override
Implementation to actually run this TestCase.
MuRtsUnprotectedReceiverTest()
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::list< Events > m_events
list of events for the test run
Ptr< PacketSocketClient > GetApplication(std::size_t staId) const
void CheckMuRts(Ptr< const WifiPsdu > psdu, const std::set< std::size_t > &staIds)
Check that the given PSDU is an MU-RTS soliciting exactly the given stations.
Time m_prevTxStart
start time of the previous frame
const Time m_txopLimit
TXOP limit for the AC of the DL traffic.
void CheckDlMuPpdu(const WifiConstPsduMap &psduMap, const std::set< std::size_t > &staIds)
Check that the given PSDU map is a DL MU PPDU addressed to exactly the given stations.
Ptr< ApWifiMac > m_apMac
AP wifi MAC.
Time m_prevTxEnd
end time of the previous frame
void Transmit(WifiConstPsduMap psduMap, WifiTxVector txVector, Watt_u txPower)
Callback invoked when a PHY passes a PSDU map to transmit.
ExpectedStart
Expected start time of a frame relative to the previous frame in the sequence.
@ SAME_TIME
at the same time as the previous frame (simultaneous responses)
@ ANY
no expectation (first frame of the sequence)
@ AFTER_SIFS
a SIFS after the end of the previous frame
wifi protection Test Suite
WifiProtectionTestSuite()
Hold variables of type enum.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
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.
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
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.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
create MAC layers for a ns3::WifiNetDevice.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
static void SetStaticAssociation(Ptr< WifiNetDevice > bssDev, const NetDeviceContainer &clientDevs)
Bypass static capabilities exchange for input devices.
static void SetStaticBlockAck(Ptr< WifiNetDevice > apDev, const NetDeviceContainer &clientDevs, const std::set< tid_t > &tids, std::optional< Mac48Address > gcrGroupAddr=std::nullopt)
Bypass ADDBA Request-Response exchange sequence between AP and STAs for given TIDs.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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...
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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 MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
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.
double Watt_u
Watt weak type.
ExpectedStart start
expected start time of the frame
Events(WifiMacType type, ExpectedStart s, std::function< void(const WifiConstPsduMap &, const WifiTxVector &)> &&f={})
Constructor.
WifiMacType hdrType
MAC header type of the frame.
std::function< void(const WifiConstPsduMap &, const WifiTxVector &)> func
actions and checks to perform
static WifiProtectionTestSuite g_wifiProtectionTestSuite
the test suite