0

Generally UDP doesn't garantee that packets will arrive in the same order they were sent. But in one LAN if sender and receiver connected via just one switch and route never changes is it possible at all that order of UDP packets will be changed?

In particular can order of UDP packets change somewhere between network card and application? In network card drivers for example?

Can I say that if two computers connected via just on switch then in 100% of cases order of UDP packets will be unchanged?

Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305

1 Answers1

2

They probably will arrive in order in that test setup, but relying on that fact is a really bad idea. Just add a sequence number to your packets or use TCP if appropiate.

  • I have sequence numbers and I have recovery algorithm as well. I need to decide if I should use straightforward algorithm and drop packets that arrived in wrong order (and recover them via tcp later) or I need more reliable (and more slow) algorithm which doesn't rely on packets order. I.e. the question what is better "Receive (100-`a`) % of packets fast and `a`% of packets very slow" or "Receive 100% packets not so fast". To answer this question I need to know `a` :) – Oleg Vazhnev Mar 08 '12 at 15:07
  • I guess for real world applications (not only 2 hosts and a switch) you should always assume that there is a small percentage of dropped packets. If in doubt just run a few benchmarks with both options, possibly with the help of this: http://stackoverflow.com/questions/614795/simulate-delayed-and-dropped-packets-on-linux –  Mar 08 '12 at 15:26
  • my real-world application (trading software) is connected with stocks exchange via just one bridge... – Oleg Vazhnev Mar 08 '12 at 15:39