Merge pull request #2049 from lucas-clemente/fix-initial-pto

fix initial PTO timer duration
This commit is contained in:
Marten Seemann
2019-08-12 21:05:54 -04:00
committed by GitHub
3 changed files with 5 additions and 17 deletions

View File

@@ -666,7 +666,7 @@ func (h *sentPacketHandler) ResetForRetry() error {
func (h *sentPacketHandler) GetStats() *quictrace.TransportState {
return &quictrace.TransportState{
MinRTT: h.rttStats.MinRTT(),
SmoothedRTT: h.rttStats.SmoothedOrInitialRTT(),
SmoothedRTT: h.rttStats.SmoothedRTT(),
LatestRTT: h.rttStats.LatestRTT(),
BytesInFlight: h.bytesInFlight,
CongestionWindow: h.congestion.GetCongestionWindow(),

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.

View File

@@ -38,12 +38,6 @@ var _ = Describe("RTT stats", func() {
Expect(rttStats.SmoothedRTT()).To(Equal((287500 * time.Microsecond)))
})
It("SmoothedOrInitialRTT", func() {
Expect(rttStats.SmoothedOrInitialRTT()).To(Equal(defaultInitialRTT))
rttStats.UpdateRTT((300 * time.Millisecond), (100 * time.Millisecond), time.Time{})
Expect(rttStats.SmoothedOrInitialRTT()).To(Equal((300 * time.Millisecond)))
})
It("MinRTT", func() {
rttStats.UpdateRTT((200 * time.Millisecond), 0, time.Time{})
Expect(rttStats.MinRTT()).To(Equal((200 * time.Millisecond)))