Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the current max content size of Datagram Frame? #3222

Closed
immysec opened this issue Jul 2, 2021 · 2 comments · Fixed by #4497
Closed

How do I get the current max content size of Datagram Frame? #3222

immysec opened this issue Jul 2, 2021 · 2 comments · Fixed by #4497

Comments

@immysec
Copy link

immysec commented Jul 2, 2021

func (s *session) SendMessage(p []byte) error {
	f := &wire.DatagramFrame{DataLenPresent: true}
	if protocol.ByteCount(len(p)) > f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version) {
		return errors.New("message too large")
	}
	f.Data = make([]byte, len(p))
	copy(f.Data, p)
	s.datagramQueue.AddAndWait(f)
	return nil
}

The API just only return "message too large" error if the size of p exceed the f.MaxDataLen(). Caller is unable to know the current allowed MaxDataLen.

@marten-seemann
Copy link
Member

You don't, as there's no way to tell the current MTU, and the MTU may change at any point in the connection.

@ydnar
Copy link
Contributor

ydnar commented Jul 22, 2021

I think for WebTransport, H3 Datagrams, or QUIC Datagrams, it might be a good idea to eventually expose this on a quic.Session.

The WebTransport API defines an application-readable maxDatagramSize, which is the effective payload MTU of a WT datagram (QUIC datagram minus H3 and WT framing overhead).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants