1#ifndef CWIST_NET_HTTP_HTTP2_FLOW_CONTROL_H
2#define CWIST_NET_HTTP_HTTP2_FLOW_CONTROL_H
8#define CWIST_HTTP2_INITIAL_CONNECTION_WINDOW (1536U * 1024U)
9#define CWIST_HTTP2_INITIAL_STREAM_WINDOW (1024U * 1024U)
10#define CWIST_HTTP2_MAX_WINDOW 0x7fffffffU
51 uint32_t initial_connection_window,
52 uint32_t max_connection_window);
55 uint32_t stream_id, uint32_t initial_stream_window,
56 uint32_t max_stream_window);
59 uint64_t rtt_sample_us);
72 uint8_t *buffer,
size_t buffer_len,
73 size_t *written, uint64_t now_us,
bool force);
78 size_t *written, uint64_t now_us,
bool force);
92 uint32_t bytes, uint64_t now_us);
void cwist_http2_stream_flow_control_add_send_window(cwist_http2_stream_flow_control *flow_control, uint32_t increment)
Credit a stream send window from a WINDOW_UPDATE frame.
int cwist_http2_flow_control_maybe_window_update(cwist_http2_flow_control *flow_control, uint8_t *buffer, size_t buffer_len, size_t *written, uint64_t now_us, bool force)
Emit a connection-level WINDOW_UPDATE when enough credit is due.
void cwist_http2_flow_control_add_send_window(cwist_http2_flow_control *flow_control, uint32_t increment)
Credit the connection send window from a WINDOW_UPDATE frame.
void cwist_http2_stream_flow_control_consume(cwist_http2_stream_flow_control *flow_control, uint32_t bytes)
Record application-consumed bytes for a stream.
bool cwist_http2_stream_flow_control_receive(cwist_http2_stream_flow_control *flow_control, uint32_t bytes)
Account received DATA bytes against a stream receive window.
void cwist_http2_flow_control_update_rtt(cwist_http2_flow_control *flow_control, uint64_t rtt_sample_us)
Feed a new RTT sample into the smoothed estimator and retune.
void cwist_http2_flow_control_consume(cwist_http2_flow_control *flow_control, uint32_t bytes)
Record application-consumed bytes for the connection.
bool cwist_http2_flow_control_reserve_send(cwist_http2_flow_control *connection_flow_control, cwist_http2_stream_flow_control *stream_flow_control, uint32_t bytes, uint64_t now_us)
Reserve send credit for an outgoing write.
bool cwist_http2_flow_control_receive(cwist_http2_flow_control *flow_control, uint32_t bytes)
Account received DATA bytes against the connection receive window.
size_t cwist_http2_flow_control_pacing_allowance(cwist_http2_flow_control *connection_flow_control, const cwist_http2_stream_flow_control *stream_flow_control, size_t requested, uint64_t now_us)
Compute how much of a send request may proceed right now.
int cwist_http2_stream_flow_control_maybe_window_update(cwist_http2_flow_control *connection_flow_control, cwist_http2_stream_flow_control *stream_flow_control, uint8_t *buffer, size_t buffer_len, size_t *written, uint64_t now_us, bool force)
Emit a stream-level WINDOW_UPDATE when enough credit is due.
void cwist_http2_stream_flow_control_init(cwist_http2_stream_flow_control *flow_control, uint32_t stream_id, uint32_t initial_stream_window, uint32_t max_stream_window)
Initialize per-stream flow-control state.
void cwist_http2_flow_control_init(cwist_http2_flow_control *flow_control, uint32_t initial_connection_window, uint32_t max_connection_window)
Initialize connection-level flow-control state.
cwist_http2_network_quality
@ CWIST_HTTP2_NETWORK_QUALITY_NORMAL
@ CWIST_HTTP2_NETWORK_QUALITY_HIGH_RTT
@ CWIST_HTTP2_NETWORK_QUALITY_UNSTABLE
uint64_t pacing_rate_bytes_per_sec
uint64_t last_window_update_us
cwist_http2_network_quality network_quality
uint64_t last_window_update_us