Compression :(

Started by
8 comments, last by osh 20 years, 3 months ago
Hello again! I would like to compress my packet data, but I can''t find appropriate algorithm. I know that somebody say that it''s useless to compress such small amount of data as packet is, but I want to try it. Only one algo I found to be good enought is on www.rakkarsoft.com pages in their manual in bitstreams section, but I don''t understand it, so can u eventually explain it to me? Thx
Advertisement
What are you doing this for, and how experienced are you with socket programming? I would try using a compression library (ie. ZLIB) on files before I would attept to compress network data.

I would check SF.net for compression libraries.
Assuming you aren''t sending large amounts of data at once (only really happens in some turn based games and for automatic downloading of mods) then general purpose compression won''t help at all, it will hinder (an adaptive stream compression algorithm might compress slightly, but only if your data was bloated to begin with). You''re going to have to use specialized (data specific) compression , and that means you''ll just have to take a look at what data you''re sending, and what format you''re sending it in. A simple example is if you are sending 7 boolean values, you should send them as a single byte, not as 7 bytes.
Check out these open-source ZIP libraries.

http://www.programmersheaven.com/zone15/cat158/index.htm

Kuphryn
And consider some form of system that recognises the sort of data it''s getting, ensuring that you don''t send out the entire dump every time, you can just send what has changed and the server/client knows how to deal with this intelligently.
Hmm... Back in the good old MODEM days, there were such
options as XMODEM, YMODEM, ZMODEM...etc. Would those help?

If I remember correctly, ZMODEM had the best compression. But
it''s been a while since I looked at it, so I could be wrong.


Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
Well, I''m not so experienced, but I use SDLNet to do a higher level classes whitch ensures reliablitity, ordering and so for UDP...
I plan to implent it in MMO game with some ''revolutional'' program aspects and thus I need to send as few data as possible.
Can you look at www.rakkarsoft.com - manual - bitstream overview and explain me clearly algorithm they use for compressing bytes?
Any other sugestions?
Thx
Maybe this is bad advice but: Create your game on a basic uncompressed network layer (proof of concept, as it were) and then you can start optimising the network aspects as things start kicking off.
Hello osh,

Is it the network packet data that the network software/hardware breaks apart or the packet of data your sending. I think you mean the latter.

If it is the data your sending and its very small I remember reading an article in game developer mag about compressing small packets of data.
www.gdmag.com in resources and then in source
there souurce in may02.zip for
Jonathan Blow''s Bit_Packer and Multiplication_Packer routines for packing integers. He wrote first acticle over a year ago and the 2nd one last year can''t remember the month. See if that helps you.

Any way, compression can help if you can compress your data to something smaller the a network packet would be then you can send the data in just one packet. Or just reduce the number of network packets.

Lord Bart
There are some things one can do:

If the packets are large enough(1k+), conventional packing methods might be useful. Check zlib(faster) and/or bzip2(better compression) for that. Although I think zlib has a way to stream compressed data. You might want to check that up as well.

Otherwise you can:
Quantize values such as positions and velocities by, for instance, casting them from floats to integers(quake 1-3 does this IIRC) and/or dividing them by some fixed value in a LUT(ála JPEG)
Use adaptive huffman compression over the entire stream(might be tricky if a packet gets lost though)
Pack bits
Google around a little
delete this;

This topic is closed to new replies.

Advertisement