inetstack icon indicating copy to clipboard operation
inetstack copied to clipboard

[tcp] Delayed ACKs Considered Harmful

Open BrianZill opened this issue 2 years ago • 0 comments

There is a well-known undesirable interaction between TCP's "delayed ACK" mechanism and Nagle's Algorithm that can cause unnecessary delays in request-response protocols. (Basically, a sender with a small amount of data to send will wait until all previously sent data is ACK'd, while the receiver will wait to ACK until the timer goes off or it receives a second packet). As a result, many TCP implementations contain a mechanism (usually a socket option) to turn one or both of these off (e.g. TCP_QUICKACK and/or TCP_NODELAY). While the ability to turn off Nagle's Algorithm was the original work-around, Nagle himself argues that delayed ACKs do more harm than his algorithm, and that they should be turned off (but Nagle might be biased :-)).

We currently implement delayed ACKs, but not Nagle. We don't currently implement a mechanism to turn delayed ACKs off.

Since we have fine-grained cooperative scheduling between our stack and the application, we might want to revisit how we implement delayed ACKs. The whole idea of the timeout is to give the application time to respond to the received data, so we can "piggyback" the ACK on that response. But if the application calls wait w/o sending, we're just wasting time if we're waiting for the delayed ACK timer to expire to send the ACK.

Bottom line: We could probably replace the delayed ACK timer with a simple flag (and remove another "watched" variable).

BrianZill avatar May 10 '22 23:05 BrianZill