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"
60 virtual void AddHeader (
void);
61 virtual bool Mark(
void);
97 virtual void DoRun (
void);
121 :
TestCase (
"Sanity check on the functionality of Adaptive RED")
129 uint32_t modeSize = 1;
132 uint32_t qSize = 300;
142 minTh = minTh * modeSize;
143 maxTh = maxTh * modeSize;
144 qSize = qSize * modeSize;
148 "Verify that we can actually set the attribute MinTh");
150 "Verify that we can actually set the attribute MaxTh");
152 true,
"Verify that we can actually set the attribute MaxSize");
154 "Verify that we can actually set the attribute QW");
155 queue->Initialize ();
159 "There should be zero unforced drops");
163 queue = CreateObject<RedQueueDisc> ();
165 "Verify that we can actually set the attribute MinTh");
167 "Verify that we can actually set the attribute MaxTh");
169 true,
"Verify that we can actually set the attribute MaxSize");
171 "Verify that we can actually set the attribute QW");
173 "Verify that we can actually set the attribute LinkBandwidth");
174 queue->Initialize ();
176 st = queue->GetStats ();
178 "There should be some unforced drops");
182 queue = CreateObject<RedQueueDisc> ();
184 "Verify that we can actually set the attribute MinTh");
186 "Verify that we can actually set the attribute MaxTh");
188 true,
"Verify that we can actually set the attribute MaxSize");
190 "Verify that we can actually set the attribute QW");
191 queue->Initialize ();
193 st = queue->GetStats ();
195 "There should be zero unforced drops");
199 queue = CreateObject<RedQueueDisc> ();
201 "Verify that we can actually set the attribute MinTh");
203 "Verify that we can actually set the attribute MaxTh");
205 true,
"Verify that we can actually set the attribute MaxSize");
207 "Verify that we can actually set the attribute QW");
209 "Verify that we can actually set the attribute LinkBandwidth");
210 queue->Initialize ();
212 st = queue->GetStats ();
214 "There should be some unforced drops");
218 queue = CreateObject<RedQueueDisc> ();
220 "Verify that we can actually set the attribute MinTh");
222 "Verify that we can actually set the attribute MaxTh");
224 true,
"Verify that we can actually set the attribute MaxSize");
226 "Verify that we can actually set the attribute QW");
227 queue->Initialize ();
229 st = queue->GetStats ();
235 queue = CreateObject<RedQueueDisc> ();
237 "Verify that we can actually set the attribute MinTh");
239 "Verify that we can actually set the attribute MaxTh");
241 true,
"Verify that we can actually set the attribute MaxSize");
243 "Verify that we can actually set the attribute QW");
245 "Verify that we can actually set the attribute LinkBandwidth");
246 queue->Initialize ();
248 st = queue->GetStats ();
254 queue = CreateObject<RedQueueDisc> ();
256 "Verify that we can actually set the attribute MinTh");
258 "Verify that we can actually set the attribute MaxTh");
260 true,
"Verify that we can actually set the attribute MaxSize");
261 queue->Initialize ();
263 st = queue->GetStats ();
265 "There should be some unforced drops");
269 queue = CreateObject<RedQueueDisc> ();
271 "Verify that we can actually set the attribute MinTh");
273 "Verify that we can actually set the attribute MaxTh");
275 true,
"Verify that we can actually set the attribute MaxSize");
277 "Verify that we can actually set the attribute LinkBandwidth");
278 queue->Initialize ();
280 st = queue->GetStats ();
282 "There should be zero unforced drops");
286 queue = CreateObject<RedQueueDisc> ();
287 minTh = 5 * modeSize;
288 maxTh = 15 * modeSize;
290 "Verify that we can actually set the attribute MinTh");
292 "Verify that we can actually set the attribute MaxTh");
294 true,
"Verify that we can actually set the attribute MaxSize");
296 "Verify that we can actually set the attribute QW");
298 "Verify that we can actually set the attribute LInterm");
299 queue->Initialize ();
303 st = queue->GetStats ();
306 "There should be some unforced drops");
310 queue = CreateObject<RedQueueDisc> ();
312 true,
"Verify that we can actually set the attribute MaxSize");
314 "Verify that we can actually set the attribute LInterm");
316 "Verify that we can actually set the attribute ARED");
317 queue->Initialize ();
321 st = queue->GetStats ();
330 for (uint32_t i = 0; i < nPkt; i++)
332 queue->Enqueue (Create<AredQueueDiscTestItem> (Create<Packet> (size), dest));
341 for (uint32_t i = 0; i < nPkt; i++)
352 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 &)=delete
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.
AttributeValue implementation for QueueSize.
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_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.
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)