UDP or TCP? Should we use buffered streams?

For people working on the C++ code.
Post Reply
User avatar
MirceaKitsune
Member
Posts: 867
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune
Location: Romania, Bucharest
Contact:

UDP or TCP? Should we use buffered streams?

by MirceaKitsune » Post

A continuation to this thread, which is old and less informed so I am starting a new one.

As many users probably agree, player and entity movement is one of Minetest's remaining weak spots. Other players always appear laggy and their movement irrational, no matter how fast your connection to the server is. Mob movement is also not so good... even in singleplayer at times. The set_animation function can also get out of sync from movement packages, allowing players and mobs to play the stand animation while still walking or vice-versa.

Someone clarified me what it is I'm actually looking at here, and I think I got a better understanding of it. Apparently the type of movement networking I imagine to be an improvement means one of two things: Either switching player / entity networking to TCP, or implementing a better message management system on top of UDP.

Sticking with UDP means implementing our own stream system; The server keeps sending movement packages to clients like it does currently. However, clients don't immediately apply them. They wait for a number of packages to arrive (5, 10, etc) and only after it's stacked enough of them, it starts going through the list and applying the changes visually. This means reducing the sensation of lag, at the cost of a delay. Therefore, considering this idea depends whether it's acceptable for clients to always see players moving some 0.x seconds later than they really are.

The second option is changing the system to use TCP. That's pretty much the native way of sending a constant stream of information, whereas UDP is more common for when you want to send something just once. But whether this is a good idea or not is discussable; Having Minetest use both UDP and TCP might be tricky and a lot of work, plus it could require multiple ports which is bad. Also, if a movement package is lost, player movement will stop being notified entirely... since the nature of TCP is to make sure all packages arrive in order, which has its good sides here.

Short version is, TCP is reliable but can be slower, whereas UDP is unreliable but faster. Most articles I'm reading seem to advice against using TCP for multiplayer games, because it means slower updates. Still, we have to think for ourselves. Minecraft for instance is said to use TCP only, and movement there works so well that you don't even feel other players are across a network! Wouldn't we want the same? Some articles useful to the debate:

http://1024monkeys.wordpress.com/2014/0 ... dp-vs-tcp/

http://gafferongames.com/networking-for ... dp-vs-tcp/

Personally, if someone is willing to do this effort, I'd suggest allowing both methods. Let Minetest network everything via either UDP or TCP, the choice present in a minetest.conf setting. TCP would even make sure that the effects of server-side Lua functions are applied in order to all clients! If not, stick with UDP, but at least have player / entity movement handled as a stream and teach the client to buffer packages in order to reduce perceived lag. No one should care if they see other players 0.1 seconds later as long as they see them moving properly. What is everyone's take on this, and what can / should be done at this stage?

User avatar
thetoon
Member
Posts: 106
Joined: Tue Dec 11, 2012 12:55

Re: UDP or TCP? Should we use buffered streams?

by thetoon » Post

Beside UDP and TCP, there's now SCTP - which from what I understood tries to offer the best of both worlds. Support is scarce in Windows (needs an extra-driver) but it should be OK for every version of Linux under the sun (anything post-kernel-2.4, apparently).

Sokomine
Member
Posts: 4127
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: UDP or TCP? Should we use buffered streams?

by Sokomine » Post

Best talk about this with Sapier. He seems to be the expert regarding network code, especially after what he contributed to recent releases.

It's true that movement of other players in Minetest is far less smooth than movement in i.e. Minecraft Classic. At least we're no scary 2d shapes anymore. That was a great improvement already! If movement would get smoother, it might even be possible to follow players around which try to show you where their building is. Currently, that's painful due to the rare updates of player positions. I'd say correct animation is a bonus on top of correct position.
A list of my mods can be found here.

User avatar
Calinou
Moderator
Posts: 3164
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

Re: UDP or TCP? Should we use buffered streams?

by Calinou » Post

Mob movement is unrealistic because they all accelerate instantly and can spin at an unlimited speed. It's not a matter of networking.

Animation bugs may be due because animation changes could be sent as unreliable, but I'm not sure if they are.

What you probably want in the first place is player yaw change smoothing, that's the most important thing.

Other than that, movement itself in Minetest is good enough. Remember that movement is client-side and not server-side, so you can't have anything as smooth as Warsow or Xonotic would have…
Sokomine wrote:It's true that movement of other players in Minetest is far less smooth than movement in i.e. Minecraft Classic.
content_cao.cpp, line 109 lets you change the intensity of the SmoothTranslator (default value is 0.8). Lower is smoother, but less instant. Older versions of Minetest used a lower value.

