nish/net/quic

The server side of a QUIC version 1 connection (RFC 9000, RFC 9001, RFC 9221): the TLS 1.3 handshake carried in CRYPTO frames at three encryption levels, transport parameters both ways, acknowledgements per packet number space, the connection-ID table, streams both ways (nish/net/quic-stream) and DATAGRAM frames once the handshake is done. Sans-IO, like the rest of nish/net.

import {
  QUIC_CONN_ADDRESS_SIZE,
  QUIC_CONN_CID_LENGTH,
  QUIC_CONN_CONFIDENTIALITY_LIMIT,
  QUIC_CONN_CRYPTO_WINDOW,
  QUIC_CONN_DATAGRAM_MAX,
  QUIC_CONN_DATAGRAM_QUEUE,
  QUIC_CONN_DATAGRAM_SIZE,
  QUIC_CONN_EARLY_RESENDS,
  QUIC_CONN_ENTROPY_SIZE,
  QUIC_CONN_HANDSHAKE_PROBES,
  QUIC_CONN_IDLE_FLOOR,
  QUIC_CONN_INTEGRITY_LIMIT_CHACHA,
  QUIC_CONN_INTEGRITY_LIMIT_GCM,
  QUIC_CONN_LOCAL_CIDS,
  QUIC_CONN_MAX_DATAGRAM_FRAME,
  QUIC_CONN_MAX_ISSUED_CIDS,
  QUIC_CONN_MAX_KEY_UPDATES,
  QUIC_CONN_MAX_STREAMS,
  QUIC_CONN_MAX_STREAM_BUFFERS,
  QUIC_CONN_MAX_STREAM_DATA,
  QUIC_CONN_PACKET_CONTROL,
  QUIC_CONN_PACKET_STREAMS,
  QUIC_CONN_SKIP_MIN,
  QUIC_CONN_SKIP_RING,
  QUIC_CONN_SKIP_SPREAD,
  QUIC_CONN_STATIC_KEY_SIZE,
  QUIC_DATAGRAM_ERR_DISABLED,
  QUIC_DATAGRAM_ERR_FULL,
  QUIC_DATAGRAM_ERR_ROOM,
  QUIC_DATAGRAM_ERR_TOO_BIG,
  QUIC_DATAGRAM_NONE,
  QUIC_DATAGRAM_OK,
  QUIC_STATE_CLOSING,
  QUIC_STATE_CONNECTED,
  QUIC_STATE_DRAINING,
  QUIC_STATE_HANDSHAKE,
  QUIC_STATE_TIMED_OUT,
  QUIC_STATE_WAIT_INITIAL,
  QUIC_WORKER_MAX,
  QuicConnection,
  QuicServerConfig,
  QuicStreamData,
  quicConnResetTokenInto,
  quicStatelessResetToken,
  quicWorkerByte,
  quicWorkerCheck,
} from "nish/net/quic";
import { QuicConnection, QuicServerConfig } from "nish/net/quic";
import { tlsSignEcdsaP256 } from "nish/net/tls";

const conn = new QuicConnection(config, entropy);   // entropy: QUIC_CONN_ENTROPY_SIZE random bytes
conn.receiveWindow(buf, off, len, now);              // every datagram the client sends; now in ms
const input: u8[] | null = conn.signatureInput();
if (input !== null) {
  const signature: u8[] | null = tlsSignEcdsaP256(key, input);   // key: Secret<u8[]>
  if (signature !== null) { conn.sign(signature); }
}
let n: i32 = conn.takeDatagramInto(out, 0, now);     // out: at least QUIC_CONN_DATAGRAM_SIZE bytes
while (n > 0) { … send out[0 .. n) to the client … ; n = conn.takeDatagramInto(out, 0, now); }
let id: i64 = conn.nextStreamEvent();                 // a stream with news: read it, write it
… conn.streamRead(id, buf, 0, size) / conn.streamWrite(id, data, 0, n, fin) …
… and at conn.deadline(), conn.handleTimer(now); once done, conn.reset(entropy) for the next peer
What it is

One connection, from the client's first Initial to a CONNECTION_CLOSE either way. The handshake is nish/net/tls's TlsServer, driven over QUIC as RFC 9001 §4 describes: the bytes it writes at each level go out in CRYPTO frames of the matching packet number space, the bytes the client sends in CRYPTO frames are put back in order and handed to it, and each level's packet keys are made with nish/net/quic-packet's quicKeys as soon as TlsServer knows the secret. The server's transport parameters, original_destination_connection_id and initial_source_connection_id among them, go into EncryptedExtensions; the client's are parsed and checked (RFC 9000 §7.3, §7.4) before the server's flight leaves.

Streams

They are nish/net/quic-stream's: both kinds, opened by either side, with flow control per stream and for the connection raised as the application reads, and the stream limits raised as streams finish. The application sees them through a small surface: nextStreamEvent names a stream with something new (opened, readable, finished, reset, stopped, or writable again), streamRead and streamWrite move bytes a chunk at a time with back-pressure, openStream opens one of the server's, streamReset and streamStopSending abandon a side. readStream and writeStream are the all-at-once forms, which allocate.

Datagrams

Datagrams (RFC 9221). With maxDatagramFrameSize above 0 the server advertises max_datagram_frame_size and takes DATAGRAM frames up to it; a DATAGRAM frame it did not offer to take, or one larger, is PROTOCOL_VIOLATION. sendDatagram queues a payload when the client offered to take one that size and it fits a packet; it goes out within the congestion window, and is never sent again. readDatagram hands out what arrived. Each way is a fixed ring (nish/net/quic-datagram).

Loss recovery

Loss recovery (RFC 9002). It is nish/net/quic-recovery's: every ack-eliciting packet is recorded in its space's ring with what it carried (its CRYPTO range, its STREAM chunks, HANDSHAKE_DONE and the control frames), the client's ACKs give the RTT estimate and show what was lost by packet or time threshold, and what a lost packet carried is sent again, from the CRYPTO bytes a level keeps until it is discarded and the bytes a stream keeps until they are acknowledged; a control frame goes again with its current value.

When nothing is acknowledged for a probe timeout, with its backoff, everything in flight is queued again and a probe goes out in each space that has packets in flight, a PING if there is nothing to resend (§6.2.4) — two datagrams of them during the handshake, each with the oldest CRYPTO data not acknowledged. A client that shows it lacks the server's handshake data (an Initial repeating CRYPTO data, an ack-eliciting Handshake packet) gets it again at once, a datagram each time, up to QUIC_CONN_EARLY_RESENDS times (§6.2.3).

NewReno's window holds back everything ack-eliciting but a probe; an ACK always goes. PATH_RESPONSE and DATAGRAM are never sent again (RFC 9000 §13.3, RFC 9221 §5.2). Pacing, and GSO batching, are the carrier's: nish/net/quic-listener. Once the 1-RTT keys are in, one Application Data packet number in every 128 to 1024 is skipped, at a distance drawn from the ID seed, and the last QUIC_CONN_SKIP_RING are remembered: an ACK of one acknowledges a packet never sent, an optimistic ACK meant to widen the congestion window, and is PROTOCOL_VIOLATION (RFC 9000 §21.4).

