FTP - File Transfer Protocol CISC 856 – Fall 2012 University of Delaware Ayush Dusia...
-
Upload
lester-payne -
Category
Documents
-
view
219 -
download
4
Transcript of FTP - File Transfer Protocol CISC 856 – Fall 2012 University of Delaware Ayush Dusia...
FTP - File Transfer ProtocolCISC 856 – Fall 2012
University of DelawareAyush Dusia
(many slides courtesy of: Brian Lucas, Umakanth Puppala, William Boyer,
Vikram Rajan, Michael Haggerty, Shriram Ganesh, Bo Xu and Prof Amer)
Computer & Information Science
File Transfer Protocol (RFC 959)
• Why FTP?
• FTP’s connections
• FTP in action
• FTP commands/responses
• Internationalization of FTP (RFC 2640)
OutlineOutline
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 NCP
RFC 765 - FTP over TCP/IP
Time
History of FTPHistory of FTP
Purpose: To transfer files between two computers
Goals 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?Why do we need a FTP service?
• 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 transferProblems of file transfer
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” ConnectionsFTP’s “2” Connections
FTP’s “2” Connections - EstablishmentFTP’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]
230 User anonymous logged in.ftp>
FTP’s “2” Connections – Data TransferFTP’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
FTP’s “2” Connections – Connection Closing 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
ftp> OPEN ftp.udel.edu SYN
SYN+ACK
ACK
220 Service Ready
ftp> USER anonymous
ACK
ACK331 User OK,password?
ACKftp> PASS [email protected]
ACK230 User login OK
ACK
Client Server
21
Eph
FTP Connection
200 Command Successful
SYN
RETR server1.txt
SYN+ACK
ACK 150 Data Connection will be open shortly
server1.txt
FIN
FIN+ACK
226 Closing Data Connection
ACK
REPLY+ACK
ACK
ACK
Control ConnectionData Connection
Client Server
Eph
Eph
21
21
5001
20
5001 20
FTP – Data transfer (get command)
Command REUSEADDRActive Open<CIP,5001,SIP,21><CIP,5001,SIP,20>
Eph 5001=
200 Command Successful
SYN
RETR server1.txt
SYN+ACK
ACK150 Data Connection will be open shortly
server1.txt
FIN
FIN+ACKACK
REPLY+ACK
ACK
Client Server
Eph
21
5001
20
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=
Eph
200 Command Successful
SYN
RETR server1.txt
SYN+ACK
ACK 150 Data Connection will be open shortly
REPLY+ACK
ACK
RETR+ACK
Client Server
ACK
Eph
21
7561
20
FTP – Data transfer with PORT Command
SYN
SYN+ACK
REPLY+ACK
RETR+ACKACK
21
7562
20
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
PORT 128,4,40,17,29,139
200 Command Successful
SYN
STOR client.txt
SYN+ACK
ACK 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
7563
20
7563 20
FTP – Data transfer (put command)
Actions
ACK
FIN
Closed
FIN+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
FTP Client Commands (issued by user interface) FTP Client Commands (issued by user interface)
Command Description
get 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.
Command Description
LIST [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 A-PDU FTP Commands
FTP Response Format 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.
x0zx1z
x2z
x3z
x4zx5z
SyntaxInformationConnections. Replies referring to control or data connections.
Authentication and accounting
UnspecifiedFilesystem status
• 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 Example FTP Responses
• 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 Summary of FTP Connections
• 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 ConnectionData Connection
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 FTP Passive Data Transfer
Internationalization of FTPInternationalization 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
UTF-8 byte sequence(binary) 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
FTP – Data transfer (mget command)
PORT 128,175,107,41,198,44 200 Command
Successful
SYN
NLIST *.txt
SYN+ACK
ACK 150 Data Connection will be open shortly
NAME LIST
FIN
FIN+ACK
ACK
REPLY+ACK
ACK
NLIST+ACK
Control ConnectionData Connection
Client Server
ACK
Eph
Eph
21
21
50732
20
50732 20226 Closing Data ConnectionACK
FTP – Data transfer (mget command) (cont’d)
PORT 128,175,107,41,198,45
200 Command Successful
SYN
RETR server1.txt
SYN+ACK
ACK 150 Data Connection will be open shortly
server1.txt
FIN
FIN+ACK
ACK
REPLY+ACK
ACK
RETR+ACK
Control ConnectionData Connection
Client Server
ACK
Eph
Eph
21
21
50733
20
50733 20
The same with server2.txt & server3.txt
• 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
ReferenceReference