forked from quic-go/quic-go
fix initial PTO timer duration
This commit is contained in:
@@ -666,7 +666,7 @@ func (h *sentPacketHandler) ResetForRetry() error {
|
|||||||
func (h *sentPacketHandler) GetStats() *quictrace.TransportState {
|
func (h *sentPacketHandler) GetStats() *quictrace.TransportState {
|
||||||
return &quictrace.TransportState{
|
return &quictrace.TransportState{
|
||||||
MinRTT: h.rttStats.MinRTT(),
|
MinRTT: h.rttStats.MinRTT(),
|
||||||
SmoothedRTT: h.rttStats.SmoothedOrInitialRTT(),
|
SmoothedRTT: h.rttStats.SmoothedRTT(),
|
||||||
LatestRTT: h.rttStats.LatestRTT(),
|
LatestRTT: h.rttStats.LatestRTT(),
|
||||||
BytesInFlight: h.bytesInFlight,
|
BytesInFlight: h.bytesInFlight,
|
||||||
CongestionWindow: h.congestion.GetCongestionWindow(),
|
CongestionWindow: h.congestion.GetCongestionWindow(),
|
||||||
|
|||||||
@@ -43,22 +43,16 @@ func (r *RTTStats) LatestRTT() time.Duration { return r.latestRTT }
|
|||||||
// May return Zero if no valid updates have occurred.
|
// May return Zero if no valid updates have occurred.
|
||||||
func (r *RTTStats) SmoothedRTT() time.Duration { return r.smoothedRTT }
|
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
|
// MeanDeviation gets the mean deviation
|
||||||
func (r *RTTStats) MeanDeviation() time.Duration { return r.meanDeviation }
|
func (r *RTTStats) MeanDeviation() time.Duration { return r.meanDeviation }
|
||||||
|
|
||||||
func (r *RTTStats) MaxAckDelay() time.Duration { return r.maxAckDelay }
|
func (r *RTTStats) MaxAckDelay() time.Duration { return r.maxAckDelay }
|
||||||
|
|
||||||
func (r *RTTStats) PTO() time.Duration {
|
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.
|
// UpdateRTT updates the RTT based on a new sample.
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ var _ = Describe("RTT stats", func() {
|
|||||||
Expect(rttStats.SmoothedRTT()).To(Equal((287500 * time.Microsecond)))
|
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() {
|
It("MinRTT", func() {
|
||||||
rttStats.UpdateRTT((200 * time.Millisecond), 0, time.Time{})
|
rttStats.UpdateRTT((200 * time.Millisecond), 0, time.Time{})
|
||||||
Expect(rttStats.MinRTT()).To(Equal((200 * time.Millisecond)))
|
Expect(rttStats.MinRTT()).To(Equal((200 * time.Millisecond)))
|
||||||
|
|||||||
Reference in New Issue
Block a user