Update loss computing

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2020-01-08 14:34:47 +00:00
parent edb86d27ad
commit 487474a80e

13
mud.c
View File

@@ -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 tx_acc = path->msg.tx.acc + tx_pkt;
uint64_t rx_acc = path->msg.rx.acc + rx_pkt; uint64_t rx_acc = path->msg.rx.acc + rx_pkt;
if (tx_acc > 10 * mud->loss_limit) { if (tx_acc >= rx_acc)
if (tx_acc >= rx_acc) { path->tx.loss = (tx_acc - rx_acc) * 255U / tx_acc;
uint64_t loss = (tx_acc - rx_acc) * 255U / tx_acc;
path->tx.loss = (6 * path->tx.loss + 2 * loss) / 8; if (tx_acc > 10000) {
} path->msg.tx.acc = tx_acc - (tx_acc >> 3);
path->msg.tx.acc = 0; path->msg.rx.acc = rx_acc - (tx_acc >> 3);
path->msg.rx.acc = 0;
} else { } else {
path->msg.tx.acc = tx_acc; path->msg.tx.acc = tx_acc;
path->msg.rx.acc = rx_acc; path->msg.rx.acc = rx_acc;