From fb65a017ac12d0be5a493e4d019c80dc67607fde Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 26 Feb 2020 11:26:15 +0700 Subject: [PATCH] use shorter packet numbers on Long Header packets --- packet_packer.go | 6 ------ packet_packer_test.go | 5 ++--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packet_packer.go b/packet_packer.go index f61933bb..0438fc8b 100644 --- a/packet_packer.go +++ b/packet_packer.go @@ -636,12 +636,6 @@ func (p *packetPacker) getLongHeader(encLevel protocol.EncryptionLevel) *wire.Ex hdr.PacketNumber = pn hdr.PacketNumberLen = pnLen - if encLevel != protocol.Encryption0RTT { - // Always send long header packets with the maximum packet number length. - // This simplifies retransmissions: Since the header can't get any larger, - // we don't need to split CRYPTO frames. - hdr.PacketNumberLen = protocol.PacketNumberLen4 - } switch encLevel { case protocol.EncryptionInitial: diff --git a/packet_packer_test.go b/packet_packer_test.go index 79ce793c..b9232050 100644 --- a/packet_packer_test.go +++ b/packet_packer_test.go @@ -113,12 +113,11 @@ var _ = Describe("Packet packer", func() { Context("generating a packet header", func() { It("uses the Long Header format", func() { - pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2) + pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen3) h := packer.getLongHeader(protocol.EncryptionHandshake) Expect(h.IsLongHeader).To(BeTrue()) Expect(h.PacketNumber).To(Equal(protocol.PacketNumber(0x42))) - // long headers always use 4 byte packet numbers, no matter what the packet number generator says - Expect(h.PacketNumberLen).To(Equal(protocol.PacketNumberLen4)) + Expect(h.PacketNumberLen).To(Equal(protocol.PacketNumberLen3)) Expect(h.Version).To(Equal(packer.version)) })