Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get UDP datagrams out of order even with processes running locally?

Tags:

java

udp

datagram

I'm developing a java interface between a streaming server and a flash client. I noticed that UDP datagrams can reach my interface out of order even if both processes are running locally.

Is that normal? I thought that as no datagram has to go through any router or any network device, then that should not be happening.

like image 965
Bilthon Avatar asked Mar 28 '10 17:03

Bilthon


People also ask

What causes UDP out of order?

UDP Traffic: Out-of-order packets can also be caused by UDP traffic. This issue occurs primarily due to stateless connections and the lack of flow control mechanisms that exist within UDP protocol.

Does UDP arrive out of order?

UDP does not guarantee that your packets will arrive in order. (It does not even guarantee that your packets will arrive at all.) If you need that level of robustness you are better off with TCP.

Does UDP guarantee in order delivery?

UDP does not guarantee that any given packet will be delivered, and no notification is provided in the case of lost packets. TCP guarantees that every octet sent will be received in the order that it was sent.

Can UDP handle out of order packets?

The User Datagram Protocol (UDP) is a lightweight data transport protocol that works on top of IP. UDP provides a mechanism to detect corrupt data in packets, but it does not attempt to solve other problems that arise with packets, such as lost or out of order packets.


2 Answers

This would be operating system dependent. While you failed to specify an operating system it isn't important anyway. To remain portable you should always anticipate your datagram sockets receiving out of order data.

like image 172
Thomas M. DuBuisson Avatar answered Oct 11 '22 21:10

Thomas M. DuBuisson


Actually there are no guarantees of ordering and reception about UDP packets, even if they are sent by localhost on localhost. Just because the specification of the protocol doesn't imply anything about it.

Since you can't make assumptions on them you should choose to use TCP or handle reordering by using a sequence number handled by your programs..

like image 25
Jack Avatar answered Oct 11 '22 19:10

Jack