Data Transfer Functions
III. DATA TRANSFER FUNCTIONS
Data and files are transferred only via the data connection. The data 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. 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 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 of after initiating the data connection.
The byte size for the data connection is specified by the TYPE (ASCII is 8 bits), or TYPE and BYTE commands. It is not required by the protocol that servers accept all possible byte size. The user of various byte size is for efficiency in data transfer and servers may implement only those byte size for which their data transfer is efficient. It is however recommended 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 sender of data. The data connection shall be closed under any of the following conditions:
1) server receives an abort command form user.
2) EOF in stream mode indicated by closing data connection.
3) the socket or byte size specification is changed.
4) any of the TELNET connections are closed.
5) an irrecoverable error condition.
It should be noted that two simultaneous data connections (for send and receive) may exist. It is a server option, however, to close the data connection after each instance of file transfer.
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 desirable to convert characters into the standard NVT-ASCII representation when transmitting text between disimilar systems. The sending and receiving site 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 length. 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) o 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 types reprentations. Transformations desired beyond this limited capability should be performed by the user directly or via the use of the Data Reconfiguration Service (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 specify a fixed transfer byte size. For example in ASCII and Print File representations, the transfer byte size must be 8 bits. Only in the Image and Local Byte representations the byte size specified by the BYTE command is to be used. The following data representation types are currently defined in FTP:
1. ASCII: The sender converts data form its internal character representation to the standard ARPANET 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 be default type, and it is recommended that this type be implemented by all.
2. 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. 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.
3. Local Byte: This representation allows for efficient storage, use, and retrieval of data. The mann 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 b 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-
4. Print File-ASCII: The server site will transform the ASCII file in a form suitable for printing at the server site. The byte size must be 8 bits. The transformation may not be invertible. This type is different from ASCII in that TABs, FFs and other ASCII format effector characters may be replaced by SPs, LFs, and other substitute characters. The print file conversions are to be well publicized by all server sites. This type would be used when the file is destined for an ASCII printer. This type in some systems may be identical to the ASCII type. It is recommended that this type be implemented by all.
5. EBCDIC Print File: The server site will transform the EBCDIC file into a form suitable for printing at the server site. The byte size must be 8 bits. the transformation may not be invertible. This type would be used when the file is destined for an EBCDIC printer. Only systems which use EBCDIC for their internal character representation need accept this type.
It should be noted that a serving HOST need not accept all representation types and/or byte size, but it must inform the user of the fact by sending an appropriate reply.