RFC 172
The File Transfer Protocol
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
- ietf: rfc172 1971-06
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms