Sign in to follow this  
CoolProgrammer

Online Multiplayer game-Direct Play, TCP, or UDP?

Recommended Posts

Hi! I am hoping to create an online-only multiplayer FPS army game. I am planning to have a main server that everybody connects to to join the game. Basically, my idea for the game is: -to have it be like the army, you start out as a private and have to work your way up -you get weekly wages(+extra for completing certain goals) to buy new weapons, gear, and to take training -have 2 or more armies to battle against each other I want one massive online multiplayer FPS. By that, I mean at least a few hundred people playing at once. I would create a server that would hold everybodies info; their rank, gear, amount of money, etc. Would a single computer be able to handle hundreds of people connected to it? Everything in the game would go through the server. I think my speed would be fine, maybe not enough bandwidth though... 8Mbps down, 1Mbps Up Finally, what protocol should I use? For now, I am creating the game in Blitz3D, which supports DirectPlay(directX), TCP, and UDP. I would maybe port it to BlitzMax for multiplatform support, but I couldn't use DirectPlay then. You could see the commands you can use for each here: http://www.blitzbasic.com/b3ddocs/command_list_2d_cat.php You can see that the Network, TCP, UDP, and DirectPlay command references are in a row. I think I remember reading that TCP at least can only handle 64 connections at once, which won't work. Thanks! Oh, and as a side thought, what port should I use? Since a lot of people have routers, are there certain ports that are open by default? -CoolProgrammer

Share this post


Link to post
Share on other sites
You may want to do some research - there's quite a few articles on this subject. I've found Networking for game programmers to be a good starting place.

Either way, this sounds like a difficult thing to pull off, especially if this is your first multiplayer game. You may want to scale down the number of players to a more realistic number.

Share this post


Link to post
Share on other sites
DirectPlay is deprecated and nobody has used it for ages. Forget about that. You'll want UDP for this type of game. However, you may want to aim for a bit less than "hundreds" of players. The game you are describing borders to MMOFPS, which you, frankly, won't be able to make right now. Start out on a smaller scale (32-64 players, perhaps) and work your way from there.

A good read is the description of the Quake III networking architecture, also known as the Book of Hook.

Share this post


Link to post
Share on other sites
He could mean simple hundreds of players use the server, not that each plays in one large session. UDP is the best choice for player movement, bullet vectors, just about anything that could lose a packet or two and still work. Things like character stats (health, ammo, etc) would maybe want to TCP so that is guaranteed to arrive in order so that you health doesn't jump around.

Share this post


Link to post
Share on other sites
I think for now, I will create a very basic network program/game to figure out how to use UDP. After that, I will create a very basic multiplayer FPS. I actully already have one made that has one level. I will just modify that...

Quote:
Original post by Windryder
DirectPlay is deprecated and nobody has used it for ages. Forget about that. You'll want UDP for this type of game. However, you may want to aim for a bit less than "hundreds" of players. The game you are describing borders to MMOFPS, which you, frankly, won't be able to make right now. Start out on a smaller scale (32-64 players, perhaps) and work your way from there.


Why wouldn't I be able to make one right now? Because UDP can't handle that many people, or I dn't know enought right now to make one?

Thanks for the links!

Share this post


Link to post
Share on other sites
Oh yes UDP is capable, that's not the problem.

The complicated part comes with designing, implementing and maintaining an infrastructure that scales up to more players than from what a single machine can handle. That's in part what distinguishes a MMOG from a MOG, and what makes the former a lot harder to make.

Quote:
I think my speed would be fine, maybe not enough bandwidth though... 8Mbps down, 1Mbps Up


Haha you make people lag like hell with such low upload in a conventional 10 player FPS server. :)

Share this post


Link to post
Share on other sites
Alot of games use both UDP (unreliable) and TCP (Reliable) for transport.

TCP is good for stuff which is not time sensitive -- since TCP packets are guaranteed to arrive (barring a timeout/loss of connectivity) and to arrive in order -- so they're practically fire-and-forget. Things like in-game chat text, event text, etc are good candidates for TCP.

