From 9e5a51a40cab01fb6cca378eb09bd7916b045490 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 2 Apr 2019 23:26:49 +0200 Subject: [PATCH] wifi: Install a ConstantWifiAckPolicySelector on every QosTxop by default --- src/mesh/helper/mesh-helper.cc | 51 +++++++++++++++++++++++++++++++ src/mesh/helper/mesh-helper.h | 34 +++++++++++++++++++++ src/wave/helper/wave-helper.cc | 56 ++++++++++++++++++++++++++++++++++ src/wave/helper/wave-helper.h | 33 ++++++++++++++++++++ src/wifi/helper/wifi-helper.cc | 41 +++++++++++++++++++++++++ src/wifi/helper/wifi-helper.h | 35 +++++++++++++++++++++ src/wifi/model/qos-txop.cc | 16 ++++++++++ src/wifi/model/qos-txop.h | 14 +++++++++ 8 files changed, 280 insertions(+) diff --git a/src/mesh/helper/mesh-helper.cc b/src/mesh/helper/mesh-helper.cc index 2db1c43f7..75dcfb4ec 100644 --- a/src/mesh/helper/mesh-helper.cc +++ b/src/mesh/helper/mesh-helper.cc @@ -27,6 +27,7 @@ #include "ns3/minstrel-wifi-manager.h" #include "ns3/mesh-wifi-interface-mac.h" #include "ns3/wifi-helper.h" +#include "ns3/wifi-ack-policy-selector.h" namespace ns3 { @@ -119,6 +120,10 @@ MeshHelper::Default (void) MeshHelper helper; helper.SetMacType (); helper.SetRemoteStationManager ("ns3::ArfWifiManager"); + helper.SetAckPolicySelectorForAc (AC_BE, "ns3::ConstantWifiAckPolicySelector"); + helper.SetAckPolicySelectorForAc (AC_BK, "ns3::ConstantWifiAckPolicySelector"); + helper.SetAckPolicySelectorForAc (AC_VI, "ns3::ConstantWifiAckPolicySelector"); + helper.SetAckPolicySelectorForAc (AC_VO, "ns3::ConstantWifiAckPolicySelector"); helper.SetSpreadInterfaceChannels (SPREAD_CHANNELS); return helper; } @@ -165,6 +170,28 @@ MeshHelper::SetRemoteStationManager (std::string type, m_stationManager.Set (n6, v6); m_stationManager.Set (n7, v7); } +void +MeshHelper::SetAckPolicySelectorForAc (AcIndex ac, std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + m_ackPolicySelector[ac] = ObjectFactory (); + m_ackPolicySelector[ac].SetTypeId (type); + m_ackPolicySelector[ac].Set (n0, v0); + m_ackPolicySelector[ac].Set (n1, v1); + m_ackPolicySelector[ac].Set (n2, v2); + m_ackPolicySelector[ac].Set (n3, v3); + m_ackPolicySelector[ac].Set (n4, v4); + m_ackPolicySelector[ac].Set (n5, v5); + m_ackPolicySelector[ac].Set (n6, v6); + m_ackPolicySelector[ac].Set (n7, v7); +} void MeshHelper::SetStandard (enum WifiPhyStandard standard) { @@ -191,6 +218,30 @@ MeshHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr node, uin device->SetRemoteStationManager (manager); node->AddDevice (device); mac->SwitchFrequencyChannel (channelId); + // Install ack policy selector + PointerValue ptr; + Ptr ackSelector; + + mac->GetAttributeFailSafe ("BE_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_BE].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + + mac->GetAttributeFailSafe ("BK_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_BK].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + + mac->GetAttributeFailSafe ("VI_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_VI].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + + mac->GetAttributeFailSafe ("VO_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_VO].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + return device; } void diff --git a/src/mesh/helper/mesh-helper.h b/src/mesh/helper/mesh-helper.h index 8b0e747c9..1f7625c04 100644 --- a/src/mesh/helper/mesh-helper.h +++ b/src/mesh/helper/mesh-helper.h @@ -25,6 +25,7 @@ #include "ns3/mesh-stack-installer.h" #include "ns3/wifi-phy-standard.h" +#include "ns3/qos-utils.h" #include "ns3/object-factory.h" namespace ns3 { @@ -120,6 +121,38 @@ public: std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + /** + * \param ac the Access Category to attach the ack policy selector to. + * \param type the type of ns3::WifiAckPolicySelector to create. + * \param n0 the name of the attribute to set + * \param v0 the value of the attribute to set + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * \param n2 the name of the attribute to set + * \param v2 the value of the attribute to set + * \param n3 the name of the attribute to set + * \param v3 the value of the attribute to set + * \param n4 the name of the attribute to set + * \param v4 the value of the attribute to set + * \param n5 the name of the attribute to set + * \param v5 the value of the attribute to set + * \param n6 the name of the attribute to set + * \param v6 the value of the attribute to set + * \param n7 the name of the attribute to set + * \param v7 the value of the attribute to set + * + * All the attributes specified in this method should exist + * in the requested ack policy selector. + */ + void SetAckPolicySelectorForAc (AcIndex ac, std::string type, + 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 (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** * Set PHY standard * \param standard the wifi phy standard @@ -231,6 +264,7 @@ private: // Interface factory ObjectFactory m_mac; ///< the MAC ObjectFactory m_stationManager; ///< the station manager + ObjectFactory m_ackPolicySelector[4]; ///< ack policy selector for all ACs enum WifiPhyStandard m_standard; ///< phy standard }; diff --git a/src/wave/helper/wave-helper.cc b/src/wave/helper/wave-helper.cc index 21ad754f3..bd9de0ab2 100644 --- a/src/wave/helper/wave-helper.cc +++ b/src/wave/helper/wave-helper.cc @@ -26,6 +26,7 @@ #include "ns3/minstrel-wifi-manager.h" #include "ns3/radiotap-header.h" #include "ns3/unused.h" +#include "ns3/wifi-ack-policy-selector.h" #include "wave-mac-helper.h" #include "wave-helper.h" @@ -277,6 +278,10 @@ WaveHelper::Default (void) "DataMode", StringValue ("OfdmRate6MbpsBW10MHz"), "ControlMode",StringValue ("OfdmRate6MbpsBW10MHz"), "NonUnicastMode", StringValue ("OfdmRate6MbpsBW10MHz")); + helper.SetAckPolicySelectorForAc (AC_BE, "ns3::ConstantWifiAckPolicySelector"); + helper.SetAckPolicySelectorForAc (AC_BK, "ns3::ConstantWifiAckPolicySelector"); + helper.SetAckPolicySelectorForAc (AC_VI, "ns3::ConstantWifiAckPolicySelector"); + helper.SetAckPolicySelectorForAc (AC_VO, "ns3::ConstantWifiAckPolicySelector"); return helper; } @@ -334,6 +339,29 @@ WaveHelper::SetRemoteStationManager (std::string type, m_stationManager.Set (n7, v7); } +void +WaveHelper::SetAckPolicySelectorForAc (AcIndex ac, std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + m_ackPolicySelector[ac] = ObjectFactory (); + m_ackPolicySelector[ac].SetTypeId (type); + m_ackPolicySelector[ac].Set (n0, v0); + m_ackPolicySelector[ac].Set (n1, v1); + m_ackPolicySelector[ac].Set (n2, v2); + m_ackPolicySelector[ac].Set (n3, v3); + m_ackPolicySelector[ac].Set (n4, v4); + m_ackPolicySelector[ac].Set (n5, v5); + m_ackPolicySelector[ac].Set (n6, v6); + m_ackPolicySelector[ac].Set (n7, v7); +} + void WaveHelper::SetChannelScheduler (std::string type, std::string n0, const AttributeValue &v0, @@ -398,6 +426,34 @@ WaveHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHe ocbMac->EnableForWave (device); ocbMac->SetWifiRemoteStationManager ( m_stationManager.Create ()); ocbMac->ConfigureStandard (WIFI_PHY_STANDARD_80211_10MHZ); + // Install ack policy selector + BooleanValue qosSupported; + PointerValue ptr; + Ptr ackSelector; + + ocbMac->GetAttributeFailSafe ("QosSupported", qosSupported); + if (qosSupported.Get ()) + { + ocbMac->GetAttributeFailSafe ("BE_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_BE].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + + ocbMac->GetAttributeFailSafe ("BK_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_BK].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + + ocbMac->GetAttributeFailSafe ("VI_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_VI].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + + ocbMac->GetAttributeFailSafe ("VO_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_VO].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); + } device->AddMac (*k, ocbMac); } diff --git a/src/wave/helper/wave-helper.h b/src/wave/helper/wave-helper.h index 248b3123a..40d969b2b 100644 --- a/src/wave/helper/wave-helper.h +++ b/src/wave/helper/wave-helper.h @@ -165,6 +165,38 @@ public: std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + /** + * \param ac the Access Category to attach the ack policy selector to. + * \param type the type of ns3::WifiAckPolicySelector to create. + * \param n0 the name of the attribute to set + * \param v0 the value of the attribute to set + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * \param n2 the name of the attribute to set + * \param v2 the value of the attribute to set + * \param n3 the name of the attribute to set + * \param v3 the value of the attribute to set + * \param n4 the name of the attribute to set + * \param v4 the value of the attribute to set + * \param n5 the name of the attribute to set + * \param v5 the value of the attribute to set + * \param n6 the name of the attribute to set + * \param v6 the value of the attribute to set + * \param n7 the name of the attribute to set + * \param v7 the value of the attribute to set + * + * All the attributes specified in this method should exist + * in the requested ack policy selector. + */ + void SetAckPolicySelectorForAc (AcIndex ac, std::string type, + 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 (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); /** * \param type the type of ns3::ChannelScheduler to create. * \param n0 the name of the attribute to set @@ -245,6 +277,7 @@ public: protected: ObjectFactory m_stationManager; ///< station manager + ObjectFactory m_ackPolicySelector[4]; ///< ack policy selector for all ACs ObjectFactory m_channelScheduler; ///< channel scheduler std::vector m_macsForChannelNumber; ///< MACs for channel number uint32_t m_physNumber; ///< Phy number diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index 9127e88b8..5f264e2dc 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -38,6 +38,7 @@ #include "ns3/vht-configuration.h" #include "ns3/he-configuration.h" #include "ns3/obss-pd-algorithm.h" +#include "ns3/wifi-ack-policy-selector.h" #include "wifi-helper.h" namespace ns3 { @@ -655,6 +656,10 @@ WifiHelper::WifiHelper () m_selectQueueCallback (&SelectQueueByDSField) { SetRemoteStationManager ("ns3::ArfWifiManager"); + SetAckPolicySelectorForAc (AC_BE, "ns3::ConstantWifiAckPolicySelector"); + SetAckPolicySelectorForAc (AC_BK, "ns3::ConstantWifiAckPolicySelector"); + SetAckPolicySelectorForAc (AC_VI, "ns3::ConstantWifiAckPolicySelector"); + SetAckPolicySelectorForAc (AC_VO, "ns3::ConstantWifiAckPolicySelector"); } void @@ -703,6 +708,29 @@ WifiHelper::SetObssPdAlgorithm (std::string type, m_obssPdAlgorithm.Set (n7, v7); } +void +WifiHelper::SetAckPolicySelectorForAc (AcIndex ac, std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) +{ + m_ackPolicySelector[ac] = ObjectFactory (); + m_ackPolicySelector[ac].SetTypeId (type); + m_ackPolicySelector[ac].Set (n0, v0); + m_ackPolicySelector[ac].Set (n1, v1); + m_ackPolicySelector[ac].Set (n2, v2); + m_ackPolicySelector[ac].Set (n3, v3); + m_ackPolicySelector[ac].Set (n4, v4); + m_ackPolicySelector[ac].Set (n5, v5); + m_ackPolicySelector[ac].Set (n6, v6); + m_ackPolicySelector[ac].Set (n7, v7); +} + void WifiHelper::SetStandard (WifiPhyStandard standard) { @@ -767,6 +795,7 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, BooleanValue qosSupported; PointerValue ptr; Ptr wmq; + Ptr ackSelector; rmac->GetAttributeFailSafe ("QosSupported", qosSupported); if (qosSupported.Get ()) @@ -775,18 +804,30 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, UintegerValue (4)); rmac->GetAttributeFailSafe ("BE_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_BE].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); wmq = ptr.Get ()->GetWifiMacQueue (); ndqi->GetTxQueue (0)->ConnectQueueTraces (wmq); rmac->GetAttributeFailSafe ("BK_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_BK].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); wmq = ptr.Get ()->GetWifiMacQueue (); ndqi->GetTxQueue (1)->ConnectQueueTraces (wmq); rmac->GetAttributeFailSafe ("VI_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_VI].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); wmq = ptr.Get ()->GetWifiMacQueue (); ndqi->GetTxQueue (2)->ConnectQueueTraces (wmq); rmac->GetAttributeFailSafe ("VO_Txop", ptr); + ackSelector = m_ackPolicySelector[AC_VO].Create (); + ackSelector->SetQosTxop (ptr.Get ()); + ptr.Get ()->SetAckPolicySelector (ackSelector); wmq = ptr.Get ()->GetWifiMacQueue (); ndqi->GetTxQueue (3)->ConnectQueueTraces (wmq); ndqi->SetSelectQueueCallback (m_selectQueueCallback); diff --git a/src/wifi/helper/wifi-helper.h b/src/wifi/helper/wifi-helper.h index 0342a8d8f..3d5ef995a 100644 --- a/src/wifi/helper/wifi-helper.h +++ b/src/wifi/helper/wifi-helper.h @@ -25,6 +25,7 @@ #include "ns3/trace-helper.h" #include "ns3/wifi-phy.h" +#include "ns3/qos-utils.h" #include "wifi-mac-helper.h" #include @@ -375,6 +376,39 @@ public: std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + /** + * \param ac the Access Category to attach the ack policy selector to. + * \param type the type of ns3::WifiAckPolicySelector to create. + * \param n0 the name of the attribute to set + * \param v0 the value of the attribute to set + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * \param n2 the name of the attribute to set + * \param v2 the value of the attribute to set + * \param n3 the name of the attribute to set + * \param v3 the value of the attribute to set + * \param n4 the name of the attribute to set + * \param v4 the value of the attribute to set + * \param n5 the name of the attribute to set + * \param v5 the value of the attribute to set + * \param n6 the name of the attribute to set + * \param v6 the value of the attribute to set + * \param n7 the name of the attribute to set + * \param v7 the value of the attribute to set + * + * All the attributes specified in this method should exist + * in the requested ack policy selector. + */ + void SetAckPolicySelectorForAc (AcIndex ac, std::string type, + 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 (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); + /// Callback invoked to determine the MAC queue selected for a given packet typedef std::function)> SelectQueueCallback; @@ -471,6 +505,7 @@ public: protected: ObjectFactory m_stationManager; ///< station manager + ObjectFactory m_ackPolicySelector[4]; ///< ack policy selector for all ACs WifiPhyStandard m_standard; ///< wifi standard SelectQueueCallback m_selectQueueCallback; ///< select queue callback ObjectFactory m_obssPdAlgorithm; ///< OBSS PD algorithm diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 1fd1b854f..51ef2a207 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -38,6 +38,8 @@ #include "mpdu-aggregator.h" #include "ctrl-headers.h" #include "wifi-phy.h" +#include "wifi-ack-policy-selector.h" +#include "wifi-psdu.h" #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } @@ -116,6 +118,7 @@ void QosTxop::DoDispose (void) { NS_LOG_FUNCTION (this); + m_ackPolicySelector = 0; m_baManager = 0; m_qosBlockedDestinations = 0; Txop::DoDispose (); @@ -153,6 +156,19 @@ QosTxop::SetWifiRemoteStationManager (const Ptr remote m_baManager->SetWifiRemoteStationManager (m_stationManager); } +void +QosTxop::SetAckPolicySelector (Ptr ackSelector) +{ + NS_LOG_FUNCTION (this << ackSelector); + m_ackPolicySelector = ackSelector; +} + +Ptr +QosTxop::GetAckPolicySelector (void) const +{ + return m_ackPolicySelector; +} + void QosTxop::SetTypeOfStation (TypeOfStation type) { diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index c5511b0c1..cadc3516d 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -39,6 +39,7 @@ class MgtAddBaResponseHeader; class MgtDelBaHeader; class AggregationCapableTransmissionListener; class WifiTxVector; +class WifiAckPolicySelector; /** * Enumeration for type of station @@ -120,6 +121,18 @@ public: * \param remoteManager WifiRemoteStationManager. */ void SetWifiRemoteStationManager (const Ptr remoteManager); + /** + * Set the ack policy selector. + * + * \param ackSelector the ack policy selector. + */ + void SetAckPolicySelector (Ptr ackSelector); + /** + * Return the ack policy selector. + * + * \return the ack policy selector. + */ + Ptr GetAckPolicySelector (void) const; /** * Set type of station with the given type. * @@ -610,6 +623,7 @@ private: AcIndex m_ac; //!< the access category TypeOfStation m_typeOfStation; //!< the type of station + Ptr m_ackPolicySelector; //!< Ack policy selector Ptr m_qosBlockedDestinations; //!< QOS blocked destinations Ptr m_baManager; //!< the Block ACK manager uint8_t m_blockAckThreshold; //!< the Block ACK threshold