TransportWireFormat

The framed webtools-udp 2.x transport wire format: the 1-byte DatagramType prefix, the control-datagram encodings (keepaliveDatagram, probePingDatagram, probePongDatagram), and the unreliable application-data frame (unreliableDatagram). The handshake bootstrap stays plain UTF-8 text — see HandshakeWireFormat.

The datagram-type tag (byte 0)

Byte 0EntryRest of datagram
0x80DatagramType.KEEPALIVE(empty)
0x81DatagramType.PROBE_PING8-byte big-endian uint64 probe sequence
0x82DatagramType.PROBE_PONG8-byte big-endian uint64 probe sequence (echoed)
0x90DatagramType.UNRELIABLE[channel:1] (2.0: always 0x00) + payload verbatim — channel-byte contract: see DEFAULT_UNRELIABLE_CHANNEL

Boundary note

This is a wire break: there is no 1.x ↔ 2.x post-handshake interop. Both ends must be on webtools-udp 2.0.0+. A cross-major peer is caught at the handshake — the server's REGISTERED reply carries FRAMED_PROTOCOL_VERSION (REGISTERED 2) and a mismatch fails MultiConnectionUDPClient.handshake cleanly with an IncompatibleProtocolException.

Every other byte 0 — including the reliable-channel 0xA0/0xA1 frames — is listed in DatagramType's own value-space table; the complete wire reference is docs/webtools-udp-protocol.md.

Properties

Link copied to clipboard

The recommended output-idle interval, in milliseconds, between keepalive datagrams on a NAT'd path (~20 s). Moved here from HandshakeWireFormat.

Link copied to clipboard

The default link-quality probe interval, in milliseconds (1 s). Moved here from HandshakeWireFormat.

Link copied to clipboard

The unreliable channel id this build emits, always 0x00. A receiver drops a datagram whose channel byte is non-zero, with a WARN; see docs/webtools-udp-protocol.md for the full channel-byte contract.

Link copied to clipboard

The wire-protocol major this build speaks; the token in the REGISTERED 2 reply.

Link copied to clipboard

The minimum accepted link-quality probe interval, in milliseconds (250 ms). Connection.startProbe and MultiConnectionUDPClient.startProbe fail with an IllegalArgumentException for an intervalMillis below this floor - the value is rejected, never silently rounded up - and send exactly one probe per requested interval at or above it.

Functions

Link copied to clipboard

The bare keepalive datagram: a single DatagramType.KEEPALIVE tag byte, no body.

Link copied to clipboard

The probe-request datagram: [0x81][seq: 8-byte big-endian uint64].

Link copied to clipboard

The probe-reply datagram: [0x82][seq: 8-byte big-endian uint64], the sequence copied verbatim from the request.

Link copied to clipboard
fun probeSequenceOf(datagram: ByteArray): Long?

The probe sequence carried by an 0x81/0x82 datagram, or null if the datagram is not exactly a tag byte plus an 8-byte big-endian sequence.

Link copied to clipboard

The channel id byte of an 0x90 datagram (byte 1), or null if the datagram is shorter than the 2-byte prefix.

Link copied to clipboard
fun unreliableDatagram(payload: ByteArray, channel: Byte = DEFAULT_UNRELIABLE_CHANNEL): ByteArray

Frames payload as an unreliable application datagram: [0x90][channel][payload…]. Framing is done here, at the application-data call site — never in the shared send seam, which also carries unframed control datagrams (keepalive, PONG, REGISTERED) that must not be double-framed.

Link copied to clipboard

The payload of an 0x90 datagram — bytes 2 onward — or null if the datagram is shorter than the 2-byte [0x90][channel] prefix.