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
30
Embed
FTP - File Transfer Protocol CISC 856 – Fall 2012 University of Delaware Ayush Dusia [email protected] (many slides courtesy of: Brian Lucas, Umakanth Puppala,
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+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.
• 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
Active Mode vs Passive ModeActive Mode vs Passive Mode
ACTIVE PASSIVE
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