RFC 172

The File Transfer Protocol

๐Ÿ“… published June 1971, from ietf

THE FILE TRANSFER PROTOCOL ๐Ÿ’–

Bestie, this is RFC 172, and it's giving 1971 ARPANET energy ๐Ÿฆ‹ Let's get into it.

  • Request for Comments: #172 โœจ
  • Network Working Group, dated 23 June 1971 ๐ŸŒธ
  • NIC number: 6794
  • Authors: Abhay Bhushan (MIT), Bob Braden (UCLA), Will Crowther (BBN), Eric Harslem (Rand), John Heafner (Rand), Alex McKenzie (BBN), John Melvin (SRI), Bob Sundberg (Harvard), Dick Watson (SRI), Jim White (UCSB) ๐Ÿ‘‘
  • Categories: D.4, D.5, and D.7
  • Updates: 114
  • Obsolete: None

I. INTRODUCTION โœจ

Okay so FTP (the file transfer protocol) is a user-level protocol for moving files between host computers ๐Ÿ’พ. That includes terminal IMP's, all on the ARPA computer network ๐ŸŒ. Its main job is getting files from one host to another, and letting you use the storage and file handling stuff on other hosts ๐Ÿงš. For the actual moving-the-data part, FTP relies on the data transfer protocol from RFC 171 ๐Ÿซถ. This paper assumes you already know RFC 171, so catch up first bestie ๐Ÿ’….

FTP's goals are to promote sharing of files (computer programs and/or data) ๐Ÿ“, and to encourage indirect use (without login or implicit) of computers. It also shields you from the differences between file and storage systems on different hosts, as far as that's practical ๐ŸŒˆ. It does this by specifying a standard file transfer socket and initial connection protocol for indirect use, plus standard conventions for file transfer and related operations ๐Ÿ’œ.

II. DISCUSSION ๐ŸŽ€

A file here is an ordered set of any length, made of computer data (instructions included) ๐Ÿ“„. Every file is uniquely identified in a system by its pathname ๐Ÿ—บ๏ธ. A pathname is (loosely!) the data string a network user MUST input to the file system to identify a file. It usually has device and/or directory names, plus file names for named files ๐Ÿ“. FTP gives you standard file system commands but no standard naming convention yet, so each user MUST follow the naming convention of whatever file system they want to use ๐Ÿ™ƒ. FTP MAY get standard pathname structures later on [1].

A file MAY or may not have access controls attached ๐Ÿ”. Access controls say what each user is allowed to do. Without them, files can't be protected from accidental or unauthorized use ๐Ÿ˜ฌ. Protection and selective access are the job of the resident file system ๐Ÿ›ก๏ธ. FTP only gives you identifier and password mechanisms for swapping access control info ๐Ÿ”‘. It SHOULD however be noted that for file sharing, a user needs to be allowed (subject to access controls) to access files they didn't create ๐Ÿค.

FTP doesn't care what's inside a file ๐Ÿ™†โ€โ™€๏ธ. It could be ASCII text, binary data, a computer program, or anything else. There's a spot in FTP for describing data structure (type and byte size), which makes parsing, interpreting, reconfiguring, and storing data way easier ๐Ÿงฉ. For indirect usage, the cooperating file transfer processes MAY be disowned "daemon" processes. These "listen" on agreed-upon sockets and follow the standard initial connection protocol to set up a full-duplex connection ๐Ÿ‘ป. It SHOULD be noted that FTP could also be used directly. You'd log into a remote host and arrange the transfer over specific sockets yourself ๐Ÿ”Œ.

FTP is super extensible ๐Ÿฆ‹. New commands and data types MAY be defined by anyone who agrees to implement them. Implementing only a subset of commands is specifically permitted, and an initial subset is RECOMMENDED [2]. The protocol MAY also be extended to enable remote execution of programs, but no standard procedure is suggested for that ๐Ÿš€.

For transferring data, FTP uses the data transfer protocol specified in RFC 171. That protocol doesn't specify how FTP should use it, so implementation MAY vary between host sites ๐Ÿ . Hosts that don't want to separate the data transfer and file transfer functions SHOULD take particular care to conform to the data transfer protocol specifications of RFC 171 โš ๏ธ.

It SHOULD be noted that FTP specifications do not require knowledge of the transfer modes used by the data transfer protocol. However, since FTP needs more than a single control transaction over the same connection, it is essential that hosts can send control transactions in either 'transparent block' (type B9) or 'descriptor and counts' (type BA) modes. Type BB, the indefinite bit stream mode, isn't suitable because it limits transfer to single transactions ๐Ÿ™…โ€โ™€๏ธ.

