FTP is internet standard for file transfer.It uses two TCP connection
to transfer a file.
1. Control connection-client server fashion.The server does a passive
open on FTP port(21) and waitsfor a client connection.The client does an
active open.Control connectionstay up entire time that the client communicate
with the server.The FTP uses the
Telnet protocol on the control connection.
2.Data connection-It is created each time a file is transferred between
the client and server.
At the initiation of the user, standard FTP commands are generated by
the user-PI (Protocol Interface) and transmitted to the server process
via the control connection. Standard replies are sent from the server-PI
to the user-PI over the control connection in response to the commands.The
FTP commands specify the parameters for the data connection (data port,
transfer mode, representation type, and structure) and the nature of file
system operation (store, retrieve, append,delete, etc.). The user-DTP
or its designate should
"listen" on the specified data port, and the server initiate the data
connection and data transfer in accordance with the specified
parameters. It should be noted that the data need not be in the
same host that initiates the FTP commands via the control
connection, but the user or the user-FTP process must ensure a "listen"
on the specified data port. It ought to also be noted
that the data connection may be used for simultaneous sending and
receiving.
In another situation a user might wish
to transfer files between two hosts, neither of which is a local host.
The user sets up
control connections to the two servers and then arranges for a data
connection between them. In this manner, control information
is passed to the user-PI but data is transferred between the server
data transfer processes. The protocol requires that the control connections
be open while data transfer is in progress. It is the responsibility
of the user to request the closing of the control connections when finished
using the FTP service, while it is the server who takes the action.
The server may abort data transfer if the control connections are closed
without command.
DATA REPRESENTATION
1.File type:-
(a). ASCII
(b). EBCDIC
(c). Image file type (data send as continuous stream of bits with 8 bit byte size)
(d). Local file type(variable bit byte size)
2.Format control
(a). Non-print(no vertical format information)
(b). Telnet format control(Telnet vertical format control for printer)
(c).Fortran carriage control(the first character of each line is Fortran format control character)
3.Structure
(a). File structure(no internal file structure)
(b). Record structure(used with text files)
(c). Page structure
4.Transmission mode
(a). Stream mode
(b).Block mode
(c). Compression mode
ESTABLISHING DATA CONNECTIONS
The mechanics of transferring data consists
of setting up the data connection to the appropriate ports and choosing
the parameters for transfer. Both the user and the server-DTPs have a default
data port. The user-process default data port is the same as the
control connection port . The server-process default data port is
the port adjacent to the control connection port(L-1).
DATA CONNECTION MANAGEMENT
Default Data Connection Ports:- All FTP implementations must support use of the default data connection ports, and only the user-PI may initiate the use of non-default ports.
Negotiating Non-Default Data Ports:- The User-PI may specify a non-default user side data port with the PORT command. The User-PI may request the server side to identify a non-default server side data port with the PASV command.
Reuse of the Data Connection:- In stream mode of data transfer
the end of the file is indicated by closing the connection. This
causes a problem if multiple files are to
be transfered in the session, due to need for TCP to hold the connection
record for a time
out period to guarantee the reliable communication.
Thus the connection can not be reopened at once. There are two solutions
to this problem. The first is to negotiate
a non-default port. The second is to use another transfer mode like(Block,
Compressed) which do not close the connection to indicate
the end of file.
ERROR RECOVERY AND RESTART
There is no provision for detecting bits lost or scrambled in data transfer; this level of error control is handled by the TCP.
However, a restart procedure is provided to protect users from gross
system failures (including failures of a host, an FTP-process,
or the underlying network).The restart procedure is defined only for
the block and compressed modes of data transfer. It requires
the sender of data to insert a special marker code in the data stream
with some marker information. In the event of a system failure,
the user can restart the data transfer by identifying the marker point
with the FTP restart procedure.
For more details on FTP refer RFC 959