diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index 242cc182a..ebca6ff13 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -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(), diff --git a/internal/congestion/rtt_stats.go b/internal/congestion/rtt_stats.go index a44d79913..0b17fc10f 100644 --- a/internal/congestion/rtt_stats.go +++ b/internal/congestion/rtt_stats.go @@ -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. diff --git a/internal/congestion/rtt_stats_test.go b/internal/congestion/rtt_stats_test.go index d7ddc8bd5..c899dde0e 100644 --- a/internal/congestion/rtt_stats_test.go +++ b/internal/congestion/rtt_stats_test.go @@ -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)))