Realtime multiplayer game principles for TCP and Node.js

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.


  • 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.
  • Although you won't have to deal with packet loss, you will have to deal with longer transit times. TCP is slower than UDP and you'll have to mitigate that in realtime multiplayer. I would think that these principles still apply at a fundamental level.

  • Can I even communicate between a server and web-browser and vice-versa using UDP and Node.js?
  • Generally speaking, not yet. At least not without some form of browser extension or plugin - WebSockets use TCP. That said, WebRTC (and more specifically, the PeerConnection API) is coming. When data channels are implemented, UDP communications should, in theory, be possible.

  • Since the paper is over a decade old are these principles still in use or has other technology appeared?
  • I'd be very surprised to hear that they're no longer in use - the article you've cited is practically required reading for game programmers. Ditto for new techniques not appearing, though I haven't been paying close attention to developments in this area for several years now.

    链接地址: http://www.djcxy.com/p/62236.html

    上一篇: 每次迭代SQL查询都会变慢?

    下一篇: 针对TCP和Node.js的实时多人游戏原则