FTP - File Transfer Protocol CISC 856 – Fall 2012

30
FTP - File Transfer Protocol CISC 856 – Fall 2012 University of Delaware Ayush Dusia [email protected] (many slides courtesy of: Brian Lucas, Umakanth Puppala, William Boyer, Vikram Rajan, Michael Haggerty, Shriram Ganesh, Bo Xu and Prof Amer) Computer & Information Science

description

FTP - File Transfer Protocol CISC 856 – Fall 2012. University of Delaware Ayush Dusia [email protected] (many slides courtesy of: Brian Lucas, Umakanth Puppala , William Boyer, Vikram Rajan , Michael Haggerty, Shriram Ganesh , Bo Xu and Prof Amer ). Computer & Information Science. - PowerPoint PPT Presentation

Transcript of FTP - File Transfer Protocol CISC 856 – Fall 2012

Page 1: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP - File Transfer ProtocolCISC 856 – Fall 2012

University of DelawareAyush Dusia

[email protected]

(many slides courtesy of: Brian Lucas, Umakanth Puppala, William Boyer,

Vikram Rajan, Michael Haggerty, Shriram Ganesh, Bo Xu and Prof Amer)

Computer & Information Science

Page 2: FTP - File Transfer Protocol CISC 856 – Fall 2012

File Transfer Protocol (RFC 959)• Why FTP?• FTP’s connections• FTP in action• FTP commands/responses• Internationalization of FTP (RFC 2640)

Outline

Page 3: FTP - File Transfer Protocol CISC 856 – Fall 2012

April 1971

July 1972 August 1973 June 1980

RFC 114 - before TCP and IP existed - Used NCP to do FTP on ARPANET

RFC 354 - Overall Communication Model

RFC 542 - Remarkably similar to today’s FTP - Still based on NCPRFC 765

- FTP over TCP/IP

Time

History of FTP

Page 4: FTP - File Transfer Protocol CISC 856 – Fall 2012

Purpose: To transfer files between two computersGoals of FTP Service

• Promote sharing of files (programs and/or data)• Encourage indirect/implicit use of remote

computers• Shield users from variations in file storage among

hosts• Transfer data safely, reliably and efficiently

Why do we need a FTP service?

Page 5: FTP - File Transfer Protocol CISC 856 – Fall 2012

• At first, file transfer may seem simple• Heterogeneous systems use different:

– Operating Systems– Character Sets– Directory Structures– File Structures and Formats

• FTP needs to address and resolve these problems

Problems of file transfer

Page 6: FTP - File Transfer Protocol CISC 856 – Fall 2012

UserInterface

User Data Transfer

Process

UserControl Process

Server ControlProcess

Server Data Transfer

Process

client

server

ControlConnection

DataConnection(s)

* Insulates users from “raw” FTP commandsServer is listening on port 21for connection requests

* Routes “raw” FTP commands * Receives server’s replies

* Persistent connection command and replyNon-persistent data connection

21

20

*Server uses port 20for data connections

FTP’s “2” Connections

Page 7: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP’s “2” Connections - Establishment

UserInterface

Data Transfer Process

Control Process

Control Process

Data Transfer Process

client

server

ControlConnection

DataConnection(s)

ftp> open ftp.udel.eduConnected to ftp.udel.edu220 FTP server ready.

USER anonymous

331 Password req for anonymous.Password:

PASS [email protected] User anonymous logged in.ftp>

Page 8: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP’s “2” Connections – Data Transfer

128.4.40.17 (19×256)+137128.4.40.17:5001

Data Transfer Process

Data Transfer Process

UserInterface

UserProtocol

Interpreter

ServerProtocol

Interpreter

client

server

ControlConnection

DataConnection(s)

ls server1.txt

Passive open onPort 5001

PORT 128,4,40,17,19,137200 Port Command SucessfulLIST server1.txt150 Data Connection will be open shortly226 Closing Data Connection

-rw-r--r-- lucasb server1.txt

Establish Data Connection

Control Process

Control Process

128.4.40.17 19,137

Page 9: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP’s “2” Connections – Connection Closing

UserInterface

Control Process

Control Process

client

server

ControlConnection

DataConnection

Data Transfer Process

Data Transfer Process

bye

QUIT221 Service Closing

Page 10: FTP - File Transfer Protocol CISC 856 – Fall 2012

ftp> OPEN ftp.udel.edu SYN

SYN+ACKACK

220 Service Ready

ftp> USER anonymous

ACK

ACK331 User OK,password?

ACKftp> PASS [email protected]

ACK230 User login OK

ACK

Client Server