The use of data transfer aborts (type B6) is neither REQUIRED nor defined in FTP. FTP has its own error terminate, which MAY be used to abort a file transfer request ๐Ÿ›‘. FTP also doesn't define the structure of files, and there are no conventions for group, record, and unit separators [3]. A file separator is used to indicate the end of file, though ๐Ÿ“‘. It is strongly RECOMMENDED that default options be provided in implementation to make the file transfer service easy to use โœจ. For example, the main file directory on disk, a pool directory, a user directory, or the directory last accessed could serve as standard pathname defaults ๐Ÿ“‚. Defaults are convenient because the user doesn't have to type the complete pathname every single time they use the file transfer service ๐Ÿ’–.


III. SPECIFICATIONS ๐Ÿ‘‘

1. Data Transfer

FTP uses the data transfer protocol described in RFC 171 to transfer data and/or control transactions ๐Ÿ“ฆ. Both data and control transactions go over the same connection ๐Ÿ›ฃ๏ธ.

2. Data Transactions

Data transactions represent the data contained in a file. They carry no data type or byte size information ๐Ÿ™ˆ. The structure of the data is communicated via control transactions instead ๐Ÿ—ฃ๏ธ. A file MAY be transferred as one or more data transactions. The protocol neither specifies nor imposes any limits on the structure (record, group, etc.) or length of a file. Limits like that MAY however be imposed by a serving host ๐Ÿšง. The end of a file MAY be indicated either by a file separator (as defined in the data transfer protocol) or by closing the connection (in type B0). Also, a serving or using host SHOULD NOT send ETX, or any other end of file character, unless that character is part of the data in the file (i.e., not provided by the system) ๐Ÿ™…โ€โ™€๏ธ.

3. Control Transactions

Control transactions MAY be typified as requests, identifiers, and terminates ๐Ÿท๏ธ. A request fulfillment sequence begins with a request and ends with receipt of data (followed by End-of-File) or a terminate ๐Ÿ.

3A. Op Codes

Control transactions are distinguished by their first byte, which is called the op code. A standard set of opcodes is defined below. Implementing a workable [4] subset of opcodes is specifically permitted. Additional standard opcodes MAY be assigned later ๐Ÿ”ข. Opcodes hex 5A (octal 100) through hex FF (octal 377) are for experimental use ๐Ÿงช.

       Op Code                   Operation
     Hex    Octal

      00     000         Change data type identifier

      01     001         Retrieve Request

      02     002         Store request (replaced if file already
                         exists)

      03     003         Delete request

      04     004         Rename_from request

      05     005         Rename_to request

      06     006         List_file_directory request

      07     007         Username identifier

      08     010         Password identifier

      09     011         Error or unsuccessful terminate

      04     012         Acknowledge or successful terminate

      0B     013         Append request (add to existing file)


      0C     014

   through through       Reserved for standard assignment

      4F     077


      5A     100

   through through       Reserved for experimental use

      FF     377

3B. Syntax and Semantics

3B.1 Data Types

The 'change data type' control transaction identifies the structure of data (data type and byte size) in the succeeding data transactions ๐Ÿงฌ. This transaction SHALL contain two more bytes in addition to the opcode byte. The first of these bytes SHALL convey a data type or code, and the second byte MAY convey the data byte size where applicable. This information MAY be used to define how the data is parsed, interpreted, reconfigured, or stored ๐Ÿง . Change data type only needs to be sent when the structure of the data changes from the one before it ๐Ÿ”„.

Although a number of data types are defined, specific implementations MAY handle only limited data types, or completely ignore the data type and byte size descriptors ๐Ÿ™ƒ. Even if a host process doesn't "recognize" a data type, it MUST accept the data (i.e., there is no such thing as a data type error) ๐Ÿซถ. These descriptors are provided only for convenience, so it's not essential that they be used. The standard default is to assume nothing about the information and treat it as a bit stream (binary data, byte size 1) [5], whose interpretation is left to a higher level process or the user ๐ŸŒŠ.

_________________________
* It is, however, possible that this bit stream is treated like
ASCII characters in specific instances such as transmitting a file
to a line printer.

