diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2022-01-21 18:40:49 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2022-02-22 19:28:35 +0000 |
commit | 4f3a0e39cf18f3d44dd2f4b469edd7055287a478 (patch) | |
tree | cb338ea070a41f17263a84428372833312bba432 /src/core | |
parent | 8052d0c2c08ac227aaee1134a52d5a3993ba4b10 (diff) | |
download | tor-4f3a0e39cf18f3d44dd2f4b469edd7055287a478.tar.gz tor-4f3a0e39cf18f3d44dd2f4b469edd7055287a478.zip |
Guard against 0 time delta in BDP calc.
This can only happen in Shadow, but it will cause issues there.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/congestion_control_common.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c index fe3228262a..4b483a90b0 100644 --- a/src/core/or/congestion_control_common.c +++ b/src/core/or/congestion_control_common.c @@ -937,21 +937,26 @@ congestion_control_update_circuit_bdp(congestion_control_t *cc, timestamp_usec = peek_timestamp(cc->sendme_arrival_timestamps); uint64_t delta = now_usec - timestamp_usec; - /* The acked data is in sendme_cnt-1 chunks, because we are counting the - * data that is processed by the other endpoint *between* all of these - * sendmes. There's one less gap between the sendmes than the number - * of sendmes. */ - uint64_t cells = (sendme_cnt-1)*cc->sendme_inc; - - /* The bandwidth estimate is cells/delta, which when multiplied - * by min RTT obtains the BDP. However, we multiply first to - * avoid precision issues with the RTT being close to delta in size. */ - sendme_rate_bdp = cells*cc->min_rtt_usec/delta; - - /* Calculate BDP_EWMA_COUNT N-EWMA */ - cc->bdp[BDP_ALG_SENDME_RATE] = - n_count_ewma(sendme_rate_bdp, cc->bdp[BDP_ALG_SENDME_RATE], - cc->ewma_cwnd_cnt*sendme_acks_per_cwnd(cc)); + /* In Shadow, the time delta between acks can be 0 if there is no + * network activity between them. Only update BDP if the delta is + * non-zero. */ + if (delta > 0) { + /* The acked data is in sendme_cnt-1 chunks, because we are counting + * the data that is processed by the other endpoint *between* all of + * these sendmes. There's one less gap between the sendmes than the + * number of sendmes. */ + uint64_t cells = (sendme_cnt-1)*cc->sendme_inc; + + /* The bandwidth estimate is cells/delta, which when multiplied + * by min RTT obtains the BDP. However, we multiply first to + * avoid precision issues with the RTT being close to delta in size. */ + sendme_rate_bdp = cells*cc->min_rtt_usec/delta; + + /* Calculate BDP_EWMA_COUNT N-EWMA */ + cc->bdp[BDP_ALG_SENDME_RATE] = + n_count_ewma(sendme_rate_bdp, cc->bdp[BDP_ALG_SENDME_RATE], + cc->ewma_cwnd_cnt*sendme_acks_per_cwnd(cc)); + } } /* In-flight BDP will cause the cwnd to drift down when underutilized. |