TcpWestwood divide-by-zero and floating point issues
This is a spinout from issue #487 (closed). tcp-rto-test
fails on the Apple M1 architecture, due to division by zero, which leads to divergent results on the M1 (and passing results on the Intel architecture).
This line in TcpWestwood::EstimateBW()
can sometimes have a divide by zero if the time difference is zero:
m_currentBW = m_ackedSegments * tcb->m_segmentSize / (currentAck - m_lastAck).GetSeconds ();
Fixing the EstimateBW method to avoid this divide-by-zero leads to other test failures on both Intel and M1. Unfortunately, this will require re-validation. m_currentBW should probably not be maintained as a double type but instead as a DataRate type.
The GetSsthresh() method also has a few casts that should be avoided:
return std::max (2*tcb->m_segmentSize,
uint32_t (m_currentBW * static_cast<double> (tcb->m_minRtt.GetSeconds ())));