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));
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");
307 Simulator::Stop (
Seconds (8.0));
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");
332 Simulator::Stop (
Seconds (8.0));
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");
357 Simulator::Stop (
Seconds (8.0));
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");
376 Simulator::Stop (
Seconds (8.0));
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");
396 Simulator::Stop (
Seconds (8.0));
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");
418 Simulator::Stop (
Seconds (8.0));
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");
441 Simulator::Stop (
Seconds (8.0));
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");
464 Simulator::Stop (
Seconds (8.0));
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");
488 Simulator::Stop (
Seconds (8.0));
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");
513 Simulator::Stop (
Seconds (8.0));
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");
536 Simulator::Stop (
Seconds (8.0));
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");
561 Simulator::Stop (
Seconds (8.0));
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);
581 Simulator::Stop (
Seconds (8.0));
591 queue = CreateObject<PieQueueDisc> ();
593 testAttributes = Create<PieQueueDiscTestItem> (Create<Packet> (
pktSize), dest,
false);
600 Simulator::Stop (
Seconds (8.0));
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 ();