CSCE 515 Computer Network Programming Rlogin Telnet Ftp

  • Slides: 49
Download presentation
CSCE 515: Computer Network Programming ------ Rlogin, Telnet, Ftp Wenyuan Xu http: //www. cse.

CSCE 515: Computer Network Programming ------ Rlogin, Telnet, Ftp Wenyuan Xu http: //www. cse. sc. edu/~wyxu/csce 515 f 07. html Department of Computer Science and Engineering University of South Carolina

TELNET vs. telnet n TELNET is a protocol that provides “a general, bidirectional, eight-bit

TELNET vs. telnet n TELNET is a protocol that provides “a general, bidirectional, eight-bit byte oriented communications facility”. n telnet is a program that supports the TELNET protocol over TCP. n RLOGIN is a protocol n rlogin is a program that supports the RLOGIN protocol 2007 CSCE 515 – Computer Network Programming

TELNET and RLOGIN n n Both are used to remote login across network TELNET

TELNET and RLOGIN n n Both are used to remote login across network TELNET is standard application provided by almost every TCP/IP implementation ¨ Can work between hosts running different OSs ¨ Can negotiate options to determine features provided by each end n 2007 RLOGIN is from BSD and was designed to work between Unix systems only CSCE 515 – Computer Network Programming

Local login shell terminal driver kernel user at a terminal 2007 CSCE 515 –

Local login shell terminal driver kernel user at a terminal 2007 CSCE 515 – Computer Network Programming

TELNET Client and Server TELNET client terminal driver TELNET server TCP/IP kernel login shell

TELNET Client and Server TELNET client terminal driver TELNET server TCP/IP kernel login shell pseudoterminal driver TCP/IP login shell kernel user at a terminal Only ONE TCP connection !!! terminal driver kernel user at a terminal 2007 CSCE 515 – Computer Network Programming

RLOGIN

RLOGIN

RLOGIN Protocol – Start up n n n Specified in RFC 1282 Use a

RLOGIN Protocol – Start up n n n Specified in RFC 1282 Use a single TCP connection Protocol between client and server after connection is set up ¨ Client writes 4 strings to server n n n a byte of 0 login name of user on client, terminated by a byte of 0 login name of user on server, terminated by a byte of 0 name of user’s terminal type, a slash, terminal speed, terminated by a byte of 0 ( John ibmpc 3/9600) Server responds with a byte of 0 ¨ Optionally server can ask user for a password ¨ Server sends a request to client asking for terminal’s window size ¨ 2007 CSCE 515 – Computer Network Programming

Interactive input Client Server keystroke 1 byte Date ACK x = 1 WIN =

Interactive input Client Server keystroke 1 byte Date ACK x = 1 WIN = xx 1 byte Date Server echo display ACK = 1 2007 WIN = x xx CSCE 515 – Computer Network Programming

Flow control Done by client n User type Control-S, Control-Q, asking SERVER to stop

Flow control Done by client n User type Control-S, Control-Q, asking SERVER to stop sending data, or start sending data n ¨ Control-S stop writing to the network ¨ Control-Q start writing to the network n 2007 Control by Server CSCE 515 – Computer Network Programming

Server to Client Commands n n Need to mark command bytes because only one

Server to Client Commands n n Need to mark command bytes because only one TCP connection is used Use TCP’s urgent mode to mark command bytes To send a command to client, server enters urgent mode and makes command byte the last byte of urgent data Four command bytes 0 x 02: client flushes output ¨ 0 x 10: client stops performing flow control ¨ 0 x 20: client resumes flow control ¨ 0 x 80: client sends current window size to server immediately and notifies server if changing window size ¨ n 2007 Out-of-band signaling CSCE 515 – Computer Network Programming

TCP Segment Format 0 15 16 source port number 31 destination port number sequence

TCP Segment Format 0 15 16 source port number 31 destination port number sequence number acknowledgment number header length reserved U A P R S F R C S S Y I G K H T N N TCP checksum window size urgent pointer option (if any) data (if any) 2007 CSCE 515 – Computer Network Programming 20 bytes

Client to Server Command n n When client receives command 0 x 80 from

Client to Server Command n n When client receives command 0 x 80 from server, client needs to send window size to server This command needs to be marked ¨ 2 bytes of 0 xff ¨ 2 flag bytes of ASCII char ‘s’ ¨ 4 16 -bit values: #rows, #chars per row, #pixels in X direction, #pixels in Y direction n 2007 In-band signaling CSCE 515 – Computer Network Programming

