Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimum Update frequency for a client server based multiplayer game

I am making a multiplayer game in c++ :

The clients simply take commands from the users, calculate their player's new position and communicate it to the server. The server accepts such position updates from all clients and broadcasts the same about each to every. In such a scenario, what parameters should determine the time gap between consecutive updates ( i dont want too many updates, hence choking the n/w). I was thinking, the max ping among the clients should be one of the contributing parameters.

Secondly, how do i determine this ping/latency of the clients ? Other threads on this forum suggest using "raw sockets" or using the system's ping command and collecting the output from a file .. do they mean using something like system('ping "client ip add" > file') or forking and exec'ing a ping command..

like image 760
AnkurVj Avatar asked Oct 18 '10 14:10

AnkurVj


1 Answers

This answer is going to depend on what kind of a multiplayer game you are talking about. It sounds like you are talking about an mmo-type game. If this is the case then it will make sense to use an 'ephemeral channel', which basically means the client can generate multiple movement packets per second, but only the most recent movement packets are sent to the server. If you use a technique like this then you should base your update rate on the rate in which players move in the game. By doing this you can ensure that players don't slip through walls or run past a trigger too quickly.

Your second question I would use boost::asio to set up a service that your clients can 'ping' by sending a simple packet, then the service would send a message back to the client and you could determine the time it took to get the packet returned.

like image 95
Kyle C Avatar answered Oct 13 '22 00:10

Kyle C