III. Data Transfer Functions
Data and files are transferred only via the data connection. The transfer of data is governed by FTP data transfer commands received on the TELNET connections. The data transfer functions include establishing the data connection to the specified data socket in the specified HOST (using the specified byte size), transmitting and receiving data in the specified representation type and transfer mode, handling EOR and EOF conditions, and error recovery (where applicable).
III.A Establishing Data Connection
The user site shall "listen" on the specified data socket, prior to sending a transfer request command. The FTP request command determines the direction of data transfer, and the socket number (odd or even) which is to be used in establishing the data connection. The server on receiving the appropriate store or retrieve request shall initiate the data connection to the specified user data socket in the specified byte size (default byte size is 8 bits), and send a reply indicating that file transfer may proceed. Prior to this reply, the server should send a reply indicating the server socket for the data connection. The user may use this server socket information to ensure the security of his data transfer. The server may send this reply either before or after initiating the data connection.
The byte size for the data connection is specified by the BYTE command. It is not required by the protocol that servers accept all possible byte sizes. The use of various byte sizes is for efficiency in data transfer and servers may implement only those byte sizes for which their data transfer is efficient. It is, however, required that servers implement at least the byte size of 8 bits.
After the data transfer is completed, it is the server's responsibility to close the data connection, except when the user is sending the data. In stream mode the sender must close the data connection to indicate EOF, i.e., completion of the transfer. Closing the connection is a server option except under the following conditions:
-
The server receives an abort command from the user.
-
The socket or the byte size specification is changed by the user.
-
The TELNET connections are closed.
-
An irrecoverable error condition occurs.
It should be noted that if none of the above conditions occur it is possible to maintain two simultaneous data connections, for send and receive.
III.B Data Representation and Storage
Data is transferred from a storage device in sending HOST to a storage device in receiving HOST. Often it is necessary to perform certain transformations on the data because data storage representations in the two systems are different. For example, NVT-ASCII has different data storage representations in different systems. PDP-10's generally store NVT-ASCII as five 7-bit ASCII characters, left-justified in a 36-bit word. 360's store NVT-ASCII as 8-bit EBCDIC codes. Multics stores NVT-ASCII as four 9-bit characters in a 36-bit word. It may be desirable to convert characters into the standard NVT-ASCII representation when transmitting text between dissimilar systems. The sending and receiving sites would have to perform the necessary transformations between the standard representation and their internal representations.
A different problem in representation arises when transmitting binary data (not character codes) between HOST systems with different word lengths. It is not always clear how the sender should send data, and the receiver store it. For example, when transmitting 32-bit bytes from a 32-bit word-length system to a 36-bit word-length system, it may be desirable (for reasons of efficiency and usefulness) to store the 32-bit bytes right-justified in a 36-bit word in the latter system. In any case, the user should have the option of specifying data representation and transformation functions. It should be noted that FTP provides for very limited data type representations. Transformations desired beyond this limited capability should be performed by the user directly or via the use of the Data Reconfiguration (DRS, RFC #138, NIC #6715). Additional representation types may be defined later if there is a demonstrable need.
Data representations are handled in FTP by a user specifying a representation type. The type may also imply a transfer byte size. For example, in ASCII representation, the transfer byte size should be 8 bits, and any other byte size specification will result in cancellation of the transfer request. In image and Local Byte representations any byte size is possible. The following data representation types are currently defined in FTP:
-
ASCII: The sender converts data from its internal character representation to the standard NVT ASCII form. The receiver converts the data from the standard form to its own internal form. The data is transferred in the standard form. The transfer byte size must be 8 bits. This type would be used for transfer of text files. This is the default type, and it is recommended that this type be implemented by all.
-
EBCDIC: The sender transfers data using the EBCDIC character code and 8-bit transfer byte size. This type may be used for efficient transfer of EBCDIC files between systems which use EBCDIC for their internal character representation.
-
Image: The sender transforms data from contiguous bits to bytes for transfer. The receiver transforms the bytes into bits, storing them contiguously independent of the byte size chosen for data transfer. With record structure and block mode, the server might need to pad each record for convenient storage. This padding is allowed at the end of a record, and should be remembered by the server so it will be stripped off when the file is retrieved by the user. The padding transformation should be well publicized by the server in case the user processes his file at the server site. Typical uses for the Image type are transfer of executable programs between like machines, and transfer of binary (non-text) data. It is recommended that this type be implemented by all for some byte size, preferably including the 8 bit byte size.
-
Local Byte: This representation allows for efficient storage, use, and retrieval of data. The manner in which data is to be transformed depends on the byte size for data transfer, and the particular HOST being used. The transformation scheme for different byte size is to be well publicized by all server sites. This transformation shall be invertible (i.e., if a file is stored using a certain transfer byte size, an identical file must be retrievable using the same byte size and representation type). It is the user's responsibility to keep track of the representation type and byte size used for his transfer. Typical uses of the Local Byte type are in efficient storage and retrieval of files, and transfer of structured binary data. This type may be identical to the Image type for byte size which are integral multiples of or factors of the computer word length.
Representation type may also be affected by another attribute, the format. For example, some printers can use ASA (Fortran) vertical format control procedures to transform printed data of type ASCII or EBCDIC. Currently format may take one of two values.
-
Unformatted: The representation type as specified is unaffected by any format transformations. This is the default value.
-
Printfile: The server is to transform data of either ASCII or EBCDIC type in accordance with ASA (Fortran) vertical format control standards. The data is to be transferred in 8-bit bytes.
A discussion of the ASA vertical format control appears in NWG/RFC 189, Appendix C, and in Communications of the ACM, Vol. 7, No. 10, p. 606, October 1964. According to the ASA vertical format control standards, the first character of a formatted record is not printed but determines vertical spacing as follow:
Character Vertical Spacing before printing
Blank One line
0 Two lines
1 To first line of the next page
+ No advance
In addition to the above four, there are more characters (defined in Appendix C, RFC 189) which represent an IBM extension to the ASA standard.
It should be noted that a serving host need not accept all representation types and/or byte sizes, but it must inform the user requesting an unacceptable type or size of this fact by sending an appropriate reply.