I've been reading the Valve article on multi-player networking which has been adapted from Yahn Bernier's 2001 paper called Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization. I'm making a realtime multi-player game using a node.js server connected to clients through socket.io and I have a few questions regarding the principles detailed below:

Entity Interpolation

[Interpolation] prevents the jittery motion this would ordinarily lead to by buffering server updates then playing them back with the gaps smoothly interpolated between. It can also protect against glitches caused by packet loss.

Client-Side Prediction

Prediction is the notion of the client predicting the effects of the local player's actions without waiting for the server to confirm them. An entity's predicted state is tested against server commands as they arrive until either a match or a mis-match is detected.

Lag Compensation

Lag compensation is the notion of the server using a player's latency to rewind time when processing [user input], in order to see what the player saw when the command was sent. In combination with prediction, lag compensation can help to combat network latency to the point of almost eliminating it from the perspective of an attacker.

  • Do the principles apply to TCP as they do to UDP and would there be any differences in implementation? I can see that the entity interpolation would not need to protect against packet loss but thats about it.

  • Can I even communicate between a server and web-browser and vice-versa using UDP and Node.js?

  • Since the paper is over a decade old are these principles still in use or has other technology appeared?

Any help would be much appreciated.

  • 1
    \$\begingroup\$ You don't actually need UDP for multiplayer games, contrary to the popular belief. Learn from the best; WoW uses TCP, and I believe many other AAA multiplayer games do. People just follow someones advice, and then they spend the next 5 months implementing a bad and slow version of TCP themselves! \$\endgroup\$ – jcora Jul 16 '12 at 16:18
  • 1
    \$\begingroup\$ (Unless, of course, you are certain that you have the knowledge and the resources to develop a decent protocol ontop of UDP that could use its advantages.) \$\endgroup\$ – jcora Jul 16 '12 at 16:22
  • 1
    \$\begingroup\$ No AAA FPS games use TCP. It truly is too slow for games that require real time updating. But since he isn't writing an action game, he should be able to get away with TCP. \$\endgroup\$ – Brendan Lesniak Jul 31 '12 at 14:49
  • \$\begingroup\$ @Yannbane Didn't know that WoW uses TCP. Seems like a lot of MMOs do, from what i could find. Makes me much more confident about writing multiplayer games with HTML5. Thanks! \$\endgroup\$ – dreta Jul 29 '13 at 21:26
  • Principles for reducing effects of lags are the same regardless of the transport protocol. Packet loss is a another topic - for many kinds of packets losing some is not critical because the next update is probably already on its way - here UPD has the advantage, but when you need to make sure a certain packet is delivered, you need custom acknowledgement code to do that with UDP
  • Node.js supports UDP, but web browsers don't (without plugins). The best real-time method for communicating between the two is Web Sockets, which is basically TCP. But for the communicating, you might want to use Socket.IO, which provides fallbacks for browsers that don't support web sockets.
  • The principles remain the same.
  • 1
    \$\begingroup\$ I guess this is outdated - WebRTC should be the way to use UDP-like communication, isn't it? \$\endgroup\$ – Nikolay Tsenkov Nov 21 '14 at 14:20

You should check out this article about Real Time Multiplayer Games in HTML5 posted on the buildnewgames.com site by Sven Bergstrom, he talks about the same things and he is using Node.JS. I have something similar going myself. I am just now researching more about the client-side prediction and interpolation and the like myself before trying to tackle the rest of it.

I believe it is definitely possible to do this with Socket.IO and Node, however the technology is still new so there is going to be little documentation and little to nothing in the way of guides on implementation. I would recommend doing what I'm doing and studying the subject in great detail in abstract high level terms and then try to implement it yourself.


I believe the technology is pretty much the same. Also, the concepts don't depend on what language you use or whether you do UDP or TCP. I've written a very detailed explanation of the whole thing here http://www.gabrielgambetta.com/fpm1.html, including pretty diagrams :)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.