150 points · by rcsorensen · 12y ago · 107 comments
Lesson Two: TCP is evil, don't use TCP for a game...
Lesson Three: Use UDP...
and the like are all "of course" solutions now, but they weren't then. How do you build something fast and reliable over something slow and creaky? Who knows.
The shoulders of giants have gotten a lot taller since then.
First, Widelands is a real-time game but with a slow pace, so relatively high latency is easy to tolerate. Second, the internet is simply more reliable today than it was 15 years ago, especially if the bandwidth that you use is small relative to the Mb/s connections that are common today.
Exactly. TCP is fine if you can tolerate 3-5 round trip times' worth of latency. RTT to the other side of the world is ~135 milliseconds at the speed of light. That's roughly one second of latency for a less than optimal network connection. Probably just fine for an RTS game or a not quite real time MMO.
It is not, however, good enough for fast paced FPS games, racing sims or (space) flight sims. They will keep on working better with UDP as long as there will be latency and packet loss in the Internet.
This makes TCP much more feasible (and sometimes necessary as getting UDP packets through various NAT routers can be difficult).
Back then, they were probably right to use UDP, but I found it funny how all the reasons they gave why TCP sucked were things their workarounds were equally bad at.
I realize that it was a huge technological leap for early 1997, I really do. But the product was shit and we paid good money for it.
Edit: I meant to add something. 11 months after XvT was released, Volition Software released Descent: Freespace. It was everything that XvT should have been. Nobody noticed it but whatever. (I admit I'm probably being unfair since the internet was changing so fast back then)
I have yet to see anything designed with UDP instead of TCP that didn't end up reimplementing TCP itself, poorly.
I'm not sure what else you can do without breaking portability or tweaking OS parameters.
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.
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’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.
> 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.
Later on you could count on corvettes and cruisers that reinforced your side (though they were always late) and you felt the tide of the war turning.
I never got that feeling again, maybe because I am older. Or maybe because DX 11.1b support is much more important for a game and story is considered overrated.
Btw. how come nobody really cashed in on the Battlestar Galactica hype?
BSG online has a bit of a following, but being browser based I gave it a miss
X-Wing Alliance was also exceptionally good, including Em-Kay shouting "Check your mail!" and "There's no point even TRYING any more!"
Disclaimer: used to work on that project, still have friends who do.
I was very hoping for this. But the (few) maps are horrible for a "space" sim. The MMO fighter/item-part killed the rest of my possible motivation.
I really hope Disney will come up with something real in the future. I've been building Maps vor TIE-Fighter, X-Wing and XvT back in their days for The Emperors Hammer (that still exists out there!) so I hope they won't forget about the creativity in the community.
SWTOR forgot completly.
Its predecessors (Tie Fight and X-Wing before it) had large, complex and well written story lines which following engaging missions paths. This was 80% of the game, as the graphics were relatively poor compared to sprite-based shooters of the time.
I remember the deep disappointment of booting XVT for the first time and realizing it had no story, and a terrible UX. I was launched into an offline lobby and only had the option to play some very uninteresting and un-engaging missions.
Put that on top of a completely unplayable multiplayer mode, it ended being a poor decision to make a game based on a technology they couldn't support -- when a perfectly valid offline story mode would have made up for it fine. So instead they charged another 49.99 on top of 69.99 for an add-on (and people complain about IAP) that gave the features the original box promised.
For me, those two are the pinnacle of the space-shooter genre, even more so as Freespace 2 was open sourced and attracted a very large community of not just programmers but also artists which resulted in a game that's still being active developped with quite current graphics and sound.
You can get the game on gog.com and use the Java-based[1] installer to get the open source engine and assets installed
[1]: http://www.hard-light.net/wiki/index.php/FreeSpace_Open_Inst...
The multiplayer is so great that we still gather together every year and fly missions for a night. Balance of Power added great coop missions that needed team-play and sticking to your role.
The most interesting thing - historically - about XvT was that it was one of the first games that completely skipped single-player campaigns for multiplayer. Everyone screamed "madness" back then. See where it got us ;).
I think an interesting project would be creating a modern graphics engine that can parse and run the various X-Wing game data files. The XvT and X-Wing Alliance engines run ok on modern Windows but still have some compatibility issues (graphics glitches, etc). If a modern graphics engine (written in Unity or some such) could capture the look and feel of the X-Wing games, that would be great. It would be even better if it was an official game and not someone's open source project that never gets finished :(
Until I played Killer Instinct, the only decent fighting games that I've run across have been based on the GGPO. Judging from my own and others experience, KI's network code is this generation's equivalent of QuakeWorld. I hope the developers of KI publish a paper like this one, detailing their technique.
X-Wing, Tie Fighter (and its mission packs) and X-Wing Alliance were awesome. XvT not so much :(
Here be dragons, my friend.
> On some connections one in five packets are dropped
And then shortly afterwards that
> This would only fail if two consecutive packets were dropped, and this seemed unlikely.
Hrm. I think I'm beginning to see the problem here, and it isn't the internet. Still, fun to read about the battle scars of remote gaming's early days.
> It turned out that on some connections, about every fifth packet we sent would just disappear into the Ethernet.
Due to the way packet-queueing works, it is actually a reasonable failure-expectation. If the network is on the edge of congestion, a packet will be dropped as there's no space in the queue, but another packet will be sent and clear space in the queue before a second packet has a chance to be lost. In many near-congestion failure modes, it is literally every fifth or tenth or twentieth packet that gets dropped. This is actually the basis of how TCP's congestion-control works, too.
There's something magical about the internet where any technical post results in a slew of commenters trying to show they are smarter than the topic author. Good job.
I think their requirements were to transmit every action the other player(s) took, so it seems like things would still be failing all over the place. But maybe occasionally insane results are better than occasionally blocked.
"We actually used the 'synchronous' version for quite awhile. It was good enough to test with, so finishing the network code was considered a lower priority than the other issues we needed to address at that stage of development."
And the result was, rather predictably:
"When we finally came back to the network code we were behind schedule, and that affected some of the decisions we make later in the process. And it meant we were absolutely committed to the complexity of the missions, and the user interface."
First of all, 1999 was 15 years ago but since I started an ISP from the ground up in 1996, I know for a fact that the Internet wasn't quite the dark ages at that time he tries to make it seem. 28.8k modems were around in '94 and by '96 to '97, 56k were standard. And maybe I was just in a lucky area, but I had a Comcast cable modem in 1996 (http://corporate.comcast.com/news-information/timeline).
Getting beyond that, he complains about everything. TCP sucks, UDP sucks, the Internet sucks. A clue for anyone with introspection is when you think everything but you sucks, it's actually you that sucks.
For an example of much more highly skilled engineers working on an arguably even bigger engineering problem in 1996 on a much larger game, read here:
http://www.gamasutra.com/view/feature/3094/1500_archers_on_a...
Currently working on an iOS project using a similar system, which so far works great. A challenge I am facing right now is pathfinding in conjunction with synchronous multiplayer. Pathfinding can take a decent chunk of cpu time on lower-end devices, but you can't really multi-thread it since you need all players to calculate the same paths on the same simulation ticks lol... so might come down to rate-limiting the amount of units that can re-path on a given sim-tick.
Making multiplayer games is fun lol... :)
Just a thought experiment I was having. What if the game state was represented as a very large N dimensional vector. The most significant bits are sent until the players report that they match. then the next significant bits. then the next after that. Adapt the granularity of an update to the current throughput. If a player disconnects for 10, 20 seconds their game state re-syncs smoothly and gradually instead of in a jump cut?
That is exactly why TCP has the "slow start" protocol. I am sympathetic to their problems, though. I understand that the implementations of TCP they had access to had way too much latency, and that back then, there probably wasn't much tuning one could do on the outside. What they did is a clever hack (message n has a copy of n-1) that takes advantage of the fact that they don't have to send much data in total.
Does this mean WebSockets are unusable for most type of multiplayer games?
Yes, it means that WebSockets are unusable for real-time multiplayer games like fast paced FPS games. That may not be "most" multiplayer games, though.
If you're planning a game on top of WebSockets (or TCP), the gameplay should be tolerant of 3-5 times the network round trip time.
http://gafferongames.com/networking-for-game-programmers/udp...
The leased line has 50 ms of very predictable latency and 56 kbps of very predictable throughput. The 56k PPP session has an unpredictable 300-500 ms of latency and a constantly varying capacity of 2.4 to 56 kbps thanks to high noise and ugly compression schemes.
Lots of things that worked perfectly well on the relatively crude internet of the 1980s were real pains in the ass on "high-tech" modems in the 1990s.
--
edit: a specific example would be X11. An emacs X11 session was totally usable on a leased line or ISDN, despite the low bandwidth, because they delivered low latency and packet loss. It was hellish on any kind of a home dial-up.
During the late '90's, I was a sysadmin for a fairly major computer science department. One of my periodic tasks, and my test of Internet health, was to download and build gcc. When I started, getting gcc took a while. By 1999 and later, when the Internet had been discovered, downloading gcc took several hours and frequently several retries.
You don't know how easy you have it now!
They obviously hadn't heard of Netrek, the third multiplayer internet game ever, first released in 1988. http://en.wikipedia.org/wiki/Netrek
Netrek's macro system was another feature I wish were more widely adopted in games. Receiver-configurable distresses (RCDs) allowed a sender to publish named kinds of messages ("help at location, intercepting X, ship status, bombing planet, etc.) but receivers control the formatting. So I can set up my client to only show your hull+fuel for general distress calls but more data based on the kind of message.
Not this game. You're probably remembering TIE Fighter.
X-Wing vs. TIE Fighter ran on Windows 9x and required DirectX. That's why the article was talking about DirectPlay.