Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  UDP vs. TCP......round 2134  (Read 2901 times)
0 Members and 1 Guest are viewing this topic.
Offline jared888

Senior Newbie




Eat your own shorts. Leave mine alone.


« Posted 2004-04-14 20:44:56 »

Hey,

If I want fast AND reliable, do I use UDP and write my own error/datagram tracking into my app?

Beware the rabbit of the mind, for it gnaweth on the carrot of the soul.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #1 - Posted 2004-04-14 21:10:57 »

No. But if you want reliable and out-of-order delivery, then yes.

Whether or not it's "faster" depends upon the exact traffic patterns of your game (in general, it will often be slower).

And don't bother writing your own unless you're trying to get a job in writing network protocols. There's too many free ones for it to be worth re-inventing the wheel (would you write your own software 3D renderer without OpenGL? Obviously a few would, but usually only those wanting to prove their abilities at 3D maths)

malloc will be first against the wall when the revolution comes...
Offline jared888

Senior Newbie




Eat your own shorts. Leave mine alone.


« Reply #2 - Posted 2004-04-15 09:37:05 »

I don't actually want to re-write networking code. I would use the existing sockets classes to build my communications between game components (I have a 3 tier plan).

So, what you are sayting, is that if I want stuff to be reliably delivered in order, I want to use TCP, and it won't be significantly slower than UDP?

Thanks!


Beware the rabbit of the mind, for it gnaweth on the carrot of the soul.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #3 - Posted 2004-04-15 09:46:34 »

For sure not slower than a protocol on top of UDP with these features.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline jared888

Senior Newbie




Eat your own shorts. Leave mine alone.


« Reply #4 - Posted 2004-04-15 15:57:05 »

Thanks all, y'all just made my life a heckuva lot easier!


Beware the rabbit of the mind, for it gnaweth on the carrot of the soul.
Offline Matei

Senior Newbie




';..;'


« Reply #5 - Posted 2004-05-05 21:33:31 »

It depends a lot on what kind of game you make. After wondering about TCP vs UDP myself, I was quite surprised to find out that virtually all MMORPG games, for example, use TCP. UDP is only for when you need very fast reactions, perhaps in a shooter game.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #6 - Posted 2004-05-05 23:01:56 »

Quote
It depends a lot on what kind of game you make. After wondering about TCP vs UDP myself, I was quite surprised to find out that virtually all MMORPG games, for example, use TCP. UDP is only for when you need very fast reactions, perhaps in a shooter game.


If you're going to make a statement like that you should list the games you're citing.

malloc will be first against the wall when the revolution comes...
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #7 - Posted 2004-05-06 06:53:38 »

Ultima online uses TCP, but Earth and Beyond uses both. UO of course is just point and click for movement, whilst Earth and Beyond isn't. Dark age of Camelot also uses UDP and again is not just point and click for movement.

It would *seem* that even some of the newer MMORPGs are using UDP for some parts of the game play.

Just for interests sake Smiley

Endolf

Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #8 - Posted 2004-05-06 09:19:02 »

Quote
Dark age of Camelot also uses UDP and again is not just point and click for movement.


Actually DAOC uses both TCP and UDP. UDP handles all of the positional updates, spawn notifications, etc...
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #9 - Posted 2004-05-06 09:26:21 »

The all use TCP for something, usually login/updates and a few other things, I was only mentioning the gameplay/movement aspects, as I assumed TCP for certain things was a given Smiley

Endolf

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #10 - Posted 2004-05-06 09:31:00 »

Quote
The all use TCP for something, usually login/updates and a few other things, I was only mentioning the gameplay/movement aspects, as I assumed TCP for certain things was a given Smiley

Endolf


Exactly. My guess on reading the "most use TCP" statement was that is what the poster was probably referring to, and that they hadn't checked their facts fully (e.g. had just seen "game X uses TCP" and assumed that meant it didn't use UDP and that it used TCP for something other than OOB data).

Hence the request for a list of games, so we can check their facts.

malloc will be first against the wall when the revolution comes...
Offline crystalsquid

Junior Member




... Boing ...


« Reply #11 - Posted 2004-05-06 10:57:55 »

