From bc4d797dbfeda697096a4467e4de359e6c61b88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 15 Aug 2015 13:14:14 +0200 Subject: [PATCH] Bug 730 [wifi] - Enabling fragmentation at run-time breaks simulation (patch from Christian Facchini) --- src/wifi/model/dca-txop.cc | 1 + src/wifi/model/edca-txop-n.cc | 1 + src/wifi/model/wifi-remote-station-manager.cc | 12 +++++++++--- src/wifi/model/wifi-remote-station-manager.h | 8 +++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/wifi/model/dca-txop.cc b/src/wifi/model/dca-txop.cc index 4df463fed..dfce07830 100644 --- a/src/wifi/model/dca-txop.cc +++ b/src/wifi/model/dca-txop.cc @@ -445,6 +445,7 @@ DcaTxop::NotifyAccessGranted (void) NS_ASSERT (m_currentPacket != 0); uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr); m_currentHdr.SetSequenceNumber (sequence); + m_stationManager->UpdateFragmentationThreshold (); m_currentHdr.SetFragmentNumber (0); m_currentHdr.SetNoMoreFragments (); m_currentHdr.SetNoRetry (); diff --git a/src/wifi/model/edca-txop-n.cc b/src/wifi/model/edca-txop-n.cc index e4da8c4ed..0d86d1ff4 100644 --- a/src/wifi/model/edca-txop-n.cc +++ b/src/wifi/model/edca-txop-n.cc @@ -506,6 +506,7 @@ EdcaTxopN::NotifyAccessGranted (void) uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr); m_currentHdr.SetSequenceNumber (sequence); + m_stationManager->UpdateFragmentationThreshold (); m_currentHdr.SetFragmentNumber (0); m_currentHdr.SetNoMoreFragments (); m_currentHdr.SetNoRetry (); diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index f59756d02..cf7b68ea8 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -862,7 +862,7 @@ WifiRemoteStationManager::DoSetFragmentationThreshold (uint32_t threshold) * ASN.1 encoding of the MAC and PHY MIB (256 ... 8000) */ NS_LOG_WARN ("Fragmentation threshold should be larger than 256. Setting to 256."); - m_fragmentationThreshold = 256; + m_nextFragmentationThreshold = 256; } else { @@ -873,15 +873,21 @@ WifiRemoteStationManager::DoSetFragmentationThreshold (uint32_t threshold) if (threshold % 2 != 0) { NS_LOG_WARN ("Fragmentation threshold should be an even number. Setting to " << threshold - 1); - m_fragmentationThreshold = threshold - 1; + m_nextFragmentationThreshold = threshold - 1; } else { - m_fragmentationThreshold = threshold; + m_nextFragmentationThreshold = threshold; } } } +void +WifiRemoteStationManager::UpdateFragmentationThreshold (void) +{ + m_fragmentationThreshold = m_nextFragmentationThreshold; +} + uint32_t WifiRemoteStationManager::DoGetFragmentationThreshold (void) const { diff --git a/src/wifi/model/wifi-remote-station-manager.h b/src/wifi/model/wifi-remote-station-manager.h index d0ab9c4b6..905b3923f 100644 --- a/src/wifi/model/wifi-remote-station-manager.h +++ b/src/wifi/model/wifi-remote-station-manager.h @@ -156,6 +156,11 @@ public: * \param threshold the fragmentation threshold */ void SetFragmentationThreshold (uint32_t threshold); + /** + * Typically called to update the fragmentation threshold at the start of a new transmission. + * This avoid that the fragmentation threshold gets changed during a transmission (see bug 730). + */ + void UpdateFragmentationThreshold (void); /** * Records HT capabilities of the remote station. * @@ -999,7 +1004,8 @@ private: uint32_t m_maxSsrc; //!< Maximum STA short retry count (SSRC) uint32_t m_maxSlrc; //!< Maximum STA long retry count (SLRC) uint32_t m_rtsCtsThreshold; //!< Threshold for RTS/CTS - uint32_t m_fragmentationThreshold; //!< Threshold for fragmentation + uint32_t m_fragmentationThreshold; //!< Current threshold for fragmentation + uint32_t m_nextFragmentationThreshold; //!< Threshold for fragmentation that will be used for the next transmission uint8_t m_defaultTxPowerLevel; //!< Default tranmission power level WifiMode m_nonUnicastMode; //!< Transmission mode for non-unicast DATA frames