24 #include "ns3/red-queue-disc.h"
25 #include "ns3/packet.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/string.h"
28 #include "ns3/double.h"
30 #include "ns3/simulator.h"
51 virtual void AddHeader (
void);
52 virtual bool Mark(
void);
72 m_ecnCapablePacket (ecnCapable)
105 virtual void DoRun (
void);
123 :
TestCase (
"Sanity check on the red queue implementation")
132 uint32_t modeSize = 1;
140 "Verify that we can actually set the attribute MinTh");
142 "Verify that we can actually set the attribute MaxTh");
144 true,
"Verify that we can actually set the attribute MaxSize");
146 "Verify that we can actually set the attribute QW");
155 queue->SetTh (minTh * modeSize, maxTh * modeSize);
156 queue->SetMaxSize (
QueueSize (mode, qSize * modeSize));
169 queue->Initialize ();
170 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 0 * modeSize,
"There should be no packets in there");
171 queue->Enqueue (Create<RedQueueDiscTestItem> (p1, dest,
false));
172 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 1 * modeSize,
"There should be one packet in there");
173 queue->Enqueue (Create<RedQueueDiscTestItem> (p2, dest,
false));
174 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 2 * modeSize,
"There should be two packets in there");
175 queue->Enqueue (Create<RedQueueDiscTestItem> (p3, dest,
false));
176 queue->Enqueue (Create<RedQueueDiscTestItem> (p4, dest,
false));
177 queue->Enqueue (Create<RedQueueDiscTestItem> (p5, dest,
false));
178 queue->Enqueue (Create<RedQueueDiscTestItem> (p6, dest,
false));
179 queue->Enqueue (Create<RedQueueDiscTestItem> (p7, dest,
false));
180 queue->Enqueue (Create<RedQueueDiscTestItem> (p8, dest,
false));
181 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 8 * modeSize,
"There should be eight packets in there");
185 item = queue->Dequeue ();
187 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 7 * modeSize,
"There should be seven packets in there");
190 item = queue->Dequeue ();
192 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 6 * modeSize,
"There should be six packet in there");
195 item = queue->Dequeue ();
197 NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 5 * modeSize,
"There should be five packets in there");
200 item = queue->Dequeue ();
201 item = queue->Dequeue ();
202 item = queue->Dequeue ();
203 item = queue->Dequeue ();
204 item = queue->Dequeue ();
206 item = queue->Dequeue ();
211 queue = CreateObject<RedQueueDisc> ();
212 minTh = 70 * modeSize;
213 maxTh = 150 * modeSize;
214 qSize = 300 * modeSize;
216 "Verify that we can actually set the attribute MinTh");
218 "Verify that we can actually set the attribute MaxTh");
220 true,
"Verify that we can actually set the attribute MaxSize");
221 queue->Initialize ();
225 "There should be zero unforced drops");
227 "There should be zero forced dropps");
229 "There should be zero drops due to queue limit");
245 queue = CreateObject<RedQueueDisc> ();
247 "Verify that we can actually set the attribute MinTh");
249 "Verify that we can actually set the attribute MaxTh");
251 true,
"Verify that we can actually set the attribute MaxSize");
253 "Verify that we can actually set the attribute QW");
254 queue->Initialize ();
256 st = queue->GetStats ();
264 maxTh = 100 * modeSize;
265 queue = CreateObject<RedQueueDisc> ();
267 "Verify that we can actually set the attribute MinTh");
269 "Verify that we can actually set the attribute MaxTh");
271 true,
"Verify that we can actually set the attribute MaxSize");
273 "Verify that we can actually set the attribute QW");
274 queue->Initialize ();
276 st = queue->GetStats ();
284 maxTh = 150 * modeSize;
285 queue = CreateObject<RedQueueDisc> ();
287 "Verify that we can actually set the attribute MinTh");
289 "Verify that we can actually set the attribute MaxTh");
291 true,
"Verify that we can actually set the attribute MaxSize");
293 "Verify that we can actually set the attribute QW");
295 "Verify that we can actually set the attribute LInterm");
296 queue->Initialize ();
298 st = queue->GetStats ();
306 queue = CreateObject<RedQueueDisc> ();
308 "Verify that we can actually set the attribute MinTh");
310 "Verify that we can actually set the attribute MaxTh");
312 true,
"Verify that we can actually set the attribute MaxSize");
314 "Verify that we can actually set the attribute QW");
316 "Verify that we can actually set the attribute Gentle");
317 queue->Initialize ();
319 st = queue->GetStats ();
327 queue = CreateObject<RedQueueDisc> ();
329 "Verify that we can actually set the attribute MinTh");
331 "Verify that we can actually set the attribute MaxTh");
333 true,
"Verify that we can actually set the attribute MaxSize");
335 "Verify that we can actually set the attribute QW");
337 "Verify that we can actually set the attribute Wait");
338 queue->Initialize ();
340 st = queue->GetStats ();
348 queue = CreateObject<RedQueueDisc> ();
349 minTh = 30 * modeSize;
350 maxTh = 90 * modeSize;
352 "Verify that we can actually set the attribute MinTh");
354 "Verify that we can actually set the attribute MaxTh");
356 true,
"Verify that we can actually set the attribute MaxSize");
358 "Verify that we can actually set the attribute QW");
360 "Verify that we can actually set the attribute LInterm");
362 "Verify that we can actually set the attribute Gentle");
364 "Verify that we can actually set the attribute UseECN");
365 queue->Initialize ();
367 st = queue->GetStats ();
370 "There should be some unforced drops");
372 "There should be no unforced marks");
376 queue = CreateObject<RedQueueDisc> ();
378 "Verify that we can actually set the attribute MinTh");
380 "Verify that we can actually set the attribute MaxTh");
382 true,
"Verify that we can actually set the attribute MaxSize");
384 "Verify that we can actually set the attribute QW");
386 "Verify that we can actually set the attribute LInterm");
388 "Verify that we can actually set the attribute Gentle");
390 "Verify that we can actually set the attribute UseECN");
391 queue->Initialize ();
393 st = queue->GetStats ();
396 "There should be some unforced drops");
398 "There should be no unforced marks");
402 queue = CreateObject<RedQueueDisc> ();
404 "Verify that we can actually set the attribute MinTh");
406 "Verify that we can actually set the attribute MaxTh");
408 true,
"Verify that we can actually set the attribute MaxSize");
410 "Verify that we can actually set the attribute QW");
412 "Verify that we can actually set the attribute LInterm");
414 "Verify that we can actually set the attribute Gentle");
416 "Verify that we can actually set the attribute UseECN");
417 queue->Initialize ();
419 st = queue->GetStats ();
422 "There should be no unforced drops");
424 "There should be some unforced marks");
428 queue = CreateObject<RedQueueDisc> ();
429 minTh = 30 * modeSize;
430 maxTh = 90 * modeSize;
432 "Verify that we can actually set the attribute MinTh");
434 "Verify that we can actually set the attribute MaxTh");
436 true,
"Verify that we can actually set the attribute MaxSize");
438 "Verify that we can actually set the attribute QW");
440 "Verify that we can actually set the attribute LInterm");
442 "Verify that we can actually set the attribute Gentle");
443 queue->Initialize ();
445 st = queue->GetStats ();
451 queue = CreateObject<RedQueueDisc> ();
453 "Verify that we can actually set the attribute MinTh");
455 "Verify that we can actually set the attribute MaxTh");
457 true,
"Verify that we can actually set the attribute MaxSize");
459 "Verify that we can actually set the attribute QW");
461 "Verify that we can actually set the attribute LInterm");
463 "Verify that we can actually set the attribute Gentle");
465 "Verify that we can actually set the attribute FengAdaptive");
466 queue->Initialize ();
468 st = queue->GetStats ();
470 NS_TEST_EXPECT_MSG_LT (drop.test12, drop.test11,
"Test 12 should have less drops due to probability mark than test 11");
474 queue = CreateObject<RedQueueDisc> ();
475 minTh = 30 * modeSize;
476 maxTh = 90 * modeSize;
478 "Verify that we can actually set the attribute MinTh");
480 "Verify that we can actually set the attribute MaxTh");
482 true,
"Verify that we can actually set the attribute MaxSize");
484 "Verify that we can actually set the attribute QW");
486 "Verify that we can actually set the attribute LInterm");
488 "Verify that we can actually set the attribute Gentle");
490 "Verify that we can actually set the attribute NLRED");
491 queue->Initialize ();
493 st = queue->GetStats ();
495 NS_TEST_EXPECT_MSG_LT (drop.test13, drop.test11,
"Test 13 should have less drops due to probability mark than test 11");
503 for (uint32_t i = 0; i < nPkt; i++)
505 queue->Enqueue (Create<RedQueueDiscTestItem> (Create<Packet> (size), dest, ecnCapable));
514 Simulator::Destroy ();
Red Queue Disc Test Case.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void RunRedTest(QueueSizeUnit mode)
Run RED test function.
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
Red Queue Disc Test Item.
virtual ~RedQueueDiscTestItem()
virtual void AddHeader(void)
Add the header to the packet.
bool m_ecnCapablePacket
ECN capable packet?
RedQueueDiscTestItem(const RedQueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
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(void) 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_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit 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.
#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_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report 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)