# HG changeset patch # User Mathieu Lacage # Date 1197017519 -3600 # Node ID 8a8305b75bedb84507f60a8ad4e9609fa3e757ee # Parent 9c2c6fbf65a7759927993b13e93bfce3273e095e make sure we never set a negative duration diff -r 9c2c6fbf65a7 -r 8a8305b75bed src/devices/wifi/mac-low.cc --- a/src/devices/wifi/mac-low.cc Fri Dec 07 08:43:55 2007 +0100 +++ b/src/devices/wifi/mac-low.cc Fri Dec 07 09:51:59 2007 +0100 @@ -998,12 +998,17 @@ * RTS/CTS/DATA/ACK hanshake */ NS_ASSERT (m_currentPacket != 0); - WifiMode dataTxMode = GetDataTxMode (m_currentHdr.GetAddr1 (), GetCurrentSize ()); + StartDataTxTimers (); - StartDataTxTimers (); + WifiMode dataTxMode = GetDataTxMode (m_currentHdr.GetAddr1 (), GetCurrentSize ()); + Time newDuration = Seconds (0); + newDuration += GetSifs (); + newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); Time txDuration = m_phy->CalculateTxDuration (GetCurrentSize (), dataTxMode, WIFI_PREAMBLE_LONG); duration -= txDuration; duration -= GetSifs (); + + duration = std::max (duration, newDuration); NS_ASSERT (duration >= MicroSeconds (0)); m_currentHdr.SetDuration (duration);