Add a stupid dynamic rate limiter
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
12
mud.c
12
mud.c
@@ -1204,11 +1204,7 @@ mud_update_window(struct mud *mud, struct mud_path *path, uint64_t now,
|
||||
uint64_t rx_dt, uint64_t rx_bytes, uint64_t rx_pkt)
|
||||
{
|
||||
if (rx_dt && rx_dt > tx_dt + (tx_dt >> 3)) {
|
||||
if (!path->conf.fixed_rate) {
|
||||
path->tx.rate = 1 + ((rx_bytes * MUD_ONE_SEC) - 1) / rx_dt;
|
||||
if (path->tx.rate > path->conf.tx_max_rate)
|
||||
path->tx.rate = path->conf.tx_max_rate;
|
||||
}
|
||||
path->tx.rate = (7 * rx_bytes * MUD_ONE_SEC) / (8 * rx_dt);
|
||||
} else {
|
||||
uint64_t tx_acc = path->msg.tx.acc + tx_pkt;
|
||||
uint64_t rx_acc = path->msg.rx.acc + rx_pkt;
|
||||
@@ -1223,7 +1219,13 @@ mud_update_window(struct mud *mud, struct mud_path *path, uint64_t now,
|
||||
path->msg.tx.acc = tx_acc;
|
||||
path->msg.rx.acc = rx_acc;
|
||||
}
|
||||
|
||||
if (!path->conf.fixed_rate)
|
||||
path->tx.rate += path->tx.rate / 10;
|
||||
}
|
||||
|
||||
if (path->tx.rate > path->conf.tx_max_rate)
|
||||
path->tx.rate = path->conf.tx_max_rate;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user