Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
187d091
Added Traffic Control Layer
natale-p Oct 7, 2015
eb9a024
Internet depends on traffic-control
natale-p Oct 7, 2015
262931f
Made public ProtocolHandlerEntry struct in node.h
natale-p Oct 7, 2015
80baa0f
Aggregate TrafficControlLayer on any Internet-enabled node
natale-p Oct 7, 2015
9285b11
Aggregate TCLayer by default on tests
natale-p Oct 7, 2015
cbafa49
Register callbacks on TCLayer and NetDevices, RX side
natale-p Oct 7, 2015
11f20e7
Use traffic-control to send packets
natale-p Oct 7, 2015
0c814e4
Initial support for multiple transmission queues inside NetDevices
stavallo Nov 19, 2015
ef2c685
WifiNetDevices can return the number of transmission queues based on …
stavallo Nov 19, 2015
bb27480
Flow control Part I: NetDeviceQueues can be started, stopped and woken
stavallo Oct 20, 2015
610f9c7
PointToPointNetDevice: Add support for flow control
stavallo Nov 12, 2015
251787d
NetDevices return the index of the transmission queue they select for…
stavallo Nov 20, 2015
bd130e8
Make Queue store QueueItem objects
stavallo Jan 5, 2016
2bf15fb
Add the QueueDisc base class
stavallo Oct 23, 2015
6e6ba99
The traffic control layer enqueues packets in the queue disc
stavallo Dec 4, 2015
4dd14d5
Defer the addition of the IP header until the packet is extracted fro…
stavallo Jan 6, 2016
9881fe5
Ipv4Header: Add GetVersion and make DscpTypeToString static
stavallo Jan 8, 2016
106f8f2
Add the pfifo_fast queue disc
stavallo Jan 9, 2016
7d99326
Add a queue disc helper to ease the installation of queue discs
stavallo Dec 2, 2015
d850946
Add a traffic control example
pasquimp Nov 25, 2015
0815e6b
Add a pfifo_fast test suite
pasquimp Dec 14, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make Queue store QueueItem objects
A QueueItem base class is introduced to represent the items stored
in a Queue. The base class only contains a Ptr<Packet>. Derived classes
can store additional information. DropTailQueue, RedQueue and CodelQueue,
along with their examples and testsuits, have been adapted. Objects using
such queues have been adapted too.
  • Loading branch information
