From 6494b95700381240f7f76860887cdf2887bbe139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Sat, 1 Dec 2018 11:17:39 +0000 Subject: [PATCH] Add a boost factor to estimate send.ratemax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 4 +++- mud.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mud.c b/mud.c index f1a28d3..e88978a 100644 --- a/mud.c +++ b/mud.c @@ -528,6 +528,7 @@ mud_reset_path(struct mud *mud, struct mud_path *path) path->mtu.max = MUD_MTU_MAX; path->mtu.count = 0; path->send.ratemax = 0; + path->send_factor = 8; path->window = 0; path->ok = 0; path->stat_count = 0; @@ -1237,7 +1238,7 @@ mud_packet_recv(struct mud *mud, struct mud_path *path, const uint64_t b = (path->send.ratemax ?: 5000) * target; if (dt < target) { - uint64_t delta = ((target - dt) * a) / b; + uint64_t delta = ((target - dt) * a * path->send_factor) / b; path->send.ratemax += delta; } else if (dt > target) { uint64_t delta = ((dt - target) * a) / b; @@ -1248,6 +1249,7 @@ mud_packet_recv(struct mud *mud, struct mud_path *path, } if (path->send.ratemax < 5000) path->send.ratemax = 5000; + path->send_factor = 1; } return !!peer_sent; diff --git a/mud.h b/mud.h index 8fe66f7..a3c6285 100644 --- a/mud.h +++ b/mud.h @@ -31,6 +31,7 @@ struct mud_path { struct sockaddr_storage local_addr, addr, r_addr; struct mud_value rtt, lat, rate; uint64_t latmin, dt; + uint64_t send_factor; uint64_t r_rate; uint64_t r_ratemax; uint64_t window;