Defining Awesome — Pump your state!
  • Status Updates

  • Pump your state!

    Written by . Posted at 5:41 pm on July 24th, 2008

    I’m feeling really pumped right now! And that’s because I’m really enjoying pumping states of entities via snapshots at each server loop!

    Well if you know what I mean… besides being a geek I am really enjoying programming the network code for Link-Dead nowadays and I decided to write something about it.

    I think the biggest challenge in producing a multiplayer game is the network code. It took me 2 years since starting to work on my engine to finally get to it. I wasn’t really thinking about it for this whole time, I was procrastinating. There was always something better to do than the net code.

    As you come to understand certain processes in human life you can’t be ignorant to them anymore. Procrastination isn’t some kind of disease. It is a strictly logical output of the way you are thinking. You don’t do things because you’re thinking about them in a wrong way, or not thinking at all. You can predict with mathematical precision whether you will finish something or not based on what is going on in your head. Procrastination absolutely isn’t an issue once you know EXACTLY what you want and you believe that what you want to do will make YOU HAPPY.

    In this particular case I wasn’t making the net code because on a deeper (subconscious?) level I felt there is something wrong with the approach I want to do. For Link-Dead I was planning nearly exactly the same network model as for Soldat. A model that I “invented” more than 5 years ago. I thought it can’t get really better that’s why I wasn’t thinking making it will make me happy (cause it could be better in certain aspects, like reliability and jerkiness). So I was sort of thinking about doing it or not doing it, not knowing exactly what I want. The solution to this is always, in my case – RESEARCH.

    Research is something I do a lot before making anything. I can spend days just on surfing the internet for ideas, reading stuff and salvaging the bookstore. Spending time on research is critical for making something of value I think.

    So what have I learnt this time? Nothing has really changed in programming multiplayer games. Unlike graphics, physics and sound evolution in games, network code has been nearly the same since the Quake days. Hardware hasn’t changed that much. Nothing to be honest changed. So I had a working network model why change something that works?

    Because it can be better. The Soldat network code was made progressively as I learnt what it is like to make a multiplayer game. That means I was making it while people were playing the game. It was trial and error. The only knowledge I had was from the limited amount of papers I found on the Internet about the subject and little chapters in books (like in Andre LaMothe’s ). To be honest there was nothing about multiplayer game coding in that time and the sad thing is, returning back to doing research about it 5 years later there still is nothing there. The same old stupid papers by inexperienced authors, in each one somebody describing the server-client network model over and over again as if it was the most complicated thing since Tabasco.

    Fortunately one person saved me. This is a person that always saves me when I’m stuck in research (his ideas were also an inspiration for the map model). I’m talking about the code guru John Carmack.

    To cut things short, the guy is a genius. In Link-Dead and Berserker I am using a modified version of his snapshot pumping model from Quake 3. It is a network model that uses an unreliable protocol UDP but every bit of data is transferred reliably between client and server. It’s a model in which you don’t have to think about reliable data (there isn’t really a distinction between reliable and unreliable). Other than that there is a precise amount of packets transferred each second. And of course it is way better than any reliable model like using TCP/IP which is basically slow and useless for games.

    This is perfect because as I’ve learnt with Soldat it’s better to send less big packets than more small ones. Experience in this case contradicted my knowledge about packet transmission (I thought it was good to send a lot of really small packets). Also this is what Carmack says: size doesn’t really matter.

    So all you guys out there smile, cause hope is not lost. It can be really large, you just have to keep it under a certain size to ensure optimal performance. I’m still talking about networking…

    The only bad thing about this model is that it uses a lot of memory and data can get really large if there is much packet loss which will result in higher pings. But I can live with that.

    As always I’m not using the exact thing that is written in the article (as with the lighting effects). I’m not really sending deltas (maybe I will but right now there is no need) and I’m using a different trick for sending reliable stuff to reduce the data size.

    If you’ve read this so far, I’ve got two surprises for you. The first one is a mind map I made while researching multiplayer game programming on the Internet. This is everything I found (not much as you see). There are links to every article I read. Of course the one with an explanation of the Quake 3 snapshot pump model is there, written by Hook from conversations he had with John over e-mail.

    Network Code Research Mind Map

    The second surprise is a preview of Berserker working in multiplayer. The game on the left is a server with loopback (I start a server and connect a player to it from the same program). The game on the right is a client connecting to the server. The video is a bit buggy but recording was slow with 2 clients. Enjoy.

    Be Sociable, Share!

    33 comments.

    1. Does it happen to you to that sometime you want to do something but you always push it forword because your “scared” that it may not turn like you expect?

      I like the video 26sec PERFECT for my internet 😛


    2. I really love it. Good work on everything your doing. I hope all your stuff comes out great.


    3. Makron666

      John Carmack Rules. Also i love the videos, but i think the lighting needs a bit of tweaking, because the dark areas are pitch black and there right next to light sources, they should be translucent.


    4. archont

    5. archont

      Damn, your site is broken.

      Anyway, what about interpolation? How much do you interpolate and predict? Is the simulation running on the server and clients or just the server?


    6. teh_ham

      Good read. A nice balance between philosophy and programming.

      I think you should get the basics done first (which you are doing I presume from your video) rather than focusing on lag compensation using delta time and whatnot.


    7. Hmmm…about those sprites… not gonna change anything about them? They still look and (more importatnly) move as same as before.

      What is it anyway that changed during your little “production crysis” ?


    8. Cool, I enjoyed this devlog quite a bit.

      Very true, the resources out there on the internet for multiplayer game programming are scarce and generally lame.


    9. Nice. That’s quite helpful for me since I currently try to get some basic multiplayer action working….thanks!
      Your method seems to work really smooth and with barely any lag.
      I’ve just been using cubic splines so far, but I get a very noticeable delay between client and server…
      How much exactly is “less” if you say it’s better to send less big packets?


    10. archont: Interpolation and dead reckoning is done by the physics engine. So the client has its own game running too but server sends entity states so that they don’t get out of sync.

      Cosmin: The graphics you see in these videos are not going to be present in the final game. I just use them for testing.

      Mungo:
      How much exactly is “less” if you say it’s better to send less big packets?
      Quake does 10 per second I think. Half-Life 20 or 30. I’m aiming for 30. Although right now it’s running at 60 but I think it will work only on LAN like that.


    11. Illuminatus

      btw: to watch the vid in “high-quality”, use this link:
      http://www.youtube.com/watch?v=eIaQcoPL5X8&fmt=18


    12. You may want to look at the Tribes networking model – this game (both T1 and T2) had awesome networking code that could handle 32+ players, even across dial-up.

      http://www.garagegames.com/articles/networking1/


    13. I just read the article on the Quake 3 networking model and all i’ve got to say is.. THAT IS AN AWESOME WAY TO NETWORK AN ACTION GAME. I read over the Tribes networking model as well.. while it presents some cool ideas, imo, it has nothing on the Q3 model in terms of pure simplicity and elegancy.

      MM, I can now see why you were so excited :0


    14. Thank you MM,

      This article helped me getting started with my own network code. I fear touching it since I have no idea, since I haven’t ever written any network code beyond the basic “Hello, World” string being sent. I’m actually working on the FMOD based audio right now which is amazing how simple, but powerful, it is.

      Please keep us posted on your designs, these kind of news posts are really useful!


    15. Dude i love your games and soldat is da best


    16. Same here. It took me a while to really figure out networking and getting it running smoothly in my game. Carmack’s advice was extremely helpful.


    17. this is unrelated to networking but you are using irrlicht no? looks like an irrlicht gui. I need to talk to you..


    18. I am the greatest.


    19. Less great person

      OMG, You really are the greatest. Keep it up!


    20. You seem to talk a lot about Quake 3 and its engine. I played a few Q3-engine based games: ET, Jedi Outcast, Jedi Academy, elite force and quake itself, each of them is overwhelmed by cheaters. So is quake3 model that good?


    21. The networking code would have little to do with hacking and things of that sort.


    22. Thats true if you consider only aimbots, but how about wallhack? I pwned at realistic soldat and at some point, aimbots aren’t a problem, the real problem were wall, speed and weapon-menu hackers. I know that server always informs clients about everyones current position, but cant this be done some other way, so that wallhacks wouldnt work? All external applications can be easily fooled (PB,sXe,etc.) but what if the networking code would include some anti-hack algorithms?


    23. The computer algorithm would have to work as well or better than a human. How do you know a player is cheating? You might be wrong also, this is not an easy task.


    24. Not easy but still possible?


    25. Are you still using RakNet, by the way?


    26. SonOfBeer

      Network seems pretty fucked up, I’m gonna need a teacher.

      It feels like you have been workin out in the last few months Michal. Keep it up and stay healthy.

      SonOf


    27. 72.232.225.70 23094
      This server’s administrator deletes the account to which he is not pleased one after another.Of course, even if not in violation, it does so.
      This server’s administrator is severe. It is an evil spirit. Help me.

      Since it does not understand where it should claim, I will carry out here.
      sry…..


    28. “72.232.225.70 23094
      This server’s administrator deletes the account to which he is not pleased one after another.Of course, even if not in violation, it does so.
      This server’s administrator is severe. It is an evil spirit. Help me.

      Since it does not understand where it should claim, I will carry out here.
      sry…..”
      1. Not the place to post it
      2. If he’s a dickhead, go to another server
      3. Even if MM cared, there’s not much he could do.


    29. thelostdweller

      when the hell is linkdead coming O_o????????????????
      if berserker is the mod, why dont finish link dead first, or atleast give us some views of some simple warfare


    30. video porn free bisexual xxx porn kiddy bisexual xxx free


    31. Buy Viagra, Viagra , Nice Site. Levitra, Levitra , Webmaster – this is a best site kjhdsf98734kj5hjkdshfkjh


    32. […] As a reminder my post about the netcode: Pump your state! […]


    33. Nice post. I was checking constantly this weblog and I am inspired!

      Extremely useful info specifically the remaining section :
      ) I handle such info much. I used to be seeking this
      particular info for a long time. Thank you and good luck.


    Post a comment.

    Links