forked from quic-go/quic-go
move calculation of RTO delay to the sent packet handler
This commit is contained in:
@@ -545,9 +545,12 @@ func (h *sentPacketHandler) computeHandshakeTimeout() time.Duration {
|
||||
}
|
||||
|
||||
func (h *sentPacketHandler) computeRTOTimeout() time.Duration {
|
||||
rto := h.congestion.RetransmissionDelay()
|
||||
if rto == 0 {
|
||||
var rto time.Duration
|
||||
rtt := h.rttStats.SmoothedRTT()
|
||||
if rtt == 0 {
|
||||
rto = defaultRTOTimeout
|
||||
} else {
|
||||
rto = rtt + 4*h.rttStats.MeanDeviation()
|
||||
}
|
||||
rto = utils.MaxDuration(rto, minRTOTimeout)
|
||||
// Exponential backoff
|
||||
|
||||
@@ -512,7 +512,6 @@ var _ = Describe("SentPacketHandler", func() {
|
||||
|
||||
BeforeEach(func() {
|
||||
cong = mocks.NewMockSendAlgorithm(mockCtrl)
|
||||
cong.EXPECT().RetransmissionDelay().AnyTimes()
|
||||
handler.congestion = cong
|
||||
})
|
||||
|
||||
@@ -693,8 +692,10 @@ var _ = Describe("SentPacketHandler", func() {
|
||||
|
||||
It("uses RTO from rttStats", func() {
|
||||
rtt := time.Second
|
||||
expected := rtt + rtt/2*4
|
||||
handler.rttStats.UpdateRTT(rtt, 0, time.Now())
|
||||
Expect(handler.rttStats.SmoothedRTT()).To(Equal(rtt))
|
||||
Expect(handler.rttStats.MeanDeviation()).To(Equal(rtt / 2))
|
||||
expected := rtt + rtt/2*4
|
||||
Expect(handler.computeRTOTimeout()).To(Equal(expected))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user