跳到主要内容

II. Telnet 协议的定义

Telnet 协议的目的,是提供一种标准方法,把某一站点的终端设备与另一站点的进程连接起来。

Telnet 协议由三个主要的子结构构成:第一是初始连接协议(Initial Connection Protocol,ICP),第二是网络虚拟终端(NVT),第三是本文所述的 Telnet 控制信号。

Telnet 的用户进程和服务器进程遵循 ICP 建立连接。“Logger”一词指服务系统中响应 ICP 并执行最初交互(例如获取用户名和密码)的那组进程。ICP 以及初始套接字号和字节大小参数,在《Current Network Protocols》(NIC #7104)中定义。

用户程序与服务器程序之间(以及反向)传输的数据,被视为内嵌控制信号的字符流。

注意,所有编码值均以十进制给出。

Telnet 控制信号​

NAME             CODE    MEANING

DATA MARK        128     Used to mark a point in the data stream.
                         Used in conjunction with INS.  See SYNCH.

BREAK            129     User-to-Server:  Has the same meaning to
                         the server as the "Break," "Interrupt," or
                         "Attention" button found on many terminals.

                         Server-to-User:  Has the same meaning to
                         to use as the "reverse break" used with
                         some terminals.

NOP              130     No Operation.

NO ECHO          131     User-to-Server:  Asks the server not to
                         return Echos of the transmitted data.

                         Server-to-User:  States that the server is
                         not sending echos of the transmitted data.
                         Sent only as a reply to ECHO or NO ECHO,
                         or to end the hide your input.

ECHO             132     User-to-Server:  Asks the server to send
                         Echos of the transmitted data.

                         Server-to User:  States that the server is
                         sending echos of the transmitted data.
                         Sent only as a reply to ECHO or NO ECHO.

Hide your input  133     The intention is that a server will send
                         this signal to a user system which is
                         echoing locally (to the user) when the user
                         is about to type something secret (e.g. a
                         password).  In this case, the user system
                         is to suppress local echoing or overprint
                         the input (or something) until the server
                         sends a NOECHO signal.  In situations where
                         the user system is not echoing locally,
                         this signal must not be sent by the server.

INS              ---     This is the "Interrupt on Send" signal,
                         defined by the Host-to-Host protocol and
                         implemented by the Network Control Program
                         (NCP).  See SYNCH.

SYNCH            ---     This is a condition indicated by the
                         combination of the DATA MARK and the INS.

                         User-to-Server:  The Server is to examine
                         the input data stream looking for a DATA
                         MARK signal; if a DATA MARK is found, the
                         server must not process further until an
                         INS is received.  If the server receives an
                         INS, it is required to examine the data
                         stream at once, taking any appropriate
                         action on "break type" characters (e.g.
                         etx, sub, BREAK), up to a DATA MARK signal
                         and thereupon continue its normal processing.
                         The passed over characters may be discarded.

                         Server-to-User:  If the user finds a DATA
                         MARK in the data stream, it must wait for
                         an INS.  If the user receives an INS, it
                         must examine and discard characters up to
                         and including a DATA MARK.

数据类型​

Telnet 通常处理 ASCII 字符,但也有转义到其他字符集的规定。如果使用了这类转义,Telnet 信号是否仍然有意义,甚至如何返回 ASCII 字符集,(在此)均未定义。用于指示字符集切换的 Telnet 信号如下:

CODE          MEANING

160 ASCII - Standard Telnet
161 Transparent
162 EBCDIC

用户 Telnet 信号​

下列信号应可供人类用户使用,以使用户 Telnet 执行所指示的动作。

Transmit Now         -  Transmit all data entered and locally
buffered now. Intended to be used with line
mode.

Suppress end-of-line - Transmit all data entered and locally
buffered now, and do not transmit the
end-of-line immediately following this signal.

标准 Telnet 实现​

使用站点(Using Site)

  1. 用户能够输入并发送全部 ASCII 编码。
  2. 用户能够使 Telnet 信号 BREAK、SYNCH、ECHO 和 NOECHO 被发送。
  3. 提供用户 Telnet 信号(例如 Transmit Now)。
  4. 实现 CR LF 行结束约定。
  5. 为本地用户终端提供本地回显。
  6. 正确处理从服务器收到的 Telnet 信号 BREAK、SYNCH、NOP、ECHO、NOECHO 和 Hide Your Input。

服务站点(Serving Site)

  1. 提供 ASCII 与本地字符集之间的映射。
  2. 正确处理 Telnet 信号 BREAK、SYNCH、NOP、NOECHO 和 ECHO。
  3. 实现 CR LF 行结束约定。
  4. 假定使用站点提供回显。可以提供服务器回显模式。

最小 Telnet 实现​

使用站点(Using Site)

  1. 用户必须能够输入并发送全部 ASCII 编码。
  2. 忽略并删除来自服务站点的所有 Telnet 信号。
  3. 为本地用户终端提供本地回显。
  4. 实现 CR LF 行结束约定。
  5. 提供用户 Telnet 信号。

服务站点(Serving Site)

  1. 提供 ASCII 与本地字符集之间的映射。
  2. 忽略并删除来自使用站点的所有 Telnet 信号。
  3. 假定使用站点提供回显。
  4. 实现 CR LF 行结束约定。