20 #include "ns3/fcfs-wifi-queue-scheduler.h"
21 #include "ns3/simulator.h"
23 #include "ns3/wifi-mac-queue.h"
47 void DoRun()
override;
51 :
TestCase(
"Test DROP_OLDEST setting")
58 auto wifiMacQueue = CreateObject<WifiMacQueue>(
AC_BE);
59 wifiMacQueue->SetMaxSize(
QueueSize(
"5p"));
60 auto wifiMacScheduler = CreateObject<FcfsWifiQueueScheduler>();
61 wifiMacScheduler->SetAttribute(
"DropPolicy",
EnumValue(FcfsWifiQueueScheduler::DROP_OLDEST));
62 wifiMacScheduler->m_perAcInfo[
AC_BE].wifiMacQueue = wifiMacQueue;
63 wifiMacQueue->SetScheduler(wifiMacScheduler);
68 std::list<uint64_t> packetUids;
69 for (uint32_t i = 0; i < 5; i++)
75 auto packet = Create<Packet>();
76 auto item = Create<WifiMpdu>(packet, header);
77 wifiMacQueue->Enqueue(item);
79 packetUids.push_back(packet->GetUid());
83 auto mpdu = wifiMacQueue->PeekByTidAndAddress(0, addr1);
86 "Queue has unexpected number of elements");
87 for (
auto packetUid : packetUids)
91 "Stored packet is not the expected one");
92 mpdu = wifiMacQueue->PeekByTidAndAddress(0, addr1, mpdu);
100 auto packet = Create<Packet>();
101 auto item = Create<WifiMpdu>(packet, header);
102 wifiMacQueue->Enqueue(item);
105 packetUids.pop_front();
106 packetUids.push_back(packet->GetUid());
109 mpdu = wifiMacQueue->PeekByTidAndAddress(0, addr1);
112 "Queue has unexpected number of elements");
113 for (
auto packetUid : packetUids)
117 "Stored packet is not the expected one");
118 mpdu = wifiMacQueue->PeekByTidAndAddress(0, addr1, mpdu);
121 wifiMacScheduler->Dispose();
122 Simulator::Destroy();
141 void DoRun()
override;
158 :
TestCase(
"Test extraction of expired MPDUs from MAC queue container")
170 auto mpdu = Create<WifiMpdu>(Create<Packet>(), header);
172 auto queueId = WifiMacQueueContainer::GetQueueId(mpdu);
174 elemIt->expiryTime = expiryTime;
177 elemIt->inflights.emplace(0, mpdu);
179 elemIt->deleter = [](
auto mpdu) {};
185 m_txAddr = Mac48Address::Allocate();
186 auto rxAddr1 = Mac48Address::Allocate();
187 auto rxAddr2 = Mac48Address::Allocate();
240 "Unexpected extracted MPDU");
246 "Unexpected extracted MPDU");
265 "Unexpected extracted MPDU");
300 std::set<uint16_t> expectedSeqNo{5, 7, 8, 14, 17};
301 std::set<uint16_t> actualSeqNo;
303 std::transform(
first, last, std::inserter(actualSeqNo, actualSeqNo.end()), [](
auto& elem) {
304 return elem.mpdu->GetHeader().GetSequenceNumber();
309 "Unexpected number of MPDUs extracted");
311 for (
auto expectedIt = expectedSeqNo.begin(), actualIt = actualSeqNo.begin();
312 expectedIt != expectedSeqNo.end();
313 ++expectedIt, ++actualIt)
331 "There should be other MPDU(s) in container queue 1");
334 "Unexpected queued MPDU");
338 "There should be other MPDU(s) in container queue 1");
341 "Unexpected queued MPDU");
345 "There should be other MPDU(s) in container queue 1");
348 "Unexpected queued MPDU");
352 "There should be other MPDU(s) in container queue 1");
355 "Unexpected queued MPDU");
359 "There should be other MPDU(s) in container queue 1");
362 "Unexpected queued MPDU");
366 "There should be other MPDU(s) in container queue 1");
369 "Unexpected queued MPDU");
373 "There should be no other MPDU in container queue 1");
382 "There should be other MPDU(s) in container queue 2");
385 "Unexpected queued MPDU");
389 "There should be other MPDU(s) in container queue 2");
392 "Unexpected queued MPDU");
396 "There should be other MPDU(s) in container queue 2");
399 "Unexpected queued MPDU");
403 "There should be other MPDU(s) in container queue 2");
406 "Unexpected queued MPDU");
410 "There should be other MPDU(s) in container queue 2");
413 "Unexpected queued MPDU");
417 "There should be other MPDU(s) in container queue 2");
420 "Unexpected queued MPDU");
424 "There should be no other MPDU in container queue 2");
428 Simulator::Destroy();
Test DROP_OLDEST setting.
WifiMacQueueDropOldestTest()
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Wifi MAC Queue Test Suite.
Hold variables of type enum.
Class for representing queue sizes.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
Class for the container used by WifiMacQueue.
const ContainerQueue & GetQueue(const WifiContainerQueueId &queueId) const
Get a const reference to the container queue identified by the given QueueId.
std::pair< iterator, iterator > ExtractAllExpiredMpdus() const
Transfer non-inflight MPDUs with expired lifetime in all the container queues to the container queue ...
iterator insert(const_iterator pos, Ptr< WifiMpdu > item)
Insert the given item at the specified location in the container.
std::pair< iterator, iterator > ExtractExpiredMpdus(const WifiContainerQueueId &queueId) const
Transfer non-inflight MPDUs with expired lifetime in the container queue identified by the given Queu...
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
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.
std::tuple< WifiContainerQueueType, WifiReceiverAddressType, Mac48Address, std::optional< uint8_t > > WifiContainerQueueId
Tuple (queue type, receiver address type, Address, TID) identifying a container queue.
static WifiMacQueueTestSuite g_wifiMacQueueTestSuite
the test suite