[PATCH] Using TCP_NODELAY unconditionally

Tobias Ringstrom tori at ringstrom.mine.nu
Wed Jan 23 09:41:16 EST 2002


[I cannot keep up with the amazingly fast typers Nico and Rick, so there 
is some overlap...]

On Tue, 22 Jan 2002, Nicolas Williams wrote:

> On Sun, Jan 20, 2002 at 03:23:48PM +0100, Markus Friedl wrote:
>
> > but i guess, it would be better if ssh implements a nagle-like
> > algorithms itself.

I've thought about this some more, and it will be hard to implement. I
think we would need an SSH ack packet for all data packets.  If we added
that, we would be able to implement our own nagle, but we would kill the
delayed-ack feature of TCP, and gain nothing.

Any ideas how to solve that?

> But, in the meantime, what is the rationale for turning Nagle off for
> interactive sessions and leaving it on for all others?
> 
> I would expect the reverse...

Me to, but remember that the primary purpose of nagle is to reduce the
number of tinygrams on the network, not neccesarily to improve the 
"interactivity feeling".  (pardon my bad english)

Consider a case where the RTT is 1 s, and I type 10 characters within that
time, and for simplicity, plain-text tcp:

With Nagle
----------
packets: 2
header bytes: 2*52 = 104 bytes  (tcp with timestamp, data direction)
time: 1.5 seconds (from first character is sent to last is received, 
                   and assuming a symmetric link of infinite "bandwidth")
user experience: very "choppy"

Without Nagle:
--------------
packets: 10
header bytes: 10*52 = 520
time: 1.5 seconds
user experience: delayed but smooth

Now, if we add a limited bandwith to the above, the nagle case would have
better average latency, but it would be less smooth.  I'd say that whether
you want nagle on or off in this case is a matter of taste (unless you
have to pay for your bytes...).

To summarize:

* Nagle should be turned off for X11 sessions.

* Nagle could be either on or off for pure shell sessions. (taste)

* Nagle can be off for sftp, since it is well behaved, and does not 
  generate unneccesary tinygrams.  Probably true for all (future) 
  subsystems as well.  The current problem we have with nagle and sftp can
  either be solved by letting nagle merge our two tinygrams, or by merging
  them in the ssh code.  I'd prefer adding buffering to ssh to merge them
  in the application.  Marcus?

My suggestion is to turn off nagle unconditionally now, and to add an
option later to turn it on, perhaps make it on by default for pure shell
sessions.

And it would be really really helpful if there was a way for the ssh
client to tell the server to turn nagle off.

/Tobias

( Nico, you really really need do do something about your pathetic sig... ;)






More information about the openssh-unix-dev mailing list