From: Frédéric Lécaille Date: Thu, 3 Mar 2022 06:50:45 +0000 (+0100) Subject: MINOR: quic: More precise window update calculation X-Git-Tag: v2.6-dev3~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e7c9a71431ce55816fee76f3e6109cbda6dd3a9;p=thirdparty%2Fhaproxy.git MINOR: quic: More precise window update calculation When in congestion avoidance state and when acknowledging an number bytes we must increase the congestion window by at most one datagram (mtu>) by congestion window. So thanks to this patch we apply a ratio to the current number of acked bytes : * mtu> / . So, when bytes are acked we precisely increment by mtu>. Furthermore we take into an account the number of remaining acknowledged bytes each time we increment the window by storing their values in the algorithm struct state (->remain_acked) so that it might be take into an account at the next ACK event. --- diff --git a/include/haproxy/quic_cc-t.h b/include/haproxy/quic_cc-t.h index 78af6a587c..95d9922f09 100644 --- a/include/haproxy/quic_cc-t.h +++ b/include/haproxy/quic_cc-t.h @@ -76,6 +76,7 @@ union quic_cc_algo_state { uint64_t cwnd; uint64_t ssthresh; uint64_t recovery_start_time; + uint64_t remain_acked; } nr; }; diff --git a/src/quic_cc_newreno.c b/src/quic_cc_newreno.c index e15b302b2b..3952910153 100644 --- a/src/quic_cc_newreno.c +++ b/src/quic_cc_newreno.c @@ -35,6 +35,7 @@ static int quic_cc_nr_init(struct quic_cc *cc) cc->algo_state.nr.cwnd = path->cwnd; cc->algo_state.nr.ssthresh = QUIC_CC_INFINITE_SSTHESH; cc->algo_state.nr.recovery_start_time = 0; + cc->algo_state.nr.remain_acked = 0; return 1; } @@ -95,17 +96,20 @@ static void quic_cc_nr_ca_cb(struct quic_cc *cc, struct quic_cc_event *ev) path = container_of(cc, struct quic_path, cc); switch (ev->type) { case QUIC_CC_EVT_ACK: + { + uint64_t acked; /* Do not increase the congestion window in recovery period. */ if (ev->ack.time_sent <= cc->algo_state.nr.recovery_start_time) goto out; - /* Increasing the congestion window by 1 maximum packet size by - * congestion window. + /* Increasing the congestion window by (acked / cwnd) */ - cc->algo_state.nr.cwnd += - path->mtu * QUIC_MAX(1ULL, (unsigned long long)ev->ack.acked / cc->algo_state.nr.cwnd); + acked = ev->ack.acked * path->mtu + cc->algo_state.nr.remain_acked; + cc->algo_state.nr.remain_acked = acked % cc->algo_state.nr.cwnd; + cc->algo_state.nr.cwnd += acked / cc->algo_state.nr.cwnd; path->cwnd = cc->algo_state.nr.cwnd; break; + } case QUIC_CC_EVT_LOSS: /* Do not decrease the congestion window when already in recovery period. */