The following data type codes are currently assigned. Where a byte size is not implicit in the data type, it MAY be provided by the second byte ๐Ÿ“‹.

     Hex    Octal

      00     000         1               Bit stream (standard default)

      01     001       none              Binary data bytes

      02     002         8               Network ASCII characters

      03     003         8               EBCDIC characters

      04     004        36               DEC-packed ASCII (five 7-bit
                                         characters, 36th bit 1 or 0)

      05     005         8               Decimal numbers, net. ASCII

      06     006         8               Octal numbers, net. ASCII

      07     007         8               Hexadecimal numbers, net. ASCII

      08     010

   through through                       Reserved for standard assignment

      4F     077

      5A     100

   through through                       Reserved for experimental use

      FF     377

To be continued, bestie ๐ŸŒˆโœจ

3B.2 Requests and Identifiers โœจ

Okay bestie, Retrieve, delete, name_from, rename_t, and append requests all carry a pathname in the information field, right after the op code ๐Ÿ’… A pathname MAY also follow the opcode in a list_file_directory request ๐Ÿ—‚๏ธ

A pathname MUST uniquely identify a file on the serving host ๐Ÿ”‘ The syntax of pathnames and identifying info SHALL conform to the serving host's conventions, except that standard network ASCII (as defined in the TELNET protocol) SHALL be used ๐Ÿ”ค

The store request has a 4-byte (32 bits) 'allocate size' field, followed by the pathname โœจ 'Allocate size' tells you how many bits of storage to set aside for the file ๐Ÿ“ฆ If it's zero, the server SHOULD use his default ๐Ÿ™ˆ

Retrieve request is all about getting a copy of the file named in pathname, moving it from the serving host to the using host ๐Ÿ“ฅ The status and contents of the file on the serving host SHOULD be unaffected ๐Ÿง˜

Store request copies a file from the using host to the serving host ๐Ÿ“ค If the file in pathname already exists on the serving host, its contents SHALL be replaced by the contents of the file being transferred ๐Ÿ”„ If the file in pathname doesn't exist yet, a new one gets created on the serving host ๐Ÿ†•

Append request moves data from the using host to the serving host ๐Ÿšš The transferred data gets tacked onto the end of the file in pathname, on the serving host โž•

Rename-from and rename-to requests change the name of the file in the pathname of rename_from to the name in the pathname of rename_to โœ๏ธ A rename_from MUST always be followed by a rename_to request ๐Ÿซถ

Delete request removes the file in pathname from the serving host ๐Ÿ—‘๏ธ If you want an extra layer of protection, like asking "Do you really wish to delete this file?", that's a local implementation in the using system ๐Ÿ›ก๏ธ Those kinds of queries SHOULD NOT be transmitted over network connections ๐Ÿ™…

Username and password identifiers carry the respective identifying info ๐Ÿชช Normally, the user of the file transfer service supplies that info. These identifiers are normally sent at the start of the connection ๐Ÿš€

3B.3 Error and Acknowledge Terminates ๐Ÿ’€

The error transactions MAY have an error code indicated by the second descriptor byte ๐Ÿšจ Sending an error message as text is also permitted ๐Ÿ’ฌ Here are the error codes that are defined ๐Ÿ‘‡

 Error Code (2nd descriptor byte)           Meaning
Hex    Octal

 00     000                 Error condition indicated by computer
                            system (external to protocol)

 01     001                 Name syntax error

 02     003                 Access control violation

 03     003                 Abort

 04     004                 Allocate size too big

 05     005                 Allocate size overflow

 06     006                 Improper order for transactions

 07     007                 Opcode not implemented

 08     010                 File search failed

 09     011                 Error described in text message
                            (ASCII characters follow code)

At present, no completion codes are defined for acknowledge ๐Ÿคท It's assumed that acknowledge refers to the current request being fulfilled ๐Ÿ’…


4. Order of Transactions โœจ

4A. A certain order of transactions MUST be maintained when fulfilling file transfer requests ๐Ÿ“‹ The exact sequence depends on the type of request, as described in section 4B ๐Ÿ” The fulfilling of a request MAY be aborted anytime by either host, as explained in section 4C โœ‹

4B. Identifier transactions (change data type, username, and password) MAY be sent by the user at any time ๐Ÿ’ฌ The usual order would be a username transaction followed by a password transaction at the start of the connection ๐Ÿ”‘ No acknowledge is REQUIRED, or permitted ๐Ÿ™… The identifiers are there for default handling and access control ๐ŸŽ€

