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
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
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
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+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
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)
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
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.
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
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
• 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
• 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
• 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
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
Active Mode vs Passive Mode
ACTIVE PASSIVE
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
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