Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you build something fast and reliable over something slow and creaky? Who knows

You use TCP, which they already had.

The article describes TCP as evil, but then they go on to reimplement TCP over UDP in a way more inefficient manner, not realizing their problems with TCP were problems with the internet. They'll hardly have been the first ones to do so, either.



> The article describes TCP as evil, but then they go on to reimplement TCP over UDP in a way more inefficient manner, not realizing their problems with TCP were problems with the internet.

Almost every real-time game out there "re-implements" parts of TCP over UDP because the mechanisms that TCP use are unsuitable for real time communication.

If a packet goes lost over a 150 ms latency (something modern game engines manage gracefully), the server will receive a resent packet that contains information from 450 ms ago. Additionally a packet going lost with TCP will inhibit the delivery of successfully received packets that were sent after the one gone missing. Re-sending an old packet (like TCP does) is worse than not receiving the packet at all in multi player gaming.

You do need (semi-) reliable delivery, connection management and flow control over UDP but implemented differently than TCP. When a packet goes lost, you send the up-to-date information instead, not what was relevant 300 ms ago.

TCP is a wonderful protocol but absolutely useless for multi player gaming. Everyone who has been writing netcode for real-time games (there are exceptions like RTS, MMORPG, etc) knows that.


I think “real-time” does not mean what you think it means.

I’ve read a lot of things like “TCP is not suitable for real-time online games”, in this thread, where the author of this sentence excludes RTS, MMORPG, etc. As if these were not real-time games.

According to http://en.wikipedia.org/wiki/Real-time_game#Real-time (and also the fact the RTS means real-time strategy), any game that is not turn based is a real-time game.

It’s not just you, but I had to choose one of the posts in this thread for my response. Saying “TCP is a wonderful protocol but absolutely useless for multi player gaming” is just plain wrong. A lot of online, real-time games are using TCP. Saying that TCP is useless for multi player gaming is really misleading and I’m tired of reading this. There are a lot of valid reason to choose TCP over UDP (for example the fact that your game doesn’t require any round-trip to be shorter than, say, 500ms, because that’s how the engine works). Of course, TCP would not really be suitable for an FPS like quake, but that’s only one case of real-time game, there are a lot of different kind of games, for which TCP is the best choice.


> I think “real-time” does not mean what you think it means.

There are various definitions of "real-time" and we should not make this an argument about semantics. I meant real-time in the sense of "a soft real time software system" or the "Quake" sense of the word.

http://en.wikipedia.org/wiki/Real-time_computing#Criteria_fo...

In other words, "real-time" in the sense that missing deadlines will mean that the quality of service is degraded. Deadlines here mean delivering the packets in time for the next simulation timestep.

Yes, TCP can be successfully used in games classified as "real time" as opposed to turn based, such as RTS games or MMORPGs. But when analyzing it them from a software standpoint, they might be just very fast turn based games.

Here's another interesting piece about networking multiplayer games, this time in an RTS game (Age of Empires): http://www.gamasutra.com/view/feature/3094/1500_archers_on_a...

The solution they used was essentially a 15 frames per second lock step loop. It looks like real time to the player but from a software standpoint it really isn't.

You and I agree on everything except the definition of "real-time". There are applications where TCP works well and applications where UDP is better. I'm sorry if my words were a bit overgeneralized and it annoys you.


> In other words, "real-time" in the sense that missing deadlines will mean that the quality of service is degraded. Deadlines here mean delivering the packets in time for the next simulation timestep.

Yeah, that’s what happens in most RTS, if the feedback for the action you sent doesn’t come back before Xms, then the game pauses and waits (for example Starcraft 2 does that).

And I know the lock step mechanism used in some RTS, I’m implementing one myself. But I don’t see how it makes it non-real-time. If quake or teeworlds associates a network packet (containing a player-position) with a frame, does that make it really-fast turn-based game (with turns being frames, or ticks, or what you want to call them)?

That being said,

> You and I agree on everything except the definition of "real-time".

No, the “real-time” word is really not that important to me, I mostly disagree with you saying “TCP is […] useless for multi player gaming.”

RTS, or MMORPG, or turn-based tactical RPG, or card games are not “some exceptions”. They probably even represent a huge proportion of the multiplayer games out there. I now understand that you were talking about “fast-paced action games like quake or the likes”, but that really didn’t sound like it.

> I'm sorry if my words were a bit overgeneralized and it annoys you.

This is not just you, I’ve seen a lot of these “— TCP sucks for all online game purposes! — but what about all these cases were it’s fine? — Oh, I was obviously talking about those other cases”

But that’s ok, I’ve made my point public instead of grumbling in my head, now I’m fine and we can move on. :)


> > In other words, "real-time" in the sense that missing deadlines will mean that the quality of service is degraded. Deadlines here mean delivering the packets in time for the next simulation timestep.

> Yeah, that’s what happens in most RTS, if the feedback for the action you sent doesn’t come back before Xms, then the game pauses and waits (for example Starcraft 2 does that).

To elaborate on this further, I would not consider Starcraft 2 a real time system, because it can stop the world and wait. It is annoying when it starts lagging but produces the "correct" results anyway.

This is not the case for simulators that deal with "continuous" physics updates. All clients are simulating the world in parallel and no one has the authority to stop everything. If lag gets significant, the results will become more and more incorrect and the view of the world that the clients have will diverge more. There's always some inaccuracy but that is tolerable to some degree.

This is by no means the only or necessarily the correct definition of real time but that's where I draw the distinction when it comes to multiplayer games. Someone might not agree with me on this one.


Could you provide an example of a real-time game?


For some definition of real-time, a racing simulator is real-time because it will produce incorrect results (with catastrophic consequences) if there is too much latency. An RTS like Age of Empires is not because it will only lag annoyingly but still produce correct results.



No. They implemented forward error correction, which is a proper thing not supported by TCP.


The article even contains an explanation why TCP does not, and NEVER should, include forward error correction :

> Our simple re-sending mechanism just didn’t perform well enough under these conditions. It was quite common for a re-sent packet to be dropped, and we saw several cases where the original packet and 4 or 5 re-sends of that packet would all be dropped. We were re-sending so many packets, we were starting to exceed the bandwidth of the modem, and then the latency would start to climb, and all hell would break loose.

(then they implemented a -very bad- form of forward error correction in their packets to almost never need retransmissions)

This effectively ignores available bandwidth, and it worked because they were only using tiny amounts of bandwidth, so cheating helped them in this case, without ill effects. It is a dangerous game however. The problem is one of unfairness. If you implement your connections with forward error correction you will have an advantage over others, as you will not follow congestion signals while others do.

And then this happens :

http://en.wikipedia.org/wiki/Congestive_collapse#Congestive_...

TLDR: massive traffic on nearly every link in the network. Effective throughput almost nonexistent. You know, like being stuck on comcast.


I am not suggesting Forward Error correction is a good idea on TCP. They put UDP and forward error correction together which is a good idea (see video/audio streaming over internet). The parent seemed to think they had reimplemented TCP badly, which they didn't, they implemented quite a different protocol which utilised forward error correction which was a good idea and something they would not have been able to do by building on vanilla TCP.

So their prototcol probably ended up messier than it should of been but they were pioneers fixing problems as they cropped up so that's understandable.


so how would you have solved it? your explanation here is pretty unsatisfying since they did use TCP, and it didn't work.


There also was a quite interesting protocol T/TCP - which was something between TCP and UDP.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: