Upper bound to PTO interval

Prevents overflow and improves worst-case latency on erratic links
with high idle timeouts.
This commit is contained in:
Benjamin Saunders
2019-01-22 17:49:17 -08:00
committed by Dirkjan Ochtman
parent d80efde3e9
commit adc41e4b2d
+3 -1
View File
@@ -685,8 +685,10 @@ impl Connection {
}
// Calculate PTO duration
const MAX_PTO_EXPONENT: u32 = 24; // 2^24μs = ~17 seconds
let timeout = self.rtt.smoothed + 4 * self.rtt.var + self.max_ack_delay();
let timeout = cmp::max(timeout, TIMER_GRANULARITY) * 2u64.pow(self.pto_count);
let timeout = cmp::max(timeout, TIMER_GRANULARITY)
* 2u64.pow(cmp::min(self.pto_count, MAX_PTO_EXPONENT));
self.io.timer_start(
Timer::LossDetection,
self.time_of_last_sent_ack_eliciting_packet + timeout,