fix initial PTO timer duration

This commit is contained in:
Marten Seemann
2019-08-10 17:21:31 +07:00
parent ee00cbe088
commit 5189cb94f1
3 changed files with 5 additions and 17 deletions

View File

@@ -43,22 +43,16 @@ func (r *RTTStats) LatestRTT() time.Duration { return r.latestRTT }
// May return Zero if no valid updates have occurred.
func (r *RTTStats) SmoothedRTT() time.Duration { return r.smoothedRTT }
// SmoothedOrInitialRTT returns the EWMA smoothed RTT for the connection.
// If no valid updates have occurred, it returns the initial RTT.
func (r *RTTStats) SmoothedOrInitialRTT() time.Duration {
if r.smoothedRTT != 0 {
return r.smoothedRTT
}
return defaultInitialRTT
}
// MeanDeviation gets the mean deviation
func (r *RTTStats) MeanDeviation() time.Duration { return r.meanDeviation }
func (r *RTTStats) MaxAckDelay() time.Duration { return r.maxAckDelay }
func (r *RTTStats) PTO() time.Duration {
return r.SmoothedOrInitialRTT() + utils.MaxDuration(4*r.MeanDeviation(), protocol.TimerGranularity) + r.MaxAckDelay()
if r.SmoothedRTT() == 0 {
return 2 * defaultInitialRTT
}
return r.SmoothedRTT() + utils.MaxDuration(4*r.MeanDeviation(), protocol.TimerGranularity) + r.MaxAckDelay()
}
// UpdateRTT updates the RTT based on a new sample.