Sokomine
Member
Posts: 4127
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: UDP or TCP? Should we use buffered streams?

by Sokomine » Post

Calinou wrote: Mob movement is unrealistic because they all accelerate instantly and can spin at an unlimited speed. It's not a matter of networking.
Hmm. I'm not sure. It depends a lot on the model of the mob. For tiny animals, such as the bee or a chicken, the current movement even in simple mobs is perfect. For lager beasts, mobf does far better than simple mobs, but there's still a lot of room for improvement. Spinning around fast does work quite well for creatures that are shaped like the player and which do not extend far in x or z direction.

It's really the movement of players that I do find odd. Ever tried following a player who wanted to show you something and who tried to lead you to that spot? It's...painful. Quite often, the other player would stop somewhere - then you'd stop somewhere else - then he'd suddenly move on - all this due to blocks not beeing loaded for one of the players concerned. Even if both players hold w+e all the time, it's more like a race, with both of them overtaking each other frequently. And beware of direction changes! It's easy to loose sight of the player leading you somewhere if he speeds off into another direction. There's no smooth transition of the other player from point A to point B - he was last seen running on the spot on point A, then mysteriously showed up at point B again. Or at point C, if you didn't spot him in time.

Would it be possible for clients to send to the server *how* their player moved from A to B?
A list of my mods can be found here.

User avatar
MirceaKitsune
Member
Posts: 867
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune
Location: Romania, Bucharest
Contact:

Re: UDP or TCP? Should we use buffered streams?

by MirceaKitsune » Post

Never tried following another player in Minetest that I know of, and experiencing this. It sounds really bad however. If movement networking is so unoptimized you can barely track someone, I really hope an idea to fix it can be thought of.

User avatar
Krock
Developer
Posts: 4562
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: UDP or TCP? Should we use buffered streams?

by Krock » Post

It's good as it is now. At a point, it's not possible to make it faster.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
MirceaKitsune
Member
Posts: 867
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune
Location: Romania, Bucharest
Contact:

Re: UDP or TCP? Should we use buffered streams?

by MirceaKitsune » Post

Krock wrote:It's good as it is now. At a point, it's not possible to make it faster.
Good as it is now no, in my opinion. It seems most games actually use UDP... such as everything on the Quake engine. Yet even there networking is a lot better, and you don't see players snapping around the place or getting out of sync over the smallest lag. I believe this eventually needs to be improved somehow, even if not necessarily TCP.

User avatar
rubenwardy
Moderator
Posts: 6271
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: UDP or TCP? Should we use buffered streams?

by rubenwardy » Post

'Good enough' isnt good enough. We should strive to excellence.

User avatar
MirceaKitsune
Member
Posts: 867
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune
Location: Romania, Bucharest
Contact:

Re: UDP or TCP? Should we use buffered streams?

by MirceaKitsune » Post

rubenwardy wrote:'Good enough' isnt good enough. We should strive to excellence.
I'd actually apply this thinking to Minetest. Since the engine has so much potential and so many features already, it's sad to see it put down by little issues like this. When you can't even follow a player around on a server with a good connection, it means the engine sucks and isn't fully useable for something serious... even if it has a ton of awesome and well designed features. That's why I think this and other essential bugs need to be corrected someday not too far from now.

User avatar
hoodedice
Member
Posts: 1372
Joined: Sat Jul 06, 2013 06:33
GitHub: hoodedice
IRC: hoodedice
In-game: hoodedice
Location: world
Contact:

Re: UDP or TCP? Should we use buffered streams?

by hoodedice » Post

MirceaKitsune wrote:
rubenwardy wrote:'Good enough' isnt good enough. We should strive to excellence.
I'd actually apply this thinking to Minetest. Since the engine has so much potential and so many features already, it's sad to see it put down by little issues like this. When you can't even follow a player around on a server with a good connection, it means the engine sucks and isn't fully useable for something serious... even if it has a ton of awesome and well designed features. That's why I think this and other essential bugs need to be corrected someday not too far from now.
Well, too much of that is bad too. Look at FreeMiner *wink wink*
7:42 PM - Bauglio: I think if you go to staples you could steal firmware from a fax machine that would run better than win10 does on any platform
7:42 PM - Bauglio: so fudge the stable build
7:43 PM - Bauglio: get the staple build

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest