Skip to content

Commit

Permalink
cancel the PTO timer when all Handshake packets are acknowledged
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jul 13, 2021
1 parent 746358c commit 61748d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/ackhandler/sent_packet_handler.go
Expand Up @@ -536,6 +536,13 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
// PTO alarm
ptoTime, encLevel, ok := h.getPTOTimeAndSpace()
if !ok {
if !oldAlarm.IsZero() {
h.alarm = time.Time{}
h.logger.Debugf("Canceling loss detection timer. No PTO needed..")
if h.tracer != nil {
h.tracer.LossTimerCanceled()
}
}
return
}
h.alarm = ptoTime
Expand Down
11 changes: 11 additions & 0 deletions internal/ackhandler/sent_packet_handler_test.go
Expand Up @@ -931,6 +931,17 @@ var _ = Describe("SentPacketHandler", func() {
handler.ReceivedPacket(protocol.EncryptionHandshake)
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
})

It("cancels the loss detection alarm when all Handshake packets are acknowledged", func() {
t := time.Now().Add(-time.Second)
handler.ReceivedBytes(99999)
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2, SendTime: t}))
handler.SentPacket(handshakePacket(&Packet{PacketNumber: 3, SendTime: t}))
handler.SentPacket(handshakePacket(&Packet{PacketNumber: 4, SendTime: t}))
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
handler.ReceivedAck(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 3, Largest: 4}}}, protocol.EncryptionHandshake, time.Now())
Expect(handler.GetLossDetectionTimeout()).To(BeZero())
})
})

Context("amplification limit, for the client", func() {
Expand Down

0 comments on commit 61748d4

Please sign in to comment.