[nginx] QUIC: path aware in-flight bytes accounting.

Sergey Kandaurov pluknet at nginx.com
Tue Dec 12 16:25:54 UTC 2023


details:   https://hg.nginx.org/nginx/rev/6c8595b77e66
branches:  
changeset: 9196:6c8595b77e66
user:      Sergey Kandaurov <pluknet at nginx.com>
date:      Tue Dec 12 20:21:12 2023 +0400
description:
QUIC: path aware in-flight bytes accounting.

On-packet acknowledgement is made path aware, as per RFC 9000, Section 9.4:
    Packets sent on the old path MUST NOT contribute to congestion control
    or RTT estimation for the new path.

To make this possible in a single congestion control context, the first packet
to be sent after the new path has been validated, which includes resetting the
congestion controller and RTT estimator, is now remembered in the connection.
Packets sent previously, such as on the old path, are not taken into account.

Note that although the packet number is saved per-connection, the added checks
affect application level packets only.  For non-application level packets,
which are only processed prior to the handshake is complete, the remembered
packet number remains set to zero.

diffstat:

 src/event/quic/ngx_event_quic_ack.c        |  8 ++++++++
 src/event/quic/ngx_event_quic_connection.h |  2 ++
 src/event/quic/ngx_event_quic_migration.c  |  6 ++++++
 3 files changed, 16 insertions(+), 0 deletions(-)

diffs (60 lines):

diff -r ff452f283aa9 -r 6c8595b77e66 src/event/quic/ngx_event_quic_ack.c
--- a/src/event/quic/ngx_event_quic_ack.c	Tue Dec 12 20:20:51 2023 +0400
+++ b/src/event/quic/ngx_event_quic_ack.c	Tue Dec 12 20:21:12 2023 +0400
@@ -325,6 +325,10 @@ ngx_quic_congestion_ack(ngx_connection_t
     qc = ngx_quic_get_connection(c);
     cg = &qc->congestion;
 
+    if (f->pnum < qc->rst_pnum) {
+        return;
+    }
+
     blocked = (cg->in_flight >= cg->window) ? 1 : 0;
 
     cg->in_flight -= f->plen;
@@ -667,6 +671,10 @@ ngx_quic_congestion_lost(ngx_connection_
     qc = ngx_quic_get_connection(c);
     cg = &qc->congestion;
 
+    if (f->pnum < qc->rst_pnum) {
+        return;
+    }
+
     blocked = (cg->in_flight >= cg->window) ? 1 : 0;
 
     cg->in_flight -= f->plen;
diff -r ff452f283aa9 -r 6c8595b77e66 src/event/quic/ngx_event_quic_connection.h
--- a/src/event/quic/ngx_event_quic_connection.h	Tue Dec 12 20:20:51 2023 +0400
+++ b/src/event/quic/ngx_event_quic_connection.h	Tue Dec 12 20:21:12 2023 +0400
@@ -266,6 +266,8 @@ struct ngx_quic_connection_s {
     ngx_quic_streams_t                streams;
     ngx_quic_congestion_t             congestion;
 
+    uint64_t                          rst_pnum;    /* first on validated path */
+
     off_t                             received;
 
     ngx_uint_t                        error;
diff -r ff452f283aa9 -r 6c8595b77e66 src/event/quic/ngx_event_quic_migration.c
--- a/src/event/quic/ngx_event_quic_migration.c	Tue Dec 12 20:20:51 2023 +0400
+++ b/src/event/quic/ngx_event_quic_migration.c	Tue Dec 12 20:21:12 2023 +0400
@@ -110,6 +110,7 @@ ngx_quic_handle_path_response_frame(ngx_
     ngx_uint_t              rst;
     ngx_queue_t            *q;
     ngx_quic_path_t        *path, *prev;
+    ngx_quic_send_ctx_t    *ctx;
     ngx_quic_connection_t  *qc;
 
     qc = ngx_quic_get_connection(c);
@@ -174,6 +175,11 @@ valid:
     }
 
     if (rst) {
+        /* prevent old path packets contribution to congestion control */
+
+        ctx = ngx_quic_get_send_ctx(qc, ssl_encryption_application);
+        qc->rst_pnum = ctx->pnum;
+
         ngx_memzero(&qc->congestion, sizeof(ngx_quic_congestion_t));
 
         qc->congestion.window = ngx_min(10 * qc->tp.max_udp_payload_size,


More information about the nginx-devel mailing list