Archived

This topic is now archived and is closed to further replies.

reliable UDP question

This topic is 5173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to create a reliable udp ''thing'' ... i have readn some about how TCP does this but 1 think i havent yet found out is do i need the 3way handshake for every packet i send ? ( using udp ) Or is there some other way to do this ? ( any links or so would be great ) - YES I HAVE TRYED GOOGLING !

Share this post


Link to post
Share on other sites
By no means is this bulletproof, but I added some reliability to my UDP setup by doing two things:

1) every packet has a sequence number - this lets you detect and deal with out of order or missing packets.
2) you send an ACK[nowledged] packet every time you receive a packet - this lets the sender know that his packet transferred successfully.

I think those are the 2 basic things for packet reliability. They''re easy to implement and go a long way towards reliability. TCP goes a lot further than this, but then again that''s why it''s called TCP, and that''s why it''s not really suitable for games.

Share this post


Link to post
Share on other sites
Get the docs for RFC908 (www.faqs.org/rfcs/rfc908.html). It''s a reliable protocol that can be put atop UDP; contrary to TCP, ordering of packets is not enforced which makes it suitable for gaming. The docs contain all the algorithms, state variables, events and data structure definitions.

If you want to use an existing library (source code, of course), there is AirHook (http://airhook.org) and ENet (http://enet.cubik.org/index.html).

-cb

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
nah you don''t need the handshake thingy..
do as foofightr said but send the ack along with your next output packet. then all you have to do is buffer your output until it''s been acked or resend it after a timeout (eg. 3*roundtrip).
this will guarantee reliable delivery just make sure that you keep sending packets regularly.

Share this post


Link to post
Share on other sites