Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 302
RobotEyes Avatar asked Jul 11 '12 15:07

RobotEyes


People also ask

Is TCP or UDP better for gaming?

UDP is less reliable than TCP, but is much simpler. UDP is used for situations where some data loss is acceptable, like live video/audio, or where speed is a critical factor like online gaming. While UDP is similar to TCP in that it's used to send and receive data online, there are a couple of key differences.

What protocols are used for multiplayer games?

The two most common protocols are TCP (transmission control protocol) and UDP (user datagram protocol).

How do real time multiplayer games work?

In a real-time match, the players are connected to each other simultaneously in a single game session where they exchange data messages. This form of match is suitable for implementing any type of game that requires live participation.

What protocol is widely used for multiplayer gaming and voice?

User datagram protocol (UDP) is defined as a communication protocol that is used for time-critical data transmissions such as DNS lookups, online gaming, and video streaming.


1 Answers

  • 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.

like image 197
psema4 Avatar answered Sep 18 '22 16:09

psema4