RLOGIN Client Escape n n n Talk to client directly instead of sending the

RLOGIN Client Escape n n n Talk to client directly instead of sending the input to server Start with a tilde ‘~’ Followed by one of four characters ¨ ‘. ’: terminate client ¨ EOF (Ctrl-D): terminate client ¨ Job control suspend char (Ctrl-Z): suspend client ¨ Job control delayed suspend char (Ctrl-Y): suspend only client input but keep server output 2007 CSCE 515 – Computer Network Programming

TELNET

TELNET

TELNET Protocol n Specified in RFC 854 TCP connection n data and control over

TELNET Protocol n Specified in RFC 854 TCP connection n data and control over the same connection. n Network Virtual Terminal n ¨ Designed to work between any host and any terminal n 2007 Negotiated options CSCE 515 – Computer Network Programming

Network Virtual Terminal Server Process 2007 NVT TCP CSCE 515 – Computer Network Programming

Network Virtual Terminal Server Process 2007 NVT TCP CSCE 515 – Computer Network Programming

Network Virtual Terminal n n intermediate representation of a generic terminal. provides a standard

Network Virtual Terminal n n intermediate representation of a generic terminal. provides a standard language for communication of terminal control functions. ¨ Client maps user’s terminal type to NVT ¨ Server maps NVT into its terminal type n 2007 Use NVT ASCII, the 7 -bit US variant of ASCII character set, but also allow 8 -bit data transmission CSCE 515 – Computer Network Programming

Negotiated Options All NVTs support a minimal set of capabilities. n Some terminals have

Negotiated Options All NVTs support a minimal set of capabilities. n Some terminals have more capabilities than the minimal set. n The 2 endpoints negotiate a set of mutually acceptable options (character set, echo mode, etc). n 2007 CSCE 515 – Computer Network Programming

Negotiated Options The protocol for requesting optional features is well defined and includes rules

Negotiated Options The protocol for requesting optional features is well defined and includes rules for eliminating possible negotiation “loops”. n The set of options is not part of the TELNET protocol, so that new terminal features can be incorporated without changing the TELNET protocol. n 2007 CSCE 515 – Computer Network Programming

Option examples n Four operation modes ¨ Half-duplex ¨ Character at a time ¨

Option examples n Four operation modes ¨ Half-duplex ¨ Character at a time ¨ Linemode n 2007 character set (EBCDIC vs. ASCII) CSCE 515 – Computer Network Programming

Command Structure n In-band signaling for both directions ¨ All TELNET commands and data

Command Structure n In-band signaling for both directions ¨ All TELNET commands and data flow through the same TCP connection. n Commands start with a special character called the Interpret as Command (IAC) escape character. ¨ The n IAC code is 255 (0 xff). Next byte is command byte ¨ <IAC n 2007 COMMAND XX > If a 0 xff is sent as data - it must be followed by another 0 xff. CSCE 515 – Computer Network Programming

Looking for Commands n Each receiver must look at each byte that arrives and

Looking for Commands n Each receiver must look at each byte that arrives and look for IAC. n If IAC is found and the next byte is IAC - a single byte is presented to the application/terminal (a 0 xff). n If IAC is followed by any other code - the TELNET layer interprets this as a command. 2007 CSCE 515 – Computer Network Programming

Command Codes IP n AO n AYT n EC n EL n 2007 243

Command Codes IP n AO n AYT n EC n EL n 2007 243 0 xf 3 244 0 xf 4 245 0 xf 5 246 0 xf 6 247 0 xf 7 WILL n WON’T n DON’T n IAC n CSCE 515 – Computer Network Programming 251 0 xfb 252 0 xfc 253 0 xfd 254 0 xfe 255 0 xff

TELNET Option Negotiation n Either side can send request to other side n n

TELNET Option Negotiation n Either side can send request to other side n n <IAC COMMANDID OPTIONID > Four different requests for any given option ¨ WILL: sender wants to enable option n DO: receiver says OK n DONT: receiver says NO ¨ DO: sender wants receiver to enable option n WILL: receiver says OK n WONT: NO ¨ WONT: sender wants to disable option n DONT: receiver must say OK ¨ DONT: sender wants receiver to disable option n WONT receiver must say OK 2007 CSCE 515 – Computer Network Programming

TELNET Options Option ID 1 3 5 6 24 31 32 33 34 36

