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")
130 uint32_t pktSize = 0;
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);
160 p1 = Create<Packet> (pktSize);
161 p2 = Create<Packet> (pktSize);
162 p3 = Create<Packet> (pktSize);
163 p4 = Create<Packet> (pktSize);
164 p5 = Create<Packet> (pktSize);
165 p6 = Create<Packet> (pktSize);
166 p7 = Create<Packet> (pktSize);
167 p8 = Create<Packet> (pktSize);
171 queue->
Enqueue (Create<RedQueueDiscTestItem> (p1, dest,
false));
173 queue->
Enqueue (Create<RedQueueDiscTestItem> (p2, dest,
false));
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));
193 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (),
"Was this the second packet ?");
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");
222 Enqueue (queue, pktSize, 300,
false);
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");
255 Enqueue (queue, pktSize, 300,
false);
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");
275 Enqueue (queue, pktSize, 300,
false);
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");
297 Enqueue (queue, pktSize, 300,
false);
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");
318 Enqueue (queue, pktSize, 300,
false);
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");
339 Enqueue (queue, pktSize, 300,
false);
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");
366 Enqueue (queue, pktSize, 300,
false);
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 ();
392 Enqueue (queue, pktSize, 300,
true);
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 ();
418 Enqueue (queue, pktSize, 300,
true);
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 ();
444 Enqueue (queue, pktSize, 300,
false);
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 ();
467 Enqueue (queue, pktSize, 300,
false);
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 ();
492 Enqueue (queue, pktSize, 300,
false);
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 ();
Structure that keeps the queue disc statistics.
uint64_t GetUid(void) const
Returns the packet's Uid.
AttributeValue implementation for Boolean.
Class for representing queue sizes.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
uint32_t GetValue() const
Get the underlying value.
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
QueueSizeUnit
Enumeration of the operating modes of queues.
virtual void AddHeader(void)
Add the header to the packet.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
#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?
a polymophic address class
Red Queue Disc Test Suite.
Red Queue Disc Test Item.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Use number of packets for queue size.
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.
void RunRedTest(QueueSizeUnit mode)
Run RED test function.
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Red Queue Disc Test Case.
virtual ~RedQueueDiscTestItem()
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
#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
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
This test suite implements a Unit Test.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Use number of bytes for queue size.
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.