UDP is usually used to impliment a lighter-weight and faster protocol than TCP that provides reliability and ordering in software -- so, for example, when the game notices that its missing a packet, it has to request that the information be resent. Alternatively, UDP packets might contain a 'sample-in-time' of the gameworld, that the client then uses to interpret events between packets with its best-guess. This is usually called 'dead-reakoning'

Share this post


Link to post
Share on other sites
K thanks for the replies. I did some research on TCP and UDP and am trying to get a few computers(clients) to connect to my best computer(server) and send stuff back and forth for now. Then I will try to make a little more progress.

Just wondering, what service would I need to host a server that had around 100 people connected to it at once? Would a T1(1.5Mbps up/down) be good enough? I know the speed isn't that great, it's the bandwidth, which is what would need a lot of, right?
-CoolProgrammer

Share this post


Link to post
Share on other sites
Quote:
Original post by CoolProgrammer

Just wondering, what service would I need to host a server that had around 100 people connected to it at once?


100 people doing what?

The problem with this many people in a setting like FPS is quadratic load. Player 1 fires a bullet, and that info needs to be replicated to 99 other players. Now if 100 players fire a bullet, then each of the other 99 needs to be told about it.

This is the real problem why such things are hard to scale. There is MAG, but it's doing some really funky stuff, and apparently it causes quite some issues, such as person getting killed without opponent ever loading on their screen.

WoW gets away with it since each player can send one action per second or less and response can lag by a second or two. In FPS the update rate needs to be 10-30Hz.

Quote:
8Mbps down, 1Mbps Up
Quote:
Would a T1(1.5Mbps up/down) be good enough? I know the speed isn't that great, it's the bandwidth, which is what would need a lot of, right?

100 people moving, and each seeing each other at 10 Hz = ~(50 bytes per update * 10 * 100)^2 = 2.3 GIGABYTES per second. T1 is 16000 times too narrow for this. And this doesn't even take into consideration anything but movement, such as hit and damage information, various actions, and anything else interesting.

This is where things get complicated, since area of interest algorithms come into play, delta compression, etc... FPS is still limited to 64 players for this reason. Most of the time, it won't matter. It's the worst-case scenario that really ruins the day. This is why maps tend to be fairly spread or consist of in-door rooms, so that the chance of all 64 players coming into view of each other is minimized. But each of these compromises causes other problems, mostly with consistency.

Share this post


Link to post
Share on other sites
Quote:
Original post by CoolProgrammer
K thanks for the replies. I did some research on TCP and UDP and am trying to get a few computers(clients) to connect to my best computer(server) and send stuff back and forth for now. Then I will try to make a little more progress.

Just wondering, what service would I need to host a server that had around 100 people connected to it at once? Would a T1(1.5Mbps up/down) be good enough? I know the speed isn't that great, it's the bandwidth, which is what would need a lot of, right?
-CoolProgrammer


no, 1.5Mbps up is not enough for a 100 players fps server, a game like BF2 recommends atleast 8Mbps upload for a 64 player server, for a hundred players or more i'd recommed looking at T3 or OC-1 connections, or any consumer 100/100 Ethernet based connection You generally aren't guaranteed to be able to use all the bandwidth on these since ISPs tend to sell more bandwidth than they actually have but they're fairly cheap (around 15-40 euro / month in sweden) and you almost never drop below 80Mbps upload anyway, just make sure that the connection is unmetered and that the ISP allows you to run bandwidth consuming servers on it. (and you'd still have to work fairly hard to keep bandwidth usage at an acceptable level, no matter what kind of connection you get on the server you should avoid using more than than 0.5Mbps per player since using more would greatly reduce your potential playerbase)

[Edited by - SimonForsman on May 1, 2010 9:34:46 PM]

Share this post


