Jump to content
  • Advertisement
Sign in to follow this  
Viper173

Network Message Size

This topic is 5470 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

I'm currently working on making my little game network compatible. That's why I wanted to through the following question into the forum: What's the typical size of a 1st person shooter network message? I know... it strongly depends on numerous things. But I already ended up with a 3000 Byte message. firstly because I was too lazy to create a dynamic memory allocation for my machine gun projectiles, ending up with 2500 bytes just for some bullets that mainly don't even exist... what's your idea of an ok size for a message ?

Share this post


Link to post
Share on other sites
Advertisement
As small as it possibly can be, only include needed information.

If you don't mind licencing your game under the GPL OpenTNL may be worth taking a look at. It's basically the networking component of the torque game engine. It's a good library and it'll do all the hard work (networking wise) for you.

Share this post


Link to post
Share on other sites
Always try to stay well below 1500 bytes to avoid messages being chopped up at the ethernet level. For an average fps I wouldn't recommend any more than 100-200 bytes for messages, but your game might still be playable on a LAN. Since LAN-only is better than nothing I still think you should try to include it. Keeping messages small generally requires a lot of thinking in the early design stage, so it might be hard to create high performance netcode from an already existing game that wasn't designed for it.

Share this post


Link to post
Share on other sites
How the hell do you get up to 2500 bytes? Are you sending arrays of bullets in one message?
I think you can better chop this up in a lot of smaller messages.

Also, it is debatable if the status of a bullet has to be relayed over the network every network frame.
Let's assume that a bullet always travels a predictable path (linear for example) you only have to fire one message the moment the bullet is created that holds the start position and the direction. Then the client side can calculate the rest of the life of the bullet according to it's loca physics system.
For example:

**Frame 1**
- Server: Tells client bullet fires with this and that position and orientation
- Client: creates locally a new bullet
**Frame 2**
- Client: update bullet's position (it moves linear so that should be possible without the server telling us)
**Frame 3**
- Client: update bullet's position again.
- Client: Oh... bullet hit some static geometry, play an explosion animation

Or...

**Frame 1**
- Server: Tells cient bullet fires with this and that position and orientation
- Client: creates locally a new bullet
**Frame 2**
- Server: hey! bullet hit a player on this position
- Client: delete the bullet, play impact animation

So, if I count correctly, you'd need about 6 floats when a bullet is fired, and an identifier to indicate the bullet.

A quick draft:
[MSGTYPE][Identifier][Position][Orientation]
- MSGTYPE - would identify the kind of message (ie: bullet_fired, or bullet_hit_player)
- Identifier - would identify a bullet. An unique nr for every bullet fired in the game. Handy when you need to delete a bullet.
- Position - The place where the bullet was created or where the impact with another player took place.
- Orientation - only used when firing a bullet.

A quick count says 32 bytes (assuming position and orientation are 12 bytes each)

Ofcourse, this is with the assumption that a bullet has a predictable path. A humanly controlled missile would not fall in this category.

Share this post


Link to post
Share on other sites
On a side note, how many bytes is the header that is appended to a message (UDP)?
e.g. If I send a 100 byte message, how big is the actual packet that is floating around the network?

Share this post


Link to post
Share on other sites
Quote:
Original post by DBX
On a side note, how many bytes is the header that is appended to a message (UDP)?
e.g. If I send a 100 byte message, how big is the actual packet that is floating around the network?


From the top of my head... 8.
Source port
Destination port
Message size
Checksum

Add to that the 20 byte header of IP and you have 28 bytes of header.

edit: Ethernet also adds a header. A quick lookup shows a 14 byte header and 4 byte trailer.

Share this post


Link to post
Share on other sites
I wouldn't worry too much about the ethernet header though. As long as the message stays on the ethernet the headers probably won't matter much since ethernet is pretty fast (unless you are sending a huge amount of messages). It's good to keep the header size in mind when trying to estimate what kind of bandwidth the game will require. Header size is obviously mostly important if you send a lot of small messages, a 20 byte message will still require 48 bytes just from UDP/IP headers.

Does anyone know if standard modem protocols can handle UDP/IP header compression? I know that they can take care of TCP/IP, but I suppose that they might not try with a connectionless protocol. Good header compression can reduce a TCP/IP header to 3-4 bytes (instead of 40).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!