Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic.c @ 8156:0351fcf52a03 quic
QUIC: drop acknowledged ranges.
13.2.4. Limiting Ranges by Tracking ACK Frames
When a packet containing an ACK frame is sent, the largest
acknowledged in that frame may be saved. When a packet containing an
ACK frame is acknowledged, the receiver can stop acknowledging
packets less than or equal to the largest acknowledged in the sent
ACK frame.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Tue, 20 Oct 2020 18:53:25 +0300 |
parents | 38c7dd720774 |
children | 85a550047eb5 |
comparison
equal
deleted
inserted
replaced
8155:38c7dd720774 | 8156:0351fcf52a03 |
---|---|
242 ngx_quic_header_t *pkt); | 242 ngx_quic_header_t *pkt); |
243 static ngx_int_t ngx_quic_ack_packet(ngx_connection_t *c, | 243 static ngx_int_t ngx_quic_ack_packet(ngx_connection_t *c, |
244 ngx_quic_header_t *pkt); | 244 ngx_quic_header_t *pkt); |
245 static ngx_int_t ngx_quic_send_ack_range(ngx_connection_t *c, | 245 static ngx_int_t ngx_quic_send_ack_range(ngx_connection_t *c, |
246 ngx_quic_send_ctx_t *ctx, uint64_t smallest, uint64_t largest); | 246 ngx_quic_send_ctx_t *ctx, uint64_t smallest, uint64_t largest); |
247 static void ngx_quic_drop_ack_ranges(ngx_connection_t *c, | |
248 ngx_quic_send_ctx_t *ctx, uint64_t pn); | |
247 static ngx_int_t ngx_quic_send_ack(ngx_connection_t *c, | 249 static ngx_int_t ngx_quic_send_ack(ngx_connection_t *c, |
248 ngx_quic_send_ctx_t *ctx); | 250 ngx_quic_send_ctx_t *ctx); |
249 static ngx_int_t ngx_quic_ack_delay(ngx_connection_t *c, | 251 static ngx_int_t ngx_quic_ack_delay(ngx_connection_t *c, |
250 struct timeval *received, enum ssl_encryption_level_t level); | 252 struct timeval *received, enum ssl_encryption_level_t level); |
251 static ngx_int_t ngx_quic_send_cc(ngx_connection_t *c); | 253 static ngx_int_t ngx_quic_send_cc(ngx_connection_t *c); |
2535 | 2537 |
2536 return NGX_OK; | 2538 return NGX_OK; |
2537 } | 2539 } |
2538 | 2540 |
2539 | 2541 |
2542 static void | |
2543 ngx_quic_drop_ack_ranges(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx, | |
2544 uint64_t pn) | |
2545 { | |
2546 uint64_t base; | |
2547 ngx_uint_t i, smallest, largest; | |
2548 ngx_quic_ack_range_t *r; | |
2549 | |
2550 base = ctx->largest_range; | |
2551 | |
2552 if (base == (uint64_t) -1) { | |
2553 return; | |
2554 } | |
2555 | |
2556 if (ctx->pending_ack != (uint64_t) -1 && pn >= ctx->pending_ack) { | |
2557 ctx->pending_ack = (uint64_t) -1; | |
2558 } | |
2559 | |
2560 largest = base; | |
2561 smallest = largest - ctx->first_range; | |
2562 | |
2563 if (pn >= largest) { | |
2564 ctx->largest_range = (uint64_t) - 1; | |
2565 ctx->first_range = 0; | |
2566 ctx->nranges = 0; | |
2567 return; | |
2568 } | |
2569 | |
2570 if (pn >= smallest) { | |
2571 ctx->first_range = largest - pn - 1; | |
2572 ctx->nranges = 0; | |
2573 return; | |
2574 } | |
2575 | |
2576 for (i = 0; i < ctx->nranges; i++) { | |
2577 r = &ctx->ranges[i]; | |
2578 | |
2579 largest = smallest - r->gap - 2; | |
2580 smallest = largest - r->range; | |
2581 | |
2582 if (pn >= largest) { | |
2583 ctx->nranges = i; | |
2584 return; | |
2585 } | |
2586 if (pn >= smallest) { | |
2587 r->range = largest - pn - 1; | |
2588 ctx->nranges = i + 1; | |
2589 return; | |
2590 } | |
2591 } | |
2592 } | |
2593 | |
2594 | |
2540 static ngx_int_t | 2595 static ngx_int_t |
2541 ngx_quic_send_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) | 2596 ngx_quic_send_ack(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx) |
2542 { | 2597 { |
2543 size_t ranges_len; | 2598 size_t ranges_len; |
2544 ngx_quic_frame_t *frame; | 2599 ngx_quic_frame_t *frame; |
2803 q = ngx_queue_prev(q); | 2858 q = ngx_queue_prev(q); |
2804 | 2859 |
2805 if (f->pnum >= min && f->pnum <= max) { | 2860 if (f->pnum >= min && f->pnum <= max) { |
2806 ngx_quic_congestion_ack(c, f); | 2861 ngx_quic_congestion_ack(c, f); |
2807 | 2862 |
2808 ngx_quic_handle_stream_ack(c, f); | 2863 switch (f->type) { |
2864 case NGX_QUIC_FT_ACK: | |
2865 ngx_quic_drop_ack_ranges(c, ctx, f->u.ack.largest); | |
2866 break; | |
2867 | |
2868 case NGX_QUIC_FT_STREAM0: | |
2869 case NGX_QUIC_FT_STREAM1: | |
2870 case NGX_QUIC_FT_STREAM2: | |
2871 case NGX_QUIC_FT_STREAM3: | |
2872 case NGX_QUIC_FT_STREAM4: | |
2873 case NGX_QUIC_FT_STREAM5: | |
2874 case NGX_QUIC_FT_STREAM6: | |
2875 case NGX_QUIC_FT_STREAM7: | |
2876 ngx_quic_handle_stream_ack(c, f); | |
2877 break; | |
2878 } | |
2809 | 2879 |
2810 if (f->pnum > found_num || !found) { | 2880 if (f->pnum > found_num || !found) { |
2811 *send_time = f->last; | 2881 *send_time = f->last; |
2812 found_num = f->pnum; | 2882 found_num = f->pnum; |
2813 } | 2883 } |
2924 { | 2994 { |
2925 uint64_t sent, unacked; | 2995 uint64_t sent, unacked; |
2926 ngx_event_t *wev; | 2996 ngx_event_t *wev; |
2927 ngx_quic_stream_t *sn; | 2997 ngx_quic_stream_t *sn; |
2928 ngx_quic_connection_t *qc; | 2998 ngx_quic_connection_t *qc; |
2929 | |
2930 if (f->type < NGX_QUIC_FT_STREAM0 || f->type > NGX_QUIC_FT_STREAM7) { | |
2931 return; | |
2932 } | |
2933 | 2999 |
2934 qc = c->quic; | 3000 qc = c->quic; |
2935 | 3001 |
2936 sn = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); | 3002 sn = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
2937 if (sn == NULL) { | 3003 if (sn == NULL) { |