LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2016 NITK Surathkal | 3 * Copyright (c) 2016 NITK Surathkal |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueRef", DoubleValue (5
0)), true, | 231 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueRef", DoubleValue (5
0)), true, |
232 "Verify that we can actually set the attribute QueueRef
"); | 232 "Verify that we can actually set the attribute QueueRef
"); |
233 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", DoubleValue
(qSize)), true, | 233 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", DoubleValue
(qSize)), true, |
234 "Verify that we can actually set the attribute QueueLim
it"); | 234 "Verify that we can actually set the attribute QueueLim
it"); |
235 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("W", DoubleValue (170)), t
rue, | 235 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("W", DoubleValue (170)), t
rue, |
236 "Verify that we can actually set the attribute W"); | 236 "Verify that we can actually set the attribute W"); |
237 queue->Initialize (); | 237 queue->Initialize (); |
238 EnqueueWithDelay (queue, pktSize, 300); | 238 EnqueueWithDelay (queue, pktSize, 300); |
239 Simulator::Stop (Seconds (40)); | 239 Simulator::Stop (Seconds (40)); |
240 Simulator::Run (); | 240 Simulator::Run (); |
241 PiQueueDisc::Stats st = StaticCast<PiQueueDisc> (queue)->GetStats (); | 241 QueueDisc::Stats st = queue->GetStats (); |
242 drop.test2 = st.unforcedDrop; | 242 drop.test2 = st.GetNDroppedPackets (PiQueueDisc::UNFORCED_DROP); |
243 NS_TEST_EXPECT_MSG_NE (drop.test2, 0, "There should be some unforced drops"); | 243 NS_TEST_EXPECT_MSG_NE (drop.test2, 0, "There should be some unforced drops"); |
244 | 244 |
245 | 245 |
246 // test 3: high value of W | 246 // test 3: high value of W |
247 queue = CreateObject<PiQueueDisc> (); | 247 queue = CreateObject<PiQueueDisc> (); |
248 qSize = 300 * modeSize; | 248 qSize = 300 * modeSize; |
249 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, | 249 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true, |
250 "Verify that we can actually set the attribute Mode"); | 250 "Verify that we can actually set the attribute Mode"); |
251 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", UintegerVal
ue (pktSize)), true, | 251 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MeanPktSize", UintegerVal
ue (pktSize)), true, |
252 "Verify that we can actually set the attribute MeanPktS
ize"); | 252 "Verify that we can actually set the attribute MeanPktS
ize"); |
253 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueRef", DoubleValue (5
0)), true, | 253 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueRef", DoubleValue (5
0)), true, |
254 "Verify that we can actually set the attribute QueueRef
"); | 254 "Verify that we can actually set the attribute QueueRef
"); |
255 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", DoubleValue
(qSize)), true, | 255 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("QueueLimit", DoubleValue
(qSize)), true, |
256 "Verify that we can actually set the attribute QueueLim
it"); | 256 "Verify that we can actually set the attribute QueueLim
it"); |
257 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("W", DoubleValue (500)), t
rue, | 257 NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("W", DoubleValue (500)), t
rue, |
258 "Verify that we can actually set the attribute W"); | 258 "Verify that we can actually set the attribute W"); |
259 queue->Initialize (); | 259 queue->Initialize (); |
260 EnqueueWithDelay (queue, pktSize, 300); | 260 EnqueueWithDelay (queue, pktSize, 300); |
261 Simulator::Stop (Seconds (40)); | 261 Simulator::Stop (Seconds (40)); |
262 Simulator::Run (); | 262 Simulator::Run (); |
263 st = StaticCast<PiQueueDisc> (queue)->GetStats (); | 263 st = queue->GetStats (); |
264 drop.test3 = st.unforcedDrop; | 264 drop.test3 = st.GetNDroppedPackets (PiQueueDisc::UNFORCED_DROP); |
265 NS_TEST_EXPECT_MSG_GT (drop.test3, drop.test2, "Test 3 should have more unforc
ed drops than Test 2"); | 265 NS_TEST_EXPECT_MSG_GT (drop.test3, drop.test2, "Test 3 should have more unforc
ed drops than Test 2"); |
266 } | 266 } |
267 | 267 |
268 void | 268 void |
269 PiQueueDiscTestCase::Enqueue (Ptr<PiQueueDisc> queue, uint32_t size, uint32_t nP
kt) | 269 PiQueueDiscTestCase::Enqueue (Ptr<PiQueueDisc> queue, uint32_t size, uint32_t nP
kt) |
270 { | 270 { |
271 Address dest; | 271 Address dest; |
272 for (uint32_t i = 0; i < nPkt; i++) | 272 for (uint32_t i = 0; i < nPkt; i++) |
273 { | 273 { |
274 queue->Enqueue (Create<PiQueueDiscTestItem> (Create<Packet> (size), dest,
0)); | 274 queue->Enqueue (Create<PiQueueDiscTestItem> (Create<Packet> (size), dest,
0)); |
(...skipping 22 matching lines...) Expand all Loading... |
297 | 297 |
298 static class PiQueueDiscTestSuite : public TestSuite | 298 static class PiQueueDiscTestSuite : public TestSuite |
299 { | 299 { |
300 public: | 300 public: |
301 PiQueueDiscTestSuite () | 301 PiQueueDiscTestSuite () |
302 : TestSuite ("pi-queue-disc", UNIT) | 302 : TestSuite ("pi-queue-disc", UNIT) |
303 { | 303 { |
304 AddTestCase (new PiQueueDiscTestCase (), TestCase::QUICK); | 304 AddTestCase (new PiQueueDiscTestCase (), TestCase::QUICK); |
305 } | 305 } |
306 } g_piQueueTestSuite; | 306 } g_piQueueTestSuite; |
LEFT | RIGHT |