2.1.2The TCP Specification
The TCP specification describes how the receiver and sender avoid SWS. Section 18.104.22.168 states that atthe receiver
A TCP SHOULD implement a delayed ACK, but an ACK should not beexcessively delayed; in particular, the delay MUST be less than 0.5seconds, and in a stream of full-sized segments there SHOULD be an ACK for at least every second segment.
Therefore a receiver can always delay acknowledging a partial segment.Section 22.214.171.124 says that
A TCP MUST include a SWS avoidance algorithm in the receiver. […] Thereceiver's SWS avoidance algorithm determines when the right windowedge may be advanced; […]
For realistic receive buffers (greater than twice the MSS) window advances are announced in incrementsof MSS.Section 126.96.36.199, “When to Send Data” says that
A TCP MUST include a SWS avoidance algorithm in the sender. […] A TCPSHOULD implement the Nagle Algorithm [Nagle 84] to coalesce shortsegments. However, there MUST be a way for an application to disablethe Nagle algorithm on an individual connection. […]The Nagle algorithm is generally as follows: If there isunacknowledged data […] then the sending TCP buffers all user data […]until the outstanding data has been acknowledged or until the TCP cansend a full-sized segment […]
If the receiver delays acknowledgements, and the application writes less than MSS to the socket, andNagle is enabled, then sending TCP delays transmission.The specification also says
To avoid a resulting deadlock, it is necessary to have a timeout toforce transmission of data […].
but in all traces we collected, the delayed acknowledgement appears to timeout before the Naglealgorithm.
2.2HTTPS and HTTP Performance Problems
In several situations HTTPS and HTTP trigger SWS avoidance in both the sender and receiver, therebycreating substantial delays. The application layer situations were the following:
HTTPS / SSL key exchange, new and reused session key:
The server writes two small messagesand blocks waiting for response; the browser reads both messages and responds.
HTTPS / SSL key exchange, reused session key:
Same situation, but with directions reversed. Thebrowser writes two small messages and blocks waiting for response; the server reads both messagesand responds.
HTTP image (GIF), smaller than MSS:
The server sends the HTTP response in two small separatewrites, containing headers and body (image data), respectively.All three cases lead to the same TCP situation. The sender transmits the first message in a separatesegment, then waits for its acknowledgement. It transmits the second message in a separate segmentwhen the acknowledgment arrives. The receiver receives the first segment, but delays theacknowledgment because the segment is partial and the window available to advertise is less than MSS.Eventually, a time-out triggers the acknowledgment, thus causing the sender to send the secondsegment.2