tags:

views:

1429

answers:

3

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.

+1  A: 

At which point does this happen? Do you mean SYN-ACKs, FIN-ACKs or what?

Nikolaos
I think he means plain ACKs -- "receives ... traffic", "no ... responses". Returning ACKs are normally delayed to include data which might be sent soon, but there is none in OP's case.
ephemient
yes, this is in an established session, not a handshake.
Tom
A: 

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.)

ephemient
I believe he has done that already based on his question and he says the value is being reset.
Nikolaos
Setting `TCP_QUICKACK` immediately sends an ACK if there is anything that needs to be ACK'ed, so I think this is sufficient.
ephemient
I am still `send()`ing on that socket. But as I said, I am not responding to messages I receive.I'll check out `/proc/net/tcp`.
Tom
A: 

I believe using the setsockopt() function you can use the TCP_NODELAY which will disable the Nagle algorithm.

Edit Found a link: http://www.ibm.com/developerworks/linux/library/l-hisock.html

Edit 2 Tom is correct. Nagle does not affect Delayed ACKs.

CoryC
Disabling Nagle's algorithm won't impact delayed acknowledgements (at least, not on any implementation I know of).
Tom