Option Negotiation between Telnet connections

Source: Internet
Author: User

Telnet runs at the application layer based on the TCP transmission protocol and provides terminal interaction between the client and the server.

Telnet uses a TCP connection. Unlike FTP, two TCP connections are used. The port number used by the telnet server is 23.

Both Parties shall negotiate options during Telnet connection.
For example, the size of the window in character mode and the terminal type must be negotiated.
Negotiation is implemented through commands supported by Telnet.

Common Telnet commands (For details, refer to TCP/IP details p303 ):
Se 240 (F0) suboption ended
Start with Sb 250 (FA) sub-option
The first byte negotiated by the IAC 255 (FF) Option
Will 251 (FB) sender activation option (Recipient agrees to activation option)
Do 253 (FD) receiver agrees (sender wants recipient to activate option)
Wont 252 (FC) receiver does not agree
Dont 254 (FE) receiver responds to wont

Common Telnet optionsCode(For details, see TCP/IP p304 ):
1 (0x01) echo)
3 (0x03) suppress continues (you can select this option to transfer one character at a time)
24 (0x18) terminal type
31 (0x1f) window size
32 (0x20) terminal speed
33 (0x21) remote traffic control
34 (0x22) rows
36 (0x24) Environment Variables

For example, the actual process of establishing a telnet connection is as follows: (192.168.1.11 is the client. 192.168.1.1 is the server)
1) TCP: 192.168.1.11: 49200> 192.168.1.1: 23 [SYN]
2) TCP: 192.168.1.1: 23> 192.168.1.11: 49200 [SYN, ack]
3) TCP: 192.168.1.11: 49200> 192.168.1.1: 23 [ack]
4) telnet: 23> 49200 IAC do 24 (meaning that the receiver can activate the terminal class dynamic command: Do terminal type)
5) telnet: 49200> 23 IAC will 24/IAC will 31 (the two commands IAC will 24 IAC will 31 respectively indicate command: Will terminal type/command will negotiate about window size) tell the server to agree to the terminal type and activate the window size.
6) telnet: 23> 49200 IAC do 31/IAC Sb 18 24 01/IAC Se (Response client allows negotiation window size/sub-option send your terminal type/sub-option to end)
7) telnet: 49200> 23 iac sb 31 80 26/IAC Se (Response server, the size of the sub-option window is 80/26/the sub-option ends)
8) telnet: 49200> 23 IAC Sb 18 "ANSI"/IAC se)
9) telnet: 23> 49200 IAC will 03/IAC will 01 (inform the client to allow the suppression to continue/allow ECHO)
10) telnet: 49200> 23 IAC do 03 (in response to the server, the recipient agrees to allow the suppression to continue)
11) telnet: 49200> 23 IAC do 01 (in response to the server, the receiver agrees to allow ECHO)
12) telnet: Data)
13) telnet: Data)
14) telnet: Data)
15) TCP: 192.168.1.11: 49200> 192.168.1.1: 23 [Fin ack] (request to disconnect)
16) TCP: 192.168.1.1: 23> 192.168.1.11: 49200 [ack]
17) TCP: 192.168.1.1: 23> 192.168.1.11: 49200 [Fin ack] (request to disconnect)
18) TCP: 192.168.1.11: 49200> 192.168.1.1: 23 [ack]
.... Here, some sub-option protocols are skipped. generally, you log on to the host and both parties negotiate on some options. and the recipient agrees or does not agree (do, dont, or will wont)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.