Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic.c @ 8026:4604e6043657 quic
QUIC: packet based bytes_in_flight accounting.
A packet size is kept in one of the frames belonging to the packet.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 14 Aug 2020 16:54:13 +0300 |
parents | 7f9938cbcd12 |
children | bce9e9643444 |
comparison
equal
deleted
inserted
replaced
8025:7f9938cbcd12 | 8026:4604e6043657 |
---|---|
286 static ngx_quic_frame_t *ngx_quic_alloc_frame(ngx_connection_t *c, size_t size); | 286 static ngx_quic_frame_t *ngx_quic_alloc_frame(ngx_connection_t *c, size_t size); |
287 static void ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame); | 287 static void ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame); |
288 | 288 |
289 static void ngx_quic_congestion_ack(ngx_connection_t *c, | 289 static void ngx_quic_congestion_ack(ngx_connection_t *c, |
290 ngx_quic_frame_t *frame); | 290 ngx_quic_frame_t *frame); |
291 static void ngx_quic_congestion_lost(ngx_connection_t *c, ngx_msec_t sent); | 291 static void ngx_quic_congestion_lost(ngx_connection_t *c, |
292 ngx_quic_frame_t *frame); | |
292 | 293 |
293 | 294 |
294 static SSL_QUIC_METHOD quic_method = { | 295 static SSL_QUIC_METHOD quic_method = { |
295 #if BORINGSSL_API_VERSION >= 10 | 296 #if BORINGSSL_API_VERSION >= 10 |
296 ngx_quic_set_read_secret, | 297 ngx_quic_set_read_secret, |
3625 ngx_queue_add(&ctx->sent, frames); | 3626 ngx_queue_add(&ctx->sent, frames); |
3626 if (qc->pto.timer_set) { | 3627 if (qc->pto.timer_set) { |
3627 ngx_del_timer(&qc->pto); | 3628 ngx_del_timer(&qc->pto); |
3628 } | 3629 } |
3629 ngx_add_timer(&qc->pto, ngx_quic_pto(c, ctx)); | 3630 ngx_add_timer(&qc->pto, ngx_quic_pto(c, ctx)); |
3630 } | 3631 |
3631 | 3632 start->plen = len; |
3632 qc->congestion.in_flight += out.len; | 3633 } |
3634 | |
3635 qc->congestion.in_flight += len; | |
3633 | 3636 |
3634 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | 3637 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
3635 "quic congestion send if:%uz", | 3638 "quic congestion send if:%uz", |
3636 qc->congestion.in_flight); | 3639 qc->congestion.in_flight); |
3637 } else { | 3640 } else { |
3781 } | 3784 } |
3782 | 3785 |
3783 q = ngx_queue_next(q); | 3786 q = ngx_queue_next(q); |
3784 | 3787 |
3785 ngx_queue_remove(&f->queue); | 3788 ngx_queue_remove(&f->queue); |
3786 qc->congestion.in_flight -= f->len; | |
3787 ngx_queue_insert_tail(&range, &f->queue); | 3789 ngx_queue_insert_tail(&range, &f->queue); |
3788 | 3790 |
3789 } while (q != ngx_queue_sentinel(&ctx->sent)); | 3791 } while (q != ngx_queue_sentinel(&ctx->sent)); |
3790 | 3792 |
3791 ngx_quic_congestion_lost(c, start->last); | 3793 ngx_quic_congestion_lost(c, start); |
3792 | 3794 |
3793 if (ngx_quic_send_frames(c, ctx, &range) != NGX_OK) { | 3795 if (ngx_quic_send_frames(c, ctx, &range) != NGX_OK) { |
3794 return NGX_ERROR; | 3796 return NGX_ERROR; |
3795 } | 3797 } |
3796 | 3798 |
4533 { | 4535 { |
4534 ngx_msec_t timer; | 4536 ngx_msec_t timer; |
4535 ngx_quic_congestion_t *cg; | 4537 ngx_quic_congestion_t *cg; |
4536 ngx_quic_connection_t *qc; | 4538 ngx_quic_connection_t *qc; |
4537 | 4539 |
4540 if (f->plen == 0) { | |
4541 return; | |
4542 } | |
4543 | |
4538 qc = c->quic; | 4544 qc = c->quic; |
4539 cg = &qc->congestion; | 4545 cg = &qc->congestion; |
4540 | 4546 |
4541 cg->in_flight -= f->len; | 4547 cg->in_flight -= f->plen; |
4542 | 4548 |
4543 timer = f->last - cg->recovery_start; | 4549 timer = f->last - cg->recovery_start; |
4544 | 4550 |
4545 if ((ngx_msec_int_t) timer <= 0) { | 4551 if ((ngx_msec_int_t) timer <= 0) { |
4552 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
4553 "quic congestion ack recovery win:%uz, ss:%uz, if:%uz", | |
4554 cg->window, cg->ssthresh, cg->in_flight); | |
4555 | |
4546 return; | 4556 return; |
4547 } | 4557 } |
4548 | 4558 |
4549 if (cg->window < cg->ssthresh) { | 4559 if (cg->window < cg->ssthresh) { |
4550 cg->window += f->len; | 4560 cg->window += f->plen; |
4551 | 4561 |
4552 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, | 4562 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
4553 "quic congestion slow start win:%uz, ss:%uz, if:%uz", | 4563 "quic congestion slow start win:%uz, ss:%uz, if:%uz", |
4554 cg->window, cg->ssthresh, cg->in_flight); | 4564 cg->window, cg->ssthresh, cg->in_flight); |
4555 | 4565 |
4556 } else { | 4566 } else { |
4557 cg->window += qc->tp.max_udp_payload_size * f->len / cg->window; | 4567 cg->window += qc->tp.max_udp_payload_size * f->plen / cg->window; |
4558 | 4568 |
4559 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, | 4569 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
4560 "quic congestion avoidance win:%uz, ss:%uz, if:%uz", | 4570 "quic congestion avoidance win:%uz, ss:%uz, if:%uz", |
4561 cg->window, cg->ssthresh, cg->in_flight); | 4571 cg->window, cg->ssthresh, cg->in_flight); |
4562 } | 4572 } |
4570 } | 4580 } |
4571 } | 4581 } |
4572 | 4582 |
4573 | 4583 |
4574 static void | 4584 static void |
4575 ngx_quic_congestion_lost(ngx_connection_t *c, ngx_msec_t sent) | 4585 ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f) |
4576 { | 4586 { |
4577 ngx_msec_t timer; | 4587 ngx_msec_t timer; |
4578 ngx_quic_congestion_t *cg; | 4588 ngx_quic_congestion_t *cg; |
4579 ngx_quic_connection_t *qc; | 4589 ngx_quic_connection_t *qc; |
4580 | 4590 |
4591 if (f->plen == 0) { | |
4592 return; | |
4593 } | |
4594 | |
4581 qc = c->quic; | 4595 qc = c->quic; |
4582 cg = &qc->congestion; | 4596 cg = &qc->congestion; |
4583 | 4597 |
4584 timer = sent - cg->recovery_start; | 4598 cg->in_flight -= f->plen; |
4599 | |
4600 timer = f->last - cg->recovery_start; | |
4585 | 4601 |
4586 if ((ngx_msec_int_t) timer <= 0) { | 4602 if ((ngx_msec_int_t) timer <= 0) { |
4603 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
4604 "quic congestion lost recovery win:%uz, ss:%uz, if:%uz", | |
4605 cg->window, cg->ssthresh, cg->in_flight); | |
4606 | |
4587 return; | 4607 return; |
4588 } | 4608 } |
4589 | 4609 |
4590 cg->recovery_start = ngx_current_msec; | 4610 cg->recovery_start = ngx_current_msec; |
4591 cg->window /= 2; | 4611 cg->window /= 2; |