Jump to content
Sign in to follow this  
chris330

UDP Transfer Protocol and Online Games

Recommended Posts

Hi,

I'm going to post this elsewhere too perhaps a more appropriate site. I always come here first though just in case I can catch the eye of a wandering expert. I've generally found over the years that the help I get on here is alot better than most other sites.

My question is about UDP versus TCP data transfer in networking. I'm sure someone on here will know something about this. I was checking my ping to the USA last night and discovered a latency of around 167ms when downloading. I was wondering then how on earth do multiplayer games ever manage to effectively render small arms fire accurately across all client machines? Surely if you had to wait anything up to 300ms the game would be horrible to play.

I'm wondering therefore are ping times here produced because of the use of TCP during the transfer? Is UDP effectively a much faster ping? If one client shot a machine gun and that's all their machine had to tell the server would this information go alot faster than 'normal' ping times if using UDP rather than TCP?

I know about packets arriving out of order and duplicated with UDP and that the application (read 'game') has to have error checking code using a timestamp with any data that's sent and received across the network. But assuming things arrived ok does UDP drastically reduce data transfer time? Surely you couldn't ever have a game with pings like 300ms if you were making an FPS action game!

I don't really know though to be honest. So I'm asking ;) Thanks.

Share this post


Link to post
Share on other sites

UDP is faster but it is less reliable than TCP. With TCP you can be sure the data you send is reaching its destination in the order you sent it (in a normal situation). With UDP you can't even be sure the data has arrived. It doesn't even have to arrive in the order you sent it.

I think if i had to do a multiplayer game like arma, I'd do much stuff on the client machine and maybe make a lot computable. Ballistics for one. You would just have to send which weapon fired and what the current vector of the projectile is. With that you can compute the rest. Thus having more bandwith available.

But to answer your question: In an optimal network i think UDP would be the better to use. Because of the decreased overhead.

Share this post


Link to post
Share on other sites
I was wondering then how on earth do multiplayer games ever manage to effectively render small arms fire accurately across all client machines?

They don't.

The usual practice is to do all the projectile's calculations on the machine where it was fired. Only then are the results sent to the other clients.

Share this post


Link to post
Share on other sites

Some good replies there thanks to you both.

Deadfast:

Thanks mate I think I'm just about with that one, but how they can they appear so fast on client machines? Does that mean that when I see someone shoot on screen in reality they actually fired about half a second ago? (client to server then server to me - 200ms + 200ms).

So do most client machines just try and follow the server's absolute sort of rippling up and down trying to chase the average all the time - in respect to game events?

I get the feeling there must be some pretty good prediction code going on. I've thought alot about it over the years. Something I once saw in industry might work well here.

I'm not getting too worked up about it yet though. I'm still yet to successfully send data from one program to another - on the SAME computer!! :mad: ;)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×