wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
moqssts.h
Go to the documentation of this file.
1#ifndef MOQSSTS_H
2#define MOQSSTS_H
3
5
21
24#define MOQSSTS_MAX_MEMBERS 4
25
30#define MOQSSTS_MAX_SETS 32
31
34#define MOQSSTS_ALG_DEFAULT 0x0ULL
35
38#define MOQSSTS_ALG_BACKPRESSURE 0xff01ULL
39
41#define MOQSSTS_NONE (-1)
42
44#define MOQSSTS_UNLIMITED_KBPS (~0ULL / 4)
45
47#define MOQSSTS_DEPTH_TARGET 1ULL
48
50#define MOQSSTS_DOWNSHIFT_DEPTH 2ULL
51
53#define MOQSSTS_UPSHIFT_GOP_STREAK 5ULL
54
56#define MOQSSTS_COOLDOWN_HIGH_STREAK 2ULL
57
59#define MOQSSTS_EV_HELD 0
60
62#define MOQSSTS_EV_COOLDOWN_EXIT 1
63
65#define MOQSSTS_EV_UPSHIFT 2
66
68#define MOQSSTS_EV_DOWNSHIFT 3
69
77
96
111
113typedef struct {
119
122
125
128u64 moqssts_budget_kbps(u64 est_kbps, u64 cap_kbps);
129
132u64 moqssts_active_depth(const moqssts_set* sets, usz n, const u64* open);
133
137 u64 budget_kbps, const moqssts_set* sets, usz n, int* out);
138
141
144
147
155 moqssts_bp* st,
156 const moqssts_set* sets,
157 usz n,
158 const u64* open,
159 u64 timeouts,
160 int* out);
161
162#endif
int moqssts_alg_supported(u64 id)
1 for an algorithm id this module implements (registry.rs), else 0.
moqssts_obs moqssts_obs_make(u64 depth, u64 timeouts)
Observation from open-stream depth and timeouts since the last decision.
int moqssts_bp_decide(moqssts_bp *st, const moqssts_set *sets, usz n, const u64 *open, u64 timeouts, int *out)
Algorithm 0xff01: observe, clamp the tier to the longest ladder - 1, and write out[i] = min(tier,...
int moqssts_set_active(const moqssts_set *s)
1 when activate > 0 and the set has at least activate members.
int moqssts_bp_observe(moqssts_bp *st, moqssts_obs ob)
Advance the tier state machine by one group; returns MOQSSTS_EV_*.
u64 moqssts_active_depth(const moqssts_set *sets, usz n, const u64 *open)
Largest open[i] over the ACTIVE sets[i] (open is parallel to sets): the deepest backed-up track,...
void moqssts_default_decide(u64 budget_kbps, const moqssts_set *sets, usz n, int *out)
Algorithm 0: stateless weighted strict-rank split of budget_kbps (clamped to MOQSSTS_UNLIMITED_KBPS).
void moqssts_bp_init(moqssts_bp *st)
Fresh backpressure state: lowest tier, no streaks, not in cooldown.
u64 moqssts_budget_kbps(u64 est_kbps, u64 cap_kbps)
The stricter of estimate and cap; 0 means "unknown" / "uncapped", and neither signal yields ~0 (uncon...
#define MOQSSTS_MAX_MEMBERS
Members per switching set.
Definition moqssts.h:24
Per-connection backpressure state; reset it with moqssts_bp_init.
Definition moqssts.h:99
u64 cooldown_ref
Depth of the previous cooldown group (valid while in_cooldown).
Definition moqssts.h:107
u64 tier
Index into the ascending ladder; 0 is the lowest quality.
Definition moqssts.h:101
u64 high_streak
Consecutive cooldown groups deeper than their predecessor.
Definition moqssts.h:109
u64 clear_streak
Consecutive groups seen at or below MOQSSTS_DEPTH_TARGET.
Definition moqssts.h:103
int in_cooldown
Nonzero during the settle-down period after a downshift.
Definition moqssts.h:105
One encoding of a switching set.
Definition moqssts.h:71
u64 threshold_kbps
Throughput the encoding needs, in kbps.
Definition moqssts.h:75
u64 track_id
The caller's track handle; the algorithms never read it.
Definition moqssts.h:73
One group's congestion evidence.
Definition moqssts.h:113
u64 depth
Open streams on active sets plus streams reset for timeout.
Definition moqssts.h:115
int timed_out
Nonzero when at least one stream timed out since the last group.
Definition moqssts.h:117
One switching set.
Definition moqssts.h:79
u64 weight
Share inside the rank tier, 1..10.
Definition moqssts.h:86
u64 activate
Members needed before the set is active; 0 keeps it inactive.
Definition moqssts.h:88
moqssts_member m[MOQSSTS_MAX_MEMBERS]
Members sorted ascending by threshold_kbps: m[0] is the lowest tier.
Definition moqssts.h:94
u64 algorithm_id
Algorithm the set is assigned to; ignored by the decide functions.
Definition moqssts.h:83
u8 rank
Strict priority: 0 is served first.
Definition moqssts.h:90
u64 set_id
Switching set id, as assigned by the publisher.
Definition moqssts.h:81
usz n_members
Members in use in m.
Definition moqssts.h:92
Linux direct syscalls.
u64 usz
unsigned size (size_t equivalent)
Definition types.h:20
unsigned char u8
unsigned 8-bit integer / byte
Definition types.h:18
unsigned long u64
unsigned 64-bit integer
Definition types.h:13