Advertisement

Number of Packets & Fairness

Started by February 15, 2014 12:31 PM
6 comments, last by wodinoneeye 10 years, 9 months ago
Hello. I currently work myself into network programming and therefore read a lot of articles about it. One article was about how to implement your own flow control ( since using UDP as a protocol, one has to implement this on his own ). So depending on some variables, one either sends 10 packets per second or 30 ( if the connection is in a "good" state ). Now the article didn't really answer the questions I had in mind. Since 10 is a third of 30, how can the game still be fair then, if you only send 10 move commands instead of 30? And also the server has to keep track of the number of packets sent by each client, right? Otherwise with a hacked client or some other tools ( like wireshark ) one could send more than 30 packets and if those contain move commands, then you would walk faster than normal. But the time it takes to send a packet always is slightly different, so I guess it could happen that only 29 packets arrive per second ( or less ) or more than 30. And since my game is running at 60fps, that could mean 60 move commands per seconds. I read on an article about networking programming by Valve, that they send about 20-30 each second, so one packet contains more than only one move command. Are they stored whenever I move and when I got 2 they are send in a packet ( which would conclude the 30 packets per seconds )? Hopefully my questions are clear and even more hopefully you may have answers for me. Thanks for your time! Jan
The game is not "fair" if someone has a better experience than someone else.
This goes for network connections, GPU speed, mouse responsiveness, player skill, ...

That being said, I think "choking" the connection is the wrong answer. If the connection can't keep up, then it can't keep up, and you'd better tell the player what the problem is and then drop the connection.
enum Bool { True, False, FileNotFound };
Advertisement

But I still have to keep track of the number of packets a client sends each second, right? So that noone sends more than he should. Of course the client will try to send only 30 packets per second ( when using my client ), but you can never trust them. And a problem with that is, that it's hard to say he is allowed exactly 30 packets per second, because the slight time differences in sending packets may lead to sending 29 ( or even less ) or 31 ( or even more ) packets per second. Is this the right understanding?

Thank you for your answer, really appreciated!

Why does it matter how many packets the client sends?

I presume that your packets contain time-stamped input commands. If the client sends more packets, it will just replace whatever the previous commands were for the given time-step.
enum Bool { True, False, FileNotFound };
Not exactly related to fairness, but that situation could also be an indication of something else.

If someone is sending packets at a slightly higher rate than others, I don't see it as a big deal. Some people are on min-spec machines on dialup, other people have high-spec machines with Google Fiber. A well-written game will have fairly consistent communication patterns.

But let's imagine for some game a typical player sends around 10-20 updates per second. This is the same rate for everyone, and it is pretty steady across a large number of games. Suddenly you note one network client is sending 80 or 100 updates per second. I might not do anything differently, but if I did, I would consider it potentially a cheater or an indirect attack on the server.

I would consider it potentially a cheater or an indirect attack on the server.


Or, perhaps even more likely, a bug in your clock/timing implementation that only manifests on certain laptops with certain CPUs and chipsets.
Not that I would know anything about any specifics... (cough)
enum Bool { True, False, FileNotFound };
Advertisement
Haha. In that case, definitely something you should note.

But in any event, minor variations in traffic are probably nothing. Major variations can be flagged and investigated if someone has the time and inclination.

The server should validate the commands the players send. If they move a distance farther than what they are allow to, then the cheat detection alarm goes off. A lower spec machine/connection might send fewer packets and command count, but those commands should reflect the full movement the player is seeing on their client (and pressing the buttons for) ---- one guy sends single move steps in more packets, and the slow machine guy perhaps sends 2 steps per packet and half as many packets within the same time interval. The players both then update with effectively the same world map speed..

--------------------------------------------[size="1"]Ratings are Opinion, not Fact

This topic is closed to new replies.

Advertisement