diff --git a/internal/protocol/params.go b/internal/protocol/params.go index a124f3aa..cafcdcae 100644 --- a/internal/protocol/params.go +++ b/internal/protocol/params.go @@ -125,6 +125,11 @@ const MaxPostHandshakeCryptoFrameSize = 1000 // but must ensure that a maximum size ACK frame fits into one packet. const MaxAckFrameSize ByteCount = 1000 +// MaxDatagramFrameSize is the maximum size of a DATAGRAM frame as defined in +// https://datatracker.ietf.org/doc/draft-pauly-quic-datagram/. +// The size is chosen such that a DATAGRAM frame fits into a QUIC packet. +const MaxDatagramFrameSize ByteCount = 1200 + // MaxNumAckRanges is the maximum number of ACK ranges that we send in an ACK frame. // It also serves as a limit for the packet history. // If at any point we keep track of more ranges, old ranges are discarded. diff --git a/session.go b/session.go index 761e91ad..4243f34e 100644 --- a/session.go +++ b/session.go @@ -296,7 +296,9 @@ var newSession = func( ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs, InitialSourceConnectionID: srcConnID, RetrySourceConnectionID: retrySrcConnID, - MaxDatagramFrameSize: protocol.InvalidByteCount, // disable DATAGRAMs + } + if s.config.EnableDatagrams { + params.MaxDatagramFrameSize = protocol.MaxDatagramFrameSize } if s.tracer != nil { s.tracer.SentTransportParameters(params) @@ -417,7 +419,9 @@ var newClientSession = func( DisableActiveMigration: true, ActiveConnectionIDLimit: protocol.MaxActiveConnectionIDs, InitialSourceConnectionID: srcConnID, - MaxDatagramFrameSize: protocol.InvalidByteCount, // disable DATAGRAMs + } + if s.config.EnableDatagrams { + params.MaxDatagramFrameSize = protocol.MaxDatagramFrameSize } if s.tracer != nil { s.tracer.SentTransportParameters(params)