25 #include "ns3/pie-queue-disc.h" 26 #include "ns3/packet.h" 27 #include "ns3/uinteger.h" 28 #include "ns3/string.h" 29 #include "ns3/double.h" 31 #include "ns3/simulator.h" 53 virtual void AddHeader (
void);
54 virtual bool Mark (
void);
57 double m_maxDropProbDiff = 0.0;
58 double m_prevDropProb = 0.0;
59 bool m_checkProb =
false;
62 double m_maxDropProb = 0.0;
63 bool m_ecnCapable =
false;
66 bool m_checkAccuProb =
false;
67 bool m_constAccuProb =
false;
68 bool m_checkMaxAccuProb =
false;
69 double m_accuProbError = 0.0;
70 double m_prevAccuProb = 0.0;
71 double m_setAccuProb = 0.0;
72 uint32_t m_expectedDrops = 0;
124 virtual void DoRun (
void);
181 :
TestCase (
"Sanity check on the pie queue disc implementation")
191 uint32_t modeSize = 1;
193 uint32_t qSize = 300;
207 qSize = qSize * modeSize;
211 true,
"Verify that we can actually set the attribute MaxSize");
225 queue->
Enqueue (Create<PieQueueDiscTestItem> (p1, dest,
false));
227 queue->
Enqueue (Create<PieQueueDiscTestItem> (p2, dest,
false));
229 queue->
Enqueue (Create<PieQueueDiscTestItem> (p3, dest,
false));
230 queue->
Enqueue (Create<PieQueueDiscTestItem> (p4, dest,
false));
231 queue->
Enqueue (Create<PieQueueDiscTestItem> (p5, dest,
false));
232 queue->
Enqueue (Create<PieQueueDiscTestItem> (p6, dest,
false));
233 queue->
Enqueue (Create<PieQueueDiscTestItem> (p7, dest,
false));
234 queue->
Enqueue (Create<PieQueueDiscTestItem> (p8, dest,
false));
247 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
265 queue = CreateObject<PieQueueDisc> ();
267 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
270 true,
"Verify that we can actually set the attribute MaxSize");
272 "Verify that we can actually set the attribute Tupdate");
274 "Verify that we can actually set the attribute DequeueThreshold");
276 "Verify that we can actually set the attribute QueueDelayReference");
278 "Verify that we can actually set the attribute MaxBurstAllowance");
282 Simulator::Stop (
Seconds (8.0));
291 queue = CreateObject<PieQueueDisc> ();
293 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
295 true,
"Verify that we can actually set the attribute MaxSize");
297 "Verify that we can actually set the attribute Tupdate");
299 "Verify that we can actually set the attribute DequeueThreshold");
301 "Verify that we can actually set the attribute QueueDelayReference");
303 "Verify that we can actually set the attribute MaxBurstAllowance");
304 queue->Initialize ();
307 Simulator::Stop (
Seconds (8.0));
309 st = queue->GetStats ();
316 queue = CreateObject<PieQueueDisc> ();
318 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
320 true,
"Verify that we can actually set the attribute MaxSize");
322 "Verify that we can actually set the attribute Tupdate");
324 "Verify that we can actually set the attribute DequeueThreshold");
326 "Verify that we can actually set the attribute QueueDelayReference");
328 "Verify that we can actually set the attribute MaxBurstAllowance");
329 queue->Initialize ();
332 Simulator::Stop (
Seconds (8.0));
334 st = queue->GetStats ();
341 queue = CreateObject<PieQueueDisc> ();
343 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
345 true,
"Verify that we can actually set the attribute MaxSize");
347 "Verify that we can actually set the attribute Tupdate");
349 "Verify that we can actually set the attribute DequeueThreshold");
351 "Verify that we can actually set the attribute QueueDelayReference");
353 "Verify that we can actually set the attribute MaxBurstAllowance");
354 queue->Initialize ();
357 Simulator::Stop (
Seconds (8.0));
359 st = queue->GetStats ();
366 queue = CreateObject<PieQueueDisc> ();
368 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
370 true,
"Verify that we can actually set the attribute MaxSize");
372 "Verify that we can actually set the attribute UseTimestamp");
373 queue->Initialize ();
376 Simulator::Stop (
Seconds (8.0));
378 st = queue->GetStats ();
385 queue = CreateObject<PieQueueDisc> ();
387 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
389 true,
"Verify that we can actually set the attribute MaxSize");
391 "Verify that we can actually set the attribute UseCapDropAdjustment");
392 queue->Initialize ();
393 testAttributes->m_checkProb =
true;
396 Simulator::Stop (
Seconds (8.0));
398 st = queue->GetStats ();
403 "Maximum increase in drop probability should be greater than 0.02");
407 queue = CreateObject<PieQueueDisc> ();
409 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
411 true,
"Verify that we can actually set the attribute MaxSize");
413 "Verify that we can actually set the attribute UseCapDropAdjustment");
414 queue->Initialize ();
415 testAttributes->m_checkProb =
true;
418 Simulator::Stop (
Seconds (8.0));
420 st = queue->GetStats ();
425 "Maximum increase in drop probability should be less than or equal to 0.02");
429 queue = CreateObject<PieQueueDisc> ();
431 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
433 true,
"Verify that we can actually set the attribute MaxSize");
435 "Verify that we can actually set the attribute UseEcn");
437 "Verify that we can actually set the attribute MarkEcnThreshold");
438 queue->Initialize ();
441 Simulator::Stop (
Seconds (8.0));
443 st = queue->GetStats ();
451 queue = CreateObject<PieQueueDisc> ();
453 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
455 true,
"Verify that we can actually set the attribute MaxSize");
457 "Verify that we can actually set the attribute UseEcn");
459 "Verify that we can actually set the attribute MarkEcnThreshold");
460 queue->Initialize ();
461 testAttributes->m_ecnCapable =
true;
464 Simulator::Stop (
Seconds (8.0));
466 st = queue->GetStats ();
474 queue = CreateObject<PieQueueDisc> ();
476 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
478 true,
"Verify that we can actually set the attribute MaxSize");
480 "Verify that we can actually set the attribute UseEcn");
482 "Verify that we can actually set the attribute MarkEcnThreshold");
483 queue->Initialize ();
484 testAttributes->m_ecnCapable =
true;
485 testAttributes->m_checkProb =
true;
488 Simulator::Stop (
Seconds (8.0));
490 st = queue->GetStats ();
497 NS_TEST_EXPECT_MSG_GT (testAttributes->m_maxDropProb, 0.3,
"Maximum Drop probability should be greater than 0.3");
502 queue = CreateObject<PieQueueDisc> ();
504 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
506 true,
"Verify that we can actually set the attribute MaxSize");
508 "Verify that we can actually set the attribute UseDerandomization");
509 queue->Initialize ();
510 testAttributes->m_checkAccuProb =
true;
513 Simulator::Stop (
Seconds (8.0));
515 st = queue->GetStats ();
519 NS_TEST_EXPECT_MSG_EQ (testAttributes->m_accuProbError, 0.0,
"There should not be any error in setting accuProb");
523 queue = CreateObject<PieQueueDisc> ();
525 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
527 true,
"Verify that we can actually set the attribute MaxSize");
529 "Verify that we can actually set the attribute UseDerandomization");
530 queue->Initialize ();
531 testAttributes->m_constAccuProb =
true;
533 testAttributes->m_setAccuProb = -0.16;
536 Simulator::Stop (
Seconds (8.0));
538 st = queue->GetStats ();
545 queue = CreateObject<PieQueueDisc> ();
547 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
549 true,
"Verify that we can actually set the attribute MaxSize");
551 "Verify that we can actually set the attribute MaxBurstAllowance");
553 "Verify that we can actually set the attribute UseDerandomization");
554 queue->Initialize ();
555 testAttributes->m_constAccuProb =
true;
556 testAttributes->m_checkMaxAccuProb =
true;
558 testAttributes->m_setAccuProb = 8.6;
561 Simulator::Stop (
Seconds (8.0));
563 st = queue->GetStats ();
566 "The number of unforced drops should be equal to number of expected unforced drops");
572 queue = CreateObject<PieQueueDisc> ();
574 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
577 queue->Initialize ();
581 Simulator::Stop (
Seconds (8.0));
583 st = queue->GetStats ();
591 queue = CreateObject<PieQueueDisc> ();
593 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
595 queue->SetAttributeFailSafe (
"ActiveThreshold",
TimeValue (
Seconds (0.001)));
596 queue->Initialize ();
600 Simulator::Stop (
Seconds (8.0));
602 st = queue->GetStats ();
612 for (uint32_t i = 0; i < nPkt; i++)
622 queue->
Enqueue (Create<PieQueueDiscTestItem> (Create<Packet> (size), dest, testAttributes->
m_ecnCapable));
660 double expectedAccuProb = testAttributes->
m_prevAccuProb + dropProb;
682 for (uint32_t i = 0; i < nPkt; i++)
691 for (uint32_t i = 0; i < nPkt; i++)
700 for (uint32_t i = 0; i < nPkt; i++)
711 Simulator::Destroy ();
Structure that keeps the queue disc statistics.
Pie Queue Disc Test Case.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
Simulation virtual time values and global simulation resolution.
bool m_checkAccuProb
Enable/Disable accumulated drop probability checks.
AttributeValue implementation for Boolean.
void CheckMaxAccuProb(Ptr< PieQueueDisc > queue, Ptr< PieQueueDiscTestItem > testAttributes)
Check Maximum Accumulated Drop Probability.
Class for representing queue sizes.
void RunPieTest(QueueSizeUnit mode)
Run test function.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
bool m_ecnCapablePacket
ECN capable packet?
uint32_t GetValue() const
Get the underlying value.
QueueSizeUnit
Enumeration of the operating modes of queues.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
bool m_checkMaxAccuProb
Enable/Disable Maximum accumulated drop probability checks.
void Dequeue(Ptr< PieQueueDisc > queue, uint32_t nPkt)
Dequeue function.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
uint32_t m_expectedDrops
Number of expected unforced drops.
double m_accuProb
Accumulated drop probability.
void Enqueue(Ptr< PieQueueDisc > queue, uint32_t size, uint32_t nPkt, Ptr< PieQueueDiscTestItem > testAttributes)
Enqueue function.
double m_dropProb
Variable used in calculation of drop probability.
a polymophic address class
double m_maxDropProbDiff
Maximum difference between two consecutive drop probability values.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double m_setAccuProb
Value to be set for accumulated drop probability.
AttributeValue implementation for Time.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Use number of packets for queue size.
double m_maxDropProb
Maximum value of drop probability.
virtual void AddHeader(void)
Add the header to the packet.
const Stats & GetStats(void)
Retrieve all the collected statistics.
double m_prevDropProb
Previous drop probability.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
void CheckAccuProb(Ptr< PieQueueDisc > queue, Ptr< PieQueueDiscTestItem > testAttributes)
Check Accumulated Drop Probability.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool m_checkProb
Enable/Disable drop probability checks.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
QueueSizeUnit GetUnit() const
Get the underlying unit.
double m_accuProbError
Error in accumulated drop probability.
Pie Queue Disc Test Item.
PieQueueDiscTestSuite g_pieQueueTestSuite
the test suite
virtual ~PieQueueDiscTestItem()
bool m_constAccuProb
Enable/Disable fixed accumulated drop probability.
Time Seconds(double value)
Construct a Time in the indicated unit.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
void EnqueueWithDelay(Ptr< PieQueueDisc > queue, uint32_t size, uint32_t nPkt, Ptr< PieQueueDiscTestItem > testAttributes)
Enqueue with delay function.
Pie Queue Disc Test Suite.
bool m_ecnCapable
Enable/Disable ECN capability.
void DequeueWithDelay(Ptr< PieQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue with delay function.
This test suite implements a Unit Test.
uint32_t pktSize
packet size used for the simulation (in bytes)
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Use number of bytes for queue size.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
double m_prevAccuProb
Previous accumulated drop probability.
void CheckDropProb(Ptr< PieQueueDisc > queue, Ptr< PieQueueDiscTestItem > testAttributes)
Check Drop Probability.