From 4e2407b6f1b9327f68472c7b2f2c7a6c1cb672fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 4 Nov 2017 09:15:06 +0100 Subject: [PATCH] wifi: merge CalculateOverallTxTime and CalculateOverallTxFragmentTime in MacLow --- src/wifi/model/edca-txop-n.cc | 6 +++--- src/wifi/model/mac-low.cc | 32 ++++++++------------------------ src/wifi/model/mac-low.h | 19 +++---------------- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/wifi/model/edca-txop-n.cc b/src/wifi/model/edca-txop-n.cc index 597e43db7..a12f9f5a1 100644 --- a/src/wifi/model/edca-txop-n.cc +++ b/src/wifi/model/edca-txop-n.cc @@ -1002,7 +1002,7 @@ EdcaTxopN::GetTxopFragmentSize () const while (!found) { size = (minSize + ((maxSize - minSize) / 2)); - if (GetLow ()->CalculateOverallTxFragmentTime (m_currentPacket, &m_currentHdr, m_currentParams, size) > txopDuration) + if (GetLow ()->CalculateOverallTxTime (m_currentPacket, &m_currentHdr, m_currentParams, size) > txopDuration) { maxSize = size; } @@ -1010,8 +1010,8 @@ EdcaTxopN::GetTxopFragmentSize () const { minSize = size; } - if (GetLow ()->CalculateOverallTxFragmentTime (m_currentPacket, &m_currentHdr, m_currentParams, size) <= txopDuration - && GetLow ()->CalculateOverallTxFragmentTime (m_currentPacket, &m_currentHdr, m_currentParams, size + 1) > txopDuration) + if (GetLow ()->CalculateOverallTxTime (m_currentPacket, &m_currentHdr, m_currentParams, size) <= txopDuration + && GetLow ()->CalculateOverallTxTime (m_currentPacket, &m_currentHdr, m_currentParams, size + 1) > txopDuration) { found = true; } diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index 7b4dc8975..ff9aab6f5 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -1251,7 +1251,8 @@ MacLow::GetAckTxVectorForData (Mac48Address to, WifiMode dataTxMode) const Time MacLow::CalculateOverallTxTime (Ptr packet, const WifiMacHeader* hdr, - const MacLowTransmissionParameters& params) const + const MacLowTransmissionParameters& params, + uint32_t fragmentSize) const { Time txTime = Seconds (0); if (params.MustSendRts ()) @@ -1262,33 +1263,16 @@ MacLow::CalculateOverallTxTime (Ptr packet, txTime += Time (GetSifs () * 2); } WifiTxVector dataTxVector = GetDataTxVector (packet, hdr); - uint32_t dataSize = GetSize (packet, hdr, m_ampdu); - txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, m_phy->GetFrequency ()); - txTime += GetSifs (); - if (params.MustWaitAck ()) + uint32_t dataSize; + if (fragmentSize > 0) { - txTime += GetAckDuration (hdr->GetAddr1 (), dataTxVector); + Ptr fragment = Create (fragmentSize); + dataSize = GetSize (fragment, hdr, m_ampdu); } - return txTime; -} - -Time -MacLow::CalculateOverallTxFragmentTime (Ptr packet, - const WifiMacHeader* hdr, - const MacLowTransmissionParameters& params, - uint32_t fragmentSize) const -{ - Time txTime = Seconds (0); - if (params.MustSendRts ()) + else { - WifiTxVector rtsTxVector = GetRtsTxVector (packet, hdr); - txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, m_phy->GetFrequency ()); - txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector); - txTime += Time (GetSifs () * 2); + dataSize = GetSize (packet, hdr, m_ampdu); } - WifiTxVector dataTxVector = GetDataTxVector (packet, hdr); - Ptr fragment = Create (fragmentSize); - uint32_t dataSize = GetSize (fragment, hdr, m_ampdu); txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, m_phy->GetFrequency ()); txTime += GetSifs (); if (params.MustWaitAck ()) diff --git a/src/wifi/model/mac-low.h b/src/wifi/model/mac-low.h index 443bff2de..6c07d89c1 100644 --- a/src/wifi/model/mac-low.h +++ b/src/wifi/model/mac-low.h @@ -455,6 +455,7 @@ public: * \param packet to send (does not include the 802.11 MAC header and checksum) * \param hdr header associated to the packet to send. * \param params transmission parameters of packet. + * \param fragmentSize the packet fragment size (if fragmentation is used) * \return the transmission time that includes the time for the next packet transmission * * This transmission time includes the time required for @@ -462,22 +463,8 @@ public: */ Time CalculateOverallTxTime (Ptr packet, const WifiMacHeader* hdr, - const MacLowTransmissionParameters ¶ms) const; - - /** - * \param packet to send (does not include the 802.11 MAC header and checksum) - * \param hdr header associated to the packet to send. - * \param params transmission parameters of packet. - * \param fragmentSize the packet fragment size - * \return the transmission time that includes the time for the next packet transmission - * - * This transmission time includes the time required for - * the next packet fragment transmission if one was selected. - */ - Time CalculateOverallTxFragmentTime (Ptr packet, - const WifiMacHeader* hdr, - const MacLowTransmissionParameters& params, - uint32_t fragmentSize) const; + const MacLowTransmissionParameters& params, + uint32_t fragmentSize = 0) const; /** * \param packet packet to send