user2485792
user2485792

Reputation: 1

Different performance between sendto and recvfrom

I have noticed that there is a difference of performance between sendto and recvfrom (UDP). I send about 100Kbytes from a server to a client, using WiFi (the estimated bandwidth is about 30Mb/s in both directions), and the sending time is about 4-5 ms (it depends, but this value is comparable to the ideal one, 3ms). On the client, the receiving time is ten-fifteen times higher, like 50-60ms. I'd like to have the two elapsed times quite similar. Any idea?

Upvotes: 0

Views: 775

Answers (1)

JeremyP
JeremyP

Reputation: 86651

and the sending time is about 4-5 ms (it depends, but this value is comparable to the ideal one, 3ms)

30Mb/s (where the b means bits) is approximately (give or take to account for headers etc) 3 MB/s (where the B means bytes). It should take roughly 30 milliseconds to transmit 100kBytes.

The sendto is returning as soon as it has written all the data to the local buffer of the network stack of the sending machine. The recv obviously has to wait for the data to be transmitted, including latency and stuff needed for all the layers of protocols.

Upvotes: 1

Related Questions