From bda2c6eaa7919e891fda83e9c15edc30c612ac7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Sat, 7 Mar 2020 15:13:37 +0000 Subject: [PATCH] Wait a few packets before computing the loss MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mud.c b/mud.c index 38de8ad..7a519c6 100644 --- a/mud.c +++ b/mud.c @@ -1201,12 +1201,11 @@ 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 >= 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 - (rx_acc >> 3); + if (tx_acc > 1000) { + if (tx_acc >= rx_acc) + path->tx.loss = (tx_acc - rx_acc) * 255U / tx_acc; + path->msg.tx.acc = tx_acc - (tx_acc >> 4); + path->msg.rx.acc = rx_acc - (rx_acc >> 4); } else { path->msg.tx.acc = tx_acc; path->msg.rx.acc = rx_acc;