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
Initial support for multiple transmission queues inside NetDevices
This patch adds a NetDeviceQueue class to store information about a single
transmission queue of a network device. This class is meant to store the
state of a transmission queue (i.e., whether the queue is stopped or not)
and some data used by techniques such as Byte Queue Limits. Also, multi-queue
aware queue discs can aggregate a child queue disc to an object of this class.
These features (excluding BQL) are added in subsequent commits.
The NetDevice class maintains a vector of NetDeviceQueue pointers, one for
each transmission queue. A NetDevice constructor is added which creates a
single transmission queue by default for every device. The number of transmission
queues can be modified (by child classes) by calling NetDevice::SetTxQueuesN.
Two public methods, GetTxQueue and GetTxQueuesN, are also added to the NetDevice class
to return the i-th NetDeviceQueue and the number of transmission queues, respectively.
  • Loading branch information
stavallo committed Jan 15, 2016
commit 0c814e4d60d6e816655991a0a466174d314cc0b6
52 changes: 52 additions & 0 deletions src/network/model/net-device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,38 @@

#include "ns3/object.h"
#include "ns3/log.h"
#include "ns3/abort.h"
#include "ns3/uinteger.h"
#include "net-device.h"

namespace ns3 {

NS_LOG_COMPONENT_DEFINE ("NetDevice");

NS_OBJECT_ENSURE_REGISTERED (NetDeviceQueue);

TypeId NetDeviceQueue::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::NetDeviceQueue")
.SetParent<Object> ()
.SetGroupName("Network")
;
return tid;
}

NetDeviceQueue::~NetDeviceQueue ()
{
NS_LOG_FUNCTION (this);
}

void
NetDeviceQueue::SetDevice (Ptr<NetDevice> device)
{
NS_ABORT_MSG_UNLESS (m_device == 0, "Cannot change the device which a transmission queue belongs to.");
m_device = device;
}


NS_OBJECT_ENSURE_REGISTERED (NetDevice);

TypeId NetDevice::GetTypeId (void)
Expand All @@ -38,9 +63,36 @@ TypeId NetDevice::GetTypeId (void)
return tid;
}

NetDevice::NetDevice ()
{
NS_LOG_FUNCTION_NOARGS ();
Ptr<NetDeviceQueue> devQueue = Create<NetDeviceQueue> ();
devQueue->SetDevice (this);
m_txQueuesVector.push_back (devQueue);
}

NetDevice::~NetDevice ()
{
NS_LOG_FUNCTION (this);
}

void
NetDevice::SetTxQueuesN (uint8_t numTxQueues)
{
NS_ASSERT (numTxQueues > 0);

/// \todo check whether a queue disc has been aggregated to the device

uint8_t prevNumTxQueues = m_txQueuesVector.size ();
m_txQueuesVector.resize (numTxQueues);

// Allocate new NetDeviceQueues if the number of queues increased
for (uint8_t i = prevNumTxQueues; i < numTxQueues; i++)
{
Ptr<NetDeviceQueue> devQueue = Create<NetDeviceQueue> ();
devQueue->SetDevice (this);
m_txQueuesVector[i] = devQueue;
}
}

} // namespace ns3
96 changes: 96 additions & 0 deletions src/network/model/net-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define NET_DEVICE_H

#include <string>
#include <vector>
#include <stdint.h>
#include "ns3/callback.h"
#include "ns3/object.h"
Expand All @@ -35,11 +36,55 @@ namespace ns3 {
class Node;
class Channel;
class Packet;
class NetDevice;

/**
* \ingroup network
* \defgroup netdevice Network Device
*/
/**
* \ingroup netdevice
*
* \brief Network device transmission queue
*
* This class stores information about a single transmission queue
* of a network device that is exposed to queue discs. Such information
* includes the state of the transmission queue (whether it has been
* stopped or not) and data used by techniques such as Byte Queue Limits.
* Also, multi-queue aware queue discs can aggregate a child queue disc
* to an object of this class.
*
* This class roughly models the struct netdev_queue of Linux.
* \todo Store the state information (done in a next commit)
* \todo Implement BQL
*/
class NetDeviceQueue : public SimpleRefCount<NetDeviceQueue>
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId (void);

virtual ~NetDeviceQueue();

/**
* \return the device which this transmission queue belongs to.
*/
inline Ptr<NetDevice> GetDevice (void) const;

/**
* \param device the device which this transmission queue belongs to.
*
* The device can be set just once.
*/
virtual void SetDevice (Ptr<NetDevice> device);

private:
Ptr<NetDevice> m_device;
};

/**
* \ingroup netdevice
*
Expand Down Expand Up @@ -80,6 +125,8 @@ class NetDevice : public Object
* \return the object TypeId
*/
static TypeId GetTypeId (void);

NetDevice ();
virtual ~NetDevice();

/**
Expand Down Expand Up @@ -339,8 +386,57 @@ class NetDevice : public Object
*/
virtual bool SupportsSendFrom (void) const = 0;

/**
* \return the i-th transmission queue of the device.
*
* The index of the first transmission queue is zero.
*/
inline Ptr<NetDeviceQueue> GetTxQueue (uint8_t i) const;

/**
* \return the number of (hardware) transmission queues.
*/
inline uint8_t GetTxQueuesN (void) const;

protected:
/**
* \param numTxQueues number of (hardware) transmission queues.
*
* Modifying the number of transmission queues is only permitted before a queue
* disc is aggregated to the device. This is because we have to set a wake
* callback for each transmission queue, and this is done when setting up
* queue discs.
*/
virtual void SetTxQueuesN (uint8_t numTxQueues);

private:
std::vector< Ptr<NetDeviceQueue> > m_txQueuesVector;
};

} // namespace ns3


namespace ns3 {

Ptr<NetDevice>
NetDeviceQueue::GetDevice (void) const
{
return m_device;
}

Ptr<NetDeviceQueue>
NetDevice::GetTxQueue (uint8_t i) const
{
NS_ASSERT (i < m_txQueuesVector.size ());
return m_txQueuesVector[i];
}

uint8_t
NetDevice::GetTxQueuesN (void) const
{
return m_txQueuesVector.size ();
}

} // namespace ns3

#endif /* NET_DEVICE_H */