From b51598d07650f84df79d35971d8a18cacb5da8f3 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 8 Mar 2017 18:02:07 +0100 Subject: [PATCH] wifi: Add support for flow control and BQL --- src/wifi/model/wifi-net-device.cc | 75 +++++++++++++++++++++++-------- src/wifi/model/wifi-net-device.h | 4 ++ 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/wifi/model/wifi-net-device.cc b/src/wifi/model/wifi-net-device.cc index 9e0827291..801c1a525 100644 --- a/src/wifi/model/wifi-net-device.cc +++ b/src/wifi/model/wifi-net-device.cc @@ -21,6 +21,7 @@ #include "wifi-net-device.h" #include "wifi-phy.h" #include "regular-wifi-mac.h" +#include "wifi-mac-queue.h" #include "ns3/llc-snap-header.h" #include "ns3/socket.h" #include "ns3/pointer.h" @@ -136,35 +137,71 @@ WifiNetDevice::NotifyNewAggregate (void) if (ndqi != 0) { m_queueInterface = ndqi; - if (m_mac == 0) - { - NS_LOG_WARN ("A mac has not been installed yet, using a single tx queue"); - } - else - { - Ptr mac = DynamicCast (m_mac); - if (mac != 0) - { - BooleanValue qosSupported; - mac->GetAttributeFailSafe ("QosSupported", qosSupported); - if (qosSupported.Get ()) - { - m_queueInterface->SetTxQueuesN (4); - // register the select queue callback - m_queueInterface->SetSelectQueueCallback (MakeCallback (&WifiNetDevice::SelectQueue, this)); - } - } - } + // register the select queue callback + m_queueInterface->SetSelectQueueCallback (MakeCallback (&WifiNetDevice::SelectQueue, this)); + m_queueInterface->SetLateTxQueuesCreation (true); + FlowControlConfig (); } } NetDevice::NotifyNewAggregate (); } +void +WifiNetDevice::FlowControlConfig (void) +{ + if (m_mac == 0 || m_queueInterface == 0) + { + return; + } + + Ptr mac = DynamicCast (m_mac); + if (mac == 0) + { + NS_LOG_WARN ("Flow control is only supported by RegularWifiMac"); + return; + } + + BooleanValue qosSupported; + mac->GetAttributeFailSafe ("QosSupported", qosSupported); + PointerValue ptr; + Ptr wmq; + if (qosSupported.Get ()) + { + m_queueInterface->SetTxQueuesN (4); + m_queueInterface->CreateTxQueues (); + + mac->GetAttributeFailSafe ("BE_EdcaTxopN", ptr); + wmq = ptr.Get ()->GetQueue (); + m_queueInterface->ConnectQueueTraces (wmq, 0); + + mac->GetAttributeFailSafe ("BK_EdcaTxopN", ptr); + wmq = ptr.Get ()->GetQueue (); + m_queueInterface->ConnectQueueTraces (wmq, 1); + + mac->GetAttributeFailSafe ("VI_EdcaTxopN", ptr); + wmq = ptr.Get ()->GetQueue (); + m_queueInterface->ConnectQueueTraces (wmq, 2); + + mac->GetAttributeFailSafe ("VO_EdcaTxopN", ptr); + wmq = ptr.Get ()->GetQueue (); + m_queueInterface->ConnectQueueTraces (wmq, 3); + } + else + { + m_queueInterface->CreateTxQueues (); + + mac->GetAttributeFailSafe ("DcaTxop", ptr); + wmq = ptr.Get ()->GetQueue (); + m_queueInterface->ConnectQueueTraces (wmq, 0); + } +} + void WifiNetDevice::SetMac (Ptr mac) { m_mac = mac; CompleteConfig (); + FlowControlConfig (); } void diff --git a/src/wifi/model/wifi-net-device.h b/src/wifi/model/wifi-net-device.h index 7f568c2c1..4279b2070 100644 --- a/src/wifi/model/wifi-net-device.h +++ b/src/wifi/model/wifi-net-device.h @@ -150,6 +150,10 @@ private: * connecting all lower components (e.g. MAC, WifiRemoteStation) together. */ void CompleteConfig (void); + /** + * Perform the actions needed to support flow control and dynamic queue limits + */ + void FlowControlConfig (void); /** * \brief Determine the tx queue for a given packet