23 #include "ns3/red-queue.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/string.h"
26 #include "ns3/double.h"
28 #include "ns3/simulator.h"
36 virtual void DoRun (
void);
43 :
TestCase (
"Sanity check on the red queue implementation")
52 uint32_t modeSize = 1;
60 "Verify that we can actually set the attribute Mode");
62 "Verify that we can actually set the attribute MinTh");
64 "Verify that we can actually set the attribute MaxTh");
66 "Verify that we can actually set the attribute QueueLimit");
68 "Verify that we can actually set the attribute QW");
74 queue->SetTh (minTh * pktSize, maxTh * pktSize);
75 queue->SetQueueLimit (qSize * pktSize);
79 p1 = Create<Packet> (pktSize);
80 p2 = Create<Packet> (pktSize);
81 p3 = Create<Packet> (pktSize);
82 p4 = Create<Packet> (pktSize);
83 p5 = Create<Packet> (pktSize);
84 p6 = Create<Packet> (pktSize);
85 p7 = Create<Packet> (pktSize);
86 p8 = Create<Packet> (pktSize);
99 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 8 * modeSize,
"There should be eight packets in there");
103 p = queue->Dequeue ();
105 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 7 * modeSize,
"There should be seven packets in there");
108 p = queue->Dequeue ();
113 p = queue->Dequeue ();
115 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize,
"There should be five packets in there");
118 p = queue->Dequeue ();
119 p = queue->Dequeue ();
120 p = queue->Dequeue ();
121 p = queue->Dequeue ();
122 p = queue->Dequeue ();
124 p = queue->Dequeue ();
129 queue = CreateObject<RedQueue> ();
130 minTh = 70 * modeSize;
131 maxTh = 150 * modeSize;
132 qSize = 300 * modeSize;
134 "Verify that we can actually set the attribute Mode");
136 "Verify that we can actually set the attribute MinTh");
138 "Verify that we can actually set the attribute MaxTh");
140 "Verify that we can actually set the attribute QueueLimit");
158 queue = CreateObject<RedQueue> ();
160 "Verify that we can actually set the attribute Mode");
162 "Verify that we can actually set the attribute MinTh");
164 "Verify that we can actually set the attribute MaxTh");
166 "Verify that we can actually set the attribute QueueLimit");
168 "Verify that we can actually set the attribute QW");
170 st = StaticCast<RedQueue> (queue)->GetStats ();
176 maxTh = 100 * modeSize;
177 queue = CreateObject<RedQueue> ();
179 "Verify that we can actually set the attribute Mode");
181 "Verify that we can actually set the attribute MinTh");
183 "Verify that we can actually set the attribute MaxTh");
185 "Verify that we can actually set the attribute QueueLimit");
187 "Verify that we can actually set the attribute QW");
189 st = StaticCast<RedQueue> (queue)->GetStats ();
195 maxTh = 150 * modeSize;
196 queue = CreateObject<RedQueue> ();
198 "Verify that we can actually set the attribute Mode");
200 "Verify that we can actually set the attribute MinTh");
202 "Verify that we can actually set the attribute MaxTh");
204 "Verify that we can actually set the attribute QueueLimit");
206 "Verify that we can actually set the attribute QW");
208 "Verify that we can actually set the attribute LInterm");
210 st = StaticCast<RedQueue> (queue)->GetStats ();
216 queue = CreateObject<RedQueue> ();
218 "Verify that we can actually set the attribute Mode");
220 "Verify that we can actually set the attribute MinTh");
222 "Verify that we can actually set the attribute MaxTh");
224 "Verify that we can actually set the attribute QueueLimit");
226 "Verify that we can actually set the attribute QW");
228 "Verify that we can actually set the attribute Gentle");
230 st = StaticCast<RedQueue> (queue)->GetStats ();
236 queue = CreateObject<RedQueue> ();
238 "Verify that we can actually set the attribute Mode");
240 "Verify that we can actually set the attribute MinTh");
242 "Verify that we can actually set the attribute MaxTh");
244 "Verify that we can actually set the attribute QueueLimit");
246 "Verify that we can actually set the attribute QW");
248 "Verify that we can actually set the attribute Wait");
250 st = StaticCast<RedQueue> (queue)->GetStats ();
258 for (uint32_t i = 0; i < nPkt; i++)
260 queue->Enqueue (Create<Packet> (size));