Nothing allocated per packet

Nothing allocated per packet (QUIC-3). A connection is a slot: every buffer it uses — the packet record, the CRYPTO reassembly, the connection-ID table, the datagram rings — is made by the constructor and reused, and reset makes the slot a new connection for the next peer.

The stream buffers are borrowed instead (QuicStreamPools in nish/net/quic-stream): a receive side takes one on its first byte and a send side on its first write, each goes back zeroed once the stream is done with it, and a server's connections share one set of pools, so idle slots hold none. A standalone connection makes private pools as large as all its slots at its first packet. The pools are primed before a packet's arena block and never touched inside it.

A packet is opened (receiveWindow) and a datagram built and sealed (takeDatagramInto) inside a using a = arena() block, so the AEAD's and the header protection's temporaries go when the block ends, and the compiler refuses the block if anything in it could store one.

The handshake keeps its state in the slot too: one TlsServer, made by the slot's first handshake and restarted by each after it; every level's packet keys, and a key update's, derived in place into QuicKeysSlots (nish/net/quic-packet) over the slot's HKDF scratch; the Initial secrets, the stateless reset tokens and the connection IDs computed in arena blocks; the transport parameters encoded and parsed into the slot's own objects. After the first connection in a slot, a connection keeps nothing at all (QUIC-3 in docs/security/quic.md).

Time

The connection has no clock: receive, takeDatagram and handleTimer take the caller's monotonic time in milliseconds, and deadline() says when handleTimer is next due. Six things run on it. The idle timeout (RFC 9000 §10.1) is the smaller of the two sides' max_idle_timeout, never under QUIC_CONN_IDLE_FLOOR or three probe timeouts; once it passes with nothing received, the connection closes silently (QUIC_STATE_TIMED_OUT) and wipes its keys. Loss recovery's timer declares packets lost by the time threshold or fires the probe timeout. While a stream's send buffer is full behind bytes in flight, an early ACK-eliciting probe goes half a round trip after the last ACK-eliciting packet, so a client whose NAT rebinds while nothing else is sent still answers from its new port (QUIC-12).

After a key update the previous read keys are kept for a probe timeout (recovery.probeTimeout()), for packets the network reordered, before the next generation's are derived (RFC 9001 §6.5). And while a new path is validated, its PATH_CHALLENGE goes again a probe timeout after the last, and validation gives up max(3 PTO, 6 kInitialRtt) after the move (RFC 9000 §8.2.4, §9.3.2).

Once the connection has closed, by either side, its keys are kept through the closing or draining period, three probe timeouts (RFC 9000 §10.2), and wiped at its end; deadline() is that end, then -1. A close this side owes starts the period when takeDatagram sends it, not when close or fail is called, so that however long the caller waits, the close still goes out.

Key update

Key update (RFC 9001 §6), both ways. A 1-RTT packet whose Key Phase bit differs from the current one is opened with the next generation's read keys, which are derived ahead of time so that a forged bit costs no derivation and shows no timing difference (§6.3); if it opens, the client has updated, and the server's write keys follow before anything is acknowledged (§6.2). updateKeys() starts an update from the server once the client has acknowledged a packet of the current phase (§6.1).

The generations take turns in two key slots and two secrets a direction, so an update keeps nothing in the arena; each still costs two key derivations of work, so a connection takes at most QUIC_CONN_MAX_KEY_UPDATES updates the client starts and closes on the next with KEY_UPDATE_ERROR (QUIC-4).

The AEAD limits are kept (RFC 9001 §6.6): from three quarters of AES-GCM's confidentiality limit, 2^23 packets under one write key, the server starts an update itself, and closes with AEAD_LIMIT_REACHED, sealing nothing more, if it reaches the limit with none possible; past the integrity limit of packets that fail to authenticate over the connection, 2^52 for AES-GCM and 2^36 for ChaCha20-Poly1305, it closes with AEAD_LIMIT_REACHED too.

Sans-IO and deterministic

