0

The send function would cost 3~4 microseconds in my linux server running in 3.10 as the following showes :

struct timeval  tv1,tv2;
gettimeofday(&tv1,NULL) ;
send(fd,strsend,strlen(strsend),MSG_NOSIGNAL) ; 
gettimeofday(&tv2,NULL) ;
printf("(%d)(%d)\n",tv1.tv_usec,tv2.tv_usec) ;

The strlen(strsend) would be 212 bytes , so I can merge 5 messages of strsend and send , instead of calling send 5 times , it contains 212 * 5 = 1060 which is below MTU 1500 , the send latency is much better than calling send 5 times .

I like to know if I can merge 10 messages and send only once?!
in this case it contains 212 * 10 = 2120 bytes , which is above MTU 1500 , Maybe the latency would be improved since I call send only once , but is there any side effect doing that ?! any config parameter of NIC would be helpful to do division in lowest latency ?! Does the peer side of tcp/ip performance is effected ?!

1 Answer 1

1

You should definitely try to aggregate as much information into a single call to send as you can. 2KB is generally considered an absolute minimum. Otherwise, among other problems, you'll send very small datagrams on the wire and reduce network efficiency.

Sign up to request clarification or add additional context in comments.

2 Comments

for those messages which package size > 1460 , Would encounter more latency in kernel ?! After all it need to be divided to 2 packets before sent in the kernel .
There's no possible way to avoid that, since they're bigger than the maximum size that would fit in one datagram anyway. At least you won't have to make two trips into and out of the code that processes the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.