9#include "ns3/ap-wifi-mac.h"
10#include "ns3/boolean.h"
12#include "ns3/mobility-helper.h"
13#include "ns3/multi-model-spectrum-channel.h"
14#include "ns3/node-list.h"
15#include "ns3/nstime.h"
16#include "ns3/packet-socket-client.h"
17#include "ns3/packet-socket-helper.h"
18#include "ns3/packet-socket-server.h"
19#include "ns3/pointer.h"
20#include "ns3/rng-seed-manager.h"
21#include "ns3/spectrum-wifi-helper.h"
22#include "ns3/sta-wifi-mac.h"
24#include "ns3/uinteger.h"
25#include "ns3/wifi-static-setup-helper.h"
58 std::vector<std::pair<std::size_t, Time>>
packets;
62 std::string
ToStr()
const;
81 void DoRun()
override;
108 std::size_t pktSize)
const;
127 std::stringstream ss;
130 for (
const auto& [staId, interval] :
packets)
132 ss <<
"(" << staId <<
", " << interval <<
")";
139 :
TestCase(
"Test case for wifi queue scheduler " + params.ToStr()),
146 "Unsupported number of links (" << +
m_params.nLinks
147 <<
"), must be 1 or 2");
155 int64_t streamNumber = 10;
158 std::max_element(
m_params.packets.cbegin(),
160 [](
auto&& lhs,
auto&& rhs) { return lhs.first < rhs.first; });
161 const std::size_t nStas = maxIt->first + 1;
168 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager");
173 phy.Set(0,
"ChannelSettings",
StringValue(
"{0, 40, BAND_5GHZ, 0}"));
177 phy.Set(1,
"ChannelSettings",
StringValue(
"{0, 40, BAND_6GHZ, 0}"));
181 mac.SetMacQueueScheduler(
m_params.schedulerTid);
182 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(
Ssid(
"scheduler-ssid")));
184 auto staDevices = wifi.Install(phy, mac, wifiStaNodes);
185 for (
uint32_t i = 0; i < staDevices.GetN(); ++i)
191 mac.SetType(
"ns3::ApWifiMac",
198 auto apDevice = wifi.Install(phy, mac, wifiApNode);
214 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
215 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
216 mobility.SetPositionAllocator(positionAlloc);
218 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
219 mobility.Install(wifiApNode);
220 mobility.Install(wifiStaNodes);
223 packetSocket.
Install(wifiApNode);
224 packetSocket.
Install(wifiStaNodes);
227 for (
uint32_t i = 0; i < wifiStaNodes.GetN(); ++i)
236 server->SetLocal(srvAddr);
237 wifiStaNodes.Get(i)->AddApplication(server);
238 server->SetStartTime(
Time{0});
247 m_dlSockets.back().SetPhysicalAddress(staMac->GetDevice()->GetAddress());
255 for (uint8_t phyId = 0; phyId < dev->GetNPhys(); ++phyId)
257 dev->GetPhy(phyId)->TraceConnectWithoutContext(
271 auto linkId = mac->GetLinkForPhy(phyId);
274 for (
const auto& [aid, psdu] : psduMap)
276 std::stringstream ss;
277 ss << std::setprecision(10) <<
" Link ID " << +linkId.value() <<
" Phy ID " << +phyId
278 <<
" #MPDUs " << psdu->GetNMpdus();
279 for (
auto it = psdu->begin(); it != psdu->end(); ++it)
287 const auto psdu = psduMap.cbegin()->second;
288 const auto addr1 = psdu->GetAddr1();
290 if ((mac !=
m_apMac) || addr1.IsBroadcast())
297 "Served more STAs than expected");
303 "Expected STA ID exceeds the number of STAs");
305 std::size_t actualServedSta{0};
307 for (std::size_t
id = 0;
id <
m_staMacs.size(); ++id)
309 if (
m_staMacs[
id]->GetLinkIdByAddress(addr1))
311 actualServedSta = id;
318 "Receiver address (" << addr1 <<
") does not belong to any STA");
330 std::size_t pktSize)
const
337 client->SetStartTime(
Time{0});
346 for (
Time delayTot;
const auto& [staId, delay] :
m_params.packets)
351 m_apMac->GetDevice()->GetNode(),
366 "Not all the expected STAs were served");
386 using ParamsResultsList = std::initializer_list<
387 std::pair<WifiQueueSchedulerTest::InputParams, WifiQueueSchedulerTest::ExpectedResults>>;
389 for (std::size_t nLinks = 1; nLinks <= 2; ++nLinks)
391 for (
const auto& [params, results] : ParamsResultsList{
393 {{.schedulerTid =
"ns3::FcfsWifiQueueScheduler",
396 .packets = {{0,
Time{0}},
402 {.servedStas = {0, 0, 1, 1, 2, 2}}},
404 {{.schedulerTid =
"ns3::FcfsWifiQueueScheduler",
407 .packets = {{0,
Time{0}},
413 {.servedStas = {0, 0, 1, 1, 2, 2}}},
417 {{.schedulerTid =
"ns3::FcfsWifiQueueScheduler",
421 {.servedStas = {0, 0, 1, 1, 2, 2, 3, 3}}},
423 {{.schedulerTid =
"ns3::RrWifiQueueScheduler",
426 .packets = {{0,
Time{0}},
432 {.servedStas = {0, 1, 2, 0, 1, 2}}},
434 {{.schedulerTid =
"ns3::RrWifiQueueScheduler",
437 .packets = {{0,
Time{0}},
443 {.servedStas = {0, 1, 2, 0, 1, 2}}},
447 {{.schedulerTid =
"ns3::RrWifiQueueScheduler",
451 {.servedStas = {0, 1, 2, 3}}},
454 if (params.nLinks < 2 && params.nMaxInflights > 1)
A configurable number of non-AP STAs associate with an AP.
std::vector< PacketSocketAddress > m_dlSockets
packet socket addresses for DL traffic
void DoRun() override
Implementation to actually run this TestCase.
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
InputParams m_params
input parameters
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void EnqueuePackets()
Enqueue packets according to input parameters.
std::vector< Ptr< StaWifiMac > > m_staMacs
the STA wifi MACs
Ptr< PacketSocketClient > GetApplication(std::size_t staId, std::size_t count, std::size_t pktSize) const
Get an application generating packets according to given parameters.
ExpectedResults m_expectedResults
expected results
const Time m_duration
simulation duration
std::list< std::size_t > m_servedStas
IDs of STAs in the order they are actually served.
void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, Watt_u txPower)
Callback invoked when a FEM passes PSDUs to the PHY.
WifiQueueSchedulerTest(const InputParams ¶ms, const ExpectedResults &results)
Constructor.
wifi queue scheduler Test Suite
WifiQueueSchedulerTestSuite()
Helper class used to assign positions and mobility models to nodes.
keep track of a set of node pointers.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application 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 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.
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
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 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...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
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...
#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_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
#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.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort 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.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double Watt_u
Watt weak type.
std::vector< std::size_t > servedStas
IDs of STAs in the order in which they are served.
static WifiQueueSchedulerTestSuite g_wifiQueueSchedulerTestSuite
the test suite