diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index a0a7c4e2..ac541a5a 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -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 diff --git a/internal/ackhandler/sent_packet_handler_test.go b/internal/ackhandler/sent_packet_handler_test.go index 5ac25192..26369a46 100644 --- a/internal/ackhandler/sent_packet_handler_test.go +++ b/internal/ackhandler/sent_packet_handler_test.go @@ -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)) }) diff --git a/internal/congestion/cubic_sender.go b/internal/congestion/cubic_sender.go index 1ab59535..21f01942 100644 --- a/internal/congestion/cubic_sender.go +++ b/internal/congestion/cubic_sender.go @@ -292,11 +292,3 @@ func (c *cubicSender) OnConnectionMigration() { func (c *cubicSender) SetSlowStartLargeReduction(enabled bool) { c.slowStartLargeReduction = enabled } - -// RetransmissionDelay gives the time to retransmission -func (c *cubicSender) RetransmissionDelay() time.Duration { - if c.rttStats.SmoothedRTT() == 0 { - return 0 - } - return c.rttStats.SmoothedRTT() + c.rttStats.MeanDeviation()*4 -} diff --git a/internal/congestion/cubic_sender_test.go b/internal/congestion/cubic_sender_test.go index a4dceaab..4a07a405 100644 --- a/internal/congestion/cubic_sender_test.go +++ b/internal/congestion/cubic_sender_test.go @@ -397,33 +397,6 @@ var _ = Describe("Cubic Sender", func() { Expect(sender.GetCongestionWindow()).To(Equal(defaultWindowTCP)) }) - It("retransmission delay", func() { - const rtt = 10 * time.Millisecond - const deviation = 3 * time.Millisecond - Expect(sender.RetransmissionDelay()).To(BeZero()) - - rttStats.UpdateRTT(rtt, 0, clock.Now()) - - // Initial value is to set the median deviation to half of the initial - // rtt, the median in then multiplied by a factor of 4 and finally the - // smoothed rtt is added which is the initial rtt. - expectedDelay := rtt + rtt/2*4 - Expect(sender.RetransmissionDelay()).To(Equal(expectedDelay)) - - for i := 0; i < 100; i++ { - // run to make sure that we converge. - rttStats.UpdateRTT(rtt+deviation, 0, clock.Now()) - rttStats.UpdateRTT(rtt-deviation, 0, clock.Now()) - } - expectedDelay = rtt + deviation*4 - - Expect(rttStats.SmoothedRTT()).To(BeNumerically("~", rtt, time.Millisecond)) - Expect(sender.RetransmissionDelay()).To(BeNumerically("~", expectedDelay, time.Millisecond)) - Expect(sender.BandwidthEstimate() / BytesPerSecond).To(Equal(Bandwidth( - sender.GetCongestionWindow() * protocol.ByteCount(time.Second) / protocol.ByteCount(rttStats.SmoothedRTT()), - ))) - }) - It("slow start max send window", func() { const maxCongestionWindowTCP = 50 const numberOfAcks = 100 diff --git a/internal/congestion/interface.go b/internal/congestion/interface.go index 3c09428f..28950dd0 100644 --- a/internal/congestion/interface.go +++ b/internal/congestion/interface.go @@ -17,7 +17,6 @@ type SendAlgorithm interface { SetNumEmulatedConnections(n int) OnRetransmissionTimeout(packetsRetransmitted bool) OnConnectionMigration() - RetransmissionDelay() time.Duration // Experiments SetSlowStartLargeReduction(enabled bool) diff --git a/internal/mocks/congestion.go b/internal/mocks/congestion.go index fec7b6c1..b86ccfea 100644 --- a/internal/mocks/congestion.go +++ b/internal/mocks/congestion.go @@ -109,18 +109,6 @@ func (mr *MockSendAlgorithmMockRecorder) OnRetransmissionTimeout(arg0 interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnRetransmissionTimeout", reflect.TypeOf((*MockSendAlgorithm)(nil).OnRetransmissionTimeout), arg0) } -// RetransmissionDelay mocks base method -func (m *MockSendAlgorithm) RetransmissionDelay() time.Duration { - ret := m.ctrl.Call(m, "RetransmissionDelay") - ret0, _ := ret[0].(time.Duration) - return ret0 -} - -// RetransmissionDelay indicates an expected call of RetransmissionDelay -func (mr *MockSendAlgorithmMockRecorder) RetransmissionDelay() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RetransmissionDelay", reflect.TypeOf((*MockSendAlgorithm)(nil).RetransmissionDelay)) -} - // SetNumEmulatedConnections mocks base method func (m *MockSendAlgorithm) SetNumEmulatedConnections(arg0 int) { m.ctrl.Call(m, "SetNumEmulatedConnections", arg0)