valence icon indicating copy to clipboard operation
valence copied to clipboard

Packet rate limiting

Open rj00a opened this issue 3 years ago • 2 comments

Currently there is no rate limit for serverbound packets. I'm not sure what the best way to do this is. We should investigate how vanilla MC does it.

rj00a avatar Sep 03 '22 00:09 rj00a

I think one way would be to use the Generic Cell Rate Algorithm.

Kevin-Konradi avatar Sep 04 '22 12:09 Kevin-Konradi

Looks like as of 1.19.2 the vanilla server code calculates the rate per second. It does this by counting the number of packets received in every second. Then, uses that total to linearly interpolate a value of 75% between it and the previous value. If this value exceeds a configurable setting then the client exceeding this limit is immediately disconnected with an error similar to "Disconnected: Exceeded packet rate".

The source code doesn't have a recommended rate-limit value, but based on some googling a reasonable setting would be from 120 to 200 packets a second.

I found this library https://crates.io/crates/governor based on the algorithm Kevin-Konradi suggested. I'll start looking into how this would integrate with the code base currently and post something once I have it sorted.

WugWugg avatar Sep 12 '22 21:09 WugWugg