FILE TRANSFER PROTOCOL (FTP)
The FTP protocol is a TCP based protocol used to exchange files
between 2 host machines over the network.
The FTP protocol can be divided into 2 section in a connection.
1. Control connection
2. Data transmission connection
The server will wait for a connection from a client on port number 21
(default port for FTP protocol). When the client connects to the server
it recieves some of gratting message from server and the client must get a
user login name from the user and send it to the FTP server followed by
the user's password. Every command will be transmitted and recieved over
the control connection but some commands need to send data like "ls",
"get", "put". For those commands the client will send extra parameters
for specifying data port for a data connection if the client wants to
change the default data port but the default data connection port is
port number 20.
Every command must have one or more reply. The reply for FTP protocol
will lead with 3 digit integer number and follow by a text message the
client and server understand only first 3 digits number. The text message
is for humans.
ESTABLISHING DATA CONNECTIONS
Data transferring consists of setting up the data connection follow by
specific ports and the parameters for transfer.
When a client wants to get data it will send the command PASV meaning
that it wants to use a passive transmission. The passive data transfer
process (this may be at client data port or at server data port) will
"listen" on the data port to sending a transfer request command. The
server will initiate the data connection to the port. When the connection
is established, the data transfer begins between both side's data port.
Every FTP implementation must support changing the default data
ports, and only the client can change to non-default ports. The data will
be transmitted after the other machine sends the command "PORT" to the
other side. Then after the server sends all of the data it will close
the connection immediatelly.
The server MUST close the data connection under the following
1. The server has completed sending data in a transfer mode
that requires a close to indicate EOF.
2. The server receives an ABORT command from the user.
3. The port specification is changed by a command from the
4. The control connection is closed legally or otherwise.
5. An irrecoverable error condition occurs.
The FTP control connection is established via TCP between the client
process and the server process port 21 (default FTP control port). For
data connection the client or the server will select an avilable port
number for transmistion of data depending on the transmission mode.
Example for FTP connection
This is example for connection to FTP server named
"docsavage.compsci.buu.ac.th" from "CS130.compsci.buu.ac.th" machine.
C -> S : Client established connection to server on port 21
C <- S :
220- Burapha University Computer Science Department, Bang Saen, Thailand
220- Powered by Burapha Linux
220 docsavage.compsci.buu.ac.th FTP server (Version
wu-2.4.2-academ[BETA-14](1) Wed Oct 15 09:52:38 ICT 1997) ready.
C -> S : USER anonymous
C <- S :
331 Guest login ok, send your complete e-mail address as password.
C -> S : PASS email@example.com
C <- S :
230-Welcome, archive user! This is an experimental FTP server.
230-You are user 1 out of a possible 100 users. If have any unusual problems,
230-please report them via e-mail to firstname.lastname@example.org
230-If you do have problems, please try using a dash (-) as the first character
230-of your password -- this will turn off the continuation messages that may
230-be confusing your ftp client.
230 Guest login ok, access restrictions apply.
C -> S : PWD
C <- S : 257 "/" is current directory.
C -> S : STOR amp.c
C -> S : PORT (203,154,86,130,45,2).
C <- S : 200 PORT command successful.
C <- S : 150 Opening BINARY mode data connection
C <- S : #include
C <- S : 226 Transfer complete.
C <->S : Close data connection.
C -> S : QUIT
C <- S : 221 Goodbye.
C <- S : Close connection. (Server will close connection and
client will close connection too.)
Links to this Page
- protocols last edited on 24 June 2003 at 7:11 pm by t3.hfbk-hamburg.de
- enter. last edited on 21 February 2002 at 1:43 am by max2-171.dialin.uni-hamburg.de.