--- a/src/internet/test/codel-queue-test-suite.cc Tue Aug 19 15:38:03 2014 -0500
+++ b/src/internet/test/codel-queue-test-suite.cc Tue Aug 19 17:04:46 2014 -0500
@@ -248,7 +248,8 @@
{
Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
- // Spot check a few points in the expected operational range of CoDelQueue's m_count and m_recInvSqrt variables
+ // 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;
@@ -275,7 +276,6 @@
public:
CoDelQueueControlLawTest ();
virtual void DoRun (void);
- // The following routine borrowed from Linux codel.h
uint32_t _codel_control_law (Ptr<CoDelQueue> queue, uint32_t t);
};
@@ -284,19 +284,35 @@
{
}
-// The following code borrowed from Linux codel.h, except the addition of queue parameter
+// The following code borrowed from Linux codel.h,
+// except the addition of queue parameter
uint32_t
CoDelQueueControlLawTest::_codel_control_law (Ptr<CoDelQueue> queue, uint32_t t)
{
return t + _reciprocal_scale(queue->Time2CoDel (queue->m_interval), queue->m_recInvSqrt << REC_INV_SQRT_SHIFT_ns3);
}
+// End Linux borrrow
void
CoDelQueueControlLawTest::DoRun (void)
{
Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
- NS_TEST_ASSERT_MSG_NE (_codel_control_law (queue, 292299), queue->ControlLaw (292249),
- "ns-3 NewtonStep() fails to match Linux equivalent");
+
+ /* Spot check a few points of m_dropNext
+ The integer approximations in Linux should be within
+ 2% of the true floating point value obtained in ns-3
+ */
+ uint32_t dropNextTestVals [4] = {292299, 341128, 9804717, 55885007};
+
+ for (int i = 0; i < 4; ++i)
+ {
+ uint32_t ns3Result = queue->ControlLaw (dropNextTestVals[i]);
+ uint32_t upperBound = ns3Result + 0.02 * ns3Result;
+ uint32_t lowerBound = ns3Result - 0.02 * ns3Result;
+ uint32_t linuxResult = _codel_control_law (queue, dropNextTestVals[i]);
+ NS_TEST_EXPECT_MSG_EQ ((lowerBound < linuxResult || linuxResult < upperBound), true,
+ "Linux result should stay within 2% of ns-3 result");
+ }
}
// Test 5: enqueue/dequeue with drops according to CoDel algorithm