23 #include "ns3/red-queue-disc.h"
24 #include "ns3/packet.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/string.h"
27 #include "ns3/double.h"
29 #include "ns3/simulator.h"
55 virtual void AddHeader (
void);
56 virtual bool Mark(
void);
103 virtual void DoRun (
void);
127 :
TestCase (
"Sanity check on the functionality of Adaptive RED")
135 uint32_t modeSize = 1;
138 uint32_t qSize = 300;
148 minTh = minTh * modeSize;
149 maxTh = maxTh * modeSize;
150 qSize = qSize * modeSize;
154 "Verify that we can actually set the attribute MinTh");
156 "Verify that we can actually set the attribute MaxTh");
158 true,
"Verify that we can actually set the attribute MaxSize");
160 "Verify that we can actually set the attribute QW");
161 queue->Initialize ();
165 "There should be zero unforced drops");
169 queue = CreateObject<RedQueueDisc> ();
171 "Verify that we can actually set the attribute MinTh");
173 "Verify that we can actually set the attribute MaxTh");
175 true,
"Verify that we can actually set the attribute MaxSize");
177 "Verify that we can actually set the attribute QW");
179 "Verify that we can actually set the attribute LinkBandwidth");
180 queue->Initialize ();
182 st = queue->GetStats ();
184 "There should be some unforced drops");
188 queue = CreateObject<RedQueueDisc> ();
190 "Verify that we can actually set the attribute MinTh");
192 "Verify that we can actually set the attribute MaxTh");
194 true,
"Verify that we can actually set the attribute MaxSize");
196 "Verify that we can actually set the attribute QW");
197 queue->Initialize ();
199 st = queue->GetStats ();
201 "There should be zero unforced drops");
205 queue = CreateObject<RedQueueDisc> ();
207 "Verify that we can actually set the attribute MinTh");
209 "Verify that we can actually set the attribute MaxTh");
211 true,
"Verify that we can actually set the attribute MaxSize");
213 "Verify that we can actually set the attribute QW");
215 "Verify that we can actually set the attribute LinkBandwidth");
216 queue->Initialize ();
218 st = queue->GetStats ();
220 "There should be some unforced drops");
224 queue = CreateObject<RedQueueDisc> ();
226 "Verify that we can actually set the attribute MinTh");
228 "Verify that we can actually set the attribute MaxTh");
230 true,
"Verify that we can actually set the attribute MaxSize");
232 "Verify that we can actually set the attribute QW");
233 queue->Initialize ();
235 st = queue->GetStats ();
241 queue = CreateObject<RedQueueDisc> ();
243 "Verify that we can actually set the attribute MinTh");
245 "Verify that we can actually set the attribute MaxTh");
247 true,
"Verify that we can actually set the attribute MaxSize");
249 "Verify that we can actually set the attribute QW");
251 "Verify that we can actually set the attribute LinkBandwidth");
252 queue->Initialize ();
254 st = queue->GetStats ();
260 queue = CreateObject<RedQueueDisc> ();
262 "Verify that we can actually set the attribute MinTh");
264 "Verify that we can actually set the attribute MaxTh");
266 true,
"Verify that we can actually set the attribute MaxSize");
267 queue->Initialize ();
269 st = queue->GetStats ();
271 "There should be some unforced drops");
275 queue = CreateObject<RedQueueDisc> ();
277 "Verify that we can actually set the attribute MinTh");
279 "Verify that we can actually set the attribute MaxTh");
281 true,
"Verify that we can actually set the attribute MaxSize");
283 "Verify that we can actually set the attribute LinkBandwidth");
284 queue->Initialize ();
286 st = queue->GetStats ();
288 "There should be zero unforced drops");
292 queue = CreateObject<RedQueueDisc> ();
293 minTh = 5 * modeSize;
294 maxTh = 15 * modeSize;
296 "Verify that we can actually set the attribute MinTh");
298 "Verify that we can actually set the attribute MaxTh");
300 true,
"Verify that we can actually set the attribute MaxSize");
302 "Verify that we can actually set the attribute QW");
304 "Verify that we can actually set the attribute LInterm");
305 queue->Initialize ();
309 st = queue->GetStats ();
312 "There should be some unforced drops");
316 queue = CreateObject<RedQueueDisc> ();
318 true,
"Verify that we can actually set the attribute MaxSize");
320 "Verify that we can actually set the attribute LInterm");
322 "Verify that we can actually set the attribute ARED");
323 queue->Initialize ();
327 st = queue->GetStats ();
336 for (uint32_t i = 0; i < nPkt; i++)
338 queue->Enqueue (Create<AredQueueDiscTestItem> (Create<Packet> (size), dest));
347 for (uint32_t i = 0; i < nPkt; i++)
358 Simulator::Destroy ();
Ared Queue Disc Test Case.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.
Ared Queue Disc Test Item.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
virtual void AddHeader(void)
Add the header to the packet.
AredQueueDiscTestItem(const AredQueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
virtual ~AredQueueDiscTestItem()
Ared Queue Disc Test Suite.
a polymophic address class
AttributeValue implementation for Boolean.
Class for representing data rates.
AttributeValue implementation for DataRate.
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.
Simulation virtual time values and global simulation resolution.
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_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.
AredQueueDiscTestSuite g_aredQueueDiscTestSuite
the test suite
Time Seconds(double value)
Construct a Time in the indicated unit.
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)