🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Good packet size?

Started by
11 comments, last by MadProgrammer 22 years, 7 months ago
whats a good packet size for a packet that is just an update of the x/y/direction of a player that is sent around 10-20 times/sec? i''m trying to figger out if i can afford sending the name of the player (25 bytes long) in that packet or if i''m gonna hafta find a less-large way to uniquely represent each player
Advertisement
i usually give each player an ID number that is independent of their name or anything else... they are just assigned one when they log on, and they us it for any transmissions for that session. how many bytes that ID number would need depends on how many players you expect to support on the game at once, but you would probably be able to use less than 25 bytes.
i never got as far as optimizing my game though, so i don''t know how much that would help.

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
madprogrammer:sending a name of player is a waste of bytes! just give every player a 2bytes long number (that gives you 65535 unique players, sounds like enought) and use it instead , you save 23b per packet!!!

Also for your approach a good method is to send 2 instructions per packet (current move and last move) because packets get lost from time to time and here you have got a good chance that the following packet will include data that didn''t arrive.
It is a good method, because sending very small packets (like under 20 bytes) doesn''t make much sense as UDP header takes over 20bytes if I remember right.

With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/
With best regards, Mirek Czerwiñski
When you say it will be sent 10-20 times a second, I think that might be a bit of overkill. It would probably help if you sent say 5 packets per second. With lag, it probably wouldn''t make much difference, except clear some conjestion on the networks.

Trying is the first step towards failure.
Trying is the first step towards failure.
It might be overkill indeed, but not for real-time action games like Quake... you''ll often see 10-15 packets pumped out your modem...
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
with a good smoothing method you can''t even see differences between updates 10 times or 1 time per second...
what a good smoothing method or a site that talks ''bout them?

i was thingink you could transmit velocities, and that should work, but takes a little more server thinking time
go to articles an resources and search for ''lag'' or ''cubic splines''. these are common methods, but not the best
Well, it always depends on the type of game you''re talking about. If you''ve just got a few things floating around in space without any player input, then 1 packet per second is, of course, enough.

But if you think about action games like FPS, there is a huge difference between 1pps and 10pps. Just think about what happens when somebody fires a gun. On average, the other clients would need about 10 times the time to realize the gun was fired if you only send 1pps.

So it always depends on the situation.

Eventually you will want to send only the information that the client can''t predict itself. E.g. if there are some things floating at constant velocity (or maybe even constant acceleration), you don''t need to send their status information at all, while you will have to send player movement etc. as fast as possible.

cu,
Prefect
Widelands - laid back, free software strategy
Well, it always depends on the type of game you''re talking about. If you''ve just got a few things floating around in space without any player input, then 1 packet per second is, of course, enough.

But if you think about action games like FPS, there is a huge difference between 1pps and 10pps. Just think about what happens when somebody fires a gun. On average, the other clients would need about 10 times the time to realize the gun was fired if you only send 1pps.

So it always depends on the situation.

Eventually you will want to send only the information that the client can''t predict itself. E.g. if there are some things floating at constant velocity (or maybe even constant acceleration), you don''t need to send their status information at all, while you will have to send player movement etc. as fast as possible.

cu,
Prefect
Widelands - laid back, free software strategy

This topic is closed to new replies.

Advertisement