For MMORPG in-game messages, the main performance issue with TCP is the socket-per-client overhead on the server, and can impact performance (using a thread per socket and 1000+ clients is a lot of thread switching).

Another aside is that each socket will perform its own throttling, which is good for clients, but means its trickier to throttle the whole server when the server output stream bandwidth is too large.

Building a TCP stack on UDP eliminates the thread overhead and socket management, but you really should implement a SACK-TCP per-client, and add some global throttling to this. Its a fair amount of work but will save you some significant proportion of server processing when you get it right. You should refer to the relevant RFC docs to get it right - there is a lot of freely available information there that would take you months to work out by yourself, + important algorythms to use so that you don't start knocking routers over when things start going wrong (which they will do).

My own implementation also uses a reduced header of around 8 bytes instead of the 20-ish of TCP. For 1000 clients and 4 msg's per second this can save you 100kbs!

To summarize - for (at a guess) 50 clients or less, the standard TCP is MUCH easier to implement, less prone to errors, and not too much overhead. If your client numbers is reaching over 500+, you should probably consider your own UDP stack  - or powerful (& expensive) multiprocessor servers / a server farm. You can beat TCP performance, but only in the realms that TCP wasn't originally intended for, and only with a lot of work.

- Dom
Offline endolf

JGO Coder


Medals: 7


Current project release date: sometime in 3003


« Reply #12 - Posted 2004-05-06 11:10:20 »

Quote
For MMORPG in-game messages, the main performance issue with TCP is the socket-per-client overhead on the server, and can impact performance (using a thread per socket and 1000+ clients is a lot of thread switching).

Thats what NIO is for, no more do you need a thread per socket. It *was* a problem with the old Java IO and TCP, under C you've always had the selectors like in NIO anyway.

Endolf

Offline Gambit

Senior Newbie




Java games rock!


« Reply #13 - Posted 2004-05-06 11:49:45 »

Dom could you give more details or some links about building TCP like protocol on top of UDP?

Cheers,
Gambit
Offline crystalsquid

Junior Member




... Boing ...


« Reply #14 - Posted 2004-05-06 17:53:53 »

Endolf:
You're right - Due to various reasons I always end up thinking of Java 1.1 as that is our target platform most of the time. I haven't looked into NIO myself   Tongue
On Windows (C++) you need to use IOCompletionPorts to handle all the sockets instead - which is a big pain that I couldn't be bothered to wade thorugh... Not sure what Linux is like for 1000+ TCP sockets, but now I have my UDP library I don't need toknow Smiley

Gambit:

Useful things to look at:
ENet: http://enet.cubik.org/
A good starting point (in C though). It doesn't do Selective ACKs (which is a must) but does include a few other essential TCP features such as exponential back-offs, and the receiver window system.

And some googled stuff:

RFC2581: Congestion Control
http://www.zvon.org/tmRFC/RFC2581/Output/chapter3.html
The basic algorithms you need to consider.

RFC 3517: A Conservative SACK based loss-recovery system
http://community.roxen.com/developers/idocs/rfc/rfc3517.html
A very good algorithmic description of using SACKs. It also has a few references to other useful RFC's

http://www.eventhelix.com/RealtimeMantra/Networking/TCP_Fast_Retransmit_and_Recovery.pdf
A nice descriptive 'flow' of communications using fast retransmits & SACKs.

These were pulled from my old favourites when I was writing my network layer, and I found them to be very useful.

Hope this helps,

- Dom
Offline Gambit

Senior Newbie




Java games rock!


« Reply #15 - Posted 2004-05-07 04:51:49 »

THX Dom!

Cheers,
Gambit
Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #16 - Posted 2004-05-07 14:39:44 »

Quote
Endolf:
On Windows (C++) you need to use IOCompletionPorts to handle all the sockets instead - which is a big pain that I couldn't be bothered to wade thorugh...


Actually, you don't *need* to use IOC on Windows. There are several (at least 4) models available. Besides, IOC does not work on Win9x kernels. Aside from select, the simplest model to use is AsyncSelect, in which socket events are handled via Windows messages. It's also more efficient than select.

I've always wondered which model NIO uses under the hood on Windows.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (21 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (56 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (65 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!