netprog: telnet1 the telnet protocol mozafar bag mohammadi
Post on 18-Jan-2018
227 Views
Preview:
DESCRIPTION
TRANSCRIPT
Netprog: TELNET 1
The TELNET ProtocolThe TELNET Protocol
Mozafar Bag mohammadiMozafar Bag mohammadi
Netprog: TELNET 2
TelnetTelnet Telnet date back to late 1960s is generally Telnet date back to late 1960s is generally
consider the first network application.consider the first network application.– There are several RFCs are listed at the end of There are several RFCs are listed at the end of
the lecture.the lecture. Uses a client/server model to define a Uses a client/server model to define a
standard way in which to interact with a standard way in which to interact with a remote system.remote system.– The telnet protocol is the basis for many protocolsThe telnet protocol is the basis for many protocols
» FTP, HTTP, SMTP, NTTP just to name a few.FTP, HTTP, SMTP, NTTP just to name a few. They don’t open a telnet connection, just use the protocol.They don’t open a telnet connection, just use the protocol.
Netprog: TELNET 3
Telnet (2)Telnet (2)
While telnet should be a very simple While telnet should be a very simple protocol, it’s not.protocol, it’s not.– It has to deal with all communications It has to deal with all communications
methods that different terminal and methods that different terminal and computers use.computers use.
– It ensures compatibility between the It ensures compatibility between the terminal types and computers and still terminal types and computers and still allow the special features used.allow the special features used.
Netprog: TELNET 4
TELNET vs. TELNET vs. telnettelnet TELNET is a TELNET is a protocolprotocol that provides “a that provides “a
general, bi-directional, eight-bit byte general, bi-directional, eight-bit byte
oriented communications facility”.oriented communications facility”. telnettelnet is a is a programprogram that supports the that supports the
TELNET protocol over TCP.TELNET protocol over TCP.
Netprog: TELNET 5
The TELNET ProtocolThe TELNET Protocol
TCP connectionTCP connection data and control over the same data and control over the same
connection.connection. Network Virtual TerminalNetwork Virtual Terminal negotiated optionsnegotiated options
Netprog: TELNET 6
Network Virtual TerminalNetwork Virtual Terminal
All communications uses a standard All communications uses a standard terminal called NVTterminal called NVT– The client takes input, translates into NVT The client takes input, translates into NVT
sends it to the server, which translates to sends it to the server, which translates to the representation that the computer uses.the representation that the computer uses.
– Special Telnet commands are interspersed Special Telnet commands are interspersed with the data to perform the functions with the data to perform the functions needed for the operation of the protocolneeded for the operation of the protocol
Netprog: TELNET 7
Network Virtual TerminalNetwork Virtual Terminal
NVTNVT NVTNVT
ServerServerProcessProcess
TCPTCP TCPTCP
Netprog: TELNET 8
TelnetTelnet
Netprog: TELNET 9
NVT ASCII Control Codes NVT ASCII Control Codes
Three mandatory codesThree mandatory codes– 0, Null 0, Null
» No operation, no effect on outputNo operation, no effect on output– 10, Line Feed10, Line Feed
» Moves printer to the next line, keep same print Moves printer to the next line, keep same print positionposition
– 13, Carriage Return 13, Carriage Return » Moves the printer to the left margin of the Moves the printer to the left margin of the
current linecurrent line
Netprog: TELNET 10
NVT ASCII Control Codes(2)NVT ASCII Control Codes(2)
Optional CodesOptional Codes– 7, Bell7, Bell– 8, Back Space8, Back Space
» Move the print position one character to the leftMove the print position one character to the left– 9, Horizontal tab9, Horizontal tab– 11, Vertical Tab11, Vertical Tab
» devices negotiate to agree on tab stopsdevices negotiate to agree on tab stops– 12, Form Feed12, Form Feed
» next page or clear the screen and put cursor at the next page or clear the screen and put cursor at the toptop
Netprog: TELNET 11
NVT ASCII Control Codes(3)NVT ASCII Control Codes(3)
End of line markerEnd of line marker– Since different computers use different Since different computers use different
standards for the end of line marker,standards for the end of line marker,– CR+LF is defined as the end of line CR+LF is defined as the end of line
marker.marker.
Netprog: TELNET 12
Negotiated OptionsNegotiated Options
All NVTs support a minimal set of All NVTs support a minimal set of capabilities.capabilities.
Some terminals have more capabilities Some terminals have more capabilities than the minimal set.than the minimal set.
The 2 endpoints negotiate a set of The 2 endpoints negotiate a set of mutually acceptable options (character mutually acceptable options (character set, echo mode, etc).set, echo mode, etc).
Netprog: TELNET 13
Negotiated OptionsNegotiated Options
The protocol for requesting optional The protocol for requesting optional features is well defined and includes features is well defined and includes rules for eliminating possible negotiation rules for eliminating possible negotiation “loops”.“loops”.
The set of options is not part of the The set of options is not part of the TELNET protocol, so that new terminal TELNET protocol, so that new terminal features can be incorporated without features can be incorporated without changing the TELNET protocol.changing the TELNET protocol.
Netprog: TELNET 14
Option examplesOption examples
Line mode vs. character modeLine mode vs. character mode
echo modesecho modes
character set (EBCDIC vs. ASCII)character set (EBCDIC vs. ASCII)
Netprog: TELNET 15
Control FunctionsControl Functions
TELNET includes support for a series of TELNET includes support for a series of control functions commonly supported control functions commonly supported by servers.by servers.
This provides a uniform mechanism for This provides a uniform mechanism for communication of (the supported) communication of (the supported) control functions.control functions.
Netprog: TELNET 16
Control FunctionsControl Functions
Interrupt Process (IP)Interrupt Process (IP)– suspend/abort process.suspend/abort process.
Abort Output (AO)Abort Output (AO)– process can complete, but send no more process can complete, but send no more
output to user’s terminal.output to user’s terminal. Are You There (AYT)Are You There (AYT)
– check to see if system is still running.check to see if system is still running.
Netprog: TELNET 17
More Control FunctionsMore Control Functions
Erase Character (EC)Erase Character (EC)– delete last character sentdelete last character sent– typically used to edit keyboard input.typically used to edit keyboard input.
Erase Line (EL)Erase Line (EL)– delete all input in current line.delete all input in current line.
Netprog: TELNET 18
Command StructureCommand Structure
All TELNET commands and data flow All TELNET commands and data flow through the same TCP connection.through the same TCP connection.
Commands start with a special Commands start with a special character called the Interpret as character called the Interpret as Command Command escapeescape character (IAC). character (IAC).
The IAC code is 255.The IAC code is 255. If a 255 is sent as data - it must be If a 255 is sent as data - it must be
followed by another 255.followed by another 255.
Netprog: TELNET 19
Looking for CommandsLooking for Commands
Each receiver must look at each byte Each receiver must look at each byte that arrives and look for IAC.that arrives and look for IAC.
If IAC is found and the next byte is IAC - If IAC is found and the next byte is IAC - a single byte is presented to the a single byte is presented to the application/terminal (a 255).application/terminal (a 255).
If IAC is followed by any other code - If IAC is followed by any other code - the TELNET layer interprets this as a the TELNET layer interprets this as a command.command.
Netprog: TELNET 20
commandscommands
WILL option (to Enable an option)WILL option (to Enable an option)– Response is eitherResponse is either
» DO option, indicate agreement and enable DO option, indicate agreement and enable optionoption
» DONT option, initiator must not use the option.DONT option, initiator must not use the option. WONT option (to disable option)WONT option (to disable option)
– Response must beResponse must be» DONT option, option is disabled.DONT option, option is disabled.
Netprog: TELNET 21
Command CodesCommand Codes
IPIP 243243 AO AO 244244 AYTAYT 245245 ECEC 246246 ELEL 247247
WILLWILL 251251 WON’TWON’T 252252 DODO 253253 DON’TDON’T 254254 IACIAC 255255
Netprog: TELNET 22
Telnet OptionsTelnet Options
When a option needs more parametersWhen a option needs more parameters– Use SB (subnegotiation) and SE (end Use SB (subnegotiation) and SE (end
subnegotiation )commandsubnegotiation )command Example: negotiate the terminal type Example: negotiate the terminal type
– (IAC is interpret as command)(IAC is interpret as command) IAC WILL Terminal-typeIAC WILL Terminal-type IAC DO Terminal-typeIAC DO Terminal-type IAC SB terminal-type SEND IAC SEIAC SB terminal-type SEND IAC SE IAC SB TERINAL-TYPE IS <type> IAC SEIAC SB TERINAL-TYPE IS <type> IAC SE
Netprog: TELNET 23
Playing with TELNETPlaying with TELNET
You can use the You can use the telnettelnet program to program to play with the TELNET protocol.play with the TELNET protocol.
telnet telnet is a is a genericgeneric TCP client. TCP client.– Sends whatever you type to the TCP Sends whatever you type to the TCP
socket.socket.– Prints whatever comes back through the Prints whatever comes back through the
TCP socket.TCP socket.– Useful for testing TCP servers (ASCII Useful for testing TCP servers (ASCII
based protocols).based protocols).
Netprog: TELNET 24
Some TCP Servers you can Some TCP Servers you can play withplay with
Many Unix systems have these servers Many Unix systems have these servers running (by default):running (by default):– echoecho port 7port 7– discarddiscard port 9port 9– daytimedaytime port 13port 13– chargenchargen port 19port 19
Netprog: TELNET 25
telnet hostname porttelnet hostname port> > telnet rcs.rpi.edu 7telnet rcs.rpi.edu 7Trying 128.113.113.33...Trying 128.113.113.33...Connected to cortez.sss.rpi.edu Connected to cortez.sss.rpi.edu (128.113.113.33).(128.113.113.33).
Escape character is '^]'.Escape character is '^]'.Hi daveHi daveHi daveHi davestop itstop itstop itstop it^]^]telnet> telnet> quitquitConnection closed.Connection closed.
Netprog: TELNET 26
telnettelnet vs. TCP vs. TCP
Not all TCP servers talk TELNET (most don't) Not all TCP servers talk TELNET (most don't)
You can use the You can use the telnettelnet program to play with program to play with these servers, but the fancy commands won't these servers, but the fancy commands won't do anything.do anything.– type ^], then "help" for a list of fancy TELNET stuff type ^], then "help" for a list of fancy TELNET stuff
you can do in you can do in telnettelnet..
Netprog: TELNET 27
RFCsRFCs
The first RFC specifically defining The first RFC specifically defining Telnet was RFC 97, Telnet was RFC 97, First Cut at a First Cut at a Proposed Telnet ProtocolProposed Telnet Protocol, published in , published in February 1971. February 1971.
Telnet Protocol SpecificationTelnet Protocol Specification, was , was published as RFC 854 in May 1983.published as RFC 854 in May 1983.
Telnet Option SpecificationsTelnet Option Specifications, , RFC 855RFC 855
top related