don't include the exponential backoff in the PTO calculation

According to the spec, the PTO is defined without the backoff. The
backoff is applied when setting the PTO alarm.
This commit is contained in:
Marten Seemann
2019-06-29 14:02:05 +07:00
parent b5764f22a2
commit 4366eac105
2 changed files with 10 additions and 8 deletions

View File

@@ -342,7 +342,7 @@ func (h *sentPacketHandler) updateLossDetectionAlarm() {
// Early retransmit timer or time loss detection.
h.alarm = h.lossTime
} else { // PTO alarm
h.alarm = h.lastSentAckElicitingPacketTime.Add(h.computePTOTimeout())
h.alarm = h.lastSentAckElicitingPacketTime.Add(h.computePTOTimeout() << h.ptoCount)
}
}
@@ -658,8 +658,7 @@ func (h *sentPacketHandler) computeCryptoTimeout() time.Duration {
}
func (h *sentPacketHandler) computePTOTimeout() time.Duration {
duration := h.rttStats.SmoothedOrInitialRTT() + utils.MaxDuration(4*h.rttStats.MeanDeviation(), protocol.TimerGranularity) + h.rttStats.MaxAckDelay()
return duration << h.ptoCount
return h.rttStats.SmoothedOrInitialRTT() + utils.MaxDuration(4*h.rttStats.MeanDeviation(), protocol.TimerGranularity) + h.rttStats.MaxAckDelay()
}
func (h *sentPacketHandler) ResetForRetry() error {

View File

@@ -626,13 +626,16 @@ var _ = Describe("SentPacketHandler", func() {
})
It("implements exponential backoff", func() {
handler.ptoCount = 0
timeout := handler.computePTOTimeout()
Expect(timeout).ToNot(BeZero())
sendTime := time.Now().Add(-time.Hour)
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 1, SendTime: sendTime}))
timeout := handler.GetAlarmTimeout().Sub(sendTime)
Expect(handler.GetAlarmTimeout().Sub(sendTime)).To(Equal(timeout))
handler.ptoCount = 1
Expect(handler.computePTOTimeout()).To(Equal(2 * timeout))
handler.updateLossDetectionAlarm()
Expect(handler.GetAlarmTimeout().Sub(sendTime)).To(Equal(2 * timeout))
handler.ptoCount = 2
Expect(handler.computePTOTimeout()).To(Equal(4 * timeout))
handler.updateLossDetectionAlarm()
Expect(handler.GetAlarmTimeout().Sub(sendTime)).To(Equal(4 * timeout))
})
It("sets the TPO send mode until two packets is sent", func() {