stavallo committed Jan 15, 2016
commit bd130e865a1339d2401e550a36dfb72a81732e5c
17 changes: 10 additions & 7 deletions src/csma/model/csma-net-device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,9 @@ CsmaNetDevice::TransmitAbort (void)
}
else
{
m_currentPkt = m_queue->Dequeue ();
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?");
Ptr<QueueItem> item = m_queue->Dequeue ();
NS_ASSERT_MSG (item != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?");
m_currentPkt = item->GetPacket ();
m_snifferTrace (m_currentPkt);
m_promiscSnifferTrace (m_currentPkt);
TransmitStart ();
Expand Down Expand Up @@ -632,8 +633,9 @@ CsmaNetDevice::TransmitReadyEvent (void)
}
else
{
m_currentPkt = m_queue->Dequeue ();
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?");
Ptr<QueueItem> item = m_queue->Dequeue ();
NS_ASSERT_MSG (item != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?");
m_currentPkt = item->GetPacket ();
m_snifferTrace (m_currentPkt);
m_promiscSnifferTrace (m_currentPkt);
TransmitStart ();
Expand Down Expand Up @@ -968,7 +970,7 @@ CsmaNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address&
// Place the packet to be sent on the send queue. Note that the
// queue may fire a drop trace, but we will too.
//
if (m_queue->Enqueue (packet) == false)
if (m_queue->Enqueue (Create<QueueItem> (packet)) == false)
{
m_macTxDropTrace (packet);
return false;
Expand All @@ -983,8 +985,9 @@ CsmaNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address&
{
if (m_queue->IsEmpty () == false)
{
m_currentPkt = m_queue->Dequeue ();
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::SendFrom(): IsEmpty false but no Packet on queue?");
Ptr<QueueItem> item = m_queue->Dequeue ();
NS_ASSERT_MSG (item != 0, "CsmaNetDevice::SendFrom(): IsEmpty false but no Packet on queue?");
m_currentPkt = item->GetPacket ();
m_promiscSnifferTrace (m_currentPkt);
m_snifferTrace (m_currentPkt);
TransmitStart ();
Expand Down
32 changes: 18 additions & 14 deletions src/internet/model/codel-queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,10 @@ CoDelQueue::GetMode (void)
}

bool
CoDelQueue::DoEnqueue (Ptr<Packet> p)
CoDelQueue::DoEnqueue (Ptr<QueueItem> item)
{
NS_LOG_FUNCTION (this << p);
NS_LOG_FUNCTION (this << item);
Ptr<Packet> p = item->GetPacket ();

if (m_mode == QUEUE_MODE_PACKETS && (m_packets.size () + 1 > m_maxPackets))
{
Expand All @@ -301,7 +302,7 @@ CoDelQueue::DoEnqueue (Ptr<Packet> p)
p->AddPacketTag (tag);

m_bytesInQueue += p->GetSize ();
m_packets.push (p);
m_packets.push (item);

NS_LOG_LOGIC ("Number packets " << m_packets.size ());
NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
Expand Down Expand Up @@ -351,7 +352,7 @@ CoDelQueue::OkToDrop (Ptr<Packet> p, uint32_t now)
return okToDrop;
}

Ptr<Packet>
Ptr<QueueItem>
CoDelQueue::DoDequeue (void)
{
NS_LOG_FUNCTION (this);
Expand All @@ -365,11 +366,12 @@ CoDelQueue::DoDequeue (void)
return 0;
}
uint32_t now = CoDelGetTime ();
Ptr<Packet> p = m_packets.front ();
Ptr<QueueItem> item = m_packets.front ();
m_packets.pop ();
Ptr<Packet> p = item->GetPacket ();
m_bytesInQueue -= p->GetSize ();

NS_LOG_LOGIC ("Popped " << p);
NS_LOG_LOGIC ("Popped " << item);
NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);

Expand Down Expand Up @@ -416,11 +418,12 @@ CoDelQueue::DoDequeue (void)
++m_states;
return 0;
}
p = m_packets.front ();
item = m_packets.front ();
m_packets.pop ();
p = item ->GetPacket ();
m_bytesInQueue -= p->GetSize ();

NS_LOG_LOGIC ("Popped " << p);
NS_LOG_LOGIC ("Popped " << item);
NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);

Expand Down Expand Up @@ -466,11 +469,12 @@ CoDelQueue::DoDequeue (void)
}
else
{
p = m_packets.front ();
item = m_packets.front ();
m_packets.pop ();
p = item->GetPacket ();
m_bytesInQueue -= p->GetSize ();

NS_LOG_LOGIC ("Popped " << p);
NS_LOG_LOGIC ("Popped " << item);
NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);

Expand Down Expand Up @@ -501,7 +505,7 @@ CoDelQueue::DoDequeue (void)
}
}
++m_states;
return p;
return item;
}

uint32_t
Expand Down Expand Up @@ -552,7 +556,7 @@ CoDelQueue::GetDropNext (void)
return m_dropNext;
}

Ptr<const Packet>
Ptr<const QueueItem>
CoDelQueue::DoPeek (void) const
{
NS_LOG_FUNCTION (this);
Expand All @@ -563,12 +567,12 @@ CoDelQueue::DoPeek (void) const
return 0;
}

Ptr<Packet> p = m_packets.front ();
Ptr<QueueItem> item = m_packets.front ();

NS_LOG_LOGIC ("Number packets " << m_packets.size ());
NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);

return p;
return item;
}

bool
Expand Down
10 changes: 5 additions & 5 deletions src/internet/model/codel-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ class CoDelQueue : public Queue
/**
* \brief Add a packet to the queue
*
* \param p The packet to be added
* \param item The item to be added
* \returns True if the packet can be added, False if the packet is dropped due to full queue
*/
virtual bool DoEnqueue (Ptr<Packet> p);
virtual bool DoEnqueue (Ptr<QueueItem> item);

/**
* \brief Remove a packet from queue based on the current state
Expand All @@ -156,9 +156,9 @@ class CoDelQueue : public Queue
*
* \returns The packet that is examined
*/
virtual Ptr<Packet> DoDequeue (void);
virtual Ptr<QueueItem> DoDequeue (void);

virtual Ptr<const Packet> DoPeek (void) const;
virtual Ptr<const QueueItem> DoPeek (void) const;

/**
* \brief Calculate the reciprocal square root of m_count by using Newton's method
Expand Down Expand Up @@ -223,7 +223,7 @@ class CoDelQueue : public Queue
*/
uint32_t Time2CoDel (Time t);

