As Goz noted, there is a queue of packages. In fact, in different places of the entire pipeline ending with your application, there is more than one. A network adapter usually has several buffers, then some of them are managed by the kernel. Kernel buffers can often be set for individual sockets using setsockopt ().
As Goz already pointed out, UDP packets may be lost on the way to you, or they may appear in a different order. If you need both realism and order, and if you cannot use TCP instead, you will have to implement some kind of protocol that will provide both over UDP, for example. sliding window protocol .
source share