diff --git a/examples/routing/global-injection-slash32.cc b/examples/routing/global-injection-slash32.cc index d89fdd957..572420b16 100644 --- a/examples/routing/global-injection-slash32.cc +++ b/examples/routing/global-injection-slash32.cc @@ -83,10 +83,12 @@ main (int argc, char *argv[]) Ptr deviceA = CreateObject (); deviceA->SetAddress (Mac48Address::Allocate ()); nA->AddDevice (deviceA); + deviceA->SetQueue (CreateObject > ()); Ptr deviceC = CreateObject (); deviceC->SetAddress (Mac48Address::Allocate ()); nC->AddDevice (deviceC); + deviceC->SetQueue (CreateObject > ()); // Later, we add IP addresses. Ipv4AddressHelper ipv4; diff --git a/examples/routing/global-routing-slash32.cc b/examples/routing/global-routing-slash32.cc index 561f419a7..c8ee02c49 100644 --- a/examples/routing/global-routing-slash32.cc +++ b/examples/routing/global-routing-slash32.cc @@ -69,10 +69,12 @@ main (int argc, char *argv[]) Ptr deviceA = CreateObject (); deviceA->SetAddress (Mac48Address::Allocate ()); nA->AddDevice (deviceA); + deviceA->SetQueue (CreateObject > ()); Ptr deviceC = CreateObject (); deviceC->SetAddress (Mac48Address::Allocate ()); nC->AddDevice (deviceC); + deviceC->SetQueue (CreateObject > ()); // Later, we add IP addresses. Ipv4AddressHelper ipv4; diff --git a/examples/routing/static-routing-slash32.cc b/examples/routing/static-routing-slash32.cc index a2b6126d3..8850cd6ef 100644 --- a/examples/routing/static-routing-slash32.cc +++ b/examples/routing/static-routing-slash32.cc @@ -69,10 +69,12 @@ main (int argc, char *argv[]) Ptr deviceA = CreateObject (); deviceA->SetAddress (Mac48Address::Allocate ()); nA->AddDevice (deviceA); + deviceA->SetQueue (CreateObject > ()); Ptr deviceC = CreateObject (); deviceC->SetAddress (Mac48Address::Allocate ()); nC->AddDevice (deviceC); + deviceC->SetQueue (CreateObject > ()); // Later, we add IP addresses. Ipv4AddressHelper ipv4; diff --git a/src/csma/model/csma-net-device.cc b/src/csma/model/csma-net-device.cc index 3dbbe08e2..0cdcb7ffb 100644 --- a/src/csma/model/csma-net-device.cc +++ b/src/csma/model/csma-net-device.cc @@ -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 ndqi = this->GetObject (); + //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) { diff --git a/src/csma/model/csma-net-device.h b/src/csma/model/csma-net-device.h index 99ff9ddb7..578441c0b 100644 --- a/src/csma/model/csma-net-device.h +++ b/src/csma/model/csma-net-device.h @@ -39,6 +39,7 @@ namespace ns3 { template 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 p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber); + virtual void DoInitialize (void); + virtual void NotifyNewAggregate (void); + private: /** @@ -683,6 +687,11 @@ private: */ Ptr m_node; + /** + * NetDevice queue interface. + */ + Ptr m_queueInterface; + /** * The MAC address which has been assigned to this device. */