wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
wired_moqtrun_peer Struct Reference

One connected participant's hub-side state: its WT session, its own control-stream MOQT session machine, and the tracks (chat/audio) it has PUBLISHed. More...

#include <moqtrun.h>

Data Fields

wired_wt_session * wt
 The participant's WebTransport session, valid while in_use: the key every hub entry point finds this peer by.
u64 control_stream_id
 The HUB's own control stream (the one its SETUP went out on), valid only while ctl_opened.
u64 peer_ctl_stream_id
 The CLIENT's incoming control stream (draft-19 3.3), valid while peer_ctl_set: the first of a client uni starting 0x2F00, a client-opened bidi starting with SETUP, or a SETUP written back on the hub's legacy bidi.
u64 rx_sid
 Stream id the current control dispatch is reading (transient, the control-stream twin of req).
wired_moqtrun_ctl_asm * rx
 Reassembly of the stream being read as control bytes: ctl_asm for the hub's own (legacy bidi) stream, peer_ctl_asm for a distinct client control stream – the two can interleave before acceptance.
wired_moqtrun_ctl_asm peer_ctl_asm
 Client-control-stream bytes carried over to the next delivery (the peer_ctl_stream_id twin of ctl_asm).
wired_moqtrun_ctl_asm ctl_asm
 Control-stream bytes carried over to the next delivery.
usz peer_impl_len
 Bytes of peer_impl in use, at most WIRED_MOQTRUN_IMPL_MAX (a longer value is kept truncated).
usz hold_len
 Bytes of hold in use; 0 when no delivery waits for replay.
