csma: Add support for flow control and BQL
This commit is contained in:
@@ -83,10 +83,12 @@ main (int argc, char *argv[])
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
deviceA->SetQueue (CreateObject<DropTailQueue<Packet> > ());
|
||||
|
||||
Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
deviceC->SetQueue (CreateObject<DropTailQueue<Packet> > ());
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
|
||||
@@ -69,10 +69,12 @@ main (int argc, char *argv[])
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
deviceA->SetQueue (CreateObject<DropTailQueue<Packet> > ());
|
||||
|
||||
Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
deviceC->SetQueue (CreateObject<DropTailQueue<Packet> > ());
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
|
||||
@@ -69,10 +69,12 @@ main (int argc, char *argv[])
|
||||
Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
|
||||
deviceA->SetAddress (Mac48Address::Allocate ());
|
||||
nA->AddDevice (deviceA);
|
||||
deviceA->SetQueue (CreateObject<DropTailQueue<Packet> > ());
|
||||
|
||||
Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
|
||||
deviceC->SetAddress (Mac48Address::Allocate ());
|
||||
nC->AddDevice (deviceC);
|
||||
deviceC->SetQueue (CreateObject<DropTailQueue<Packet> > ());
|
||||
|
||||
// Later, we add IP addresses.
|
||||
Ipv4AddressHelper ipv4;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "csma-net-device.h"
|
||||
#include "csma-channel.h"
|
||||
#include "ns3/net-device-queue-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -189,7 +190,7 @@ CsmaNetDevice::CsmaNetDevice ()
|
||||
NS_LOG_FUNCTION (this);
|
||||
m_txMachineState = READY;
|
||||
m_tInterframeGap = Seconds (0);
|
||||
m_channel = 0;
|
||||
m_channel = 0;
|
||||
|
||||
//
|
||||
// We would like to let the attribute system take care of initializing the
|
||||
@@ -217,9 +218,45 @@ CsmaNetDevice::DoDispose ()
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_channel = 0;
|
||||
m_node = 0;
|
||||
m_queue = 0;
|
||||
m_queueInterface = 0;
|
||||
NetDevice::DoDispose ();
|
||||
}
|
||||
|
||||
void
|
||||
CsmaNetDevice::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
|
||||
CsmaNetDevice::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
|
||||
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace ns3 {
|
||||
template <typename Item> class Queue;
|
||||
class CsmaChannel;
|
||||
class ErrorModel;
|
||||
class NetDeviceQueueInterface;
|
||||
|
||||
/**
|
||||
* \defgroup csma CSMA Network Device
|
||||
@@ -128,7 +129,7 @@ public:
|
||||
*
|
||||
* The CsmaNetDevice "owns" a queue. This queue may be set by higher
|
||||
* level topology objects to implement a particular queueing method such as
|
||||
* DropTail or RED.
|
||||
* DropTail.
|
||||
*
|
||||
* \see Queue
|
||||
* \see DropTailQueue
|
||||
@@ -356,6 +357,9 @@ protected:
|
||||
*/
|
||||
void AddHeader (Ptr<Packet> p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber);
|
||||
|
||||
virtual void DoInitialize (void);
|
||||
virtual void NotifyNewAggregate (void);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -683,6 +687,11 @@ private:
|
||||
*/
|
||||
Ptr<Node> m_node;
|
||||
|
||||
/**
|
||||
* NetDevice queue interface.
|
||||
*/
|
||||
Ptr<NetDeviceQueueInterface> m_queueInterface;
|
||||
|
||||
/**
|
||||
* The MAC address which has been assigned to this device.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user