A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
red-queue-disc-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright © 2011 Marcos Talau
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marcos Talau (talau@users.sourceforge.net)
7 * Modified by: Pasquale Imputato <p.imputato@gmail.com>
8 *
9 */
10
11#include "ns3/double.h"
12#include "ns3/log.h"
13#include "ns3/packet.h"
14#include "ns3/red-queue-disc.h"
15#include "ns3/simulator.h"
16#include "ns3/string.h"
17#include "ns3/test.h"
18#include "ns3/uinteger.h"
19
20using namespace ns3;
21
22/**
23 * @ingroup traffic-control-test
24 *
25 * @brief Red Queue Disc Test Item
26 */
28{
29 public:
30 /**
31 * Constructor
32 *
33 * @param p packet
34 * @param addr address
35 * @param ecnCapable ECN capable flag
36 */
37 RedQueueDiscTestItem(Ptr<Packet> p, const Address& addr, bool ecnCapable);
38
39 // Delete default constructor, copy constructor and assignment operator to avoid misuse
43
44 void AddHeader() override;
45 bool Mark() override;
46
47 private:
48 bool m_ecnCapablePacket; ///< ECN capable packet?
49};
50
52 : QueueDiscItem(p, addr, 0),
53 m_ecnCapablePacket(ecnCapable)
54{
55}
56
57void
61
62bool
67
68/**
69 * @ingroup traffic-control-test
70 *
71 * @brief Red Queue Disc Test Case
72 */
74{
75 public:
77 void DoRun() override;
78
79 private:
80 /**
81 * Enqueue function
82 * @param queue the queue disc
83 * @param size the size
84 * @param nPkt the number of packets
85 * @param ecnCapable ECN capable flag
86 */
87 void Enqueue(Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nPkt, bool ecnCapable);
88 /**
89 * Run RED test function
90 * @param mode the mode
91 */
92 void RunRedTest(QueueSizeUnit mode);
93};
94
96 : TestCase("Sanity check on the red queue implementation")
97{
98}
99
100void
102{
103 uint32_t pktSize = 0;
104 // 1 for packets; pktSize for bytes
105 uint32_t modeSize = 1;
106 double minTh = 2;
107 double maxTh = 5;
108 uint32_t qSize = 8;
110
111 // test 1: simple enqueue/dequeue with no drops
112 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
113 true,
114 "Verify that we can actually set the attribute MinTh");
115 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
116 true,
117 "Verify that we can actually set the attribute MaxTh");
119 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
120 true,
121 "Verify that we can actually set the attribute MaxSize");
122 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
123 true,
124 "Verify that we can actually set the attribute QW");
125
126 Address dest;
127
128 if (mode == QueueSizeUnit::BYTES)
129 {
130 // pktSize should be same as MeanPktSize to avoid performance gap between byte and packet
131 // mode
132 pktSize = 500;
133 modeSize = pktSize;
134 queue->SetTh(minTh * modeSize, maxTh * modeSize);
135 queue->SetMaxSize(QueueSize(mode, qSize * modeSize));
136 }
137
138 Ptr<Packet> p1;
139 Ptr<Packet> p2;
140 Ptr<Packet> p3;
141 Ptr<Packet> p4;
142 Ptr<Packet> p5;
143 Ptr<Packet> p6;
144 Ptr<Packet> p7;
145 Ptr<Packet> p8;
154
155 queue->Initialize();
156 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
157 0 * modeSize,
158 "There should be no packets in there");
159 queue->Enqueue(Create<RedQueueDiscTestItem>(p1, dest, false));
160 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
161 1 * modeSize,
162 "There should be one packet in there");
163 queue->Enqueue(Create<RedQueueDiscTestItem>(p2, dest, false));
164 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
165 2 * modeSize,
166 "There should be two packets in there");
167 queue->Enqueue(Create<RedQueueDiscTestItem>(p3, dest, false));
168 queue->Enqueue(Create<RedQueueDiscTestItem>(p4, dest, false));
169 queue->Enqueue(Create<RedQueueDiscTestItem>(p5, dest, false));
170 queue->Enqueue(Create<RedQueueDiscTestItem>(p6, dest, false));
171 queue->Enqueue(Create<RedQueueDiscTestItem>(p7, dest, false));
172 queue->Enqueue(Create<RedQueueDiscTestItem>(p8, dest, false));
173 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
174 8 * modeSize,
175 "There should be eight packets in there");
176
178
179 item = queue->Dequeue();
180 NS_TEST_ASSERT_MSG_NE(item, nullptr, "I want to remove the first packet");
181 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
182 7 * modeSize,
183 "There should be seven packets in there");
184 NS_TEST_ASSERT_MSG_EQ(item->GetPacket()->GetUid(), p1->GetUid(), "was this the first packet ?");
185
186 item = queue->Dequeue();
187 NS_TEST_ASSERT_MSG_NE(item, nullptr, "I want to remove the second packet");
188 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
189 6 * modeSize,
190 "There should be six packet in there");
191 NS_TEST_ASSERT_MSG_EQ(item->GetPacket()->GetUid(),
192 p2->GetUid(),
193 "Was this the second packet ?");
194
195 item = queue->Dequeue();
196 NS_TEST_ASSERT_MSG_NE(item, nullptr, "I want to remove the third packet");
197 NS_TEST_ASSERT_MSG_EQ(queue->GetCurrentSize().GetValue(),
198 5 * modeSize,
199 "There should be five packets in there");
200 NS_TEST_ASSERT_MSG_EQ(item->GetPacket()->GetUid(), p3->GetUid(), "Was this the third packet ?");
201
202 item = queue->Dequeue();
203 item = queue->Dequeue();
204 item = queue->Dequeue();
205 item = queue->Dequeue();
206 item = queue->Dequeue();
207
208 item = queue->Dequeue();
209 NS_TEST_ASSERT_MSG_EQ(item, nullptr, "There are really no packets in there");
210
211 // test 2: more data, but with no drops
213 minTh = 70 * modeSize;
214 maxTh = 150 * modeSize;
215 qSize = 300 * modeSize;
216 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
217 true,
218 "Verify that we can actually set the attribute MinTh");
219 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
220 true,
221 "Verify that we can actually set the attribute MaxTh");
223 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
224 true,
225 "Verify that we can actually set the attribute MaxSize");
226 queue->Initialize();
227 Enqueue(queue, pktSize, 300, false);
228 QueueDisc::Stats st = queue->GetStats();
230 0,
231 "There should be zero unforced drops");
233 0,
234 "There should be zero forced dropps");
236 0,
237 "There should be zero drops due to queue limit");
238
239 // save number of drops from tests
240 struct d
241 {
242 uint32_t test3;
243 uint32_t test4;
244 uint32_t test5;
245 uint32_t test6;
246 uint32_t test7;
247 uint32_t test11;
248 uint32_t test12;
249 uint32_t test13;
250 } drop;
251
252 // test 3: more data, now drops due QW change
254 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
255 true,
256 "Verify that we can actually set the attribute MinTh");
257 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
258 true,
259 "Verify that we can actually set the attribute MaxTh");
261 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
262 true,
263 "Verify that we can actually set the attribute MaxSize");
264 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.020)),
265 true,
266 "Verify that we can actually set the attribute QW");
267 queue->Initialize();
268 Enqueue(queue, pktSize, 300, false);
269 st = queue->GetStats();
273 NS_TEST_ASSERT_MSG_NE(drop.test3, 0, "There should be some dropped packets");
274
275 // test 4: reduced maxTh, this causes more drops
276 maxTh = 100 * modeSize;
278 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
279 true,
280 "Verify that we can actually set the attribute MinTh");
281 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
282 true,
283 "Verify that we can actually set the attribute MaxTh");
285 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
286 true,
287 "Verify that we can actually set the attribute MaxSize");
288 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.020)),
289 true,
290 "Verify that we can actually set the attribute QW");
291 queue->Initialize();
292 Enqueue(queue, pktSize, 300, false);
293 st = queue->GetStats();
297 NS_TEST_ASSERT_MSG_GT(drop.test4, drop.test3, "Test 4 should have more drops than test 3");
298
299 // test 5: change drop probability to a high value (LInterm)
300 maxTh = 150 * modeSize;
302 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
303 true,
304 "Verify that we can actually set the attribute MinTh");
305 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
306 true,
307 "Verify that we can actually set the attribute MaxTh");
309 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
310 true,
311 "Verify that we can actually set the attribute MaxSize");
312 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.020)),
313 true,
314 "Verify that we can actually set the attribute QW");
315 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(5)),
316 true,
317 "Verify that we can actually set the attribute LInterm");
318 queue->Initialize();
319 Enqueue(queue, pktSize, 300, false);
320 st = queue->GetStats();
324 NS_TEST_ASSERT_MSG_GT(drop.test5, drop.test3, "Test 5 should have more drops than test 3");
325
326 // test 6: disable Gentle param
328 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
329 true,
330 "Verify that we can actually set the attribute MinTh");
331 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
332 true,
333 "Verify that we can actually set the attribute MaxTh");
335 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
336 true,
337 "Verify that we can actually set the attribute MaxSize");
338 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.020)),
339 true,
340 "Verify that we can actually set the attribute QW");
341 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(false)),
342 true,
343 "Verify that we can actually set the attribute Gentle");
344 queue->Initialize();
345 Enqueue(queue, pktSize, 300, false);
346 st = queue->GetStats();
350 NS_TEST_ASSERT_MSG_GT(drop.test6, drop.test3, "Test 6 should have more drops than test 3");
351
352 // test 7: disable Wait param
354 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
355 true,
356 "Verify that we can actually set the attribute MinTh");
357 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
358 true,
359 "Verify that we can actually set the attribute MaxTh");
361 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
362 true,
363 "Verify that we can actually set the attribute MaxSize");
364 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.020)),
365 true,
366 "Verify that we can actually set the attribute QW");
367 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Wait", BooleanValue(false)),
368 true,
369 "Verify that we can actually set the attribute Wait");
370 queue->Initialize();
371 Enqueue(queue, pktSize, 300, false);
372 st = queue->GetStats();
376 NS_TEST_ASSERT_MSG_GT(drop.test7, drop.test3, "Test 7 should have more drops than test 3");
377
378 // test 8: RED queue disc is ECN enabled, but packets are not ECN capable
380 minTh = 30 * modeSize;
381 maxTh = 90 * modeSize;
382 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
383 true,
384 "Verify that we can actually set the attribute MinTh");
385 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
386 true,
387 "Verify that we can actually set the attribute MaxTh");
389 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
390 true,
391 "Verify that we can actually set the attribute MaxSize");
392 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
393 true,
394 "Verify that we can actually set the attribute QW");
395 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(2)),
396 true,
397 "Verify that we can actually set the attribute LInterm");
398 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(true)),
399 true,
400 "Verify that we can actually set the attribute Gentle");
401 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("UseEcn", BooleanValue(true)),
402 true,
403 "Verify that we can actually set the attribute UseECN");
404 queue->Initialize();
405 Enqueue(queue, pktSize, 300, false);
406 st = queue->GetStats();
407 // Packets are not ECN capable, so there should be only unforced drops, no unforced marks
409 0,
410 "There should be some unforced drops");
412 0,
413 "There should be no unforced marks");
414
415 // test 9: Packets are ECN capable, but RED queue disc is not ECN enabled
417 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
418 true,
419 "Verify that we can actually set the attribute MinTh");
420 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
421 true,
422 "Verify that we can actually set the attribute MaxTh");
424 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
425 true,
426 "Verify that we can actually set the attribute MaxSize");
427 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
428 true,
429 "Verify that we can actually set the attribute QW");
430 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(2)),
431 true,
432 "Verify that we can actually set the attribute LInterm");
433 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(true)),
434 true,
435 "Verify that we can actually set the attribute Gentle");
436 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("UseEcn", BooleanValue(false)),
437 true,
438 "Verify that we can actually set the attribute UseECN");
439 queue->Initialize();
440 Enqueue(queue, pktSize, 300, true);
441 st = queue->GetStats();
442 // RED queue disc is not ECN enabled, so there should be only unforced drops, no unforced marks
444 0,
445 "There should be some unforced drops");
447 0,
448 "There should be no unforced marks");
449
450 // test 10: Packets are ECN capable and RED queue disc is ECN enabled
452 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
453 true,
454 "Verify that we can actually set the attribute MinTh");
455 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
456 true,
457 "Verify that we can actually set the attribute MaxTh");
459 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
460 true,
461 "Verify that we can actually set the attribute MaxSize");
462 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
463 true,
464 "Verify that we can actually set the attribute QW");
465 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(2)),
466 true,
467 "Verify that we can actually set the attribute LInterm");
468 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(true)),
469 true,
470 "Verify that we can actually set the attribute Gentle");
471 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("UseEcn", BooleanValue(true)),
472 true,
473 "Verify that we can actually set the attribute UseECN");
474 queue->Initialize();
475 Enqueue(queue, pktSize, 300, true);
476 st = queue->GetStats();
477 // Packets are ECN capable, RED queue disc is ECN enabled; there should be only unforced marks,
478 // no unforced drops
480 0,
481 "There should be no unforced drops");
483 0,
484 "There should be some unforced marks");
485
486 // test 11: RED with default parameter settings, linear drop probability and fixed m_curMaxP
488 minTh = 30 * modeSize;
489 maxTh = 90 * modeSize;
490 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
491 true,
492 "Verify that we can actually set the attribute MinTh");
493 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
494 true,
495 "Verify that we can actually set the attribute MaxTh");
497 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
498 true,
499 "Verify that we can actually set the attribute MaxSize");
500 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
501 true,
502 "Verify that we can actually set the attribute QW");
503 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(2)),
504 true,
505 "Verify that we can actually set the attribute LInterm");
506 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(true)),
507 true,
508 "Verify that we can actually set the attribute Gentle");
509 queue->Initialize();
510 Enqueue(queue, pktSize, 300, false);
511 st = queue->GetStats();
513 NS_TEST_ASSERT_MSG_NE(drop.test11,
514 0,
515 "There should some dropped packets due to probability mark");
516
517 // test 12: Feng's Adaptive RED with default parameter settings and varying m_curMaxP
519 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
520 true,
521 "Verify that we can actually set the attribute MinTh");
522 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
523 true,
524 "Verify that we can actually set the attribute MaxTh");
526 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
527 true,
528 "Verify that we can actually set the attribute MaxSize");
529 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
530 true,
531 "Verify that we can actually set the attribute QW");
532 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(2)),
533 true,
534 "Verify that we can actually set the attribute LInterm");
535 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(true)),
536 true,
537 "Verify that we can actually set the attribute Gentle");
538 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("FengAdaptive", BooleanValue(true)),
539 true,
540 "Verify that we can actually set the attribute FengAdaptive");
541 queue->Initialize();
542 Enqueue(queue, pktSize, 300, false);
543 st = queue->GetStats();
545 NS_TEST_ASSERT_MSG_LT(drop.test12,
546 drop.test11,
547 "Test 12 should have less drops due to probability mark than test 11");
548
549 // test 13: RED with Nonlinear drop probability
551 minTh = 30 * modeSize;
552 maxTh = 90 * modeSize;
553 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MinTh", DoubleValue(minTh)),
554 true,
555 "Verify that we can actually set the attribute MinTh");
556 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("MaxTh", DoubleValue(maxTh)),
557 true,
558 "Verify that we can actually set the attribute MaxTh");
560 queue->SetAttributeFailSafe("MaxSize", QueueSizeValue(QueueSize(mode, qSize))),
561 true,
562 "Verify that we can actually set the attribute MaxSize");
563 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("QW", DoubleValue(0.002)),
564 true,
565 "Verify that we can actually set the attribute QW");
566 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("LInterm", DoubleValue(2)),
567 true,
568 "Verify that we can actually set the attribute LInterm");
569 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("Gentle", BooleanValue(true)),
570 true,
571 "Verify that we can actually set the attribute Gentle");
572 NS_TEST_ASSERT_MSG_EQ(queue->SetAttributeFailSafe("NLRED", BooleanValue(true)),
573 true,
574 "Verify that we can actually set the attribute NLRED");
575 queue->Initialize();
576 Enqueue(queue, pktSize, 300, false);
577 st = queue->GetStats();
579 NS_TEST_ASSERT_MSG_LT(drop.test13,
580 drop.test11,
581 "Test 13 should have less drops due to probability mark than test 11");
582}
583
584void
586 uint32_t size,
587 uint32_t nPkt,
588 bool ecnCapable)
589{
590 Address dest;
591 for (uint32_t i = 0; i < nPkt; i++)
592 {
593 queue->Enqueue(Create<RedQueueDiscTestItem>(Create<Packet>(size), dest, ecnCapable));
594 }
595}
596
597void
599{
600 RunRedTest(QueueSizeUnit::PACKETS);
601 RunRedTest(QueueSizeUnit::BYTES);
603}
604
605/**
606 * @ingroup traffic-control-test
607 *
608 * @brief Red Queue Disc Test Suite
609 */
610static class RedQueueDiscTestSuite : public TestSuite
611{
612 public:
614 : TestSuite("red-queue-disc", Type::UNIT)
615 {
616 AddTestCase(new RedQueueDiscTestCase(), TestCase::Duration::QUICK);
617 }
618} g_redQueueTestSuite; ///< the test suite
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
Definition address.h:90
AttributeValue implementation for Boolean.
Definition boolean.h:26
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Smart pointer class similar to boost::intrusive_ptr.
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.
Definition queue-disc.h:511
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition queue-item.h:122
Class for representing queue sizes.
Definition queue-size.h:85
AttributeValue implementation for QueueSize.
Definition queue-size.h:210
static constexpr const char * FORCED_DROP
Forced drops, m_qAvg > m_maxTh.
static constexpr const char * UNFORCED_DROP
Early probability drops.
static constexpr const char * UNFORCED_MARK
Early probability marks.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
static constexpr auto UNIT
Definition test.h:1291
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
QueueSizeUnit
Enumeration of the operating modes of queues.
Definition queue-size.h:33
#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.
Definition test.h:699
#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.
Definition test.h:134
#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.
Definition test.h:554
#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.
Definition test.h:864
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.
Definition queue-disc.h:177
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)