Add a specific timer for mtu probing

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-03-14 18:47:43 +00:00
parent ef319d2153
commit 2c5eb574f9
2 changed files with 21 additions and 15 deletions

35
mud.c
View File

@@ -1273,6 +1273,25 @@ mud_recv(struct mud *mud, void *data, size_t size)
return ret; return ret;
} }
static void
mud_probe_mtu(struct mud *mud, struct mud_path *path, uint64_t now)
{
if ((!path->rtt) ||
(!mud_timeout(now, path->mtu.time, path->rtt)) ||
(path->mtu.probe == path->r_rms + 1) ||
(path->r_rms == MUD_PACKET_MAX_SIZE))
return;
if (path->mtu.probe > path->mtu.ok) {
path->mtu.probe = (path->mtu.probe + path->mtu.ok) >> 1;
} else {
path->mtu.probe = (MUD_PACKET_MAX_SIZE + path->mtu.ok + 1) >> 1;
}
mud_packet_send(mud, mud_fake, path, now, 0);
path->mtu.time = now;
}
static void static void
mud_update(struct mud *mud, uint64_t now) mud_update(struct mud *mud, uint64_t now)
{ {
@@ -1302,21 +1321,7 @@ mud_update(struct mud *mud, uint64_t now)
path->conf.send_time = now; path->conf.send_time = now;
} }
if ((!path->rtt) || mud_probe_mtu(mud, path, now);
(!mud_timeout(now, path->send_max_time, path->rtt)))
continue;
if ((path->mtu.probe == path->r_rms + 1) ||
(path->r_rms == MUD_PACKET_MAX_SIZE))
continue;
if (path->mtu.probe > path->mtu.ok) {
path->mtu.probe = (path->mtu.probe + path->mtu.ok) >> 1;
} else {
path->mtu.probe = (MUD_PACKET_MAX_SIZE + path->mtu.ok + 1) >> 1;
}
mud_packet_send(mud, mud_fake, path, now, 0);
} }
} }

1
mud.h
View File

@@ -39,6 +39,7 @@ struct mud_path {
struct { struct {
size_t ok; size_t ok;
size_t probe; size_t probe;
uint64_t time;
} mtu; } mtu;
}; };