Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic_ack.c @ 8717:e06283038ec8 quic
QUIC: clear SSL_OP_ENABLE_MIDDLEBOX_COMPAT on SSL context switch.
The SSL_OP_ENABLE_MIDDLEBOX_COMPAT option is provided by QuicTLS and enabled
by default in the newly created SSL contexts. SSL_set_quic_method() is used
to clear it, which is required for SSL handshake to work on QUIC connections.
Switching context in the ngx_http_ssl_servername() SNI callback overrides SSL
options from the new SSL context. This results in the option set again.
Fix is to explicitly clear it when switching to another SSL context.
Initially reported here (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2021-November/063989.html
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 07 Dec 2021 15:49:51 +0300 |
parents | da112e7f8de6 |
children | b42a041d23a2 |
rev | line source |
---|---|
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 #include <ngx_event_quic_connection.h> |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 #define NGX_QUIC_MAX_ACK_GAP 2 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
15 /* RFC 9002, 6.1.1. Packet Threshold: kPacketThreshold */ |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 #define NGX_QUIC_PKT_THR 3 /* packets */ |
8647
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
17 /* RFC 9002, 6.1.2. Time Threshold: kGranularity */ |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
18 #define NGX_QUIC_TIME_GRANULARITY 1 /* ms */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
19 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
20 /* RFC 9002, 7.6.1. Duration: kPersistentCongestionThreshold */ |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
21 #define NGX_QUIC_PERSISTENT_CONGESTION_THR 3 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
22 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
23 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
24 /* send time of ACK'ed packets */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
25 typedef struct { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
26 ngx_msec_t max_pn; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
27 ngx_msec_t oldest; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
28 ngx_msec_t newest; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
29 } ngx_quic_ack_stat_t; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
30 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
31 |
8647
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
32 static ngx_inline ngx_msec_t ngx_quic_lost_threshold(ngx_quic_connection_t *qc); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 static void ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 enum ssl_encryption_level_t level, ngx_msec_t send_time); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 static ngx_int_t ngx_quic_handle_ack_frame_range(ngx_connection_t *c, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 ngx_quic_send_ctx_t *ctx, uint64_t min, uint64_t max, |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
37 ngx_quic_ack_stat_t *st); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 static void ngx_quic_drop_ack_ranges(ngx_connection_t *c, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 ngx_quic_send_ctx_t *ctx, uint64_t pn); |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
40 static ngx_int_t ngx_quic_detect_lost(ngx_connection_t *c, |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
41 ngx_quic_ack_stat_t *st); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
42 static ngx_msec_t ngx_quic_pcg_duration(ngx_connection_t *c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
43 static void ngx_quic_persistent_congestion(ngx_connection_t *c); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
44 static void ngx_quic_congestion_lost(ngx_connection_t *c, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
45 ngx_quic_frame_t *frame); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 static void ngx_quic_lost_handler(ngx_event_t *ev); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
47 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
48 |
8647
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
49 /* RFC 9002, 6.1.2. Time Threshold: kTimeThreshold, kGranularity */ |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
50 static ngx_inline ngx_msec_t |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
51 ngx_quic_lost_threshold(ngx_quic_connection_t *qc) |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
52 { |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
53 ngx_msec_t thr; |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
54 |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
55 thr = ngx_max(qc->latest_rtt, qc->avg_rtt); |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
56 thr += thr >> 3; |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
57 |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
58 return ngx_max(thr, NGX_QUIC_TIME_GRANULARITY); |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
59 } |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
60 |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
61 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
62 ngx_int_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
63 ngx_quic_handle_ack_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 ngx_quic_frame_t *f) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
65 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 ssize_t n; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
67 u_char *pos, *end; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
68 uint64_t min, max, gap, range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
69 ngx_uint_t i; |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
70 ngx_quic_ack_stat_t send_time; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 ngx_quic_ack_frame_t *ack; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
73 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
74 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
77 ctx = ngx_quic_get_send_ctx(qc, pkt->level); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
78 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
79 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
80 "quic ngx_quic_handle_ack_frame level:%d", pkt->level); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
81 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
82 ack = &f->u.ack; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
83 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
84 /* |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
85 * RFC 9000, 19.3.1. ACK Ranges |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
86 * |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
87 * If any computed packet number is negative, an endpoint MUST |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
88 * generate a connection error of type FRAME_ENCODING_ERROR. |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
89 */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
90 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
91 if (ack->first_range > ack->largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
92 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
93 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
94 "quic invalid first range in ack frame"); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
95 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
96 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
97 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
98 min = ack->largest - ack->first_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
99 max = ack->largest; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
100 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
101 send_time.oldest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
102 send_time.newest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
103 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
104 if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
105 != NGX_OK) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
106 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
107 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
108 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
109 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
110 /* RFC 9000, 13.2.4. Limiting Ranges by Tracking ACK Frames */ |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
111 if (ctx->largest_ack < max || ctx->largest_ack == NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
112 ctx->largest_ack = max; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
113 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
114 "quic updated largest received ack:%uL", max); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
115 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
116 /* |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
117 * RFC 9002, 5.1. Generating RTT Samples |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
118 * |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
119 * An endpoint generates an RTT sample on receiving an |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
120 * ACK frame that meets the following two conditions: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
121 * |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
122 * - the largest acknowledged packet number is newly acknowledged |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
123 * - at least one of the newly acknowledged packets was ack-eliciting. |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
124 */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
125 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
126 if (send_time.max_pn != NGX_TIMER_INFINITE) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
127 ngx_quic_rtt_sample(c, ack, pkt->level, send_time.max_pn); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
128 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
129 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
130 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
131 if (f->data) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
132 pos = f->data->buf->pos; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
133 end = f->data->buf->last; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
134 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
135 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
136 pos = NULL; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
137 end = NULL; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
138 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
139 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
140 for (i = 0; i < ack->range_count; i++) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
141 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
142 n = ngx_quic_parse_ack_range(pkt->log, pos, end, &gap, &range); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
143 if (n == NGX_ERROR) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
144 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
145 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
146 pos += n; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
147 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
148 if (gap + 2 > min) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
149 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
150 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
151 "quic invalid range:%ui in ack frame", i); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
152 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
153 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
154 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
155 max = min - gap - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
156 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
157 if (range > max) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
158 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
159 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
160 "quic invalid range:%ui in ack frame", i); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
161 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
162 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
163 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
164 min = max - range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
165 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
166 if (ngx_quic_handle_ack_frame_range(c, ctx, min, max, &send_time) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
167 != NGX_OK) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
168 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
169 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
170 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
171 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
172 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
173 return ngx_quic_detect_lost(c, &send_time); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
174 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
175 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
176 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
177 static void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
178 ngx_quic_rtt_sample(ngx_connection_t *c, ngx_quic_ack_frame_t *ack, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
179 enum ssl_encryption_level_t level, ngx_msec_t send_time) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
180 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
181 ngx_msec_t latest_rtt, ack_delay, adjusted_rtt, rttvar_sample; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
182 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
183 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
184 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
185 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
186 latest_rtt = ngx_current_msec - send_time; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
187 qc->latest_rtt = latest_rtt; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
188 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
189 if (qc->min_rtt == NGX_TIMER_INFINITE) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
190 qc->min_rtt = latest_rtt; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
191 qc->avg_rtt = latest_rtt; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
192 qc->rttvar = latest_rtt / 2; |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
193 qc->first_rtt = ngx_current_msec; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
194 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
195 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
196 qc->min_rtt = ngx_min(qc->min_rtt, latest_rtt); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
197 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
198 ack_delay = ack->delay * (1 << qc->ctp.ack_delay_exponent) / 1000; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
199 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
200 if (c->ssl->handshaked) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
201 ack_delay = ngx_min(ack_delay, qc->ctp.max_ack_delay); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
202 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
203 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
204 adjusted_rtt = latest_rtt; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
205 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
206 if (qc->min_rtt + ack_delay < latest_rtt) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
207 adjusted_rtt -= ack_delay; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
208 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
209 |
8647
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
210 qc->avg_rtt += (adjusted_rtt >> 3) - (qc->avg_rtt >> 3); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
211 rttvar_sample = ngx_abs((ngx_msec_int_t) (qc->avg_rtt - adjusted_rtt)); |
8647
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8646
diff
changeset
|
212 qc->rttvar += (rttvar_sample >> 2) - (qc->rttvar >> 2); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
213 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
214 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
215 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
216 "quic rtt sample latest:%M min:%M avg:%M var:%M", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
217 latest_rtt, qc->min_rtt, qc->avg_rtt, qc->rttvar); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
218 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
219 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
220 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
221 static ngx_int_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
222 ngx_quic_handle_ack_frame_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
223 uint64_t min, uint64_t max, ngx_quic_ack_stat_t *st) |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
224 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
225 ngx_uint_t found; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
226 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
227 ngx_quic_frame_t *f; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
228 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
229 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
230 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
231 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
232 st->max_pn = NGX_TIMER_INFINITE; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
233 found = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
234 |
8646
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
235 q = ngx_queue_head(&ctx->sent); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
236 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
237 while (q != ngx_queue_sentinel(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
238 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
239 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
8646
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
240 q = ngx_queue_next(q); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
241 |
8646
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
242 if (f->pnum > max) { |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
243 break; |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
244 } |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
245 |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8548
diff
changeset
|
246 if (f->pnum >= min) { |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 ngx_quic_congestion_ack(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
248 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
249 switch (f->type) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
250 case NGX_QUIC_FT_ACK: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
251 case NGX_QUIC_FT_ACK_ECN: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
252 ngx_quic_drop_ack_ranges(c, ctx, f->u.ack.largest); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
253 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
254 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
255 case NGX_QUIC_FT_STREAM: |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
256 ngx_quic_handle_stream_ack(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
257 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
258 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
259 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
260 if (f->pnum == max) { |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
261 st->max_pn = f->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
262 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
263 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
264 /* save earliest and latest send times of frames ack'ed */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
265 if (st->oldest == NGX_TIMER_INFINITE || f->last < st->oldest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
266 st->oldest = f->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
267 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
268 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
269 if (st->newest == NGX_TIMER_INFINITE || f->last > st->newest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
270 st->newest = f->last; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
271 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
272 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
273 ngx_queue_remove(&f->queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
274 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
275 found = 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
276 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
277 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
278 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
279 if (!found) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
280 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
281 if (max < ctx->pnum) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
282 /* duplicate ACK or ACK for non-ack-eliciting frame */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
283 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
284 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
285 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
286 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
287 "quic ACK for the packet not sent"); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
288 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
289 qc->error = NGX_QUIC_ERR_PROTOCOL_VIOLATION; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
290 qc->error_ftype = NGX_QUIC_FT_ACK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
291 qc->error_reason = "unknown packet number"; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
292 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
293 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
294 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
295 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
296 if (!qc->push.timer_set) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
297 ngx_post_event(&qc->push, &ngx_posted_events); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
298 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
299 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
300 qc->pto_count = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
301 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
302 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
303 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
304 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
305 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
306 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
307 ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
308 { |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
309 ngx_uint_t blocked; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
310 ngx_msec_t timer; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
311 ngx_quic_congestion_t *cg; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
312 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
313 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
314 if (f->plen == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
315 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
316 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
317 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
318 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
319 cg = &qc->congestion; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
320 |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
321 blocked = (cg->in_flight >= cg->window) ? 1 : 0; |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
322 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
323 cg->in_flight -= f->plen; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
324 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
325 timer = f->last - cg->recovery_start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
326 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
327 if ((ngx_msec_int_t) timer <= 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
328 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
329 "quic congestion ack recovery win:%uz ss:%z if:%uz", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
330 cg->window, cg->ssthresh, cg->in_flight); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
331 |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
332 goto done; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
333 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
334 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
335 if (cg->window < cg->ssthresh) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
336 cg->window += f->plen; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
337 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
338 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
339 "quic congestion slow start win:%uz ss:%z if:%uz", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
340 cg->window, cg->ssthresh, cg->in_flight); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
341 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
342 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 cg->window += qc->tp.max_udp_payload_size * f->plen / cg->window; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
344 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
345 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 "quic congestion avoidance win:%uz ss:%z if:%uz", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
347 cg->window, cg->ssthresh, cg->in_flight); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
348 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
349 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
350 /* prevent recovery_start from wrapping */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
351 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
352 timer = cg->recovery_start - ngx_current_msec + qc->tp.max_idle_timeout * 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
353 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
354 if ((ngx_msec_int_t) timer < 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
355 cg->recovery_start = ngx_current_msec - qc->tp.max_idle_timeout * 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
356 } |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
357 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
358 done: |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
359 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
360 if (blocked && cg->in_flight < cg->window) { |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
361 ngx_post_event(&qc->push, &ngx_posted_events); |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
362 } |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
363 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
364 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
365 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
366 static void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
367 ngx_quic_drop_ack_ranges(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
368 uint64_t pn) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
369 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 uint64_t base; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 ngx_uint_t i, smallest, largest; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 ngx_quic_ack_range_t *r; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
373 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
374 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
375 "quic ngx_quic_drop_ack_ranges pn:%uL largest:%uL" |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
376 " fr:%uL nranges:%ui", pn, ctx->largest_range, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
377 ctx->first_range, ctx->nranges); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
378 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
379 base = ctx->largest_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
380 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
381 if (base == NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
382 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
383 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
384 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
385 if (ctx->pending_ack != NGX_QUIC_UNSET_PN && pn >= ctx->pending_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
386 ctx->pending_ack = NGX_QUIC_UNSET_PN; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
387 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
388 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
389 largest = base; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
390 smallest = largest - ctx->first_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
391 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
392 if (pn >= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
393 ctx->largest_range = NGX_QUIC_UNSET_PN; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
394 ctx->first_range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
395 ctx->nranges = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
396 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
397 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
398 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
399 if (pn >= smallest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
400 ctx->first_range = largest - pn - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
401 ctx->nranges = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
402 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
403 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
404 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
405 for (i = 0; i < ctx->nranges; i++) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
406 r = &ctx->ranges[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
407 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
408 largest = smallest - r->gap - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
409 smallest = largest - r->range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
410 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
411 if (pn >= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
412 ctx->nranges = i; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
413 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
414 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
415 if (pn >= smallest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
416 r->range = largest - pn - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
417 ctx->nranges = i + 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
418 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
419 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
420 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
421 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
422 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
423 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
424 static ngx_int_t |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
425 ngx_quic_detect_lost(ngx_connection_t *c, ngx_quic_ack_stat_t *st) |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
426 { |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
427 ngx_uint_t i, nlost; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
428 ngx_msec_t now, wait, thr, oldest, newest; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
429 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
430 ngx_quic_frame_t *start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
431 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
432 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
433 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
434 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
435 now = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
436 thr = ngx_quic_lost_threshold(qc); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
437 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
438 /* send time of lost packets across all send contexts */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
439 oldest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
440 newest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
441 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
442 nlost = 0; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
443 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
444 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
445 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
446 ctx = &qc->send_ctx[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
447 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
448 if (ctx->largest_ack == NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
449 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
450 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
451 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
452 while (!ngx_queue_empty(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
453 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
454 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
455 start = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
456 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
457 if (start->pnum > ctx->largest_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
458 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
459 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
460 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
461 wait = start->last + thr - now; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
462 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
463 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
464 "quic detect_lost pnum:%uL thr:%M wait:%i level:%d", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
465 start->pnum, thr, (ngx_int_t) wait, start->level); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
466 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
467 if ((ngx_msec_int_t) wait > 0 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
468 && ctx->largest_ack - start->pnum < NGX_QUIC_PKT_THR) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
469 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
470 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
471 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
472 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
473 if (start->last > qc->first_rtt) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
474 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
475 if (oldest == NGX_TIMER_INFINITE || start->last < oldest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
476 oldest = start->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
477 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
478 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
479 if (newest == NGX_TIMER_INFINITE || start->last > newest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
480 newest = start->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
481 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
482 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
483 nlost++; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
484 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
485 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
486 ngx_quic_resend_frames(c, ctx); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
487 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
488 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
489 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
490 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
491 /* RFC 9002, 7.6.2. Establishing Persistent Congestion */ |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
492 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
493 /* |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
494 * Once acknowledged, packets are no longer tracked. Thus no send time |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
495 * information is available for such packets. This limits persistent |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
496 * congestion algorithm to packets mentioned within ACK ranges of the |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
497 * latest ACK frame. |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
498 */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
499 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
500 if (st && nlost >= 2 && (st->newest < oldest || st->oldest > newest)) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
501 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
502 if (newest - oldest > ngx_quic_pcg_duration(c)) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
503 ngx_quic_persistent_congestion(c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
504 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
505 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
506 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
507 ngx_quic_set_lost_timer(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
508 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
509 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
510 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
511 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
512 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
513 static ngx_msec_t |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
514 ngx_quic_pcg_duration(ngx_connection_t *c) |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
515 { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
516 ngx_msec_t duration; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
517 ngx_quic_connection_t *qc; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
518 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
519 qc = ngx_quic_get_connection(c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
520 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
521 duration = qc->avg_rtt; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
522 duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
523 duration += qc->ctp.max_ack_delay; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
524 duration *= NGX_QUIC_PERSISTENT_CONGESTION_THR; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
525 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
526 return duration; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
527 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
528 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
529 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
530 static void |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
531 ngx_quic_persistent_congestion(ngx_connection_t *c) |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
532 { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
533 ngx_quic_congestion_t *cg; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
534 ngx_quic_connection_t *qc; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
535 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
536 qc = ngx_quic_get_connection(c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
537 cg = &qc->congestion; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
538 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
539 cg->recovery_start = ngx_current_msec; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
540 cg->window = qc->tp.max_udp_payload_size * 2; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
541 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
542 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
543 "quic persistent congestion win:%uz", cg->window); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
544 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
545 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
546 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
547 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
548 ngx_quic_resend_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
549 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
550 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
551 ngx_quic_frame_t *f, *start; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
552 ngx_quic_stream_t *qs; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
553 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
554 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
555 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
556 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
557 start = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
558 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
559 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
560 "quic resend packet pnum:%uL", start->pnum); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
561 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
562 ngx_quic_congestion_lost(c, start); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
563 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
564 do { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
565 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
566 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
567 if (f->pnum != start->pnum) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
568 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
569 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
570 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
571 q = ngx_queue_next(q); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
572 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
573 ngx_queue_remove(&f->queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
574 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
575 switch (f->type) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
576 case NGX_QUIC_FT_ACK: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
577 case NGX_QUIC_FT_ACK_ECN: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
578 if (ctx->level == ssl_encryption_application) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
579 /* force generation of most recent acknowledgment */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
580 ctx->send_ack = NGX_QUIC_MAX_ACK_GAP; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
581 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
582 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
583 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
584 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
585 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
586 case NGX_QUIC_FT_PING: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
587 case NGX_QUIC_FT_PATH_RESPONSE: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
588 case NGX_QUIC_FT_CONNECTION_CLOSE: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
589 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
590 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
591 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
592 case NGX_QUIC_FT_MAX_DATA: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
593 f->u.max_data.max_data = qc->streams.recv_max_data; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
594 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
595 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
596 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
597 case NGX_QUIC_FT_MAX_STREAMS: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
598 case NGX_QUIC_FT_MAX_STREAMS2: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
599 f->u.max_streams.limit = f->u.max_streams.bidi |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
600 ? qc->streams.client_max_streams_bidi |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
601 : qc->streams.client_max_streams_uni; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
602 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
603 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
604 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
605 case NGX_QUIC_FT_MAX_STREAM_DATA: |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
606 qs = ngx_quic_find_stream(&qc->streams.tree, |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
607 f->u.max_stream_data.id); |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
608 if (qs == NULL) { |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
609 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
610 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
611 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
612 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8423
diff
changeset
|
613 f->u.max_stream_data.limit = qs->recv_max_data; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
614 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
615 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
616 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
617 case NGX_QUIC_FT_STREAM: |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
618 qs = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
619 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
620 if (qs && qs->connection->write->error) { |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
621 /* RESET_STREAM was sent */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
622 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
623 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
624 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
625 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
626 /* fall through */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
627 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
628 default: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
629 ngx_queue_insert_tail(&ctx->frames, &f->queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
630 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
631 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
632 } while (q != ngx_queue_sentinel(&ctx->sent)); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
633 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
634 if (qc->closing) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
635 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
636 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
637 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
638 ngx_post_event(&qc->push, &ngx_posted_events); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
639 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
640 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
641 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
642 static void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
643 ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
644 { |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
645 ngx_uint_t blocked; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
646 ngx_msec_t timer; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
647 ngx_quic_congestion_t *cg; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
648 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
649 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
650 if (f->plen == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
651 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
653 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
654 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
655 cg = &qc->congestion; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
656 |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
657 blocked = (cg->in_flight >= cg->window) ? 1 : 0; |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
658 |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
659 cg->in_flight -= f->plen; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
660 f->plen = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
661 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
662 timer = f->last - cg->recovery_start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
663 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
664 if ((ngx_msec_int_t) timer <= 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
665 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
666 "quic congestion lost recovery win:%uz ss:%z if:%uz", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
667 cg->window, cg->ssthresh, cg->in_flight); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
668 |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
669 goto done; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
670 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
671 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
672 cg->recovery_start = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
673 cg->window /= 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
674 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
675 if (cg->window < qc->tp.max_udp_payload_size * 2) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
676 cg->window = qc->tp.max_udp_payload_size * 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
677 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
678 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
679 cg->ssthresh = cg->window; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
680 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
681 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
682 "quic congestion lost win:%uz ss:%z if:%uz", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
683 cg->window, cg->ssthresh, cg->in_flight); |
8548
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
684 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
685 done: |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
686 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
687 if (blocked && cg->in_flight < cg->window) { |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
688 ngx_post_event(&qc->push, &ngx_posted_events); |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
689 } |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
690 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
691 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
692 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
693 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
694 ngx_quic_set_lost_timer(ngx_connection_t *c) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
695 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
696 ngx_uint_t i; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
697 ngx_msec_t now; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
698 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
699 ngx_msec_int_t lost, pto, w; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
700 ngx_quic_frame_t *f; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
701 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
702 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
703 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
704 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
705 now = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
706 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
707 lost = -1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
708 pto = -1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
709 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
710 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
711 ctx = &qc->send_ctx[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
712 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
713 if (ngx_queue_empty(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
714 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
715 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
716 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
717 if (ctx->largest_ack != NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
718 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
719 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
720 w = (ngx_msec_int_t) (f->last + ngx_quic_lost_threshold(qc) - now); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
721 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
722 if (f->pnum <= ctx->largest_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
723 if (w < 0 || ctx->largest_ack - f->pnum >= NGX_QUIC_PKT_THR) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
724 w = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
725 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
726 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
727 if (lost == -1 || w < lost) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
728 lost = w; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
729 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
730 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
731 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
732 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
733 q = ngx_queue_last(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
734 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
735 w = (ngx_msec_int_t) (f->last + ngx_quic_pto(c, ctx) - now); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
736 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
737 if (w < 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
738 w = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
739 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
740 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
741 if (pto == -1 || w < pto) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
742 pto = w; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
743 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
744 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
745 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
746 if (qc->pto.timer_set) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
747 ngx_del_timer(&qc->pto); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
748 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
749 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
750 if (lost != -1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
751 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
752 "quic lost timer lost:%M", lost); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
753 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
754 qc->pto.handler = ngx_quic_lost_handler; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
755 ngx_add_timer(&qc->pto, lost); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
756 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
758 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
759 if (pto != -1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
760 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
761 "quic lost timer pto:%M", pto); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
762 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
763 qc->pto.handler = ngx_quic_pto_handler; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
764 ngx_add_timer(&qc->pto, pto); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
765 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
766 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
767 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
768 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic lost timer unset"); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
769 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
770 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
771 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
772 ngx_msec_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
773 ngx_quic_pto(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
774 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
775 ngx_msec_t duration; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
776 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
777 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
778 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
779 |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8493
diff
changeset
|
780 /* RFC 9002, Appendix A.8. Setting the Loss Detection Timer */ |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
781 duration = qc->avg_rtt; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
782 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
783 duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
784 duration <<= qc->pto_count; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
785 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
786 if (qc->congestion.in_flight == 0) { /* no in-flight packets */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
787 return duration; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
788 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
789 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
790 if (ctx->level == ssl_encryption_application && c->ssl->handshaked) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
791 duration += qc->ctp.max_ack_delay << qc->pto_count; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
792 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
793 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 return duration; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
795 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
796 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
797 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
798 static |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
799 void ngx_quic_lost_handler(ngx_event_t *ev) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
800 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 ngx_connection_t *c; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
802 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic lost timer"); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
804 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
805 c = ev->data; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
806 |
8493
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8439
diff
changeset
|
807 if (ngx_quic_detect_lost(c, NULL) != NGX_OK) { |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
808 ngx_quic_close_connection(c, NGX_ERROR); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
809 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
810 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
811 ngx_quic_connstate_dbg(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
812 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
813 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
814 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
815 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
816 ngx_quic_pto_handler(ngx_event_t *ev) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
817 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
818 ngx_uint_t i; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
819 ngx_msec_t now; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
820 ngx_queue_t *q, *next; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
821 ngx_connection_t *c; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
822 ngx_quic_frame_t *f; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
823 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
824 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
825 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
826 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "quic pto timer"); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
827 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
828 c = ev->data; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
829 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
830 now = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
831 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
832 for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
833 |
8423
4117aa7fa38e
QUIC: connection migration.
Vladimir Homutov <vl@nginx.com>
parents:
8421
diff
changeset
|
834 ctx = &qc->send_ctx[i]; |
8411
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
835 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
836 if (ngx_queue_empty(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
837 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
838 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
839 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
840 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
841 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
842 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
843 if (f->pnum <= ctx->largest_ack |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
844 && ctx->largest_ack != NGX_QUIC_UNSET_PN) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
845 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
846 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
847 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
848 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
849 if ((ngx_msec_int_t) (f->last + ngx_quic_pto(c, ctx) - now) > 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
850 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
851 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
852 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
853 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
854 "quic pto %s pto_count:%ui", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
855 ngx_quic_level_name(ctx->level), qc->pto_count); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
856 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
857 for (q = ngx_queue_head(&ctx->frames); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
858 q != ngx_queue_sentinel(&ctx->frames); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
859 /* void */) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
860 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
861 next = ngx_queue_next(q); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
862 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
863 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
864 if (f->type == NGX_QUIC_FT_PING) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
865 ngx_queue_remove(q); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
866 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
867 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
868 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
869 q = next; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
870 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
871 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
872 for (q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
873 q != ngx_queue_sentinel(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
874 /* void */) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
875 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
876 next = ngx_queue_next(q); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
877 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
878 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
879 if (f->type == NGX_QUIC_FT_PING) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
880 ngx_quic_congestion_lost(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
881 ngx_queue_remove(q); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
882 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
883 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
884 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
885 q = next; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
886 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
887 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
888 /* enforce 2 udp datagrams */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
889 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
890 f = ngx_quic_alloc_frame(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
891 if (f == NULL) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
892 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
893 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
894 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
895 f->level = ctx->level; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
896 f->type = NGX_QUIC_FT_PING; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
897 f->flush = 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
898 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
899 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
900 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
901 f = ngx_quic_alloc_frame(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
902 if (f == NULL) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
903 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
904 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
905 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
906 f->level = ctx->level; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
907 f->type = NGX_QUIC_FT_PING; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
908 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
909 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
910 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
911 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
912 qc->pto_count++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
913 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
914 ngx_quic_connstate_dbg(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
915 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
916 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
917 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
918 ngx_int_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
919 ngx_quic_ack_packet(ngx_connection_t *c, ngx_quic_header_t *pkt) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
920 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
921 uint64_t base, largest, smallest, gs, ge, gap, range, pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
922 uint64_t prev_pending; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
923 ngx_uint_t i, nr; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
924 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
925 ngx_quic_ack_range_t *r; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
926 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
927 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
928 c->log->action = "preparing ack"; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
929 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
930 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
931 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
932 ctx = ngx_quic_get_send_ctx(qc, pkt->level); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
933 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
934 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
935 "quic ngx_quic_ack_packet pn:%uL largest %L fr:%uL" |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
936 " nranges:%ui", pkt->pn, (int64_t) ctx->largest_range, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
937 ctx->first_range, ctx->nranges); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
938 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
939 prev_pending = ctx->pending_ack; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
940 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
941 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
942 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
943 ngx_post_event(&qc->push, &ngx_posted_events); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
944 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
945 if (ctx->send_ack == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
946 ctx->ack_delay_start = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
947 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
948 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
949 ctx->send_ack++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
950 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
951 if (ctx->pending_ack == NGX_QUIC_UNSET_PN |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
952 || ctx->pending_ack < pkt->pn) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
953 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
954 ctx->pending_ack = pkt->pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
955 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
956 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
957 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
958 base = ctx->largest_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
959 pn = pkt->pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
960 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
961 if (base == NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
962 ctx->largest_range = pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
963 ctx->largest_received = pkt->received; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
964 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
965 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
966 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
967 if (base == pn) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
968 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
969 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
970 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
971 largest = base; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
972 smallest = largest - ctx->first_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
973 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
974 if (pn > base) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
975 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
976 if (pn - base == 1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
977 ctx->first_range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
978 ctx->largest_range = pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
979 ctx->largest_received = pkt->received; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
980 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
981 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
982 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
983 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
984 /* new gap in front of current largest */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
985 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
986 /* no place for new range, send current range as is */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
987 if (ctx->nranges == NGX_QUIC_MAX_RANGES) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
988 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
989 if (prev_pending != NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
990 if (ngx_quic_send_ack(c, ctx) != NGX_OK) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
991 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
992 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
993 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
994 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
995 if (prev_pending == ctx->pending_ack || !pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
996 ctx->pending_ack = NGX_QUIC_UNSET_PN; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
997 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
998 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
999 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1000 gap = pn - base - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1001 range = ctx->first_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1002 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1003 ctx->first_range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1004 ctx->largest_range = pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1005 ctx->largest_received = pkt->received; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1006 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1007 /* packet is out of order, force send */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1008 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1009 ctx->send_ack = NGX_QUIC_MAX_ACK_GAP; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1010 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1011 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1012 i = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1013 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1014 goto insert; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1015 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1016 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1017 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1018 /* pn < base, perform lookup in existing ranges */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1019 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1020 /* packet is out of order */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1021 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1022 ctx->send_ack = NGX_QUIC_MAX_ACK_GAP; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1023 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1024 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1025 if (pn >= smallest && pn <= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1026 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1027 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1028 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1029 #if (NGX_SUPPRESS_WARN) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1030 r = NULL; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1031 #endif |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1032 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1033 for (i = 0; i < ctx->nranges; i++) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1034 r = &ctx->ranges[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1035 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1036 ge = smallest - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1037 gs = ge - r->gap; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1038 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1039 if (pn >= gs && pn <= ge) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1040 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1041 if (gs == ge) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1042 /* gap size is exactly one packet, now filled */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1043 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1044 /* data moves to previous range, current is removed */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1045 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1046 if (i == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1047 ctx->first_range += r->range + 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1048 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1049 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1050 ctx->ranges[i - 1].range += r->range + 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1051 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1052 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1053 nr = ctx->nranges - i - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1054 if (nr) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1055 ngx_memmove(&ctx->ranges[i], &ctx->ranges[i + 1], |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1056 sizeof(ngx_quic_ack_range_t) * nr); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1057 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1058 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1059 ctx->nranges--; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1060 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1061 } else if (pn == gs) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1062 /* current gap shrinks from tail (current range grows) */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1063 r->gap--; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1064 r->range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1065 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1066 } else if (pn == ge) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1067 /* current gap shrinks from head (previous range grows) */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1068 r->gap--; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1069 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1070 if (i == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1071 ctx->first_range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1072 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1073 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1074 ctx->ranges[i - 1].range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1075 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1076 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1077 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1078 /* current gap is split into two parts */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1079 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1080 gap = ge - pn - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1081 range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1082 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1083 if (ctx->nranges == NGX_QUIC_MAX_RANGES) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1084 if (prev_pending != NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1085 if (ngx_quic_send_ack(c, ctx) != NGX_OK) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1086 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1087 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1088 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1089 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1090 if (prev_pending == ctx->pending_ack || !pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1091 ctx->pending_ack = NGX_QUIC_UNSET_PN; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1092 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1093 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1094 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1095 r->gap = pn - gs - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1096 goto insert; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1097 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1098 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1099 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1100 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1101 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1102 largest = smallest - r->gap - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1103 smallest = largest - r->range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1104 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1105 if (pn >= smallest && pn <= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1106 /* this packet number is already known */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1107 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1108 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1109 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1110 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1111 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1112 if (pn == smallest - 1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1113 /* extend first or last range */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1114 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1115 if (i == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1116 ctx->first_range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1117 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1118 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1119 r->range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1120 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1121 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1122 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1123 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1124 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1125 /* nothing found, add new range at the tail */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1126 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1127 if (ctx->nranges == NGX_QUIC_MAX_RANGES) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1128 /* packet is too old to keep it */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1129 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1130 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1131 return ngx_quic_send_ack_range(c, ctx, pn, pn); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1132 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1133 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1134 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1135 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1136 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1137 gap = smallest - 2 - pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1138 range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1139 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1140 insert: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1141 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1142 if (ctx->nranges < NGX_QUIC_MAX_RANGES) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1143 ctx->nranges++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1144 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1145 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1146 ngx_memmove(&ctx->ranges[i + 1], &ctx->ranges[i], |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1147 sizeof(ngx_quic_ack_range_t) * (ctx->nranges - i - 1)); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1148 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1149 ctx->ranges[i].gap = gap; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1150 ctx->ranges[i].range = range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1151 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1152 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1153 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1154 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1155 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1156 ngx_int_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1157 ngx_quic_generate_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1158 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1159 ngx_msec_t delay; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1160 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1161 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1162 if (!ctx->send_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1163 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1164 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1165 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1166 if (ctx->level == ssl_encryption_application) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1167 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1168 delay = ngx_current_msec - ctx->ack_delay_start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1169 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1170 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1171 if (ctx->send_ack < NGX_QUIC_MAX_ACK_GAP |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1172 && delay < qc->tp.max_ack_delay) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1173 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1174 if (!qc->push.timer_set && !qc->closing) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1175 ngx_add_timer(&qc->push, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1176 qc->tp.max_ack_delay - delay); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1177 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1178 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1179 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1180 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1181 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1182 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1183 if (ngx_quic_send_ack(c, ctx) != NGX_OK) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1184 return NGX_ERROR; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1185 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1186 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1187 ctx->send_ack = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1188 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1189 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1190 } |