Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
2 /* | |
3 * Copyright (c) 2016 NITK Surathkal | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License version 2 as | |
7 * published by the Free Software Foundation; | |
8 * | |
9 * This program is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License | |
15 * along with this program; if not, write to the Free Software | |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 * | |
18 * Author: Shravya Ks <shravya.ks0@gmail.com> | |
19 * | |
20 */ | |
21 | |
22 #include "ns3/test.h" | |
23 #include "ns3/red-queue-disc.h" | |
24 #include "ns3/drop-tail-queue.h" | |
25 #include "ns3/uinteger.h" | |
26 #include "ns3/string.h" | |
27 #include "ns3/double.h" | |
28 #include "ns3/log.h" | |
29 #include "ns3/simulator.h" | |
30 #include "ns3/ipv6-queue-disc-item.h" | |
31 #include "ns3/rng-seed-manager.h" | |
32 | |
33 using namespace ns3; | |
34 | |
35 class EcnIpv6RedQueueDiscTestItem : public Ipv6QueueDiscItem | |
36 { | |
37 public: | |
38 EcnIpv6RedQueueDiscTestItem (Ptr<Packet> p, const Address & addr, uint16_t pro tocol, const Ipv6Header & header); | |
39 virtual ~EcnIpv6RedQueueDiscTestItem (); | |
40 | |
41 private: | |
42 EcnIpv6RedQueueDiscTestItem (); | |
43 EcnIpv6RedQueueDiscTestItem (const EcnIpv6RedQueueDiscTestItem &); | |
44 EcnIpv6RedQueueDiscTestItem &operator = (const EcnIpv6RedQueueDiscTestItem &); | |
45 }; | |
46 | |
47 EcnIpv6RedQueueDiscTestItem::EcnIpv6RedQueueDiscTestItem (Ptr<Packet> p, const A ddress & addr, uint16_t protocol, const Ipv6Header & header) | |
48 : Ipv6QueueDiscItem (p, addr, protocol, header) | |
49 { | |
50 } | |
51 | |
52 EcnIpv6RedQueueDiscTestItem::~EcnIpv6RedQueueDiscTestItem () | |
53 { | |
54 } | |
55 | |
56 class EcnIpv6RedQueueDiscTestCase : public TestCase | |
57 { | |
58 public: | |
59 EcnIpv6RedQueueDiscTestCase (); | |
60 virtual void DoRun (void); | |
61 private: | |
62 void Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nPkt); | |
63 void EnqueueNonEcnCapable (Ptr<RedQueueDisc> queue, uint32_t size, uint32_t nP kt); | |
64 void RunRedTest (StringValue mode); | |
65 }; | |
66 | |
67 EcnIpv6RedQueueDiscTestCase::EcnIpv6RedQueueDiscTestCase () | |
68 : TestCase ("Test the marking behavior for IPv6 ECN for a RED queue") | |
69 { | |
70 } | |
71 | |
72 void | |
73 EcnIpv6RedQueueDiscTestCase::RunRedTest (StringValue mode) | |
74 { | |
75 uint32_t ipPayloadSize = 1000; // bytes | |
76 // modeSize has units of packets when 'mode' is Queue::QUEUE_MODE_PACKETS | |
77 // modeSize has units of bytes when 'mode' is Queue::QUEUE_MODE_BYTES | |
78 uint32_t modeSize = 1; | |
79 double minTh = 2; | |
80 double maxTh = 5; | |
81 uint32_t qSize = 8; | |
82 Ptr<RedQueueDisc> queue = CreateObject<RedQueueDisc> (); | |
83 queue->AssignStreams (1); | |
84 | |
85 // test 1: simple enqueue/dequeue with no drops or marks | |
86 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | |
87 "Verify that we can actually set the attribute Mode"); | |
88 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minT h)), true, | |
89 "Verify that we can actually set the attribute MinTh"); | |
90 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxT h)), true, | |
91 "Verify that we can actually set the attribute MaxTh"); | |
92 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValu e (qSize)), true, | |
93 "Verify that we can actually set the attribute QueueLim it"); | |
94 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)) , true, | |
95 "Verify that we can actually set the attribute QW"); | |
96 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (tr ue)), true, | |
97 "Verify that we can actually set the attribute UseEcn") ; | |
98 | |
99 Address dest; | |
100 | |
101 if (queue->GetMode () == Queue::QUEUE_MODE_BYTES) | |
102 { | |
103 ipPayloadSize = 1000; | |
104 modeSize = ipPayloadSize + 40; | |
105 queue->SetTh (minTh * modeSize, maxTh * modeSize); | |
106 queue->SetQueueLimit (qSize * modeSize); | |
107 } | |
108 | |
109 Ipv6Header hdr, tmp_hdr; | |
110 hdr.SetEcn (Ipv6Header::ECN_ECT0); | |
111 | |
112 Ptr<Packet> p1, p2, p3, p4, p5, p6, p7, p8; | |
113 p1 = Create<Packet> (ipPayloadSize); | |
114 p2 = Create<Packet> (ipPayloadSize); | |
115 p3 = Create<Packet> (ipPayloadSize); | |
116 p4 = Create<Packet> (ipPayloadSize); | |
117 p5 = Create<Packet> (ipPayloadSize); | |
118 | |
119 queue->Initialize (); | |
120 | |
121 Ptr<QueueDiscItem> item; | |
122 | |
123 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets"); | |
124 item = Create<EcnIpv6RedQueueDiscTestItem> (p1, dest, 0, hdr); | |
125 queue->Enqueue (item); | |
126 item = Create<EcnIpv6RedQueueDiscTestItem> (p2, dest, 0, hdr); | |
127 queue->Enqueue (item); | |
128 item = Create<EcnIpv6RedQueueDiscTestItem> (p3, dest, 0, hdr); | |
129 queue->Enqueue (item); | |
130 item = Create<EcnIpv6RedQueueDiscTestItem> (p4, dest, 0, hdr); | |
131 queue->Enqueue (item); | |
132 item = Create<EcnIpv6RedQueueDiscTestItem> (p5, dest, 0, hdr); | |
133 queue->Enqueue (item); | |
134 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets"); | |
135 | |
136 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
137 NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "Remove the first packet"); | |
138 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets"); | |
139 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?"); | |
140 | |
141 NS_TEST_EXPECT_MSG_EQ ((DynamicCast<Ipv6QueueDiscItem>(item)->GetHeader()).Get Ecn (), Ipv6Header::ECN_ECT0, "The packet should be marked"); | |
142 ··· | |
Mohit Tahiliani
2016/11/14 14:17:50
Remove these spaces
| |
143 | |
144 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
145 NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "Remove the second packet"); | |
146 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packet"); | |
147 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?"); | |
148 | |
149 NS_TEST_EXPECT_MSG_EQ ((DynamicCast<Ipv6QueueDiscItem>(item)->GetHeader()).Get Ecn (), Ipv6Header::ECN_ECT0, "The packet should be marked"); | |
150 ··· | |
Mohit Tahiliani
2016/11/14 14:17:50
Remove these spaces
| |
151 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
152 NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "Remove the third packet"); | |
153 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets"); | |
154 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?"); | |
155 | |
156 DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
157 DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
158 | |
159 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
160 NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "There are no packets"); | |
161 | |
162 //test2 : Test with packets which are not ECN-Capable | |
163 | |
164 queue = CreateObject<RedQueueDisc> (); | |
165 | |
166 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | |
167 "Verify that we can actually set the attribute Mode"); | |
168 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minT h)), true, | |
169 "Verify that we can actually set the attribute MinTh"); | |
170 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxT h)), true, | |
171 "Verify that we can actually set the attribute MaxTh"); | |
172 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValu e (qSize)), true, | |
173 "Verify that we can actually set the attribute QueueLim it"); | |
174 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.002)) , true, | |
175 "Verify that we can actually set the attribute QW"); | |
176 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (fa lse)), true, | |
177 "Verify that we can actually set the attribute UseEcn") ; | |
178 | |
179 if (queue->GetMode () == Queue::QUEUE_MODE_BYTES) | |
180 { | |
181 ipPayloadSize = 1000; | |
182 modeSize = ipPayloadSize + 40; | |
183 queue->SetTh (minTh * modeSize, maxTh * modeSize); | |
184 queue->SetQueueLimit (qSize * modeSize); | |
185 } | |
186 | |
187 p1 = Create<Packet> (ipPayloadSize); | |
188 p2 = Create<Packet> (ipPayloadSize); | |
189 p3 = Create<Packet> (ipPayloadSize); | |
190 p4 = Create<Packet> (ipPayloadSize); | |
191 p5 = Create<Packet> (ipPayloadSize); | |
192 | |
193 Ipv6Header hdr1; | |
194 | |
195 queue->Initialize (); | |
196 item = Create<EcnIpv6RedQueueDiscTestItem> (p1, dest, 0, hdr1); | |
197 queue->Enqueue (item); | |
198 item = Create<EcnIpv6RedQueueDiscTestItem> (p2, dest, 0, hdr1); | |
199 queue->Enqueue (item); | |
200 item = Create<EcnIpv6RedQueueDiscTestItem> (p3, dest, 0, hdr1); | |
201 queue->Enqueue (item); | |
202 item = Create<EcnIpv6RedQueueDiscTestItem> (p4, dest, 0, hdr1); | |
203 queue->Enqueue (item); | |
204 item = Create<EcnIpv6RedQueueDiscTestItem> (p5, dest, 0, hdr1); | |
205 queue->Enqueue (item); | |
206 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets"); | |
207 | |
208 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
209 NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "Remove the first packet"); | |
210 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets"); | |
211 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?"); | |
212 | |
213 if (item->GetPacket ()->GetSize ()) | |
214 { | |
215 item->GetPacket ()->PeekHeader (tmp_hdr); | |
216 NS_TEST_EXPECT_MSG_EQ (tmp_hdr.GetEcn (), Ipv6Header::ECN_NotECT, "The pac ket should not be marked"); | |
217 } | |
218 | |
219 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
220 NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "Remove the second packet"); | |
221 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packets"); | |
222 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?"); | |
223 | |
224 if (item->GetPacket ()->GetSize ()) | |
225 { | |
226 item->GetPacket ()->PeekHeader (tmp_hdr); | |
227 NS_TEST_EXPECT_MSG_EQ (tmp_hdr.GetEcn (), Ipv6Header::ECN_NotECT, "The pac ket should not be marked"); | |
228 } | |
229 | |
230 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
231 NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "Remove the third packet"); | |
232 NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets"); | |
233 NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?"); | |
234 | |
235 DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
236 DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
237 item = DynamicCast<Ipv6QueueDiscItem> (queue->Dequeue ()); | |
238 NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "There are no packets"); | |
239 | |
240 | |
241 // test 3: more data, but with no marks or drops | |
242 queue = CreateObject<RedQueueDisc> (); | |
243 minTh = 70 * modeSize; | |
244 maxTh = 150 * modeSize; | |
245 qSize = 300 * modeSize; | |
246 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | |
247 "Verify that we can actually set the attribute Mode"); | |
248 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minT h)), true, | |
249 "Verify that we can actually set the attribute MinTh"); | |
250 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxT h)), true, | |
251 "Verify that we can actually set the attribute MaxTh"); | |
252 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValu e (qSize)), true, | |
253 "Verify that we can actually set the attribute QueueLim it"); | |
254 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (tr ue)), true, | |
255 "Verify that we can actually set the attribute UseEcn") ; | |
256 ·· | |
Mohit Tahiliani
2016/11/14 14:17:50
Remove spaces
| |
257 if (queue->GetMode () == Queue::QUEUE_MODE_BYTES) | |
258 { | |
259 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", Uintege rValue (modeSize)), true, | |
260 "Verify that we can actually set the attribute Mean PktSize"); | |
261 } | |
262 | |
263 queue->Initialize (); | |
264 Enqueue (queue, ipPayloadSize, 300); | |
265 RedQueueDisc::Stats st = queue->GetStats (); | |
266 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 0, "There should zero marked packets d ue to probability mark with this seed, run number, and stream"); | |
267 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 0, "There should zero dropped packets due to probability mark with this seed, run number, and stream"); | |
268 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 0, "There should zero dropped packets du e to hard mark with this seed, run number, and stream"); | |
269 NS_TEST_EXPECT_MSG_EQ (st.qLimDrop, 0, "There should zero dropped packets due to queue full with this seed, run number, and stream"); | |
270 | |
271 | |
272 //test 4: more data which are ECN capable resulting in unforced marks but no u nforced drops | |
273 queue = CreateObject<RedQueueDisc> (); | |
274 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | |
275 "Verify that we can actually set the attribute Mode"); | |
276 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minT h)), true, | |
277 "Verify that we can actually set the attribute MinTh"); | |
278 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxT h)), true, | |
279 "Verify that we can actually set the attribute MaxTh"); | |
280 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValu e (qSize)), true, | |
281 "Verify that we can actually set the attribute QueueLim it"); | |
282 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)) , true, | |
283 "Verify that we can actually set the attribute QW"); | |
284 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (tr ue)), true, | |
285 "Verify that we can actually set the attribute UseEcn") ; | |
286 | |
287 if (queue->GetMode () == Queue::QUEUE_MODE_BYTES) | |
288 { | |
289 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", Uintege rValue (modeSize)), true, | |
290 "Verify that we can actually set the attribute Mean PktSize"); | |
291 } | |
292 queue->Initialize (); | |
293 Enqueue (queue, ipPayloadSize, 300); | |
294 st = queue->GetStats (); | |
295 | |
296 if (queue->GetMode () == Queue::QUEUE_MODE_PACKETS) | |
297 { | |
298 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 0, "There should be no unforced dr opped packets with this seed, run number, and stream"); | |
299 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 27, "There should be 27 marked pac kets with this seed, run number, and stream"); | |
300 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 0, "There should be no forced droppe d packets with this seed, run number, and stream"); | |
301 } | |
302 else | |
303 { | |
304 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 0, "There should be no unforced dr opped packets with this seed, run number, and stream"); | |
305 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 88, "There should be 88 marked pac kets with this seed, run number, and stream"); | |
306 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 0, "There should be no forced droppe d packets with this seed, run number, and stream"); | |
307 } | |
308 · | |
Mohit Tahiliani
2016/11/14 14:17:50
Remove this space
| |
309 //test 5: more data which are not ECN capable resulting in unforced drops but no unforced marks | |
310 queue = CreateObject<RedQueueDisc> (); | |
311 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | |
312 "Verify that we can actually set the attribute Mode"); | |
313 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minT h)), true, | |
314 "Verify that we can actually set the attribute MinTh"); | |
315 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxT h)), true, | |
316 "Verify that we can actually set the attribute MaxTh"); | |
317 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValu e (qSize)), true, | |
318 "Verify that we can actually set the attribute QueueLim it"); | |
319 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)) , true, | |
320 "Verify that we can actually set the attribute QW"); | |
321 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (fa lse)), true, | |
322 "Verify that we can actually set the attribute UseEcn") ; | |
323 | |
324 if (queue->GetMode () == Queue::QUEUE_MODE_BYTES) | |
325 { | |
326 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", Uintege rValue (modeSize)), true, | |
327 "Verify that we can actually set the attribute Mean PktSize"); | |
328 } | |
329 | |
330 queue->Initialize (); | |
331 EnqueueNonEcnCapable (queue, ipPayloadSize, 300); | |
332 st = queue->GetStats (); | |
333 | |
334 if (queue->GetMode () == Queue::QUEUE_MODE_PACKETS) | |
335 { | |
336 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 0, "There should be no unforced ma rk packets with this seed, run number, and stream"); | |
337 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 26, "There should be 26 unforced d ropped packets with this seed, run number, and stream"); | |
338 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 0, "There should be no forced droppe d packets with this seed, run number, and stream"); | |
339 } | |
340 else | |
341 { | |
342 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 0, "There should be no unforced ma rked packets with this seed, run number, and stream"); | |
343 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 24, "There should be 24 unforced d ropped packets with this seed, run number, and stream"); | |
344 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 0, "There should be no forced droppe d packets with this seed, run number, and stream"); | |
345 } | |
346 | |
347 // test 6: There can be forced drops along with unforced marks but no unforced drops when packets are ECN capable | |
348 maxTh = 100 * modeSize; | |
349 queue = CreateObject<RedQueueDisc> (); | |
350 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | |
351 "Verify that we can actually set the attribute Mode"); | |
352 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinTh", DoubleValue (minT h)), true, | |
353 "Verify that we can actually set the attribute MinTh"); | |
354 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxTh", DoubleValue (maxT h)), true, | |
355 "Verify that we can actually set the attribute MaxTh"); | |
356 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", UintegerValu e (qSize)), true, | |
357 "Verify that we can actually set the attribute QueueLim it"); | |
358 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QW", DoubleValue (0.020)) , true, | |
359 "Verify that we can actually set the attribute QW"); | |
360 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (tr ue)), true, | |
361 "Verify that we can actually set the attribute UseEcn") ; | |
362 | |
363 if (queue->GetMode () == Queue::QUEUE_MODE_BYTES) | |
364 { | |
365 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", Uintege rValue (modeSize)), true, | |
366 "Verify that we can actually set the attribute Mean PktSize"); | |
367 } | |
368 queue->Initialize (); | |
369 Enqueue (queue, ipPayloadSize, 300); | |
370 st = queue->GetStats (); | |
371 | |
372 if (queue->GetMode () == Queue::QUEUE_MODE_PACKETS) | |
373 { | |
374 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 0, "There should be no unforced dr opped packets with this seed, run number, and stream"); | |
375 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 62, "There should be 62 unforced m arked packets due to probability mark with this seed, run number, and stream"); | |
376 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 51, "There should be 51 forced drops with this seed, run number, and stream"); | |
377 } | |
378 else | |
379 { | |
380 NS_TEST_EXPECT_MSG_EQ (st.unforcedDrop, 0, "There should be no unforced dr opped packets with this seed, run number, and stream"); | |
381 NS_TEST_EXPECT_MSG_EQ (st.unforcedMark, 124, "There should be 124 unforced marked packets due to probability mark with this seed, run number, and strea m"); | |
382 NS_TEST_EXPECT_MSG_EQ (st.forcedDrop, 51, "There should be 51 forced drops due to queue limit with this seed, run number, and stream"); | |
383 } | |
384 } | |
385 | |
386 void | |
387 EcnIpv6RedQueueDiscTestCase::Enqueue (Ptr<RedQueueDisc> queue, uint32_t size, ui nt32_t nPkt) | |
388 { | |
389 Address dest; | |
390 Ipv6Header hdr; | |
391 hdr.SetEcn (Ipv6Header::ECN_ECT0); | |
392 Ptr<QueueDiscItem> item; | |
393 | |
394 for (uint32_t i = 0; i < nPkt; i++) | |
395 { | |
396 Ptr<Packet> p = Create<Packet> (size); | |
397 item = Create<EcnIpv6RedQueueDiscTestItem> (p, dest, 0, hdr); | |
398 ····· | |
Mohit Tahiliani
2016/11/14 14:17:50
Remove these spaces
| |
399 queue->Enqueue (item); | |
400 } | |
401 } | |
402 | |
403 void | |
404 EcnIpv6RedQueueDiscTestCase::EnqueueNonEcnCapable (Ptr<RedQueueDisc> queue, uint 32_t size, uint32_t nPkt) | |
405 { | |
406 Address dest; | |
407 Ipv6Header hdr; | |
408 Ptr<QueueDiscItem> item; | |
409 | |
410 for (uint32_t i = 0; i < nPkt; i++) | |
411 { | |
412 Ptr<Packet> p = Create<Packet> (size); | |
413 item = Create<EcnIpv6RedQueueDiscTestItem> (p, dest, 0, hdr); | |
414 queue->Enqueue (item); | |
415 | |
416 } | |
417 } | |
418 | |
419 void | |
420 EcnIpv6RedQueueDiscTestCase::DoRun (void) | |
421 { | |
422 RngSeedManager::SetSeed (1); | |
423 RngSeedManager::SetRun (17); | |
424 RunRedTest (StringValue ("QUEUE_MODE_PACKETS")); | |
425 RunRedTest (StringValue ("QUEUE_MODE_BYTES")); | |
426 Simulator::Destroy (); | |
427 | |
428 } | |
429 | |
430 static class EcnIpv6RedQueueDiscTestSuite : public TestSuite | |
431 { | |
432 public: | |
433 EcnIpv6RedQueueDiscTestSuite () | |
434 : TestSuite ("ecn-ipv6-red-queue-disc", UNIT) | |
435 { | |
436 AddTestCase (new EcnIpv6RedQueueDiscTestCase (), TestCase::QUICK); | |
437 } | |
438 } g_redQueueTestSuite; | |
OLD | NEW |