diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 280def33b..6d59d21f4 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -28,6 +28,7 @@ New user-visible features Bugs fixed ---------- - Bug 1974 - CalculateTxTime should return a Time, not a double +- Bug 2070 - Wrong report of Packets and Bytes stored in CoDeL - Bug 2073 - NDisc cache entries update timer might be stuck in a loop Known issues diff --git a/src/internet/model/codel-queue.cc b/src/internet/model/codel-queue.cc index a07584f25..84c1f5878 100644 --- a/src/internet/model/codel-queue.cc +++ b/src/internet/model/codel-queue.cc @@ -399,6 +399,12 @@ CoDelQueue::DoDequeue (void) // hence the while loop. NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << p); Drop (p); + + // p was in queue, trace dequeue and update stats manually + m_traceDequeue (p); + m_nBytes -= p->GetSize (); + m_nPackets--; + ++m_dropCount; ++m_count; NewtonStep (); @@ -444,6 +450,12 @@ CoDelQueue::DoDequeue (void) NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << p << " and entering the dropping state"); ++m_dropCount; Drop (p); + + // p was in queue, trace the dequeue and update stats manually + m_traceDequeue (p); + m_nBytes -= p->GetSize (); + m_nPackets--; + if (m_packets.empty ()) { m_dropping = false; diff --git a/src/internet/test/codel-queue-test-suite.cc b/src/internet/test/codel-queue-test-suite.cc index 5ed57a328..c96388619 100644 --- a/src/internet/test/codel-queue-test-suite.cc +++ b/src/internet/test/codel-queue-test-suite.cc @@ -61,6 +61,21 @@ class CoDelQueueBasicEnqueueDequeue : public TestCase public: CoDelQueueBasicEnqueueDequeue (std::string mode); virtual void DoRun (void); + + void QueueTestSize (Ptr queue, uint32_t size, std::string error) + { + if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES) + { + NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error); + } + else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS) + { + NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error); + } + + NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error); + } + private: StringValue m_mode; }; @@ -109,19 +124,19 @@ CoDelQueueBasicEnqueueDequeue::DoRun (void) p5 = Create (pktSize); p6 = Create (pktSize); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets in queue"); + QueueTestSize (queue, 0 * modeSize, "There should be no packets in queue"); queue->Enqueue (p1); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in queue"); + QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue"); queue->Enqueue (p2); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in queue"); + QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue"); queue->Enqueue (p3); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packets in queue"); + QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue"); queue->Enqueue (p4); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets in queue"); + QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue"); queue->Enqueue (p5); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in queue"); + QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue"); queue->Enqueue (p6); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 6 * modeSize, "There should be six packets in queue"); + QueueTestSize (queue, 6 * modeSize, "There should be six packets in queue"); NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 0, "There should be no packets being dropped due to full queue"); @@ -129,32 +144,32 @@ CoDelQueueBasicEnqueueDequeue::DoRun (void) p = queue->Dequeue (); NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the first packet"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in queue"); + QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue"); NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p1->GetUid (), "was this the first packet ?"); p = queue->Dequeue (); NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the second packet"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets in queue"); + QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue"); NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p2->GetUid (), "Was this the second packet ?"); p = queue->Dequeue (); NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the third packet"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packets in queue"); + QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue"); NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p3->GetUid (), "Was this the third packet ?"); p = queue->Dequeue (); NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the forth packet"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in queue"); + QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue"); NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p4->GetUid (), "Was this the fourth packet ?"); p = queue->Dequeue (); NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the fifth packet"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in queue"); + QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue"); NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p5->GetUid (), "Was this the fifth packet ?"); p = queue->Dequeue (); NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the last packet"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be zero packet in queue"); + QueueTestSize (queue, 0 * modeSize, "There should be zero packet in queue"); NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p6->GetUid (), "Was this the sixth packet ?"); p = queue->Dequeue (); @@ -169,6 +184,21 @@ class CoDelQueueBasicOverflow : public TestCase public: CoDelQueueBasicOverflow (std::string mode); virtual void DoRun (void); + + void QueueTestSize (Ptr queue, uint32_t size, std::string error) + { + if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES) + { + NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error); + } + else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS) + { + NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error); + } + + NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error); + } + private: void Enqueue (Ptr queue, uint32_t size, uint32_t nPkt); StringValue m_mode; @@ -216,7 +246,7 @@ CoDelQueueBasicOverflow::DoRun (void) queue->Enqueue (p2); queue->Enqueue (p3); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 500 * modeSize, "There should be 500 packets in queue"); + QueueTestSize (queue, 500 * modeSize, "There should be 500 packets in queue"); NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 3, "There should be three packets being dropped due to full queue"); } @@ -321,6 +351,21 @@ class CoDelQueueBasicDrop : public TestCase public: CoDelQueueBasicDrop (std::string mode); virtual void DoRun (void); + + void QueueTestSize (Ptr queue, uint32_t size, std::string error) + { + if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES) + { + NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error); + } + else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS) + { + NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error); + } + + NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error); + } + private: void Enqueue (Ptr queue, uint32_t size, uint32_t nPkt); void Dequeue (Ptr queue, uint32_t modeSize); @@ -419,13 +464,13 @@ CoDelQueueBasicDrop::Dequeue (Ptr queue, uint32_t modeSize) NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state." "Sojourn time has just gone above target from below." "Hence, there should be no packet drops"); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - modeSize, "There should be 1 packet dequeued."); + QueueTestSize (queue, initialQSize - modeSize, "There should be 1 packet dequeued."); } else if (currentTime >= queue->GetInterval ()) { currentDropCount = queue->GetDropCount (); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval." + QueueTestSize (queue, initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval." "We enter the dropping state, perform initial packet drop, and dequeue the next." "So there should be 2 more packets dequeued."); NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop"); @@ -436,7 +481,7 @@ CoDelQueueBasicDrop::Dequeue (Ptr queue, uint32_t modeSize) if (currentTime.GetMicroSeconds () < initialDropNext) { currentDropCount = queue->GetDropCount (); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - modeSize, "We are in dropping state." + QueueTestSize (queue, initialQSize - modeSize, "We are in dropping state." "Sojourn is still above target." "However, it's not time for next drop." "So there should be only 1 more packet dequeued"); @@ -446,7 +491,7 @@ CoDelQueueBasicDrop::Dequeue (Ptr queue, uint32_t modeSize) else if (currentTime.GetMicroSeconds () >= initialDropNext) { currentDropCount = queue->GetDropCount (); - NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state." + QueueTestSize (queue, initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state." "It's time for next drop." "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue"); NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1 + m_dropNextCount, "The number of drops equals to the number of times m_dropNext is updated plus 1 from last dequeue"); diff --git a/src/network/utils/queue.h b/src/network/utils/queue.h index 14b7596a6..7f7c8c638 100644 --- a/src/network/utils/queue.h +++ b/src/network/utils/queue.h @@ -180,7 +180,6 @@ protected: */ void Drop (Ptr packet); -private: /// Traced callback: fired when a packet is enqueued TracedCallback > m_traceEnqueue; /// Traced callback: fired when a packet is dequeued