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"
52 virtual void AddHeader (
void);
53 virtual bool Mark(
void);
73 m_ecnCapablePacket (ecnCapable)
106 virtual void DoRun (
void);
124 :
TestCase (
"Sanity check on the red queue implementation")
131 uint32_t pktSize = 0;
133 uint32_t modeSize = 1;
141 "Verify that we can actually set the attribute Mode");
143 "Verify that we can actually set the attribute MinTh");
145 "Verify that we can actually set the attribute MaxTh");
147 "Verify that we can actually set the attribute QueueLimit");
149 "Verify that we can actually set the attribute QW");
153 if (queue->
GetMode () == RedQueueDisc::QUEUE_DISC_MODE_BYTES)
158 queue->
SetTh (minTh * modeSize, maxTh * modeSize);
163 p1 = Create<Packet> (pktSize);
164 p2 = Create<Packet> (pktSize);
165 p3 = Create<Packet> (pktSize);
166 p4 = Create<Packet> (pktSize);
167 p5 = Create<Packet> (pktSize);
168 p6 = Create<Packet> (pktSize);
169 p7 = Create<Packet> (pktSize);
170 p8 = Create<Packet> (pktSize);
174 queue->
Enqueue (Create<RedQueueDiscTestItem> (p1, dest, 0,
false));
176 queue->
Enqueue (Create<RedQueueDiscTestItem> (p2, dest, 0,
false));
178 queue->
Enqueue (Create<RedQueueDiscTestItem> (p3, dest, 0,
false));
179 queue->
Enqueue (Create<RedQueueDiscTestItem> (p4, dest, 0,
false));
180 queue->
Enqueue (Create<RedQueueDiscTestItem> (p5, dest, 0,
false));
181 queue->
Enqueue (Create<RedQueueDiscTestItem> (p6, dest, 0,
false));
182 queue->
Enqueue (Create<RedQueueDiscTestItem> (p7, dest, 0,
false));
183 queue->
Enqueue (Create<RedQueueDiscTestItem> (p8, dest, 0,
false));
196 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
214 queue = CreateObject<RedQueueDisc> ();
215 minTh = 70 * modeSize;
216 maxTh = 150 * modeSize;
217 qSize = 300 * modeSize;
219 "Verify that we can actually set the attribute Mode");
221 "Verify that we can actually set the attribute MinTh");
223 "Verify that we can actually set the attribute MaxTh");
225 "Verify that we can actually set the attribute QueueLimit");
227 Enqueue (queue, pktSize, 300,
false);
230 "There should be zero unforced drops");
232 "There should be zero forced dropps");
234 "There should be zero drops due to queue limit");
250 queue = CreateObject<RedQueueDisc> ();
252 "Verify that we can actually set the attribute Mode");
254 "Verify that we can actually set the attribute MinTh");
256 "Verify that we can actually set the attribute MaxTh");
258 "Verify that we can actually set the attribute QueueLimit");
260 "Verify that we can actually set the attribute QW");
262 Enqueue (queue, pktSize, 300,
false);
271 maxTh = 100 * modeSize;
272 queue = CreateObject<RedQueueDisc> ();
274 "Verify that we can actually set the attribute Mode");
276 "Verify that we can actually set the attribute MinTh");
278 "Verify that we can actually set the attribute MaxTh");
280 "Verify that we can actually set the attribute QueueLimit");
282 "Verify that we can actually set the attribute QW");
284 Enqueue (queue, pktSize, 300,
false);
293 maxTh = 150 * modeSize;
294 queue = CreateObject<RedQueueDisc> ();
296 "Verify that we can actually set the attribute Mode");
298 "Verify that we can actually set the attribute MinTh");
300 "Verify that we can actually set the attribute MaxTh");
302 "Verify that we can actually set the attribute QueueLimit");
304 "Verify that we can actually set the attribute QW");
306 "Verify that we can actually set the attribute LInterm");
308 Enqueue (queue, pktSize, 300,
false);
317 queue = CreateObject<RedQueueDisc> ();
319 "Verify that we can actually set the attribute Mode");
321 "Verify that we can actually set the attribute MinTh");
323 "Verify that we can actually set the attribute MaxTh");
325 "Verify that we can actually set the attribute QueueLimit");
327 "Verify that we can actually set the attribute QW");
329 "Verify that we can actually set the attribute Gentle");
331 Enqueue (queue, pktSize, 300,
false);
340 queue = CreateObject<RedQueueDisc> ();
342 "Verify that we can actually set the attribute Mode");
344 "Verify that we can actually set the attribute MinTh");
346 "Verify that we can actually set the attribute MaxTh");
348 "Verify that we can actually set the attribute QueueLimit");
350 "Verify that we can actually set the attribute QW");
352 "Verify that we can actually set the attribute Wait");
354 Enqueue (queue, pktSize, 300,
false);
363 queue = CreateObject<RedQueueDisc> ();
364 minTh = 30 * modeSize;
365 maxTh = 90 * modeSize;
367 "Verify that we can actually set the attribute Mode");
369 "Verify that we can actually set the attribute MinTh");
371 "Verify that we can actually set the attribute MaxTh");
373 "Verify that we can actually set the attribute QueueLimit");
375 "Verify that we can actually set the attribute QW");
377 "Verify that we can actually set the attribute LInterm");
379 "Verify that we can actually set the attribute Gentle");
381 "Verify that we can actually set the attribute UseECN");
383 Enqueue (queue, pktSize, 300,
false);
387 "There should be some unforced drops");
389 "There should be no unforced marks");
393 queue = CreateObject<RedQueueDisc> ();
395 "Verify that we can actually set the attribute Mode");
397 "Verify that we can actually set the attribute MinTh");
399 "Verify that we can actually set the attribute MaxTh");
401 "Verify that we can actually set the attribute QueueLimit");
403 "Verify that we can actually set the attribute QW");
405 "Verify that we can actually set the attribute LInterm");
407 "Verify that we can actually set the attribute Gentle");
409 "Verify that we can actually set the attribute UseECN");
410 queue->Initialize ();
411 Enqueue (queue, pktSize, 300,
true);
412 st = queue->GetStats ();
415 "There should be some unforced drops");
417 "There should be no unforced marks");
421 queue = CreateObject<RedQueueDisc> ();
423 "Verify that we can actually set the attribute Mode");
425 "Verify that we can actually set the attribute MinTh");
427 "Verify that we can actually set the attribute MaxTh");
429 "Verify that we can actually set the attribute QueueLimit");
431 "Verify that we can actually set the attribute QW");
433 "Verify that we can actually set the attribute LInterm");
435 "Verify that we can actually set the attribute Gentle");
437 "Verify that we can actually set the attribute UseECN");
438 queue->Initialize ();
439 Enqueue (queue, pktSize, 300,
true);
440 st = queue->GetStats ();
443 "There should be no unforced drops");
445 "There should be some unforced marks");
449 queue = CreateObject<RedQueueDisc> ();
450 minTh = 30 * modeSize;
451 maxTh = 90 * modeSize;
453 "Verify that we can actually set the attribute Mode");
455 "Verify that we can actually set the attribute MinTh");
457 "Verify that we can actually set the attribute MaxTh");
459 "Verify that we can actually set the attribute QueueLimit");
461 "Verify that we can actually set the attribute QW");
463 "Verify that we can actually set the attribute LInterm");
465 "Verify that we can actually set the attribute Gentle");
466 queue->Initialize ();
467 Enqueue (queue, pktSize, 300,
false);
468 st = queue->GetStats ();
474 queue = CreateObject<RedQueueDisc> ();
476 "Verify that we can actually set the attribute Mode");
478 "Verify that we can actually set the attribute MinTh");
480 "Verify that we can actually set the attribute MaxTh");
482 "Verify that we can actually set the attribute QueueLimit");
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 FengAdaptive");
491 queue->Initialize ();
492 Enqueue (queue, pktSize, 300,
false);
493 st = queue->GetStats ();
495 NS_TEST_EXPECT_MSG_LT (drop.test12, drop.test11,
"Test 12 should have less drops due to probability mark than test 11");
499 queue = CreateObject<RedQueueDisc> ();
500 minTh = 30 * modeSize;
501 maxTh = 90 * modeSize;
503 "Verify that we can actually set the attribute Mode");
505 "Verify that we can actually set the attribute MinTh");
507 "Verify that we can actually set the attribute MaxTh");
509 "Verify that we can actually set the attribute QueueLimit");
511 "Verify that we can actually set the attribute QW");
513 "Verify that we can actually set the attribute LInterm");
515 "Verify that we can actually set the attribute Gentle");
517 "Verify that we can actually set the attribute NLRED");
518 queue->Initialize ();
519 Enqueue (queue, pktSize, 300,
false);
520 st = queue->GetStats ();
522 NS_TEST_EXPECT_MSG_LT (drop.test13, drop.test11,
"Test 13 should have less drops due to probability mark than test 11");
530 for (uint32_t i = 0; i < nPkt; i++)
532 queue->
Enqueue (Create<RedQueueDiscTestItem> (Create<Packet> (size), dest, 0, ecnCapable));
541 Simulator::Destroy ();
Structure that keeps the queue disc statistics.
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
AttributeValue implementation for Boolean.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
virtual void AddHeader(void)
Add the header to the packet.
uint64_t GetUid(void) const
Returns the packet's Uid.
QueueDiscMode GetMode(void)
Get the operating mode of this queue disc.
#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.
bool m_ecnCapablePacket
ECN capable packet?
This test suite implements a Unit Test.
a polymophic address class
Red Queue Disc Test Suite.
void SetQueueLimit(uint32_t lim)
Set the limit of the queue.
Red Queue Disc Test Item.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
const Stats & GetStats(void)
Retrieve all the collected statistics.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Red Queue Disc Test Case.
virtual ~RedQueueDiscTestItem()
#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.
RedQueueDiscTestSuite g_redQueueTestSuite
the test suite
void RunRedTest(StringValue mode)
Run RED test function.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.