Using zlib to compress traffic

This is a discussion on Using zlib to compress traffic within the Networking/Device Communication forums, part of the General Programming Boards category; Greetings all, Im writing a small text based mmorpg and its going pretty good. Luckily im not stuck at the ...

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    21

    Using zlib to compress traffic

    Greetings all,

    Im writing a small text based mmorpg and its going pretty good. Luckily im not stuck at the moment but I was told something a while ago and am now contemplating using it within the game. A friend suggested I should use zlib to compress my tcp packets both from the server and the clients and simply uncompress them each end as it could increase performance.

    Heres my question.. Has anyone else tried this method to speed up traffic using tcp? I need to try and figure out if there will be any performance gain from having to compress and un-compress the other end rather than just sending data as normal. It might be a bit of an overkill aswell for a game which maybe only 20 people will be playing at once. I dont have any encryption at the moment with my data I simply sending ID numbers along with a number of different parameters. My data packets are not huge aswell they are in fact quite small. Perhaps the max size will be the odd packet of 1-2kb.

    If anyone has any thoughts or experience in this matter I would appreciate hearing them.

    Thanks in advance.

    Stan
    Last edited by StanleyC; 08-12-2004 at 12:37 PM. Reason: Forgot something

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    Since the huge bulk of the overhead is actually sending a message, whether you send 20 bytes uncompressed or 10 bytes compressed isn't really going to make much difference.

    You might benefit on the server->client traffic since this is likely to be a larger message (containing what up to 20 people just did), rather than the client->server message which just contains what you did.

    So long as you've made a decent job of wrapping up the network interface, you can add compression and or encryption whenever you like. Like for example when you've had chance to test it in a proper real-world test environment. You could otherwise find yourself doing a whole lot of work for no real benefit.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Vehiclular Traffic Monitoring
    By Renarudo in forum C++ Programming
    Replies: 1
    Last Post: 07-22-2008, 06:58 PM
  2. Implementing Zlib function
    By vin_pll in forum C++ Programming
    Replies: 6
    Last Post: 01-24-2008, 10:37 PM
  3. HTTP traffic meter
    By Carlos in forum Windows Programming
    Replies: 3
    Last Post: 10-02-2003, 04:27 PM
  4. traffic cones
    By iain in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 01-27-2002, 07:56 PM
  5. So you want website traffic?
    By Betazep in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-19-2002, 12:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21