Commands and option negotiation
Echo and Suppress Go Ahead
Understand why Telnet negotiates who echoes typed characters and whether the old half-duplex Go Ahead signal is needed.
When you type a character into a terminal session, something has to display it. That job is called echo, and there are two ways to assign it.
With local echo, the client displays a character as you type it. With remote echo, the server sends the character back and the client displays the returned copy.
If both sides echo, you see everything twice. If neither does, you see nothing. So Telnet negotiates the ECHO option, defined in RFC 857 as option code 1. A typical remote-login server offers to do the echoing:
server: 255 251 1 IAC WILL ECHO (I will echo what you type)
client: 255 253 1 IAC DO ECHO (agreed, you echo)
After this exchange the client stops echoing locally and displays only what the server returns.
Get this wrong and you see it immediately. Two echoes duplicate every character, so typing ls shows llss. No echo makes your typing invisible, even though the bytes still leave your machine and the commands still run.
Remote echo is also how old-school servers hid your password. The server agreed to echo, and then chose not to echo those particular characters. The client, trusting the server to paint the screen, showed nothing.
Suppress Go Ahead
The original NVT model assumed half-duplex terminals, devices that could not send and receive at the same time. So the protocol included a Go Ahead signal, IAC GA, meaning “your turn to transmit”.
Modern connections are full duplex. The signal is pure overhead. Sessions normally negotiate Suppress Go Ahead, or SGA, option code 3, in both directions:
server: 255 251 3 IAC WILL SGA
client: 255 253 3 IAC DO SGA
Both directions matter because, as you learned in the previous lesson, each direction is a separate agreement. The client also offers WILL SGA and the server answers DO SGA.
ECHO and SGA together are what turn a Telnet session into the character-at-a-time mode most people expect. Almost every real session negotiates both within the first few bytes.
Echo is not buffering
Echo and line buffering are separate ideas, and people mix them up when debugging.
A client may show characters locally while waiting for Enter before sending the line. Or it may send each character the moment you press it. One question is who paints the character on screen. The other is when the bytes leave the machine.
Keep them apart when a session feels strange. Duplicated or missing characters point at echo. Typing that appears instantly but only reaches the server when you press Enter points at buffering.
Lesson completed