add exponential backoff to RTO calculation

fixes #112
This commit is contained in:
Lucas Clemente
2016-09-09 00:26:18 +02:00
parent 5d0399bfe3
commit 9b2127018d
3 changed files with 30 additions and 1 deletions

View File

@@ -786,6 +786,21 @@ var _ = Describe("SentPacketHandler", func() {
handler.rttStats.UpdateRTT(rtt, 0, time.Now())
Expect(handler.getRTO()).To(Equal(protocol.MinRetransmissionTime))
})
It("limits RTO max", func() {
rtt := time.Hour
handler.rttStats.UpdateRTT(rtt, 0, time.Now())
Expect(handler.getRTO()).To(Equal(protocol.MaxRetransmissionTime))
})
It("implements exponential backoff", func() {
handler.consecutiveRTOCount = 0
Expect(handler.getRTO()).To(Equal(protocol.DefaultRetransmissionTime))
handler.consecutiveRTOCount = 1
Expect(handler.getRTO()).To(Equal(2 * protocol.DefaultRetransmissionTime))
handler.consecutiveRTOCount = 2
Expect(handler.getRTO()).To(Equal(4 * protocol.DefaultRetransmissionTime))
})
})
Context("RTO retransmission", func() {