Add a boost factor to estimate send.ratemax

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-12-01 11:17:39 +00:00
parent ff0c10b66c
commit 6494b95700
2 changed files with 4 additions and 1 deletions

4
mud.c
View File

@@ -528,6 +528,7 @@ mud_reset_path(struct mud *mud, struct mud_path *path)
path->mtu.max = MUD_MTU_MAX; path->mtu.max = MUD_MTU_MAX;
path->mtu.count = 0; path->mtu.count = 0;
path->send.ratemax = 0; path->send.ratemax = 0;
path->send_factor = 8;
path->window = 0; path->window = 0;
path->ok = 0; path->ok = 0;
path->stat_count = 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; const uint64_t b = (path->send.ratemax ?: 5000) * target;
if (dt < 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; path->send.ratemax += delta;
} else if (dt > target) { } else if (dt > target) {
uint64_t delta = ((dt - target) * a) / b; 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) if (path->send.ratemax < 5000)
path->send.ratemax = 5000; path->send.ratemax = 5000;
path->send_factor = 1;
} }
return !!peer_sent; return !!peer_sent;

1
mud.h
View File

@@ -31,6 +31,7 @@ struct mud_path {
struct sockaddr_storage local_addr, addr, r_addr; struct sockaddr_storage local_addr, addr, r_addr;
struct mud_value rtt, lat, rate; struct mud_value rtt, lat, rate;
uint64_t latmin, dt; uint64_t latmin, dt;
uint64_t send_factor;
uint64_t r_rate; uint64_t r_rate;
uint64_t r_ratemax; uint64_t r_ratemax;
uint64_t window; uint64_t window;