comparison src/event/quic/ngx_event_quic_ack.c @ 8498:4715f3e669f1 quic

QUIC: updated specification references. This includes updating citations and further clarification.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 16 Jun 2021 11:55:12 +0300
parents 004172345bdc
children 4009f120cad4
comparison
equal deleted inserted replaced
8497:1fec68e322d0 8498:4715f3e669f1
10 #include <ngx_event_quic_connection.h> 10 #include <ngx_event_quic_connection.h>
11 11
12 12
13 #define NGX_QUIC_MAX_ACK_GAP 2 13 #define NGX_QUIC_MAX_ACK_GAP 2
14 14
15 /* quic-recovery, section 6.1.1, Packet Threshold */ 15 /* RFC 9002, 6.1.1. Packet Threshold: kPacketThreshold */
16 #define NGX_QUIC_PKT_THR 3 /* packets */ 16 #define NGX_QUIC_PKT_THR 3 /* packets */
17 /* quic-recovery, section 6.1.2, Time Threshold */ 17 /* RFC 9002, 6.1.2. Time Threshold: kTimeThreshold, kGranularity */
18 #define NGX_QUIC_TIME_THR 1.125 18 #define NGX_QUIC_TIME_THR 1.125
19 #define NGX_QUIC_TIME_GRANULARITY 1 /* ms */ 19 #define NGX_QUIC_TIME_GRANULARITY 1 /* ms */
20 20
21 /* quic-recovery, section 7.6.1 Persistent congestion duration */ 21 /* RFC 9002, 7.6.1. Duration: kPersistentCongestionThreshold */
22 #define NGX_QUIC_PERSISTENT_CONGESTION_THR 3 22 #define NGX_QUIC_PERSISTENT_CONGESTION_THR 3
23 23
24 #define ngx_quic_lost_threshold(qc) \ 24 #define ngx_quic_lost_threshold(qc) \
25 ngx_max(NGX_QUIC_TIME_THR * ngx_max((qc)->latest_rtt, (qc)->avg_rtt), \ 25 ngx_max(NGX_QUIC_TIME_THR * ngx_max((qc)->latest_rtt, (qc)->avg_rtt), \
26 NGX_QUIC_TIME_GRANULARITY) 26 NGX_QUIC_TIME_GRANULARITY)
71 "quic ngx_quic_handle_ack_frame level:%d", pkt->level); 71 "quic ngx_quic_handle_ack_frame level:%d", pkt->level);
72 72
73 ack = &f->u.ack; 73 ack = &f->u.ack;
74 74
75 /* 75 /*
76 * RFC 9000, 19.3.1. ACK Ranges
77 *
76 * If any computed packet number is negative, an endpoint MUST 78 * If any computed packet number is negative, an endpoint MUST
77 * generate a connection error of type FRAME_ENCODING_ERROR. 79 * generate a connection error of type FRAME_ENCODING_ERROR.
78 * (19.3.1)
79 */ 80 */
80 81
81 if (ack->first_range > ack->largest) { 82 if (ack->first_range > ack->largest) {
82 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR; 83 qc->error = NGX_QUIC_ERR_FRAME_ENCODING_ERROR;
83 ngx_log_error(NGX_LOG_INFO, c->log, 0, 84 ngx_log_error(NGX_LOG_INFO, c->log, 0,
95 != NGX_OK) 96 != NGX_OK)
96 { 97 {
97 return NGX_ERROR; 98 return NGX_ERROR;
98 } 99 }
99 100
100 /* 13.2.3. Receiver Tracking of ACK Frames */ 101 /* RFC 9000, 13.2.4. Limiting Ranges by Tracking ACK Frames */
101 if (ctx->largest_ack < max || ctx->largest_ack == NGX_QUIC_UNSET_PN) { 102 if (ctx->largest_ack < max || ctx->largest_ack == NGX_QUIC_UNSET_PN) {
102 ctx->largest_ack = max; 103 ctx->largest_ack = max;
103 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 104 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
104 "quic updated largest received ack:%uL", max); 105 "quic updated largest received ack:%uL", max);
105 106
106 /* 107 /*
108 * RFC 9002, 5.1. Generating RTT Samples
109 *
107 * An endpoint generates an RTT sample on receiving an 110 * An endpoint generates an RTT sample on receiving an
108 * ACK frame that meets the following two conditions: 111 * ACK frame that meets the following two conditions:
109 * 112 *
110 * - the largest acknowledged packet number is newly acknowledged 113 * - the largest acknowledged packet number is newly acknowledged
111 * - at least one of the newly acknowledged packets was ack-eliciting. 114 * - at least one of the newly acknowledged packets was ack-eliciting.
468 ngx_quic_resend_frames(c, ctx); 471 ngx_quic_resend_frames(c, ctx);
469 } 472 }
470 } 473 }
471 474
472 475
473 /* Establishing Persistent Congestion (7.6.2) */ 476 /* RFC 9002, 7.6.2. Establishing Persistent Congestion */
474 477
475 /* 478 /*
476 * Once acknowledged, packets are no longer tracked. Thus no send time 479 * Once acknowledged, packets are no longer tracked. Thus no send time
477 * information is available for such packets. This limits persistent 480 * information is available for such packets. This limits persistent
478 * congestion algorithm to packets mentioned within ACK ranges of the 481 * congestion algorithm to packets mentioned within ACK ranges of the
755 ngx_msec_t duration; 758 ngx_msec_t duration;
756 ngx_quic_connection_t *qc; 759 ngx_quic_connection_t *qc;
757 760
758 qc = ngx_quic_get_connection(c); 761 qc = ngx_quic_get_connection(c);
759 762
760 /* PTO calculation: quic-recovery, Appendix 8 */ 763 /* RFC 9002, Appendix A.8. Setting the Loss Detection Timer */
761 duration = qc->avg_rtt; 764 duration = qc->avg_rtt;
762 765
763 duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY); 766 duration += ngx_max(4 * qc->rttvar, NGX_QUIC_TIME_GRANULARITY);
764 duration <<= qc->pto_count; 767 duration <<= qc->pto_count;
765 768