forked from quic-go/quic-go
use shorter packet numbers on Long Header packets
This commit is contained in:
@@ -636,12 +636,6 @@ func (p *packetPacker) getLongHeader(encLevel protocol.EncryptionLevel) *wire.Ex
|
|||||||
|
|
||||||
hdr.PacketNumber = pn
|
hdr.PacketNumber = pn
|
||||||
hdr.PacketNumberLen = pnLen
|
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 {
|
switch encLevel {
|
||||||
case protocol.EncryptionInitial:
|
case protocol.EncryptionInitial:
|
||||||
|
|||||||
@@ -113,12 +113,11 @@ var _ = Describe("Packet packer", func() {
|
|||||||
|
|
||||||
Context("generating a packet header", func() {
|
Context("generating a packet header", func() {
|
||||||
It("uses the Long Header format", 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)
|
h := packer.getLongHeader(protocol.EncryptionHandshake)
|
||||||
Expect(h.IsLongHeader).To(BeTrue())
|
Expect(h.IsLongHeader).To(BeTrue())
|
||||||
Expect(h.PacketNumber).To(Equal(protocol.PacketNumber(0x42)))
|
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.PacketNumberLen3))
|
||||||
Expect(h.PacketNumberLen).To(Equal(protocol.PacketNumberLen4))
|
|
||||||
Expect(h.Version).To(Equal(packer.version))
|
Expect(h.Version).To(Equal(packer.version))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user