Skip to main content

Module datagram

Module datagram 

Source
Expand description

Datagram tracks: live, unreliable payloads addressed by their own sequence.

A datagram track is fixed as one when it is created, independent of any stream track of the same name. Each datagram is one self-contained payload carried in a single QUIC datagram: best-effort, unordered, and never retransmitted, cached, or fetched. It has a sequence from the track’s own counter and a timestamp, and no group.

A broadcast creates a Producer with broadcast::Producer::create_datagrams, and a reader asks for a Consumer with broadcast::Consumer::datagrams. A consumer is live from when it is created: it never receives a datagram written before it. A created track is in the broadcast’s listing until it ends.

Delivery is best-effort per hop: a session drops (with a debug log) any datagram whose encoded body exceeds the transport’s datagram size, and sessions that can’t carry datagrams at all (moq-lite before 05, or stream-only transports like WebSocket) never deliver them. Moq-transport maps a datagram track onto SUBSCRIBE and OBJECT_DATAGRAM, with the sequence as the group ID and object ID 0.

Moq-lite 07 asks for a datagram track on a request of its own. Moq-lite 05 and 06 carry a name’s groups and datagrams on one subscription, as moq-transport does: a session serves an old subscription with both of the name’s tracks, and a subscriber keeps only the kind it asked for, sharing one subscription with any reader of the other kind. Two limits follow on those versions:

  • A subscription carries the datagram track that exists when it starts, so create a name’s datagram track before, or with, its stream track.
  • The wire never says a name has no datagram track, so a datagram reader of a name with only a stream track receives nothing until that track ends.
  • The wire never says which kind a subscription asks for, so a publisher serves it from the stream track when one is published, and otherwise from whichever kind answers first: a local datagram track answers without waiting for a stream request handler, which need not answer a name it doesn’t serve.

Structs§

Consumer
Reads a datagram track’s datagrams, in arrival order, from when it was created.
Datagram
A single unreliable payload: its sequence, its timestamp, and the bytes.
Info
Publisher-side properties of a datagram track, fixed when it is created.
Producer
Writes datagrams to a datagram track.
Request
A datagram track a consumer asked for that a handler has yet to serve.