21Eph

FTP Connection

Page 11: FTP - File Transfer Protocol CISC 856 – Fall 2012

200 Command Successful

SYN

RETR server1.txt

SYN+ACKACK 150 Data Connection

will be open shortly

server1.txt

FINFIN+ACK

226 Closing Data Connection

ACK

REPLY+ACK

ACK

ACK

Control ConnectionData Connection

Client Server

Eph

Eph

21

21

500120

5001 20

FTP – Data transfer (get command)

Command REUSEADDRActive Open<CIP,5001,SIP,21><CIP,5001,SIP,20>

Eph 5001=

Page 12: FTP - File Transfer Protocol CISC 856 – Fall 2012

200 Command Successful

SYN

RETR server1.txt

SYN+ACKACK

150 Data Connection will be open shortly

server1.txt

FINFIN+ACKACK

REPLY+ACK

ACK

Client Server

Eph21

500120

FTP – Data transfer and WAIT STATE

Active Open<CIP,5001,SIP,21><CIP,5001,SIP,20>

RETR server2.txt (all attempt to open TCP connection will fail)

Time Wait State

2 MSL

RETR server2.txt200 Command Successful

REPLY+ACK5001

<CIP,5001,SIP,20>

<CIP,5001,SIP,20>

SYN

Eph 5001=

Page 13: FTP - File Transfer Protocol CISC 856 – Fall 2012

Eph

200 Command Successful

SYN

RETR server1.txt

SYN+ACKACK 150 Data Connection

will be open shortly

REPLY+ACK

ACK

RETR+ACK

Client Server

ACK

Eph21

756120

FTP – Data transfer with PORT Command

SYNSYN+ACK

REPLY+ACKRETR+ACK

ACK

21

756220

Date Transfer and FIN

PORT 128,4,40,17,29,137

ACK

<CIP,7561,SIP,20> (WS) <CIP,7562,SIP,20>

RETR server2.txt

150 Data Connection will be open shortly

200 Command Successful

Command REUSEADDR

PORT 128,4,40,17,29,138

Eph = 7560

Page 14: FTP - File Transfer Protocol CISC 856 – Fall 2012

PORT 128,4,40,17,29,139200 Command Successful

SYN

STOR client.txt

SYN+ACKACK 150 Data Connection

will be open shortly

client.txt

FINFIN+ACK

226 Closing Data Connection

ACK

REPLY+ACK

ACK

ACK

STOR+ACK

Control ConnectionData Connection

Client Server

ACK

Eph

Eph

21

21

756320

7563 20

FTP – Data transfer (put command)

Page 15: FTP - File Transfer Protocol CISC 856 – Fall 2012

Actions

ACK

FIN

ClosedFIN+ACK

SYN+ACK

ACK

ACK

Control Connection

Client Server

Eph

Eph

21

21

FTP – Control Connect Closing

SYN

…………

The client request close

Request: QUIT

Response 221: goodbye

Page 16: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP Client Commands (issued by user interface)

Command Descriptionget filename Retrieve file from server

mget filename* Retrieve multiple files from server

put filename Copy local file to server

mput filename* Copy multiple local files to server

open server Begin login to server

bye / close / exit Logoff server

ls / dir List files in current remote dir on server

lcd Change local directory

cd Change remote directory

rhelp / remotehelp Lists commands the server accepts

*Server sends list of matching files to client, Client protocol interpreter asks the user for operation on each matching file.

Page 17: FTP - File Transfer Protocol CISC 856 – Fall 2012

Command DescriptionLIST [filelist ] List files or directories (ls / dir)

USER username Send username to server

PASS password Password on server

PORT h1,h2,h3,h4,p1,p2 Client IP and port number

RETR filename Retrieve (get) filename

STOR filename Store (put) filename

NLIST *.* To retrieve (mget) mutliple files

A-PDU FTP Commands

Page 18: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP Response Format

Reply Description1yz

2yz3yz

4yz

5yz

Positive preliminary reply.The action is being started but expect another reply before sending another cmd.Positive completion reply. A new cmd can be sent.Positive intermediate reply. The cmd has been accepted but another cmd must be sent.Transient negative completion reply. The requested action did not take place but can be sent laterPermanent negative completion reply. Cmd not accepted and should not be reissued.

x0zx1zx2z

x3z

x4zx5z

SyntaxInformationConnections. Replies referring to control or data connections.

Authentication and accounting

UnspecifiedFilesystem status

Page 19: FTP - File Transfer Protocol CISC 856 – Fall 2012

