network: Add support for flow control and BQL to SimpleNetDevice

This commit is contained in:
Stefano Avallone
2017-03-08 18:01:51 +01:00
parent 4e9e6fec02
commit fb12ef3a8b
3 changed files with 42 additions and 2 deletions

View File

@@ -21,7 +21,7 @@
#include "ns3/simulator.h"
#include "ns3/pointer.h"
#include "ns3/log.h"
#include "ns3/queue.h"
#include "ns3/net-device-queue-interface.h"
#include "lte-simple-net-device.h"
namespace ns3 {

View File

@@ -29,7 +29,7 @@
#include "ns3/string.h"
#include "ns3/tag.h"
#include "ns3/simulator.h"
#include "ns3/queue.h"
#include "ns3/net-device-queue-interface.h"
namespace ns3 {
@@ -229,6 +229,40 @@ SimpleNetDevice::SimpleNetDevice ()
NS_LOG_FUNCTION (this);
}
void
SimpleNetDevice::DoInitialize (void)
{
if (m_queueInterface)
{
NS_ASSERT_MSG (m_queue != 0, "A Queue object has not been attached to the device");
// connect the traced callbacks of m_queue to the static methods provided by
// the NetDeviceQueue class to support flow control and dynamic queue limits.
// This could not be done in NotifyNewAggregate because at that time we are
// not guaranteed that a queue has been attached to the netdevice
m_queueInterface->ConnectQueueTraces (m_queue, 0);
}
NetDevice::DoInitialize ();
}
void
SimpleNetDevice::NotifyNewAggregate (void)
{
NS_LOG_FUNCTION (this);
if (m_queueInterface == 0)
{
Ptr<NetDeviceQueueInterface> ndqi = this->GetObject<NetDeviceQueueInterface> ();
//verify that it's a valid netdevice queue interface and that
//the netdevice queue interface was not set before
if (ndqi != 0)
{
m_queueInterface = ndqi;
}
}
NetDevice::NotifyNewAggregate ();
}
void
SimpleNetDevice::Receive (Ptr<Packet> packet, uint16_t protocol,
Mac48Address to, Mac48Address from)
@@ -538,6 +572,7 @@ SimpleNetDevice::DoDispose (void)
m_node = 0;
m_receiveErrorModel = 0;
m_queue->Flush ();
m_queueInterface = 0;
if (TransmitCompleteEvent.IsRunning ())
{
TransmitCompleteEvent.Cancel ();

View File

@@ -36,6 +36,7 @@ template <typename Item> class Queue;
class SimpleChannel;
class Node;
class ErrorModel;
class NetDeviceQueueInterface;
/**
* \ingroup netdevice
@@ -137,11 +138,15 @@ public:
protected:
virtual void DoDispose (void);
virtual void DoInitialize (void);
virtual void NotifyNewAggregate (void);
private:
Ptr<SimpleChannel> m_channel; //!< the channel the device is connected to
NetDevice::ReceiveCallback m_rxCallback; //!< Receive callback
NetDevice::PromiscReceiveCallback m_promiscCallback; //!< Promiscuous receive callback
Ptr<Node> m_node; //!< Node this netDevice is associated to
Ptr<NetDeviceQueueInterface> m_queueInterface; //!< NetDevice queue interface
uint16_t m_mtu; //!< MTU
uint32_t m_ifIndex; //!< Interface index
Mac48Address m_address; //!< MAC address