News for hackers. Stuff that matters.
Re:SSH uses four TCP segments for each character you type by simias on Thursday May 30, 2013 @10:14AM (#5792581)
Well, that's just called "remote echo" and it doesn't have much to do with SSH. It's just that the remote is in charge of drawing the character on the screen if needed.

If you change to "local echo" it would cause problems with programs such as vi which will interpret certain characters (such as hjkl) as special commands and won't actually draw them on the screen.

If you start a remote program that just "eats" your input without updating the terminal (like a password prompt) you won't see the 2nd tcp roundtrip.

You'd have the same behaviour with a serial link, rsh, telnet or anything else.

I think I saw a custom SSH client on hn some months ago that would try to compensate high network latencies by echoing the characters locally while waiting for the remote reply. It would then undo the local echo and use the "authoritative" reply instead.

Re:SSH uses four TCP segments for each character you type by pronoiac on Thursday May 30, 2013 @10:28AM (#5792689)
The article isn't as judgmental as the headline makes it sound. It notes that in practice, it only sends three segments across the wire, and that's what I'd expect from telnet, too.
Re:SSH uses four TCP segments for each character you type by simias on Thursday May 30, 2013 @10:31AM (#5792713)
Indeed, I didn't mean to sound harsh either. I just wanted to point out that this is in no way specific to SSH as the headline seems to imply.
Re:SSH uses four TCP segments for each character you type by pronoiac on Thursday May 30, 2013 @10:42AM (#5792797)
You didn't seem harsh. In retrospect, I should have made that as a top-level comment instead of a reply.
Re:SSH uses four TCP segments for each character you type by robinson-wall on Thursday May 30, 2013 @10:29AM (#5792700)
Are you thinking of Mosh? http://mosh.mit.edu/
Re:SSH uses four TCP segments for each character you type by markild on Thursday May 30, 2013 @10:41AM (#5792786)
I have used Mosh as my primary remote access client for a few months on my "on-the-go" laptop, and I must say that the user experience is very good.

In a lot of scenarios, the latency is not much of an issue, but on wlan/3g, this very fast become very noticeable. In the few cases since, I've used ssh on wireless, I suddenly find myself noticing how much of an issue the sudden feedback delay might be at some times.

Re:SSH uses four TCP segments for each character you type by eridius on Thursday May 30, 2013 @02:25PM (#5794230)
Not only is mosh great for latency, but it's also great for laptops because of IP roaming. These days I have a dedicated Terminal window with a permanent Mosh session to my Linode. The Mosh session never shuts down (unless I'm rebooting), no matter how often I put my laptop to sleep, or go between home and work.
Re:SSH uses four TCP segments for each character you type by markild on Friday May 31, 2013 @06:08AM (#5797677)
Indeed.

The only obvious downside to Mosh I've seen so far, is that a lot of enterprisy firewalls tend to block UDP traffic.

Re:SSH uses four TCP segments for each character you type by simias on Thursday May 30, 2013 @10:33AM (#5792727)
That's the one, and after watching the video again it's actually more clever than my "local echo" description even though it's part of it.
Re:SSH uses four TCP segments for each character you type by notaddicted on Thursday May 30, 2013 @10:38AM (#5792773)
For a high latency situation if you're text editing there is EMACS TRAMP mode, and probably others similar that buffer the file locally, which will also solve the responsiveness problem.
Re:SSH uses four TCP segments for each character you type by ajross on Thursday May 30, 2013 @01:31PM (#5793877)
Exactly. In the modern world latency concerns so outstrip bandwidth issues that it's actually much saner to copy the whole file across the wire than it is to try to edit it locally. The curmudgeon in me finds that amazing sometimes.
Re:SSH uses four TCP segments for each character you type by notaddicted on Thursday May 30, 2013 @02:31PM (#5794272)
Yup. For command line work I usually don't mind but for text editing I find any perceptible latency incredibly grating. SSHFS is another solution that doesn't need anything special installed on the remote end. It's a pity Plan9 didn't take off, I think it hides this kind of pointless drudgery.
Re:SSH uses four TCP segments for each character you type by jdonahue on Thursday May 30, 2013 @04:22PM (#5794965)
I think it would be neat if SSH provided an API or a set of special characters so that the remote shell could tell SSH to switch back and forth between remote and local echo. For example, bash could tell SSH to begin local echo mode after it finishes printing the prompt, and end local echo mode when the user enters a key sequence that requires remote processing, like Tab or Return. vim could enter local echo mode when the user enters insert mode and leave when the user presses the Esc or Return, etc.

Perhaps this extra complexity would lead to all sorts of strange bugs though.

Re:SSH uses four TCP segments for each character you type by simias on Thursday May 30, 2013 @05:25PM (#5795342)
There already exists such an API at the TTY level (see man 4 termios). You can switch between so called "canonical" mode where the input is buffered by lines or non-canonical to get the input byte by byte without waiting. You can also switch echo on and off among other things.

I don't think ssh sends that back to the client terminal though, but I must say I'm not really sure how that's handled. On one hand I'd like to know better how unix TTYs work, but on the other I value my sanity so I'm probably not looking back into those just now :).

Re:SSH uses four TCP segments for each character you type by akjj on Thursday May 30, 2013 @10:28PM (#5796531)
This is right, but the canonical/non-canonical distinction is all or nothing. Bash echos most characters, but it needs to treat a handful, like tab, up, and down, specially so it (or readline probably) puts the terminal in non-buffered mode and ends up echoing the normal characters. I read the GP as suggesting that there should be a way for bash to indicate which characters were "normal" and should be buffered and echoed and which it wants to see immediately. It's an interesting idea, but of course such a mechanism would require coordination between the kernel's terminal interface, bash/readline, and ssh in order to get a marginal improvement in network efficiency.
Re:SSH uses four TCP segments for each character you type by jdonahue on Thursday May 30, 2013 @07:35PM (#5795949)
Ah, providing it at the terminal level does make more sense (that was probably obvious to anyone with any familiarity with the basics of Unix terminals, sorry), and now that I hear it I'm not surprised it already exists :)

In that case, I guess this functionality would be implemented similarly to the example you mentioned of stopping the client from sending every keystroke at a password prompt, right? It seems like it would be strange for ssh to send the 'toggle echo' signals to the client, but not the 'toggle canonical mode' signals (which the client could also handle in a useful way).

Re:SSH uses four TCP segments for each character you type by ephemient on Thursday May 30, 2013 @05:30PM (#5795367)
Are you thinking of EXTPROC/LINEMODE? There's outstanding patches to bash, telnet, and ssh to support these, which enables local line-editing that works smarter than just local echo.

TIOCPKT_IOCTL(EXTPROC) and TIOCSIG support landed in Linux kernel 2.6.36: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux....