Skip to content

datagrams: Add initial datagram draft#680

Open
MarcoPolo wants to merge 4 commits into
masterfrom
marco/datagrams
Open

datagrams: Add initial datagram draft#680
MarcoPolo wants to merge 4 commits into
masterfrom
marco/datagrams

Conversation

@MarcoPolo

Copy link
Copy Markdown
Contributor

Initial text for specifying how datagrams will work on libp2p.

cc @raulk @sukunrt @jxs

@marten-seemann marten-seemann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered tying a datagram flow to a stream, similar to what HTTP DATAGRAMS (RFC 9297) does?

This would have the following benefits:

  1. Shorter datagram header (especially important given MTU restrictions).
  2. Both peers get the opportunity to cancel a datagram flow (by closing / resetting the associated stream).
  3. A reliable control channel, e.g. for application protocols that need to send an occasional control message next to a datagram flow.

@MarcoPolo

Copy link
Copy Markdown
Contributor Author

Thanks @marten-seemann! That's a nice idea. We can include the versioning information in the stream as well so we don't pay that overhead on every datagram. The datagram itself then only has a single varint of overhead.

@johannamoran

Copy link
Copy Markdown

@jxs - I've reached out to zig, nim, py and dotnet for feedback to get this moving.

Comment thread datagrams/datagrams.md
Comment on lines +85 to +89
libp2p datagrams on WebTransport behave the same as libp2p datagrams on QUIC.
However, the application data may be further limited by the overhead of HTTP
Datagram's Quarter Stream ID field.

In the future, a separate spec may be able to remove this overhead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the quic encoding uses a stream id as the control stream identifier, but browser webtransport doesn't expose quic stream ids. If browser implementations are expected to support this, how is the control stream identified? would some specific webtransport flow identifier be needed?

Comment thread datagrams/datagrams.md
start sending datagrams at once. There is currently no other use for the control
stream besides negotiating the application protocol ID. Receipt of a QUIC
DATAGRAM frame whose payload is too short to allow parsing the Control Stream ID
field MUST be treated as a connection error of type PROTOCOL_VIOLATION (0x1003).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps something like this so the name does not clash with QUIC's own PROTOCOL_VIOLATION (0x0a) error? (also on line 71:72)

Suggested change
field MUST be treated as a connection error of type PROTOCOL_VIOLATION (0x1003).
field MUST be treated as a connection error of type DG_PROTOCOL_VIOLATION (0x1003).

Comment thread datagrams/datagrams.md
Comment on lines +69 to +72
If a libp2p datagram is received and its Control Stream ID field maps to a
stream that cannot be created due to client-initiated bidirectional stream
limits, it MUST be treated as a connection error of type PROTOCOL_VIOLATION
(0x1003).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm a bit confused by the reference to "client-initiated bidirectional stream limits". Can control streams be opened by either peer?

Comment thread datagrams/datagrams.md
Comment on lines +51 to +54
protocol. A control stream is a QUIC bidirectional stream that has negotiated
the libp2p datagram control stream protocol ID `/dg/1`. The initiator MUST send
the related application protocol ID with a [uvarint] length prefix after
negotiating the control stream. The control stream MUST stay open for the

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would help to clarify the receiver behavior if the application protocol id is unsupported or malformed. (i.e. close stream / reset?). Is this going to use multistream-select?

Comment thread datagrams/datagrams.md
the related application protocol ID with a [uvarint] length prefix after
negotiating the control stream. The control stream MUST stay open for the
duration of the datagram flow. Implementation MAY create the control stream and
start sending datagrams at once. There is currently no other use for the control

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen to datagrams that arrive before control stream has finished /dg1 processing and application protocol negotiation? should they be dropped or buffered?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

4 participants