Skip to content

Commit

Permalink
wire: write configured value of max_udp_payload_size transport parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 8, 2024
1 parent 66f968b commit 73ff5c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ var newConnection = func(
MaxUniStreamNum: protocol.StreamNum(s.config.MaxIncomingUniStreams),
MaxAckDelay: protocol.MaxAckDelayInclGranularity,
AckDelayExponent: protocol.AckDelayExponent,
MaxUDPPayloadSize: protocol.MaxPacketBufferSize,
DisableActiveMigration: true,
StatelessResetToken: &statelessResetToken,
OriginalDestinationConnectionID: origDestConnID,
Expand Down Expand Up @@ -410,6 +411,7 @@ var newClientConnection = func(
MaxBidiStreamNum: protocol.StreamNum(s.config.MaxIncomingStreams),
MaxUniStreamNum: protocol.StreamNum(s.config.MaxIncomingUniStreams),
MaxAckDelay: protocol.MaxAckDelayInclGranularity,
MaxUDPPayloadSize: protocol.MaxPacketBufferSize,
AckDelayExponent: protocol.AckDelayExponent,
DisableActiveMigration: true,
// For interoperability with quic-go versions before May 2023, this value must be set to a value
Expand Down
2 changes: 2 additions & 0 deletions internal/wire/transport_parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var _ = Describe("Transport Parameters", func() {
AckDelayExponent: 13,
MaxAckDelay: 42 * time.Millisecond,
ActiveConnectionIDLimit: 2 + getRandomValueUpTo(math.MaxInt64-2),
MaxUDPPayloadSize: 1200 + protocol.ByteCount(getRandomValue()-1200),
MaxDatagramFrameSize: protocol.ByteCount(getRandomValue()),
}
data := params.Marshal(protocol.PerspectiveServer)
Expand All @@ -124,6 +125,7 @@ var _ = Describe("Transport Parameters", func() {
Expect(p.AckDelayExponent).To(Equal(uint8(13)))
Expect(p.MaxAckDelay).To(Equal(42 * time.Millisecond))
Expect(p.ActiveConnectionIDLimit).To(Equal(params.ActiveConnectionIDLimit))
Expect(p.MaxUDPPayloadSize).To(Equal(params.MaxUDPPayloadSize))
Expect(p.MaxDatagramFrameSize).To(Equal(params.MaxDatagramFrameSize))
})

Expand Down
4 changes: 3 additions & 1 deletion internal/wire/transport_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte {
// idle_timeout
b = p.marshalVarintParam(b, maxIdleTimeoutParameterID, uint64(p.MaxIdleTimeout/time.Millisecond))
// max_packet_size
b = p.marshalVarintParam(b, maxUDPPayloadSizeParameterID, uint64(protocol.MaxPacketBufferSize))
if p.MaxUDPPayloadSize > 0 {
b = p.marshalVarintParam(b, maxUDPPayloadSizeParameterID, uint64(p.MaxUDPPayloadSize))
}
// max_ack_delay
// Only send it if is different from the default value.
if p.MaxAckDelay != protocol.DefaultMaxAckDelay {
Expand Down

0 comments on commit 73ff5c6

Please sign in to comment.