|
|
|
|
@@ -61,6 +61,21 @@ class CoDelQueueBasicEnqueueDequeue : public TestCase
|
|
|
|
|
public:
|
|
|
|
|
CoDelQueueBasicEnqueueDequeue (std::string mode);
|
|
|
|
|
virtual void DoRun (void);
|
|
|
|
|
|
|
|
|
|
void QueueTestSize (Ptr<CoDelQueue> 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<Packet> (pktSize);
|
|
|
|
|
p6 = Create<Packet> (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<CoDelQueue> 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<CoDelQueue> 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<CoDelQueue> 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<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
|
|
|
|
|
void Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize);
|
|
|
|
|
@@ -419,13 +464,13 @@ CoDelQueueBasicDrop::Dequeue (Ptr<CoDelQueue> 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<CoDelQueue> 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<CoDelQueue> 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");
|
|
|
|
|
|