Connected: An Internet Encyclopedia
RFC 1122 - 4.2.3.4 When to Send Data

Top: Connected: An Internet Encyclopedia
Up: Requests For Comments
Up: RFC 1122
Up: 4. TRANSPORT PROTOCOLS
Up: 4.2 TRANSMISSION CONTROL PROTOCOL -- TCP
Up: 4.2.3 SPECIFIC ISSUES
Prev: 4.2.3.3 When to Send a Window Update
Next: 4.2.3.5 TCP Connection Failures

### 4.2.3.4 When to Send Data

A TCP MUST include a SWS avoidance algorithm in the sender.

A TCP SHOULD implement the Nagle Algorithm [TCP:9] to coalesce short segments. However, there MUST be a way for an application to disable the Nagle algorithm on an individual connection. In all cases, sending data is also subject to the limitation imposed by the Slow Start algorithm (Section 4.2.2.15).

DISCUSSION:

  The Nagle algorithm is generally as follows:

  If there is unacknowledged data (i.e., SND.NXT > SND.UNA), then the sending TCP buffers all user data (regardless of the PSH bit), until the outstanding data has been acknowledged or until the TCP can send a full-sized segment (Eff.snd.MSS bytes; see Section 4.2.2.6).

  Some applications (e.g., real-time display window updates) require that the Nagle algorithm be turned off, so small data segments can be streamed out at the maximum rate.

IMPLEMENTATION:

  The sender's SWS avoidance algorithm is more difficult than the receivers's, because the sender does not know (directly) the receiver's total buffer space RCV.BUFF. An approach which has been found to work well is for the sender to calculate Max(SND.WND), the maximum send window it has seen so far on the connection, and to use this value as an estimate of RCV.BUFF. Unfortunately, this can only be an estimate; the receiver may at any time reduce the size of RCV.BUFF. To avoid a resulting deadlock, it is necessary to have a timeout to force transmission of data, overriding the SWS avoidance algorithm. In practice, this timeout should seldom occur.

  The "useable window" [TCP:5] is:

             U = SND.UNA + SND.WND - SND.NXT

  i.e., the offered window less the amount of data sent but not acknowledged. If D is the amount of data queued in the sending TCP but not yet sent, then the following set of rules is recommended.

  Send data:

  1. if a maximum-sized segment can be sent, i.e, if:

                     min(D,U) >= Eff.snd.MSS;

  2. or if the data is pushed and all queued data can be sent now, i.e., if:

                    [SND.NXT = SND.UNA and] PUSHED and D <= U

     (the bracketed condition is imposed by the Nagle algorithm);

  3. or if at least a fraction Fs of the maximum window can be sent, i.e., if:

                    [SND.NXT = SND.UNA and]

                            min(D.U) >= Fs * Max(SND.WND);

  4. or if data is PUSHed and the override timeout occurs.

  Here Fs is a fraction whose recommended value is 1/2. The override timeout should be in the range 0.1 - 1.0 seconds. It may be convenient to combine this timer with the timer used to probe zero windows (Section 4.2.2.17).

  Finally, note that the SWS avoidance algorithm just specified is to be used instead of the sender-side algorithm contained in [TCP:5].

Next: 4.2.3.5 TCP Connection Failures

Connected: An Internet Encyclopedia
RFC 1122 - 4.2.3.4 When to Send Data