From 0c11ce5785e5dea597f5d4812f7f490dc1299f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Mon, 2 Apr 2018 09:30:36 +0000 Subject: [PATCH] Add number of packets per path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 15 +++++++++------ mud.h | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mud.c b/mud.c index 7a62f2c..78fa802 100644 --- a/mud.c +++ b/mud.c @@ -359,7 +359,8 @@ mud_send_path(struct mud *mud, struct mud_path *path, uint64_t now, ssize_t ret = sendmsg(mud->fd, &msg, flags); - path->send_time = now; + path->send.total++; + path->send.time = now; if (path->send_max <= size) { path->send_max = size; @@ -1307,7 +1308,9 @@ mud_recv(struct mud *mud, void *data, size_t size) return 0; path->rst = send_time; - path->recv_time = now; + + path->recv.total++; + path->recv.time = now; if (path->recv_max <= packet_size) { path->recv_max = packet_size; @@ -1373,7 +1376,7 @@ mud_update(struct mud *mud, uint64_t now) if (path->state < MUD_DOWN) continue; - if (update_keyx || mud_timeout(now, path->recv_time, mud->send_timeout + MUD_ONE_SEC)) + if (update_keyx || mud_timeout(now, path->recv.time, mud->send_timeout + MUD_ONE_SEC)) path->conf.remote = 0; if ((!path->conf.remote) && @@ -1424,7 +1427,7 @@ mud_send(struct mud *mud, const void *data, size_t size, int tc) } int64_t limit = path->limit; - uint64_t elapsed = now - path->send_time; + uint64_t elapsed = now - path->send.time; if (limit > elapsed) { limit += path->rtt / 2 - elapsed; @@ -1432,8 +1435,8 @@ mud_send(struct mud *mud, const void *data, size_t size, int tc) limit = path->rtt / 2; } - if (mud_timeout(now, path->recv_time, mud->send_timeout + MUD_ONE_SEC)) { - if (mud_timeout(now, path->send_time, mud->send_timeout)) { + if (mud_timeout(now, path->recv.time, mud->send_timeout + MUD_ONE_SEC)) { + if (mud_timeout(now, path->send.time, mud->send_timeout)) { mud_send_path(mud, path, now, packet, packet_size, tc, 0); path->limit = limit; } diff --git a/mud.h b/mud.h index 0cc764c..335428f 100644 --- a/mud.h +++ b/mud.h @@ -33,14 +33,16 @@ struct mud_path { uint64_t r_rms; uint64_t r_rmt; uint64_t limit; - uint64_t recv_time; - uint64_t send_time; uint64_t stat_time; struct { size_t ok; size_t probe; uint64_t time; } mtu; + struct { + uint64_t total; + uint64_t time; + } send, recv; }; struct mud *mud_create (struct sockaddr *);