I read that application can handle in order delivery of udp. But how does that work? There is no sequence number or anything to determine if a packet is out of order.
-
You should take a look at this question: https://softwareengineering.stackexchange.com/questions/193745/udp-order-of-packets-with-direct-connection. – Ross Jacobs Mar 15 '20 at 04:09
-
UDP cannot do that. You need the application or an application-layer protocol to handle that for UDP. – Ron Maupin Mar 15 '20 at 05:05
1 Answers
What are some approaches to make sure UDP delivers packets in order?
This is the wrong approach to the problem. You cannot guarantee a specific delivery order of packets and neither you can make sure that packets are not lost or that packets get duplicated. Instead you need to check the successful delivery and delivery order in your recipient application and react to transmission problems by ignoring duplicates, processing messages in the intended order or if necessary ask the sender for a retransmit of a lost message.
The typical way to do this is to add some sequence number to the message and then check this sequence number in the recipients application. This is for example done with RTP (UDP based protocol for real time audio/video/...) which has a 16 bit sequence number in the RTP header. Similar QUIC has a 32 bit sequence number in each frame.
The same approach is actually used with TCP which uses a 16 bit sequence number. Only that with TCP the logic for reordering and retransmits is usually done inside the recipients OS kernel and not inside the recipients application.

- 1
- 1

- 114,247
- 10
- 131
- 172