Skip to content

Instantly share code, notes, and snippets.

@eaglgenes101
Last active October 18, 2018 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eaglgenes101/1a7d7350bebdbdfe0244915921b46d6a to your computer and use it in GitHub Desktop.
Save eaglgenes101/1a7d7350bebdbdfe0244915921b46d6a to your computer and use it in GitHub Desktop.
Protocol take 4
The protocol is implemented on top of QUIC.
First, the server and client recognise protocol compatibility through ALPN. The protocol is actually a potentially limitless family of mutually incompatible protocols, and has ALPNs of the form "laminar/<game name>/<game ID>/<minor version>", where game name is a string that is 16 bytes or less for the name of the game, game ID is a 64-character base64 string that is randomly generated each major version, and minor version is a 64-bit number in hexadecimal that is set to 0x0000000000000000 for the first release of a major version and then incremented each minor version which modifies the protocol.
Once compatibility is confirmed and the server and client establish a connection, a few extensions are automatically enabled (others may be negotiated and then enabled):
- Type 0x1C and 0x1D are DATAGRAM, and follow the syntax and semantics described in detail at https://datatracker.ietf.org/doc/draft-pauly-quic-datagram/ .
- Type 0x4C20 is EXPIRED_STREAM_DATA, and follows the syntax and semantics described in detail at https://datatracker.ietf.org/doc/draft-lubashev-quic-partial-reliability/ .
The application error code 0x0022 is used to signal that a stream is ended because the useful life of the contained data is up. This is a normal occurrence in this protocol.
... and that's pretty much it. Messages are encoded either by datagram frames, if they can be fit into a single frame, or as an independent numbered stream, if they cannot. QUIC protocol handles most of the cases, and it's up to the other end to figure out how to make sense of the byte buffers that make it across.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment