diff --git a/src/wifi/model/mpdu-aggregator.cc b/src/wifi/model/mpdu-aggregator.cc index a58b0ff8f..af4f05b3c 100644 --- a/src/wifi/model/mpdu-aggregator.cc +++ b/src/wifi/model/mpdu-aggregator.cc @@ -34,7 +34,7 @@ #include "ht-capabilities.h" #include "vht-capabilities.h" #include "he-capabilities.h" -#include "wifi-mac.h" +#include "regular-wifi-mac.h" #include "ctrl-headers.h" #include "wifi-mac-trailer.h" @@ -64,9 +64,17 @@ MpduAggregator::~MpduAggregator () } void -MpduAggregator::SetEdcaQueues (EdcaQueues edcaQueues) +MpduAggregator::DoDispose () { - m_edca = edcaQueues; + m_mac = 0; + Object::DoDispose (); +} + +void +MpduAggregator::SetWifiMac (const Ptr mac) +{ + NS_LOG_FUNCTION (this << mac); + m_mac = mac; } void @@ -116,11 +124,6 @@ MpduAggregator::GetMaxAmpduSize (Mac48Address recipient, uint8_t tid, NS_LOG_FUNCTION (this << recipient << +tid << modulation); AcIndex ac = QosUtilsMapTidToAc (tid); - Ptr qosTxop = m_edca.find (ac)->second; - Ptr device = DynamicCast (qosTxop->GetLow ()->GetPhy ()->GetDevice ()); - NS_ASSERT (device); - Ptr stationManager = device->GetRemoteStationManager (); - NS_ASSERT (stationManager); // Find the A-MPDU max size configured on this device UintegerValue size; @@ -128,16 +131,16 @@ MpduAggregator::GetMaxAmpduSize (Mac48Address recipient, uint8_t tid, switch (ac) { case AC_BE: - device->GetMac ()->GetAttribute ("BE_MaxAmpduSize", size); + m_mac->GetAttribute ("BE_MaxAmpduSize", size); break; case AC_BK: - device->GetMac ()->GetAttribute ("BK_MaxAmpduSize", size); + m_mac->GetAttribute ("BK_MaxAmpduSize", size); break; case AC_VI: - device->GetMac ()->GetAttribute ("VI_MaxAmpduSize", size); + m_mac->GetAttribute ("VI_MaxAmpduSize", size); break; case AC_VO: - device->GetMac ()->GetAttribute ("VO_MaxAmpduSize", size); + m_mac->GetAttribute ("VO_MaxAmpduSize", size); break; default: NS_ABORT_MSG ("Unknown AC " << ac); @@ -152,6 +155,9 @@ MpduAggregator::GetMaxAmpduSize (Mac48Address recipient, uint8_t tid, return 0; } + Ptr stationManager = m_mac->GetWifiRemoteStationManager (); + NS_ASSERT (stationManager); + // Retrieve the Capabilities elements advertised by the recipient Ptr heCapabilities = stationManager->GetStationHeCapabilities (recipient); Ptr vhtCapabilities = stationManager->GetStationVhtCapabilities (recipient); @@ -216,10 +222,10 @@ MpduAggregator::GetNextAmpdu (Ptr mpdu, WifiTxVector txV NS_ASSERT (mpdu->GetHeader ().IsQosData () && !recipient.IsGroup ()); uint8_t tid = GetTid (mpdu->GetPacket (), mpdu->GetHeader ()); - auto edcaIt = m_edca.find (QosUtilsMapTidToAc (tid)); - NS_ASSERT (edcaIt != m_edca.end ()); + Ptr qosTxop = m_mac->GetQosTxop (tid); + NS_ASSERT (qosTxop != 0); - WifiModulationClass modulation = txVector.GetMode ().GetModulationClass (); + WifiModulationClass modulation = txVector.GetModulationClass (); uint32_t maxAmpduSize = GetMaxAmpduSize (recipient, tid, modulation); if (maxAmpduSize == 0) @@ -229,16 +235,16 @@ MpduAggregator::GetNextAmpdu (Ptr mpdu, WifiTxVector txV } //Have to make sure that the block ack agreement is established before sending an A-MPDU - if (edcaIt->second->GetBaAgreementEstablished (recipient, tid)) + if (qosTxop->GetBaAgreementEstablished (recipient, tid)) { /* here is performed MPDU aggregation */ - uint16_t startingSequenceNumber = edcaIt->second->GetBaStartingSequence (recipient, tid); + uint16_t startingSequenceNumber = qosTxop->GetBaStartingSequence (recipient, tid); Ptr nextMpdu; - uint16_t maxMpdus = edcaIt->second->GetBaBufferSize (recipient, tid); + uint16_t maxMpdus = qosTxop->GetBaBufferSize (recipient, tid); uint32_t currentAmpduSize = 0; // check if the received MPDU meets the size and duration constraints - if (edcaIt->second->GetLow ()->IsWithinSizeAndTimeLimits (mpdu, txVector, 0, ppduDurationLimit)) + if (qosTxop->GetLow ()->IsWithinSizeAndTimeLimits (mpdu, txVector, 0, ppduDurationLimit)) { // MPDU can be aggregated nextMpdu = Copy (mpdu); @@ -271,7 +277,7 @@ MpduAggregator::GetNextAmpdu (Ptr mpdu, WifiTxVector txV nextMpdu = 0; Ptr peekedMpdu; - peekedMpdu = edcaIt->second->PeekNextFrame (tid, recipient); + peekedMpdu = qosTxop->PeekNextFrame (tid, recipient); if (peekedMpdu != 0) { uint16_t currentSequenceNumber = peekedMpdu->GetHeader ().GetSequenceNumber (); @@ -282,7 +288,7 @@ MpduAggregator::GetNextAmpdu (Ptr mpdu, WifiTxVector txV // Note that the dequeued MPDU differs from the peeked MPDU if A-MSDU // aggregation is performed during the dequeue NS_LOG_DEBUG ("Trying to aggregate another MPDU"); - nextMpdu = edcaIt->second->DequeuePeekedFrame (peekedMpdu, txVector, true, + nextMpdu = qosTxop->DequeuePeekedFrame (peekedMpdu, txVector, true, currentAmpduSize, ppduDurationLimit); } } diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index 51a9fa76b..4b4bbd834 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -33,6 +33,7 @@ class AmpduSubframeHeader; class WifiTxVector; class Packet; class WifiMacQueueItem; +class RegularWifiMac; /** * \brief Aggregator used to construct A-MPDUs @@ -120,11 +121,11 @@ public: Time ppduDurationLimit = Time::Min ()) const; /** - * Set the map of EDCA queues. + * Set the MAC layer to use. * - * \param edcaQueues the map of EDCA queues. + * \param mac the MAC layer to use */ - void SetEdcaQueues (EdcaQueues edcaQueues); + void SetWifiMac (const Ptr mac); /** * \param ampduSize the size of the A-MPDU that needs to be padded in bytes @@ -145,8 +146,11 @@ public: */ static AmpduSubframeHeader GetAmpduSubframeHeader (uint16_t mpduSize, bool isSingle); +protected: + virtual void DoDispose (); + private: - EdcaQueues m_edca; //!< the map of EDCA queues + Ptr m_mac; //!< the MAC of this station }; } //namespace ns3 diff --git a/src/wifi/model/msdu-aggregator.cc b/src/wifi/model/msdu-aggregator.cc index d597dc174..00e2c5c9d 100644 --- a/src/wifi/model/msdu-aggregator.cc +++ b/src/wifi/model/msdu-aggregator.cc @@ -29,7 +29,7 @@ #include "wifi-phy.h" #include "wifi-net-device.h" #include "ht-capabilities.h" -#include "wifi-mac.h" +#include "regular-wifi-mac.h" #include "wifi-mac-queue.h" #include "wifi-mac-trailer.h" #include @@ -60,9 +60,17 @@ MsduAggregator::~MsduAggregator () } void -MsduAggregator::SetEdcaQueues (EdcaQueues map) +MsduAggregator::DoDispose () { - m_edca = map; + m_mac = 0; + Object::DoDispose (); +} + +void +MsduAggregator::SetWifiMac (const Ptr mac) +{ + NS_LOG_FUNCTION (this << mac); + m_mac = mac; } uint16_t @@ -87,7 +95,7 @@ MsduAggregator::GetNextAmsdu (Mac48Address recipient, uint8_t tid, */ NS_ABORT_MSG_IF (recipient.IsGroup (), "Recipient address is group addressed"); - Ptr qosTxop = m_edca.find (QosUtilsMapTidToAc (tid))->second; + Ptr qosTxop = m_mac->GetQosTxop (tid); Ptr queue = qosTxop->GetWifiMacQueue (); WifiMacQueue::ConstIterator peekedIt = queue->PeekByTidAndAddress (tid, recipient); @@ -104,7 +112,7 @@ MsduAggregator::GetNextAmsdu (Mac48Address recipient, uint8_t tid, */ // No check required for now, as we always set the A-MSDU Supported field to 1 - WifiModulationClass modulation = txVector.GetMode ().GetModulationClass (); + WifiModulationClass modulation = txVector.GetModulationClass (); // Get the maximum size of the A-MSDU we can send to the recipient uint16_t maxAmsduSize = GetMaxAmsduSize (recipient, tid, modulation); @@ -189,11 +197,6 @@ MsduAggregator::GetMaxAmsduSize (Mac48Address recipient, uint8_t tid, NS_LOG_FUNCTION (this << recipient << +tid << modulation); AcIndex ac = QosUtilsMapTidToAc (tid); - Ptr qosTxop = m_edca.find (ac)->second; - Ptr device = DynamicCast (qosTxop->GetLow ()->GetPhy ()->GetDevice ()); - NS_ASSERT (device); - Ptr stationManager = device->GetRemoteStationManager (); - NS_ASSERT (stationManager); // Find the A-MSDU max size configured on this device UintegerValue size; @@ -201,16 +204,16 @@ MsduAggregator::GetMaxAmsduSize (Mac48Address recipient, uint8_t tid, switch (ac) { case AC_BE: - device->GetMac ()->GetAttribute ("BE_MaxAmsduSize", size); + m_mac->GetAttribute ("BE_MaxAmsduSize", size); break; case AC_BK: - device->GetMac ()->GetAttribute ("BK_MaxAmsduSize", size); + m_mac->GetAttribute ("BK_MaxAmsduSize", size); break; case AC_VI: - device->GetMac ()->GetAttribute ("VI_MaxAmsduSize", size); + m_mac->GetAttribute ("VI_MaxAmsduSize", size); break; case AC_VO: - device->GetMac ()->GetAttribute ("VO_MaxAmsduSize", size); + m_mac->GetAttribute ("VO_MaxAmsduSize", size); break; default: NS_ABORT_MSG ("Unknown AC " << ac); @@ -225,6 +228,9 @@ MsduAggregator::GetMaxAmsduSize (Mac48Address recipient, uint8_t tid, return 0; } + Ptr stationManager = m_mac->GetWifiRemoteStationManager (); + NS_ASSERT (stationManager); + // Retrieve the Capabilities elements advertised by the recipient Ptr vhtCapabilities = stationManager->GetStationVhtCapabilities (recipient); Ptr htCapabilities = stationManager->GetStationHtCapabilities (recipient); diff --git a/src/wifi/model/msdu-aggregator.h b/src/wifi/model/msdu-aggregator.h index 23dadf86c..d4cc5b090 100644 --- a/src/wifi/model/msdu-aggregator.h +++ b/src/wifi/model/msdu-aggregator.h @@ -33,6 +33,7 @@ namespace ns3 { class Packet; class QosTxop; class WifiTxVector; +class RegularWifiMac; /** * \brief Aggregator used to construct A-MSDUs @@ -117,11 +118,11 @@ public: static WifiMacQueueItem::DeaggregatedMsdus Deaggregate (Ptr aggregatedPacket); /** - * Set the map of EDCA queues. + * Set the MAC layer to use. * - * \param map the map of EDCA queues. + * \param mac the MAC layer to use */ - void SetEdcaQueues (EdcaQueues map); + void SetWifiMac (const Ptr mac); /** * Calculate how much padding must be added to the end of an A-MSDU of the @@ -134,8 +135,11 @@ public: */ static uint8_t CalculatePadding (uint16_t amsduSize); +protected: + virtual void DoDispose (); + private: - EdcaQueues m_edca; //!< the map of EDCA queues + Ptr m_mac; //!< the MAC of this station }; } //namespace ns3 diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index 1cb68b7af..4ea560420 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -1199,13 +1199,13 @@ RegularWifiMac::EnableAggregation (void) if (m_low->GetMsduAggregator () == 0) { Ptr msduAggregator = CreateObject (); - msduAggregator->SetEdcaQueues (m_edca); + msduAggregator->SetWifiMac (this); m_low->SetMsduAggregator (msduAggregator); } if (m_low->GetMpduAggregator () == 0) { Ptr mpduAggregator = CreateObject (); - mpduAggregator->SetEdcaQueues (m_edca); + mpduAggregator->SetWifiMac (this); m_low->SetMpduAggregator (mpduAggregator); } }