althea-net / rita

Rita is a routing and billing protocol that allows devices to buy and sell bandwidth
https://docs.althea.net/
Apache License 2.0
90 stars 24 forks source link

Throttle wg_exit locally when balance is low. #930

Open jkilpatr opened 2 months ago

jkilpatr commented 2 months ago

One of the major user complains is that when a users balance is low it takes a long time for them to experience enforcement and then once they add funds it can be difficult for the actual payment to be made by the router (because their neighbor has throttled the connection, resulting in poor quality, which is what is causing the users to pay).

We should restructure this so that a router first throttles itself when it's balance becomes low. Becuase this will provide quick feedback to the user, and then if they add funds in any reasonable amount of time an instant resolution to 'enforcement' because their neighbor never had to take any action.

We already have a function to check if we have outstanding payments higher than the current balance in debt keeper, when that is true exit_manager should setup a different qdisc to throttle traffic on the wg_exit interface. We'll need to throttle ingress rather than egress, but modern cake has an easy way to do that by specifying 'ingress' when creating the qdisc.