diff --git a/src/wifi/model/aarfcd-wifi-manager.cc b/src/wifi/model/aarfcd-wifi-manager.cc index b3b8c8a04..24146f720 100644 --- a/src/wifi/model/aarfcd-wifi-manager.cc +++ b/src/wifi/model/aarfcd-wifi-manager.cc @@ -362,9 +362,9 @@ AarfcdWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) bool AarfcdWifiManager::DoNeedRts (WifiRemoteStation *st, - Ptr packet, bool normally) + uint32_t size, bool normally) { - NS_LOG_FUNCTION (this << st << packet << normally); + NS_LOG_FUNCTION (this << st << size << normally); AarfcdWifiRemoteStation *station = static_cast (st); NS_LOG_INFO ("" << station << " rate=" << station->m_rate << " rts=" << (station->m_rtsOn ? "RTS" : "BASIC") << " rtsCounter=" << station->m_rtsCounter); diff --git a/src/wifi/model/aarfcd-wifi-manager.h b/src/wifi/model/aarfcd-wifi-manager.h index b8b9062a6..cdfe0c366 100644 --- a/src/wifi/model/aarfcd-wifi-manager.h +++ b/src/wifi/model/aarfcd-wifi-manager.h @@ -83,7 +83,7 @@ private: WifiTxVector DoGetDataTxVector (WifiRemoteStation *station); WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); bool DoNeedRts (WifiRemoteStation *station, - Ptr packet, bool normally); + uint32_t size, bool normally); /** * Check if the use of RTS for the given station can be turned off. diff --git a/src/wifi/model/cara-wifi-manager.cc b/src/wifi/model/cara-wifi-manager.cc index 2674251fd..8fb551b1d 100644 --- a/src/wifi/model/cara-wifi-manager.cc +++ b/src/wifi/model/cara-wifi-manager.cc @@ -244,9 +244,9 @@ CaraWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) bool CaraWifiManager::DoNeedRts (WifiRemoteStation *st, - Ptr packet, bool normally) + uint32_t size, bool normally) { - NS_LOG_FUNCTION (this << st << normally); + NS_LOG_FUNCTION (this << st << size << normally); CaraWifiRemoteStation *station = static_cast (st); return normally || station->m_failed >= m_probeThreshold; } diff --git a/src/wifi/model/cara-wifi-manager.h b/src/wifi/model/cara-wifi-manager.h index 9d479dcd8..dfa980fe8 100644 --- a/src/wifi/model/cara-wifi-manager.h +++ b/src/wifi/model/cara-wifi-manager.h @@ -71,7 +71,7 @@ private: WifiTxVector DoGetDataTxVector (WifiRemoteStation *station); WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); bool DoNeedRts (WifiRemoteStation *station, - Ptr packet, bool normally); + uint32_t size, bool normally); uint32_t m_timerTimeout; ///< timer threshold uint32_t m_successThreshold; ///< success threshold diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 151b4b18c..675102bd9 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -441,7 +441,7 @@ QosTxop::GetTransmissionParameters (Ptr frame) const // Enable/disable RTS if (!frame->GetHeader ().IsBlockAckReq () - && m_stationManager->NeedRts (&frame->GetHeader (), frame->GetPacket ()) + && m_stationManager->NeedRts (frame->GetHeader (), frame->GetSize ()) && !m_low->IsCfPeriod ()) { params.EnableRts (); @@ -998,25 +998,18 @@ QosTxop::RestartAccessIfNeeded (void) if ((m_currentPacket != 0 || baManagerHasPackets || queueIsNotEmpty) && !IsAccessRequested ()) { - Ptr packet; - WifiMacHeader hdr; + Ptr item; if (m_currentPacket != 0) { - packet = m_currentPacket; - hdr = m_currentHdr; + item = Create (m_currentPacket, m_currentHdr); } else { - Ptr item = PeekNextFrame (); - if (item) - { - packet = item->GetPacket (); - hdr = item->GetHeader (); - } + item = PeekNextFrame (); } - if (packet != 0) + if (item != 0) { - m_isAccessRequestedForRts = m_stationManager->NeedRts (&hdr, packet); + m_isAccessRequestedForRts = m_stationManager->NeedRts (item->GetHeader (), item->GetSize ()); } else { @@ -1042,17 +1035,10 @@ QosTxop::StartAccessIfNeeded (void) && (baManagerHasPackets || queueIsNotEmpty) && !IsAccessRequested ()) { - Ptr packet; - WifiMacHeader hdr; Ptr item = PeekNextFrame (); - if (item) + if (item != 0) { - packet = item->GetPacket (); - hdr = item->GetHeader (); - } - if (packet != 0) - { - m_isAccessRequestedForRts = m_stationManager->NeedRts (&hdr, packet); + m_isAccessRequestedForRts = m_stationManager->NeedRts (item->GetHeader (), item->GetSize ()); } else { diff --git a/src/wifi/model/rraa-wifi-manager.cc b/src/wifi/model/rraa-wifi-manager.cc index 429d1b428..d72de3d44 100644 --- a/src/wifi/model/rraa-wifi-manager.cc +++ b/src/wifi/model/rraa-wifi-manager.cc @@ -393,9 +393,9 @@ RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) bool RraaWifiManager::DoNeedRts (WifiRemoteStation *st, - Ptr packet, bool normally) + uint32_t size, bool normally) { - NS_LOG_FUNCTION (this << st << packet << normally); + NS_LOG_FUNCTION (this << st << size << normally); RraaWifiRemoteStation *station = static_cast (st); CheckInit (station); if (m_basic) diff --git a/src/wifi/model/rraa-wifi-manager.h b/src/wifi/model/rraa-wifi-manager.h index de7ef9f18..9bde22520 100644 --- a/src/wifi/model/rraa-wifi-manager.h +++ b/src/wifi/model/rraa-wifi-manager.h @@ -90,7 +90,7 @@ private: WifiTxVector DoGetDataTxVector (WifiRemoteStation *station); WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); bool DoNeedRts (WifiRemoteStation *st, - Ptr packet, bool normally); + uint32_t size, bool normally); /** * Check for initializations. diff --git a/src/wifi/model/rrpaa-wifi-manager.cc b/src/wifi/model/rrpaa-wifi-manager.cc index 61f116be3..506ad71f1 100644 --- a/src/wifi/model/rrpaa-wifi-manager.cc +++ b/src/wifi/model/rrpaa-wifi-manager.cc @@ -443,9 +443,9 @@ RrpaaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) bool RrpaaWifiManager::DoNeedRts (WifiRemoteStation *st, - Ptr packet, bool normally) + uint32_t size, bool normally) { - NS_LOG_FUNCTION (this << st << packet << normally); + NS_LOG_FUNCTION (this << st << size << normally); RrpaaWifiRemoteStation *station = static_cast (st); CheckInit (station); if (m_basic) diff --git a/src/wifi/model/rrpaa-wifi-manager.h b/src/wifi/model/rrpaa-wifi-manager.h index f8ff2e1fd..6582eafcb 100644 --- a/src/wifi/model/rrpaa-wifi-manager.h +++ b/src/wifi/model/rrpaa-wifi-manager.h @@ -115,7 +115,7 @@ private: virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station); virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station); virtual bool DoNeedRts (WifiRemoteStation *st, - Ptr packet, bool normally); + uint32_t size, bool normally); /** * Check for initializations. diff --git a/src/wifi/model/txop.cc b/src/wifi/model/txop.cc index 073723bad..1ed7202ba 100644 --- a/src/wifi/model/txop.cc +++ b/src/wifi/model/txop.cc @@ -29,6 +29,7 @@ #include "mac-tx-middle.h" #include "mac-low.h" #include "wifi-remote-station-manager.h" +#include "wifi-mac-trailer.h" #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } @@ -532,7 +533,8 @@ Txop::NotifyAccessGranted (void) } else { - if (m_stationManager->NeedRts (&m_currentHdr, m_currentPacket) && !m_low->IsCfPeriod ()) + uint32_t size = m_currentHdr.GetSize () + m_currentPacket->GetSize () + WIFI_MAC_FCS_LENGTH; + if (m_stationManager->NeedRts (m_currentHdr, size) && !m_low->IsCfPeriod ()) { m_currentParams.EnableRts (); } diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index dbcadcb0c..6f7bb6db5 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -740,11 +740,11 @@ WifiRemoteStationManager::ReportAmpduTxStatus (Mac48Address address, } bool -WifiRemoteStationManager::NeedRts (const WifiMacHeader *header, Ptr packet) +WifiRemoteStationManager::NeedRts (const WifiMacHeader &header, uint32_t size) { - NS_LOG_FUNCTION (this << *header << packet); - Mac48Address address = header->GetAddr1 (); - WifiTxVector txVector = GetDataTxVector (*header); + NS_LOG_FUNCTION (this << header << size); + Mac48Address address = header.GetAddr1 (); + WifiTxVector txVector = GetDataTxVector (header); WifiMode mode = txVector.GetMode (); if (address.IsGroup ()) { @@ -769,8 +769,8 @@ WifiRemoteStationManager::NeedRts (const WifiMacHeader *header, PtrGetSize () + header->GetSize () + WIFI_MAC_FCS_LENGTH) > m_rtsCtsThreshold; - return DoNeedRts (Lookup (address), packet, normally); + bool normally = (size > m_rtsCtsThreshold); + return DoNeedRts (Lookup (address), size, normally); } bool @@ -1386,7 +1386,7 @@ WifiRemoteStationManager::GetNonUnicastMode (void) const bool WifiRemoteStationManager::DoNeedRts (WifiRemoteStation *station, - Ptr packet, bool normally) + uint32_t size, bool normally) { return normally; } diff --git a/src/wifi/model/wifi-remote-station-manager.h b/src/wifi/model/wifi-remote-station-manager.h index da3501e09..d35304fe7 100644 --- a/src/wifi/model/wifi-remote-station-manager.h +++ b/src/wifi/model/wifi-remote-station-manager.h @@ -766,12 +766,12 @@ public: /** * \param header MAC header - * \param packet the packet to send + * \param size the size of the frame to send in bytes * * \return true if we want to use an RTS/CTS handshake for this - * packet before sending it, false otherwise. + * frame before sending it, false otherwise. */ - bool NeedRts (const WifiMacHeader *header, Ptr packet); + bool NeedRts (const WifiMacHeader &header, uint32_t size); /** * Return if we need to do CTS-to-self before sending a DATA. * @@ -1061,17 +1061,17 @@ protected: private: /** * \param station the station that we need to communicate - * \param packet the packet to send + * \param size the size of the frame to send in bytes * \param normally indicates whether the normal 802.11 RTS enable mechanism would * request that the RTS is sent or not. * - * \return true if we want to use an RTS/CTS handshake for this packet before sending it, + * \return true if we want to use an RTS/CTS handshake for this frame before sending it, * false otherwise. * * Note: This method is called before a unicast packet is sent on the medium. */ virtual bool DoNeedRts (WifiRemoteStation *station, - Ptr packet, bool normally); + uint32_t size, bool normally); /** * \param station the station that we need to communicate * \param packet the packet to send