diff --git a/ChangeLog b/ChangeLog index 8416271c4..ddd1b1307 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * make uTP less aggressive resetting cwnd when idle + 0.16.1 release * fixed crash when providing corrupt resume data diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index 589addff5..5e72c5de0 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -2880,7 +2880,19 @@ void utp_socket_impl::tick(ptime const& now) // we can now sent messages again, the send window was opened if ((m_cwnd >> 16) < m_mtu) window_opened = true; - m_cwnd = boost::int64_t(m_mtu) << 16; + if (m_bytes_in_flight == 0 && (m_cwnd >> 16) >= m_mtu) + { + // this is just a timeout because this direction of + // the stream is idle. Don't reset the cwnd, just decay it + m_cwnd = m_cwnd * 2 / 3; + } + else + { + // we timed out because a packet was not ACKed or because + // the cwnd was made smaller than one packet + m_cwnd = boost::int64_t(m_mtu) << 16; + } + if (m_outbuf.size()) ++m_num_timeouts; if (m_num_timeouts > m_sm->num_resends())