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"
56 virtual void AddHeader (
void);
57 virtual bool Mark(
void);
104 virtual void DoRun (
void);
128 :
TestCase (
"Sanity check on the functionality of Adaptive RED")
135 uint32_t pktSize = 0;
136 uint32_t modeSize = 1;
139 uint32_t qSize = 300;
145 "Verify that we can actually set the attribute Mode");
147 if (queue->
GetMode () == RedQueueDisc::QUEUE_DISC_MODE_BYTES)
151 minTh = minTh * modeSize;
152 maxTh = maxTh * modeSize;
153 qSize = qSize * modeSize;
157 "Verify that we can actually set the attribute MinTh");
159 "Verify that we can actually set the attribute MaxTh");
161 "Verify that we can actually set the attribute QueueLimit");
163 "Verify that we can actually set the attribute QW");
168 "There should be zero unforced drops");
172 queue = CreateObject<RedQueueDisc> ();
174 "Verify that we can actually set the attribute Mode");
176 "Verify that we can actually set the attribute MinTh");
178 "Verify that we can actually set the attribute MaxTh");
180 "Verify that we can actually set the attribute QueueLimit");
182 "Verify that we can actually set the attribute QW");
184 "Verify that we can actually set the attribute LinkBandwidth");
185 queue->Initialize ();
187 st = queue->GetStats ();
189 "There should be some unforced drops");
193 queue = CreateObject<RedQueueDisc> ();
195 "Verify that we can actually set the attribute Mode");
197 "Verify that we can actually set the attribute MinTh");
199 "Verify that we can actually set the attribute MaxTh");
201 "Verify that we can actually set the attribute QueueLimit");
203 "Verify that we can actually set the attribute QW");
204 queue->Initialize ();
206 st = queue->GetStats ();
208 "There should be zero unforced drops");
212 queue = CreateObject<RedQueueDisc> ();
214 "Verify that we can actually set the attribute Mode");
216 "Verify that we can actually set the attribute MinTh");
218 "Verify that we can actually set the attribute MaxTh");
220 "Verify that we can actually set the attribute QueueLimit");
222 "Verify that we can actually set the attribute QW");
224 "Verify that we can actually set the attribute LinkBandwidth");
225 queue->Initialize ();
227 st = queue->GetStats ();
229 "There should be some unforced drops");
233 queue = CreateObject<RedQueueDisc> ();
235 "Verify that we can actually set the attribute Mode");
237 "Verify that we can actually set the attribute MinTh");
239 "Verify that we can actually set the attribute MaxTh");
241 "Verify that we can actually set the attribute QueueLimit");
243 "Verify that we can actually set the attribute QW");
244 queue->Initialize ();
246 st = queue->GetStats ();
252 queue = CreateObject<RedQueueDisc> ();
254 "Verify that we can actually set the attribute Mode");
256 "Verify that we can actually set the attribute MinTh");
258 "Verify that we can actually set the attribute MaxTh");
260 "Verify that we can actually set the attribute QueueLimit");
262 "Verify that we can actually set the attribute QW");
264 "Verify that we can actually set the attribute LinkBandwidth");
265 queue->Initialize ();
267 st = queue->GetStats ();
273 queue = CreateObject<RedQueueDisc> ();
275 "Verify that we can actually set the attribute Mode");
277 "Verify that we can actually set the attribute MinTh");
279 "Verify that we can actually set the attribute MaxTh");
281 "Verify that we can actually set the attribute QueueLimit");
282 queue->Initialize ();
284 st = queue->GetStats ();
286 "There should be some unforced drops");
290 queue = CreateObject<RedQueueDisc> ();
292 "Verify that we can actually set the attribute Mode");
294 "Verify that we can actually set the attribute MinTh");
296 "Verify that we can actually set the attribute MaxTh");
298 "Verify that we can actually set the attribute QueueLimit");
300 "Verify that we can actually set the attribute LinkBandwidth");
301 queue->Initialize ();
303 st = queue->GetStats ();
305 "There should be zero unforced drops");
309 queue = CreateObject<RedQueueDisc> ();
310 minTh = 5 * modeSize;
311 maxTh = 15 * modeSize;
313 "Verify that we can actually set the attribute Mode");
315 "Verify that we can actually set the attribute MinTh");
317 "Verify that we can actually set the attribute MaxTh");
319 "Verify that we can actually set the attribute QueueLimit");
321 "Verify that we can actually set the attribute QW");
323 "Verify that we can actually set the attribute LInterm");
324 queue->Initialize ();
328 st = queue->GetStats ();
331 "There should be some unforced drops");
335 queue = CreateObject<RedQueueDisc> ();
337 "Verify that we can actually set the attribute Mode");
339 "Verify that we can actually set the attribute QueueLimit");
341 "Verify that we can actually set the attribute LInterm");
343 "Verify that we can actually set the attribute ARED");
344 queue->Initialize ();
348 st = queue->GetStats ();
357 for (uint32_t i = 0; i < nPkt; i++)
359 queue->
Enqueue (Create<AredQueueDiscTestItem> (Create<Packet> (size), dest, 0));
368 for (uint32_t i = 0; i < nPkt; i++)
379 Simulator::Destroy ();
Structure that keeps the queue disc statistics.
virtual ~AredQueueDiscTestItem()
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Boolean.
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Hold variables of type string.
Ared Queue Disc Test Suite.
Ared Queue Disc Test Item.
QueueDiscMode GetMode(void)
Get the operating mode of this queue disc.
#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.
This test suite implements a Unit Test.
a polymophic address class
Class for representing data rates.
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
virtual void AddHeader(void)
Add the header to the packet.
const Stats & GetStats(void)
Retrieve all the collected statistics.
void RunAredDiscTest(StringValue mode)
Run ARED queue disc test function.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ared Queue Disc Test Case.
#define NS_TEST_EXPECT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report if not.
AttributeValue implementation for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
AredQueueDiscTestSuite g_aredQueueDiscTestSuite
the test suite
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
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.