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?
source
share