Jump to content
  • Advertisement
Sign in to follow this  
spocchio

performance of a multiplayer architecture platform game

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

Hi, i'm making a platform multiplayer game.
The levels are not tiled based and an element can have any shape (I use JBox2D)

THE network traffics is about *1.6 MB* per minuite! TOO MUCH I SUPPOSE!

The client/server system works like this:
- every element in the level have a set of sprite
- every sprite have a set of strings of the image path and the size
- in the C/S system the SPRITES are sent ONLY ONE TIME in the gameplay
and they are index(ized?)
- for each screen update the SERVER send:
--- the number of the NEW sprite that will be sent
--- the number of the elements in the screen
- for each element in the client screen (800x600) the server send 4 integers:
--- relative X and Y and WIDTH and HEIGHT of the element
--- the sprite ID
- there are about 20 or 30 elements per screen
- the screen is update every 40ms

I think I have to compress the data! any suggestion for the algorithm?
does Java supports it in a simple way?
thax!

Share this post


Link to post
Share on other sites
Advertisement
1. Some companies allow to play 3d games on server without any game client. They just capture input and send video to client. So 1.6 mb per minute is not big. Sometimes Quake Live sends 1 mb per second.
2. You need to find some logic in changes. If I want to move my character to position 5,5 from 0,0, I just send MOVE_TO_PACKET(5, 5), and every frame client processes to move to 0.01, 0.01, then move to 0.02, 0.02 etc. But there's no traffic while getting to 5,5. Maybe someone can kill you before, then you just receive DEAD_PACKET. Or if you change the target, you gen new MOVE_TO_PACKET and you character change orientation immediately.

Share this post


Link to post
Share on other sites
If your relative coordinates are restricted to 800x600 you can cut those down alot by using smaller integers:

use 9 bit integers for x/y (0-1023)
use 7 bit integers for width/height (0-127 or 1-128 since a 0 width/height is pointless) (If the minimum width or height is higher you can skew the values further) (you could let it represent 16-143 for example aswell)

this lets you pack x,y,width,height into a single 32 bit integer (9+9+7+7 = 32) , adding in a 8 bit ID you get 5 bytes of data per element instead of 20 bytes)

3) Don't send one packet for each element, IP headers will eat up alot of unnecessary bandwidth that way, instead send one or a few larger packets with multiple elements. (you might be doing this allready though)

If you send the distance an object moves rather than its coordinates each update (after the first) you can cut down the size even further as long as the velocities are restricted.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anton Vatchenko
1. Some companies allow to play 3d games on server without any game client. They just capture input and send video to client. So 1.6 mb per minute is not big. Sometimes Quake Live sends 1 mb per second.

very small consolation :~)
Quote:

2. You need to find some logic in changes. If I want to move my character to position 5,5 from 0,0, I just send MOVE_TO_PACKET(5, 5)

are you talking about interpolation? unluckly I don't find any useful documentation on the net!

Quote:
Original post by SimonForsman
If your relative coordinates are restricted to 800x600 you can cut those down alot by using smaller integers:

Yeah!! I changed my algorithm today!
using only 10 bit per integer so I've compressed the 5 integers (x,y,width,height) in only 6 bytes!
now I send 6 bytes in place of 4*4=16.
plus I set the chatupdate every 5 seconds,.
now I use 400kB per minutes, it's less than a floppy so it's OK!

[Edited by - spocchio on August 21, 2010 2:53:23 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by spocchio

THE network traffics is about *1.6 MB* per minuite! TOO MUCH I SUPPOSE!
That is 25kb/sec. A lot, but within range of effectively all broadband users today.

Quote:
I think I have to compress the data! any suggestion for the algorithm?
Java comes with zlib/zip compression. IIRC java.util.zip or somesuch.

Considering that values are well in 16-bit range represented as 32-bit ints, the above should result in 50% of more compression, with a bit of luck at 25% or so. So final transfer rate should be under 10kb/sec, which is acceptable for most purposes.

That is the "zero effort" solution, just pass socket outputStream via zip encoder and flush() both after each packet.

Share this post


Link to post
Share on other sites
The Forum FAQ talks about interpolation/extrapolation a bit.
Generally, though, you want to be sending intents, not coordinates.
Look at the "zen of networked character physics" and "1,000 archers / Age of Empires" articles for some ideas.

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!