12#include "ns3/double.h"
14#include "ns3/packet.h"
15#include "ns3/pie-queue-disc.h"
16#include "ns3/simulator.h"
17#include "ns3/string.h"
19#include "ns3/uinteger.h"
73 m_ecnCapablePacket(ecnCapable)
97 void DoRun()
override;
161 :
TestCase(
"Sanity check on the pie queue disc implementation")
182 if (mode == QueueSizeUnit::BYTES)
188 qSize = qSize * modeSize;
194 "Verify that we can actually set the attribute MaxSize");
216 "There should be no packets in there");
220 "There should be one packet in there");
224 "There should be two packets in there");
233 "There should be eight packets in there");
237 item = queue->Dequeue();
241 "There should be seven packets in there");
244 item = queue->Dequeue();
248 "There should be six packet in there");
251 "Was this the second packet ?");
253 item = queue->Dequeue();
257 "There should be five packets in there");
260 item = queue->Dequeue();
261 item = queue->Dequeue();
262 item = queue->Dequeue();
263 item = queue->Dequeue();
264 item = queue->Dequeue();
266 item = queue->Dequeue();
277 "Verify that we can actually set the attribute MaxSize");
280 "Verify that we can actually set the attribute Tupdate");
283 "Verify that we can actually set the attribute DequeueThreshold");
285 queue->SetAttributeFailSafe(
"QueueDelayReference",
TimeValue(
Seconds(0.02))),
287 "Verify that we can actually set the attribute QueueDelayReference");
290 "Verify that we can actually set the attribute MaxBurstAllowance");
301 "There should be zero forced drops");
310 "Verify that we can actually set the attribute MaxSize");
313 "Verify that we can actually set the attribute Tupdate");
316 "Verify that we can actually set the attribute DequeueThreshold");
318 queue->SetAttributeFailSafe(
"QueueDelayReference",
TimeValue(
Seconds(0.08))),
320 "Verify that we can actually set the attribute QueueDelayReference");
323 "Verify that we can actually set the attribute MaxBurstAllowance");
329 st = queue->GetStats();
334 "There should be zero forced drops");
343 "Verify that we can actually set the attribute MaxSize");
346 "Verify that we can actually set the attribute Tupdate");
349 "Verify that we can actually set the attribute DequeueThreshold");
351 queue->SetAttributeFailSafe(
"QueueDelayReference",
TimeValue(
Seconds(0.02))),
353 "Verify that we can actually set the attribute QueueDelayReference");
356 "Verify that we can actually set the attribute MaxBurstAllowance");
362 st = queue->GetStats();
367 "There should be zero forced drops");
376 "Verify that we can actually set the attribute MaxSize");
379 "Verify that we can actually set the attribute Tupdate");
382 "Verify that we can actually set the attribute DequeueThreshold");
384 queue->SetAttributeFailSafe(
"QueueDelayReference",
TimeValue(
Seconds(0.02))),
386 "Verify that we can actually set the attribute QueueDelayReference");
389 "Verify that we can actually set the attribute MaxBurstAllowance");
395 st = queue->GetStats();
400 "There should be zero forced drops");
409 "Verify that we can actually set the attribute MaxSize");
411 queue->SetAttributeFailSafe(
"UseDequeueRateEstimator",
BooleanValue(
true)),
413 "Verify that we can actually set the attribute UseTimestamp");
419 st = queue->GetStats();
424 "There should be zero forced drops");
433 "Verify that we can actually set the attribute MaxSize");
436 "Verify that we can actually set the attribute UseCapDropAdjustment");
438 testAttributes->m_checkProb =
true;
443 st = queue->GetStats();
448 "There should be zero forced drops");
451 "Maximum increase in drop probability should be greater than 0.02");
460 "Verify that we can actually set the attribute MaxSize");
463 "Verify that we can actually set the attribute UseCapDropAdjustment");
465 testAttributes->m_checkProb =
true;
470 st = queue->GetStats();
475 "There should be zero forced drops");
477 testAttributes->m_maxDropProbDiff,
479 "Maximum increase in drop probability should be less than or equal to 0.02");
488 "Verify that we can actually set the attribute MaxSize");
491 "Verify that we can actually set the attribute UseEcn");
494 "Verify that we can actually set the attribute MarkEcnThreshold");
500 st = queue->GetStats();
505 "There should be some unforced drops");
508 "There should be zero forced drops");
517 "Verify that we can actually set the attribute MaxSize");
520 "Verify that we can actually set the attribute UseEcn");
523 "Verify that we can actually set the attribute MarkEcnThreshold");
525 testAttributes->m_ecnCapable =
true;
530 st = queue->GetStats();
535 "There should be some unforced drops");
538 "There should be zero forced drops");
547 "Verify that we can actually set the attribute MaxSize");
550 "Verify that we can actually set the attribute UseEcn");
553 "Verify that we can actually set the attribute MarkEcnThreshold");
555 testAttributes->m_ecnCapable =
true;
556 testAttributes->m_checkProb =
true;
561 st = queue->GetStats();
568 "There should be some unforced drops");
572 "Maximum Drop probability should be greater than 0.3");
575 "There should be zero forced drops");
584 "Verify that we can actually set the attribute MaxSize");
587 "Verify that we can actually set the attribute UseDerandomization");
589 testAttributes->m_checkAccuProb =
true;
594 st = queue->GetStats();
599 "There should be zero forced drops");
602 "There should not be any error in setting accuProb");
611 "Verify that we can actually set the attribute MaxSize");
614 "Verify that we can actually set the attribute UseDerandomization");
616 testAttributes->m_constAccuProb =
true;
619 testAttributes->m_setAccuProb = -0.16;
624 st = queue->GetStats();
629 "There should be zero forced drops");
638 "Verify that we can actually set the attribute MaxSize");
641 "Verify that we can actually set the attribute MaxBurstAllowance");
644 "Verify that we can actually set the attribute UseDerandomization");
646 testAttributes->m_constAccuProb =
true;
647 testAttributes->m_checkMaxAccuProb =
true;
650 testAttributes->m_setAccuProb = 8.6;
655 st = queue->GetStats();
659 testAttributes->m_expectedDrops,
660 "The number of unforced drops should be equal to number of expected unforced drops");
663 "There should be zero forced drops");
678 st = queue->GetStats();
683 "There should be zero marks");
698 st = queue->GetStats();
703 "There should be zero marks");
715 if (testAttributes->m_constAccuProb)
717 queue->m_accuProb = testAttributes->m_setAccuProb;
718 if (testAttributes->m_checkMaxAccuProb)
725 if (testAttributes->m_checkProb)
729 if (testAttributes->m_checkAccuProb)
740 double dropProb = queue->m_dropProb;
741 if (testAttributes->m_maxDropProb < dropProb)
743 testAttributes->m_maxDropProb = dropProb;
745 if (testAttributes->m_prevDropProb > 0.1)
747 double currentDiff = dropProb - testAttributes->m_prevDropProb;
748 if (testAttributes->m_maxDropProbDiff < currentDiff)
750 testAttributes->m_maxDropProbDiff = currentDiff;
753 testAttributes->m_prevDropProb = dropProb;
760 double dropProb = queue->m_dropProb;
761 double accuProb = queue->m_accuProb;
764 double expectedAccuProb = testAttributes->m_prevAccuProb + dropProb;
765 testAttributes->m_accuProbError = accuProb - expectedAccuProb;
767 testAttributes->m_prevAccuProb = accuProb;
774 queue->m_dropProb = 0.001;
779 testAttributes->m_expectedDrops = testAttributes->m_expectedDrops + 1;
Pie Queue Disc Test Case.
void Dequeue(Ptr< PieQueueDisc > queue, uint32_t nPkt)
Dequeue function.
void RunPieTest(QueueSizeUnit mode)
Run test function.
void CheckMaxAccuProb(Ptr< PieQueueDisc > queue, Ptr< PieQueueDiscTestItem > testAttributes)
Check Maximum Accumulated Drop Probability.
void EnqueueWithDelay(Ptr< PieQueueDisc > queue, uint32_t size, uint32_t nPkt, Ptr< PieQueueDiscTestItem > testAttributes)
Enqueue with delay function.
void CheckAccuProb(Ptr< PieQueueDisc > queue, Ptr< PieQueueDiscTestItem > testAttributes)
Check Accumulated Drop Probability.
void CheckDropProb(Ptr< PieQueueDisc > queue, Ptr< PieQueueDiscTestItem > testAttributes)
Check Drop Probability.
void DequeueWithDelay(Ptr< PieQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue with delay function.
void Enqueue(Ptr< PieQueueDisc > queue, uint32_t size, uint32_t nPkt, Ptr< PieQueueDiscTestItem > testAttributes)
Enqueue function.
void DoRun() override
Implementation to actually run this TestCase.
Pie Queue Disc Test Item.
double m_prevDropProb
Previous drop probability.
bool m_checkAccuProb
Enable/Disable accumulated drop probability checks.
bool m_ecnCapable
Enable/Disable ECN capability.
double m_maxDropProbDiff
Maximum difference between two consecutive drop probability values.
bool m_constAccuProb
Enable/Disable fixed accumulated drop probability.
bool m_ecnCapablePacket
ECN capable packet?
PieQueueDiscTestItem & operator=(const PieQueueDiscTestItem &)=delete
PieQueueDiscTestItem(const PieQueueDiscTestItem &)=delete
bool m_checkProb
Enable/Disable drop probability checks.
bool m_checkMaxAccuProb
Enable/Disable Maximum accumulated drop probability checks.
double m_maxDropProb
Maximum value of drop probability.
double m_prevAccuProb
Previous accumulated drop probability.
PieQueueDiscTestItem()=delete
void AddHeader() override
Add the header to the packet.
uint32_t m_expectedDrops
Number of expected unforced drops.
double m_setAccuProb
Value to be set for accumulated drop probability.
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
double m_accuProbError
Error in accumulated drop probability.
Pie Queue Disc Test Suite.
a polymophic address class
This class can be used to hold variables of floating point type such as 'double' or 'float'.
static constexpr const char * UNFORCED_DROP
Early probability drops: proactive.
static constexpr const char * FORCED_DROP
Drops due to queue limit: reactive.
static constexpr const char * UNFORCED_MARK
Early probability marks: proactive.
Smart pointer class similar to boost::intrusive_ptr.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Class for representing queue sizes.
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.
static constexpr auto UNIT
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
QueueSizeUnit
Enumeration of the operating modes of queues.
#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_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
PieQueueDiscTestSuite g_pieQueueTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure that keeps the queue disc statistics.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
uint32_t pktSize
packet size used for the simulation (in bytes)