Sign in to follow this  

Sending packets

This topic is 3735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it better to send smaller packets often, or one larger packet at a specified time interval? For example: -Player switches armor and generates: SWITCH_LEG_ARMOR message -There are also 50 people around him, so he must know their positions and their gamestates, which must be updated soon. -Player is also walking in a specified direction, updating the server with his position. So he's doing three things. 1) He's changing armor, which the server must know about to 1) update the visual of his character to other players, and 2) in case he gets dropped the server must remember his last state) 2) Updating the players around him for visuals, and checking for possible attacks and trades 3) Walking and sending the server information on where he currently is. Should I send out a small packet for each one of these messages, since perhaps he will have to update his position and world around him each frame, or send out a bigger packet at the end of all the logic, detailing everything? Also, for drawing other players, could I do a complex enumeration:
enum PlayerAppearance
{
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_BRONZE_SWORD = 1,
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_IRON_SWORD = 2,
BRONZE_LEGS_BRONZE_HELMET_BRONZE_PLATE_STEEL_SWORD = 3,
... etc.
};
And go through all possible drawing combinations of characters, so when the player is passed an array of those around him:
char array[];

for (int i = 1; i < array.size(); i++)
Draw(array[i];
The Draw function would associate the enum to possible loaded meshes in the players client memory. The only downside would be writing all these enumerations, but I think it might save time with telling the client what to draw.

Share this post


Link to post
Share on other sites
There is 20 bytes of IP header overhead, and 8 bytes of UDP header overhead per packet. (TCP uses at least 24 bytes of header, instead of the 8 for UDP). Thus, small messages waste bandwidth. Also, on server side, it makes sense to update more things having to do with a given player at once, from a locality point of view.

Thus, I would recommend sending packets to the server perhaps 10 times a second, and sending packets from the server somewhere between 4 and 20 times a second, depending on how much is going on and how bandwidth you want to use. If you send player packets 10 times a second, that means a mean latency of movement commands of 50 ms, one-way, plus transmission latency. Then sending the updates to clients 4 times a second means a mean latency of 125 ms, plus transmission latency. So, the mean latency between a command and it being reflected is < 200 ms in that case (depending on RTT), which really isn't a lot of time, unless you're playing an FPS.

Share this post


Link to post
Share on other sites

This topic is 3735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this