forked from quic-go/quic-go
@@ -181,6 +181,11 @@ func (p *packetPacker) composeNextPacket(stopWaitingFrame *frames.StopWaitingFra
|
|||||||
|
|
||||||
maxFrameSize := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLength
|
maxFrameSize := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLength
|
||||||
|
|
||||||
|
// until QUIC 33, packets have a 1 byte private header
|
||||||
|
if p.version < protocol.Version34 {
|
||||||
|
maxFrameSize--
|
||||||
|
}
|
||||||
|
|
||||||
if stopWaitingFrame != nil {
|
if stopWaitingFrame != nil {
|
||||||
payloadFrames = append(payloadFrames, stopWaitingFrame)
|
payloadFrames = append(payloadFrames, stopWaitingFrame)
|
||||||
minLength, err := stopWaitingFrame.MinLength(p.version)
|
minLength, err := stopWaitingFrame.MinLength(p.version)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ var _ = Describe("Packet packer", func() {
|
|||||||
streamFrameQueue: newStreamFrameQueue(),
|
streamFrameQueue: newStreamFrameQueue(),
|
||||||
}
|
}
|
||||||
publicHeaderLen = 1 + 8 + 1 // 1 flag byte, 8 connection ID, 1 packet number
|
publicHeaderLen = 1 + 8 + 1 // 1 flag byte, 8 connection ID, 1 packet number
|
||||||
|
packer.version = protocol.Version34
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
@@ -267,6 +268,7 @@ var _ = Describe("Packet packer", func() {
|
|||||||
Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse())
|
Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse())
|
||||||
p, err = packer.PackPacket(nil, []frames.Frame{})
|
p, err = packer.PackPacket(nil, []frames.Frame{})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(p.frames).To(HaveLen(1))
|
||||||
Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse())
|
Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -302,6 +304,19 @@ var _ = Describe("Packet packer", func() {
|
|||||||
Expect(p.raw).To(ContainSubstring(string(f3.Data)))
|
Expect(p.raw).To(ContainSubstring(string(f3.Data)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("packs a packet with a stream frame larger than maximum size, in QUIC < 34", func() {
|
||||||
|
packer.version = protocol.Version33
|
||||||
|
f := frames.StreamFrame{
|
||||||
|
StreamID: 5,
|
||||||
|
Offset: 1,
|
||||||
|
Data: bytes.Repeat([]byte{'f'}, int(protocol.MaxPacketSize)+100),
|
||||||
|
}
|
||||||
|
packer.AddStreamFrame(f)
|
||||||
|
p, err := packer.PackPacket(nil, []frames.Frame{})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(p.raw).To(HaveLen(int(protocol.MaxPacketSize)))
|
||||||
|
})
|
||||||
|
|
||||||
It("splits one stream frame larger than maximum size", func() {
|
It("splits one stream frame larger than maximum size", func() {
|
||||||
f := frames.StreamFrame{
|
f := frames.StreamFrame{
|
||||||
StreamID: 7,
|
StreamID: 7,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const MaxByteCount = math.MaxUint64
|
|||||||
const MaxPacketSize ByteCount = 1350
|
const MaxPacketSize ByteCount = 1350
|
||||||
|
|
||||||
// MaxFrameAndPublicHeaderSize is the maximum size of a QUIC frame plus PublicHeader
|
// MaxFrameAndPublicHeaderSize is the maximum size of a QUIC frame plus PublicHeader
|
||||||
const MaxFrameAndPublicHeaderSize = MaxPacketSize - 1 /*private header*/ - 12 /*crypto signature*/
|
const MaxFrameAndPublicHeaderSize = MaxPacketSize - 12 /*crypto signature*/
|
||||||
|
|
||||||
// DefaultTCPMSS is the default maximum packet size used in the Linux TCP implementation.
|
// DefaultTCPMSS is the default maximum packet size used in the Linux TCP implementation.
|
||||||
// Used in QUIC for congestion window computations in bytes.
|
// Used in QUIC for congestion window computations in bytes.
|
||||||
|
|||||||
Reference in New Issue
Block a user