spot-checked few points of count and recInvSqrt draft
authorAnh Nguyen <trucanh524@gmail.com>
Tue, 19 Aug 2014 13:59:16 -0500
changeset 10854 715be83c05df
parent 10853 2210c2f068b7
child 10855 cc364a7ff1ae
spot-checked few points of count and recInvSqrt
src/internet/model/codel-queue.cc
src/internet/test/codel-queue-test-suite.cc
--- a/src/internet/model/codel-queue.cc	Mon Aug 18 18:57:20 2014 -0500
+++ b/src/internet/model/codel-queue.cc	Tue Aug 19 13:59:16 2014 -0500
@@ -215,6 +215,7 @@
 CoDelQueue::NewtonStep (void)
 {
   NS_LOG_FUNCTION (this); 
+  NS_LOG_LOGIC ("m_count: " << m_count << "m_recInvSqrt: " << m_recInvSqrt);
   uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT;
   uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
   uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2);
--- a/src/internet/test/codel-queue-test-suite.cc	Mon Aug 18 18:57:20 2014 -0500
+++ b/src/internet/test/codel-queue-test-suite.cc	Tue Aug 19 13:59:16 2014 -0500
@@ -241,26 +241,26 @@
 {
   Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
 
-  // Test across the expected operational range of CoDelQueue's m_count and m_recInvSqrt variables
-  uint32_t MIN_COUNT = 5;
-  uint32_t MAX_COUNT = 10;
-  uint16_t MIN_INV_SQRT = 5;
-  uint16_t MAX_INV_SQRT = 10;
-  for (uint32_t i = MIN_COUNT; i < MAX_COUNT; i++)
-  {
-	for (uint16_t j = MIN_INV_SQRT; j < MAX_INV_SQRT; j++)
-	{
-	  queue->m_count = i;
-	  queue->m_recInvSqrt = j;
-	  queue->NewtonStep ();
-	  // Test that ns-3 value is exactly the same as the Linux value
-	  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (i,j), queue->m_recInvSqrt,
-			                                 "ns-3 NewtonStep() fails to match Linux equivalent");
-	}
-  }
+  // Spot check a few points in the expected operational range of CoDelQueue's m_count and m_recInvSqrt variables
+  uint32_t count = 2;
+  uint16_t recInvSqrt = 65535;
+  queue->m_count = count;
+  queue->m_recInvSqrt = recInvSqrt;
+  queue->NewtonStep ();
+  // Test that ns-3 value is exactly the same as the Linux value
+  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (count, recInvSqrt), queue->m_recInvSqrt,
+ 			                                 "ns-3 NewtonStep() fails to match Linux equivalent");
+
+  count = 4;
+  recInvSqrt = 36864;
+  queue->m_count = count;
+  queue->m_recInvSqrt = recInvSqrt;
+  queue->NewtonStep ();
+  // Test that ns-3 value is exactly the same as the Linux value
+  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (count, recInvSqrt), queue->m_recInvSqrt,
+   			                                 "ns-3 NewtonStep() fails to match Linux equivalent");
 }
 
-
 // Test 4: enqueue/dequeue with drops according to CoDel algorithm
 class CoDelQueueBasicDrop : public TestCase
 {