File Transfer on the Internet Trivial File Transfer

  • Slides: 8
Download presentation
File Transfer on the Internet Trivial File Transfer Protocol (TFTP) File Transfer Protocol (FTP)

File Transfer on the Internet Trivial File Transfer Protocol (TFTP) File Transfer Protocol (FTP) 1

TFTP: Trivial file transfer protocol LAN file transfer TFTP client TFTP server remote file

TFTP: Trivial file transfer protocol LAN file transfer TFTP client TFTP server remote file system • 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 2

TFTP Commands 20 IP Header 2 Opcode UDP (1=RRQ) Header (2=WRQ) Mode • ASCII:

TFTP Commands 20 IP Header 2 Opcode UDP (1=RRQ) Header (2=WRQ) Mode • ASCII: Each line ends with CRLF • octet: binary 8 Opcode (3=data) N filename 1 M 1 0 mode 0 2 0 -512 block number data 2 Opcode (4=ACK) block number 2 Opcode (5=error) error number N Error message 0 3

TFTP File Transfer • Employs a “stop-and-wait” protocol – Server sends a block, waits

TFTP File Transfer • 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. 4

FTP: the file transfer protocol user at host FTP user client interface file transfer

FTP: the file transfer protocol user at host FTP user client interface file transfer FTP server local file system remote file system • Problem: – Want to transfer file to/from remote host • System Components – FTP Server – TCP port 21 – FTP Client – FTP Protocol -- RFC 959 5

FTP: separate control, data connections • FTP client contacts FTP server at port 21,

FTP: separate control, data connections • 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 FTP client TCP data connection port 20 FTP server • Server opens a second TCP data connection to transfer another file. • Control connection: “out of band” • FTP server maintains “state”: current directory, earlier authentication 6

FTP commands, responses Sample commands: Sample return codes • sent as ASCII text over

FTP commands, responses Sample commands: Sample return codes • sent as ASCII text over control channel • USER username • PASS password • status code and phrase • LIST return list of file in current directory • CWD change current directory • RETR filename retrieves (gets) file • 331 Username OK, password required • 125 data connection already open; transfer starting • 425 Can’t open data connection • 452 Error writing file • STOR filename stores (puts) file onto remote host • PORT n 1, n 2, n 3, n 4, n 5, n 6 • QUIT 7

Example: RETRieving a file Client SYN Server SYN + ACK d a r re

Example: RETRieving a file Client SYN Server SYN + ACK d a r re y 220 FTP serve USER cakinlar d require 331 Password PASS cakinlar r logged in la in k a c r e s U 0 23 PORT 127, 0, 0, 1, 4, 150 successful d n a m m o c T R 220 PO RETR a. c on … mode connecti SCII 150 Opening A Server opens a TCP connection to port 1174 of the client and transfers the data over the this data channel 226 Transfer c omplete 8