queue 0-RTT packets for retransmission after receiving a Retry

This commit is contained in:
Marten Seemann
2019-08-15 12:38:25 +07:00
parent afbf5efd01
commit 951477af92
2 changed files with 38 additions and 0 deletions

View File

@@ -598,7 +598,15 @@ func (h *sentPacketHandler) ResetForRetry() error {
h.queueFramesForRetransmission(p)
return true, nil
})
// All application data packets sent at this point are 0-RTT packets.
// In the case of a Retry, we can assume that the server dropped all of them.
h.appDataPackets.history.Iterate(func(p *Packet) (bool, error) {
h.queueFramesForRetransmission(p)
return true, nil
})
h.initialPackets = newPacketNumberSpace(h.initialPackets.pns.Pop())
h.appDataPackets = newPacketNumberSpace(h.appDataPackets.pns.Pop())
h.setLossDetectionTimer()
return nil
}

View File

@@ -875,5 +875,35 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.GetLossDetectionTimeout()).To(BeZero())
Expect(handler.SendMode()).To(Equal(SendAny))
})
It("queues outstanding frames for retransmission and cancels alarms", func() {
var lostInitial, lost0RTT bool
handler.SentPacket(&Packet{
PacketNumber: 13,
EncryptionLevel: protocol.EncryptionInitial,
Frames: []Frame{
{Frame: &wire.CryptoFrame{Data: []byte("foobar")}, OnLost: func(wire.Frame) { lostInitial = true }},
},
Length: 100,
})
pn := handler.PopPacketNumber(protocol.Encryption0RTT)
handler.SentPacket(&Packet{
PacketNumber: pn,
EncryptionLevel: protocol.Encryption0RTT,
Frames: []Frame{
{Frame: &wire.StreamFrame{Data: []byte("foobar")}, OnLost: func(wire.Frame) { lost0RTT = true }},
},
Length: 999,
})
Expect(handler.bytesInFlight).ToNot(BeZero())
// now receive a Retry
Expect(handler.ResetForRetry()).To(Succeed())
Expect(handler.bytesInFlight).To(BeZero())
Expect(lostInitial).To(BeTrue())
Expect(lost0RTT).To(BeTrue())
// make sure we keep increasing the packet number for 0-RTT packets
Expect(handler.PopPacketNumber(protocol.Encryption0RTT)).To(BeNumerically(">", pn))
})
})
})