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)
92 void DoRun()
override;
111 :
TestCase(
"Sanity check on the red queue implementation")
120 uint32_t modeSize = 1;
129 "Verify that we can actually set the attribute MinTh");
132 "Verify that we can actually set the attribute MaxTh");
136 "Verify that we can actually set the attribute MaxSize");
139 "Verify that we can actually set the attribute QW");
149 queue->SetTh(minTh * modeSize, maxTh * modeSize);
150 queue->SetMaxSize(
QueueSize(mode, qSize * modeSize));
173 "There should be no packets in there");
174 queue->Enqueue(Create<RedQueueDiscTestItem>(p1, dest,
false));
177 "There should be one packet in there");
178 queue->Enqueue(Create<RedQueueDiscTestItem>(p2, dest,
false));
181 "There should be two packets in there");
182 queue->Enqueue(Create<RedQueueDiscTestItem>(p3, dest,
false));
183 queue->Enqueue(Create<RedQueueDiscTestItem>(p4, dest,
false));
184 queue->Enqueue(Create<RedQueueDiscTestItem>(p5, dest,
false));
185 queue->Enqueue(Create<RedQueueDiscTestItem>(p6, dest,
false));
186 queue->Enqueue(Create<RedQueueDiscTestItem>(p7, dest,
false));
187 queue->Enqueue(Create<RedQueueDiscTestItem>(p8, dest,
false));
190 "There should be eight packets in there");
194 item = queue->Dequeue();
198 "There should be seven packets in there");
201 item = queue->Dequeue();
205 "There should be six packet in there");
208 "Was this the second packet ?");
210 item = queue->Dequeue();
214 "There should be five packets in there");
217 item = queue->Dequeue();
218 item = queue->Dequeue();
219 item = queue->Dequeue();
220 item = queue->Dequeue();
221 item = queue->Dequeue();
223 item = queue->Dequeue();
227 queue = CreateObject<RedQueueDisc>();
228 minTh = 70 * modeSize;
229 maxTh = 150 * modeSize;
230 qSize = 300 * modeSize;
233 "Verify that we can actually set the attribute MinTh");
236 "Verify that we can actually set the attribute MaxTh");
240 "Verify that we can actually set the attribute MaxSize");
246 "There should be zero unforced drops");
249 "There should be zero forced dropps");
252 "There should be zero drops due to queue limit");
268 queue = CreateObject<RedQueueDisc>();
271 "Verify that we can actually set the attribute MinTh");
274 "Verify that we can actually set the attribute MaxTh");
278 "Verify that we can actually set the attribute MaxSize");
281 "Verify that we can actually set the attribute QW");
284 st = queue->GetStats();
291 maxTh = 100 * modeSize;
292 queue = CreateObject<RedQueueDisc>();
295 "Verify that we can actually set the attribute MinTh");
298 "Verify that we can actually set the attribute MaxTh");
302 "Verify that we can actually set the attribute MaxSize");
305 "Verify that we can actually set the attribute QW");
308 st = queue->GetStats();
315 maxTh = 150 * modeSize;
316 queue = CreateObject<RedQueueDisc>();
319 "Verify that we can actually set the attribute MinTh");
322 "Verify that we can actually set the attribute MaxTh");
326 "Verify that we can actually set the attribute MaxSize");
329 "Verify that we can actually set the attribute QW");
332 "Verify that we can actually set the attribute LInterm");
335 st = queue->GetStats();
342 queue = CreateObject<RedQueueDisc>();
345 "Verify that we can actually set the attribute MinTh");
348 "Verify that we can actually set the attribute MaxTh");
352 "Verify that we can actually set the attribute MaxSize");
355 "Verify that we can actually set the attribute QW");
358 "Verify that we can actually set the attribute Gentle");
361 st = queue->GetStats();
368 queue = CreateObject<RedQueueDisc>();
371 "Verify that we can actually set the attribute MinTh");
374 "Verify that we can actually set the attribute MaxTh");
378 "Verify that we can actually set the attribute MaxSize");
381 "Verify that we can actually set the attribute QW");
384 "Verify that we can actually set the attribute Wait");
387 st = queue->GetStats();
394 queue = CreateObject<RedQueueDisc>();
395 minTh = 30 * modeSize;
396 maxTh = 90 * modeSize;
399 "Verify that we can actually set the attribute MinTh");
402 "Verify that we can actually set the attribute MaxTh");
406 "Verify that we can actually set the attribute MaxSize");
409 "Verify that we can actually set the attribute QW");
412 "Verify that we can actually set the attribute LInterm");
415 "Verify that we can actually set the attribute Gentle");
418 "Verify that we can actually set the attribute UseECN");
421 st = queue->GetStats();
425 "There should be some unforced drops");
428 "There should be no unforced marks");
431 queue = CreateObject<RedQueueDisc>();
434 "Verify that we can actually set the attribute MinTh");
437 "Verify that we can actually set the attribute MaxTh");
441 "Verify that we can actually set the attribute MaxSize");
444 "Verify that we can actually set the attribute QW");
447 "Verify that we can actually set the attribute LInterm");
450 "Verify that we can actually set the attribute Gentle");
453 "Verify that we can actually set the attribute UseECN");
456 st = queue->GetStats();
460 "There should be some unforced drops");
463 "There should be no unforced marks");
466 queue = CreateObject<RedQueueDisc>();
469 "Verify that we can actually set the attribute MinTh");
472 "Verify that we can actually set the attribute MaxTh");
476 "Verify that we can actually set the attribute MaxSize");
479 "Verify that we can actually set the attribute QW");
482 "Verify that we can actually set the attribute LInterm");
485 "Verify that we can actually set the attribute Gentle");
488 "Verify that we can actually set the attribute UseECN");
491 st = queue->GetStats();
496 "There should be no unforced drops");
499 "There should be some unforced marks");
502 queue = CreateObject<RedQueueDisc>();
503 minTh = 30 * modeSize;
504 maxTh = 90 * modeSize;
507 "Verify that we can actually set the attribute MinTh");
510 "Verify that we can actually set the attribute MaxTh");
514 "Verify that we can actually set the attribute MaxSize");
517 "Verify that we can actually set the attribute QW");
520 "Verify that we can actually set the attribute LInterm");
523 "Verify that we can actually set the attribute Gentle");
526 st = queue->GetStats();
530 "There should some dropped packets due to probability mark");
533 queue = CreateObject<RedQueueDisc>();
536 "Verify that we can actually set the attribute MinTh");
539 "Verify that we can actually set the attribute MaxTh");
543 "Verify that we can actually set the attribute MaxSize");
546 "Verify that we can actually set the attribute QW");
549 "Verify that we can actually set the attribute LInterm");
552 "Verify that we can actually set the attribute Gentle");
555 "Verify that we can actually set the attribute FengAdaptive");
558 st = queue->GetStats();
562 "Test 12 should have less drops due to probability mark than test 11");
565 queue = CreateObject<RedQueueDisc>();
566 minTh = 30 * modeSize;
567 maxTh = 90 * modeSize;
570 "Verify that we can actually set the attribute MinTh");
573 "Verify that we can actually set the attribute MaxTh");
577 "Verify that we can actually set the attribute MaxSize");
580 "Verify that we can actually set the attribute QW");
583 "Verify that we can actually set the attribute LInterm");
586 "Verify that we can actually set the attribute Gentle");
589 "Verify that we can actually set the attribute NLRED");
592 st = queue->GetStats();
596 "Test 13 should have less drops due to probability mark than test 11");
606 for (uint32_t i = 0; i < nPkt; i++)
608 queue->Enqueue(Create<RedQueueDiscTestItem>(Create<Packet>(size), dest, ecnCapable));
617 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
AttributeValue implementation for Boolean.
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.
AttributeValue implementation for QueueSize.
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)