Take the time to check loss before enabling a path

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2019-10-23 14:07:35 +00:00
parent 94ae912138
commit f647519e1c
2 changed files with 9 additions and 5 deletions

12
mud.c
View File

@@ -1276,9 +1276,11 @@ mud_update_window(struct mud *mud, struct mud_path *path,
if (send_bytes && send_bytes >= recv_bytes) {
path->tx.loss = (send_bytes - recv_bytes) * 100 / send_bytes;
if (path->tx.loss < mud->loss_limit) {
path->loss_count = 0;
} else if (path->loss_count < MUD_LOSS_COUNT) {
path->loss_count++;
if (path->loss_count > -MUD_LOSS_COUNT)
path->loss_count--;
} else {
if (path->loss_count < MUD_LOSS_COUNT)
path->loss_count++;
}
}
@@ -1317,7 +1319,9 @@ mud_recv_msg(struct mud *mud, struct mud_path *path,
path->rx.loss = (uint64_t)msg->loss;
path->msg_sent = 0;
path->ok = 1;
if (path->loss_count == -MUD_LOSS_COUNT) // tmp hack
path->ok = 1;
} else {
mud_keyx_init(mud, now);
path->state = (enum mud_state)msg->state;