diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index 4e5c2ee48..1fd0b5991 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -327,15 +327,12 @@ FrameExchangeManager::GetFirstFragmentIfNeeded (Ptr mpdu) { NS_LOG_DEBUG ("Fragmenting the MSDU"); m_fragmentedPacket = mpdu->GetPacket ()->Copy (); - AcIndex ac = mpdu->GetQueueAc (); - // dequeue the MSDU - DequeueMpdu (mpdu); // create the first fragment - mpdu->GetHeader ().SetMoreFragments (); Ptr fragment = m_fragmentedPacket->CreateFragment (0, m_mac->GetWifiRemoteStationManager ()->GetFragmentSize (mpdu, 0)); // enqueue the first fragment Ptr item = Create (fragment, mpdu->GetHeader (), mpdu->GetTimeStamp ()); - m_mac->GetTxopQueue (ac)->PushFront (item); + item->GetHeader ().SetMoreFragments (); + m_mac->GetTxopQueue (mpdu->GetQueueAc ())->Replace (mpdu, item); return item; } return mpdu; @@ -1142,16 +1139,17 @@ FrameExchangeManager::ReceivedNormalAck (Ptr mpdu, const WifiT // a frame containing all or part of an MSDU or MMPDU (sec. 10.3.3 of 802.11-2016) m_dcf->ResetCw (); - // The MPDU has been acknowledged, we can now dequeue it if it is stored in a queue - DequeueMpdu (mpdu); - if (mpdu->GetHeader ().IsMoreFragments ()) { - // enqueue the next fragment - Ptr next = GetNextFragment (); - m_dcf->GetWifiMacQueue ()->PushFront (next); + // replace the current fragment with the next one + m_dcf->GetWifiMacQueue ()->Replace (mpdu, GetNextFragment ()); m_moreFragments = true; } + else + { + // the MPDU has been acknowledged, we can now dequeue it if it is stored in a queue + DequeueMpdu (mpdu); + } TransmissionSucceeded (); } diff --git a/src/wifi/model/wifi-mac-queue.h b/src/wifi/model/wifi-mac-queue.h index 5264debc2..0e9d0199f 100644 --- a/src/wifi/model/wifi-mac-queue.h +++ b/src/wifi/model/wifi-mac-queue.h @@ -115,14 +115,6 @@ public: * \return true if success, false if the packet has been dropped */ bool PushFront (Ptr item); - /** - * Enqueue the given Wifi MAC queue item before the given position. - * - * \param pos the position before which the item is to be inserted - * \param item the Wifi MAC queue item to be enqueued - * \return true if success, false if the packet has been dropped - */ - bool Insert (ConstIterator pos, Ptr item); /** * Dequeue the packet in the front of the queue. * @@ -342,6 +334,14 @@ private: */ inline bool TtlExceeded (ConstIterator &it, const Time& now); + /** + * Enqueue the given Wifi MAC queue item before the given position. + * + * \param pos the position before which the item is to be inserted + * \param item the Wifi MAC queue item to be enqueued + * \return true if success, false if the packet has been dropped + */ + bool Insert (ConstIterator pos, Ptr item); /** * Wrapper for the DoEnqueue method provided by the base class that additionally * sets the iterator field of the item and updates internal statistics, if