From 1b2805118d2e20f2c9ea7689f7bafa4f22a12d09 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 16 Jun 2012 02:16:45 +0000 Subject: [PATCH] make uTP less aggressive resetting cwnd when idle --- ChangeLog | 2 ++ src/utp_stream.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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())