]> git.kaiwu.me - nginx.git/commitdiff
QUIC: use path MTU in congestion window computations.
authorRoman Arutyunyan <arut@nginx.com>
Fri, 3 Jan 2025 07:17:07 +0000 (11:17 +0400)
committerRoman Arutyunyan <arutyunyan.roman@gmail.com>
Tue, 15 Apr 2025 15:01:36 +0000 (19:01 +0400)
As per RFC 9002, Section B.2, max_datagram_size used in congestion window
computations should be based on path MTU.

src/event/quic/ngx_event_quic.c
src/event/quic/ngx_event_quic_ack.c
src/event/quic/ngx_event_quic_migration.c

index 308597e27ba8f23aefd0b6e22296d213f584658c..70d9748bd2f31eee3828b5583d578512590d3bb9 100644 (file)
@@ -308,8 +308,8 @@ ngx_quic_new_connection(ngx_connection_t *c, ngx_quic_conf_t *conf,
     qc->streams.client_max_streams_uni = qc->tp.initial_max_streams_uni;
     qc->streams.client_max_streams_bidi = qc->tp.initial_max_streams_bidi;
 
-    qc->congestion.window = ngx_min(10 * qc->tp.max_udp_payload_size,
-                                    ngx_max(2 * qc->tp.max_udp_payload_size,
+    qc->congestion.window = ngx_min(10 * NGX_QUIC_MIN_INITIAL_SIZE,
+                                    ngx_max(2 * NGX_QUIC_MIN_INITIAL_SIZE,
                                             14720));
     qc->congestion.ssthresh = (size_t) -1;
     qc->congestion.recovery_start = ngx_current_msec;
index 2487ea60d09be22304d0bd3dd102f2b33cf3efd1..4616e70536fe495572b7cfbd4f8f9169b22f1ff8 100644 (file)
@@ -353,7 +353,7 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
                        now, cg->window, cg->ssthresh, cg->in_flight);
 
     } else {
-        cg->window += qc->tp.max_udp_payload_size * f->plen / cg->window;
+        cg->window += (uint64_t) qc->path->mtu * f->plen / cg->window;
 
         ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
                        "quic congestion ack reno t:%M win:%uz if:%uz",
@@ -552,7 +552,7 @@ ngx_quic_persistent_congestion(ngx_connection_t *c)
     now = ngx_current_msec;
 
     cg->recovery_start = now;
-    cg->window = qc->tp.max_udp_payload_size * 2;
+    cg->window = qc->path->mtu * 2;
 
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
                    "quic congestion persistent t:%M win:%uz", now, cg->window);
@@ -698,8 +698,8 @@ ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f)
     cg->recovery_start = now;
     cg->window /= 2;
 
-    if (cg->window < qc->tp.max_udp_payload_size * 2) {
-        cg->window = qc->tp.max_udp_payload_size * 2;
+    if (cg->window < qc->path->mtu * 2) {
+        cg->window = qc->path->mtu * 2;
     }
 
     cg->ssthresh = cg->window;
index 2d1467e1493f97d5950ab92a26e6f1e6334238da..ac22b1327b20b48c5d8798d6371f6399d673a43e 100644 (file)
@@ -182,8 +182,8 @@ valid:
 
         ngx_memzero(&qc->congestion, sizeof(ngx_quic_congestion_t));
 
-        qc->congestion.window = ngx_min(10 * qc->tp.max_udp_payload_size,
-                                   ngx_max(2 * qc->tp.max_udp_payload_size,
+        qc->congestion.window = ngx_min(10 * NGX_QUIC_MIN_INITIAL_SIZE,
+                                   ngx_max(2 * NGX_QUIC_MIN_INITIAL_SIZE,
                                            14720));
         qc->congestion.ssthresh = (size_t) -1;
         qc->congestion.recovery_start = ngx_current_msec;