Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are good UDP timeout and retry values?

I'm working on a UDP server/client configuration. The client sends the server a single packet, which varies in size but is usually <500 bytes. The server responds essentially instantly with a single outgoing packet, usually smaller than the incoming request packet. Complete transactions always consist of a single packet exchange.

If the client doesn't see the response within T amount of time, it retries R times, increasing T by X before each retry, before finally giving up and returning an error. Currently, R is never changed.

Is there any special logic to choosing optimum initial T (wait time), R (retries), and X (wait increase)? How persistent should retries be (ie, what minimum R to use) to reach some approximation of a "reliable" protocol?

like image 445
Witness Protection ID 44583292 Avatar asked Aug 22 '11 17:08

Witness Protection ID 44583292


People also ask

What is UDP timeout value?

UDP Timeout refers to the amount of time a UDP Pinhole stays open on a Firewall or Router. Depending on your equipment this timeout can range from a few seconds to many minutes. Most devices fall under the minute(s) range. We recommend UDP Timeout to be set at 30 or 60 seconds.

Does UDP wait for response?

UDP is completely stateless, so after firing off a packet the only way an application can expect a response is if it knows the other end is going to send one.

What is a UDP session?

User Datagram Protocol (UDP) is a communications protocol that is primarily used to establish low-latency and loss-tolerating connections between applications on the internet. UDP speeds up transmissions by enabling the transfer of data before an agreement is provided by the receiving party.


1 Answers

This is similar to question 5227520. Googling "tcp retries" and "tcp retransmission" leads to lots of suggestions that have been tried over the years. Unfortunately, no single solution appears optimum.

I'd choose T to start at 2 or 3 seconds. My increase X would be half of T (doubling T seems popular, but you quickly get long timeouts). I'd adjust R on the fly to be at least 5 and more if necessary so my total timeout is at least a minute or two.

I'd be careful not to leave R and T too high if subsequent transactions are usually quicker; you might want to lower R and T as your stats allow so you can retry and get a quick response instead of leaving R and T at their max (especially if your clients are human and you want to be responsive).

Keep in mind: you're never going to be as reliable as an algorithm that retries more than you, if those retries succeed. On the other hand, if your server is always available and always "responds essentially instantly" then if the client fails to see a response it's a failure out of your server's control and the only thing that can be done is for the client to retry (although a retry can be more than just resending, such as closing/reopening the connection, trying a backup server at a different IP, etc).

like image 177
underflew Avatar answered Sep 23 '22 02:09

underflew