diff --git a/src/wifi/model/mpdu-aggregator.cc b/src/wifi/model/mpdu-aggregator.cc index f31ccf055..09918ce84 100644 --- a/src/wifi/model/mpdu-aggregator.cc +++ b/src/wifi/model/mpdu-aggregator.cc @@ -35,6 +35,7 @@ #include "ns3/he-capabilities.h" #include "ns3/ht-capabilities.h" +#include "ns3/ht-frame-exchange-manager.h" #include "ns3/log.h" #include "ns3/packet.h" #include "ns3/vht-capabilities.h" @@ -60,6 +61,7 @@ void MpduAggregator::DoDispose() { m_mac = nullptr; + m_htFem = nullptr; Object::DoDispose(); } @@ -68,6 +70,7 @@ MpduAggregator::SetWifiMac(const Ptr mac) { NS_LOG_FUNCTION(this << mac); m_mac = mac; + m_htFem = DynamicCast(m_mac->GetFrameExchangeManager(m_linkId)); } void @@ -75,6 +78,10 @@ MpduAggregator::SetLinkId(uint8_t linkId) { NS_LOG_FUNCTION(this << +linkId); m_linkId = linkId; + if (m_mac) + { + m_htFem = DynamicCast(m_mac->GetFrameExchangeManager(m_linkId)); + } } void @@ -205,6 +212,7 @@ MpduAggregator::GetNextAmpdu(Ptr mpdu, Mac48Address recipient = mpdu->GetHeader().GetAddr1(); NS_ASSERT(mpdu->GetHeader().IsQosData() && !recipient.IsBroadcast()); uint8_t tid = mpdu->GetHeader().GetQosTid(); + auto origRecipient = mpdu->GetOriginal()->GetHeader().GetAddr1(); Ptr qosTxop = m_mac->GetQosTxop(tid); NS_ASSERT(qosTxop); @@ -227,16 +235,18 @@ MpduAggregator::GetNextAmpdu(Ptr mpdu, mpduList.push_back(nextMpdu); // If allowed by the BA agreement, get the next MPDU - auto peekedMpdu = qosTxop->PeekNextMpdu(m_linkId, tid, recipient, nextMpdu); + auto peekedMpdu = + qosTxop->PeekNextMpdu(m_linkId, tid, origRecipient, nextMpdu->GetOriginal()); nextMpdu = nullptr; if (peekedMpdu) { // PeekNextMpdu() does not return an MPDU that is beyond the transmit window NS_ASSERT(IsInWindow(peekedMpdu->GetHeader().GetSequenceNumber(), - qosTxop->GetBaStartingSequence(recipient, tid), - qosTxop->GetBaBufferSize(recipient, tid))); + qosTxop->GetBaStartingSequence(origRecipient, tid), + qosTxop->GetBaBufferSize(origRecipient, tid))); + peekedMpdu = m_htFem->CreateAlias(peekedMpdu); // get the next MPDU to aggregate, provided that the constraints on size // and duration limit are met. Note that the returned MPDU differs from // the peeked MPDU if A-MSDU aggregation is enabled. diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index 038d78cb8..d72c2116a 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -38,6 +38,7 @@ class Packet; class WifiMac; class WifiMpdu; class WifiTxParameters; +class HtFrameExchangeManager; /** * \brief Aggregator used to construct A-MPDUs @@ -165,8 +166,9 @@ class MpduAggregator : public Object void DoDispose() override; private: - Ptr m_mac; //!< the MAC of this station - uint8_t m_linkId{0}; //!< ID of the link this object is connected to + Ptr m_mac; //!< the MAC of this station + Ptr m_htFem; //!< the HT Frame Exchange Manager of this station + uint8_t m_linkId{0}; //!< ID of the link this object is connected to }; } // namespace ns3