Link to post
Share on other sites
You haven't mentioned where you're from, but in the US, in some areas, you might be able to get fast enough Cable internet or Fiber-Optic service for 32+ players. Most 'residential' services don't allow you to run heavy-use servers, but you can usually also get 'business-class' services that do allow this, while costing a little more.

However, there's still a lot of problems with this home-hosting model. For one, what about redundancy -- Hardware, PSU, Power, Internet backbone? In a home situation, there are several individual links in the chain that, if broken, have no backup -- which will take your game entirely offline.

There are plenty of hosting companies that offer dedicated servers that they will manage for you. They've pretty universally got redundancy for hardware, power supplies, power (battery-banks, generators, 2+ power-grid connections), and they'll sell you a certain amount of bandwidth with the package (plus a reasonable rate for each gigabyte you go over), or some have unlimited packages available. Unfortunately, I don't really have a good idea of what kind of monthly transfer a dedicated gaming server would be pushing 24/7 over a month.

Then, there are dedicated gaming server hosts, like Art of War Central -- they offer dedicated gaming servers with unlimited 'gaming' bandwidth starting at a cool $99 -- which is probably what a viable home-based connection would cost you anyhow... Now, I'm sure they defray some of their costs by spreading their investment (knowlege, tools, etc) over popular games, so you won't likely get the same level of support -- but I imagine they'd be happy to host a new or lesser-known game as long as bandwidth wasn't entirely out of line with other games they host (I'm sure they've calculated average usage for 24/7 gaming servers to price their plans).

This is probably the best way to go.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ravyne
I don't really have a good idea of what kind of monthly transfer a dedicated gaming server would be pushing 24/7 over a month.


If you utilize 1Mbps average bandwidth (up and down combined) you hit a bit over 300GB / month.
BF2 tends to average at around 6Mbps (up/down combined) at 64 slot if the server is full 24/7 (IIRC its around 0.5-1.0 down / 5-5.5 up average (peak bandwidth usage is quite a bit higher))

For development purposes i suggest going with a fast home connection (unless he lives in a region that is limited to dsl/cable/etc, in which case he might have to switch to proper hosting fairly early)

Asymmetric connections such as DSL/Cable are practically useless for server hosting, so avoid those.

Share this post


Link to post
Share on other sites
It's also worth mentioning, though it may not be of direct use to you if your ambitions are high player counts, that many popular games host the actual game session on user hardware, and that the central server system only serves as a hub for matchmaking. There's a risk, particularly for PC games, that a nefarious user might have hacked the code to give them an advantage when they get host, but the risk is not much greater, if at all, than games which allow users to run dedicated servers themselves.

In fact, nearly all games on Xbox live work under this model, save the few MMOs they have. Much of the stuff on the Playstation Network also works this way, though PS devs have more freedom in this regard, so some companies have dedicated servers (Sometimes on actual playstation units, sometimes on PC hardware) -- I imagine the recent MAG as a good example of the latter. But take, for example, Halo 3 or the upcoming Reach -- that's all hosted on users' machines.

The only caveats to this are the performance considerations -- which is why most console FPS games are limited to 16 people in a single match (Some go as high as 24, but I'm not aware of any that go higher than that) -- home connections have to support that number of players, and the hardware has to be able to process the extra data and run the extra code, in addition to its regular playing duties. The advantage is not having the expense of running dedicated servers, and that the server code has access to the same hardware as the clients (which eases, for example, concerns about floating point precision and round-off, as well as sharing critical code used on the simulation side of things, such as physics) with the client code.

Share this post


Link to post
Share on other sites
Thanks for the replies. Ravyne, I looked into Art of War Central, and that looks like that would be a good route if I ever created a descent game. Also, I think I will create a small version of the game where a player can host their own server. I am trying to get going with UDP, but having trouble getting two computers on my network connected. If I create two streams on one computer (each with a different port), I can send & recieve stuff easily. Might be that my router is blocking certain ports. I will try to figure that out and then start on a small fps.
Thanks!
-CoolProgrammer

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this