• 120 Service will be ready shortly• 200 Command OK• 230 User login OK• 331 User name OK; password is needed• 421 Service not available• 530 User not logged in• 552 Requested action aborted; exceeded

storage allocation

Example FTP Responses

Page 20: FTP - File Transfer Protocol CISC 856 – Fall 2012

• FTP has 2 connections- Control (persistent connection)

- Server issues a passive open on well-known 21- Client uses an ephemeral port to issue active open- Server ultimately closes control connection- The connection is designed for minimum delay

- Data (ephemeral connection)- Client issues passive open on an ephemeral port- Client sends this port to server via PORT command- Server receives the port number and issues active

open using its well-known 20 to the received ephemeral port

- The connection is designed for maximum throughput

Summary of FTP Connections

Page 21: FTP - File Transfer Protocol CISC 856 – Fall 2012

• PORT does not always work…why?• Instead, use PASV command

– Client sends PASV command to server– Server chooses ephemeral port: passive open– Server responds with IP, Port in reply (227)– Client issues active open to server’s port

• Ultimately, the data sender closes connection

Data Connection

Page 22: FTP - File Transfer Protocol CISC 856 – Fall 2012

Data Transfer Process

Data Transfer Process

UserInterface

UserProtocol

Interpreter

ServerProtocol

Interpreter

client

server

ControlConnection

DataConnection

ls server1.txt

Passive open onPort 5125

PASV227 Entering Passive Mode (128,4,40,42,20,5) LIST server1.txt150 Data Connection will be open shortly226 Closing Data Connection

-rw-r--r-- lucasb server1.txt

Establish Data Connection

Control Process

Control Process

FTP Passive Data Transfer

Page 23: FTP - File Transfer Protocol CISC 856 – Fall 2012

Active Mode vs Passive Mode

ACTIVE PASSIVE

Page 24: FTP - File Transfer Protocol CISC 856 – Fall 2012

Internationalization of FTP

• The File Transfer Protocol use 7 bit ASCII and 8 bit EBCDIC• Cannot support wide range to characters• Need for single character sets understandable by all

systems• RFC 2640 recommends the use of character set ISO/IEC

10646:1993 and the UTF-8 encoding• UTF-8 consistent with ASCII character set

Page 25: FTP - File Transfer Protocol CISC 856 – Fall 2012

UTF-8 byte sequence(binary) • UTF-8 encoding represents each UCS character as a

sequence of 1 to 6 bytes in length• For all sequences of one byte the most significant bit is

ZERO• The number of ONE bits in the first byte indicates the

number of bytes used in the UTF-8 sequence• A beneficial property of UTF-8 is that its single byte

sequence is consistent with the ASCII character set

0xxxxxxx 110xxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

Page 26: FTP - File Transfer Protocol CISC 856 – Fall 2012

Appendix

Page 27: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP – Data transfer (mget command)

PORT 128,175,107,41,198,44 200 Command

Successful

SYN

NLIST *.txt

SYN+ACKACK 150 Data

Connection will be open shortlyNAME LIST

FINFIN+ACKACK

REPLY+ACK

ACK

NLIST+ACK

Control ConnectionData Connection

Client Server

ACK

Eph

Eph

21

21

5073220

50732 20226 Closing Data ConnectionACK

Page 28: FTP - File Transfer Protocol CISC 856 – Fall 2012

FTP – Data transfer (mget command) (cont’d)

PORT 128,175,107,41,198,45

200 Command Successful

SYN

RETR server1.txt

SYN+ACKACK 150 Data

Connection will be open shortlyserver1.txt

FINFIN+ACKACK

REPLY+ACK

ACK

RETR+ACK

Control ConnectionData Connection

Client Server

ACK

Eph

Eph

21

21

5073320

50733 20

The same with server2.txt & server3.txt

Page 29: FTP - File Transfer Protocol CISC 856 – Fall 2012

• Behrouz Forouzan. TCP/IP Protocol Suite, 4th edition. McGraw-Hill, Boston, MA, 2006

• RFC 959, File Transfer Protocol (FTP)• http://en.wikipedia.org/wiki/Ftp• Waël Noureddine, Fouad Tabagi, The Transmission

Control Protocol, July 2002: 53 – 54, 59 – 60.• Kioskea(en.kioskea.net), FTP protocol (File Transfer

Protocol)• Priscilla Oppenheimer, Analysis of the File Transfer

Protocol (FTP)• http://www.pcvr.nl/tcpip/ftp_file.htm• RFC 2640, Internationalization of the File Transfer

Protocol

Reference

Page 30: FTP - File Transfer Protocol CISC 856 – Fall 2012

Thank you!