QUIC: do not increase underutilized congestion window.

As per RFC 9002, Section 7.8, congestion window should not be increased
when it's underutilized.
This commit is contained in:
Roman Arutyunyan 2025-01-04 18:03:46 +04:00
parent 6e06f53917
commit cab22e246c
4 changed files with 37 additions and 1 deletions

View File

@ -354,6 +354,14 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
goto done;
}
if (cg->idle) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic congestion ack idle t:%M win:%uz if:%uz",
now, cg->window, cg->in_flight);
goto done;
}
if (cg->window < cg->ssthresh) {
cg->window += f->plen;
@ -377,6 +385,22 @@ done:
}
void
ngx_quic_congestion_idle(ngx_connection_t *c, ngx_uint_t idle)
{
ngx_quic_congestion_t *cg;
ngx_quic_connection_t *qc;
qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic congestion idle:%ui", idle);
cg->idle = idle;
}
static void
ngx_quic_drop_ack_ranges(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
uint64_t pn)

View File

@ -17,6 +17,7 @@ ngx_int_t ngx_quic_handle_ack_frame(ngx_connection_t *c,
void ngx_quic_congestion_ack(ngx_connection_t *c,
ngx_quic_frame_t *frame);
void ngx_quic_congestion_idle(ngx_connection_t *c, ngx_uint_t idle);
void ngx_quic_resend_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx);
void ngx_quic_set_lost_timer(ngx_connection_t *c);
void ngx_quic_pto_handler(ngx_event_t *ev);

View File

@ -169,6 +169,7 @@ typedef struct {
size_t window;
size_t ssthresh;
ngx_msec_t recovery_start;
ngx_uint_t idle; /* unsigned idle:1; */
} ngx_quic_congestion_t;

View File

@ -196,7 +196,7 @@ ngx_quic_create_datagrams(ngx_connection_t *c)
static void
ngx_quic_commit_send(ngx_connection_t *c)
{
ngx_uint_t i;
ngx_uint_t i, idle;
ngx_queue_t *q;
ngx_quic_frame_t *f;
ngx_quic_send_ctx_t *ctx;
@ -206,9 +206,15 @@ ngx_quic_commit_send(ngx_connection_t *c)
qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
idle = 1;
for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) {
ctx = &qc->send_ctx[i];
if (!ngx_queue_empty(&ctx->frames)) {
idle = 0;
}
while (!ngx_queue_empty(&ctx->sending)) {
q = ngx_queue_head(&ctx->sending);
@ -229,6 +235,8 @@ ngx_quic_commit_send(ngx_connection_t *c)
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic congestion send if:%uz", cg->in_flight);
ngx_quic_congestion_idle(c, idle);
}
@ -257,6 +265,8 @@ ngx_quic_revert_send(ngx_connection_t *c, uint64_t pnum[NGX_QUIC_SEND_CTX_LAST])
ctx->pnum = pnum[i];
}
ngx_quic_congestion_idle(c, 1);
}