From 9ee9ec1c492a88cbcd2c2dc24ef3ea5295be183f Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 10 Jul 2009 17:59:20 +0400 Subject: [PATCH] Initial QoS implementation in 802.11s --- src/devices/mesh/mesh-wifi-interface-mac.cc | 67 +++++++++------------ src/devices/mesh/mesh-wifi-interface-mac.h | 14 ++--- src/helper/mesh-interface-helper.cc | 66 ++++++++++---------- src/helper/mesh-interface-helper.h | 25 +++----- 4 files changed, 76 insertions(+), 96 deletions(-) diff --git a/src/devices/mesh/mesh-wifi-interface-mac.cc b/src/devices/mesh/mesh-wifi-interface-mac.cc index 3ac6f77d4..e7c47aad1 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.cc +++ b/src/devices/mesh/mesh-wifi-interface-mac.cc @@ -62,18 +62,7 @@ MeshWifiInterfaceMac::GetTypeId () &MeshWifiInterfaceMac::GetBeaconGeneration ), MakeBooleanChecker () - ) - - .AddAttribute ("BE", "The DcaTxop object", - PointerValue (), - MakePointerAccessor (&MeshWifiInterfaceMac::GetBE, - &MeshWifiInterfaceMac::SetBE), - MakePointerChecker ()) - .AddAttribute ("VO", "The DcaTxop object", - PointerValue (), - MakePointerAccessor (&MeshWifiInterfaceMac::GetVO, - &MeshWifiInterfaceMac::SetVO), - MakePointerChecker ()); + ); return tid; } @@ -199,10 +188,8 @@ MeshWifiInterfaceMac::SetWifiRemoteStationManager (Ptr { NS_LOG_FUNCTION (this << stationManager); m_stationManager = stationManager; - NS_ASSERT(m_BE != 0); - m_BE->SetWifiRemoteStationManager (stationManager); - NS_ASSERT(m_VO != 0); - m_VO->SetWifiRemoteStationManager (stationManager); + for (Queues::const_iterator i = m_queues.begin (); i != m_queues.end (); i ++) + i->second->SetWifiRemoteStationManager (stationManager); m_beaconDca->SetWifiRemoteStationManager (stationManager); m_low->SetWifiRemoteStationManager (stationManager); } @@ -293,8 +280,7 @@ MeshWifiInterfaceMac::DoDispose () m_low = 0; m_dcfManager = 0; m_phy = 0; - m_BE = 0; - m_VO = 0; + m_queues.clear (); m_beaconSendEvent.Cancel (); m_beaconDca = 0; @@ -416,7 +402,7 @@ MeshWifiInterfaceMac::ForwardDown (Ptr const_packet, Mac48Address } m_stats.sentFrames ++; m_stats.sentBytes += packet->GetSize (); - m_BE->Queue (packet, hdr); + m_queues[AC_BK]->Queue (packet, hdr); } void @@ -431,7 +417,12 @@ MeshWifiInterfaceMac::SendManagementFrame (Ptr packet, const WifiMacHead } m_stats.sentFrames ++; m_stats.sentBytes += packet->GetSize (); - m_VO->Queue (packet, header); + Queues::iterator i = m_queues.find (AC_VO); + if (i == m_queues.end ()) + { + NS_FATAL_ERROR("Voice queue is not set up!"); + } + m_queues[AC_VO]->Queue (packet, header); } SupportedRates @@ -671,28 +662,28 @@ MeshWifiInterfaceMac::ResetStats () m_stats = Statistics::Statistics (); } void -MeshWifiInterfaceMac::SetBE (Ptr dcaTxop) +MeshWifiInterfaceMac::SetQueue (Ptr queue, AccessClass ac) { - m_BE = dcaTxop; - m_BE->SetLow (m_low); - m_BE->SetManager (m_dcfManager); -} -void -MeshWifiInterfaceMac::SetVO (Ptr dcaTxop) -{ - m_VO = dcaTxop; - m_VO->SetLow (m_low); - m_VO->SetManager (m_dcfManager); + Queues::iterator i = m_queues.find(ac); + if(i != m_queues.end ()) + { + NS_LOG_WARN("Queue is already set!"); + return; + } + m_queues.insert (std::make_pair(ac, queue)); + m_queues[ac]->SetLow (m_low); + m_queues[ac]->SetManager (m_dcfManager); } Ptr -MeshWifiInterfaceMac::GetBE () const +MeshWifiInterfaceMac::GetQueue (AccessClass ac) { - return m_BE; -} -Ptr -MeshWifiInterfaceMac::GetVO () const -{ - return m_VO; + Queues::iterator i = m_queues.find(ac); + if(i != m_queues.end ()) + { + NS_LOG_WARN("Queue is not found! Check access class!"); + return 0; + } + return i->second; } } // namespace ns3 diff --git a/src/devices/mesh/mesh-wifi-interface-mac.h b/src/devices/mesh/mesh-wifi-interface-mac.h index 0fafd04b8..a0b0db406 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.h +++ b/src/devices/mesh/mesh-wifi-interface-mac.h @@ -33,7 +33,7 @@ #include "ns3/wifi-mac.h" #include "ns3/mesh-wifi-interface-mac-plugin.h" #include "ns3/event-id.h" - +#include "qos-utils.h" namespace ns3 { class WifiMacHeader; @@ -160,11 +160,9 @@ public: void ResetStats (); /// Enable/disable beacons void SetBeaconGeneration (bool enable); + void SetQueue (Ptr queue, AccessClass ac); private: - Ptr GetBE(void) const; - void SetBE (Ptr dcaTxop); - Ptr GetVO(void) const; - void SetVO (Ptr dcaTxop); + Ptr GetQueue (AccessClass ac); /// Frame receive handler void Receive (Ptr packet, WifiMacHeader const *hdr); /// Forward frame to mesh point @@ -183,10 +181,8 @@ private: private: ///\name Wifi MAC internals //\{ - Ptr m_BE; - Ptr m_BK; - Ptr m_VI; - Ptr m_VO; + typedef std::map > Queues; + Queues m_queues; Ptr m_beaconDca; Ptr m_stationManager; Ptr m_phy; diff --git a/src/helper/mesh-interface-helper.cc b/src/helper/mesh-interface-helper.cc index a9b90719d..0064f887a 100644 --- a/src/helper/mesh-interface-helper.cc +++ b/src/helper/mesh-interface-helper.cc @@ -28,8 +28,15 @@ namespace ns3 { MeshInterfaceHelper::MeshInterfaceHelper () { - m_Be.SetTypeId ("ns3::DcaTxop"); - m_Vo.SetTypeId ("ns3::DcaTxop"); + m_queues.insert (std::make_pair (AC_VO, ObjectFactory ())); + m_queues.insert (std::make_pair (AC_VI, ObjectFactory ())); + m_queues.insert (std::make_pair (AC_BE, ObjectFactory ())); + m_queues.insert (std::make_pair (AC_BK, ObjectFactory ())); + + m_queues[AC_VO].SetTypeId ("ns3::DcaTxop"); + m_queues[AC_VI].SetTypeId ("ns3::DcaTxop"); + m_queues[AC_BE].SetTypeId ("ns3::DcaTxop"); + m_queues[AC_BK].SetTypeId ("ns3::DcaTxop"); } MeshInterfaceHelper::~MeshInterfaceHelper () @@ -40,14 +47,6 @@ MeshInterfaceHelper::Default (void) { MeshInterfaceHelper helper; helper.SetType (); - helper.SetBeParameters ( - "MinCw", UintegerValue (15), - "MaxCw", UintegerValue (255), - "Aifsn", UintegerValue (2)); - helper.SetVoParameters ( - "MinCw", UintegerValue (3), - "MaxCw", UintegerValue (7), - "Aifsn", UintegerValue (2)); helper.SetRemoteStationManager ("ns3::ArfWifiManager"); return helper; } @@ -73,26 +72,24 @@ MeshInterfaceHelper::SetType (std::string n0, const AttributeValue &v0, m_mac.Set (n7, v7); } void -MeshInterfaceHelper::SetBeParameters (std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3) +MeshInterfaceHelper::SetQueueParameters ( AccessClass ac, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3) { - m_Be.Set (n0, v0); - m_Be.Set (n1, v1); - m_Be.Set (n2, v2); - m_Be.Set (n3, v3); -} -void -MeshInterfaceHelper::SetVoParameters (std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3) -{ - m_Vo.Set (n0, v0); - m_Vo.Set (n1, v1); - m_Vo.Set (n2, v2); - m_Vo.Set (n3, v3); + std::map::iterator queue = m_queues.find (ac); + if (queue != m_queues.end ()) + { + queue->second.Set (n0, v0); + queue->second.Set (n1, v1); + queue->second.Set (n2, v2); + queue->second.Set (n3, v3); + } + else + { + NS_FATAL_ERROR ("Queue is not set!"); + } } void MeshInterfaceHelper::SetRemoteStationManager (std::string type, @@ -137,11 +134,12 @@ MeshInterfaceHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr Ptr MeshInterfaceHelper::Create (void) const { - Ptr mac = m_mac.Create (); - Ptr be = m_Be.Create (); - Ptr vo = m_Vo.Create (); - mac->SetAttribute ("BE", PointerValue (be)); - mac->SetAttribute ("VO", PointerValue (vo)); + Ptr mac = m_mac.Create (); + for (std::map::const_iterator i = m_queues.begin (); i != m_queues.end (); i ++) + { + //Ptr dca = i->second->Create (); + mac->SetQueue(i->second.Create (), i->first); + } return mac; } void diff --git a/src/helper/mesh-interface-helper.h b/src/helper/mesh-interface-helper.h index a67b8664e..7370d6151 100644 --- a/src/helper/mesh-interface-helper.h +++ b/src/helper/mesh-interface-helper.h @@ -23,6 +23,7 @@ #include "ns3/wifi-helper.h" #include "ns3/wifi-net-device.h" #include "ns3/mesh-wifi-interface-mac.h" +#include "ns3/qos-utils.h" namespace ns3 { class MeshInterfaceHelper : public WifiMacHelper @@ -51,23 +52,16 @@ public: std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** + * \param ac is access class of the queue to be adjusted * \param type the type of ns3::WifiMac to create. * \param n%d the name of the attribute to set * \param v%d the value of the attribute to set */ - void SetBeParameters ( std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ()); - /** - * \param type the type of ns3::WifiMac to create. - * \param n%d the name of the attribute to set - * \param v%d the value of the attribute to set - */ - void SetVoParameters ( std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ()); + void SetQueueParameters (AccessClass ac, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue ()); /** * \param type the type of ns3::WifiRemoteStationManager to create. * \param n%d the name of the attribute to set @@ -104,8 +98,9 @@ private: Ptr Create (void) const; ObjectFactory m_mac; - ObjectFactory m_Be; - ObjectFactory m_Vo; + std::map m_queues; + //ObjectFactory m_Be; + //ObjectFactory m_Vo; ObjectFactory m_stationManager; };