From 487474a80ee5dc701e7adfdd7c17e46b08a5e759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Wed, 8 Jan 2020 14:34:47 +0000 Subject: [PATCH] Update loss computing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mud.c b/mud.c index 99ddedc..1637b4f 100644 --- a/mud.c +++ b/mud.c @@ -1205,13 +1205,12 @@ mud_update_window(struct mud *mud, struct mud_path *path, uint64_t now, uint64_t tx_acc = path->msg.tx.acc + tx_pkt; uint64_t rx_acc = path->msg.rx.acc + rx_pkt; - if (tx_acc > 10 * mud->loss_limit) { - if (tx_acc >= rx_acc) { - uint64_t loss = (tx_acc - rx_acc) * 255U / tx_acc; - path->tx.loss = (6 * path->tx.loss + 2 * loss) / 8; - } - path->msg.tx.acc = 0; - path->msg.rx.acc = 0; + if (tx_acc >= rx_acc) + path->tx.loss = (tx_acc - rx_acc) * 255U / tx_acc; + + if (tx_acc > 10000) { + path->msg.tx.acc = tx_acc - (tx_acc >> 3); + path->msg.rx.acc = rx_acc - (tx_acc >> 3); } else { path->msg.tx.acc = tx_acc; path->msg.rx.acc = rx_acc;