No socket, no clock and no random device: every random choice (the TLS server random and ephemeral key, the server's first connection ID, and the seed later IDs are derived from) comes from the entropy the constructor and reset take, every stateless reset token from the configuration's static key (RFC 9000 §10.3.2), and every ACK says a delay of zero. So a recorded exchange replays byte for byte.

Paths

Paths (RFC 9000 §8.2, §9). receiveWindowFrom takes the 18-byte nish:net address each datagram came from, and sendAddress() says where the connection's datagrams go: the first Initial's address, validated by the handshake, until the client's address changes. Before the handshake is confirmed a datagram from any other address is dropped unread, so no forged source moves a handshake or takes its flight.

After it, a datagram from a new address whose newest non-probing packet authenticates moves the connection there (§9.3) — a later one from the old address, with a lower packet number, does not move it back — and a PATH_CHALLENGE, eight bytes from the ID seed's HMAC, padded to 1,200 bytes, validates the new path.

Until a PATH_RESPONSE with any of the last three challenges' data arrives, on any path, the server sends there at most three times what came from it (§9.3.1); a lost challenge is drawn again, fresh, a probe timeout later; past max(3 PTO, 6 kInitialRtt) validation has failed and the connection goes back to the last validated address, where the client — or, for a forged source, the real client's next packet — finds it.

Validated, a new address starts congestion control and the RTT estimate again, a port-only change keeps them (§9.4), and ECN is tested again (§13.4.2). A packet that carries only probing frames moves nothing: its PATH_CHALLENGE is answered on its own path, alone in a datagram takeProbeInto writes for probeAddress, under that path's own 3x limit. The client's connection ID is kept across a move (§9.5): a NAT rebinding gives the client no reason to change it, and this server never migrates itself. Every address, challenge and counter is a field made by the constructor and cleared by reset.

What a peer cannot do

Nothing it sends makes this module panic. A datagram that does not parse, a packet that does not authenticate, a duplicate packet number, a packet for keys already discarded and a 1-RTT packet before the handshake is done are dropped and counted in dropped. A frame that breaks the protocol closes the connection with the transport error RFC 9000 names (QUIC_ERROR_* in nish/net/quic-frame), a TLS alert closes it with CRYPTO_ERROR (0x100 + the alert), and the CONNECTION_CLOSE is the next datagram out.

Before the client's address is validated — by a Handshake packet, or by a Retry token nish/net/quic-listener checked — the server sends at most three times what it received (§8.1). Every buffer a peer can fill is fixed: CRYPTO reassembly by QUIC_CONN_CRYPTO_WINDOW, each stream by the credit advertised (its buffer), the connection by maxData, the connection-ID table by the limit advertised, the received packet numbers by QUIC_ACK_MAX_RANGES, and datagrams by their ring.

Secrets

The packet keys of each level live in this connection's key slots as long as the level does; so do the 1-RTT secrets the next key generation is derived from, and the next generation's read keys. The traffic secrets and the ephemeral key TlsServer holds are Secret fields its wipe() reaches (TLS-1): afterTls takes each level's secrets out of them once, into this connection's plain slots, and zeroes them through wipeSecret.

The slots are plain bytes, wiped with stores no optimiser removes (secureZero, and aesKeyWipe for an AES schedule): each level's key, IV, header-protection key and schedules when the level is discarded; each generation's key, IV, schedule and secret when a key update replaces it; and the rest — the 1-RTT keys, the key-update secrets, whatever TlsServer still holds and the connection-ID seed — by release(), reset, the idle timeout, and the end of the closing or draining period (RFC 9000 §10.2), three probe timeouts after this side's CONNECTION_CLOSE went out or the client's arrived. docs/security/quic.md records what is wiped where as QUIC-2.

Written from RFC 9000, RFC 9001 and RFC 9221, in this module's own structure; nothing here is ported from another implementation. Private names carry the quicConn prefix (docs/wp26-stdlib.md §3e).

Functions

quicConnResetTokenInto

quicStatelessResetToken of the ID cid[at .. at + length) into out[outAt ..], computed in a connection's own HMAC scratch inside an arena block, so issuing an ID keeps nothing (QUIC-3). The scratch and the full MAC are wiped before it returns.

const quicConnResetTokenInto: (
  mac: HmacSha256Scratch,
  key: u8[],
  cid: u8[],
  at: i32,
  length: i32,
  out: u8[],
  outAt: i32,
) => void
macHmacSha256Scratchrequired

The connection's HMAC-SHA256 scratch, wiped on return.

keyu8[]required

The server's static reset key, QUIC_CONN_STATIC_KEY_SIZE bytes.

cidu8[]required

The array holding the connection ID.

ati32required

Where the ID starts in cid.

lengthi32required

The ID's length in bytes, at most 20: the caller's to keep, as nothing checks it.

outu8[]required

Where the 16-byte token goes; bytes that would fall past its end are not written.

outAti32required

Where in out the token starts.

quicStatelessResetToken

The stateless reset token for the connection ID cid (RFC 9000 §10.3.2): the first 16 bytes of HMAC-SHA256 under the server's static key. A connection hands it to the client with each ID it issues, and nish/net/quic-listener derives the same token from a packet's ID alone once the connection is gone, which is what lets a server that lost its state end the connection.

const quicStatelessResetToken: (
  key: u8[],
  cid: u8[],
) => u8[]
keyu8[]required

The server's static reset key, QUIC_CONN_STATIC_KEY_SIZE bytes (QuicServerConfig.statelessResetKey).

cidu8[]required

The connection ID the token is for, all of its bytes.

returnsu8[]

A fresh 16-byte token (QUIC_RESET_TOKEN_SIZE); the full MAC it was cut from is wiped.

quicWorkerByte

The byte a server writes at the start of every connection ID it issues: config.workerIndex when the pair names a worker of a steered group, -1 (write nothing) otherwise.

const quicWorkerByte: (config: QuicServerConfig) => i32
configQuicServerConfigrequired

The server's configuration.

returnsi32

The worker index k, from 0 to 254, or -1 when the IDs carry no worker.

quicWorkerCheck

Panics, with the pair in the message, unless config's worker fields are both unset (workerIndex -1 and workerCount 0) or name a worker of a steered group (0 <= k < N <= 255). QuicListener calls it when it is built, before it reads a datagram, so an Http3Server panics through its listener.

const quicWorkerCheck: (config: QuicServerConfig) => void
configQuicServerConfigrequired

The configuration whose workerIndex and workerCount are checked.

Classes

QuicConnection

One server connection, which is also a reusable slot. Make one, hand it every datagram the client sends with receiveWindow (or receive), sign when signatureInput() asks, send what takeDatagramInto() writes until it answers 0, and use streams and datagrams once state is QUIC_STATE_CONNECTED. Once it has closed, reset makes it a new connection for the next client, with its buffers kept.

The fields are readable: state, error (the transport error or application code the connection closed with), dropped, alpn and serverName once the handshake has read them, peerParameters, streams (the stream table), and cids, the connection-ID table, which a server that runs many connections routes datagrams by (ownsConnectionId).

class QuicConnection
Member
new QuicConnection(config: QuicServerConfig, entropy: u8[]) A connection under config, with entropy its QUIC_CONN_ENTROPY_SIZE random bytes, which are copied out and then wiped in the caller's array. Every buffer the connection will use is made here, sized by config. Entropy of another length, or limits outside what QuicServerConfig documents, leave the connection closing with INTERNAL_ERROR before it reads anything; it then sends nothing.
addressValidated: boolean Whether the client's address is validated: a Handshake packet from it was processed.
alpn: string The ALPN protocol the handshake chose.
application: QuicConnSpace The Application Data packet number space, which holds the 1-RTT keys.
appReadSlot: i32 Which of the Application Data space's two read slots, and two write slots, hold the current keys.
appWriteSlot: i32 Which of the Application Data space's two write slots holds the current keys, 0 or 1.
arrivalEcn: i32 The ECN bits the next datagram handed to receive, receiveWindow or receiveWindowFrom arrived with (the IP header's two low traffic-class bits: 0 Not-ECT, 1 ECT(1), 2 ECT(0), 3 CE), which the carrier sets before the call and keeps for every coalesced packet of that datagram. Each packet that opens and is not a duplicate adds them to its packet number space's counts (RFC 9000 §13.4.1), which the space's ACKs then carry as an ACK_ECN. A carrier that cannot read the bits leaves it 0, and its ACKs stay plain. reset clears it.
authFailures: i64 Packets that failed to authenticate over the connection, against integrityLimit.
bytesReceived: i64 Bytes received and sent, for the anti-amplification limit (RFC 9000 §8.1).
bytesSent: i64 Bytes sent, which may not pass three times bytesReceived before the address is validated.
challengeResendAt: i64 When the PATH_CHALLENGE goes again with fresh data, and when validation gives up (§8.2.4); -1 when not validating.
challengesDrawn: i64 How many PATH_CHALLENGE data have been drawn over the connection; see challengeData.
challengeUntil: i64 When path validation gives up, in milliseconds, or -1 when not validating.
cids: QuicCidTable The connection IDs of both sides and their stateless reset tokens (nish/net/quic-conn-cid).
cidSeed: u8[] The 32-byte HMAC key, taken from the entropy, that each new local connection ID is derived from; release wipes it.
confidentialityLimit: i64 The AEAD limits this connection keeps (RFC 9001 §6.6): packets one 1-RTT write key seals, and packets that fail to authenticate over the connection. afterTls sets them from the suite when the 1-RTT keys arrive; until then they are AES-GCM's. They are fields so that a test can lower them after the handshake; nothing else should set them.
datagramEcn: i32 ECN (RFC 9000 §13.4): ecnMarking is the carrier's to set when it sends this connection's datagrams with the ECN bits of datagramEcn, which each takeDatagramInto sets for the datagram it wrote: ECT(0) while loss recovery's ecnCodepoint() asks for it, 0 otherwise and always while ecnMarking is false. Every packet of a marked datagram is counted as marked, and an ACK_ECN's counts are validated against them. reset keeps ecnMarking, which is the carrier's, and clears the rest.
datagramsIn: QuicDatagramQueue DATAGRAM payloads the client sent, waiting to be read; its dropped counts those that found it full.
datagramsOut: QuicDatagramQueue DATAGRAM payloads waiting to be sent, and those the client sent waiting to be read.
dropped: i32 Packets dropped without closing the connection: unparseable, unauthenticated, duplicated, or for keys not held.
earlyProbeAcked: i64 The Application Data space's largest acknowledged packet number when the last early probe was asked for (earlyProbeAt), so one goes per acknowledgment that moves it; -2 before any.
earlyResends: i32 Handshake data sent again early, against QUIC_CONN_EARLY_RESENDS (RFC 9002 §6.2.3).
ecnMarking: boolean Whether the carrier sends with the ECN bits of datagramEcn; the carrier sets it, and reset keeps it.
readonly ephemeral: Secret<u8[]> The x25519 private key begin takes from the entropy, until the handshake hands it to TlsServer.
error: i64 The error code the connection closed with: a transport error, 0x100 + alert, or the application's code.
errorIsApplication: boolean Whether error is an application code (CONNECTION_CLOSE 0x1d) rather than a transport error.
handshake: QuicConnSpace The Handshake packet number space.
handshakeComplete: boolean Whether the handshake is complete, which for a server is also confirmed (RFC 9001 §4.1.2).
initial: QuicConnSpace The Initial packet number space: its keys, packet numbers and acknowledgements (RFC 9000 §12.3).
initialClient: u8[] The Initial secrets of RFC 9001 §5.2, the client's and the server's.
initialServer: u8[] The server's Initial secret (RFC 9001 §5.2); see initialClient.
integrityLimit: i64 Packets that may fail to authenticate before the connection closes (RFC 9001 §6.6). afterTls sets it from the suite; a test may lower it after the handshake.
keyUpdates: i32 Key updates the client started, against QUIC_CONN_MAX_KEY_UPDATES.
localEncoded: u8[] localParameters encoded for the TLS extension the server sends.
localParameters: QuicTransportParameters The server's transport parameters, set for each connection, and their encoding.
readonly nextReadSecret256: Secret<u8[]> The next generation's 1-RTT read secret under SHA-256, 32 bytes; see readSecret256.
readonly nextReadSecret384: Secret<u8[]> The next generation's 1-RTT read secret under SHA-384, 48 bytes; see readSecret256.
nextSkip: i64 The next Application Data packet number skipped (RFC 9000 §21.4), or -1 before the 1-RTT keys; a test may set it to force one. skipped holds the last QUIC_CONN_SKIP_RING skipped, -1 where none, skipHead where the next goes, and skipsDrawn how many distances were drawn.
now: i64 The latest time the caller gave, in milliseconds; time never runs backwards here.
otherIsNext: boolean Whether otherReadKeys are the next generation's rather than the previous one's.
otherReadKeys: QuicKeys | null The other read keys of the Application Data space (RFC 9001 §6.3): the next generation's while otherIsNext, and for a probe timeout after an update the previous one's, for reordered packets (§6.5).
pathCount: i32 How many PATH_CHALLENGE payloads wait to be answered, 0 to 4.
pathKnown: boolean Whether pathCurrent holds the client's address: the carrier passes addresses, and a first Initial gave one.
pathMtu: i32 The largest datagram validated on the current path: 1200 until a probe is acknowledged.
pathMtuLimit: i32 Path MTU discovery (RFC 9000 §14.3, RFC 8899): once the handshake is confirmed and the path validated, the server probes for a datagram larger than 1200 bytes with a PING padded to the size being tried, sent only when nothing else is due, so a probe never holds data back. An acknowledged probe validates its size as pathMtu, which every later datagram may then fill; three lost probes of a size end the search below it. A lost probe is no congestion signal (§14.4). Three loss events that each lose a packet larger than 1200 bytes, with none of that size acknowledged between, are taken for a black hole: pathMtu falls back to 1200 and the search resumes below the size that stopped getting through. A new address starts again from 1200.

pathMtuLimit is the carrier's to lower, for an interface whose MTU carries less than QUIC_CONN_DATAGRAM_MAX: before the first datagram by setting it, and at any time through setPathMtuLimit, which also takes a pathMtu above it down to it. The next probe keeps under it, and an acknowledged probe raises pathMtu no higher than it. 1200 or less turns discovery off. reset keeps it.
pathReceived: i64 Bytes received from and sent to the path being validated, for its own 3x limit (§9.3, §8.1).
pathSent: i64 Bytes sent to the path being validated, at most three times pathReceived.
pathValidated: u8[] The last address the client proved it receives at, in nish:net's 18-byte form (RFC 9000 §9): the handshake's, or one a PATH_RESPONSE answered.
pathValidating: boolean Whether pathCurrent is not validated yet: a PATH_CHALLENGE is out on it.
peerParameters: QuicTransportParameters The client's transport parameters, once the handshake has checked them; until then, every default.
pmtuBlackHoles: i32 Times a black hole sent pathMtu back to 1200.
pmtuProbes: i32 Path MTU probes sent.
pmtuProbesLost: i32 Path MTU probes declared lost.
probeAddress: u8[] A PATH_CHALLENGE that came from another address in a datagram that moved nothing (§9.1): answered there by takeProbeInto, from probeData, within probeBudget bytes, three times what came from probeAddress (§8.1). Only the latest such challenge is kept. A response owed on pathCurrent when the connection moves goes back the same way (sendResponsesBack).
probeOwed: boolean Whether a PATH_RESPONSE is owed on probeAddress, and whether the datagram being read carried a challenge for it.
readPhase: boolean The Key Phase bit of the current read keys, and of the current write keys.
readonly readSecret256: Secret<u8[]> The 1-RTT traffic secrets (RFC 9001 §6.1), one set of SHA-256's length and one of SHA-384's, the one the suite's hash picks in use: the current read secret, the next generation's, and the current write secret, which a key update ratchets in place. The write side keeps no next secret, because the server derives its next write keys only when it moves to them.
readonly readSecret384: Secret<u8[]> The current 1-RTT read secret under SHA-384, 48 bytes; see readSecret256.
recovery: QuicRecovery Loss detection, the RTT estimate, the congestion window and the pacer (RFC 9002).
sealedUnderKey: i64 Packets sealed under the current 1-RTT write key, and packets that failed to authenticate, against those limits.
serverName: string The client's server_name the handshake read, or empty when it sent none.
skipHead: i32 Where the next skipped packet number goes in skipped.
skipsDrawn: i64 How many skip distances have been drawn; see nextSkip.
state: i32 Where the connection is in its life: one of the QUIC_STATE_* constants.
streams: QuicStreams The streams, both ways (nish/net/quic-stream).
tls: TlsServer | null The TlsServer running this connection's handshake: null until the client's first Initial has opened, and again after reset.
tlsSlot: TlsServer | null The slot's TlsServer, made by its first handshake and restarted by every one after (QUIC-3).
writePhase: boolean The Key Phase bit of the current write keys.
readonly writeSecret256: Secret<u8[]> The current 1-RTT write secret under SHA-256, 32 bytes; see readSecret256.
readonly writeSecret384: Secret<u8[]> The current 1-RTT write secret under SHA-384, 48 bytes; see readSecret256.
acceptRetry(originalDcid: u8[], retryScid: u8[]): boolean Sets up a connection whose client came back with a Retry token that nish/net/quic-listener checked (RFC 9000 §8.1.2): originalDcid is the DCID of the client's Initial before the Retry, and retryScid the Retry's SCID, which the client now sends to. The server's transport parameters then name both (§7.3), and the client's address counts as validated, so the anti-amplification limit does not apply. Call it before the first receive; answers whether it took: not once the connection has started, and not for an ID over 20 bytes.
afterTls(): void Whatever TLS's last step made due: its output moved into each level's CRYPTO stream, the keys of each level it now has secrets for, the client's transport parameters checked once it has read them, and, when the handshake completes, the Handshake keys discarded (RFC 9001 §4.9.2), HANDSHAKE_DONE queued (§4.1.2) and the client given more connection IDs.
amplificationBlocked(): boolean Whether the anti-amplification limit stops the server sending (RFC 9000 §8.1): the client's address is not validated and three times what it sent leaves no room for a whole datagram.
close(code: i64): void Closes the connection from the application, with its own error code (CONNECTION_CLOSE 0x1d; RFC 9000 §10.2). The next takeDatagram answers the close, and nothing after it. Closing twice, or after the client closed, does nothing.
closed(): boolean Whether the connection has closed, either way.
datagramSize(): i32 The largest datagram the server sends now: pathMtu, or 1200 while a new path is being validated.
deadline(): i64 When handleTimer is next due, in the caller's milliseconds: the idle timeout, loss recovery's timer (a time-threshold loss or the probe timeout), an early probe while a stream's send buffer is full behind bytes in flight, the end of a key update's probe timeout, or, while a path is validated, its PATH_CHALLENGE's resend or the end of its validation, whichever comes first; once the connection has closed, the end of its closing or draining period, when its keys are wiped. -1 when nothing is timed: before the first packet, while a closed connection's own close has not gone out (takeDatagram sends it), once a closed connection's keys are wiped, and with no idle timeout, nothing in flight, no update pending and no path being validated.
handleTimer(now: i64): void Runs whatever is due by now, the caller's monotonic time in milliseconds; call it at deadline(), or any time. Past the idle timeout the connection closes silently (QUIC_STATE_TIMED_OUT, RFC 9000 §10.1): no CONNECTION_CLOSE, every key wiped. Past the closing or draining period of a connection that closed, every key is wiped (§10.2). Past a key update's probe timeout the previous read keys are wiped and the next generation's derived (RFC 9001 §6.5).

Past loss recovery's timer, packets lost by the time threshold have their frames queued again, or a probe timeout queues every space's packets in flight and asks for a probe (RFC 9002 §6.1.2, §6.2.4): takeDatagram then sends it. Past the early probe's time, while a stream's send buffer is full behind bytes in flight, a probe is asked for the same way, so the client answers from wherever its NAT now sends it. receive and takeDatagram run it themselves. Time never runs backwards here: an earlier now than one already given counts as that one.
idleDeadline(): i64 When the idle timeout passes, or -1 when there is none or the timer has not started.
maxDatagramPayload(): i32 The largest DATAGRAM payload sendDatagram takes now: what fits the client's max_datagram_frame_size with the frame's type and Length, and a 1-RTT packet of datagramSize() with the longest packet number; 0 when the client takes none, or the server sends none. It grows when path MTU discovery validates a larger datagram, and shrinks again on a fall back to 1200, which drops a queued payload that no longer fits.
nextStreamEvent(): i64 The ID of the next stream with something new for the application — the client opened it, it has bytes or its FIN to read, it was reset or stopped, or it has room to write again after a short write — or -1 when there is none. Each stream comes up once however much happened; read and write it until it has nothing more to say.
openStream(bidirectional: boolean): i64 Opens a stream of the server's (RFC 9000 §2.1): bidirectional when bidirectional, else unidirectional. Answers its ID, or QUIC_STREAM_ERR_STATE when not connected, or QUIC_STREAM_ERR_LIMIT when the client's MAX_STREAMS is reached (STREAMS_BLOCKED then goes out) or localStreams of the server's are open.
ownsConnectionId(dcid: u8[]): boolean Whether a datagram whose first packet is sent to dcid belongs to this connection: one of its active connection IDs, or, until the handshake is done, the DCID of the client's first Initial. A closed connection still answers for its IDs; the caller drops it once it is done with it.
ownsConnectionIdAt(buf: u8[], at: i32, length: i32): boolean ownsConnectionId of the ID buf[at .. at + length), read in place, so a carrier routes without a copy.
readDatagram(buf: u8[], at: i32, cap: i32): i32 Copies the oldest DATAGRAM payload the client sent into buf at at, at most cap bytes, and forgets it. Answers its length, QUIC_DATAGRAM_NONE when none is waiting, or QUIC_DATAGRAM_ERR_ROOM, keeping it, when it does not fit.
readStream(): QuicStreamData | null The next run of stream data the client sent, or null when there is none: the all-at-once form of nextStreamEvent and streamRead, which allocates the run it answers. fin marks the last of its stream; a stream the client reset is passed over.
receive(datagram: u8[], now: i64): i64 receiveWindow of a whole datagram.
receiveWindow(buf: u8[], off: i32, len: i32, now: i64): i64 Takes one datagram from the client, buf[off .. off + len), which arrived at now (the caller's monotonic time in milliseconds): every packet in it is opened and its frames acted on, in order. buf is read, never written, so a GRO receive buffer is handed over a datagram at a time. Answers 0, or the error the connection closed with — in which case takeDatagramInto writes the CONNECTION_CLOSE to send. A packet that cannot be used is dropped and counted (see the module header). Once the connection has closed, or its idle timeout has passed by now, every datagram is ignored.
receiveWindowFrom(buf: u8[], off: i32, len: i32, address: u8[], now: i64): i64 receiveWindow of a datagram that came from address, an 18-byte nish:net address: the connection follows the client from one address to another (RFC 9000 §9) — see "Paths" in the module header. An address of any other length is no address, as receiveWindow gives.
release(): void Wipes everything secret the connection and its TlsServer still hold: every level's packet keys, the next generation's read keys, the traffic secrets and expected client Finished, the ephemeral key, the connection-ID seed and the stateless reset tokens (QUIC-2). Call it when the connection is done with (or reset the slot, which does the same first); the connection is closed after it and sends nothing more. Every stream buffer it borrowed goes back to its pool, zeroed: nothing is sent again from a closed connection.
reset(entropy: u8[]): void Makes this slot a new connection for the next client, with entropy its QUIC_CONN_ENTROPY_SIZE fresh random bytes (wiped in the caller's array): every secret of the last connection is wiped first, as release() does, and every buffer is kept and emptied. The limits are the constructor's configuration's. A slot reset this way allocates nothing, and neither does the next handshake (QUIC-3 in docs/security/quic.md).
sendAddress(): u8[] Where this connection's datagrams go now: the 18-byte nish:net address receiveWindowFrom last moved it to, or the first Initial's. A carrier sends every datagram of takeDatagramInto here; it is empty (all zero) for a connection fed by receiveWindow alone.
sendDatagram(buf: u8[], from: i32, length: i32): i32 Queues buf[from .. from + length) as a DATAGRAM (RFC 9221) for the next packet the congestion window allows; it is never sent again if lost. Answers QUIC_DATAGRAM_OK, QUIC_DATAGRAM_ERR_DISABLED when not connected, the client takes none, or the server takes none and so sends none, QUIC_DATAGRAM_ERR_TOO_BIG for a frame past the client's limit or a payload past maxDatagramPayload(), or QUIC_DATAGRAM_ERR_FULL while the ring holds QUIC_CONN_DATAGRAM_QUEUE waiting.
setPathMtuLimit(limit: i32): void Sets pathMtuLimit, for a carrier whose interface MTU changed. A pathMtu above the new limit falls to it, no lower than 1200, and recovery's datagram size with it; the search goes on below it.
sign(signature: u8[]): i64 Hands the signature over signatureInput() to TLS, which writes the rest of the server's flight. Answers 0, or the CRYPTO_ERROR the connection closed with when TLS refused it (a call at the wrong time, or an empty signature: internal_error).
signatureInput(): u8[] | null What CertificateVerify must sign while the handshake waits for it, else null (see TlsServer.signatureInput).
streamRead(id: i64, buf: u8[], at: i32, length: i32): i32 Reads up to length bytes of stream id into buf from at. Answers how many it read, 0 when nothing more has arrived yet, QUIC_STREAM_END once every byte up to the FIN was read, QUIC_STREAM_ERR_RESET once the client reset the stream (its code is the stream's resetCode), or another QUIC_STREAM_ERR_*. Reading is what gives the client more credit.
streamReset(id: i64, code: i64): i32 Abandons stream id's sending side with application error code (RESET_STREAM). Answers QUIC_STREAM_OK or a QUIC_STREAM_ERR_*.
streamStopSending(id: i64, code: i64): i32 Asks the client to stop sending on stream id, with application error code (STOP_SENDING). Answers QUIC_STREAM_OK or a QUIC_STREAM_ERR_*.
streamWrite(id: i64, buf: u8[], from: i32, length: i32, fin: boolean): i32 Writes up to length bytes of buf from from to stream id, and finishes its sending side when fin and every byte fit. Answers how many bytes it took — fewer than length when the stream's buffer is full, in which case nextStreamEvent names it again once acknowledgements free room — or a QUIC_STREAM_ERR_*: not connected, an unknown stream, one only the client sends on, one already finished or reset, or one the client asked to stop (STOP_SENDING, which this side answered with RESET_STREAM).
takeDatagram(now: i64): u8[] | null The next datagram to send, or null when nothing is due: the allocating form of takeDatagramInto, which a test or a recording uses. It is held to QUIC_CONN_DATAGRAM_SIZE bytes, so it never sends a path MTU probe nor fills a larger validated path.
takeDatagramInto(out: u8[], at: i32, now: i64): i32 Writes the next datagram to send into out at at, which needs QUIC_CONN_DATAGRAM_SIZE bytes of room and may take up to datagramSize(), or a path MTU probe's size (see takeDatagramWithin), and answers its length, or 0 when nothing is due (or the room is not there). Call it until it answers 0 after every receive, sign, write and close. It coalesces an Initial, a Handshake and a 1-RTT packet as each has something to carry, pads a datagram with an ack-eliciting Initial to 1200 bytes (RFC 9000 §14.1), and before the client's address is validated sends only while three times what was received allows (§8.1).

After a close it writes the CONNECTION_CLOSE once, then nothing. While the handshake waits for a signature it writes nothing, so the server's flight leaves whole. Lost data goes before new data. While the congestion window is full (RFC 9002 §7), or a space's record of packets in flight is, a space sends only an ACK, unless a probe timeout asked it for a probe.

now is the caller's time in milliseconds: a datagram that elicits an acknowledgement restarts the idle timer when it is the first since the client's last packet (RFC 9000 §10.1), and once the idle timeout has passed nothing goes out. The datagram is built and sealed in place, inside an arena block: nothing it does allocates past the call. This is not paced: a carrier that paces calls nish/net/quic-listener's quicListenerTakeFlight instead.

Its contract changed with path MTU discovery: it writes up to the room in out from at, capped at datagramSize() (never past pathMtuLimit or QUIC_CONN_DATAGRAM_MAX), where it once wrote at most 1200 bytes. A carrier that sizes its buffer from QUIC_CONN_DATAGRAM_SIZE keeps getting datagrams of at most that size and is never probed past it; one that hands over a larger buffer must send all of what comes back.
takeDatagramWithin(out: u8[], at: i32, room: i32, now: i64): i32 takeDatagramInto with the datagram held to room bytes: it is at most room and datagramSize(), whichever is less. When nothing else is due and room has space for it, the datagram is a path MTU probe (see pathMtu), so a carrier that wants probing gives at least QUIC_CONN_DATAGRAM_MAX bytes of room, and one that gives 1200 never probes. A probe never displaces data: a sender that always has something due does not probe until it runs out, and stays at 1200 bytes until then.
takeProbeInto(out: u8[], at: i32, now: i64): i32 Writes the PATH_RESPONSE owed on another path (§8.2.2, §9.1) into out at at, which needs QUIC_CONN_DATAGRAM_SIZE bytes of room, and answers its length, or 0 when none is owed: a 1-RTT packet with that frame alone, padded to 1200 bytes or to three times what came from the path (§8.1), whichever is less. The carrier sends it to probeAddress, before takeDatagramInto's datagrams. It is answered once and never sent again (§13.3).
updateKeys(): boolean Starts a key update from the server (RFC 9001 §6.1): the write keys move to the next generation and the Key Phase bit of every packet after toggles; the client follows when it reads one. Answers whether it did. It does not while it may not: before the handshake is confirmed, while an update is still in flight (the client has not answered the last one, or answered it less than a probe timeout ago, so the next read keys are not ready), and until the client has acknowledged a packet sent with the current keys.
writeStream(id: i64, data: u8[], fin: boolean): i32 Queues all of data on stream id, finishing its sending side when fin: the all-or-nothing form of streamWrite. Answers QUIC_STREAM_OK, or QUIC_STREAM_ERR_*: the connection is not connected, the stream is unknown, its side is already finished (or the client stopped it), or the data would pass the credit the client gave for the stream or the connection, or the room in the stream's buffer.

QuicStreamData

One run of stream data the client sent, in order, as readStream answers it: fin when it ends the stream.

class QuicStreamData
Member
new QuicStreamData(streamId: i64, data: u8[], fin: boolean) A run as readStream hands it out.
data: u8[] The bytes of the run, in stream order.
fin: boolean Whether the run ends the stream: the client sends no bytes after it.
streamId: i64 The RFC 9000 stream ID the bytes arrived on.

Interfaces

QuicServerConfig

What a QUIC server is configured with, the same for every connection. The limits are the transport parameters it advertises (RFC 9000 §18.2); the stream limits and maxStreamData also size each connection's buffers, which are made once and reused.

interface QuicServerConfig
Member
activeConnectionIdLimit: i64 active_connection_id_limit: how many of its connection IDs the client may give the server, 2 to 8.
alpn: string[] The ALPN protocols the server speaks, most preferred first; QUIC requires one to match (RFC 9001 §8.1).
certificateChain: u8[][] DER certificates, leaf first, as TlsServerConfig takes them.
congestion: i32 The congestion controller every connection runs: QUIC_RECOVERY_NEWRENO (RFC 9002) or QUIC_RECOVERY_CUBIC (RFC 9438), from nish/net/quic-recovery; QUIC_RECOVERY_DEFAULT names the one to pass without a reason to pick. Any other value does not fit, and a connection made with it closes at once.
localStreams: i64 How many streams of its own the server may have open at once, 0 to 1024 (openStream).
maxData: i64 initial_max_data: the connection's receive window, 0 to 2^62 − 1, raised as the application reads.
maxDatagramFrameSize: i64 RFC 9221's max_datagram_frame_size: the largest DATAGRAM frame the server takes, 0 (none, and the parameter is not sent) to 1500. The server sends DATAGRAM frames only when it takes them too.
maxIdleTimeout: i64 max_idle_timeout in milliseconds: 0 for none, at most 2^62 − 1. The connection times out after the smaller of this and the client's, and never sooner than QUIC_CONN_IDLE_FLOOR.
maxStreamData: i64 initial_max_stream_data_bidi_remote (and _uni, and _bidi_local when the server opens streams): each stream's receive window and the size of its buffer each way, 1 to 1 MiB. The send buffer holds what the client has not acknowledged, so it bounds a stream's send-side memory and its bytes in flight: behind one lost packet a stream sends nothing new until the resend is acknowledged, and the connection sends an early ACK-eliciting probe meanwhile so a client's NAT rebinding is still seen.
maxStreamsBidi: i64 initial_max_streams_bidi: how many bidirectional streams the client may have open at once, 0 to 1024.
maxStreamsUni: i64 initial_max_streams_uni: how many unidirectional streams the client may have open at once, 0 to 1024.
retry: boolean Whether nish/net/quic-listener answers a client's first Initial with a Retry (§8.1.2).
retryTokenKey: u8[] The key nish/net/quic-listener authenticates its Retry tokens with (§8.1.4), QUIC_CONN_STATIC_KEY_SIZE bytes.
retryTokenLifetime: i64 How long, in milliseconds, a Retry token is accepted after it was issued: 1 to 60000.
signatureScheme: i32 The signature scheme the caller's key signs with, as TlsServerConfig takes it.
statelessResetKey: u8[] The static key every stateless reset token is derived from (quicStatelessResetToken, RFC 9000 §10.3.2), QUIC_CONN_STATIC_KEY_SIZE bytes. Keep it across restarts: a server that lost a connection resets it with the token this key gives for the connection ID the client sends to.
workerCount: i32 How many processes N share the steered UDP port (preforkUdpCount), or 0 outside a prefork group. Valid with workerIndex when 0 <= k < N <= 255, or both unset (-1 and 0); QuicListener and Http3Server panic on any other pair.
workerIndex: i32 This process's index k in a prefork group whose UDP sockets are steered by connection ID (preforkIndex), or -1 outside one. With a valid pair, every connection ID the server issues carries k in byte 0, so the kernel hands the connection's packets to this process whatever address they come from. Copy it from the supervisor's flags, never compute it.

Limits

1,452

QUIC_CONN_DATAGRAM_MAX: i32

The largest datagram path MTU discovery searches for: 1452 bytes, what a 1500-byte Ethernet MTU carries under an IPv6 and a UDP header. The search also stops at pathMtuLimit and at the client's max_udp_payload_size.

8

QUIC_CONN_DATAGRAM_QUEUE: i32

How many DATAGRAM payloads each way a connection holds, when it takes any.

3,000

QUIC_CONN_IDLE_FLOOR: i64

The shortest idle timeout the server keeps: three times the probe timeout of a path with no RTT sample yet (RFC 9002 §6.2.2, about a second), and never under three times the current one either. RFC 9000 §10.1 has an endpoint raise a smaller negotiated value to this, so that several probes can be lost before the connection is given up.

4

QUIC_CONN_LOCAL_CIDS: i32

The most connection IDs the server keeps active for the client to use, its own first one included.

1,500

QUIC_CONN_MAX_DATAGRAM_FRAME: i64

The largest maxDatagramFrameSize a configuration may advertise: 1500 bytes, an Ethernet path's whole UDP payload, past which no DATAGRAM frame reaches a server on a real path. Each of the receive ring's entries is sized to what is advertised, so every frame taken is held.

1,024

QUIC_CONN_MAX_STREAMS: i64

The most streams of one kind a configuration may let the client open at once, or open itself.

67,108,864

QUIC_CONN_MAX_STREAM_BUFFERS: i64

The most bytes of stream buffer a configuration may let each connection hold: every stream slot (maxStreamsBidi + maxStreamsUni + localStreams) may borrow maxStreamData bytes each way, and the pools are sized so all of them can at once, so a configuration past 64 MiB of them is refused rather than allowed to allocate it.

1,048,576

QUIC_CONN_MAX_STREAM_DATA: i64

The largest per-stream credit a configuration may advertise, which is also each stream's buffer each way.

4

QUIC_CONN_PACKET_CONTROL: i32

The most control frames one packet carries — NEW_CONNECTION_ID, RETIRE_CONNECTION_ID and the flow-control, limit and stream-ending frames of nish/net/quic-stream — for the same reason: the three new IDs the server announces once the handshake is done fit one packet, and the rest go over the next few.

4

QUIC_CONN_PACKET_STREAMS: i32

The most STREAM frames one packet carries, which is how many chunks a packet's record keeps for retransmission; the rest of the streams go in the next packet.

128

QUIC_CONN_SKIP_MIN: i64

The fewest Application Data packets between two skipped packet numbers (RFC 9000 §21.4). Large enough that the gaps cost the client almost nothing in ACK ranges.

897

QUIC_CONN_SKIP_SPREAD: i64

How many distances past QUIC_CONN_SKIP_MIN a skip may fall at: the next skipped number is QUIC_CONN_SKIP_MIN plus 0 to 896 past the number after the last skip, so skips fall 129 to 1025 numbers apart.

255

QUIC_WORKER_MAX: i32

The most processes a steered UDP group may have (QuicServerConfig.workerCount): the worker index is one byte of the connection ID, read modulo the count.

Constants

18

QUIC_CONN_ADDRESS_SIZE: i32

A nish:net address: sixteen bytes of IPv6 (IPv4 mapped), then the port, big-endian.

8

QUIC_CONN_CID_LENGTH: i32

The length of every connection ID this server issues; a short header's DCID is read at this length.

8,388,608

QUIC_CONN_CONFIDENTIALITY_LIMIT: i64

AES-GCM's confidentiality limit (RFC 9001 §6.6): how many packets one 1-RTT write key seals. The server starts a key update at three quarters of it, and closes the connection with AEAD_LIMIT_REACHED, sending nothing more under the key, if it reaches it with no update possible. ChaCha20-Poly1305 has no such limit.

16,384

QUIC_CONN_CRYPTO_WINDOW: i32

How far ahead of what it has handed TLS the server buffers CRYPTO data. RFC 9000 §7.5 asks for at least 4096 bytes; a frame past this is CRYPTO_BUFFER_EXCEEDED. One buffer of this size serves every level, since the client's Initial flight is complete before its Handshake one starts.

1,200

QUIC_CONN_DATAGRAM_SIZE: i32

The datagram size every QUIC path carries, and the smallest a client's first Initial may arrive in (RFC 9000 §14.1): 1200 bytes. The server sends no larger datagram until path MTU discovery has validated one (pathMtu), and falls back to it when a validated path stops carrying larger ones. takeDatagramInto needs this much room.

2

QUIC_CONN_EARLY_RESENDS: i32

How many times a connection resends its handshake data before the probe timeout because the client showed it lacks it (RFC 9002 §6.2.3, "for a limited number of times per connection"): a client Initial carrying CRYPTO data the server already read, or an ack-eliciting Handshake packet, while the server's own CRYPTO data at that level is in flight. Each resend is one datagram, so a client cannot make the server answer more than this many packets that way, whatever it sends.

104

QUIC_CONN_ENTROPY_SIZE: i32

How many random bytes the constructor and reset take: 32 for the TLS server random, 32 for the x25519 key, 8 for the first connection ID and 32 for the seed the later IDs and their reset tokens are derived from.

2

QUIC_CONN_HANDSHAKE_PROBES: i32

How many ack-eliciting datagrams a probe timeout sends in the Initial and Handshake spaces (RFC 9002 §6.2.4 allows up to two). The server's first flight is usually one datagram, so with one probe a lossy path loses every copy of it about as often as it loses one datagram per probe timeout; two square that, and stay inside the amplification limit, which a one-datagram flight and two probes fill exactly. The Application Data space sends one.

68,719,476,736

QUIC_CONN_INTEGRITY_LIMIT_CHACHA: i64

ChaCha20-Poly1305's integrity limit (RFC 9001 §6.6), 2^36 packets that fail to authenticate over a connection, across every key, before it closes with AEAD_LIMIT_REACHED. The connection counts failures against the limit of the AEAD it negotiated.

4,503,599,627,370,496

QUIC_CONN_INTEGRITY_LIMIT_GCM: i64

The integrity limits (RFC 9001 §6.6): how many packets may fail to authenticate over a connection's life, across every key, before it closes with AEAD_LIMIT_REACHED. AES-GCM's is 2^52, ChaCha20-Poly1305's 2^36.

64

QUIC_CONN_MAX_ISSUED_CIDS: i64

How many connection IDs a connection issues in all, its first included. The client retiring one asks for a replacement (§5.1.1, a SHOULD), and each costs two HMACs whose temporaries stay in the arena, so this bounds what a client can make the server derive by retiring IDs over and over; past it, a retired ID is not replaced.

64

QUIC_CONN_MAX_KEY_UPDATES: i32

How many key updates a connection takes from its client (RFC 9001 §6). Each costs two key derivations of work, though none of their memory, so the cap bounds what a client can make the server derive (QUIC-4); the next one closes the connection with KEY_UPDATE_ERROR. A client also has to wait a probe timeout between two of them.

8

QUIC_CONN_SKIP_RING: i32

How many skipped packet numbers the server remembers (RFC 9000 §21.4): an ACK of any of the last this many closes the connection as an optimistic acknowledgement. One is skipped every QUIC_CONN_SKIP_MIN to QUIC_CONN_SKIP_MIN + QUIC_CONN_SKIP_SPREAD - 1 packets, so the ring reaches back at least 7 × 129 = 903 packets.

32

QUIC_CONN_STATIC_KEY_SIZE: i32

The length of the configuration's static keys: the stateless reset key and the Retry token key.

-3

QUIC_DATAGRAM_ERR_DISABLED: i32

sendDatagram: the client did not offer to take DATAGRAM frames (RFC 9221 §3), or the connection is not connected.

-5

QUIC_DATAGRAM_ERR_FULL: i32

sendDatagram: the send ring is full; try again once a datagram has gone.

-2

QUIC_DATAGRAM_ERR_ROOM: i32

readDatagram: the next datagram does not fit in the room given; it is kept.

-4

QUIC_DATAGRAM_ERR_TOO_BIG: i32

sendDatagram: the payload is larger than the client takes, or than fits one packet (maxDatagramPayload).

-1

QUIC_DATAGRAM_NONE: i32

readDatagram: nothing has arrived.

0

QUIC_DATAGRAM_OK: i32

sendDatagram queued the payload.

3

QUIC_STATE_CLOSING: i32

This side closed the connection: one CONNECTION_CLOSE goes out, then nothing. error says why.

2

QUIC_STATE_CONNECTED: i32

The handshake is complete and confirmed; stream data flows.

4

QUIC_STATE_DRAINING: i32

The client closed the connection: nothing more goes out (RFC 9000 §10.2.2). error is its code.

1

QUIC_STATE_HANDSHAKE: i32

The handshake is under way.

5

QUIC_STATE_TIMED_OUT: i32

The idle timeout passed (RFC 9000 §10.1): the connection closed silently, its keys wiped, and nothing more goes out. Its state is to be discarded: drop the connection (or reset the slot), so that a later packet to its IDs reaches nish/net/quic-listener, whose stateless reset tells the client.

0

QUIC_STATE_WAIT_INITIAL: i32

Waiting for the client's first Initial packet.