22 #include "ns3/double.h"
24 #include "ns3/packet.h"
25 #include "ns3/red-queue-disc.h"
26 #include "ns3/simulator.h"
27 #include "ns3/string.h"
29 #include "ns3/uinteger.h"
55 void AddHeader()
override;
64 m_ecnCapablePacket(ecnCapable)
88 void DoRun()
override;
107 :
TestCase(
"Sanity check on the red queue implementation")
116 uint32_t modeSize = 1;
125 "Verify that we can actually set the attribute MinTh");
128 "Verify that we can actually set the attribute MaxTh");
130 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
132 "Verify that we can actually set the attribute MaxSize");
135 "Verify that we can actually set the attribute QW");
145 queue->SetTh(minTh * modeSize, maxTh * modeSize);
146 queue->SetMaxSize(
QueueSize(mode, qSize * modeSize));
169 "There should be no packets in there");
170 queue->Enqueue(Create<RedQueueDiscTestItem>(p1, dest,
false));
173 "There should be one packet in there");
174 queue->Enqueue(Create<RedQueueDiscTestItem>(p2, dest,
false));
177 "There should be two packets in there");
178 queue->Enqueue(Create<RedQueueDiscTestItem>(p3, dest,
false));
179 queue->Enqueue(Create<RedQueueDiscTestItem>(p4, dest,
false));
180 queue->Enqueue(Create<RedQueueDiscTestItem>(p5, dest,
false));
181 queue->Enqueue(Create<RedQueueDiscTestItem>(p6, dest,
false));
182 queue->Enqueue(Create<RedQueueDiscTestItem>(p7, dest,
false));
183 queue->Enqueue(Create<RedQueueDiscTestItem>(p8, dest,
false));
186 "There should be eight packets in there");
190 item = queue->Dequeue();
194 "There should be seven packets in there");
197 item = queue->Dequeue();
201 "There should be six packet in there");
204 "Was this the second packet ?");
206 item = queue->Dequeue();
210 "There should be five packets in there");
213 item = queue->Dequeue();
214 item = queue->Dequeue();
215 item = queue->Dequeue();
216 item = queue->Dequeue();
217 item = queue->Dequeue();
219 item = queue->Dequeue();
223 queue = CreateObject<RedQueueDisc>();
224 minTh = 70 * modeSize;
225 maxTh = 150 * modeSize;
226 qSize = 300 * modeSize;
229 "Verify that we can actually set the attribute MinTh");
232 "Verify that we can actually set the attribute MaxTh");
234 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
236 "Verify that we can actually set the attribute MaxSize");
242 "There should be zero unforced drops");
245 "There should be zero forced dropps");
248 "There should be zero drops due to queue limit");
264 queue = CreateObject<RedQueueDisc>();
267 "Verify that we can actually set the attribute MinTh");
270 "Verify that we can actually set the attribute MaxTh");
272 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
274 "Verify that we can actually set the attribute MaxSize");
277 "Verify that we can actually set the attribute QW");
280 st = queue->GetStats();
287 maxTh = 100 * modeSize;
288 queue = CreateObject<RedQueueDisc>();
291 "Verify that we can actually set the attribute MinTh");
294 "Verify that we can actually set the attribute MaxTh");
296 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
298 "Verify that we can actually set the attribute MaxSize");
301 "Verify that we can actually set the attribute QW");
304 st = queue->GetStats();
311 maxTh = 150 * modeSize;
312 queue = CreateObject<RedQueueDisc>();
315 "Verify that we can actually set the attribute MinTh");
318 "Verify that we can actually set the attribute MaxTh");
320 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
322 "Verify that we can actually set the attribute MaxSize");
325 "Verify that we can actually set the attribute QW");
328 "Verify that we can actually set the attribute LInterm");
331 st = queue->GetStats();
338 queue = CreateObject<RedQueueDisc>();
341 "Verify that we can actually set the attribute MinTh");
344 "Verify that we can actually set the attribute MaxTh");
346 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
348 "Verify that we can actually set the attribute MaxSize");
351 "Verify that we can actually set the attribute QW");
354 "Verify that we can actually set the attribute Gentle");
357 st = queue->GetStats();
364 queue = CreateObject<RedQueueDisc>();
367 "Verify that we can actually set the attribute MinTh");
370 "Verify that we can actually set the attribute MaxTh");
372 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
374 "Verify that we can actually set the attribute MaxSize");
377 "Verify that we can actually set the attribute QW");
380 "Verify that we can actually set the attribute Wait");
383 st = queue->GetStats();
390 queue = CreateObject<RedQueueDisc>();
391 minTh = 30 * modeSize;
392 maxTh = 90 * modeSize;
395 "Verify that we can actually set the attribute MinTh");
398 "Verify that we can actually set the attribute MaxTh");
400 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
402 "Verify that we can actually set the attribute MaxSize");
405 "Verify that we can actually set the attribute QW");
408 "Verify that we can actually set the attribute LInterm");
411 "Verify that we can actually set the attribute Gentle");
414 "Verify that we can actually set the attribute UseECN");
417 st = queue->GetStats();
421 "There should be some unforced drops");
424 "There should be no unforced marks");
427 queue = CreateObject<RedQueueDisc>();
430 "Verify that we can actually set the attribute MinTh");
433 "Verify that we can actually set the attribute MaxTh");
435 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
437 "Verify that we can actually set the attribute MaxSize");
440 "Verify that we can actually set the attribute QW");
443 "Verify that we can actually set the attribute LInterm");
446 "Verify that we can actually set the attribute Gentle");
449 "Verify that we can actually set the attribute UseECN");
452 st = queue->GetStats();
456 "There should be some unforced drops");
459 "There should be no unforced marks");
462 queue = CreateObject<RedQueueDisc>();
465 "Verify that we can actually set the attribute MinTh");
468 "Verify that we can actually set the attribute MaxTh");
470 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
472 "Verify that we can actually set the attribute MaxSize");
475 "Verify that we can actually set the attribute QW");
478 "Verify that we can actually set the attribute LInterm");
481 "Verify that we can actually set the attribute Gentle");
484 "Verify that we can actually set the attribute UseECN");
487 st = queue->GetStats();
492 "There should be no unforced drops");
495 "There should be some unforced marks");
498 queue = CreateObject<RedQueueDisc>();
499 minTh = 30 * modeSize;
500 maxTh = 90 * modeSize;
503 "Verify that we can actually set the attribute MinTh");
506 "Verify that we can actually set the attribute MaxTh");
508 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
510 "Verify that we can actually set the attribute MaxSize");
513 "Verify that we can actually set the attribute QW");
516 "Verify that we can actually set the attribute LInterm");
519 "Verify that we can actually set the attribute Gentle");
522 st = queue->GetStats();
526 "There should some dropped packets due to probability mark");
529 queue = CreateObject<RedQueueDisc>();
532 "Verify that we can actually set the attribute MinTh");
535 "Verify that we can actually set the attribute MaxTh");
537 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
539 "Verify that we can actually set the attribute MaxSize");
542 "Verify that we can actually set the attribute QW");
545 "Verify that we can actually set the attribute LInterm");
548 "Verify that we can actually set the attribute Gentle");
551 "Verify that we can actually set the attribute FengAdaptive");
554 st = queue->GetStats();
558 "Test 12 should have less drops due to probability mark than test 11");
561 queue = CreateObject<RedQueueDisc>();
562 minTh = 30 * modeSize;
563 maxTh = 90 * modeSize;
566 "Verify that we can actually set the attribute MinTh");
569 "Verify that we can actually set the attribute MaxTh");
571 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
573 "Verify that we can actually set the attribute MaxSize");
576 "Verify that we can actually set the attribute QW");
579 "Verify that we can actually set the attribute LInterm");
582 "Verify that we can actually set the attribute Gentle");
585 "Verify that we can actually set the attribute NLRED");
588 st = queue->GetStats();
592 "Test 13 should have less drops due to probability mark than test 11");
602 for (uint32_t i = 0; i < nPkt; i++)
604 queue->Enqueue(Create<RedQueueDiscTestItem>(Create<Packet>(size), dest, ecnCapable));
613 Simulator::Destroy();
Red Queue Disc Test Case.
void RunRedTest(QueueSizeUnit mode)
Run RED test function.
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
void DoRun() override
Implementation to actually run this TestCase.
Red Queue Disc Test Item.
void AddHeader() override
Add the header to the packet.
RedQueueDiscTestItem & operator=(const RedQueueDiscTestItem &)=delete
RedQueueDiscTestItem()=delete
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
RedQueueDiscTestItem(const RedQueueDiscTestItem &)=delete
bool m_ecnCapablePacket
ECN capable packet?
Red 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'.
uint64_t GetUid() const
Returns the packet's Uid.
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Class for representing queue sizes.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
QueueSizeUnit
Enumeration of the operating modes of queues.
@ BYTES
Use number of bytes for queue size.
@ PACKETS
Use number of packets for queue size.
#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.
RedQueueDiscTestSuite g_redQueueTestSuite
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)