Streaming: Double the RTO on congestion (ticket #1939)

This prevents being stuck at a window size of 1, retransmitting every packet,
never updating the RTT or RTO. See RFC 6298 section 5 item 5.5.
This commit is contained in:
zzz
2017-12-01 14:10:57 +00:00
parent 9b2a85df38
commit 17b72dd549
2 changed files with 19 additions and 2 deletions

View File

@@ -1495,8 +1495,12 @@ class Connection {
if (newWindowSize <= 0)
newWindowSize = 1;
// setRTT has its own ceiling
//getOptions().setRTT(getOptions().getRTT() + 10*1000);
// The timeout for _this_ packet will be doubled below, but we also
// need to double the RTO for the _next_ packets.
// See RFC 6298 section 5 item 5.5
// This prevents being stuck at a window size of 1, retransmitting every packet,
// never updating the RTT or RTO.
getOptions().doubleRTO();
getOptions().setWindowSize(newWindowSize);
if (_log.shouldLog(Log.INFO))

View File

@@ -607,6 +607,19 @@ class ConnectionOptions extends I2PSocketOptionsImpl {
_rto = (int)Connection.MAX_RESEND_DELAY;
}
/**
* Double the RTO (after congestion).
* See RFC 6298 section 5 item 5.5
*
* @since 0.9.33
*/
synchronized void doubleRTO() {
// we don't need to switch on _initState, _rto is set in constructor
_rto *= 2;
if (_rto > Connection.MAX_RESEND_DELAY)
_rto = (int)Connection.MAX_RESEND_DELAY;
}
/**
* If we have 3 consecutive rtt increases, we are trending upwards (1), or if we have
* 3 consecutive rtt decreases, we are trending downwards (-1), else we're stable.