🎉 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!

minimizing packet size

Started by
11 comments, last by evilchicken 22 years, 9 months ago
what is the most effective way of storing say.. snapshot infomation (player xpos, ypos, zpos, ...) in a string? I already plan on using base32 for numbers, the total network traffic for my game under max load for 8 players will be almost 5.5K!
Advertisement
First you have to consider truncating the data down. If you can get away with a dynamic range of a char or short, then use them instead. You could implement your own 16 bit floating point if you need fractionals (2 methods to this , fixed point or using the same system as 32 bit floating point but just reduce number of bits for the components).

Second try not sending redundant data and use dead reckoning to extrapalate as much as possible. Reduce your update rate until you find the minimal acceptable update rate. You could also implement a variable update rate, which scales with bandwidth load , quality of connection, and importance of the packet. Also use some sort of filter on the server side to reduce the number of packets that have to be sent. Scale them based upon an imperically determined factor based upon gameplay, for instance distance from player, in line of sight, etc..

Lastly, try using compression algorithms,like the zlib compession library or an adapative algorithms, like arithimic compression.

Good Luck

-ddn
It takes 5 bits to do Base32. I''d go with either 16 or 256. Personally I use Base256 most of the time with Base16 where I can.

Other than that it''s basically what the AP said.

Ben



[Icarus Independent | Jump Down The Rabbithole | Tombstone: Vendetta ]
question, how did you do base256?
Same as you do any base.

char4 = (number/256/256/256)%256
char3 = (number/256/256)%256
char2 = (number/256)%256
char1 = number%256

To convert an int to 3 chars you do 1,2,3. For a short you just do 1,2.

to get it back you do

int = char1+char2*256+char3*256*256
short = char1+char2*256

You can change 256 to any N integer to do baseN.

If you have variables that go from 0-15 (hex) you can convert two Hex values to base256 by

char1 = hex1*16+hex2

to get it back you just do

hex1=char/16;
hex2=char%16;

Ben

[Icarus Independent | Jump Down The Rabbithole | Tombstone: Vendetta ]
I meant, how did you manage to use the extended ASCII set? whenever I try printing the value for chars of ASCII values 127 or more, I get there really wierd negative numbers.
example (cout<
AP = me.

example
  cout<<int(char(255));   


Edited by - evilchicken on October 3, 2001 6:50:59 PM
You don''t need to view it as readable text except as numbers from 0-255.

If you want to be efficient as possible you don''t waste bytes trying to make the message readable to you.

Ben

[Icarus Independent | Jump Down The Rabbithole | Tombstone: Vendetta ]
I dont care about readable text, but when I typecast a char that is of ASCII value 127 or greater, I get weird negative values. that would throw off the equations.

how did you do it?
use ''unsigned char'' (range [0..255]), instead of ''char'' (range [-128..127]).

This topic is closed to new replies.

Advertisement