don't retransmit PING frames added to ACK-only packets

Every 20 non-ack-eliciting packets, we add a PING frame to make that
packet ack-eliciting. That way, we regularly receive acknowledgements,
even if we're not actually sending any data. This allows us to clean up
our sent packet history.
There's no need to retransmit this PING frame though. We'll just send a
new one if one of them is lost, as soon as we've sent another 20
non-ack-eliciting packets.
This commit is contained in:
Marten Seemann 2020-12-17 11:36:02 +07:00
parent 9693a46d31
commit d8858d767d
2 changed files with 18 additions and 3 deletions

View file

@ -728,7 +728,14 @@ var _ = Describe("Packet packer", func() {
p, err := packer.PackPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.frames).To(ContainElement(ackhandler.Frame{Frame: &wire.PingFrame{}}))
var hasPing bool
for _, f := range p.frames {
if _, ok := f.Frame.(*wire.PingFrame); ok {
hasPing = true
Expect(f.OnLost).ToNot(BeNil()) // make sure the PING is not retransmitted if lost
}
}
Expect(hasPing).To(BeTrue())
// make sure the next packet doesn't contain another PING
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
@ -768,7 +775,14 @@ var _ = Describe("Packet packer", func() {
p, err = packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.ack).To(Equal(ack))
Expect(p.frames).To(Equal([]ackhandler.Frame{{Frame: &wire.PingFrame{}}}))
var hasPing bool
for _, f := range p.frames {
if _, ok := f.Frame.(*wire.PingFrame); ok {
hasPing = true
Expect(f.OnLost).ToNot(BeNil()) // make sure the PING is not retransmitted if lost
}
}
Expect(hasPing).To(BeTrue())
})
It("doesn't send a PING if it already sent another ack-eliciting frame", func() {