usz early_n
 Bytes of early in use; 0 when no stream is kept (WIRED_MOQTRUN_ EARLY_BUF's own doc).
u64 early_sid
 The SUBGROUP stream kept in early, valid while early_n is non-zero.
int early_fin
 1 once early_sid's FIN is kept too.
u64 pre_sid
 A fresh stream whose first delivery ended inside its first varint (RFC 9000 2.2): its bytes so far wait in pre (pre_n of them) until the varint is whole, so the stream is classified once (ledger 12-12).
u64 request_id_next
 Next Request ID this hub sends on the session: odd, 1-origin, +2 per request (the hub is the server, draft SS10.2).
u64 peer_rid_next
 One past the largest Request ID the peer has sent (+2, 0 for none): a draft-18 GOAWAY's Request ID (SS10.4).
u64 join_seq
 Registration order (wired_moqt_init-relative, never reused): a higher value is a newer session.
wired_moqtrun_req * req
 The request stream whose message is being handled, 0 for the control stream: replies go to it.
u64 goaway_deadline
 Clock (wired_moqt_tick) past which a session sent GOAWAY (sess.goaway_sent) is closed with GOAWAY_TIMEOUT; (u64)-1 for none.
u64 goaway_flushed_at
 wired_moqt_tick clock at which PUBLISH_DONE went to every subscription; 0 before that happens.
wired_moqtrun_track tracks [WIRED_MOQTRUN_MAX_TRACKS_PER_PEER]
 The tracks this peer PUBLISHed; a slot is live while its in_use is set, and other peers' SUBSCRIBEs are recorded against it.
usz sub_name_lens [WIRED_MOQTRUN_SUB_NAMES]
 Length of each sub_names entry (same index).
usz sub_ns_lens [WIRED_MOQTRUN_SUB_NAMES]
 Length of each sub_ns entry (same index).
wired_moqtrun_sub sub_state [WIRED_MOQTRUN_SUB_NAMES]
 Subscription state of each sub_names entry (same index), restored when a REPUBLISH re-attaches this peer.
usz send_lens [2]
 Bytes queued in each send_bufs slot (same index): the armed slot's round in flight, the pending slot's replies still to flush.
moqtss_sess ssts
 This session's negotiated SSTS algorithms, switching sets and group decisions (reset with the slot).
int in_use
 1 while this slot holds a registered session; 0 marks it free for the next wired_moqt_on_session.
int ver
 Negotiated MOQT draft (MOQVER_*), decided from the WT subprotocol token in wired_moqt_on_session and fixed for the session's life.
int armed_idx
 The send_bufs slot (0 or 1) last handed to stream_send – the ARMED one, never written while its round may be unACKed (send_bufs).
moqsess sess
 The session's control-stream MOQT state machine (SETUP exchange, GOAWAY, control-stream end), stepped by every control message.
u8 legacy
 1 while the control-stream binding is the pre-d17 single bidi: the WT token was empty (a browser cannot negotiate a subprotocol) or unlisted.
u8 raw
 1 for a raw-QUIC session (wired_moqt_on_session_raw), 0 for WebTransport: decides how PATH/AUTHORITY Setup Options are judged (moqraw_setup_verdict) and that GOAWAY carries no new URI.
u8 ctl_opened
 1 once the hub's control stream opened (SETUP went out with it).
u8 peer_ctl_set
 1 once peer_ctl_stream_id names the client's control stream.
u8 setup_recv
 1 once the client's SETUP was accepted (a 2nd SETUP violates).
u8 peer_has_impl
 1 when the client's SETUP carried MOQT_IMPLEMENTATION (peer_impl holds it).
u8 pre_n
 Bytes of stream pre_sid kept in pre; 0 = none pending.
u8 sub_names_n
 entries recorded (<= WIRED_MOQTRUN_SUB_NAMES)
u8 sub_names_at
 ring write index
u8 closing
 1 once the hub asked the transport to close the session: nothing more is sent on it.
u8 wt_drained
 1 once the peer drains its WebTransport session (WT_DRAIN_SESSION): like its GOAWAY, the hub sends it no new request.
u8 pre [9]
 The kept head of stream pre_sid: at most one MOQT varint (9 bytes), pre_n of them valid.
u8 peer_impl [WIRED_MOQTRUN_IMPL_MAX]
 The client SETUP's MOQT_IMPLEMENTATION (10.4), copied – the decoded view dangles after the dispatch.
u8 sub_names [WIRED_MOQTRUN_SUB_NAMES][WIRED_MOQTRUN_MAX_NAME]
 Track Names this peer has successfully SUBSCRIBEd to (ring, newest overwrites oldest past WIRED_MOQTRUN_SUB_NAMES) – kept on the SUBSCRIBER so the intent outlives the publisher.
u8 hold [WIRED_MOQTRUN_HOLD_BUF]
 Pre-establishment deliveries held for replay (WIRED_MOQTRUN_ HOLD_BUF's own doc).
u8 early [WIRED_MOQTRUN_EARLY_BUF]
 The SUBGROUP stream kept before its upstream SUBSCRIBE_OK.
u8 sub_ns [WIRED_MOQTRUN_SUB_NAMES][WIRED_MOQTRUN_MAX_NS]
 Encoded Track Namespace of each sub_names entry (same index).
u8 send_bufs [2][WIRED_MOQTRUN_CTL_SEND_BUF]
 Two send_buf slots, used as an ARMED/PENDING pair rather than a single shared buffer: wired_server_wt_stream_send's payload is a VIEW (srvrun.h – "the caller must keep it alive and unmoved until every byte has been acknowledged"), so once a stream_send call succeeds, the bytes it was given must stay untouched until that round is actually ACKed – success only means "armed", not "delivered".

Detailed Description

One connected participant's hub-side state: its WT session, its own control-stream MOQT session machine, and the tracks (chat/audio) it has PUBLISHed.

Members are grouped by alignment, widest first, so the slot carries no interior padding (each of the hub's peers[] is ~700 KB); related members that land in different groups name each other.

Field Documentation

◆ ctl_opened

u8 wired_moqtrun_peer::ctl_opened

1 once the hub's control stream opened (SETUP went out with it).

A refused open retries on a later tick; nothing else is sent before.

◆ goaway_flushed_at

u64 wired_moqtrun_peer::goaway_flushed_at

wired_moqt_tick clock at which PUBLISH_DONE went to every subscription; 0 before that happens.

The close itself waits until WIRED_MOQTRUN_GOAWAY_GRACE_MS past this, not merely the next tick: a flush and a close on back-to-back ticks give a loaded peer no real time to read the flushed bytes before its session is torn down.

◆ join_seq

u64 wired_moqtrun_peer::join_seq

Registration order (wired_moqt_init-relative, never reused): a higher value is a newer session.

Decides which of two sessions PUBLISHing the same name owns it (moqtrun_supersede_name).

◆ legacy

u8 wired_moqtrun_peer::legacy

1 while the control-stream binding is the pre-d17 single bidi: the WT token was empty (a browser cannot negotiate a subprotocol) or unlisted.

0 = draft-19 3.3 uni pair.

◆ peer_ctl_stream_id

u64 wired_moqtrun_peer::peer_ctl_stream_id

The CLIENT's incoming control stream (draft-19 3.3), valid while peer_ctl_set: the first of a client uni starting 0x2F00, a client-opened bidi starting with SETUP, or a SETUP written back on the hub's legacy bidi.

A second one closes the session.

◆ pre_sid

u64 wired_moqtrun_peer::pre_sid

A fresh stream whose first delivery ended inside its first varint (RFC 9000 2.2): its bytes so far wait in pre (pre_n of them) until the varint is whole, so the stream is classified once (ledger 12-12).

Valid while pre_n is non-zero.

◆ send_bufs

u8 wired_moqtrun_peer::send_bufs[2][WIRED_MOQTRUN_CTL_SEND_BUF]

Two send_buf slots, used as an ARMED/PENDING pair rather than a single shared buffer: wired_server_wt_stream_send's payload is a VIEW (srvrun.h – "the caller must keep it alive and unmoved until every byte has been acknowledged"), so once a stream_send call succeeds, the bytes it was given must stay untouched until that round is actually ACKed – success only means "armed", not "delivered".

A single shared buffer that gets zeroed and reused for the NEXT dispatch's replies the moment stream_send returns 1 corrupts an in-flight, not-yet-ACKed round the instant new bytes are queued into it (confirmed via a real two-track client: PUBLISH's REQUEST_OK stayed armed past its round while SUBSCRIBE replies were queued into the same buffer, splicing bytes together on the wire). send_bufs[armed_idx] holds whatever is currently in flight (or was last successfully armed) and is never written to again; moqtrun_queue_reply always appends to send_bufs[armed_idx ^ 1] (the "pending" slot); a successful flush swaps armed_idx to that slot – the newly-armed bytes – and the old armed slot becomes the next pending target (safe to overwrite: nothing from it was ever handed to stream_send). send_lens holds each slot's length.

◆ sub_names

u8 wired_moqtrun_peer::sub_names[WIRED_MOQTRUN_SUB_NAMES][WIRED_MOQTRUN_MAX_NAME]

Track Names this peer has successfully SUBSCRIBEd to (ring, newest overwrites oldest past WIRED_MOQTRUN_SUB_NAMES) – kept on the SUBSCRIBER so the intent outlives the publisher.

When a publisher drops and REPUBLISHes the same name (a rejoin), its old track died together with every subscription recorded against it, while the still-connected subscribers' clients believe their subscription stands and never re-SUBSCRIBE: the rejoined publisher played into silence until the listener reloaded the page. PUBLISH re-attaches every live holder of the name (moqtrun_reattach_subs).

◆ wt

wired_wt_session* wired_moqtrun_peer::wt

The participant's WebTransport session, valid while in_use: the key every hub entry point finds this peer by.

Owned by the transport.


The documentation for this struct was generated from the following file: