Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable TCP Delayed ACKs

Tags:

I have an application that receives relatively sparse traffic over TCP with no application-level responses. I believe the TCP stack is sending delayed ACKs (based on glancing at a network packet capture). What is the recommended way to disable delayed-ACK in the network stack for a single socket? I've looked at TCP_QUICKACK, but it seems that the stack will change it under my feet anyways.

This is running on a Linux 2.6 kernel, and I am not worried about portability.

like image 566
Tom Avatar asked Oct 23 '09 19:10

Tom


People also ask

What is the purpose of delayed ACK timer in TCP?

The TCP delayed acknowledgment timer allows you to adjust, on a per-socket basis, how long the z/TPF system waits before sending a stand-alone ACK to acknowledge data on a TCP socket. A stand-alone ACK is sent if two full packets worth of data arrive before the delayed ACK timer expires.

What is TCP no delay?

The TCPNODELAY option specifies whether the server disables the delay of sending successive small packets on the network. Change the value from the default of YES only under one of these conditions: You are directed to change the option by your service representative.

What is TCP quick ACK?

Quick ACK. This mode is used at the start of a TCP connection so that the congestion window can grow quickly. The acknowledgment (ACK) timeout interval (ATO) is set to tcp_ato_min , the minimum timeout value.

What problem does Nagle's algorithm solve?

Nagle's algorithm is a TCP optimization that makes the stack wait until all data is acknowledged on a connection before sending more data. This process, called "nagling", increases the efficiency of a network application system by decreasing the number of packets that must be sent.


1 Answers

You could setsockopt(sockfd, IPPROTO_TCP, TCP_QUICKACK, (int[]){1}, sizeof(int)) after every recv you perform. It appears that TCP_QUICKACK is only reset when there is data being sent or received; if you're not sending any data, then it will only get reset when you receive data, in which case you can simply set it again.

You can check this in the 14th field of /proc/net/tcp; if it is not 1, ACKs should be sent immediately... if I'm reading the TCP code correctly. (I'm not an expert at this either.)

like image 91
ephemient Avatar answered Sep 25 '22 22:09

ephemient