Reputation: 24067
I'm writing application than need to receive UDP multicast packets in the certain order. I'm trying to understand when and why I can receive packets in the wrong order. Because knowing how likely such situation is implies architecture of my system.
Let's assume that host A sent two packets with seqNum = 1 and seqNum = 2 one by one to host B.
Is it guaranteed that destination host B will receive these packets in the same order?
Upvotes: 2
Views: 2923
Reputation: 31
A switch or a router or any network device with queues and lots of links may send packets in different order - the packets (even with all same MAC/IP headers) may end up in different queues that may be forwarded at different modes, or even easier - link aggregation (etherchannel/ethernet trunk/bonding with or w/out LACP) or even plain routing may send packets via different paths
Upvotes: 0
Reputation: 9570
No, it is never guaranteed that B will receive any of the packets, let alone the order in which it will receive them. In case #1, it is highly probable, but not 100%. Both of the other cases have non-trivial probabilities of non-delivery or out-of-order delivery.
There are lots of reasons why a network element might drop a packet or send it out of order. The most common reason is queue overrun. Many IP implementations have a maximum number of packets they will hold waiting to process. If they receive another packet (from another machine or from code on the same machine), they will often discard it. It is even possible for packets to be dropped or delayed by the wires connecting machines, due to attempts by multiple machines to transmit on the wire at the same time. When that happens, none of the packets may get through, and the sending machines may or may not attempt to retransmit.
As always, if order and success matter, use TCP.
Upvotes: 1