Title: Telnet
1Telnet
- The Telnet Protocol
- RFC 854
2Overview of Telnet
- Allow for remote logins to a host computer via
the Internet - Essentially a raw socket
- Emulates a virtual terminal
- Excellent site
- http//www.scit.wlv.ac.uk/jphb/comms/telnet.html
- Note SSH is Secure SHell an encrypted version
of Telnet (port 22)
3Network Virtual Terminals
- Mega-Handshake
- Determine
- Terminal type
- Terminal width/height
- Terminal Speed
- Remote Flow Control
- Environment Variables
4WILL / WONT / DO / DONTVirtual Terminal
Negotiations
- WILL Sender supports certain functionality
- WONT Sender cannot support the specified
functionality - DO Sender wants the other end to do something
- DONT Sender wants the other end not to do
something
5Combinations
- Sender WILL/Receiver DO Sender wants to use
certain functionality. Receiver says OK. - Sender WILL/Receiver DONT Receiver cannot
support that option - Sender DO/ Receiver WILL Sender can handle
certain functionality if receiver wants. - Sender DO/ Receiver WONT Receiver cannot support
option - Sender WONT/ Receiver DONT Option disabled
- Sender DONT/ Receiver WONT Option disabled
6Telnet Algorithmics
- Telnet begins at port 23
- Client and server communicate in eight-bit bytes
- Client and server negotiate options
- Normal telnet commands are sent
7ASCII 0-127
8Commands
- Distinguished by the most significant bit set!
- SE 240 End subnegotiations
- NOP 241 No operation
- AYT 246 Are you there?
- GA 249 Go ahead. Used in old dialup
- SB 250 Subnegotiations
- IAC 255 Interpret As Command
9Negotiable Options
- Echo 1 RFC 857
- Suppress Go Ahead 3 RFC 858
- Status 5 RFC 859
- Timing Mark 6 RFC 860
- Terminal Type 24 RFC 1091
- Window Size 31 RFC 1073
- Terminal Speed 32 RFC 1079
- Remote Flow Ctrl 33 RFC 1372
- Linemode 34 RFC 1184
- Environment Vars 36 RFC 1408
10Negotiable Options
- For some options, further negotiations are
needed - Client 255 (IAC), 251 (WILL), 24 (Term Type)
- Server255 (IAC), 253 (DO), 24
- Server255 (IAC), 250 (SB), 24, 1 , 255 (IAC),
240 (SE) - Client 255 (IAC), 250 (SB), 24, 0, 'V', 'T',
'1', '0', '0', 255 (IAC), 240 (SE)
11How Telnet Works
Primary Thread
Server
12Enter the Client
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
13Client Bombards with InformationSuppress Go Ahead
255 (IAC), 253 (DO), 3 (SGA)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
14Client Bombards with InformationWill Term Type
255 (IAC), 251 (WILL), 24 (TT)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
15Client Bombards with InformationWill NAWS
255 (IAC), 251 (WILL), 31 (WinSize)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
16Client Bombards with InformationWill TermSpeed
255 (IAC), 251 (WILL), 32 (TS)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
17Client Bombards with InformationWill LineFlow
255 (IAC), 251 (WILL), 33 (LF)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
18Client Bombards with InformationWill LineMode
255 (IAC), 251 (WILL), 34 (LM)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
19Client Bombards with InformationWill New
Environment
255 (IAC), 251 (WILL), 36 (NEnv)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
20Client Bombards with InformationWill Status
255 (IAC), 251 (WILL), 5 (Status)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
21Client Bombards with InformationWill XDisplay
255 (IAC), 251 (WILL), 35 (XDisp)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
22Get Ready
- Server will now send back a series of DOs
- Each option is sub-negotiated
23Server Bombards with InformationDO TermType
255 (IAC), 251 (DO), 24 (Type)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
24Server Bombards with InformationInterpret
Command and Send Response
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
25Server Bombards with Information Interpret
Command and Send Response
255 (IAC), 250 (SB), 24 (Type), 0, 'V', 'T', '1',
'0', '0', 255, 240 (SE)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
26Server Bombards with InformationDO WinSize
255 (IAC), 251 (DO), 31 (WinSize)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
27Server Bombards with InformationInterpret
Command and Send Response
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
28Server Bombards with Information Interpret
Command and Send Response
255 (IAC), 250 (SB), 31 (WinSize), 0, 80, 0, 24,
255, 240 (SE)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
29Etc Etc
255 (IAC), 251 (DO), X
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
30Etc Etc
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
31Etc Etc
255 (IAC), 250 (SB), X, X, X, 255, 240 (SE)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
32What if you DONT want to do something?
- Send the WONT command
- Good default response!
- Technically, you can do this for ALL responses
- Good if you don't know what the option is
- Example Timing mark
33Server Requests DO
255 (IAC), 251 (DO), 6 (TMark)
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
34Interpret Command
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
35Send Back WONT
255 (IAC), 252 (WONT), 6
Primary Thread
Primary Thread
Socket (23)
Secondary Reader Thread
Client
Server
36Overall Algorithm
- Byte mode
- Optionally send all your DOs
- Interpret commands coming over the net
- Send appropriate responses
- String mode
- Read and send Strings for the rest of the time
37Things that Might Save You Time
- A class that
- knows all the command codes (constants)
- can print out those codes in English
- A class that can send terminal info
- Big case statement
- Generic sendDO( ), sendDONT( )
- Generic sendWILL( ), send WONT( )
- Specific methods for sending subnegotiated
options (like TermType, TermSpeed, etc)
38(No Transcript)