Mercurial > hg > nginx
annotate src/event/quic/ngx_event_quic_ack.c @ 9143:48691bab4474
QUIC: fixed probe-congestion deadlock.
When probe timeout expired while congestion window was exhausted, probe PINGs
could not be sent. As a result, lost packets could not be declared lost and
congestion window could not be freed for new packets. This deadlock
continued until connection idle timeout expiration.
Now PINGs are sent separately from the frame queue without congestion control,
as specified by RFC 9002, Section 7:
An endpoint MUST NOT send a packet if it would cause bytes_in_flight
(see Appendix B.2) to be larger than the congestion window, unless the
packet is sent on a PTO timer expiration (see Section 6.2) or when entering
recovery (see Section 7.3.2).
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 14 Aug 2023 08:28:30 +0400 |
parents | 7e8ee4b7cbf4 |
children | 58afcd72446f |
rev | line source |
---|---|
8751
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 |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
15 /* RFC 9002, 6.1.1. Packet Threshold: kPacketThreshold */ |
8751
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 */ |
8885
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
17 /* RFC 9002, 6.1.2. Time Threshold: kGranularity */ |
8751
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 |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
20 /* RFC 9002, 7.6.1. Duration: kPersistentCongestionThreshold */ |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
21 #define NGX_QUIC_PERSISTENT_CONGESTION_THR 3 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
22 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
23 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
24 /* send time of ACK'ed packets */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
25 typedef struct { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
26 ngx_msec_t max_pn; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
27 ngx_msec_t oldest; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
28 ngx_msec_t newest; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
29 } ngx_quic_ack_stat_t; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
30 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
31 |
8885
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
32 static ngx_inline ngx_msec_t ngx_quic_lost_threshold(ngx_quic_connection_t *qc); |
8751
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, |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
37 ngx_quic_ack_stat_t *st); |
8751
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); |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
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:
8779
diff
changeset
|
41 ngx_quic_ack_stat_t *st); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
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:
8779
diff
changeset
|
43 static void ngx_quic_persistent_congestion(ngx_connection_t *c); |
8751
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 |
8885
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
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:
8884
diff
changeset
|
50 static ngx_inline ngx_msec_t |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
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:
8884
diff
changeset
|
52 { |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
53 ngx_msec_t thr; |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
54 |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
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:
8884
diff
changeset
|
56 thr += thr >> 3; |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
57 |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
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:
8884
diff
changeset
|
59 } |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
60 |
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
61 |
8751
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; |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
70 ngx_quic_ack_stat_t send_time; |
8751
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 /* |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
85 * RFC 9000, 19.3.1. ACK Ranges |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
86 * |
8751
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 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
101 send_time.oldest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
102 send_time.newest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
103 |
8751
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 |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
110 /* RFC 9000, 13.2.4. Limiting Ranges by Tracking ACK Frames */ |
8751
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 /* |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
117 * RFC 9002, 5.1. Generating RTT Samples |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
118 * |
8751
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 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
126 if (send_time.max_pn != NGX_TIMER_INFINITE) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
127 ngx_quic_rtt_sample(c, ack, pkt->level, send_time.max_pn); |
8751
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 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
173 return ngx_quic_detect_lost(c, &send_time); |
8751
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; |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
193 qc->first_rtt = ngx_current_msec; |
8751
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 |
9044
2b3a8d5795c9
QUIC: fixed C4334 MSVC warning about 32 to 64 bits conversion.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9015
diff
changeset
|
198 ack_delay = (ack->delay << qc->ctp.ack_delay_exponent) / 1000; |
8751
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
210 rttvar_sample = ngx_abs((ngx_msec_int_t) (qc->avg_rtt - adjusted_rtt)); |
8885
da112e7f8de6
QUIC: switched to integer arithmetic in rtt calculations.
Vladimir Homutov <vl@nginx.com>
parents:
8884
diff
changeset
|
211 qc->rttvar += (rttvar_sample >> 2) - (qc->rttvar >> 2); |
9122
a32905d6fc10
QUIC: fixed rttvar on subsequent RTT samples (ticket #2505).
Sergey Kandaurov <pluknet@nginx.com>
parents:
9112
diff
changeset
|
212 qc->avg_rtt += (adjusted_rtt >> 3) - (qc->avg_rtt >> 3); |
8751
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, |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
223 uint64_t min, uint64_t max, ngx_quic_ack_stat_t *st) |
8751
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 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
232 st->max_pn = NGX_TIMER_INFINITE; |
8751
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 |
8884
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
235 q = ngx_queue_head(&ctx->sent); |
8751
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); |
8884
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
240 q = ngx_queue_next(q); |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
241 |
8884
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
242 if (f->pnum > max) { |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
243 break; |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
244 } |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
245 |
1798acc01970
QUIC: optimized ack range processing.
Vladimir Homutov <vl@nginx.com>
parents:
8823
diff
changeset
|
246 if (f->pnum >= min) { |
8751
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 |
8820
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8797
diff
changeset
|
255 case NGX_QUIC_FT_STREAM: |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9044
diff
changeset
|
256 case NGX_QUIC_FT_RESET_STREAM: |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
257 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
|
258 break; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
261 if (f->pnum == max) { |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
262 st->max_pn = f->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
263 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
264 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
265 /* save earliest and latest send times of frames ack'ed */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
266 if (st->oldest == NGX_TIMER_INFINITE || f->last < st->oldest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
267 st->oldest = f->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
268 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
269 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
270 if (st->newest == NGX_TIMER_INFINITE || f->last > st->newest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
271 st->newest = f->last; |
8751
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
274 ngx_queue_remove(&f->queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
275 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
276 found = 1; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
280 if (!found) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
281 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
282 if (max < ctx->pnum) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
283 /* 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
|
284 return NGX_OK; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
287 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
|
288 "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
|
289 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
290 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
|
291 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
|
292 qc->error_reason = "unknown packet number"; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
293 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
294 return NGX_ERROR; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
297 if (!qc->push.timer_set) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
298 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
|
299 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
300 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
301 qc->pto_count = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
302 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
303 return NGX_OK; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
307 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
308 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
|
309 { |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
310 ngx_uint_t blocked; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
311 ngx_msec_t timer; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
312 ngx_quic_congestion_t *cg; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
313 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
314 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
315 if (f->plen == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
316 return; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
319 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
320 cg = &qc->congestion; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
321 |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
322 blocked = (cg->in_flight >= cg->window) ? 1 : 0; |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
323 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
324 cg->in_flight -= f->plen; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
325 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
326 timer = f->last - cg->recovery_start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
327 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
328 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
|
329 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
|
330 "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
|
331 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
|
332 |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
333 goto done; |
8751
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
336 if (cg->window < cg->ssthresh) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
337 cg->window += f->plen; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
338 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
339 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
|
340 "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
|
341 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
|
342 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
344 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
|
345 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 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
|
347 "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
|
348 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
|
349 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
350 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
351 /* prevent recovery_start from wrapping */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
352 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
353 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
|
354 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
355 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
|
356 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
|
357 } |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
358 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
359 done: |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
360 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
361 if (blocked && cg->in_flight < cg->window) { |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
362 ngx_post_event(&qc->push, &ngx_posted_events); |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
363 } |
8751
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
367 static void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
368 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
|
369 uint64_t pn) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 uint64_t base; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 ngx_uint_t i, smallest, largest; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
373 ngx_quic_ack_range_t *r; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
374 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
375 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
|
376 "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
|
377 " 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
|
378 ctx->first_range, ctx->nranges); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
379 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
380 base = ctx->largest_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
381 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
382 if (base == NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
383 return; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
386 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
|
387 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
|
388 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
389 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
390 largest = base; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
391 smallest = largest - ctx->first_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
392 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
393 if (pn >= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
394 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
|
395 ctx->first_range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
396 ctx->nranges = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
397 return; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
400 if (pn >= smallest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
401 ctx->first_range = largest - pn - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
402 ctx->nranges = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
403 return; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
406 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
|
407 r = &ctx->ranges[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
408 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
409 largest = smallest - r->gap - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
410 smallest = largest - r->range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
411 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
412 if (pn >= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
413 ctx->nranges = i; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
414 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
415 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
416 if (pn >= smallest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
417 r->range = largest - pn - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
418 ctx->nranges = i + 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
419 return; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
425 static ngx_int_t |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
426 ngx_quic_detect_lost(ngx_connection_t *c, ngx_quic_ack_stat_t *st) |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
427 { |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
428 ngx_uint_t i, nlost; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
429 ngx_msec_t now, wait, thr, oldest, newest; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
430 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
431 ngx_quic_frame_t *start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
432 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
433 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
434 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
435 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
436 now = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
437 thr = ngx_quic_lost_threshold(qc); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
438 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
439 /* send time of lost packets across all send contexts */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
440 oldest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
441 newest = NGX_TIMER_INFINITE; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
442 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
443 nlost = 0; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
444 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
445 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
|
446 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
447 ctx = &qc->send_ctx[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
448 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
449 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
|
450 continue; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
453 while (!ngx_queue_empty(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
454 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
455 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
456 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
|
457 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
458 if (start->pnum > ctx->largest_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
459 break; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
462 wait = start->last + thr - now; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
463 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
464 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
|
465 "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
|
466 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
|
467 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
468 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
|
469 && 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
|
470 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
471 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
472 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
473 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
474 if (start->last > qc->first_rtt) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
475 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
476 if (oldest == NGX_TIMER_INFINITE || start->last < oldest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
477 oldest = start->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
478 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
479 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
480 if (newest == NGX_TIMER_INFINITE || start->last > newest) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
481 newest = start->last; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
482 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
483 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
484 nlost++; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
485 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
486 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
487 ngx_quic_resend_frames(c, ctx); |
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 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
490 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
491 |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
492 /* RFC 9002, 7.6.2. Establishing Persistent Congestion */ |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
493 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
494 /* |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
495 * Once acknowledged, packets are no longer tracked. Thus no send time |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
496 * information is available for such packets. This limits persistent |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
497 * congestion algorithm to packets mentioned within ACK ranges of the |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
498 * latest ACK frame. |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
499 */ |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
500 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
501 if (st && nlost >= 2 && (st->newest < oldest || st->oldest > newest)) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
502 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
503 if (newest - oldest > ngx_quic_pcg_duration(c)) { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
504 ngx_quic_persistent_congestion(c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
505 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
506 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
507 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
508 ngx_quic_set_lost_timer(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
509 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
510 return NGX_OK; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
513 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
514 static ngx_msec_t |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
515 ngx_quic_pcg_duration(ngx_connection_t *c) |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
516 { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
517 ngx_msec_t duration; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
518 ngx_quic_connection_t *qc; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
519 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
520 qc = ngx_quic_get_connection(c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
521 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
522 duration = qc->avg_rtt; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
523 duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
524 duration += qc->ctp.max_ack_delay; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
525 duration *= NGX_QUIC_PERSISTENT_CONGESTION_THR; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
526 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
527 return duration; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
528 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
529 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
530 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
531 static void |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
532 ngx_quic_persistent_congestion(ngx_connection_t *c) |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
533 { |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
534 ngx_quic_congestion_t *cg; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
535 ngx_quic_connection_t *qc; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
536 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
537 qc = ngx_quic_get_connection(c); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
538 cg = &qc->congestion; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
539 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
540 cg->recovery_start = ngx_current_msec; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
541 cg->window = qc->tp.max_udp_payload_size * 2; |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
542 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
543 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
544 "quic persistent congestion win:%uz", cg->window); |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
545 } |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
546 |
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
547 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
548 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
549 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
|
550 { |
9141
5d1e7c74aadf
QUIC: avoid accessing freed frame.
Roman Arutyunyan <arut@nginx.com>
parents:
9138
diff
changeset
|
551 uint64_t pnum; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
552 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
553 ngx_quic_frame_t *f, *start; |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
554 ngx_quic_stream_t *qs; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
555 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
556 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
557 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
558 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
559 start = ngx_queue_data(q, ngx_quic_frame_t, queue); |
9141
5d1e7c74aadf
QUIC: avoid accessing freed frame.
Roman Arutyunyan <arut@nginx.com>
parents:
9138
diff
changeset
|
560 pnum = start->pnum; |
8751
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_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
|
563 "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
|
564 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
565 ngx_quic_congestion_lost(c, start); |
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 do { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
568 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
|
569 |
9141
5d1e7c74aadf
QUIC: avoid accessing freed frame.
Roman Arutyunyan <arut@nginx.com>
parents:
9138
diff
changeset
|
570 if (f->pnum != pnum) { |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
571 break; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
574 q = ngx_queue_next(q); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
575 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
576 ngx_queue_remove(&f->queue); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
577 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
578 switch (f->type) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
579 case NGX_QUIC_FT_ACK: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
580 case NGX_QUIC_FT_ACK_ECN: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
581 if (ctx->level == ssl_encryption_application) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
582 /* force generation of most recent acknowledgment */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
583 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
|
584 } |
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 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
587 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
588 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
589 case NGX_QUIC_FT_PING: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
590 case NGX_QUIC_FT_PATH_RESPONSE: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
591 case NGX_QUIC_FT_CONNECTION_CLOSE: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
592 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
593 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
594 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
595 case NGX_QUIC_FT_MAX_DATA: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
596 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
|
597 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
598 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
599 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
600 case NGX_QUIC_FT_MAX_STREAMS: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
601 case NGX_QUIC_FT_MAX_STREAMS2: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
602 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
|
603 ? qc->streams.client_max_streams_bidi |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
604 : qc->streams.client_max_streams_uni; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
605 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
606 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
607 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
608 case NGX_QUIC_FT_MAX_STREAM_DATA: |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
609 qs = ngx_quic_find_stream(&qc->streams.tree, |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
610 f->u.max_stream_data.id); |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
611 if (qs == NULL) { |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
612 ngx_quic_free_frame(c, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
613 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
614 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
615 |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
616 f->u.max_stream_data.limit = qs->recv_max_data; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
617 ngx_quic_queue_frame(qc, f); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
618 break; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
619 |
8820
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8797
diff
changeset
|
620 case NGX_QUIC_FT_STREAM: |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
621 qs = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
622 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
623 if (qs) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
624 if (qs->send_state == NGX_QUIC_STREAM_SEND_RESET_SENT |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
625 || qs->send_state == NGX_QUIC_STREAM_SEND_RESET_RECVD) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
626 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
627 ngx_quic_free_frame(c, f); |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
628 break; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8885
diff
changeset
|
629 } |
8751
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 /* fall through */ |
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 default: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
635 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
|
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 } 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
|
639 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
640 if (qc->closing) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
641 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
642 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
643 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
644 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
|
645 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
646 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
647 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
648 static void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
649 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
|
650 { |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
651 ngx_uint_t blocked; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 ngx_msec_t timer; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
653 ngx_quic_congestion_t *cg; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
654 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
655 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
656 if (f->plen == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
657 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
658 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
659 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
660 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
661 cg = &qc->congestion; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
662 |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
663 blocked = (cg->in_flight >= cg->window) ? 1 : 0; |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
664 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
665 cg->in_flight -= f->plen; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
666 f->plen = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
667 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
668 timer = f->last - cg->recovery_start; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
669 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
670 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
|
671 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
|
672 "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
|
673 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
|
674 |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
675 goto done; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
676 } |
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 cg->recovery_start = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
679 cg->window /= 2; |
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 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
|
682 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
|
683 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
684 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
685 cg->ssthresh = cg->window; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
686 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
687 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
|
688 "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
|
689 cg->window, cg->ssthresh, cg->in_flight); |
8823
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
690 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
691 done: |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
692 |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
693 if (blocked && cg->in_flight < cg->window) { |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
694 ngx_post_event(&qc->push, &ngx_posted_events); |
f3331deed357
QUIC: limit in-flight bytes by congestion window.
Roman Arutyunyan <arut@nginx.com>
parents:
8820
diff
changeset
|
695 } |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
696 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
697 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
698 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
699 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
700 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
|
701 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
702 ngx_uint_t i; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
703 ngx_msec_t now; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
704 ngx_queue_t *q; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
705 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
|
706 ngx_quic_frame_t *f; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
707 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
708 ngx_quic_connection_t *qc; |
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 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
711 now = ngx_current_msec; |
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 lost = -1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
714 pto = -1; |
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 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
|
717 ctx = &qc->send_ctx[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
718 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
719 if (ngx_queue_empty(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
720 continue; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
723 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
|
724 q = ngx_queue_head(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
725 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
|
726 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
|
727 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
728 if (f->pnum <= ctx->largest_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
729 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
|
730 w = 0; |
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 if (lost == -1 || w < lost) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
734 lost = w; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
735 } |
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 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
738 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
739 q = ngx_queue_last(&ctx->sent); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
740 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
9096
c6db94ec3841
QUIC: separated path validation retransmit backoff.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9095
diff
changeset
|
741 w = (ngx_msec_int_t) (f->last + (ngx_quic_pto(c, ctx) << qc->pto_count) |
c6db94ec3841
QUIC: separated path validation retransmit backoff.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9095
diff
changeset
|
742 - now); |
8751
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 if (w < 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
745 w = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
746 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
747 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
748 if (pto == -1 || w < pto) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
749 pto = w; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
750 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
751 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
752 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
753 if (qc->pto.timer_set) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
754 ngx_del_timer(&qc->pto); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
755 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
756 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 if (lost != -1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
758 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
|
759 "quic lost timer lost:%M", lost); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
760 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
761 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
|
762 ngx_add_timer(&qc->pto, lost); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
763 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
764 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
765 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
766 if (pto != -1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
767 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
|
768 "quic lost timer pto:%M", pto); |
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 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
|
771 ngx_add_timer(&qc->pto, pto); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
772 return; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
773 } |
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_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
|
776 } |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
779 ngx_msec_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
780 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
|
781 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
782 ngx_msec_t duration; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
783 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
784 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
785 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
786 |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8792
diff
changeset
|
787 /* RFC 9002, Appendix A.8. Setting the Loss Detection Timer */ |
9095
52cddd44ec11
QUIC: removed check for in-flight packets in computing PTO.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9052
diff
changeset
|
788 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
789 duration = qc->avg_rtt; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
790 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
|
791 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
792 if (ctx->level == ssl_encryption_application && c->ssl->handshaked) { |
9096
c6db94ec3841
QUIC: separated path validation retransmit backoff.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9095
diff
changeset
|
793 duration += qc->ctp.max_ack_delay; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 } |
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 return duration; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
799 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
800 static |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 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
|
802 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 ngx_connection_t *c; |
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 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
|
806 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
807 c = ev->data; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
808 |
8792
004172345bdc
QUIC: persistent congestion calculation.
Vladimir Homutov <vl@nginx.com>
parents:
8779
diff
changeset
|
809 if (ngx_quic_detect_lost(c, NULL) != NGX_OK) { |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
810 ngx_quic_close_connection(c, NGX_ERROR); |
9112
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9096
diff
changeset
|
811 return; |
8751
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 ngx_quic_connstate_dbg(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
815 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
816 |
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 void |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
819 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
|
820 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
821 ngx_uint_t i; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
822 ngx_msec_t now; |
9143
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
823 ngx_queue_t *q; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
824 ngx_connection_t *c; |
9143
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
825 ngx_quic_frame_t *f, frame; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
826 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
827 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
828 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
829 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
|
830 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
831 c = ev->data; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
832 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
833 now = ngx_current_msec; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
834 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
835 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
|
836 |
9015
a2fbae359828
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8990
diff
changeset
|
837 ctx = &qc->send_ctx[i]; |
8751
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 if (ngx_queue_empty(&ctx->sent)) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
840 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
841 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
842 |
9142
7e8ee4b7cbf4
QUIC: fixed PTO expiration condition.
Roman Arutyunyan <arut@nginx.com>
parents:
9141
diff
changeset
|
843 q = ngx_queue_last(&ctx->sent); |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
844 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
|
845 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
846 if (f->pnum <= ctx->largest_ack |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
847 && 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
|
848 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
849 continue; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
850 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
851 |
9096
c6db94ec3841
QUIC: separated path validation retransmit backoff.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9095
diff
changeset
|
852 if ((ngx_msec_int_t) (f->last + (ngx_quic_pto(c, ctx) << qc->pto_count) |
c6db94ec3841
QUIC: separated path validation retransmit backoff.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9095
diff
changeset
|
853 - now) > 0) |
c6db94ec3841
QUIC: separated path validation retransmit backoff.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9095
diff
changeset
|
854 { |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
855 continue; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
858 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
|
859 "quic pto %s pto_count:%ui", |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
860 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
|
861 |
9143
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
862 ngx_memzero(&frame, sizeof(ngx_quic_frame_t)); |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
863 |
9143
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
864 frame.level = ctx->level; |
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
865 frame.type = NGX_QUIC_FT_PING; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
866 |
9143
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
867 if (ngx_quic_frame_sendto(c, &frame, 0, qc->path) != NGX_OK |
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
868 || ngx_quic_frame_sendto(c, &frame, 0, qc->path) != NGX_OK) |
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
869 { |
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
870 ngx_quic_close_connection(c, NGX_ERROR); |
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
871 return; |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
872 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
873 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
874 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
875 qc->pto_count++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
876 |
9143
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
877 ngx_quic_set_lost_timer(c); |
48691bab4474
QUIC: fixed probe-congestion deadlock.
Roman Arutyunyan <arut@nginx.com>
parents:
9142
diff
changeset
|
878 |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
879 ngx_quic_connstate_dbg(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
880 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
881 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
882 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
883 ngx_int_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
884 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
|
885 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
886 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
|
887 uint64_t prev_pending; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
888 ngx_uint_t i, nr; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
889 ngx_quic_send_ctx_t *ctx; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
890 ngx_quic_ack_range_t *r; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
891 ngx_quic_connection_t *qc; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
892 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
893 c->log->action = "preparing ack"; |
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 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
896 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
897 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
|
898 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
899 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
|
900 "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
|
901 " 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
|
902 ctx->first_range, ctx->nranges); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
903 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
904 prev_pending = ctx->pending_ack; |
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 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
907 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
908 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
|
909 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
910 if (ctx->send_ack == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
911 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
|
912 } |
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 ctx->send_ack++; |
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 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
|
917 || ctx->pending_ack < pkt->pn) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
918 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
919 ctx->pending_ack = pkt->pn; |
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 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
922 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
923 base = ctx->largest_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
924 pn = pkt->pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
925 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
926 if (base == NGX_QUIC_UNSET_PN) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
927 ctx->largest_range = pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
928 ctx->largest_received = pkt->received; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
929 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
930 } |
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 if (base == pn) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
933 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
934 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
935 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
936 largest = base; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
937 smallest = largest - ctx->first_range; |
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 if (pn > base) { |
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 (pn - base == 1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
942 ctx->first_range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
943 ctx->largest_range = pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
944 ctx->largest_received = pkt->received; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
945 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
946 return NGX_OK; |
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 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
949 /* 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
|
950 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
951 /* 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
|
952 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
|
953 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
954 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
|
955 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
|
956 return NGX_ERROR; |
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 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
959 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
960 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
|
961 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
|
962 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
963 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
964 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
965 gap = pn - base - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
966 range = ctx->first_range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
967 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
968 ctx->first_range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
969 ctx->largest_range = pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
970 ctx->largest_received = pkt->received; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
971 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
972 /* 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
|
973 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
974 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
|
975 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
976 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
977 i = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
978 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
979 goto insert; |
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 } |
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 /* 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
|
984 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
985 /* packet is out of order */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
986 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
987 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
|
988 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
989 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
990 if (pn >= smallest && pn <= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
991 return NGX_OK; |
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 #if (NGX_SUPPRESS_WARN) |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
995 r = NULL; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
996 #endif |
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 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
|
999 r = &ctx->ranges[i]; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1000 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1001 ge = smallest - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1002 gs = ge - r->gap; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1003 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1004 if (pn >= gs && pn <= ge) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1005 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1006 if (gs == ge) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1007 /* 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
|
1008 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1009 /* 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
|
1010 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1011 if (i == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1012 ctx->first_range += r->range + 2; |
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 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1015 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
|
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 nr = ctx->nranges - i - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1019 if (nr) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1020 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
|
1021 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
|
1022 } |
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 ctx->nranges--; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1025 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1026 } else if (pn == gs) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1027 /* 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
|
1028 r->gap--; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1029 r->range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1030 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1031 } else if (pn == ge) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1032 /* 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
|
1033 r->gap--; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1034 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1035 if (i == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1036 ctx->first_range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1037 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1038 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1039 ctx->ranges[i - 1].range++; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1042 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1043 /* 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
|
1044 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1045 gap = ge - pn - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1046 range = 0; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1047 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1048 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
|
1049 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
|
1050 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
|
1051 return NGX_ERROR; |
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 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1054 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1055 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
|
1056 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
|
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1060 r->gap = pn - gs - 1; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1061 goto insert; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1062 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1063 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1064 return NGX_OK; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1067 largest = smallest - r->gap - 2; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1068 smallest = largest - r->range; |
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 (pn >= smallest && pn <= largest) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1071 /* this packet number is already known */ |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1072 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1073 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1074 |
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 if (pn == smallest - 1) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1078 /* extend first or last range */ |
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 if (i == 0) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1081 ctx->first_range++; |
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 } else { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1084 r->range++; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1085 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1086 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1087 return NGX_OK; |
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 /* 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
|
1091 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1092 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
|
1093 /* 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
|
1094 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1095 if (pkt->need_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1096 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
|
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 gap = smallest - 2 - pn; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1103 range = 0; |
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 insert: |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1106 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1107 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
|
1108 ctx->nranges++; |
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 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
|
1112 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
|
1113 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1114 ctx->ranges[i].gap = gap; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1115 ctx->ranges[i].range = range; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1116 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1117 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1118 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1119 |
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 ngx_int_t |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1122 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
|
1123 { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1124 ngx_msec_t delay; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1125 ngx_quic_connection_t *qc; |
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->send_ack) { |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1128 return NGX_OK; |
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 |
9015
a2fbae359828
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8990
diff
changeset
|
1131 if (ctx->level == ssl_encryption_application) { |
8751
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 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
|
1134 qc = ngx_quic_get_connection(c); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1135 |
9138
a90f79792b5d
QUIC: optimized ACK delay.
Roman Arutyunyan <arut@nginx.com>
parents:
9122
diff
changeset
|
1136 if (ngx_queue_empty(&ctx->frames) |
a90f79792b5d
QUIC: optimized ACK delay.
Roman Arutyunyan <arut@nginx.com>
parents:
9122
diff
changeset
|
1137 && ctx->send_ack < NGX_QUIC_MAX_ACK_GAP |
8751
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1138 && delay < qc->tp.max_ack_delay) |
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 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
|
1141 ngx_add_timer(&qc->push, |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1142 qc->tp.max_ack_delay - delay); |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1143 } |
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 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1146 } |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1147 } |
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 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
|
1150 return NGX_ERROR; |
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 |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1153 ctx->send_ack = 0; |
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 return NGX_OK; |
bc910a5ec737
QUIC: separate files for output and ack related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1156 } |