🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

UDP normally, TCP for chat & data transfer..?

Started by
15 comments, last by civguy 23 years, 5 months ago
Ok AP. here are the facts.

I don''t know much Winsock but I know my protocols.

Right from the artical on Gamasutra (I posted the URL in one of my last posts),

"In general, anything above 1450 bytes or so is considered bad form for IP based packets such as UDP packets. Routers or other equipment often discard packets larger than about 1450 bytes."

Get the video version of the artical and Yahn talks about this a tad more then whats in the artical.

> (It''s been asked over and over and over and over and over. People won''t stop asking it. When the world finally ends, people will still be desperately begging to be told if TCP or UDP is better. It''s a pity none of the people asking actually have the ability to understand anything.)

Here''s you answer, NEITHER (It''s like asking if OpenGL or Direct X is better)! If it has to be their in the right order soon. TCP/IP is your man. If you don''t care about maybe missing a message or getting it out of order. If you don''t want to open another port UDP is your babe. You get it? I do.

Now AP, before you shoot your mouth off next time. Make sure your not in over your head.

------------------------------------------------------------I wrote the best video game ever, then I woke up...
Advertisement
(I am AP#1 above, not AP#2...)

Assuming your UDP implementation isn''t using really small packets in general TCP will use more bandwidth than UDP. TCP has to all do all the same stuff that UDP has to do but do it reliably - and that takes more work/bandwidth.

Either I''m misunderstanding Galileo''s first post above or he''s off a bit. UDP may be connectionless but it does have a port associated with it. In fact the whole point of having UDP vs just doing raw IP is to get ports. As for routing, many routers couldn''t care less if you''re using TCP or UDP, they route based on raw IP. The reason you don''t necessarily see the packet loss is because TCP is doing the work for you.

Also, the reliability scheme he proposes isn''t the best. This is essentially a wait-for-ack scheme and is going to be really slow. You (civguy) should look up "sliding-window protocols" if you''re thinking of providing your own reliability scheme over UDP. The main advantage of TCP is that you don''t have to do all this work yourself (and getting all the details right can be tricky).

Be sure to test over the actual Internet or at least some sort of simulator. When I''ve tested my stuff over a LAN (even a busy one) I''ve gone for days without a packet drop or out-of-order delivery. On the actual Internet you gut bursts of packet loss lasting several seconds, out-of-order is fairly common (e.g. packets 0-9, 20-29, 10-19, in that order), I even saw once case where I sent out 100 packets 0-99 and they all got to the other side in reverse order (99-0).

-Mike
Acutally, AP #2''s advice was good, it just didn''t answer the question.

Trying is the first step towards failure.
Trying is the first step towards failure.
AP #2,

You got it right.

If you have 2 clients.
With TCP/IP you have them setup 2 sockets. One for each client. Then have them connect to send data.
With UDP you can have both clients sendto one port which does not does not have to be connected to.
Once the client connects to a port with TCP it can''t be used by anyone else except for the client and the server. With UDP everyone can send data to one port.

You might want to read up on UDP. It''s useful but unreliable.

------------------------------------------------------------I wrote the best video game ever, then I woke up...
Im not sure why there has been such controversy over such a simple and straight forward question. I beleive almost all commercial games use the 2 protocol (TCP/UDP) system or indirectly through DirectPlay. UDP is the standard protocol for low latency, lossy information, and TCP for bulk reliable data transmission. You can moniter the ports/protocols usage for your favorite online game with a network moniter such as performance moniter under NT/2000, a packet sniffer, or netstat with the command prompt to see that most games do use the 2 protocol system. Check out this website for a really good article on desiging a fast multiplayer action game and the issues involved.

http://www.bolt-action.com/dl_papers.html

specificly "A Look at Latency in Networked Games"

As for reliable UDP, unless you really need that level of control for UDP packets, i suggesting sticking to TCP_IP for reliable bulk data trasmission (player messages/initial level download/ patches etc..)

From my experience, it is possible to design an action game using TCP_IP only, however it adds about 10-20% additional latency over UDP/TCP_IP, however if you exceed the bandwith of your client, you take a major lag hit, contrary to UDP which would result in loss instead. This may not be acceptable for some games ofcourse.

Good Luck

-ddn

Dear Anonymous Poster #2.

quote:

I just know I''m going to offend someone here. Isn''t life sad?

The fact that you asked that question proves that you don''t know enough about TCP/UDP to actually know if these people are being helpful, or if they''re talking bullshit.

Go to the library. Read a few books about how internet protocols and network protocols work. Go to a search engine or 6, and try looking up some tutorials on the net - after all, I think it''s safe to assume the internet will have some information on internet protocls.

Eventually you''ll actually understand what''s going on.
[/qoute]

True so far (except that most libraries probably don''t have books about TCP and UDP).


Then not only will the answers make sense, you won''t even need to ask this question.


It seems to me that the answers DO make sense. They may not be correct but that is an entirely different matter.

quote:
(It''s been asked over and over and over and over and over. People won''t stop asking it. When the world finally ends, people will still be desperately begging to be told if TCP or UDP is better. It''s a pity none of the people asking actually have the ability to understand anything.)


And it sure is a pity that people like you write bullshit like that instead of just answering the question or minding your own business.

quote:
If you don''t understand what''s going on, how to you expect to actually make use of answers that you don''t understand?


As far as I can see, all he is asking is which protocols would be the best to use and how they should be combined. Whether or not he understands the individual protocols is irrelevant.

quote:
No, I''m not calling you stupid. I''m simply pointing out that you actually need to learn this stuff for yourself if you ever want to actually write a real game that runs over the internet.


Not calling him stupid? I thought you just said that he was "unable to understand anything".

quote:
Alternatively, you can wait five minutes, until someone else asks the same pointless question.

(PS: an intelligent question to ask would be "can someone point me to some useful pages about how network protocols work?" That at least demonstrates a willingness to learn, and also that you realise it takes more than a 3 line post to explain TCP & UDP.)


Again, he is not asking HOW the protocols work. He is just asking WHAT protocols to use.
What is wrong with: "could someone please tell me which network protocol would be the best for me to use for my game, so that I know which protocol I should read about?"

Personally I don''t like newbies. They always ask question that clearly indicate that they know NOTHING about the subject and that they are unwilling to do anything on their own. Questions like "how do I program a 3d engine?" and "how do I make my own file format?". And they ALWAYS ask before they think. I find that kind of behavior unacceptable.

Civguy seems to know at least a little about the subject and as even you should be able to see, he has already thought about how it could be done. I can''t really see what is so stupid about his question.

Anonymous Poster #3
err guys...sorry for the interruption....i also know something abt this TCP/IP programming ( not very expert thou)..currently i also working on a network game...using client/server as my game connection...come to think of using directx(maybe)..would DIRECTX able to automaticcaly provide synchornization thru the client/server which i was worrying about?

This topic is closed to new replies.

Advertisement