From c43ac519199c14bea7e478ecb736b815dd3f505c Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 24 Apr 2020 09:46:33 +0200 Subject: [PATCH] wifi: Add public methods to RegularWifiMac to get (Qos)Txops (Qos)Txops can be obtained via attributes anyway, so make it easier to get them. --- src/wifi/helper/wifi-helper.cc | 42 +++++++----------------------- src/wifi/model/regular-wifi-mac.cc | 12 +++++++++ src/wifi/model/regular-wifi-mac.h | 29 ++++++++++++++++----- 3 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/wifi/helper/wifi-helper.cc b/src/wifi/helper/wifi-helper.cc index fb4232456..285d1e053 100644 --- a/src/wifi/helper/wifi-helper.cc +++ b/src/wifi/helper/wifi-helper.cc @@ -899,51 +899,29 @@ WifiHelper::Install (const WifiPhyHelper &phyHelper, { Ptr ndqi; BooleanValue qosSupported; - PointerValue ptr; Ptr wmq; - Ptr ackSelector; rmac->GetAttributeFailSafe ("QosSupported", qosSupported); if (qosSupported.Get ()) { ndqi = CreateObjectWithAttributes ("NTxQueues", 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); + for (auto& ac : {AC_BE, AC_BK, AC_VI, AC_VO}) + { + Ptr qosTxop = rmac->GetQosTxop (ac); + auto ackSelector = m_ackPolicySelector[ac].Create (); + ackSelector->SetQosTxop (qosTxop); + qosTxop->SetAckPolicySelector (ackSelector); + wmq = qosTxop->GetWifiMacQueue (); + ndqi->GetTxQueue (static_cast (ac))->ConnectQueueTraces (wmq); + } ndqi->SetSelectQueueCallback (m_selectQueueCallback); } else { ndqi = CreateObject (); - rmac->GetAttributeFailSafe ("Txop", ptr); - wmq = ptr.Get ()->GetWifiMacQueue (); + wmq = rmac->GetTxop ()->GetWifiMacQueue (); ndqi->GetTxQueue (0)->ConnectQueueTraces (wmq); } device->AggregateObject (ndqi); diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index 5dae651bd..448cd5fca 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -456,6 +456,18 @@ RegularWifiMac::GetTxop () const return m_txop; } +Ptr +RegularWifiMac::GetQosTxop (AcIndex ac) const +{ + return m_edca.find (ac)->second; +} + +Ptr +RegularWifiMac::GetQosTxop (uint8_t tid) const +{ + return GetQosTxop (QosUtilsMapTidToAc (tid)); +} + Ptr RegularWifiMac::GetVOQueue () const { diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h index 610a44ca0..d8407153c 100644 --- a/src/wifi/model/regular-wifi-mac.h +++ b/src/wifi/model/regular-wifi-mac.h @@ -103,6 +103,28 @@ public: * \return the station manager attached to this MAC. */ Ptr GetWifiRemoteStationManager (void) const; + + /** + * Accessor for the DCF object + * + * \return a smart pointer to Txop + */ + Ptr GetTxop (void) const; + /** + * Accessor for a specified EDCA object + * + * \param ac the Access Category + * \return a smart pointer to a QosTxop + */ + Ptr GetQosTxop (AcIndex ac) const; + /** + * Accessor for a specified EDCA object + * + * \param tid the Traffic ID + * \return a smart pointer to a QosTxop + */ + Ptr GetQosTxop (uint8_t tid) const; + /** * Return the extended capabilities of the device. * @@ -158,13 +180,6 @@ protected: channel access function */ EdcaQueues m_edca; - /** - * Accessor for the DCF object - * - * \return a smart pointer to Txop - */ - Ptr GetTxop (void) const; - /** * Accessor for the AC_VO channel access function *