Retrieve and list_file_directory requests cause the transfer of a file from server to user ๐Ÿ“ฅ After a complete file has been transferred, the server SHOULD indicate end-of-file (by sending CLS or file separator) to complete the request fulfillment sequence, as shown below ๐Ÿ

      Read / List_file_directory request
     ------------------------------------->
User            <File -- data>              Server
     <-------------------------------------
            End of file indication
     <-------------------------------------

Store and append requests cause the transfer of a file from user to server ๐Ÿ“ค After a complete file has been transferred, the user SHOULD send an end-of-file indication ๐Ÿ”š The receipt of the file MUST be acknowledged by the server, as shown below ๐Ÿซก

User          Store / Append request        Server
     ------------------------------------->
              <File -- data>
     ------------------------------------->
              End of file indication
     ------------------------------------->
              Acknowledge
     <-------------------------------------

A Rename_from request MUST be followed by a rename_to request ๐Ÿ” The request MUST be acknowledged, as shown below ๐Ÿ’–

User          Rename_from request           Server
     ------------------------------------->
              Rename_to request
     ------------------------------------->
              Acknowledge
     <-------------------------------------

The delete request requires the server to acknowledge it, as shown below ๐Ÿงพ

User              Delete                    Server
     ------------------------------------->
                Acknowledge
     <-------------------------------------

Error transactions MAY be sent by either host at any time, and these terminate the current request fulfillment sequence ๐Ÿ›‘

4C. Aborts. Either host MAY abort a request fulfillment sequence at any time, by sending an error terminate or by closing the connection (NCP to transmit a CLS for the connection) ๐Ÿšช CLS is a more drastic type of abort, and it SHALL be used when there's a catastrophic failure, or when you need to abort in the middle of a long transaction ๐Ÿ’ฅ The abort tells the receiving host that the sender wants to terminate request fulfillment and is now ready to initiate or fulfill new requests ๐Ÿซถ When CLS is used to abort, the using host is responsible for reopening the connection ๐Ÿ”„ The file transfer abort described here is different from the data transfer abort, which is sent only by the sender of data. The use of the data transfer abort is not defined in this protocol ๐Ÿ™ˆ


6. Initial Connection, CLS, and Access Control ๐ŸŽ€

6A. There will be a preassigned permanent socket number[6] for the cooperating file transfer process at the serving host ๐Ÿ”Œ Connection establishment follows the standard initial connection protocol[7], giving you a full-duplex connection ๐Ÿฆ‹

6B. The connection gets broken by trading a CLS between the NCP's for each of the two connections ๐Ÿ‘‹ Normally, the user is the one who initiates CLS ๐Ÿ’…

CLS MAY also be used by either user or server, to abort a transaction in the middle ๐Ÿ›‘ If CLS is received in the middle of a transaction, the current request fulfillment sequence gets aborted. The using host will then reopen the connection ๐Ÿ”

6C. It is RECOMMENDED that identifier (user name and password) transactions be sent by the user to the server at the start ๐Ÿ”‘ That makes default handling and access control work for the entire duration of the connection ๐Ÿ›ก๏ธ Identifier transactions don't require or permit an acknowledge, so the user can jump straight into requests ๐Ÿš€ If the identifier information is incorrect or not received, the server MAY send an error transaction indicating an access control violation on subsequent requests ๐Ÿšจ


NOTES โœจ

[1] Alex McKenzie from BBN is running a survey of network file systems to figure out whether standard pathname conventions are practical, and to share info with network users about host file systems ๐Ÿ”

[2] This initial subset covers the control functions needed for basic file transfer, plus some elementary file manipulation ๐Ÿงฉ There's no attempt to provide a data management or complete file management capability ๐Ÿ™…

[3] It's possible that we MAY, later on, assign meaning to these information separators within FTP ๐Ÿ”ฎ

[4] A workable subset is any request, plus terminates ๐Ÿงƒ Identifiers MAY be REQUIRED in addition when using protected file systems ๐Ÿ”

[5] Still, it's possible this bit stream gets treated like ASCII characters in specific cases, like sending a file to a line printer ๐Ÿ–จ๏ธ

[6] Looks like socket 1 was already assigned to logger ๐Ÿชต Socket 3 seems like a reasonable pick for File Transfer ๐Ÿ“

[7] RFC 165, or any later standard that applies to initial connection for loggers ๐Ÿ“œ

[ This RFC was put into machine readable form for entry ]

[ into the online RFC archives by Glenn Forbes Fleming Larratt 5/97 ] ๐ŸŒˆ

๐Ÿ“ฆ where this page comes from