move calculation of RTO delay to the sent packet handler

This commit is contained in:
Marten Seemann
2018-04-16 11:18:14 +09:00
parent ef286afa3c
commit 2b9b949855
6 changed files with 8 additions and 52 deletions

View File

@@ -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

View File

@@ -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))
})