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

Comment Utility
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

Comment Utility
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

Comment Utility
My server in Spain (Europe) and my client is in USA.

Accepted Solution

alien_life_form earned 100 total points
Comment Utility

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now