21 #include "ns3/double.h"
23 #include "ns3/packet.h"
24 #include "ns3/red-queue-disc.h"
25 #include "ns3/simulator.h"
26 #include "ns3/string.h"
28 #include "ns3/uinteger.h"
60 void AddHeader()
override;
93 void DoRun()
override;
118 :
TestCase(
"Sanity check on the functionality of Adaptive RED")
126 uint32_t modeSize = 1;
129 uint32_t qSize = 300;
139 minTh = minTh * modeSize;
140 maxTh = maxTh * modeSize;
141 qSize = qSize * modeSize;
146 "Verify that we can actually set the attribute MinTh");
149 "Verify that we can actually set the attribute MaxTh");
151 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
153 "Verify that we can actually set the attribute MaxSize");
156 "Verify that we can actually set the attribute QW");
162 "There should be zero unforced drops");
165 queue = CreateObject<RedQueueDisc>();
168 "Verify that we can actually set the attribute MinTh");
171 "Verify that we can actually set the attribute MaxTh");
173 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
175 "Verify that we can actually set the attribute MaxSize");
178 "Verify that we can actually set the attribute QW");
180 queue->SetAttributeFailSafe(
"LinkBandwidth", DataRateValue(
DataRate(
"0.015Mbps"))),
182 "Verify that we can actually set the attribute LinkBandwidth");
185 st = queue->GetStats();
188 "There should be some unforced drops");
191 queue = CreateObject<RedQueueDisc>();
194 "Verify that we can actually set the attribute MinTh");
197 "Verify that we can actually set the attribute MaxTh");
199 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
201 "Verify that we can actually set the attribute MaxSize");
204 "Verify that we can actually set the attribute QW");
207 st = queue->GetStats();
210 "There should be zero unforced drops");
213 queue = CreateObject<RedQueueDisc>();
216 "Verify that we can actually set the attribute MinTh");
219 "Verify that we can actually set the attribute MaxTh");
221 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
223 "Verify that we can actually set the attribute MaxSize");
226 "Verify that we can actually set the attribute QW");
228 queue->SetAttributeFailSafe(
"LinkBandwidth", DataRateValue(
DataRate(
"0.015Mbps"))),
230 "Verify that we can actually set the attribute LinkBandwidth");
233 st = queue->GetStats();
236 "There should be some unforced drops");
239 queue = CreateObject<RedQueueDisc>();
242 "Verify that we can actually set the attribute MinTh");
245 "Verify that we can actually set the attribute MaxTh");
247 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
249 "Verify that we can actually set the attribute MaxSize");
252 "Verify that we can actually set the attribute QW");
255 st = queue->GetStats();
260 queue = CreateObject<RedQueueDisc>();
263 "Verify that we can actually set the attribute MinTh");
266 "Verify that we can actually set the attribute MaxTh");
268 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
270 "Verify that we can actually set the attribute MaxSize");
273 "Verify that we can actually set the attribute QW");
275 queue->SetAttributeFailSafe(
"LinkBandwidth", DataRateValue(
DataRate(
"0.015Mbps"))),
277 "Verify that we can actually set the attribute LinkBandwidth");
280 st = queue->GetStats();
286 queue = CreateObject<RedQueueDisc>();
289 "Verify that we can actually set the attribute MinTh");
292 "Verify that we can actually set the attribute MaxTh");
294 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
296 "Verify that we can actually set the attribute MaxSize");
299 st = queue->GetStats();
302 "There should be some unforced drops");
306 queue = CreateObject<RedQueueDisc>();
309 "Verify that we can actually set the attribute MinTh");
312 "Verify that we can actually set the attribute MaxTh");
314 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
316 "Verify that we can actually set the attribute MaxSize");
318 queue->SetAttributeFailSafe(
"LinkBandwidth", DataRateValue(
DataRate(
"150Mbps"))),
320 "Verify that we can actually set the attribute LinkBandwidth");
323 st = queue->GetStats();
326 "There should be zero unforced drops");
329 queue = CreateObject<RedQueueDisc>();
330 minTh = 5 * modeSize;
331 maxTh = 15 * modeSize;
334 "Verify that we can actually set the attribute MinTh");
337 "Verify that we can actually set the attribute MaxTh");
339 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
341 "Verify that we can actually set the attribute MaxSize");
344 "Verify that we can actually set the attribute QW");
347 "Verify that we can actually set the attribute LInterm");
352 st = queue->GetStats();
356 "There should be some unforced drops");
359 queue = CreateObject<RedQueueDisc>();
361 queue->SetAttributeFailSafe(
"MaxSize", QueueSizeValue(
QueueSize(mode, qSize))),
363 "Verify that we can actually set the attribute MaxSize");
366 "Verify that we can actually set the attribute LInterm");
369 "Verify that we can actually set the attribute ARED");
374 st = queue->GetStats();
383 for (uint32_t i = 0; i < nPkt; i++)
385 queue->Enqueue(Create<AredQueueDiscTestItem>(Create<Packet>(size), dest));
394 for (uint32_t i = 0; i < nPkt; i++)
396 Simulator::Schedule(
Time(
Seconds((i + 1) * delay)),
410 Simulator::Destroy();
Ared Queue Disc Test Case.
void RunAredDiscTest(QueueSizeUnit mode)
Run ARED queue disc test function.
void Enqueue(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
void EnqueueWithDelay(Ptr< RedQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue with delay function.
void DoRun() override
Implementation to actually run this TestCase.
Ared Queue Disc Test Item.
AredQueueDiscTestItem()=delete
void AddHeader() override
Add the header to the packet.
AredQueueDiscTestItem(const AredQueueDiscTestItem &)=delete
bool Mark() override
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
AredQueueDiscTestItem & operator=(const AredQueueDiscTestItem &)=delete
~AredQueueDiscTestItem() override
Ared Queue Disc Test Suite.
a polymophic address class
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
AredQueueDiscTestSuite g_aredQueueDiscTestSuite
the test suite
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
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 pktSize
packet size used for the simulation (in bytes)