skip a packet number when sending a 1-RTT PTO packet

This commit is contained in:
Marten Seemann 2020-09-07 17:22:26 +07:00
parent 9605eddc23
commit 8ea663d04a
2 changed files with 19 additions and 0 deletions

View file

@ -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)

View file

@ -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()