What causes udp to be delayed?

I noticed that when I send packets at regular intervals from the udp socket, the first packet sent seems to be delayed. For example, if I send packets every 100 ms, I find that the delay between receiving packets is usually distributed with an average of 100 ms and an average standard deviation of 4 on my network. However, the gap between the reception time for the first and second packets is usually from 10 to 40 ms - as you can see, this is clearly a statistically significant difference, and therefore my question is what causes it?

I am using the sendto function from C on linux. Someone suggested that the delay could be caused by ARP permission, which prevents packet transmission until the destination IP address is converted to a MAC address - is this likely? If I restart the sending program, the first packet again takes too much time, and the delay does not correspond - from 10 to 40 ms - a rather large range.

I need to find out why this first package takes too much time and how to get around it.

Edit: Further analysis with pcap indicates that the sending program sends packets at the correct interval. The problem should be with the receiver, which uses select () to wait for the socket to read, and then calls recvfrom and print the packet. Are there any buffers that I may not know?

+3
source share
5 answers

You asked about workarounds. One of the possible ways to bypass the solution, if it is important to know the time of receiving the packet, is to set the socket option SO_TIMESTAMP. This will allow you to get the time during which each packet was received by the target kernel - you can use this time in subsequent processing, rather than in the "current time".

Alternatively, you can indicate that the sender contains a high-resolution timestamp in the packet being sent and use them.

0
source

, , ARP. , MAC- IP-.

, arp arp -s ip-address hw_address.

+2

, Wireshark, , .

+1

? , () ARP / . , ( ).

0

"", , , , , ARP-, . , ARP LAN. wirehark " 192.168.0.24?" ... , , IP-. UDP ARP IP- MAC- Ethernet... UDP , ... ARP . , , UDP , , ARP... .

0
source

Source: https://habr.com/ru/post/1781211/


All Articles