TELNET Options Option ID 1 3 5 6 24 31 32 33 34 36 2007 Name echo suppress go ahead status timing mark terminal type window size terminal speed remote flow control linemode environment variables CSCE 515 – Computer Network Programming

TELNET Suboption Negotiation n n Used for options that require more information than just

TELNET Suboption Negotiation n n Used for options that require more information than just “enable” or “disable” For example, client: <IAC, WILL, 24> server: <IAC, DO, 24> server: <IAC, SB, 24, 1, IAC, SE> client: <IAC, SB, 24, 0, ‘I’, ‘B’, ‘M’, ‘P’, ‘C’, IAC, SE> 2007 CSCE 515 – Computer Network Programming

Control Functions n TELNET includes support for a series of control functions commonly supported

Control Functions n TELNET includes support for a series of control functions commonly supported by servers. n This provides a uniform mechanism for communication of (the supported) control functions. 2007 CSCE 515 – Computer Network Programming

Control Functions n Interrupt Process (IP) ¨ suspend/abort n process. Abort Output (AO) ¨

Control Functions n Interrupt Process (IP) ¨ suspend/abort n process. Abort Output (AO) ¨ process can complete, but send no more output to user’s terminal. n Are You There (AYT) ¨ check 2007 to see if system is still running. CSCE 515 – Computer Network Programming

More Control Functions n Erase Character (EC) ¨ delete last character sent ¨ typically

More Control Functions n Erase Character (EC) ¨ delete last character sent ¨ typically used to edit keyboard input. n Erase Line (EL) ¨ delete 2007 all input in current line. CSCE 515 – Computer Network Programming

TELNET Client Escape n Talk to client directly instead of sending the input to

TELNET Client Escape n Talk to client directly instead of sending the input to server n Normal client escape char is Ctrl-] n Can type commands to change settings or print information 2007 CSCE 515 – Computer Network Programming

