100 likes | 785 Views
File Transfer on the Internet Trivial File Transfer Protocol (TFTP) File Transfer Protocol (FTP). Used to transfer a file to/from remote host Intended to be used when bootstrapping diskless systems with BOOTP or DHCP System Components TFTP Server – UDP port 69 TFTP Client TFTP Protocol.
E N D
File Transfer on the InternetTrivial File Transfer Protocol (TFTP)File Transfer Protocol (FTP)
Used to transfer a file to/from remote host Intended to be used when bootstrapping diskless systems with BOOTP or DHCP System Components TFTP Server – UDP port 69 TFTP Client TFTP Protocol TFTP server TFTP: Trivial file transfer protocol LAN file transfer TFTP client TFTP client remote file system
TFTP Commands 1 M 8 2 1 N 20 0 IP Header UDP Header Opcode (1=RRQ) (2=WRQ) filename 0 mode 0-512 2 • Mode • ASCII: Each line ends with CRLF • octet: binary block number data Opcode (3=data) 2 block number Opcode (4=ACK) N 2 error number Error message 0 Opcode (5=error)
Employs a “stop-and-wait” protocol Server sends a block, waits for ACK, then sends the next block Server must to handle duplicate/lost packets. EOF: When the client receives a block that has less than 512 bytes, it knows this is the last block. TFTP File Transfer
Problem: Want to transfer file to/from remote host System Components FTP Server – TCP port 21 FTP Client FTP Protocol -- RFC 959 FTP user interface FTP client FTP server local file system FTP: the file transfer protocol file transfer user at host remote file system
FTP client contacts FTP server at port 21, specifying TCP as transport protocol Client obtains authorization over control connection Client browses remote directory by sending commands over control connection. When server receives a command for a file transfer, the server opens a TCP data connection to client Uses the Port command After transferring one file, server closes connection. TCP control connection port 21 TCP data connection port 20 FTP client FTP server FTP: separate control, data connections • Server opens a second TCP data connection to transfer another file. • Control connection: “out of band” • FTP server maintains “state”: current directory, earlier authentication
Sample commands: sent as ASCII text over control channel USERusername PASSpassword LISTreturn list of file in current directory CWD change current directory RETR filenameretrieves (gets) file STOR filenamestores (puts) file onto remote host PORT n1,n2,n3,n4,n5,n6 QUIT Sample return codes status code and phrase 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file FTP commands, responses
Example: RETRieving a file Server Client SYN SYN + ACK ACK 220 FTP server ready USER cakinlar 331 Password required PASS cakinlar 230 User cakinlar logged in PORT 127,0,0,1,4,150 220 PORT command successful RETR a.c 150 Opening ASCII mode connection … Server opens a TCP connection to port 1174 of the client and transfers the data over the this data channel 226 Transfer complete