1
File Transfer Protocol (FTP)
Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007, TAIWAN
File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and - - PowerPoint PPT Presentation
File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007 , TAIWAN 1 Contents CONNECTIONS COMMUNICATION COMMAND PROCESSING FILE TRANSFER SIMPLE FTP LAB
1
Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007, TAIWAN
2
3
One for data transfer One for control information
4
5
6
The control connection remains connected during the entire interactive FTP session; the data connection is opened and then closed for each file transferred.
7
8
Server issues a passive open on port 21 and waits Clients uses an ephemeral port and issues an active open
9
10
Client issues a passive open using an ephemeral port Client sends this port number to the server using PORT command Server receives the port number and issues an active open using the well-known port
11
12
13
Control connection Data connection
14
15
16
17
File type Data structure Transmission mode
18
default format for transferring text file
default format for transferring binary files Mostly used to transfer binary files such as compiled programs
19
Continuous stream of bytes
Divided into records (or structs in C) Used only with text files
Divided into pages each having a page number and header Can be stored or accessed randomly or sequentially
20
Default mode Data are delivered from FTP to TCP as a continuous stream of bytes
21
22
23
24
25
Access commands File management commands Data format commands Port defining commands File transferring commands Miscellaneous commands
26
USER user-id PASS user-passwd ACCT account to be changed REIN QUIT ABOR
27
CWD dir CDUP DELE file LIST dir NLIST dir MKD dir PWD RMD dir
28
TYPE A(ASCII), E(EBCDIC), I (Image), N (Nonprint), or T(TELNET) STRU F (File), R (Record), or P (page) MODE S (Stream), B (Block), or C (Compressed)
29
Selects an port number and sends it to the server using a passive open Asks the server to choose a port number and send the port number in the response and then the client creates an active open using that port
PORT (6-digits id) PASV
30
RETR file(s) STOR file(s) APPE file(s) STOU file(s) ALLO file(s) REST file(s) STAT file(s)
31
HELP NOOP SITE SYST
32
3-digit number: defines the code Text: defined needed parameters or extra explanations
33
34
Retrieving a file (RETR) Storing a file (STOR) Listing directory or file names (LIST) Note that, FTP treats a list of directory or file name as a file and sends it over the data connection.
35
36
37
38
39
40
Commands on the remote machine ls, cd, get, mget, put, mput Commands on the local machine lls, lcd
41
PORT 140,124,182,140,4,200 IP:140.124.182.140 Port:4*256+200=1224
AASCII IBinary
42
download
upload
Return h1,h2,h3,h4,p1,p4
43
44
45
The username is required by the server for access to its file system.
The argument field is a TELNET string identifying the user's password.
This command terminates a USER and if file transfer is not in progress, the server closes the TELNET connection.
46
The argument is a HOST-PORT specification for the data port to be used in data connection. A port command would be: PORT h1,h2,h3,h4,p1,p2 where, h1 is the high order 8 bits of the internet host address.
47
This command requests the server to "listen" on a data port (which may not be its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command. Server replies a code : 227 Entering Passive Mode. h1,h2,h3,h4,p1,p2
48
The argument specifies the representation type, for example:
A - ASCII I - Image
This command causes the server to transfer a copy of the file, specified in the pathname, to the server or user at the other end of the data connection.
49
STOR <SP> <pathname> <CRLF> This command causes the server to accept the data transferred via the data connection and to store the data as a file at the server site. CWD <SP> <pathname> <CRLF> This command allows the user to work with a different directory or dataset for file storage or retrieval without altering his login or accounting information. LIST [<SP> <pathname>] <CRLF> This command causes a list to be sent from the server to the client. PWD <CRLF> Return the current location of direction
50
Client Server USER username Reply a code PASS password Reply a code
51
QUIT Reply a code Client Server Reply a code
52
Client Server PASV Reply a code Connect to the data connection socket Transmit the information of direction by data connection socket LIST <pathname> Rely a code Rely a code Close the data connection socket
53
Client Server CWD pathname Reply a code PWD Reply a code
54
Client Server PASV Reply a code Connect to the data connection socket Reply a code RETR filename Reply a code Transmit the file though data connection socket Close the data connection socket
55
Client Server PASV Reply a code Connect to the data connection socket Reply a code STOR filename Reply a code Transmit the file though data connection socket Close the data connection socket