MMORPG and the ol' UDP vs TCP

Started by
68 comments, last by hplus0603 18 years, 10 months ago
I'm working on an MMORPG style game for a school project. It is a client-server model with a database as a backend. I'm wondering what protocols should be used for what. I know the UDP vs TCP argument is a common question and is discussed in the FAQ. I need to take it a little further than what is covered there. The game is ship based and will involve combat between ships. So, for ship movement and cannon ball movement, ie the twitch gaming portions of the game, I'm thinking UDP is the best way to go (as seems to be the common approach). So I'll use UDP and interpolation to handle that. As for the other elements of the game, I'm wondering if TCP is the best way to go, thus using both protocols. First of all, is it common that games will use both protocols, or do they often times pick one and settle on it. Is there a performance motivation to settling on one packet or using both. The other elements of the game: Users will dock at ports. The user then requests the port information from the server and displays it when its received. Port information is sent only on a request-basis and thus, a lost packet cannot merely be ignored in favor or a later update. Users will fire cannon balls in combat and will need to tell the server that such an event has occurred. Once cannon balls are fired, the cannons must be reloaded. Thus, if the user fired the cannons and the packet declaring this never made it to the server, the user's cannons would be unloaded and they would have to wait for them to reload again without ever reaping the benefits of the lost shot. There will be other similar events in the game. Is using both TCP and UDP for this game a good model to follow? Or would people suggest one over the other. Next, I have a few questions that are specific to the MMORPG genre. I'm not sure how to handle things like user inventory and statistics. Do you maintain a copy of the users inventory on the client side, only updating the server when the inventory changes? Or do you store the inventory on the server and fetch it any time the user requests to see their inventory? The quick answer that comes to mind for me is that it would be best to manage it on the user side and just update the server as necessary. This seems to achieve the least amount of server interaction and ensures that things happen in a timely manner on the client side. However, it seems more prone to hacking (Like the Diablo complex)... So how do games handle issues like that? I know validating any information that is given to the server is important, but are there any other tricks?
Advertisement
TCP would be my recomendation because you can't pull the Quake3 trick of sending a time encoded state package, because if it is a MMO, then there is alot of data that NEEDS to get to it's destination (I want to do x/y/z, and don't want to deal with race conditions, or having to resend data).

Anyone have the look at Quake3 network code story hanging around? It's an intresting read, but it only really works for small enviroments where the priority is speed and not efficiancy or realiablity. Mind you, that system can be used over TCP or UDP. Just TCP automatically made sure the data arrived in a certain order.

EDIT: Found it
http://www.bookofhook.com/Article/GameDevelopment/TheQuake3NetworkingModel.html

Also See the Forum FAQ about TCP v UDP
http://www.gamedev.net/community/forums/showfaq.asp?forum_id=15

So anyways: TCP
-Scott
I agree that TCP should probably be used for most forms of communication as I need the packets to be reliably delivered.

However, I would still like to take advantage of interpolating users positions as they will be quickly moving around. Thus, I don't need to spend time waiting for a packet detailing the position of a ship that got lost when I already have the next update. So that implies I should be using UDP for that aspect of the game (as I mentioned in my post).

I did spend the time to read the FAQ as well as read over several of the articles here before I posted. The FAQ states exactly: "For role playing games, the story is less clear -- action-based RPGs with lots of kinetics, like City of Heroes, use UDP, whereas slower RPGs and MUDs often stay with TCP. For action-based games like first-person shooters or racers, you should absolutely use UDP." This game is an RPG where much of the game takes place in boats which are firing cannons back and forth. Thus, it is a bit of an action game. Though not as action filled as say Planetside. At the same time, there are less action packed areas of the game play. Anyway, my question still remains, is a combination of the two an appropriate approach or is it generally better to pick one? And I guess now, an add on, if just one, then which? It seems to me that the easy answer to that last question is TCP, but then how do you deal with lost position update packets, other than just letting the game be jumpy and laggy...
Oops! Forgot to log in for the last post... So just FYI, the last post from Anonymous was from me (the original author of the question).
Doing two may be benificial, but I'd suggest working with TCP now, leaving in hooks for UDP later. I think it would be more benificial to get the project up and running then worrying about latancy issues this early. As pointed out in that Quake 3 article I linked, doing both TCP and UDP at the same time introduces intresting and very hard to track bugs.
-Scott
I've been hearing that World of Warcraft is done with TCP for their communication.
(It seems fast enough to me *wink*)

Probably also helps to deal with security/hacking issues that are much harder to track/prevent with straight UDP..

Learn about game programming!Games Programming in C++: Start to Finish
Quote:(It seems fast enough to me *wink*)


Yeah, that's why the FAQ talks about the "speed" of the two protocols.

Rumor has it that one of the reasons they had such lag and server queue problems initially was that they were using TCP, and the number of connections per server was just too much. With TCP, there is overhead per connected user in the form of a separate socket; with UDP, you can push that into user space and a simple hash table.

For the project described here, however, I doubt that either protocol will get in the way; pick one (or better: pick an existing library) and run with it.
enum Bool { True, False, FileNotFound };
They still are using TCP afaik. Unless something has changed in the last two weeks. I'll check again when I get home.

Also the lag issues are still present. Whether this is a result of using TCP or just the high volume of users, whos to say other than Blizzard.

I have ran some TCPdump's on the game while playing and one thing that I noticed is when you use the mouse to "look around" the client pelts the server with an insane number of updates/sec. I didnt count, but I'd say on the order of 30 packets/sec.

With that said, TCP seems to be working good for the most part.


-=[ Megahertz ]=-
-=[Megahertz]=-
RakNet uses UDP, but I gives you all the advantages of TCP through software.

It allows you to send priority messages, packet ordering, etc.

rekkarsoft.com
GameDev Product Review

I'd really suggest using it. I'm doing the same thing for my school project (actually 2 school projects), except my game is tile-based.
The G'Bro GameDev Society! -The Southeastern US GameDev Gathering Group
Depends on the problem space and type of game.

RunUO is an Ultima Online emulator written in C# that has had up to 3200 connected clients on a quad Xeon box. Of course an isometric point and click game uses a hell of a lot less traffic (movement/view) than a 3D game.

You could also look at Dawn of Light which is a Dark Age of Camelot emulator written in C# that is a TCP/UDP hybrid approach. Basically the movement system works off UDP and for things that need to get to the server TCP works well.

So UO uses TCP, WoW uses TCP, Camelot uses TCP w/ UDP for movement, AC uses UDP, City of Heroes UDP, EQ TCP w/ UDP.

I'm not so sure if it is fair to say that WoW is laggy because of using TCP over UDP quite yet unless we see them change network subsystems.. as AC had a hell of a lot more lag than WoW ever has but it is using UDP.

So really it is up to the problem space, at least in my opinion I may be wrong on this.

This topic is closed to new replies.

Advertisement