telnet vs. TCP n Not all TCP servers talk TELNET (most don't) n You

telnet vs. TCP n Not all TCP servers talk TELNET (most don't) n You can use the telnet program to play with these servers, but the fancy commands won't do anything. ¨ type ^], then "help" for a list of fancy TELNET stuff you can do in telnet. 2007 CSCE 515 – Computer Network Programming

Playing with TELNET You can use the telnet program to play with the TELNET

Playing with TELNET You can use the telnet program to play with the TELNET protocol. n telnet is a generic TCP client. n ¨ Sends whatever you type to the TCP socket. ¨ Prints whatever comes back through the TCP socket. ¨ Useful for testing TCP servers (ASCII based protocols). 2007 CSCE 515 – Computer Network Programming

Some TCP Servers you can play with n Many Unix systems have these servers

Some TCP Servers you can play with n Many Unix systems have these servers running (by default): ¨ echo ¨ discard ¨ daytime ¨ chargen 2007 port 9 port 13 port 19 CSCE 515 – Computer Network Programming

Security n Does not encrypt any data sent over the connection ¨ Including password

Security n Does not encrypt any data sent over the connection ¨ Including password n No authentication – man in the middle attack n Daemons have vulnerabilities 2007 CSCE 515 – Computer Network Programming

Secure Shell (SSH) n n n Operate over TCP/IP connection or other reliable but

Secure Shell (SSH) n n n Operate over TCP/IP connection or other reliable but insecure transport layers to support secure remote login, secure file transfer and other secure services Can automatically encrypt, authenticate, and compress transmitted data Three major components Transport Layer Protocol to provide server authentication, confidentiality, and integrity ¨ User Authentication Protocol to provide authentication of client -side user to server ¨ Connection Protocol to multiplex encrypted channels to logical channels ¨ 2007 CSCE 515 – Computer Network Programming

FTP

FTP

File Transfer Protocol (FTP) n n n Internet standard for file transfer Designed to

File Transfer Protocol (FTP) n n n Internet standard for file transfer Designed to work between different systems but support limited number of file types and structures Use two TCP connections ¨ Control connection n Client active open to TCP port 21 of server Stay up all the time of communication IP TOS should be “minimize delay” ¨ Data n n 2007 connection Created each time a file is transferred IP TOS should be “maximize throughput” CSCE 515 – Computer Network Programming

FTP Client and Server client user at a terminal user interface server user protocol

FTP Client and Server client user at a terminal user interface server user protocol interpreter file system 2007 user data transfer function control connection (FTP commands, FTP replies) data connection CSCE 515 – Computer Network Programming server protocol interpreter server data transfer function file system

Control Connection • The control connection is the “well known” service. • The control

Control Connection • The control connection is the “well known” service. • The control connection uses the TELNET protocol. • Commands and replies are all line oriented text (default is ASCII). 2007 CSCE 515 – Computer Network Programming

FTP Commands n n n Commands are sent in NVT ASCII with a pair

FTP Commands n n n Commands are sent in NVT ASCII with a pair of CR, LF at end of each line Commands are 3 or 4 bytes of ASCII chars, some require optional arguments Access Control Commands USER username specify user PASS password specify password CWD change directory CDUP change directory to parent QUIT logout 2007 CSCE 515 – Computer Network Programming

Transfer Parameter Commands PORT PASV TYPE type MODE STRU 2007 publish local data port

Transfer Parameter Commands PORT PASV TYPE type MODE STRU 2007 publish local data port server should listen establish data representation establish transfer mode establish file structure CSCE 515 – Computer Network Programming

Service Commands RETR filename retrieve file STOR filename send file STOU send file and

Service Commands RETR filename retrieve file STOR filename send file STOU send file and save as unique APPE send file and append ABOR abort prev. service command PWD print working directory LIST transfer list of files over data link 2007 CSCE 515 – Computer Network Programming

FTP Replies • All replies are sent over control connection. • Replies are a

FTP Replies • All replies are sent over control connection. • Replies are a single line containing ¨ 3 digit status code (sent as 3 numeric chars). ¨ text message. • The FTP spec. includes support for multiline text replies. 2007 CSCE 515 – Computer Network Programming

FTP Reply Status Code First digit of status code indicates type of reply: ‘

FTP Reply Status Code First digit of status code indicates type of reply: ‘ 1’: Positive Preliminary Reply (got it, but wait). ‘ 2’: Positive Completion Reply (success). ‘ 3’: Positive Intermediate Reply (waiting for more information). ‘ 4’: Transient Negative Completion (error - try again). ‘ 5’: Permanent Negative Reply (error - can’t do). 2007 CSCE 515 – Computer Network Programming

FTP Reply Status Code • 2 nd digit indicates function groupings. ‘ 0’: Syntax

FTP Reply Status Code • 2 nd digit indicates function groupings. ‘ 0’: Syntax (problem with command syntax). ‘ 1’: Information (reply to help or status cmds). ‘ 2’: Connections (problem with a connection). ‘ 3’: Authentication (problem with login). ‘ 4’: Unspecified. ‘ 5’: File system (related to file system). • 3 rd digit indicates specific problem within function group. • 331: Username OK, password required 2007 CSCE 515 – Computer Network Programming

FTP Data Representation n Four dimensions determine how file is transferred and stored File

FTP Data Representation n Four dimensions determine how file is transferred and stored File type: ASCII file, EBCDIC file, binary file, local file ¨ Format control: nonprint, telnet format control, Fortran carriage control ¨ Structure: file structure, record structure, page structure ¨ Transmission mode: stream mode, block mode, compressed mode ¨ n 2007 Typical implementation restricts to ASCII or binary, nonprint, file structure, stream mode CSCE 515 – Computer Network Programming

FTP Connection Management n Three uses for data connection Sending file from client to

FTP Connection Management n Three uses for data connection Sending file from client to server ¨ Sending file from server to client ¨ Sending a listing of files or directories from server to client ¨ n n 2007 Client chooses an ephemeral port, sends it to server across control connection, and passive open for data connection Server receives this port number from control connection, and active open to that port on client CSCE 515 – Computer Network Programming

Anonymous FTP n n n 2007 A server can allow anyone to login and

Anonymous FTP n n n 2007 A server can allow anyone to login and use FTP to transfer files To use anonymous FTP, login with “anonymous” as username and an email address as password Some anonymous FTP server denies client from a host that does not have valid hostname CSCE 515 – Computer Network Programming

Tiny. OS Forwarder uses provides Std. Control Comm. Control Main Std. Control Receive. Msg

Tiny. OS Forwarder uses provides Std. Control Comm. Control Main Std. Control Receive. Msg Std. Control Forwarder. M Receive. Msg Send. Msg Generic. Comm Send. Msg Leds. C Communication to RS-232, NOT something you should dig into. Radio. Here you go! Keep digging. 2007 CSCE 515 – Computer Network Programming