Why the network communication latency Increase when I add a sleep() after socket.send()?

阳峰 王 0 Reputation points
2023-09-15T04:16:53.4233333+00:00

I want to do inter process communication(IPC) use socket interface, the protocol i used is tcp. then I write a demo to test RTT. A clinet record current time and send() data in a loop using stream. A server record current time and recv() data in a loop. I curious about that socket buffer in kernel will be full and affect the result. So, and send() the client will sleep 1ms. Then I test it again, the RTT increase a lot! I don't know why it increase, i thought it should be same or decrease?

A simple demo like below:

client:

`

while(1){

uint64_t send_time = now();

socket.send();

sleep(1);

}

`

server:

`

while(1){

uint64_t receive_time = now();

socket.recv();

}

`

Windows Network
Windows Network
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Network: A group of devices that communicate either wirelessly or via a physical connection.
639 questions
0 comments No comments
{count} votes