upd does not get disordered

Posted on 2000-02-21
Last Modified: 2010-03-18
I am sending udp packets to the port 7
of a remote host and the packets are returned in the same order they were
Could you send to me a code in C with
2 threads (sender and receiver)in wich
the packets get disordered?

Question by:jjescri
  • 2

Expert Comment

ID: 2545426
Well, it looks to me that UDP does not *guarantee* that packets will be received in the order they are sent. But it does not guarantee the opposite either.

This means you cannot rely on the packet (dis)ordering either way. (As a matter of fact you cannot even assume that packets are actually delivered, unless somehow acknowledged)

The reasons packets (TCP or UDP) can get out of order are plentiful but they are dependent on the network paths and conditions, not on their specific treatment at the sending/receiving side. (For instance packets can be processed by different routers and travel through different network segments).
In my opinion, you will seldom (if ever) witness such an occurence on your standard LAN.

UDP differs from TCP in that while a conscious effort is made to reorder out-of-order TCP packets (using sequence numbers) no such action is taken for UDP. OTOH no effort is made to scramble UDP packet ordering, either.

HTH & cheers,

Expert Comment

ID: 2546011
What alf told is correct.
That basically depends on where your server and client are located in LAN. I think your LAN could be small and you may have few paths from server to client. More over there really may not be much delay in two paths. That is why you are receiving the packets in the same order.
try to put your client and server in a big LAN where many paths exists and network trafic is more, then you will see the dis order of the packets.
Bt I have seen many times dis order of packets.

Author Comment

ID: 2546198
My server in Spain (Europe) and my client is in USA.

Accepted Solution

alien_life_form earned 100 total points
ID: 2546281

This does in no way guarantee that your
packets do in fact take different  network paths. It is in fact extremely
likely that (during the same session) the path taken by your packets do not change. (Try traceroute at a few seconds interval  - does the sequence of gateways change?)

I may be mistaken, but in the IP world, the only way for a (short) session (of course UDP does not have sessions, but let's assume a figure of speech) to be variably routed is that one of the routers receives a routing update which actualy changes its idea of best route while the session is in progress - this should be a rare event. Alternatively, you could be traversing a router that does dynamic load balancing during a moment of congestion, or an above-CIR frame relay segment (this would drop some of the packets).

Another (hypothetical) possibility, is if you send packets of different sizes and end up traversing a router that gives a higher priority to shorter packets (does anybody know of routers beahving this way? I'd be curious).

If nothing like this happens, and your packets travel down the cable in the order you send, then I see no way they could be scrambled. Of course, you could differently source route your packets, but, these days, everybody drops source routed packets.


Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question