--- a/src/internet/model/codel-queue.h Wed Aug 27 14:39:08 2014 -0500
+++ b/src/internet/model/codel-queue.h Tue Sep 02 09:36:53 2014 -0500
@@ -59,8 +59,6 @@
class CoDelQueue : public Queue
{
public:
- friend class Fq_CoDelQueue;
-
static TypeId GetTypeId (void);
/**
--- a/src/internet/model/fq_codel-queue.cc Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,237 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <limits>
-#include "ns3/log.h"
-#include "ns3/enum.h"
-#include "ns3/uinteger.h"
-#include "fq_codel-queue.h"
-#include "ns3/red-queue.h"
-#include "ns3/ipv4-header.h"
-#include "ns3/ppp-header.h"
-#include <boost/functional/hash.hpp>
-#include <boost/format.hpp>
-
-/*
- * FQ_Codel as implemented by Linux.
- */
-
-NS_LOG_COMPONENT_DEFINE ("Fq_CoDelQueue");
-
-using namespace boost;
-
-namespace ns3 {
-
-Fq_CoDelSlot::Fq_CoDelSlot () :
- h(0)
-{
- NS_LOG_FUNCTION_NOARGS ();
- INIT_LIST_HEAD(&flowchain);
- this->q = CreateObject<CoDelQueue> ();
-}
-
-Fq_CoDelSlot::~Fq_CoDelSlot ()
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-NS_OBJECT_ENSURE_REGISTERED (Fq_CoDelQueue);
-
-TypeId Fq_CoDelQueue::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::Fq_CoDelQueue")
- .SetParent<Queue> ()
- .AddConstructor<Fq_CoDelQueue> ()
- .AddAttribute ("headMode",
- "Add new flows in the head position",
- BooleanValue (false),
- MakeBooleanAccessor (&Fq_CoDelQueue::m_headmode),
- MakeBooleanChecker ())
- .AddAttribute ("peturbInterval",
- "Peterbation interval in packets",
- UintegerValue (500000),
- MakeUintegerAccessor (&Fq_CoDelQueue::m_peturbInterval),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("Quantum",
- "Quantum in bytes",
- UintegerValue (1500),
- MakeUintegerAccessor (&Fq_CoDelQueue::m_quantum),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("Flows",
- "Number of flows",
- UintegerValue (1024),
- MakeUintegerAccessor (&Fq_CoDelQueue::m_divisor),
- MakeUintegerChecker<uint32_t> ())
- ;
- return tid;
-}
-
-Fq_CoDelQueue::Fq_CoDelQueue () :
- m_ht (),
- psource (),
- peturbation (psource.GetInteger(0,std::numeric_limits<std::size_t>::max()))
-{
- NS_LOG_FUNCTION_NOARGS ();
- INIT_LIST_HEAD(&m_new_flows);
- INIT_LIST_HEAD(&m_old_flows);
-}
-
-Fq_CoDelQueue::~Fq_CoDelQueue ()
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-std::size_t
-Fq_CoDelQueue::hash(Ptr<Packet> p)
-{
- boost::hash<std::string> string_hash;
-
- Ptr<Packet> q = p->Copy();
-
- class PppHeader ppp_hd;
-
- q->RemoveHeader(ppp_hd);
-
- class Ipv4Header ip_hd;
- if (q->PeekHeader (ip_hd))
- {
- if (pcounter > m_peturbInterval)
- peturbation = psource.GetInteger(0,std::numeric_limits<std::size_t>::max());
- std::size_t h = (string_hash((format("%x%x%x%x")
- % (ip_hd.GetDestination().Get())
- % (ip_hd.GetSource().Get())
- % (ip_hd.GetProtocol())
- % (peturbation)).str())
- % m_divisor);
- return h;
- }
- else
- {
- return 0;
- }
-}
-
-bool
-Fq_CoDelQueue::DoEnqueue (Ptr<Packet> p)
-{
- NS_LOG_FUNCTION (this << p);
- bool queued;
-
- Fq_CoDelSlot *slot;
-
- std::size_t h = Fq_CoDelQueue::hash(p);
- NS_LOG_DEBUG ("fq_codel enqueue use queue "<<h);
- if (m_ht[h] == NULL)
- {
- NS_LOG_DEBUG ("fq_codel enqueue Create queue " << h);
- m_ht[h] = new Fq_CoDelSlot ();
- slot = m_ht[h];
- // slot->q->backlog = &backlog;
- slot->q->m_bytesInQueue = backlog;
- slot->h = h;
- }
- else
- {
- slot = m_ht[h];
- }
-
- queued = slot->q->Enqueue(p);
-
- if (queued)
- {
- slot->backlog += p->GetSize();
- backlog += p->GetSize();
-
- if (list_empty(&slot->flowchain)) {
- NS_LOG_DEBUG ("fq_codel enqueue inactive queue "<<h);
- list_add_tail(&slot->flowchain, &m_new_flows);
- slot->deficit = m_quantum;
- }
- }
- else
- {
- Drop (p);
- }
- NS_LOG_DEBUG ("fq_codel enqueue "<<slot->h<<" "<<queued);
- return queued;
-}
-
-Ptr<Packet>
-Fq_CoDelQueue::DoDequeue (void)
-{
- NS_LOG_FUNCTION (this);
- Fq_CoDelSlot *flow;
- struct list_head *head;
-
-begin:
- head = &m_new_flows;
- if (list_empty(head)) {
- head = &m_old_flows;
- if (list_empty(head))
- return NULL;
- }
- flow = list_first_entry(head, Fq_CoDelSlot, flowchain);
-
- NS_LOG_DEBUG ("fq_codel scan "<<flow->h);
-
- if (flow->deficit <= 0)
- {
- flow->deficit += m_quantum;
- NS_LOG_DEBUG ("fq_codel deficit now "<<flow->deficit<<" "<<flow->h);
- list_move_tail(&flow->flowchain, &m_old_flows);
- goto begin;
- }
-
- Ptr<Packet> p = flow->q->Dequeue();
- if (p == NULL)
- {
- /* force a pass through old_flows to prevent starvation */
- if ((head == &m_new_flows) && !list_empty(&m_old_flows))
- list_move_tail(&flow->flowchain, &m_old_flows);
- else
- list_del_init(&flow->flowchain);
- goto begin;
-
- }
- NS_LOG_DEBUG ("fq_codel found a packet "<<flow->h);
-
- flow->deficit -= p->GetSize();
- flow->backlog -= p->GetSize();
- backlog -= p->GetSize();
-
- return p;
-}
-
-Ptr<const Packet>
-Fq_CoDelQueue::DoPeek (void) const
-{
- NS_LOG_FUNCTION (this);
-
- struct list_head *head;
-
- head = &m_new_flows;
- if (list_empty(head)) {
- head = &m_old_flows;
- if (list_empty(head))
- return 0;
- }
- return list_first_entry(head, Fq_CoDelSlot, flowchain)->q->Peek();
-}
-
-} // namespace ns3
-
--- a/src/internet/model/fq_codel-queue.h Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef FQ_CODEL_H
-#define FQ_CODEL_H
-
-#include <map>
-#include "ns3/random-variable.h"
-#include "ns3/linux-list.h"
-#include "ns3/boolean.h"
-#include "ns3/packet.h"
-#include "ns3/queue.h"
-#include "ns3/codel-queue.h"
-
-namespace ns3 {
-
-class TraceContainer;
-
-class Fq_CoDelSlot {
-public:
- friend class CoDelQueue;
-
- // static TypeId GetTypeId (void);
- Fq_CoDelSlot ();
-
- virtual ~Fq_CoDelSlot();
-
- struct list_head flowchain;
-
- Ptr<CoDelQueue> q;
- int deficit;
- uint32_t backlog;
- int h;
-};
-
-/**
- * \ingroup queue
- */
-class Fq_CoDelQueue : public Queue {
-public:
- static TypeId GetTypeId (void);
- /**
- * \brief Fq_CoDelQueue Constructor
- */
- Fq_CoDelQueue ();
-
- virtual ~Fq_CoDelQueue();
-
-private:
- virtual bool DoEnqueue (Ptr<Packet> p);
- virtual Ptr<Packet> DoDequeue (void);
- virtual Ptr<const Packet> DoPeek (void) const;
-
- std::size_t hash(Ptr<Packet> p);
- // only mutable so we can get a reference out of here in Peek()
- mutable std::map<int, Fq_CoDelSlot * > m_ht;
- mutable struct list_head m_new_flows;
- mutable struct list_head m_old_flows;
- uint32_t m_divisor;
- uint32_t m_buckets;
- uint32_t m_peturbInterval;
- bool m_headmode;
- mutable size_t pcounter;
- UniformVariable psource;
- mutable uint32_t peturbation;
- uint32_t m_quantum;
- uint32_t backlog;
-};
-
-} // namespace ns3
-
-#endif /* FQ_CODEL_H */
--- a/src/internet/model/sfq-queue.cc Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <limits>
-#include "ns3/log.h"
-#include "ns3/enum.h"
-#include "ns3/uinteger.h"
-#include "sfq-queue.h"
-#include "ns3/red-queue.h"
-#include "ns3/ipv4-header.h"
-#include "ns3/ppp-header.h"
-#include <boost/functional/hash.hpp>
-#include <boost/format.hpp>
-
-/*
- * SFQ as implemented by Linux, not the classical version.
- */
-
-NS_LOG_COMPONENT_DEFINE ("SfqQueue");
-
-using namespace boost;
-
-namespace ns3 {
-
-SfqSlot::SfqSlot () :
- allot(0),
- backlog(0),
- h(0),
- active(false)
-{
- this->q = CreateObject<RedQueue> ();
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-SfqSlot::~SfqSlot ()
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-NS_OBJECT_ENSURE_REGISTERED (SfqQueue);
-
-TypeId SfqQueue::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::SfqQueue")
- .SetParent<Queue> ()
- .AddConstructor<SfqQueue> ()
- .AddAttribute ("headMode",
- "Add new flows in the head position",
- BooleanValue (false),
- MakeBooleanAccessor (&SfqQueue::m_headmode),
- MakeBooleanChecker ())
- .AddAttribute ("peturbInterval",
- "Perturbation interval in packets",
- UintegerValue (500),
- MakeUintegerAccessor (&SfqQueue::m_peturbInterval),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("Quantum",
- "Quantum in bytes",
- UintegerValue (1500),
- MakeUintegerAccessor (&SfqQueue::m_quantum),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("Flows",
- "Number of flows",
- UintegerValue (1024),
- MakeUintegerAccessor (&SfqQueue::m_divisor),
- MakeUintegerChecker<uint32_t> ())
- ;
- return tid;
-}
-
-SfqQueue::SfqQueue () :
- m_ht (),
- m_flows(),
- psource (),
- peturbation (psource.GetInteger(0,std::numeric_limits<std::size_t>::max()))
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-SfqQueue::~SfqQueue ()
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-std::size_t
-SfqQueue::hash(Ptr<Packet> p)
-{
- boost::hash<std::string> string_hash;
-
- Ptr<Packet> q = p->Copy();
-
- class PppHeader ppp_hd;
-
- q->RemoveHeader(ppp_hd);
-
- class Ipv4Header ip_hd;
- if (q->PeekHeader (ip_hd))
- {
- if (pcounter > m_peturbInterval)
- peturbation = psource.GetInteger(0,std::numeric_limits<std::size_t>::max());
- std::size_t h = (string_hash((format("%x%x%x%x")
- % (ip_hd.GetDestination().Get())
- % (ip_hd.GetSource().Get())
- % (ip_hd.GetProtocol())
- % (peturbation)).str())
- % m_divisor );
- return h;
- }
- else
- {
- return 0;
- }
-}
-
-bool
-SfqQueue::DoEnqueue (Ptr<Packet> p)
-{
- NS_LOG_FUNCTION (this << p);
- bool queued;
-
- Ptr<SfqSlot> slot;
-
- std::size_t h = SfqQueue::hash(p);
- if (m_ht[h] == NULL)
- {
- NS_LOG_DEBUG ("SFQ enqueue Create queue " << h);
- m_ht[h] = slot = Create<SfqSlot> ();
- slot->h = h;
- slot->backlog = 0;
- slot->allot = m_quantum;
- }
- else
- {
- NS_LOG_DEBUG ("SFQ enqueue use queue "<<h);
- slot = m_ht[h];
- }
-
- if (!slot->active)
- {
- NS_LOG_DEBUG ("SFQ enqueue inactive queue "<<h);
- if (m_headmode) {
- m_flows.push_front(slot);
- } else {
- m_flows.push_back(slot);
- }
- }
- slot->active = true;
-
- uint32_t sz = p->GetSize();
-
- if ((queued = slot->q->Enqueue(p))) {
- slot->backlog += sz;
- }
-
- return queued;
-}
-
-Ptr<Packet>
-SfqQueue::DoDequeue (void)
-{
- NS_LOG_FUNCTION (this);
-
- if (m_flows.empty()) {
- return 0;
- }
-
- Ptr<SfqSlot> slot;
-
- next_slot:
- slot = m_flows.front();
- NS_LOG_DEBUG ("SFQ scan "<<slot->h);
-
- m_flows.pop_front();
-
- if (slot->allot <= 0) {
- slot->allot += m_quantum;
- m_flows.push_back(slot);
- goto next_slot;
- }
-
- if (slot->q->Peek() != 0)
- {
- NS_LOG_DEBUG ("SFQ found a packet "<<slot->h);
- Ptr<Packet> p = slot->q->Dequeue();
-
- slot->backlog -= p->GetSize();
- slot->allot -= p->GetSize();
-
- if (slot->q->Peek() != 0)
- {
- m_flows.push_back(slot);
- }
- else
- {
- slot->active = false;
- }
- return p;
- }
- else
- {
- NS_LOG_DEBUG ("SFQ found empty queue "<<slot->h);
- slot->active = false;
- return 0;
- }
-}
-
-Ptr<const Packet>
-SfqQueue::DoPeek (void) const
-{
- NS_LOG_FUNCTION (this);
-
- if (!m_flows.empty())
- {
- return m_flows.front()->q->Peek();
- }
- else
- {
- return 0;
- }
-}
-
-} // namespace ns3
-
--- a/src/internet/model/sfq-queue.h Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 University of Washington
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef SFQ_H
-#define SFQ_H
-
-#include <queue>
-#include "ns3/packet.h"
-#include "ns3/queue.h"
-#include <map>
-#include "ns3/red-queue.h"
-#include "ns3/random-variable.h"
-
-namespace ns3 {
-
-class TraceContainer;
-
-class SfqSlot : public SimpleRefCount<SfqSlot> {
-public:
- // static TypeId GetTypeId (void);
- SfqSlot ();
-
- virtual ~SfqSlot();
-
- Ptr<RedQueue> q;
- int allot;
- unsigned int backlog;
- int h;
- bool active;
-};
-
-/**
- * \ingroup queue
- */
-class SfqQueue : public Queue {
-public:
- static TypeId GetTypeId (void);
- /**
- * \brief SfqQueue Constructor
- */
- SfqQueue ();
-
- virtual ~SfqQueue();
-
-private:
- virtual bool DoEnqueue (Ptr<Packet> p);
- virtual Ptr<Packet> DoDequeue (void);
- virtual Ptr<const Packet> DoPeek (void) const;
-
- std::size_t hash(Ptr<Packet> p);
- // only mutable so we can get a reference out of here in Peek()
- mutable std::map<int, Ptr<SfqSlot> > m_ht;
- mutable std::list<Ptr<SfqSlot> > m_flows;
- uint32_t m_divisor;
- uint32_t m_buckets;
- uint32_t m_peturbInterval;
- bool m_headmode;
- mutable size_t pcounter;
- UniformVariable psource;
- mutable uint32_t peturbation;
- uint32_t m_quantum;
-};
-
-} // namespace ns3
-
-#endif /* SFQ_H */
--- a/src/internet/wscript Wed Aug 27 14:39:08 2014 -0500
+++ b/src/internet/wscript Tue Sep 02 09:36:53 2014 -0500
@@ -183,8 +183,6 @@
'model/global-route-manager.cc',
'model/global-route-manager-impl.cc',
'model/candidate-queue.cc',
- 'model/sfq-queue.cc',
- 'model/fq_codel-queue.cc',
'model/codel-queue.cc',
'model/ipv4-global-routing.cc',
'helper/ipv4-global-routing-helper.cc',
@@ -296,8 +294,6 @@
'model/global-route-manager.h',
'model/global-route-manager-impl.h',
'model/candidate-queue.h',
- 'model/sfq-queue.h',
- 'model/fq_codel-queue.h',
'model/codel-queue.h',
'model/ipv4-global-routing.h',
'helper/ipv4-global-routing-helper.h',
--- a/src/network/test/codel-queue-test-suite.cc Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014 ResiliNets, ITTC, University of Kansas
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Truc Anh N Nguyen <trucanh524@gmail.com>
- *
- * This test is based on unit test for RED
- *
- */
-
-#include "ns3/test.h"
-#include "ns3/codel-queue.h"
-#include "ns3/uinteger.h"
-#include "ns3/string.h"
-#include "ns3/double.h"
-#include "ns3/log.h"
-#include "ns3/simulator.h"
-
-using namespace ns3;
-
-
-class CoDelQueueTestCase : public TestCase
-{
-public:
- CoDelQueueTestCase ();
- virtual void DoRun (void);
-private:
- void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
- void FirstDequeue (Ptr<CoDelQueue> queue, uint32_t modeSize, Ptr<Packet> p1);
- void RunCoDelTest (StringValue mode);
-};
-
-CoDelQueueTestCase::CoDelQueueTestCase ()
- : TestCase ("Sanity check on the CoDel queue implementation")
-{
-}
-
-void
-CoDelQueueTestCase::RunCoDelTest (StringValue mode)
-{
- Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
-
- uint32_t pktSize = 0;
- uint32_t modeSize = 1;
-
- // Test 1: simple enqueue/dequeue with no drops
-
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
- "Verify that we can actually set the attribute Mode");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue(1500)), true,
- "Verify that we can actually set the attribute MaxPackets");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue(1000*1500)), true,
- "Verify that we can actually set the attribute MaxBytes");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (1000)), true,
- "Verify that we can actually set the attribute MinBytes");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Interval", StringValue("50ms")), true,
- "Verify that we can actually set the attribute Interval");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Target", StringValue("4ms")), true,
- "Verify that we can actually set the attribute Target");
-
- if (queue->GetMode() == CoDelQueue::BYTES)
- {
- pktSize = 1000;
- modeSize = pktSize;
- }
-
- Ptr<Packet> p1, p2, p3, p4, p5, p6;
- p1 = Create<Packet> (pktSize);
- p2 = Create<Packet> (pktSize);
- p3 = Create<Packet> (pktSize);
- p4 = Create<Packet> (pktSize);
- p5 = Create<Packet> (pktSize);
- p6 = Create<Packet> (pktSize);
-
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 0 * modeSize, "There should be no packets in there");
- queue->Enqueue (p1);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 1 * modeSize, "There should be one packet in there");
- queue->Enqueue (p2);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 2 * modeSize, "There should be two packets in there");
- queue->Enqueue (p3);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 3 * modeSize, "There should be three packets in there");
- queue->Enqueue (p4);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 4 * modeSize, "There should be four packets in there");
- queue->Enqueue (p5);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in there");
- queue->Enqueue (p6);
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 6 * modeSize, "There should be six packets in there");
-
- NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 0, "There should be no packets being dropped due to full queue");
-
- Ptr<Packet> p;
-
- 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 there");
- 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 there");
- 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 there");
- 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 there");
- NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p4->GetUid (), "Was this the third 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 there");
- NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p5->GetUid (), "Was this the third 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 there");
- NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p6->GetUid (), "Was this the third packet ?");
-
- p = queue->Dequeue ();
- NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in there");
-
- NS_TEST_EXPECT_MSG_EQ (queue->GetDropCount (), 0, "There should be no packet drops according to CoDel algorithm");
-
- // Test 2: enqueue with drops due to queue overflow
-
- queue = CreateObject<CoDelQueue> ();
-
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
- "Verify that we can actually set the attribute Mode");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue(500)), true,
- "Verify that we can actually set the attribute MaxPackets");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue(1000*500)), true,
- "Verify that we can actually set the attribute MaxBytes");
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (1000)), true,
- "Verify that we can actually set the attribute MinBytes");
-
- if (queue->GetMode() == CoDelQueue::BYTES)
- {
- pktSize = 1000;
- modeSize = pktSize;
- }
-
- Enqueue (queue, pktSize, 500);
- queue->Enqueue (p1);
- queue->Enqueue (p2);
- queue->Enqueue (p3);
-
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 500 * modeSize, "There should be 500 packets in there");
- NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 3, "There should be three packets being dropped due to full queue");
-
- // Test 3: enqueue/dequeue with drops according to CoDel algorithm
-
- queue = CreateObject<CoDelQueue> ();
-
- NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", mode), true,
- "Verify that we can actually set the attribute Mode");
-
- if (queue->GetMode() == CoDelQueue::BYTES)
- {
- pktSize = 1000;
- modeSize = pktSize;
- }
-
- queue->Enqueue (p1);
- queue->Enqueue (p2);
- queue->Enqueue (p3);
- queue->Enqueue (p4);
- queue->Enqueue (p5);
- queue->Enqueue (p6);
-
- Time waitUntilDequeue = 2 * queue->GetTarget ();
-
- Simulator::Schedule (waitUntilDequeue, &CoDelQueueTestCase::FirstDequeue, this, queue, modeSize, p1);
-
- //TODO: test CoDel while in dropping state
-}
-
-void
-CoDelQueueTestCase::Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt)
-{
- for (uint32_t i = 0; i < nPkt; i++)
- {
- queue->Enqueue (Create<Packet> (size));
- }
-}
-
-void
-CoDelQueueTestCase::FirstDequeue (Ptr<CoDelQueue> queue, uint32_t modeSize, Ptr<Packet> p1)
-{
- Ptr<Packet> p = queue->Dequeue ();
- NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "The first packet should be removed");
- NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 5 * modeSize, "There should be five packets in there");
- NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p1->GetUid (), "was this the first packet ?");
-
- NS_TEST_EXPECT_MSG_EQ (queue->GetDropCount (), 0, "There should be no packet drops");
-}
-
-void
-CoDelQueueTestCase::DoRun (void)
-{
- RunCoDelTest (StringValue ("Packets"));
- RunCoDelTest (StringValue ("Bytes"));
- Simulator::Run ();
- Simulator::Destroy ();
-
-}
-
-static class CoDelQueueTestSuite : public TestSuite
-{
-public:
- CoDelQueueTestSuite ()
- : TestSuite ("codel-queue", UNIT)
- {
- AddTestCase (new CoDelQueueTestCase (), TestCase::QUICK);
- }
-} g_coDelQueueTestSuite;
--- a/src/network/utils/codel-queue.cc Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,518 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2012 Andrew McGregor
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Codel, the COntrolled DELay Queueing discipline
- * Based on ns2 simulation code presented by Kathie Nichols
- *
- * This port based on linux kernel code by
- * Authors: Dave Täht <d@taht.net>
- * Eric Dumazet <edumazet@google.com>
- *
- * Ported to ns-3 by: Andrew McGregor <andrewmcgr@gmail.com>
-*/
-
-#include "ns3/log.h"
-#include "ns3/enum.h"
-#include "ns3/uinteger.h"
-#include "ns3/abort.h"
-#include "codel-queue.h"
-
-NS_LOG_COMPONENT_DEFINE ("CoDelQueue");
-
-namespace ns3 {
-
-#define BITS_PER_LONG (8 * sizeof (unsigned long))
-
-/* borrowed from the linux kernel */
-#define DoDiv(n,base) \
-({ \
- int __res; \
- __res = ((unsigned long)n) % (unsigned int)base; \
- n = ((unsigned long)n) / (unsigned int)base; \
- __res; \
-})
-
-static inline uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
-{
- return (uint32_t)(((uint64_t)A * R) >> 32);
-}
-
-/* end kernel borrowings */
-
-static codelTime_t CoDelGetTime(void)
-{
- Time time = Simulator::Now ();
- uint64_t ns = time.GetNanoSeconds ();
-
- return ns >> CODEL_SHIFT;
-}
-
-#define CoDelTimeAfter(a, b) ((int)(a) - (int)(b) > 0)
-#define CoDelTimeAfterEq(a, b) ((int)(a) - (int)(b) >= 0)
-#define CoDelTimeBefore(a, b) ((int)(a) - (int)(b) < 0)
-#define CodelTimeBeforeEq(a, b) ((int)(a) - (int)(b) <= 0)
-
-#define NSEC_PER_MSEC 1000000
-#define NSEC_PER_USEC 1000
-#define MS2TIME(a) ((a * NSEC_PER_MSEC) >> CODEL_SHIFT)
-#define US2TIME(a) ((a * NSEC_PER_USEC) >> CODEL_SHIFT)
-#define NS2TIME(a) ((a) >> CODEL_SHIFT)
-#define TIME2CODEL(a) NS2TIME(a.GetNanoSeconds())
-
-#define DEFAULT_CODEL_LIMIT 1000
-
-
-class CoDelTimestampTag : public Tag
-{
-public:
- CoDelTimestampTag ();
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
-
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (TagBuffer i) const;
- virtual void Deserialize (TagBuffer i);
- virtual void Print (std::ostream &os) const;
-
- Time GetTxTime (void) const;
-private:
- uint64_t m_creationTime;
-};
-
-CoDelTimestampTag::CoDelTimestampTag ()
- : m_creationTime (Simulator::Now ().GetTimeStep ())
-{
-}
-
-TypeId
-CoDelTimestampTag::GetTypeId (void)
-{
- static TypeId tid = TypeId ("anon::CoDelTimestampTag")
- .SetParent<Tag> ()
- .AddConstructor<CoDelTimestampTag> ()
- .AddAttribute ("CreationTime",
- "The time at which the timestamp was created",
- StringValue ("0.0s"),
- MakeTimeAccessor (&CoDelTimestampTag::GetTxTime),
- MakeTimeChecker ())
- ;
- return tid;
-}
-TypeId
-CoDelTimestampTag::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-uint32_t
-CoDelTimestampTag::GetSerializedSize (void) const
-{
- return 8;
-}
-void
-CoDelTimestampTag::Serialize (TagBuffer i) const
-{
- i.WriteU64 (m_creationTime);
-}
-void
-CoDelTimestampTag::Deserialize (TagBuffer i)
-{
- m_creationTime = i.ReadU64 ();
-}
-void
-CoDelTimestampTag::Print (std::ostream &os) const
-{
- os << "CreationTime=" << m_creationTime;
-}
-Time
-CoDelTimestampTag::GetTxTime (void) const
-{
- return TimeStep (m_creationTime);
-}
-
-NS_OBJECT_ENSURE_REGISTERED (CoDelQueue);
-
-TypeId CoDelQueue::GetTypeId (void)
-{
- static TypeId tid = TypeId ("ns3::CoDelQueue")
- .SetParent<Queue> ()
- .AddConstructor<CoDelQueue> ()
- .AddAttribute ("Mode",
- "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
- EnumValue (BYTES),
- MakeEnumAccessor (&CoDelQueue::SetMode),
- MakeEnumChecker (BYTES, "Bytes",
- PACKETS, "Packets"))
- .AddAttribute ("MaxPackets",
- "The maximum number of packets accepted by this CoDelQueue.",
- UintegerValue (DEFAULT_CODEL_LIMIT),
- MakeUintegerAccessor (&CoDelQueue::m_maxPackets),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("MaxBytes",
- "The maximum number of bytes accepted by this CoDelQueue.",
- UintegerValue (1500*DEFAULT_CODEL_LIMIT),
- MakeUintegerAccessor (&CoDelQueue::m_maxBytes),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("MinBytes",
- "The CoDel algorithm minbytes parameter.",
- UintegerValue (1500),
- MakeUintegerAccessor (&CoDelQueue::m_minBytes),
- MakeUintegerChecker<uint32_t> ())
- .AddAttribute ("Interval",
- "The CoDel algorithm interval",
- StringValue ("100ms"),
- MakeTimeAccessor (&CoDelQueue::m_interval),
- MakeTimeChecker ())
- .AddAttribute ("Target",
- "The CoDel algorithm target queue delay",
- StringValue ("5ms"),
- MakeTimeAccessor (&CoDelQueue::m_target),
- MakeTimeChecker ())
- .AddTraceSource("count",
- "CoDel count",
- MakeTraceSourceAccessor(&CoDelQueue::m_count))
- .AddTraceSource("drop_count",
- "CoDel drop count",
- MakeTraceSourceAccessor(&CoDelQueue::m_dropCount))
- .AddTraceSource("last_count",
- "CoDel lastcount",
- MakeTraceSourceAccessor(&CoDelQueue::m_lastCount))
- // .AddTraceSource("bytesInQueue",
- // "Number of bytes in the queue",
- // MakeTraceSourceAccessor(&CoDelQueue::m_bytesInQueue))
- ;
-
- return tid;
-}
-
-CoDelQueue::CoDelQueue () :
- Queue (),
- m_packets (),
- m_maxBytes(),
- m_bytesInQueue(0),
- backlog(&m_bytesInQueue),
- m_count(0),
- m_dropCount(0),
- m_lastCount(0),
- m_dropping(false),
- m_recInvSqrt(~0U >> REC_INV_SQRT_SHIFT),
- m_firstAboveTime(0),
- m_dropNext(0),
- m_state1(0),
- m_state2(0),
- m_state3(0),
- m_states(0),
- m_dropOverLimit(0)
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-CoDelQueue::~CoDelQueue ()
-{
- NS_LOG_FUNCTION_NOARGS ();
-}
-
-void
-CoDelQueue::NewtonStep(void)
-{
- 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);
-
- val >>= 2; /* avoid overflow */
- val = (val * invsqrt) >> (32-2+1);
- m_recInvSqrt = val >> REC_INV_SQRT_SHIFT;
-}
-
-codelTime_t
-CoDelQueue::ControlLaw(codelTime_t t)
-{
- return t + ReciprocalDivide(TIME2CODEL(m_interval), m_recInvSqrt << REC_INV_SQRT_SHIFT);
-}
-
-void
-CoDelQueue::SetMode (enum Mode mode)
-{
- NS_LOG_FUNCTION (mode);
- m_mode = mode;
-}
-
-CoDelQueue::Mode
-CoDelQueue::GetMode (void)
-{
- NS_LOG_FUNCTION_NOARGS ();
- return m_mode;
-}
-
-bool
-CoDelQueue::DoEnqueue (Ptr<Packet> p)
-{
- NS_LOG_FUNCTION (this << p);
-
- if (m_mode == PACKETS && (m_packets.size () + 1 > m_maxPackets))
- {
- NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
- Drop (p);
- ++m_dropOverLimit;
- return false;
- }
-
- if (m_mode == BYTES && (m_bytesInQueue + p->GetSize () > m_maxBytes))
- {
- NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
- Drop (p);
- ++m_dropOverLimit;
- return false;
- }
-
- // Tag packet with current time for DoDequeue() to compute sojourn time
- CoDelTimestampTag tag;
- p->AddByteTag (tag);
-
- m_bytesInQueue += p->GetSize ();
- m_packets.push (p);
-
- NS_LOG_LOGIC ("Number packets " << m_packets.size ());
- NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
-
- return true;
-}
-
-bool
-CoDelQueue::ShouldDrop(Ptr<Packet> p, codelTime_t now)
-{
- CoDelTimestampTag tag;
- bool drop;
- p->FindFirstMatchingByteTag (tag);
- Time delta = Simulator::Now () - tag.GetTxTime ();
- NS_LOG_INFO ("Sojourn time "<< delta.GetSeconds ());
- codelTime_t sojournTime = TIME2CODEL(delta);
-
- if (CoDelTimeBefore(sojournTime, TIME2CODEL(m_target)) ||
- *backlog < m_minBytes)
- {
- /* went below so we'll stay below for at least q->interval */
- m_firstAboveTime = 0;
- return false;
- }
- drop = false;
- if (m_firstAboveTime == 0)
- {
- /* just went above from below. If we stay above
- * for at least q->interval we'll say it's ok to drop
- */
- m_firstAboveTime = now + TIME2CODEL(m_interval);
- }
- else
- if (CoDelTimeAfter(now, m_firstAboveTime))
- {
- drop = true;
- ++m_state1;
- }
- return drop;
-}
-
-Ptr<Packet>
-CoDelQueue::DoDequeue (void)
-{
- NS_LOG_FUNCTION (this);
-
- if (m_packets.empty ())
- {
- m_dropping = false;
- m_firstAboveTime = 0;
- NS_LOG_LOGIC ("Queue empty");
- return 0;
- }
- codelTime_t now = CoDelGetTime();
- Ptr<Packet> p = m_packets.front ();
- m_packets.pop ();
- m_bytesInQueue -= p->GetSize ();
-
- NS_LOG_LOGIC ("Popped " << p);
- NS_LOG_LOGIC ("Number packets " << m_packets.size ());
- NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
-
- bool drop = ShouldDrop(p, now);
- if (m_dropping)
- {// In the dropping state (sojourn time has gone above target and hasn't come down yet)
- // Check if we can leave the dropping state or next drop should occur
- if (!drop)
- {
- /* sojourn time below target - leave dropping state */
- m_dropping = false;
- }
- else
- if (CoDelTimeAfterEq(now, m_dropNext))
- {
- m_state2++;
- /* It's time for the next drop. Drop the current
- * packet and dequeue the next. The dequeue might
- * take us out of dropping state.
- * If not, schedule the next drop.
- * A large backlog might result in drop rates so high
- * that the next drop should happen now,
- * hence the while loop.
- */
- while (m_dropping &&
- CoDelTimeAfterEq(now, m_dropNext)) {
- Drop(p);
- ++m_dropCount;
- ++m_count;
- NewtonStep();
- if (m_packets.empty ())
- {
- m_dropping = false;
- NS_LOG_LOGIC ("Queue empty");
- ++m_states;
- return 0;
- }
- p = m_packets.front ();
- m_packets.pop ();
- m_bytesInQueue -= p->GetSize ();
-
- NS_LOG_LOGIC ("Popped " << p);
- NS_LOG_LOGIC ("Number packets " << m_packets.size ());
- NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
-
- if (!ShouldDrop(p, now))
- {
- /* leave dropping state */
- m_dropping = false;
- }
- else
- {
- /* and schedule the next drop */
- m_dropNext = ControlLaw(m_dropNext);
- }
- }
- }
- }
- else
- // Not in the dropping state
- // Decide if we have to enter the dropping state and drop the first packet
- if(drop)
- {
- // Drop the first packet and enter dropping state unless the queue is empty
- ++m_dropCount;
- Drop(p);
- if (m_packets.empty ())
- {
- m_dropping = false;
- drop = false;
- NS_LOG_LOGIC ("Queue empty");
- ++m_states;
- }
- else {
- p = m_packets.front ();
- m_packets.pop ();
- m_bytesInQueue -= p->GetSize ();
-
- NS_LOG_LOGIC ("Popped " << p);
- NS_LOG_LOGIC ("Number packets " << m_packets.size ());
- NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
-
- drop = ShouldDrop(p, now);
- m_dropping = true;
- }
- ++m_state3;
- /*
- * if min went above target close to when we last went below it
- * assume that the drop rate that controlled the queue on the
- * last cycle is a good starting point to control it now.
- */
- int delta = m_count - m_lastCount;
- if (delta > 1 && CoDelTimeBefore(now - m_dropNext, 16*TIME2CODEL(m_interval)))
- {
- m_count = delta;
- NewtonStep();
- }
- else
- {
- m_count = 1;
- m_recInvSqrt = ~0U >> REC_INV_SQRT_SHIFT;
- }
- m_lastCount = m_count;
- m_dropNext = ControlLaw(now);
- }
- ++m_states;
- return p;
-}
-
-uint32_t
-CoDelQueue::GetQueueSize (void)
-{
- NS_LOG_FUNCTION_NOARGS ();
- if (GetMode () == BYTES)
- {
- return m_bytesInQueue;
- }
- else if (GetMode () == PACKETS)
- {
- return m_packets.size ();
- }
- else
- {
- NS_ABORT_MSG ("Unknown mode.");
- }
-}
-
-uint32_t
-CoDelQueue::GetDropOverLimit (void)
-{
- return m_dropOverLimit;
-}
-
-uint32_t
-CoDelQueue::GetDropCount (void)
-{
- return m_dropCount;
-}
-
-Time
-CoDelQueue::GetTarget (void)
-{
- return m_target;
-}
-
-Time
-CoDelQueue::GetInterval (void)
-{
- return m_interval;
-}
-
-Ptr<const Packet>
-CoDelQueue::DoPeek (void) const
-{
- NS_LOG_FUNCTION (this);
-
- if (m_packets.empty ())
- {
- NS_LOG_LOGIC ("Queue empty");
- return 0;
- }
-
- Ptr<Packet> p = m_packets.front ();
-
- NS_LOG_LOGIC ("Number packets " << m_packets.size ());
- NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
-
- return p;
-}
-
-} // namespace ns3
-
--- a/src/network/utils/codel-queue.h Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,197 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2012 Andrew McGregor
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Codel, the COntrolled DELay Queueing discipline
- * Based on ns2 simulation code presented by Kathie Nichols
- *
- * This port based on linux kernel code by
- * Authors: Dave Täht <d@taht.net>
- * Eric Dumazet <edumazet@google.com>
- *
- * Ported to ns-3 by: Andrew McGregor <andrewmcgr@gmail.com>
- */
-
-#ifndef CODEL_H
-#define CODEL_H
-
-#include <queue>
-#include "ns3/packet.h"
-#include "ns3/queue.h"
-#include "ns3/nstime.h"
-#include "ns3/simulator.h"
-#include "ns3/string.h"
-#include "ns3/traced-value.h"
-#include "ns3/trace-source-accessor.h"
-
-namespace ns3 {
-
-typedef uint32_t codelTime_t;
-typedef uint16_t recInvSqrt_t;
-
-#define CODEL_SHIFT 10
-#define REC_INV_SQRT_BITS (8*sizeof(recInvSqrt_t))
-#define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS)
-
-class TraceContainer;
-
-/**
- * \ingroup queue
- *
- * \brief A CoDel packet queue
- */
-
-class CoDelQueue : public Queue
-{
-public:
- friend class Fq_CoDelQueue;
-
- static TypeId GetTypeId (void);
-
- /**
- * \brief CoDelQueue Constructor
- *
- * Creates a CoDel queue with a maximum size of 1000 packets by default
- */
- CoDelQueue ();
-
- virtual ~CoDelQueue();
-
- /**
- * \brief Enumeration of the modes supported in the class
- */
- enum Mode
- {
- ILLEGAL, /**< Mode not set */
- PACKETS, /**< Use number of packets for maximum queue size */
- BYTES, /**< Use number of bytes for maximum queue size */
- };
-
- /**
- * \brief Set the operating mode of this device.
- *
- * \param mode The operating mode of this device.
- */
- void SetMode (CoDelQueue::Mode mode);
-
- /**
- * \brief Get the encapsulation mode of this device.
- *
- * \returns The encapsulation mode of this device.
- */
- CoDelQueue::Mode GetMode (void);
-
- /**
- * \brief Get the current value of the queue in bytes or packets.
- *
- * \returns The queue size in bytes or packets.
- */
- uint32_t GetQueueSize (void);
-
- /**
- * \brief Get the number of packets dropped due to full queue
- *
- * \returns The number of dropped packets
- */
- uint32_t GetDropOverLimit (void);
-
- /**
- * \brief Get the number of packets dropped according to CoDel algorithm
- *
- * \returns The number of dropped packets
- */
- uint32_t GetDropCount (void);
-
- /**
- * \brief Get the target queue delay
- *
- * \returns The target queue delay
- */
- Time GetTarget (void);
-
- /**
- * \brief Get the interval
- *
- * \returns The interval
- */
- Time GetInterval (void);
-
-private:
- /**
- * \brief Add a packet to the queue
- *
- * \param p The packet 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);
-
- /**
- * \brief Remove a packet from queue based on the current state
- * If we are in dropping state, check if we could leave the dropping state
- * or if we should perform next drop
- * If we are not currently in dropping state, check if we need to enter the state
- * and drop the first packet
- *
- * \returns The packet that is examined
- */
- virtual Ptr<Packet> DoDequeue (void);
-
- virtual Ptr<const Packet> DoPeek (void) const;
- void NewtonStep(void);
-
- /**
- * \brief Determine the time for next drop
- *
- * \param t Current next drop time
- * \returns The next next-drop time
- */
- codelTime_t ControlLaw(codelTime_t t);
-
- /**
- * \brief Determine whether a packet should be dropped
- *
- * \param p The packet that is considered
- * \param now The current time
- * \returns True if it is OK to drop the packet (sojourn time above target for at least interval)
- */
- bool ShouldDrop(Ptr<Packet> p, codelTime_t now);
-
- std::queue<Ptr<Packet> > 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
- uint32_t m_bytesInQueue; //!< The total number of bytes in queue
- uint32_t *backlog; //!< Bytes in queue
- uint32_t m_minBytes; //!< Minimum bytes in queue to allow a packet drop
- Time m_interval; //!< 100 ms sliding minimum time window width
- Time m_target; //!< 5 ms target queue delay
- TracedValue<uint32_t> m_count; //!< Number of packets dropped since entering drop state
- TracedValue<uint32_t> m_dropCount; //!< Number of dropped packets according CoDel algorithm
- TracedValue<uint32_t> m_lastCount; //<! Last number of packets dropped since entering drop state
- bool m_dropping; //!< True if in dropping state
- uint16_t m_recInvSqrt; //!< Reciprocal inverse square root
- codelTime_t m_firstAboveTime; //!< Time to declare sojourn time above target
- codelTime_t m_dropNext; //!< Time to drop next packet
- uint32_t m_state1; //!< Number of times packet sojourn goes above target for interval
- uint32_t m_state2; //!< Number of times we perform next drop while in dropping state
- uint32_t m_state3; //!< Number of times we enter drop state and drop the fist packet
- uint32_t m_states; //!< Total number of times we are in state 1, state 2, or state 3
- uint32_t m_dropOverLimit; //!< The number of packets dropped due to full queue
- Mode m_mode; //!< The operating mode (PACKETS, BYTES, or ILLEGAL)
-};
-
-} // namespace ns3
-
-#endif /* CODEL_H */
--- a/src/network/utils/codel-timestamp-tag.cc Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#include "codel-timestamp-tag.h"
-
-namespace ns3 {
-CoDelTimestampTag::CoDelTimestampTag ()
- : m_creationTime (Simulator::Now ().GetTimeStep ())
-{
-}
-
-TypeId
-CoDelTimestampTag::GetTypeId (void)
-{
- static TypeId tid = TypeId ("anon::CoDelTimestampTag")
- .SetParent<Tag> ()
- .AddConstructor<CoDelTimestampTag> ()
- .AddAttribute ("CreationTime",
- "The time at which the timestamp was created",
- StringValue ("0.0s"),
- MakeTimeAccessor (&CoDelTimestampTag::GetTxTime),
- MakeTimeChecker ())
- ;
- return tid;
-}
-TypeId
-CoDelTimestampTag::GetInstanceTypeId (void) const
-{
- return GetTypeId ();
-}
-
-uint32_t
-CoDelTimestampTag::GetSerializedSize (void) const
-{
- return 8;
-}
-void
-CoDelTimestampTag::Serialize (TagBuffer i) const
-{
- i.WriteU64 (m_creationTime);
-}
-void
-CoDelTimestampTag::Deserialize (TagBuffer i)
-{
- m_creationTime = i.ReadU64 ();
-}
-void
-CoDelTimestampTag::Print (std::ostream &os) const
-{
- os << "CreationTime=" << m_creationTime;
-}
-Time
-CoDelTimestampTag::GetTxTime (void) const
-{
- return TimeStep (m_creationTime);
-}
-}
--- a/src/network/utils/codel-timestamp-tag.h Wed Aug 27 14:39:08 2014 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#ifndef CODELTIMESTAMPTAG_H
-#define CODELTIMESTAMPTAG_H
-
-#include "ns3/log.h"
-#include "ns3/enum.h"
-#include "ns3/uinteger.h"
-#include "ns3/abort.h"
-#include <queue>
-#include "ns3/packet.h"
-#include "ns3/queue.h"
-#include "ns3/nstime.h"
-#include "ns3/simulator.h"
-#include "ns3/string.h"
-#include "ns3/traced-value.h"
-#include "ns3/trace-source-accessor.h"
-
-namespace ns3 {
-class CoDelTimestampTag : public Tag
-{
-public:
- CoDelTimestampTag ();
- static TypeId GetTypeId (void);
- virtual TypeId GetInstanceTypeId (void) const;
-
- virtual uint32_t GetSerializedSize (void) const;
- virtual void Serialize (TagBuffer i) const;
- virtual void Deserialize (TagBuffer i);
- virtual void Print (std::ostream &os) const;
-
- Time GetTxTime (void) const;
-private:
- uint64_t m_creationTime;
-};
-}
-#endif