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;