std::queue<Ptr<Packet> > m_packets; //!< The packet queue
std::queue<Ptr<QueueItem> > m_packets; //!< The packet queue
uint32_t m_maxPackets; //!< Max # of packets accepted by the queue
uint32_t m_maxBytes; //!< Max # of bytes accepted by the queue
TracedValue<uint32_t> m_bytesInQueue; //!< The total number of bytes in queue
Expand Down
66 changes: 33 additions & 33 deletions src/internet/test/codel-queue-test-suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,55 +125,55 @@ CoDelQueueBasicEnqueueDequeue::DoRun (void)
p6 = Create<Packet> (pktSize);

QueueTestSize (queue, 0 * modeSize, "There should be no packets in queue");
queue->Enqueue (p1);
queue->Enqueue (Create<QueueItem> (p1));
QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
queue->Enqueue (p2);
queue->Enqueue (Create<QueueItem> (p2));
QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
queue->Enqueue (p3);
queue->Enqueue (Create<QueueItem> (p3));
QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
queue->Enqueue (p4);
queue->Enqueue (Create<QueueItem> (p4));
QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
queue->Enqueue (p5);
queue->Enqueue (Create<QueueItem> (p5));
QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
queue->Enqueue (p6);
queue->Enqueue (Create<QueueItem> (p6));
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");

Ptr<Packet> p;
Ptr<QueueItem> item;

p = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the first packet");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
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 ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
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 ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
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 ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the forth packet");
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 ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the fifth packet");
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 ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the last packet");
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 ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p6->GetUid (), "Was this the sixth packet ?");

p = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in queue");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "There are really no packets in queue");

NS_TEST_EXPECT_MSG_EQ (queue->GetDropCount (), 0, "There should be no packet drops according to CoDel algorithm");
}
Expand Down Expand Up @@ -242,9 +242,9 @@ CoDelQueueBasicOverflow::DoRun (void)
"Verify that we can actually set the attribute MinBytes");

Enqueue (queue, pktSize, 500);
queue->Enqueue (p1);
queue->Enqueue (p2);
queue->Enqueue (p3);
queue->Enqueue (Create<QueueItem> (p1));
queue->Enqueue (Create<QueueItem> (p2));
queue->Enqueue (Create<QueueItem> (p3));

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");
Expand All @@ -255,7 +255,7 @@ CoDelQueueBasicOverflow::Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t
{
for (uint32_t i = 0; i < nPkt; i++)
{
queue->Enqueue (Create<Packet> (size));
queue->Enqueue (Create<QueueItem> (Create<Packet> (size)));
}
}

Expand Down Expand Up @@ -435,7 +435,7 @@ CoDelQueueBasicDrop::Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPk
{
for (uint32_t i = 0; i < nPkt; i++)
{
queue->Enqueue (Create<Packet> (size));
queue->Enqueue (Create<QueueItem> (Create<Packet> (size)));
}
}

Expand All @@ -455,7 +455,7 @@ CoDelQueueBasicDrop::Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize)

if (initialQSize != 0)
{
Ptr<Packet> p = queue->Dequeue ();
Ptr<QueueItem> item = queue->Dequeue ();
if (initialDropCount == 0 && currentTime > queue->GetTarget ())
{
if (currentTime < queue->GetInterval ())
Expand Down
32 changes: 16 additions & 16 deletions src/network/test/drop-tail-queue-test-suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,34 @@ DropTailQueueTestCase::DoRun (void)
p4 = Create<Packet> ();

NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 0, "There should be no packets in there");
queue->Enqueue (p1);
queue->Enqueue (Create<QueueItem> (p1));
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 1, "There should be one packet in there");
queue->Enqueue (p2);
queue->Enqueue (Create<QueueItem> (p2));
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 2, "There should be two packets in there");
queue->Enqueue (p3);
queue->Enqueue (Create<QueueItem> (p3));
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 3, "There should be three packets in there");
queue->Enqueue (p4); // will be dropped
queue->Enqueue (Create<QueueItem> (p4)); // will be dropped
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 3, "There should be still three packets in there");

Ptr<Packet> p;
Ptr<QueueItem> item;

p = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the first packet");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 2, "There should be two packets in there");
NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p1->GetUid (), "was this the first packet ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 1, "There should be one packet in there");
NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p2->GetUid (), "Was this the second packet ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->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");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), 0, "There should be no packets in there");
NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p3->GetUid (), "Was this the third packet ?");
NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?");

p = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in there");
item = queue->Dequeue ();
NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "There are really no packets in there");
}

static class DropTailQueueTestSuite : public TestSuite
Expand Down
Loading