2.3 THE FTP MODEL
With the above definitions in mind, the following model (shown in Figure 1) may be diagrammed for an FTP service.
-------------
|/---------\|
|| User || --------
||Interface|`<--->`| User |
|\---------/| --------
---------- | User-PI |
|/------\| FTP Commands | User-DTP |
||Server|`<---------------->`| |
|| PI || FTP Replies -------------
|\------/|
|/------\|
||Server||
|| DTP ||
|\------/|
----------
Server-FTP User-FTP
Figure 1 Model for FTP Use
In this model a user-protocol interpreter (User-PI) initiates the control connection. The control connection follows the Telnet protocol and at the initiation of the user a standard set of commands and replies is sent between the user-PI and server-PI. This connection is used for the transmission of commands which describe the functions to be performed, and the replies to these commands. These commands may indicate that a second connection, a data connection, is to be established to perform the data transfer function. The user-data transfer process (User-DTP) should "listen" on the specified data port, and this should be done BEFORE sending the transfer request command. The server initiates the data connection from its data transfer process (Server-DTP) and connects to the listening data port. The direction of the connection establishment is important. In an alternative situation, the user might initiate the data connection to the server-DTP. This class of connection is defined as passive.
The data connection is opened for the transfer and closed when the transfer is complete. The data transferred via the data connection includes data to be stored on the server host, or data retrieved from the server host, or data to be used in the execution of a server-side function. In the third case, the information transmitted over the data connection may be for use by an application program at the server site, rather than actually stored as a file. These general uses for a data connection exist for retrieval, storage, and execution at the server site.
COMMUNICATION
The user-PI and server-PI perform the user protocol by exchanging the standard set of FTP commands. The data transfer is performed by transferring data over a separate data connection. This procedure allows the control and data transfer to occur on independent paths.
The user-PI initiates all commands, and the server-PI responds with FTP replies. The user-PI may send more than one FTP command without waiting for a reply. The server-PI will reply to each FTP command sent in the order that the commands were received. The replies may be deferred if the server-PI is performing a lengthy operation as a result of a previous command. If this occurs, the server-PI may send a preliminary reply indicating that the command was received but that processing is not yet complete. When the operation is completed, the server-PI will send the completion reply.
FTP replies are devised to ensure the synchronization of requests and actions in the process of file transfer, and to guarantee that the user process always knows the state of the server. Every command must generate at least one reply, although there may be more than one. In the latter case, the multiple replies must be easily distinguished. In addition, some commands occur in sequential groups, such as USER, PASS and ACCT, or RNFR and RNTO. The replies show the existence of an intermediate state if all preceding commands have been successful. A failure at any point in the sequence necessitates the repetition of the entire sequence from the beginning.
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 sides must be in agreement on the parameters for the data connection before the transfer can take place. These parameters consist of: the data port, the representation type, the structure, and the transmission mode.
The representation type defines the way in which the file data is represented. This includes the data type (ASCII, EBCDIC, or Image) and the format control. The structure defines the way in which the file is structured. Three structures are supported: file-structure, record-structure, and page-structure. The transmission mode defines how the data will be transmitted. Three transmission modes are defined: stream mode, block mode, and compressed mode.
The selection of these parameters is negotiated by the exchange of FTP commands and replies between the user-PI and server-PI. The default values for these parameters are defined in the protocol. If no parameters are specified by the user, the defaults are assumed.