From 8ea663d04ad0c8e020aa9aa6a49f5094d4f6c6bc Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 7 Sep 2020 17:22:26 +0700 Subject: [PATCH] skip a packet number when sending a 1-RTT PTO packet --- internal/ackhandler/sent_packet_handler.go | 2 ++ internal/ackhandler/sent_packet_handler_test.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index 6b441443..d970b61f 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -632,6 +632,8 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error { case protocol.EncryptionHandshake: h.ptoMode = SendPTOHandshake case protocol.Encryption1RTT: + // skip a packet number in order to elicit an immediate ACK + _ = h.PopPacketNumber(protocol.Encryption1RTT) h.ptoMode = SendPTOAppData default: return fmt.Errorf("PTO timer in unexpected encryption level: %s", encLevel) diff --git a/internal/ackhandler/sent_packet_handler_test.go b/internal/ackhandler/sent_packet_handler_test.go index 9b428809..489631d2 100644 --- a/internal/ackhandler/sent_packet_handler_test.go +++ b/internal/ackhandler/sent_packet_handler_test.go @@ -692,6 +692,23 @@ var _ = Describe("SentPacketHandler", func() { Expect(handler.SendMode()).ToNot(Equal(SendPTOAppData)) }) + It("skips a packet number for 1-RTT PTOs", func() { + handler.ReceivedPacket(protocol.EncryptionHandshake) + handler.SetHandshakeConfirmed() + var lostPackets []protocol.PacketNumber + pn := handler.PopPacketNumber(protocol.Encryption1RTT) + handler.SentPacket(ackElicitingPacket(&Packet{ + PacketNumber: pn, + SendTime: time.Now().Add(-time.Hour), + Frames: []Frame{ + {Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, 1) }}, + }, + })) + Expect(handler.OnLossDetectionTimeout()).To(Succeed()) + Expect(handler.SendMode()).To(Equal(SendPTOAppData)) + Expect(handler.PopPacketNumber(protocol.Encryption1RTT)).To(Equal(pn + 2)) + }) + It("only counts ack-eliciting packets as probe packets", func() { handler.ReceivedPacket(protocol.EncryptionHandshake) handler.SetHandshakeConfirmed()