FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.71k stars 396 forks source link

Too frequent kick because of too many packets sent #12033

Open Scrymmery opened 1 year ago

Scrymmery commented 1 year ago

Disclaimers

What happened?

Anti-DoS working bad, it can kick you even if you are not doing anything bad. Usually it happens while i use voice chat and doing any actions except just standing and talking like bot. By the fact, almost every time when i not cosplaying bots(walking withous suit and fixing few pumps once a hour), but doing more than two interacts per hour, i got kicked. I suppose it because default packet limits are too low. Also, if host have not very good PC, you might even get kicked just because you touched a control terminal. Even worse, if host have a potato PC, sometimes entire server get kicked because game for some reason think they're all DoSing host.

Maybe it will be better to increase default packet limitation, so it will be impossible to reach unless you not using any soft for packet flood? Also, i don't know how exactly you count packets, but i think it will also better if you do some changes to their counter, so it will filter legit packets, and don't count them(voice chat for example), to minimize frequency of fake antidos kicks. At this moment it just too high. i just want to have fun, but every time i get kicked because of it, or see other guys also get kicked. I know packet limits can be increased in settings, but a lot of hosts are newbies who joined game after 1.0, also some of them just too dumb, so if you asking them to make it work good, they're either just say "haha dumb cheater i will not disable dos protection" or will ignore you because fuck you that's why. Btw game settings should be ok "from a box", so it's strange why we have to increase packet limits to be able to play without fake kicks. Hope you fix it.

Reproduction steps

  1. Join server
  2. Attach a soundpad to high quality microphone(not 1 bit 1hz 1 channel)
  3. Start playing music, or just actively talking
  4. Start doing more actions(shooting, healing, driving a sub, etc.)
  5. If you are lucky enough, you'll reach packet limit and get kicked

Bug prevalence

Happens every time I play

Version

v1.0.13.2

-

No response

Which operating system did you encounter this bug on?

Windows

Relevant error messages and crash reports

No response

Regalis11 commented 1 year ago

Thank you for the report!

There is a known issue in the rate limiter that can easily cause a client to be kicked if they're using voice chat in a server with a higher than normal tickrate. However, I'm not entirely sure if that's the case here: if the server is hosted by a new player, it seems unlikely they would've adjusted the server's tickrate (which can only be done by modifying the server config file manually). So we need to take a closer look at this and see where the issue is.

Also, i don't know how exactly you count packets, but i think it will also better if you do some changes to their counter, so it will filter legit packets, and don't count them(voice chat for example), to minimize frequency of fake antidos kicks.

This wouldn't actually work: we cannot filter legit packets, because that'd mean a hacker can bypass the protection by sending a ton of those "legit" packets. Or rather, we would need a way to evaluate what's a legit packet and what isn't, which seems like a nearly impossible task, unless we do it the way we do it now: if the client is sending packets at a higher rate than what should be possible by an unmodified client, it's considered "not legit".

Scrymmery commented 1 year ago

So we need to take a closer look at this and see where the issue

i think the issue is default packet limit too low, so it should be increased. As i said, it can occur not only using voice chat. It's just looks like limit is wrongly defined, so it's possible to reach by an unmodified client.

which seems like a nearly impossible task

What's about giving some sort of a "mass" to packets, then? For example, if packets are too large, or sending too frequently on legit unmodified clients, it will have less mass, so 1000 voice chat packets would be counted as 500. It will still prevent DoS attacks, but also there will be no actions that are easier to fakekick player than other. (so usually you are sending for example X count packets of nonvoicechat packets, and 2X count of voicechat packets. Giving a 0.5mass to voicechat will make it equal, and fake kicks will occur less frequent when using vc)

also, i think, a good idea is to make some sort of watchdog, which will look for performance. And if it notices unexcepted performance drop at the same time when some player start sending more packets than it should be, then it's a flag this player is DoSing.

Regalis11 commented 1 year ago

Yeah, you're right, it does seem like the default packet limit is too low. Something like the "mass" system could also be worth considering, or in other words, the server could allow the clients to send a larger number of the kind of packets we know the clients will be sending large numbers of (like voice chat packets).

also, i think, a good idea is to make some sort of watchdog, which will look for performance

We actually also added this kind of a system too in the latest update: in addition to measuring the number of packets sent by the client, the server also checks if packets sent by the client are taking a long time to process.

NilanthAnimosus commented 1 year ago

Tested against 1.0.13.2 on master

image

In my attempts to get kicked on the default settings (20 ticketrate, 3000 on the packetlimit) this was the closest I could get - noting at some point this was an increased value back in commit https://github.com/Regalis11/Barotrauma-development/commit/22df846036d2ef3e36e01acbd112d7cc493adb65 from 1.0.16.0 onwards.

So its part of the next patch / current unstable and might be worth considering bumping the value past 3000 (to say 3500 or 4000 as a new default value). That should be sufficient enough given I was trying everything with an always-on mic to achieve the above value.

3e849f2e5c commented 1 year ago

The default limit has been increased so this shouldn't be an issue anymore but older configs do not update the value, need to decide what we want to do about that or just let it boil over

itchyOwl commented 1 year ago

Also worth considering, as Nilanth commented, if 3000 is actually enough.

Regalis11 commented 11 months ago

Note: mention the current limit in the error message