Advertisement

UDP Networking

Started by January 20, 2004 02:54 PM
15 comments, last by Ademan555 21 years ago
Ok, i have a pretty good understanding of winsock, and know that UDP packets have the possibility of not making it to its destination... I recently picked up Advanced 3d game programming with direct x 9.0 (because many 3d concepts were just plain goin over my head) and...it covers more than 3d which is nice... but it seems to choose udp networking... why?!
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Some people choose UDP for speed reasons. The reason that TCP is more reliable is because it sends an awknoledgement (sp?) for every packet sent, which can clog up network lines with extra data. If bandwidth is at a premium, UDP can be a good solution. And its success rate is very high, it''s not like it''s a crapshoot with it.
Advertisement
Alright thats cool, yeah i didnt realize it was fairly reliable... (hey ive been noticing a sudden increase in AP intelligence... i dont get it)
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
This may be an interesting read Lessons Learned (The Internet Sucks) from Gamasutra ( may require registration, but is free and easy and Gamasutra has a lot of good articles ).

Even though the article is a few years (5!) old it has some of the practical discussio of the TCP/UDP debate.

-------
Andrew
PlaneShift - A MMORPG in development.
TCP''s acknowledgement packet takes a while; it has to send a packet, then decide that enough time has passed without an acknowledgement, then send the same packet again. It can''t send the next packet until it has recieved the client''s confirmation.

UDP is good for sending absolute data, i.e. the player is at this absolute position, because if you send relative data (the player has moved three units since last update), you have to rely on TCP to make sure that the packet gets there.

And don''t insult the APs, lest you stir their anger.
While I was monkeying around with game networking, I came across this draft of a protocol specification... RUDP (Reliable)

http://www.ietf.org/proceedings/99mar/I-D/draft-ietf-sigtran-reliable-udp-00.txt

Perhaps you could employ certain features from that, along with other stuff. I can''t think right now, my asshat roommate is coughing up a storm. I hope he dies of pneumonia.
Member of the Unban nes8bit or the White Rhino in my Basement Gets Sold to the Highest Bidder Association (UNWRBGSHBA - Not accepting new members.)Member of the I'm Glad Mithrandir Finally Found an Association that Accepts People with his Past History Association (IGMFFAAPPHA)
Advertisement
LOL, anyways, thanks all, i already read the gameasutra one, it was informative, i think ive drafted my own ideas in my head....but i think ill definitely take a look at what you came up with, reliability never hurt :-D, agan, thanx
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Imho, the strength of UDP is not that it''s faster (it isn''t) nor that it consumes less bandwidth (it does, but only to a certain degree) - but that its unordered.

A dropped packet is a roundtrip time catastrophe for TCP - no more packets will arrive until the dropped packet has been resent. In UDP you can merrily keep on processing packets without having to wait for anything. If you''ve got a reliability layer on top of UDP you''ll get a resend of the dropped packet eventually.

> the strength of UDP {...}

Another feature is that you can have connections with many peers using only one socket; that''s because unlike TCP, UDP is connection-less.

As for reliability, you can check the specs for RFC908 (it''s old, but well described so you adapt some ideas from it), AirHook and ENet.

-cb
Packet acking is not a big issue. One of the big reasons for choosing UDP is because you often *don''t want* the reliable layer that TCP imposes on you. A lot of the information being sent by a game is position updates. If the net drops the packet with the position update for time 1 you don''t care because the info for time 2 is already on it''s way and the previous packet is going to be obsolete anyway. A reliable protocol would not only go out of it''s way to ensure that you get that obsolete information it will also delay giving you the latest information to do so.
-Mike

This topic is closed to new replies.

Advertisement