home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit 2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Texts / Rfc / RFC959.TXT < prev    next >
Encoding:
Text File  |  1999-11-04  |  143.8 KB  |  4,004 lines

  1. Network Working Group                                          J. Postel
  2. Request for Comments: 959                                    J. Reynolds
  3.                                                                      ISI
  4. Obsoletes RFC: 765 (IEN 149)                                October 1985
  5.  
  6.                       FILE TRANSFER PROTOCOL (FTP)
  7.  
  8.  
  9. Status of this Memo
  10.  
  11.    This memo is the official specification of the File Transfer
  12.    Protocol (FTP).  Distribution of this memo is unlimited.
  13.  
  14.    The following new optional commands are included in this edition of
  15.    the specification:
  16.  
  17.       CDUP (Change to Parent Directory), SMNT (Structure Mount), STOU
  18.       (Store Unique), RMD (Remove Directory), MKD (Make Directory), PWD
  19.       (Print Directory), and SYST (System).
  20.  
  21.    Note that this specification is compatible with the previous edition.
  22.  
  23. 1.  INTRODUCTION
  24.  
  25.    The objectives of FTP are 1) to promote sharing of files (computer
  26.    programs and/or data), 2) to encourage indirect or implicit (via
  27.    programs) use of remote computers, 3) to shield a user from
  28.    variations in file storage systems among hosts, and 4) to transfer
  29.    data reliably and efficiently.  FTP, though usable directly by a user
  30.    at a terminal, is designed mainly for use by programs.
  31.  
  32.    The attempt in this specification is to satisfy the diverse needs of
  33.    users of maxi-hosts, mini-hosts, personal workstations, and TACs,
  34.    with a simple, and easily implemented protocol design.
  35.  
  36.    This paper assumes knowledge of the Transmission Control Protocol
  37.    (TCP) [2] and the Telnet Protocol [3].  These documents are contained
  38.    in the ARPA-Internet protocol handbook [1].
  39.  
  40. 2.  OVERVIEW
  41.  
  42.    In this section, the history, the terminology, and the FTP model are
  43.    discussed.  The terms defined in this section are only those that
  44.    have special significance in FTP.  Some of the terminology is very
  45.    specific to the FTP model; some readers may wish to turn to the
  46.    section on the FTP model while reviewing the terminology.
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. Postel & Reynolds                                               [Page 1]
  55.  
  56.  
  57.  
  58.                                                                         
  59. RFC 959                                                     October 1985
  60. File Transfer Protocol
  61.  
  62.  
  63.    2.1.  HISTORY
  64.  
  65.       FTP has had a long evolution over the years.  Appendix III is a
  66.       chronological compilation of Request for Comments documents
  67.       relating to FTP.  These include the first proposed file transfer
  68.       mechanisms in 1971 that were developed for implementation on hosts
  69.       at M.I.T. (RFC 114), plus comments and discussion in RFC 141.
  70.  
  71.       RFC 172 provided a user-level oriented protocol for file transfer
  72.       between host computers (including terminal IMPs).  A revision of
  73.       this as RFC 265, restated FTP for additional review, while RFC 281
  74.       suggested further changes.  The use of a "Set Data Type"
  75.       transaction was proposed in RFC 294 in January 1982.
  76.  
  77.       RFC 354 obsoleted RFCs 264 and 265.  The File Transfer Protocol
  78.       was now defined as a protocol for file transfer between HOSTs on
  79.       the ARPANET, with the primary function of FTP defined as
  80.       transfering files efficiently and reliably among hosts and
  81.       allowing the convenient use of remote file storage capabilities.
  82.       RFC 385 further commented on errors, emphasis points, and
  83.       additions to the protocol, while RFC 414 provided a status report
  84.       on the working server and user FTPs.  RFC 430, issued in 1973,
  85.       (among other RFCs too numerous to mention) presented further
  86.       comments on FTP.  Finally, an "official" FTP document was
  87.       published as RFC 454.
  88.  
  89.       By July 1973, considerable changes from the last versions of FTP
  90.       were made, but the general structure remained the same.  RFC 542
  91.       was published as a new "official" specification to reflect these
  92.       changes.  However, many implementations based on the older
  93.       specification were not updated.
  94.  
  95.       In 1974, RFCs 607 and 614 continued comments on FTP.  RFC 624
  96.       proposed further design changes and minor modifications.  In 1975,
  97.       RFC 686 entitled, "Leaving Well Enough Alone", discussed the
  98.       differences between all of the early and later versions of FTP.
  99.       RFC 691 presented a minor revision of RFC 686, regarding the
  100.       subject of print files.
  101.  
  102.       Motivated by the transition from the NCP to the TCP as the
  103.       underlying protocol, a phoenix was born out of all of the above
  104.       efforts in RFC 765 as the specification of FTP for use on TCP.
  105.  
  106.       This current edition of the FTP specification is intended to
  107.       correct some minor documentation errors, to improve the
  108.       explanation of some protocol features, and to add some new
  109.       optional commands.
  110.  
  111.  
  112. Postel & Reynolds                                               [Page 2]
  113.  
  114.  
  115.  
  116.                                                                         
  117. RFC 959                                                     October 1985
  118. File Transfer Protocol
  119.  
  120.  
  121.       In particular, the following new optional commands are included in
  122.       this edition of the specification:
  123.  
  124.          CDUP - Change to Parent Directory
  125.  
  126.          SMNT - Structure Mount
  127.  
  128.          STOU - Store Unique
  129.  
  130.          RMD - Remove Directory
  131.  
  132.          MKD - Make Directory
  133.  
  134.          PWD - Print Directory
  135.  
  136.          SYST - System
  137.  
  138.       This specification is compatible with the previous edition.  A
  139.       program implemented in conformance to the previous specification
  140.       should automatically be in conformance to this specification.
  141.  
  142.    2.2.  TERMINOLOGY
  143.  
  144.       ASCII
  145.  
  146.          The ASCII character set is as defined in the ARPA-Internet
  147.          Protocol Handbook.  In FTP, ASCII characters are defined to be
  148.          the lower half of an eight-bit code set (i.e., the most
  149.          significant bit is zero).
  150.  
  151.       access controls
  152.  
  153.          Access controls define users' access privileges to the use of a
  154.          system, and to the files in that system.  Access controls are
  155.          necessary to prevent unauthorized or accidental use of files.
  156.          It is the prerogative of a server-FTP process to invoke access
  157.          controls.
  158.  
  159.       byte size
  160.  
  161.          There are two byte sizes of interest in FTP:  the logical byte
  162.          size of the file, and the transfer byte size used for the
  163.          transmission of the data.  The transfer byte size is always 8
  164.          bits.  The transfer byte size is not necessarily the byte size
  165.          in which data is to be stored in a system, nor the logical byte
  166.          size for interpretation of the structure of the data.
  167.  
  168.  
  169.  
  170. Postel & Reynolds                                               [Page 3]
  171.  
  172.  
  173.  
  174.                                                                         
  175. RFC 959                                                     October 1985
  176. File Transfer Protocol
  177.  
  178.  
  179.       control connection
  180.  
  181.          The communication path between the USER-PI and SERVER-PI for
  182.          the exchange of commands and replies.  This connection follows
  183.          the Telnet Protocol.
  184.  
  185.       data connection
  186.  
  187.          A full duplex connection over which data is transferred, in a
  188.          specified mode and type. The data transferred may be a part of
  189.          a file, an entire file or a number of files.  The path may be
  190.          between a server-DTP and a user-DTP, or between two
  191.          server-DTPs.
  192.  
  193.       data port
  194.  
  195.          The passive data transfer process "listens" on the data port
  196.          for a connection from the active transfer process in order to
  197.          open the data connection.
  198.  
  199.       DTP
  200.  
  201.          The data transfer process establishes and manages the data
  202.          connection.  The DTP can be passive or active.
  203.  
  204.       End-of-Line
  205.  
  206.          The end-of-line sequence defines the separation of printing
  207.          lines.  The sequence is Carriage Return, followed by Line Feed.
  208.  
  209.       EOF
  210.  
  211.          The end-of-file condition that defines the end of a file being
  212.          transferred.
  213.  
  214.       EOR
  215.  
  216.          The end-of-record condition that defines the end of a record
  217.          being transferred.
  218.  
  219.       error recovery
  220.  
  221.          A procedure that allows a user to recover from certain errors
  222.          such as failure of either host system or transfer process.  In
  223.          FTP, error recovery may involve restarting a file transfer at a
  224.          given checkpoint.
  225.  
  226.  
  227.  
  228. Postel & Reynolds                                               [Page 4]
  229.  
  230.  
  231.  
  232.                                                                         
  233. RFC 959                                                     October 1985
  234. File Transfer Protocol
  235.  
  236.  
  237.       FTP commands
  238.  
  239.          A set of commands that comprise the control information flowing
  240.          from the user-FTP to the server-FTP process.
  241.  
  242.       file
  243.  
  244.          An ordered set of computer data (including programs), of
  245.          arbitrary length, uniquely identified by a pathname.
  246.  
  247.       mode
  248.  
  249.          The mode in which data is to be transferred via the data
  250.          connection.  The mode defines the data format during transfer
  251.          including EOR and EOF.  The transfer modes defined in FTP are
  252.          described in the Section on Transmission Modes.
  253.  
  254.       NVT
  255.  
  256.          The Network Virtual Terminal as defined in the Telnet Protocol.
  257.  
  258.       NVFS
  259.  
  260.          The Network Virtual File System.  A concept which defines a
  261.          standard network file system with standard commands and
  262.          pathname conventions.
  263.  
  264.       page
  265.  
  266.          A file may be structured as a set of independent parts called
  267.          pages.  FTP supports the transmission of discontinuous files as
  268.          independent indexed pages.
  269.  
  270.       pathname
  271.  
  272.          Pathname is defined to be the character string which must be
  273.          input to a file system by a user in order to identify a file.
  274.          Pathname normally contains device and/or directory names, and
  275.          file name specification.  FTP does not yet specify a standard
  276.          pathname convention.  Each user must follow the file naming
  277.          conventions of the file systems involved in the transfer.
  278.  
  279.       PI
  280.  
  281.          The protocol interpreter.  The user and server sides of the
  282.          protocol have distinct roles implemented in a user-PI and a
  283.          server-PI.
  284.  
  285.  
  286. Postel & Reynolds                                               [Page 5]
  287.  
  288.  
  289.  
  290.                                                                         
  291. RFC 959                                                     October 1985
  292. File Transfer Protocol
  293.  
  294.  
  295.       record
  296.  
  297.          A sequential file may be structured as a number of contiguous
  298.          parts called records.  Record structures are supported by FTP
  299.          but a file need not have record structure.
  300.  
  301.       reply
  302.  
  303.          A reply is an acknowledgment (positive or negative) sent from
  304.          server to user via the control connection in response to FTP
  305.          commands.  The general form of a reply is a completion code
  306.          (including error codes) followed by a text string.  The codes
  307.          are for use by programs and the text is usually intended for
  308.          human users.
  309.  
  310.       server-DTP
  311.  
  312.          The data transfer process, in its normal "active" state,
  313.          establishes the data connection with the "listening" data port.
  314.          It sets up parameters for transfer and storage, and transfers
  315.          data on command from its PI.  The DTP can be placed in a
  316.          "passive" state to listen for, rather than initiate a
  317.          connection on the data port.
  318.  
  319.       server-FTP process
  320.  
  321.          A process or set of processes which perform the function of
  322.          file transfer in cooperation with a user-FTP process and,
  323.          possibly, another server.  The functions consist of a protocol
  324.          interpreter (PI) and a data transfer process (DTP).
  325.  
  326.       server-PI
  327.  
  328.          The server protocol interpreter "listens" on Port L for a
  329.          connection from a user-PI and establishes a control
  330.          communication connection.  It receives standard FTP commands
  331.          from the user-PI, sends replies, and governs the server-DTP.
  332.  
  333.       type
  334.  
  335.          The data representation type used for data transfer and
  336.          storage.  Type implies certain transformations between the time
  337.          of data storage and data transfer.  The representation types
  338.          defined in FTP are described in the Section on Establishing
  339.          Data Connections.
  340.  
  341.  
  342.  
  343.  
  344. Postel & Reynolds                                               [Page 6]
  345.  
  346.  
  347.  
  348.                                                                         
  349. RFC 959                                                     October 1985
  350. File Transfer Protocol
  351.  
  352.  
  353.       user
  354.  
  355.          A person or a process on behalf of a person wishing to obtain
  356.          file transfer service.  The human user may interact directly
  357.          with a server-FTP process, but use of a user-FTP process is
  358.          preferred since the protocol design is weighted towards
  359.          automata.
  360.  
  361.       user-DTP
  362.  
  363.          The data transfer process "listens" on the data port for a
  364.          connection from a server-FTP process.  If two servers are
  365.          transferring data between them, the user-DTP is inactive.
  366.  
  367.       user-FTP process
  368.  
  369.          A set of functions including a protocol interpreter, a data
  370.          transfer process and a user interface which together perform
  371.          the function of file transfer in cooperation with one or more
  372.          server-FTP processes.  The user interface allows a local
  373.          language to be used in the command-reply dialogue with the
  374.          user.
  375.  
  376.       user-PI
  377.  
  378.          The user protocol interpreter initiates the control connection
  379.          from its port U to the server-FTP process, initiates FTP
  380.          commands, and governs the user-DTP if that process is part of
  381.          the file transfer.
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402. Postel & Reynolds                                               [Page 7]
  403.  
  404.  
  405.  
  406.                                                                         
  407. RFC 959                                                     October 1985
  408. File Transfer Protocol
  409.  
  410.  
  411.    2.3.  THE FTP MODEL
  412.  
  413.       With the above definitions in mind, the following model (shown in
  414.       Figure 1) may be diagrammed for an FTP service.
  415.  
  416.                                             -------------
  417.                                             |/---------\|
  418.                                             ||   User  ||    --------
  419.                                             ||Interface|<--->| User |
  420.                                             |\----^----/|    --------
  421.                   ----------                |     |     |
  422.                   |/------\|  FTP Commands  |/----V----\|
  423.                   ||Server|<---------------->|   User  ||
  424.                   ||  PI  ||   FTP Replies  ||    PI   ||
  425.                   |\--^---/|                |\----^----/|
  426.                   |   |    |                |     |     |
  427.       --------    |/--V---\|      Data      |/----V----\|    --------
  428.       | File |<--->|Server|<---------------->|  User   |<--->| File |
  429.       |System|    || DTP  ||   Connection   ||   DTP   ||    |System|
  430.       --------    |\------/|                |\---------/|    --------
  431.                   ----------                -------------
  432.  
  433.                   Server-FTP                   USER-FTP
  434.  
  435.       NOTES: 1. The data connection may be used in either direction.
  436.              2. The data connection need not exist all of the time.
  437.  
  438.                       Figure 1  Model for FTP Use
  439.  
  440.       In the model described in Figure 1, the user-protocol interpreter
  441.       initiates the control connection.  The control connection follows
  442.       the Telnet protocol.  At the initiation of the user, standard FTP
  443.       commands are generated by the user-PI and transmitted to the
  444.       server process via the control connection.  (The user may
  445.       establish a direct control connection to the server-FTP, from a
  446.       TAC terminal for example, and generate standard FTP commands
  447.       independently, bypassing the user-FTP process.) Standard replies
  448.       are sent from the server-PI to the user-PI over the control
  449.       connection in response to the commands.
  450.  
  451.       The FTP commands specify the parameters for the data connection
  452.       (data port, transfer mode, representation type, and structure) and
  453.       the nature of file system operation (store, retrieve, append,
  454.       delete, etc.).  The user-DTP or its designate should "listen" on
  455.       the specified data port, and the server initiate the data
  456.       connection and data transfer in accordance with the specified
  457.       parameters.  It should be noted that the data port need not be in
  458.  
  459.  
  460. Postel & Reynolds                                               [Page 8]
  461.  
  462.  
  463.  
  464.                                                                         
  465. RFC 959                                                     October 1985
  466. File Transfer Protocol
  467.  
  468.  
  469.       the same host that initiates the FTP commands via the control
  470.       connection, but the user or the user-FTP process must ensure a
  471.       "listen" on the specified data port.  It ought to also be noted
  472.       that the data connection may be used for simultaneous sending and
  473.       receiving.
  474.  
  475.       In another situation a user might wish to transfer files between
  476.       two hosts, neither of which is a local host. The user sets up
  477.       control connections to the two servers and then arranges for a
  478.       data connection between them.  In this manner, control information
  479.       is passed to the user-PI but data is transferred between the
  480.       server data transfer processes.  Following is a model of this
  481.       server-server interaction.
  482.  
  483.       
  484.                     Control     ------------   Control
  485.                     ---------->| User-FTP |<-----------
  486.                     |          | User-PI  |           |
  487.                     |          |   "C"    |           |
  488.                     V          ------------           V
  489.             --------------                        --------------
  490.             | Server-FTP |   Data Connection      | Server-FTP |
  491.             |    "A"     |<---------------------->|    "B"     |
  492.             -------------- Port (A)      Port (B) --------------
  493.       
  494.  
  495.                                  Figure 2
  496.  
  497.       The protocol requires that the control connections be open while
  498.       data transfer is in progress.  It is the responsibility of the
  499.       user to request the closing of the control connections when
  500.       finished using the FTP service, while it is the server who takes
  501.       the action.  The server may abort data transfer if the control
  502.       connections are closed without command.
  503.  
  504.       The Relationship between FTP and Telnet:
  505.  
  506.          The FTP uses the Telnet protocol on the control connection.
  507.          This can be achieved in two ways: first, the user-PI or the
  508.          server-PI may implement the rules of the Telnet Protocol
  509.          directly in their own procedures; or, second, the user-PI or
  510.          the server-PI may make use of the existing Telnet module in the
  511.          system.
  512.  
  513.          Ease of implementaion, sharing code, and modular programming
  514.          argue for the second approach.  Efficiency and independence
  515.  
  516.  
  517.  
  518. Postel & Reynolds                                               [Page 9]
  519.  
  520.  
  521.  
  522.                                                                         
  523. RFC 959                                                     October 1985
  524. File Transfer Protocol
  525.  
  526.  
  527.          argue for the first approach.  In practice, FTP relies on very
  528.          little of the Telnet Protocol, so the first approach does not
  529.          necessarily involve a large amount of code.
  530.  
  531. 3.  DATA TRANSFER FUNCTIONS
  532.  
  533.    Files are transferred only via the data connection.  The control
  534.    connection is used for the transfer of commands, which describe the
  535.    functions to be performed, and the replies to these commands (see the
  536.    Section on FTP Replies).  Several commands are concerned with the
  537.    transfer of data between hosts.  These data transfer commands include
  538.    the MODE command which specify how the bits of the data are to be
  539.    transmitted, and the STRUcture and TYPE commands, which are used to
  540.    define the way in which the data are to be represented.  The
  541.    transmission and representation are basically independent but the
  542.    "Stream" transmission mode is dependent on the file structure
  543.    attribute and if "Compressed" transmission mode is used, the nature
  544.    of the filler byte depends on the representation type.
  545.  
  546.    3.1.  DATA REPRESENTATION AND STORAGE
  547.  
  548.       Data is transferred from a storage device in the sending host to a
  549.       storage device in the receiving host.  Often it is necessary to
  550.       perform certain transformations on the data because data storage
  551.       representations in the two systems are different.  For example,
  552.       NVT-ASCII has different data storage representations in different
  553.       systems.  DEC TOPS-20s's generally store NVT-ASCII as five 7-bit
  554.       ASCII characters, left-justified in a 36-bit word. IBM Mainframe's
  555.       store NVT-ASCII as 8-bit EBCDIC codes.  Multics stores NVT-ASCII
  556.       as four 9-bit characters in a 36-bit word.  It is desirable to
  557.       convert characters into the standard NVT-ASCII representation when
  558.       transmitting text between dissimilar systems.  The sending and
  559.       receiving sites would have to perform the necessary
  560.       transformations between the standard representation and their
  561.       internal representations.
  562.  
  563.       A different problem in representation arises when transmitting
  564.       binary data (not character codes) between host systems with
  565.       different word lengths.  It is not always clear how the sender
  566.       should send data, and the receiver store it.  For example, when
  567.       transmitting 32-bit bytes from a 32-bit word-length system to a
  568.       36-bit word-length system, it may be desirable (for reasons of
  569.       efficiency and usefulness) to store the 32-bit bytes
  570.       right-justified in a 36-bit word in the latter system.  In any
  571.       case, the user should have the option of specifying data
  572.       representation and transformation functions.  It should be noted
  573.  
  574.  
  575.  
  576. Postel & Reynolds                                              [Page 10]
  577.  
  578.  
  579.  
  580.                                                                         
  581. RFC 959                                                     October 1985
  582. File Transfer Protocol
  583.  
  584.  
  585.       that FTP provides for very limited data type representations.
  586.       Transformations desired beyond this limited capability should be
  587.       performed by the user directly.
  588.  
  589.       3.1.1.  DATA TYPES
  590.  
  591.          Data representations are handled in FTP by a user specifying a
  592.          representation type.  This type may implicitly (as in ASCII or
  593.          EBCDIC) or explicitly (as in Local byte) define a byte size for
  594.          interpretation which is referred to as the "logical byte size."
  595.          Note that this has nothing to do with the byte size used for
  596.          transmission over the data connection, called the "transfer
  597.          byte size", and the two should not be confused.  For example,
  598.          NVT-ASCII has a logical byte size of 8 bits.  If the type is
  599.          Local byte, then the TYPE command has an obligatory second
  600.          parameter specifying the logical byte size.  The transfer byte
  601.          size is always 8 bits.
  602.  
  603.          3.1.1.1.  ASCII TYPE
  604.  
  605.             This is the default type and must be accepted by all FTP
  606.             implementations.  It is intended primarily for the transfer
  607.             of text files, except when both hosts would find the EBCDIC
  608.             type more convenient.
  609.  
  610.             The sender converts the data from an internal character
  611.             representation to the standard 8-bit NVT-ASCII
  612.             representation (see the Telnet specification).  The receiver
  613.             will convert the data from the standard form to his own
  614.             internal form.
  615.  
  616.             In accordance with the NVT standard, the <CRLF> sequence
  617.             should be used where necessary to denote the end of a line
  618.             of text.  (See the discussion of file structure at the end
  619.             of the Section on Data Representation and Storage.)
  620.  
  621.             Using the standard NVT-ASCII representation means that data
  622.             must be interpreted as 8-bit bytes.
  623.  
  624.             The Format parameter for ASCII and EBCDIC types is discussed
  625.             below.
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634. Postel & Reynolds                                              [Page 11]
  635.  
  636.  
  637.  
  638.                                                                         
  639. RFC 959                                                     October 1985
  640. File Transfer Protocol
  641.  
  642.  
  643.          3.1.1.2.  EBCDIC TYPE
  644.  
  645.             This type is intended for efficient transfer between hosts
  646.             which use EBCDIC for their internal character
  647.             representation.
  648.  
  649.             For transmission, the data are represented as 8-bit EBCDIC
  650.             characters.  The character code is the only difference
  651.             between the functional specifications of EBCDIC and ASCII
  652.             types.
  653.  
  654.             End-of-line (as opposed to end-of-record--see the discussion
  655.             of structure) will probably be rarely used with EBCDIC type
  656.             for purposes of denoting structure, but where it is
  657.             necessary the <NL> character should be used.
  658.  
  659.          3.1.1.3.  IMAGE TYPE
  660.  
  661.             The data are sent as contiguous bits which, for transfer,
  662.             are packed into the 8-bit transfer bytes.  The receiving
  663.             site must store the data as contiguous bits.  The structure
  664.             of the storage system might necessitate the padding of the
  665.             file (or of each record, for a record-structured file) to
  666.             some convenient boundary (byte, word or block).  This
  667.             padding, which must be all zeros, may occur only at the end
  668.             of the file (or at the end of each record) and there must be
  669.             a way of identifying the padding bits so that they may be
  670.             stripped off if the file is retrieved.  The padding
  671.             transformation should be well publicized to enable a user to
  672.             process a file at the storage site.
  673.  
  674.             Image type is intended for the efficient storage and
  675.             retrieval of files and for the transfer of binary data.  It
  676.             is recommended that this type be accepted by all FTP
  677.             implementations.
  678.  
  679.          3.1.1.4.  LOCAL TYPE
  680.  
  681.             The data is transferred in logical bytes of the size
  682.             specified by the obligatory second parameter, Byte size.
  683.             The value of Byte size must be a decimal integer; there is
  684.             no default value.  The logical byte size is not necessarily
  685.             the same as the transfer byte size.  If there is a
  686.             difference in byte sizes, then the logical bytes should be
  687.             packed contiguously, disregarding transfer byte boundaries
  688.             and with any necessary padding at the end.
  689.  
  690.  
  691.  
  692. Postel & Reynolds                                              [Page 12]
  693.  
  694.  
  695.  
  696.                                                                         
  697. RFC 959                                                     October 1985
  698. File Transfer Protocol
  699.  
  700.  
  701.             When the data reaches the receiving host, it will be
  702.             transformed in a manner dependent on the logical byte size
  703.             and the particular host.  This transformation must be
  704.             invertible (i.e., an identical file can be retrieved if the
  705.             same parameters are used) and should be well publicized by
  706.             the FTP implementors.
  707.  
  708.             For example, a user sending 36-bit floating-point numbers to
  709.             a host with a 32-bit word could send that data as Local byte
  710.             with a logical byte size of 36.  The receiving host would
  711.             then be expected to store the logical bytes so that they
  712.             could be easily manipulated; in this example putting the
  713.             36-bit logical bytes into 64-bit double words should
  714.             suffice.
  715.  
  716.             In another example, a pair of hosts with a 36-bit word size
  717.             may send data to one another in words by using TYPE L 36.
  718.             The data would be sent in the 8-bit transmission bytes
  719.             packed so that 9 transmission bytes carried two host words.
  720.  
  721.          3.1.1.5.  FORMAT CONTROL
  722.  
  723.             The types ASCII and EBCDIC also take a second (optional)
  724.             parameter; this is to indicate what kind of vertical format
  725.             control, if any, is associated with a file.  The following
  726.             data representation types are defined in FTP:
  727.  
  728.             A character file may be transferred to a host for one of
  729.             three purposes: for printing, for storage and later
  730.             retrieval, or for processing.  If a file is sent for
  731.             printing, the receiving host must know how the vertical
  732.             format control is represented.  In the second case, it must
  733.             be possible to store a file at a host and then retrieve it
  734.             later in exactly the same form.  Finally, it should be
  735.             possible to move a file from one host to another and process
  736.             the file at the second host without undue trouble.  A single
  737.             ASCII or EBCDIC format does not satisfy all these
  738.             conditions.  Therefore, these types have a second parameter
  739.             specifying one of the following three formats:
  740.  
  741.             3.1.1.5.1.  NON PRINT
  742.  
  743.                This is the default format to be used if the second
  744.                (format) parameter is omitted.  Non-print format must be
  745.                accepted by all FTP implementations.
  746.  
  747.  
  748.  
  749.  
  750. Postel & Reynolds                                              [Page 13]
  751.  
  752.  
  753.  
  754.                                                                         
  755. RFC 959                                                     October 1985
  756. File Transfer Protocol
  757.  
  758.  
  759.                The file need contain no vertical format information.  If
  760.                it is passed to a printer process, this process may
  761.                assume standard values for spacing and margins.
  762.  
  763.                Normally, this format will be used with files destined
  764.                for processing or just storage.
  765.  
  766.             3.1.1.5.2.  TELNET FORMAT CONTROLS
  767.  
  768.                The file contains ASCII/EBCDIC vertical format controls
  769.                (i.e., <CR>, <LF>, <NL>, <VT>, <FF>) which the printer
  770.                process will interpret appropriately.  <CRLF>, in exactly
  771.                this sequence, also denotes end-of-line.
  772.  
  773.             3.1.1.5.2.  CARRIAGE CONTROL (ASA)
  774.  
  775.                The file contains ASA (FORTRAN) vertical format control
  776.                characters.  (See RFC 740 Appendix C; and Communications
  777.                of the ACM, Vol. 7, No. 10, p. 606, October 1964.)  In a
  778.                line or a record formatted according to the ASA Standard,
  779.                the first character is not to be printed.  Instead, it
  780.                should be used to determine the vertical movement of the
  781.                paper which should take place before the rest of the
  782.                record is printed.
  783.  
  784.                The ASA Standard specifies the following control
  785.                characters:
  786.  
  787.                   Character     Vertical Spacing
  788.  
  789.                   blank         Move paper up one line
  790.                   0             Move paper up two lines
  791.                   1             Move paper to top of next page
  792.                   +             No movement, i.e., overprint
  793.  
  794.                Clearly there must be some way for a printer process to
  795.                distinguish the end of the structural entity.  If a file
  796.                has record structure (see below) this is no problem;
  797.                records will be explicitly marked during transfer and
  798.                storage.  If the file has no record structure, the <CRLF>
  799.                end-of-line sequence is used to separate printing lines,
  800.                but these format effectors are overridden by the ASA
  801.                controls.
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808. Postel & Reynolds                                              [Page 14]
  809.  
  810.  
  811.  
  812.                                                                         
  813. RFC 959                                                     October 1985
  814. File Transfer Protocol
  815.  
  816.  
  817.       3.1.2.  DATA STRUCTURES
  818.  
  819.          In addition to different representation types, FTP allows the
  820.          structure of a file to be specified.  Three file structures are
  821.          defined in FTP:
  822.  
  823.             file-structure,     where there is no internal structure and
  824.                                 the file is considered to be a
  825.                                 continuous sequence of data bytes,
  826.  
  827.             record-structure,   where the file is made up of sequential
  828.                                 records,
  829.  
  830.             and page-structure, where the file is made up of independent
  831.                                 indexed pages.
  832.  
  833.          File-structure is the default to be assumed if the STRUcture
  834.          command has not been used but both file and record structures
  835.          must be accepted for "text" files (i.e., files with TYPE ASCII
  836.          or EBCDIC) by all FTP implementations.  The structure of a file
  837.          will affect both the transfer mode of a file (see the Section
  838.          on Transmission Modes) and the interpretation and storage of
  839.          the file.
  840.  
  841.          The "natural" structure of a file will depend on which host
  842.          stores the file.  A source-code file will usually be stored on
  843.          an IBM Mainframe in fixed length records but on a DEC TOPS-20
  844.          as a stream of characters partitioned into lines, for example
  845.          by <CRLF>.  If the transfer of files between such disparate
  846.          sites is to be useful, there must be some way for one site to
  847.          recognize the other's assumptions about the file.
  848.  
  849.          With some sites being naturally file-oriented and others
  850.          naturally record-oriented there may be problems if a file with
  851.          one structure is sent to a host oriented to the other.  If a
  852.          text file is sent with record-structure to a host which is file
  853.          oriented, then that host should apply an internal
  854.          transformation to the file based on the record structure.
  855.          Obviously, this transformation should be useful, but it must
  856.          also be invertible so that an identical file may be retrieved
  857.          using record structure.
  858.  
  859.          In the case of a file being sent with file-structure to a
  860.          record-oriented host, there exists the question of what
  861.          criteria the host should use to divide the file into records
  862.          which can be processed locally.  If this division is necessary,
  863.          the FTP implementation should use the end-of-line sequence,
  864.  
  865.  
  866. Postel & Reynolds                                              [Page 15]
  867.  
  868.  
  869.  
  870.                                                                         
  871. RFC 959                                                     October 1985
  872. File Transfer Protocol
  873.  
  874.  
  875.          <CRLF> for ASCII, or <NL> for EBCDIC text files, as the
  876.          delimiter.  If an FTP implementation adopts this technique, it
  877.          must be prepared to reverse the transformation if the file is
  878.          retrieved with file-structure.
  879.  
  880.          3.1.2.1.  FILE STRUCTURE
  881.  
  882.             File structure is the default to be assumed if the STRUcture
  883.             command has not been used.
  884.  
  885.             In file-structure there is no internal structure and the
  886.             file is considered to be a continuous sequence of data
  887.             bytes.
  888.  
  889.          3.1.2.2.  RECORD STRUCTURE
  890.  
  891.             Record structures must be accepted for "text" files (i.e.,
  892.             files with TYPE ASCII or EBCDIC) by all FTP implementations.
  893.  
  894.             In record-structure the file is made up of sequential
  895.             records.
  896.  
  897.          3.1.2.3.  PAGE STRUCTURE
  898.  
  899.             To transmit files that are discontinuous, FTP defines a page
  900.             structure.  Files of this type are sometimes known as
  901.             "random access files" or even as "holey files".  In these
  902.             files there is sometimes other information associated with
  903.             the file as a whole (e.g., a file descriptor), or with a
  904.             section of the file (e.g., page access controls), or both.
  905.             In FTP, the sections of the file are called pages.
  906.  
  907.             To provide for various page sizes and associated
  908.             information, each page is sent with a page header.  The page
  909.             header has the following defined fields:
  910.  
  911.                Header Length
  912.  
  913.                   The number of logical bytes in the page header
  914.                   including this byte.  The minimum header length is 4.
  915.  
  916.                Page Index
  917.  
  918.                   The logical page number of this section of the file.
  919.                   This is not the transmission sequence number of this
  920.                   page, but the index used to identify this page of the
  921.                   file.
  922.  
  923.  
  924. Postel & Reynolds                                              [Page 16]
  925.  
  926.  
  927.  
  928.                                                                         
  929. RFC 959                                                     October 1985
  930. File Transfer Protocol
  931.  
  932.  
  933.                Data Length
  934.  
  935.                   The number of logical bytes in the page data.  The
  936.                   minimum data length is 0.
  937.  
  938.                Page Type
  939.  
  940.                   The type of page this is.  The following page types
  941.                   are defined:
  942.  
  943.                      0 = Last Page
  944.  
  945.                         This is used to indicate the end of a paged
  946.                         structured transmission.  The header length must
  947.                         be 4, and the data length must be 0.
  948.  
  949.                      1 = Simple Page
  950.  
  951.                         This is the normal type for simple paged files
  952.                         with no page level associated control
  953.                         information.  The header length must be 4.
  954.  
  955.                      2 = Descriptor Page
  956.  
  957.                         This type is used to transmit the descriptive
  958.                         information for the file as a whole.
  959.  
  960.                      3 = Access Controlled Page
  961.  
  962.                         This type includes an additional header field
  963.                         for paged files with page level access control
  964.                         information.  The header length must be 5.
  965.  
  966.                Optional Fields
  967.  
  968.                   Further header fields may be used to supply per page
  969.                   control information, for example, per page access
  970.                   control.
  971.  
  972.             All fields are one logical byte in length.  The logical byte
  973.             size is specified by the TYPE command.  See Appendix I for
  974.             further details and a specific case at the page structure.
  975.  
  976.       A note of caution about parameters:  a file must be stored and
  977.       retrieved with the same parameters if the retrieved version is to
  978.  
  979.  
  980.  
  981.  
  982. Postel & Reynolds                                              [Page 17]
  983.  
  984.  
  985.  
  986.                                                                         
  987. RFC 959                                                     October 1985
  988. File Transfer Protocol
  989.  
  990.  
  991.       be identical to the version originally transmitted.  Conversely,
  992.       FTP implementations must return a file identical to the original
  993.       if the parameters used to store and retrieve a file are the same.
  994.  
  995.    3.2.  ESTABLISHING DATA CONNECTIONS
  996.  
  997.       The mechanics of transferring data consists of setting up the data
  998.       connection to the appropriate ports and choosing the parameters
  999.       for transfer.  Both the user and the server-DTPs have a default
  1000.       data port.  The user-process default data port is the same as the
  1001.       control connection port (i.e., U).  The server-process default
  1002.       data port is the port adjacent to the control connection port
  1003.       (i.e., L-1).
  1004.  
  1005.       The transfer byte size is 8-bit bytes.  This byte size is relevant
  1006.       only for the actual transfer of the data; it has no bearing on
  1007.       representation of the data within a host's file system.
  1008.  
  1009.       The passive data transfer process (this may be a user-DTP or a
  1010.       second server-DTP) shall "listen" on the data port prior to
  1011.       sending a transfer request command.  The FTP request command
  1012.       determines the direction of the data transfer.  The server, upon
  1013.       receiving the transfer request, will initiate the data connection
  1014.       to the port.  When the connection is established, the data
  1015.       transfer begins between DTP's, and the server-PI sends a
  1016.       confirming reply to the user-PI.
  1017.  
  1018.       Every FTP implementation must support the use of the default data
  1019.       ports, and only the USER-PI can initiate a change to non-default
  1020.       ports.
  1021.  
  1022.       It is possible for the user to specify an alternate data port by
  1023.       use of the PORT command.  The user may want a file dumped on a TAC
  1024.       line printer or retrieved from a third party host.  In the latter
  1025.       case, the user-PI sets up control connections with both
  1026.       server-PI's.  One server is then told (by an FTP command) to
  1027.       "listen" for a connection which the other will initiate.  The
  1028.       user-PI sends one server-PI a PORT command indicating the data
  1029.       port of the other.  Finally, both are sent the appropriate
  1030.       transfer commands.  The exact sequence of commands and replies
  1031.       sent between the user-controller and the servers is defined in the
  1032.       Section on FTP Replies.
  1033.  
  1034.       In general, it is the server's responsibility to maintain the data
  1035.       connection--to initiate it and to close it.  The exception to this
  1036.  
  1037.  
  1038.  
  1039.  
  1040. Postel & Reynolds                                              [Page 18]
  1041.  
  1042.  
  1043.  
  1044.                                                                         
  1045. RFC 959                                                     October 1985
  1046. File Transfer Protocol
  1047.  
  1048.  
  1049.       is when the user-DTP is sending the data in a transfer mode that
  1050.       requires the connection to be closed to indicate EOF.  The server
  1051.       MUST close the data connection under the following conditions:
  1052.  
  1053.          1. The server has completed sending data in a transfer mode
  1054.             that requires a close to indicate EOF.
  1055.  
  1056.          2. The server receives an ABORT command from the user.
  1057.  
  1058.          3. The port specification is changed by a command from the
  1059.             user.
  1060.  
  1061.          4. The control connection is closed legally or otherwise.
  1062.  
  1063.          5. An irrecoverable error condition occurs.
  1064.  
  1065.       Otherwise the close is a server option, the exercise of which the
  1066.       server must indicate to the user-process by either a 250 or 226
  1067.       reply only.
  1068.  
  1069.    3.3.  DATA CONNECTION MANAGEMENT
  1070.  
  1071.       Default Data Connection Ports:  All FTP implementations must
  1072.       support use of the default data connection ports, and only the
  1073.       User-PI may initiate the use of non-default ports.
  1074.  
  1075.       Negotiating Non-Default Data Ports:   The User-PI may specify a
  1076.       non-default user side data port with the PORT command.  The
  1077.       User-PI may request the server side to identify a non-default
  1078.       server side data port with the PASV command.  Since a connection
  1079.       is defined by the pair of addresses, either of these actions is
  1080.       enough to get a different data connection, still it is permitted
  1081.       to do both commands to use new ports on both ends of the data
  1082.       connection.
  1083.  
  1084.       Reuse of the Data Connection:  When using the stream mode of data
  1085.       transfer the end of the file must be indicated by closing the
  1086.       connection.  This causes a problem if multiple files are to be
  1087.       transfered in the session, due to need for TCP to hold the
  1088.       connection record for a time out period to guarantee the reliable
  1089.       communication.  Thus the connection can not be reopened at once.
  1090.  
  1091.          There are two solutions to this problem.  The first is to
  1092.          negotiate a non-default port.  The second is to use another
  1093.          transfer mode.
  1094.  
  1095.          A comment on transfer modes.  The stream transfer mode is
  1096.  
  1097.  
  1098. Postel & Reynolds                                              [Page 19]
  1099.  
  1100.  
  1101.  
  1102.                                                                         
  1103. RFC 959                                                     October 1985
  1104. File Transfer Protocol
  1105.  
  1106.  
  1107.          inherently unreliable, since one can not determine if the
  1108.          connection closed prematurely or not.  The other transfer modes
  1109.          (Block, Compressed) do not close the connection to indicate the
  1110.          end of file.  They have enough FTP encoding that the data
  1111.          connection can be parsed to determine the end of the file.
  1112.          Thus using these modes one can leave the data connection open
  1113.          for multiple file transfers.
  1114.  
  1115.    3.4.  TRANSMISSION MODES
  1116.  
  1117.       The next consideration in transferring data is choosing the
  1118.       appropriate transmission mode.  There are three modes: one which
  1119.       formats the data and allows for restart procedures; one which also
  1120.       compresses the data for efficient transfer; and one which passes
  1121.       the data with little or no processing.  In this last case the mode
  1122.       interacts with the structure attribute to determine the type of
  1123.       processing.  In the compressed mode, the representation type
  1124.       determines the filler byte.
  1125.  
  1126.       All data transfers must be completed with an end-of-file (EOF)
  1127.       which may be explicitly stated or implied by the closing of the
  1128.       data connection.  For files with record structure, all the
  1129.       end-of-record markers (EOR) are explicit, including the final one.
  1130.       For files transmitted in page structure a "last-page" page type is
  1131.       used.
  1132.  
  1133.       NOTE:  In the rest of this section, byte means "transfer byte"
  1134.       except where explicitly stated otherwise.
  1135.  
  1136.       For the purpose of standardized transfer, the sending host will
  1137.       translate its internal end of line or end of record denotation
  1138.       into the representation prescribed by the transfer mode and file
  1139.       structure, and the receiving host will perform the inverse
  1140.       translation to its internal denotation.  An IBM Mainframe record
  1141.       count field may not be recognized at another host, so the
  1142.       end-of-record information may be transferred as a two byte control
  1143.       code in Stream mode or as a flagged bit in a Block or Compressed
  1144.       mode descriptor.  End-of-line in an ASCII or EBCDIC file with no
  1145.       record structure should be indicated by <CRLF> or <NL>,
  1146.       respectively.  Since these transformations imply extra work for
  1147.       some systems, identical systems transferring non-record structured
  1148.       text files might wish to use a binary representation and stream
  1149.       mode for the transfer.
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156. Postel & Reynolds                                              [Page 20]
  1157.  
  1158.  
  1159.  
  1160.                                                                         
  1161. RFC 959                                                     October 1985
  1162. File Transfer Protocol
  1163.  
  1164.  
  1165.       The following transmission modes are defined in FTP:
  1166.  
  1167.       3.4.1.  STREAM MODE
  1168.  
  1169.          The data is transmitted as a stream of bytes.  There is no
  1170.          restriction on the representation type used; record structures
  1171.          are allowed.
  1172.  
  1173.          In a record structured file EOR and EOF will each be indicated
  1174.          by a two-byte control code.  The first byte of the control code
  1175.          will be all ones, the escape character.  The second byte will
  1176.          have the low order bit on and zeros elsewhere for EOR and the
  1177.          second low order bit on for EOF; that is, the byte will have
  1178.          value 1 for EOR and value 2 for EOF.  EOR and EOF may be
  1179.          indicated together on the last byte transmitted by turning both
  1180.          low order bits on (i.e., the value 3).  If a byte of all ones
  1181.          was intended to be sent as data, it should be repeated in the
  1182.          second byte of the control code.
  1183.  
  1184.          If the structure is a file structure, the EOF is indicated by
  1185.          the sending host closing the data connection and all bytes are
  1186.          data bytes.
  1187.  
  1188.       3.4.2.  BLOCK MODE
  1189.  
  1190.          The file is transmitted as a series of data blocks preceded by
  1191.          one or more header bytes.  The header bytes contain a count
  1192.          field, and descriptor code.  The count field indicates the
  1193.          total length of the data block in bytes, thus marking the
  1194.          beginning of the next data block (there are no filler bits).
  1195.          The descriptor code defines:  last block in the file (EOF) last
  1196.          block in the record (EOR), restart marker (see the Section on
  1197.          Error Recovery and Restart) or suspect data (i.e., the data
  1198.          being transferred is suspected of errors and is not reliable).
  1199.          This last code is NOT intended for error control within FTP.
  1200.          It is motivated by the desire of sites exchanging certain types
  1201.          of data (e.g., seismic or weather data) to send and receive all
  1202.          the data despite local errors (such as "magnetic tape read
  1203.          errors"), but to indicate in the transmission that certain
  1204.          portions are suspect).  Record structures are allowed in this
  1205.          mode, and any representation type may be used.
  1206.  
  1207.          The header consists of the three bytes.  Of the 24 bits of
  1208.          header information, the 16 low order bits shall represent byte
  1209.          count, and the 8 high order bits shall represent descriptor
  1210.          codes as shown below.
  1211.  
  1212.  
  1213.  
  1214. Postel & Reynolds                                              [Page 21]
  1215.  
  1216.  
  1217.  
  1218.                                                                         
  1219. RFC 959                                                     October 1985
  1220. File Transfer Protocol
  1221.  
  1222.  
  1223.          Block Header
  1224.  
  1225.             +----------------+----------------+----------------+
  1226.             | Descriptor     |    Byte Count                   |
  1227.             |         8 bits |                      16 bits    |
  1228.             +----------------+----------------+----------------+
  1229.             
  1230.  
  1231.          The descriptor codes are indicated by bit flags in the
  1232.          descriptor byte.  Four codes have been assigned, where each
  1233.          code number is the decimal value of the corresponding bit in
  1234.          the byte.
  1235.  
  1236.             Code     Meaning
  1237.             
  1238.              128     End of data block is EOR
  1239.               64     End of data block is EOF
  1240.               32     Suspected errors in data block
  1241.               16     Data block is a restart marker
  1242.  
  1243.          With this encoding, more than one descriptor coded condition
  1244.          may exist for a particular block.  As many bits as necessary
  1245.          may be flagged.
  1246.  
  1247.          The restart marker is embedded in the data stream as an
  1248.          integral number of 8-bit bytes representing printable
  1249.          characters in the language being used over the control
  1250.          connection (e.g., default--NVT-ASCII).  <SP> (Space, in the
  1251.          appropriate language) must not be used WITHIN a restart marker.
  1252.  
  1253.          For example, to transmit a six-character marker, the following
  1254.          would be sent:
  1255.  
  1256.             +--------+--------+--------+
  1257.             |Descrptr|  Byte count     |
  1258.             |code= 16|             = 6 |
  1259.             +--------+--------+--------+
  1260.  
  1261.             +--------+--------+--------+
  1262.             | Marker | Marker | Marker |
  1263.             | 8 bits | 8 bits | 8 bits |
  1264.             +--------+--------+--------+
  1265.  
  1266.             +--------+--------+--------+
  1267.             | Marker | Marker | Marker |
  1268.             | 8 bits | 8 bits | 8 bits |
  1269.             +--------+--------+--------+
  1270.  
  1271.  
  1272. Postel & Reynolds                                              [Page 22]
  1273.  
  1274.  
  1275.  
  1276.                                                                         
  1277. RFC 959                                                     October 1985
  1278. File Transfer Protocol
  1279.  
  1280.  
  1281.       3.4.3.  COMPRESSED MODE
  1282.  
  1283.          There are three kinds of information to be sent:  regular data,
  1284.          sent in a byte string; compressed data, consisting of
  1285.          replications or filler; and control information, sent in a
  1286.          two-byte escape sequence.  If n>0 bytes (up to 127) of regular
  1287.          data are sent, these n bytes are preceded by a byte with the
  1288.          left-most bit set to 0 and the right-most 7 bits containing the
  1289.          number n.
  1290.  
  1291.          Byte string:
  1292.  
  1293.              1       7                8                     8
  1294.             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+
  1295.             |0|       n     | |    d(1)       | ... |      d(n)     |
  1296.             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+
  1297.                                           ^             ^
  1298.                                           |---n bytes---|
  1299.                                               of data
  1300.  
  1301.             String of n data bytes d(1),..., d(n)
  1302.             Count n must be positive.
  1303.  
  1304.          To compress a string of n replications of the data byte d, the
  1305.          following 2 bytes are sent:
  1306.  
  1307.          Replicated Byte:
  1308.  
  1309.               2       6               8
  1310.             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  1311.             |1 0|     n     | |       d       |
  1312.             +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
  1313.  
  1314.          A string of n filler bytes can be compressed into a single
  1315.          byte, where the filler byte varies with the representation
  1316.          type.  If the type is ASCII or EBCDIC the filler byte is <SP>
  1317.          (Space, ASCII code 32, EBCDIC code 64).  If the type is Image
  1318.          or Local byte the filler is a zero byte.
  1319.  
  1320.          Filler String:
  1321.  
  1322.               2       6
  1323.             +-+-+-+-+-+-+-+-+
  1324.             |1 1|     n     |
  1325.             +-+-+-+-+-+-+-+-+
  1326.  
  1327.          The escape sequence is a double byte, the first of which is the
  1328.  
  1329.  
  1330. Postel & Reynolds                                              [Page 23]
  1331.  
  1332.  
  1333.  
  1334.                                                                         
  1335. RFC 959                                                     October 1985
  1336. File Transfer Protocol
  1337.  
  1338.  
  1339.          escape byte (all zeros) and the second of which contains
  1340.          descriptor codes as defined in Block mode.  The descriptor
  1341.          codes have the same meaning as in Block mode and apply to the
  1342.          succeeding string of bytes.
  1343.  
  1344.          Compressed mode is useful for obtaining increased bandwidth on
  1345.          very large network transmissions at a little extra CPU cost.
  1346.          It can be most effectively used to reduce the size of printer
  1347.          files such as those generated by RJE hosts.
  1348.  
  1349.    3.5.  ERROR RECOVERY AND RESTART
  1350.  
  1351.       There is no provision for detecting bits lost or scrambled in data
  1352.       transfer; this level of error control is handled by the TCP.
  1353.       However, a restart procedure is provided to protect users from
  1354.       gross system failures (including failures of a host, an
  1355.       FTP-process, or the underlying network).
  1356.  
  1357.       The restart procedure is defined only for the block and compressed
  1358.       modes of data transfer.  It requires the sender of data to insert
  1359.       a special marker code in the data stream with some marker
  1360.       information.  The marker information has meaning only to the
  1361.       sender, but must consist of printable characters in the default or
  1362.       negotiated language of the control connection (ASCII or EBCDIC).
  1363.       The marker could represent a bit-count, a record-count, or any
  1364.       other information by which a system may identify a data
  1365.       checkpoint.  The receiver of data, if it implements the restart
  1366.       procedure, would then mark the corresponding position of this
  1367.       marker in the receiving system, and return this information to the
  1368.       user.
  1369.  
  1370.       In the event of a system failure, the user can restart the data
  1371.       transfer by identifying the marker point with the FTP restart
  1372.       procedure.  The following example illustrates the use of the
  1373.       restart procedure.
  1374.  
  1375.       The sender of the data inserts an appropriate marker block in the
  1376.       data stream at a convenient point.  The receiving host marks the
  1377.       corresponding data point in its file system and conveys the last
  1378.       known sender and receiver marker information to the user, either
  1379.       directly or over the control connection in a 110 reply (depending
  1380.       on who is the sender).  In the event of a system failure, the user
  1381.       or controller process restarts the server at the last server
  1382.       marker by sending a restart command with server's marker code as
  1383.       its argument.  The restart command is transmitted over the control
  1384.  
  1385.  
  1386.  
  1387.  
  1388. Postel & Reynolds                                              [Page 24]
  1389.  
  1390.  
  1391.  
  1392.                                                                         
  1393. RFC 959                                                     October 1985
  1394. File Transfer Protocol
  1395.  
  1396.  
  1397.       connection and is immediately followed by the command (such as
  1398.       RETR, STOR or LIST) which was being executed when the system
  1399.       failure occurred.
  1400.  
  1401. 4.  FILE TRANSFER FUNCTIONS
  1402.  
  1403.    The communication channel from the user-PI to the server-PI is
  1404.    established as a TCP connection from the user to the standard server
  1405.    port.  The user protocol interpreter is responsible for sending FTP
  1406.    commands and interpreting the replies received; the server-PI
  1407.    interprets commands, sends replies and directs its DTP to set up the
  1408.    data connection and transfer the data.  If the second party to the
  1409.    data transfer (the passive transfer process) is the user-DTP, then it
  1410.    is governed through the internal protocol of the user-FTP host; if it
  1411.    is a second server-DTP, then it is governed by its PI on command from
  1412.    the user-PI.  The FTP replies are discussed in the next section.  In
  1413.    the description of a few of the commands in this section, it is
  1414.    helpful to be explicit about the possible replies.
  1415.  
  1416.    4.1.  FTP COMMANDS
  1417.  
  1418.       4.1.1.  ACCESS CONTROL COMMANDS
  1419.  
  1420.          The following commands specify access control identifiers
  1421.          (command codes are shown in parentheses).
  1422.  
  1423.          USER NAME (USER)
  1424.  
  1425.             The argument field is a Telnet string identifying the user.
  1426.             The user identification is that which is required by the
  1427.             server for access to its file system.  This command will
  1428.             normally be the first command transmitted by the user after
  1429.             the control connections are made (some servers may require
  1430.             this).  Additional identification information in the form of
  1431.             a password and/or an account command may also be required by
  1432.             some servers.  Servers may allow a new USER command to be
  1433.             entered at any point in order to change the access control
  1434.             and/or accounting information.  This has the effect of
  1435.             flushing any user, password, and account information already
  1436.             supplied and beginning the login sequence again.  All
  1437.             transfer parameters are unchanged and any file transfer in
  1438.             progress is completed under the old access control
  1439.             parameters.
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446. Postel & Reynolds                                              [Page 25]
  1447.  
  1448.  
  1449.  
  1450.                                                                         
  1451. RFC 959                                                     October 1985
  1452. File Transfer Protocol
  1453.  
  1454.  
  1455.          PASSWORD (PASS)
  1456.  
  1457.             The argument field is a Telnet string specifying the user's
  1458.             password.  This command must be immediately preceded by the
  1459.             user name command, and, for some sites, completes the user's
  1460.             identification for access control.  Since password
  1461.             information is quite sensitive, it is desirable in general
  1462.             to "mask" it or suppress typeout.  It appears that the
  1463.             server has no foolproof way to achieve this.  It is
  1464.             therefore the responsibility of the user-FTP process to hide
  1465.             the sensitive password information.
  1466.  
  1467.          ACCOUNT (ACCT)
  1468.  
  1469.             The argument field is a Telnet string identifying the user's
  1470.             account.  The command is not necessarily related to the USER
  1471.             command, as some sites may require an account for login and
  1472.             others only for specific access, such as storing files.  In
  1473.             the latter case the command may arrive at any time.
  1474.  
  1475.             There are reply codes to differentiate these cases for the
  1476.             automation: when account information is required for login,
  1477.             the response to a successful PASSword command is reply code
  1478.             332.  On the other hand, if account information is NOT
  1479.             required for login, the reply to a successful PASSword
  1480.             command is 230; and if the account information is needed for
  1481.             a command issued later in the dialogue, the server should
  1482.             return a 332 or 532 reply depending on whether it stores
  1483.             (pending receipt of the ACCounT command) or discards the
  1484.             command, respectively.
  1485.  
  1486.          CHANGE WORKING DIRECTORY (CWD)
  1487.  
  1488.             This command allows the user to work with a different
  1489.             directory or dataset for file storage or retrieval without
  1490.             altering his login or accounting information.  Transfer
  1491.             parameters are similarly unchanged.  The argument is a
  1492.             pathname specifying a directory or other system dependent
  1493.             file group designator.
  1494.  
  1495.          CHANGE TO PARENT DIRECTORY (CDUP)
  1496.  
  1497.             This command is a special case of CWD, and is included to
  1498.             simplify the implementation of programs for transferring
  1499.             directory trees between operating systems having different
  1500.  
  1501.  
  1502.  
  1503.  
  1504. Postel & Reynolds                                              [Page 26]
  1505.  
  1506.  
  1507.  
  1508.                                                                         
  1509. RFC 959                                                     October 1985
  1510. File Transfer Protocol
  1511.  
  1512.  
  1513.             syntaxes for naming the parent directory.  The reply codes
  1514.             shall be identical to the reply codes of CWD.  See
  1515.             Appendix II for further details.
  1516.  
  1517.          STRUCTURE MOUNT (SMNT)
  1518.  
  1519.             This command allows the user to mount a different file
  1520.             system data structure without altering his login or
  1521.             accounting information.  Transfer parameters are similarly
  1522.             unchanged.  The argument is a pathname specifying a
  1523.             directory or other system dependent file group designator.
  1524.  
  1525.          REINITIALIZE (REIN)
  1526.  
  1527.             This command terminates a USER, flushing all I/O and account
  1528.             information, except to allow any transfer in progress to be
  1529.             completed.  All parameters are reset to the default settings
  1530.             and the control connection is left open.  This is identical
  1531.             to the state in which a user finds himself immediately after
  1532.             the control connection is opened.  A USER command may be
  1533.             expected to follow.
  1534.  
  1535.          LOGOUT (QUIT)
  1536.  
  1537.             This command terminates a USER and if file transfer is not
  1538.             in progress, the server closes the control connection.  If
  1539.             file transfer is in progress, the connection will remain
  1540.             open for result response and the server will then close it.
  1541.             If the user-process is transferring files for several USERs
  1542.             but does not wish to close and then reopen connections for
  1543.             each, then the REIN command should be used instead of QUIT.
  1544.  
  1545.             An unexpected close on the control connection will cause the
  1546.             server to take the effective action of an abort (ABOR) and a
  1547.             logout (QUIT).
  1548.  
  1549.       4.1.2.  TRANSFER PARAMETER COMMANDS
  1550.  
  1551.          All data transfer parameters have default values, and the
  1552.          commands specifying data transfer parameters are required only
  1553.          if the default parameter values are to be changed.  The default
  1554.          value is the last specified value, or if no value has been
  1555.          specified, the standard default value is as stated here.  This
  1556.          implies that the server must "remember" the applicable default
  1557.          values.  The commands may be in any order except that they must
  1558.          precede the FTP service request.  The following commands
  1559.          specify data transfer parameters:
  1560.  
  1561.  
  1562. Postel & Reynolds                                              [Page 27]
  1563.  
  1564.  
  1565.  
  1566.                                                                         
  1567. RFC 959                                                     October 1985
  1568. File Transfer Protocol
  1569.  
  1570.  
  1571.          DATA PORT (PORT)
  1572.  
  1573.             The argument is a HOST-PORT specification for the data port
  1574.             to be used in data connection.  There are defaults for both
  1575.             the user and server data ports, and under normal
  1576.             circumstances this command and its reply are not needed.  If
  1577.             this command is used, the argument is the concatenation of a
  1578.             32-bit internet host address and a 16-bit TCP port address.
  1579.             This address information is broken into 8-bit fields and the
  1580.             value of each field is transmitted as a decimal number (in
  1581.             character string representation).  The fields are separated
  1582.             by commas.  A port command would be:
  1583.  
  1584.                PORT h1,h2,h3,h4,p1,p2
  1585.  
  1586.             where h1 is the high order 8 bits of the internet host
  1587.             address.
  1588.  
  1589.          PASSIVE (PASV)
  1590.  
  1591.             This command requests the server-DTP to "listen" on a data
  1592.             port (which is not its default data port) and to wait for a
  1593.             connection rather than initiate one upon receipt of a
  1594.             transfer command.  The response to this command includes the
  1595.             host and port address this server is listening on.
  1596.  
  1597.          REPRESENTATION TYPE (TYPE)
  1598.  
  1599.             The argument specifies the representation type as described
  1600.             in the Section on Data Representation and Storage.  Several
  1601.             types take a second parameter.  The first parameter is
  1602.             denoted by a single Telnet character, as is the second
  1603.             Format parameter for ASCII and EBCDIC; the second parameter
  1604.             for local byte is a decimal integer to indicate Bytesize.
  1605.             The parameters are separated by a <SP> (Space, ASCII code
  1606.             32).
  1607.  
  1608.             The following codes are assigned for type:
  1609.  
  1610.                          \    /
  1611.                A - ASCII |    | N - Non-print
  1612.                          |-><-| T - Telnet format effectors
  1613.                E - EBCDIC|    | C - Carriage Control (ASA)
  1614.                          /    \
  1615.                I - Image
  1616.                
  1617.                L <byte size> - Local byte Byte size
  1618.  
  1619.  
  1620. Postel & Reynolds                                              [Page 28]
  1621.  
  1622.  
  1623.  
  1624.                                                                         
  1625. RFC 959                                                     October 1985
  1626. File Transfer Protocol
  1627.  
  1628.  
  1629.             The default representation type is ASCII Non-print.  If the
  1630.             Format parameter is changed, and later just the first
  1631.             argument is changed, Format then returns to the Non-print
  1632.             default.
  1633.  
  1634.          FILE STRUCTURE (STRU)
  1635.  
  1636.             The argument is a single Telnet character code specifying
  1637.             file structure described in the Section on Data
  1638.             Representation and Storage.
  1639.  
  1640.             The following codes are assigned for structure:
  1641.  
  1642.                F - File (no record structure)
  1643.                R - Record structure
  1644.                P - Page structure
  1645.  
  1646.             The default structure is File.
  1647.  
  1648.          TRANSFER MODE (MODE)
  1649.  
  1650.             The argument is a single Telnet character code specifying
  1651.             the data transfer modes described in the Section on
  1652.             Transmission Modes.
  1653.  
  1654.             The following codes are assigned for transfer modes:
  1655.  
  1656.                S - Stream
  1657.                B - Block
  1658.                C - Compressed
  1659.  
  1660.             The default transfer mode is Stream.
  1661.  
  1662.       4.1.3.  FTP SERVICE COMMANDS
  1663.  
  1664.          The FTP service commands define the file transfer or the file
  1665.          system function requested by the user.  The argument of an FTP
  1666.          service command will normally be a pathname.  The syntax of
  1667.          pathnames must conform to server site conventions (with
  1668.          standard defaults applicable), and the language conventions of
  1669.          the control connection.  The suggested default handling is to
  1670.          use the last specified device, directory or file name, or the
  1671.          standard default defined for local users.  The commands may be
  1672.          in any order except that a "rename from" command must be
  1673.          followed by a "rename to" command and the restart command must
  1674.          be followed by the interrupted service command (e.g., STOR or
  1675.          RETR).  The data, when transferred in response to FTP service
  1676.  
  1677.  
  1678. Postel & Reynolds                                              [Page 29]
  1679.  
  1680.  
  1681.  
  1682.                                                                         
  1683. RFC 959                                                     October 1985
  1684. File Transfer Protocol
  1685.  
  1686.  
  1687.          commands, shall always be sent over the data connection, except
  1688.          for certain informative replies.  The following commands
  1689.          specify FTP service requests:
  1690.  
  1691.          RETRIEVE (RETR)
  1692.  
  1693.             This command causes the server-DTP to transfer a copy of the
  1694.             file, specified in the pathname, to the server- or user-DTP
  1695.             at the other end of the data connection.  The status and
  1696.             contents of the file at the server site shall be unaffected.
  1697.  
  1698.          STORE (STOR)
  1699.  
  1700.             This command causes the server-DTP to accept the data
  1701.             transferred via the data connection and to store the data as
  1702.             a file at the server site.  If the file specified in the
  1703.             pathname exists at the server site, then its contents shall
  1704.             be replaced by the data being transferred.  A new file is
  1705.             created at the server site if the file specified in the
  1706.             pathname does not already exist.
  1707.  
  1708.          STORE UNIQUE (STOU)
  1709.  
  1710.             This command behaves like STOR except that the resultant
  1711.             file is to be created in the current directory under a name
  1712.             unique to that directory.  The 250 Transfer Started response
  1713.             must include the name generated.
  1714.  
  1715.          APPEND (with create) (APPE)
  1716.  
  1717.             This command causes the server-DTP to accept the data
  1718.             transferred via the data connection and to store the data in
  1719.             a file at the server site.  If the file specified in the
  1720.             pathname exists at the server site, then the data shall be
  1721.             appended to that file; otherwise the file specified in the
  1722.             pathname shall be created at the server site.
  1723.  
  1724.          ALLOCATE (ALLO)
  1725.  
  1726.             This command may be required by some servers to reserve
  1727.             sufficient storage to accommodate the new file to be
  1728.             transferred.  The argument shall be a decimal integer
  1729.             representing the number of bytes (using the logical byte
  1730.             size) of storage to be reserved for the file.  For files
  1731.             sent with record or page structure a maximum record or page
  1732.             size (in logical bytes) might also be necessary; this is
  1733.             indicated by a decimal integer in a second argument field of
  1734.  
  1735.  
  1736. Postel & Reynolds                                              [Page 30]
  1737.  
  1738.  
  1739.  
  1740.                                                                         
  1741. RFC 959                                                     October 1985
  1742. File Transfer Protocol
  1743.  
  1744.  
  1745.             the command.  This second argument is optional, but when
  1746.             present should be separated from the first by the three
  1747.             Telnet characters <SP> R <SP>.  This command shall be
  1748.             followed by a STORe or APPEnd command.  The ALLO command
  1749.             should be treated as a NOOP (no operation) by those servers
  1750.             which do not require that the maximum size of the file be
  1751.             declared beforehand, and those servers interested in only
  1752.             the maximum record or page size should accept a dummy value
  1753.             in the first argument and ignore it.
  1754.  
  1755.          RESTART (REST)
  1756.  
  1757.             The argument field represents the server marker at which
  1758.             file transfer is to be restarted.  This command does not
  1759.             cause file transfer but skips over the file to the specified
  1760.             data checkpoint.  This command shall be immediately followed
  1761.             by the appropriate FTP service command which shall cause
  1762.             file transfer to resume.
  1763.  
  1764.          RENAME FROM (RNFR)
  1765.  
  1766.             This command specifies the old pathname of the file which is
  1767.             to be renamed.  This command must be immediately followed by
  1768.             a "rename to" command specifying the new file pathname.
  1769.  
  1770.          RENAME TO (RNTO)
  1771.  
  1772.             This command specifies the new pathname of the file
  1773.             specified in the immediately preceding "rename from"
  1774.             command.  Together the two commands cause a file to be
  1775.             renamed.
  1776.  
  1777.          ABORT (ABOR)
  1778.  
  1779.             This command tells the server to abort the previous FTP
  1780.             service command and any associated transfer of data.  The
  1781.             abort command may require "special action", as discussed in
  1782.             the Section on FTP Commands, to force recognition by the
  1783.             server.  No action is to be taken if the previous command
  1784.             has been completed (including data transfer).  The control
  1785.             connection is not to be closed by the server, but the data
  1786.             connection must be closed.
  1787.  
  1788.             There are two cases for the server upon receipt of this
  1789.             command: (1) the FTP service command was already completed,
  1790.             or (2) the FTP service command is still in progress.
  1791.  
  1792.  
  1793.  
  1794. Postel & Reynolds                                              [Page 31]
  1795.  
  1796.  
  1797.  
  1798.                                                                         
  1799. RFC 959                                                     October 1985
  1800. File Transfer Protocol
  1801.  
  1802.  
  1803.                In the first case, the server closes the data connection
  1804.                (if it is open) and responds with a 226 reply, indicating
  1805.                that the abort command was successfully processed.
  1806.  
  1807.                In the second case, the server aborts the FTP service in
  1808.                progress and closes the data connection, returning a 426
  1809.                reply to indicate that the service request terminated
  1810.                abnormally.  The server then sends a 226 reply,
  1811.                indicating that the abort command was successfully
  1812.                processed.
  1813.  
  1814.          DELETE (DELE)
  1815.  
  1816.             This command causes the file specified in the pathname to be
  1817.             deleted at the server site.  If an extra level of protection
  1818.             is desired (such as the query, "Do you really wish to
  1819.             delete?"), it should be provided by the user-FTP process.
  1820.  
  1821.          REMOVE DIRECTORY (RMD)
  1822.  
  1823.             This command causes the directory specified in the pathname
  1824.             to be removed as a directory (if the pathname is absolute)
  1825.             or as a subdirectory of the current working directory (if
  1826.             the pathname is relative).  See Appendix II.
  1827.  
  1828.          MAKE DIRECTORY (MKD)
  1829.  
  1830.             This command causes the directory specified in the pathname
  1831.             to be created as a directory (if the pathname is absolute)
  1832.             or as a subdirectory of the current working directory (if
  1833.             the pathname is relative).  See Appendix II.
  1834.  
  1835.          PRINT WORKING DIRECTORY (PWD)
  1836.  
  1837.             This command causes the name of the current working
  1838.             directory to be returned in the reply.  See Appendix II.
  1839.  
  1840.          LIST (LIST)
  1841.  
  1842.             This command causes a list to be sent from the server to the
  1843.             passive DTP.  If the pathname specifies a directory or other
  1844.             group of files, the server should transfer a list of files
  1845.             in the specified directory.  If the pathname specifies a
  1846.             file then the server should send current information on the
  1847.             file.  A null argument implies the user's current working or
  1848.             default directory.  The data transfer is over the data
  1849.             connection in type ASCII or type EBCDIC.  (The user must
  1850.  
  1851.  
  1852. Postel & Reynolds                                              [Page 32]
  1853.  
  1854.  
  1855.  
  1856.                                                                         
  1857. RFC 959                                                     October 1985
  1858. File Transfer Protocol
  1859.  
  1860.  
  1861.             ensure that the TYPE is appropriately ASCII or EBCDIC).
  1862.             Since the information on a file may vary widely from system
  1863.             to system, this information may be hard to use automatically
  1864.             in a program, but may be quite useful to a human user.
  1865.  
  1866.          NAME LIST (NLST)
  1867.  
  1868.             This command causes a directory listing to be sent from
  1869.             server to user site.  The pathname should specify a
  1870.             directory or other system-specific file group descriptor; a
  1871.             null argument implies the current directory.  The server
  1872.             will return a stream of names of files and no other
  1873.             information.  The data will be transferred in ASCII or
  1874.             EBCDIC type over the data connection as valid pathname
  1875.             strings separated by <CRLF> or <NL>.  (Again the user must
  1876.             ensure that the TYPE is correct.)  This command is intended
  1877.             to return information that can be used by a program to
  1878.             further process the files automatically.  For example, in
  1879.             the implementation of a "multiple get" function.
  1880.  
  1881.          SITE PARAMETERS (SITE)
  1882.  
  1883.             This command is used by the server to provide services
  1884.             specific to his system that are essential to file transfer
  1885.             but not sufficiently universal to be included as commands in
  1886.             the protocol.  The nature of these services and the
  1887.             specification of their syntax can be stated in a reply to
  1888.             the HELP SITE command.
  1889.  
  1890.          SYSTEM (SYST)
  1891.  
  1892.             This command is used to find out the type of operating
  1893.             system at the server.  The reply shall have as its first
  1894.             word one of the system names listed in the current version
  1895.             of the Assigned Numbers document [4].
  1896.  
  1897.          STATUS (STAT)
  1898.  
  1899.             This command shall cause a status response to be sent over
  1900.             the control connection in the form of a reply.  The command
  1901.             may be sent during a file transfer (along with the Telnet IP
  1902.             and Synch signals--see the Section on FTP Commands) in which
  1903.             case the server will respond with the status of the
  1904.             operation in progress, or it may be sent between file
  1905.             transfers.  In the latter case, the command may have an
  1906.             argument field.  If the argument is a pathname, the command
  1907.             is analogous to the "list" command except that data shall be
  1908.  
  1909.  
  1910. Postel & Reynolds                                              [Page 33]
  1911.  
  1912.  
  1913.  
  1914.                                                                         
  1915. RFC 959                                                     October 1985
  1916. File Transfer Protocol
  1917.  
  1918.  
  1919.             transferred over the control connection.  If a partial
  1920.             pathname is given, the server may respond with a list of
  1921.             file names or attributes associated with that specification.
  1922.             If no argument is given, the server should return general
  1923.             status information about the server FTP process.  This
  1924.             should include current values of all transfer parameters and
  1925.             the status of connections.
  1926.  
  1927.          HELP (HELP)
  1928.  
  1929.             This command shall cause the server to send helpful
  1930.             information regarding its implementation status over the
  1931.             control connection to the user.  The command may take an
  1932.             argument (e.g., any command name) and return more specific
  1933.             information as a response.  The reply is type 211 or 214.
  1934.             It is suggested that HELP be allowed before entering a USER
  1935.             command. The server may use this reply to specify
  1936.             site-dependent parameters, e.g., in response to HELP SITE.
  1937.  
  1938.          NOOP (NOOP)
  1939.  
  1940.             This command does not affect any parameters or previously
  1941.             entered commands. It specifies no action other than that the
  1942.             server send an OK reply.
  1943.  
  1944.    The File Transfer Protocol follows the specifications of the Telnet
  1945.    protocol for all communications over the control connection.  Since
  1946.    the language used for Telnet communication may be a negotiated
  1947.    option, all references in the next two sections will be to the
  1948.    "Telnet language" and the corresponding "Telnet end-of-line code".
  1949.    Currently, one may take these to mean NVT-ASCII and <CRLF>.  No other
  1950.    specifications of the Telnet protocol will be cited.
  1951.  
  1952.    FTP commands are "Telnet strings" terminated by the "Telnet end of
  1953.    line code".  The command codes themselves are alphabetic characters
  1954.    terminated by the character <SP> (Space) if parameters follow and
  1955.    Telnet-EOL otherwise.  The command codes and the semantics of
  1956.    commands are described in this section; the detailed syntax of
  1957.    commands is specified in the Section on Commands, the reply sequences
  1958.    are discussed in the Section on Sequencing of Commands and Replies,
  1959.    and scenarios illustrating the use of commands are provided in the
  1960.    Section on Typical FTP Scenarios.
  1961.  
  1962.    FTP commands may be partitioned as those specifying access-control
  1963.    identifiers, data transfer parameters, or FTP service requests.
  1964.    Certain commands (such as ABOR, STAT, QUIT) may be sent over the
  1965.    control connection while a data transfer is in progress.  Some
  1966.  
  1967.  
  1968. Postel & Reynolds                                              [Page 34]
  1969.  
  1970.  
  1971.  
  1972.                                                                         
  1973. RFC 959                                                     October 1985
  1974. File Transfer Protocol
  1975.  
  1976.  
  1977.    servers may not be able to monitor the control and data connections
  1978.    simultaneously, in which case some special action will be necessary
  1979.    to get the server's attention.  The following ordered format is
  1980.    tentatively recommended:
  1981.  
  1982.       1. User system inserts the Telnet "Interrupt Process" (IP) signal
  1983.       in the Telnet stream.
  1984.  
  1985.       2. User system sends the Telnet "Synch" signal.
  1986.  
  1987.       3. User system inserts the command (e.g., ABOR) in the Telnet
  1988.       stream.
  1989.  
  1990.       4. Server PI, after receiving "IP", scans the Telnet stream for
  1991.       EXACTLY ONE FTP command.
  1992.  
  1993.    (For other servers this may not be necessary but the actions listed
  1994.    above should have no unusual effect.)
  1995.  
  1996.    4.2.  FTP REPLIES
  1997.  
  1998.       Replies to File Transfer Protocol commands are devised to ensure
  1999.       the synchronization of requests and actions in the process of file
  2000.       transfer, and to guarantee that the user process always knows the
  2001.       state of the Server.  Every command must generate at least one
  2002.       reply, although there may be more than one; in the latter case,
  2003.       the multiple replies must be easily distinguished.  In addition,
  2004.       some commands occur in sequential groups, such as USER, PASS and
  2005.       ACCT, or RNFR and RNTO.  The replies show the existence of an
  2006.       intermediate state if all preceding commands have been successful.
  2007.       A failure at any point in the sequence necessitates the repetition
  2008.       of the entire sequence from the beginning.
  2009.  
  2010.          The details of the command-reply sequence are made explicit in
  2011.          a set of state diagrams below.
  2012.  
  2013.       An FTP reply consists of a three digit number (transmitted as
  2014.       three alphanumeric characters) followed by some text.  The number
  2015.       is intended for use by automata to determine what state to enter
  2016.       next; the text is intended for the human user.  It is intended
  2017.       that the three digits contain enough encoded information that the
  2018.       user-process (the User-PI) will not need to examine the text and
  2019.       may either discard it or pass it on to the user, as appropriate.
  2020.       In particular, the text may be server-dependent, so there are
  2021.       likely to be varying texts for each reply code.
  2022.  
  2023.       A reply is defined to contain the 3-digit code, followed by Space
  2024.  
  2025.  
  2026. Postel & Reynolds                                              [Page 35]
  2027.  
  2028.  
  2029.  
  2030.                                                                         
  2031. RFC 959                                                     October 1985
  2032. File Transfer Protocol
  2033.  
  2034.  
  2035.       <SP>, followed by one line of text (where some maximum line length
  2036.       has been specified), and terminated by the Telnet end-of-line
  2037.       code.  There will be cases however, where the text is longer than
  2038.       a single line.  In these cases the complete text must be bracketed
  2039.       so the User-process knows when it may stop reading the reply (i.e.
  2040.       stop processing input on the control connection) and go do other
  2041.       things.  This requires a special format on the first line to
  2042.       indicate that more than one line is coming, and another on the
  2043.       last line to designate it as the last.  At least one of these must
  2044.       contain the appropriate reply code to indicate the state of the
  2045.       transaction.  To satisfy all factions, it was decided that both
  2046.       the first and last line codes should be the same.
  2047.  
  2048.          Thus the format for multi-line replies is that the first line
  2049.          will begin with the exact required reply code, followed
  2050.          immediately by a Hyphen, "-" (also known as Minus), followed by
  2051.          text.  The last line will begin with the same code, followed
  2052.          immediately by Space <SP>, optionally some text, and the Telnet
  2053.          end-of-line code.
  2054.  
  2055.             For example:
  2056.                                 123-First line
  2057.                                 Second line
  2058.                                   234 A line beginning with numbers
  2059.                                 123 The last line
  2060.  
  2061.          The user-process then simply needs to search for the second
  2062.          occurrence of the same reply code, followed by <SP> (Space), at
  2063.          the beginning of a line, and ignore all intermediary lines.  If
  2064.          an intermediary line begins with a 3-digit number, the Server
  2065.          must pad the front  to avoid confusion.
  2066.  
  2067.             This scheme allows standard system routines to be used for
  2068.             reply information (such as for the STAT reply), with
  2069.             "artificial" first and last lines tacked on.  In rare cases
  2070.             where these routines are able to generate three digits and a
  2071.             Space at the beginning of any line, the beginning of each
  2072.             text line should be offset by some neutral text, like Space.
  2073.  
  2074.          This scheme assumes that multi-line replies may not be nested.
  2075.  
  2076.       The three digits of the reply each have a special significance.
  2077.       This is intended to allow a range of very simple to very
  2078.       sophisticated responses by the user-process.  The first digit
  2079.       denotes whether the response is good, bad or incomplete.
  2080.       (Referring to the state diagram), an unsophisticated user-process
  2081.       will be able to determine its next action (proceed as planned,
  2082.  
  2083.  
  2084. Postel & Reynolds                                              [Page 36]
  2085.  
  2086.  
  2087.  
  2088.                                                                         
  2089. RFC 959                                                     October 1985
  2090. File Transfer Protocol
  2091.  
  2092.  
  2093.       redo, retrench, etc.) by simply examining this first digit.  A
  2094.       user-process that wants to know approximately what kind of error
  2095.       occurred (e.g. file system error, command syntax error) may
  2096.       examine the second digit, reserving the third digit for the finest
  2097.       gradation of information (e.g., RNTO command without a preceding
  2098.       RNFR).
  2099.  
  2100.          There are five values for the first digit of the reply code:
  2101.  
  2102.             1yz   Positive Preliminary reply
  2103.  
  2104.                The requested action is being initiated; expect another
  2105.                reply before proceeding with a new command.  (The
  2106.                user-process sending another command before the
  2107.                completion reply would be in violation of protocol; but
  2108.                server-FTP processes should queue any commands that
  2109.                arrive while a preceding command is in progress.)  This
  2110.                type of reply can be used to indicate that the command
  2111.                was accepted and the user-process may now pay attention
  2112.                to the data connections, for implementations where
  2113.                simultaneous monitoring is difficult.  The server-FTP
  2114.                process may send at most, one 1yz reply per command.
  2115.  
  2116.             2yz   Positive Completion reply
  2117.  
  2118.                The requested action has been successfully completed.  A
  2119.                new request may be initiated.
  2120.  
  2121.             3yz   Positive Intermediate reply
  2122.  
  2123.                The command has been accepted, but the requested action
  2124.                is being held in abeyance, pending receipt of further
  2125.                information.  The user should send another command
  2126.                specifying this information.  This reply is used in
  2127.                command sequence groups.
  2128.  
  2129.             4yz   Transient Negative Completion reply
  2130.  
  2131.                The command was not accepted and the requested action did
  2132.                not take place, but the error condition is temporary and
  2133.                the action may be requested again.  The user should
  2134.                return to the beginning of the command sequence, if any.
  2135.                It is difficult to assign a meaning to "transient",
  2136.                particularly when two distinct sites (Server- and
  2137.                User-processes) have to agree on the interpretation.
  2138.                Each reply in the 4yz category might have a slightly
  2139.                different time value, but the intent is that the
  2140.  
  2141.  
  2142. Postel & Reynolds                                              [Page 37]
  2143.  
  2144.  
  2145.  
  2146.                                                                         
  2147. RFC 959                                                     October 1985
  2148. File Transfer Protocol
  2149.  
  2150.  
  2151.                user-process is encouraged to try again.  A rule of thumb
  2152.                in determining if a reply fits into the 4yz or the 5yz
  2153.                (Permanent Negative) category is that replies are 4yz if
  2154.                the commands can be repeated without any change in
  2155.                command form or in properties of the User or Server
  2156.                (e.g., the command is spelled the same with the same
  2157.                arguments used; the user does not change his file access
  2158.                or user name; the server does not put up a new
  2159.                implementation.)
  2160.  
  2161.             5yz   Permanent Negative Completion reply
  2162.  
  2163.                The command was not accepted and the requested action did
  2164.                not take place.  The User-process is discouraged from
  2165.                repeating the exact request (in the same sequence).  Even
  2166.                some "permanent" error conditions can be corrected, so
  2167.                the human user may want to direct his User-process to
  2168.                reinitiate the command sequence by direct action at some
  2169.                point in the future (e.g., after the spelling has been
  2170.                changed, or the user has altered his directory status.)
  2171.  
  2172.          The following function groupings are encoded in the second
  2173.          digit:
  2174.  
  2175.             x0z   Syntax - These replies refer to syntax errors,
  2176.                   syntactically correct commands that don't fit any
  2177.                   functional category, unimplemented or superfluous
  2178.                   commands.
  2179.  
  2180.             x1z   Information -  These are replies to requests for
  2181.                   information, such as status or help.
  2182.  
  2183.             x2z   Connections - Replies referring to the control and
  2184.                   data connections.
  2185.  
  2186.             x3z   Authentication and accounting - Replies for the login
  2187.                   process and accounting procedures.
  2188.  
  2189.             x4z   Unspecified as yet.
  2190.  
  2191.             x5z   File system - These replies indicate the status of the
  2192.                   Server file system vis-a-vis the requested transfer or
  2193.                   other file system action.
  2194.  
  2195.          The third digit gives a finer gradation of meaning in each of
  2196.          the function categories, specified by the second digit.  The
  2197.          list of replies below will illustrate this.  Note that the text
  2198.  
  2199.  
  2200. Postel & Reynolds                                              [Page 38]
  2201.  
  2202.  
  2203.  
  2204.                                                                         
  2205. RFC 959                                                     October 1985
  2206. File Transfer Protocol
  2207.  
  2208.  
  2209.          associated with each reply is recommended, rather than
  2210.          mandatory, and may even change according to the command with
  2211.          which it is associated.  The reply codes, on the other hand,
  2212.          must strictly follow the specifications in the last section;
  2213.          that is, Server implementations should not invent new codes for
  2214.          situations that are only slightly different from the ones
  2215.          described here, but rather should adapt codes already defined.
  2216.  
  2217.             A command such as TYPE or ALLO whose successful execution
  2218.             does not offer the user-process any new information will
  2219.             cause a 200 reply to be returned.  If the command is not
  2220.             implemented by a particular Server-FTP process because it
  2221.             has no relevance to that computer system, for example ALLO
  2222.             at a TOPS20 site, a Positive Completion reply is still
  2223.             desired so that the simple User-process knows it can proceed
  2224.             with its course of action.  A 202 reply is used in this case
  2225.             with, for example, the reply text:  "No storage allocation
  2226.             necessary."  If, on the other hand, the command requests a
  2227.             non-site-specific action and is unimplemented, the response
  2228.             is 502.  A refinement of that is the 504 reply for a command
  2229.             that is implemented, but that requests an unimplemented
  2230.             parameter.
  2231.  
  2232.       4.2.1  Reply Codes by Function Groups
  2233.  
  2234.          200 Command okay.
  2235.          500 Syntax error, command unrecognized.
  2236.              This may include errors such as command line too long.
  2237.          501 Syntax error in parameters or arguments.
  2238.          202 Command not implemented, superfluous at this site.
  2239.          502 Command not implemented.
  2240.          503 Bad sequence of commands.
  2241.          504 Command not implemented for that parameter.
  2242.           
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258. Postel & Reynolds                                              [Page 39]
  2259.  
  2260.  
  2261.  
  2262.                                                                         
  2263. RFC 959                                                     October 1985
  2264. File Transfer Protocol
  2265.  
  2266.  
  2267.          110 Restart marker reply.
  2268.              In this case, the text is exact and not left to the
  2269.              particular implementation; it must read:
  2270.                   MARK yyyy = mmmm
  2271.              Where yyyy is User-process data stream marker, and mmmm
  2272.              server's equivalent marker (note the spaces between markers
  2273.              and "=").
  2274.          211 System status, or system help reply.
  2275.          212 Directory status.
  2276.          213 File status.
  2277.          214 Help message.
  2278.              On how to use the server or the meaning of a particular
  2279.              non-standard command.  This reply is useful only to the
  2280.              human user.
  2281.          215 NAME system type.
  2282.              Where NAME is an official system name from the list in the
  2283.              Assigned Numbers document.
  2284.           
  2285.          120 Service ready in nnn minutes.
  2286.          220 Service ready for new user.
  2287.          221 Service closing control connection.
  2288.              Logged out if appropriate.
  2289.          421 Service not available, closing control connection.
  2290.              This may be a reply to any command if the service knows it
  2291.              must shut down.
  2292.          125 Data connection already open; transfer starting.
  2293.          225 Data connection open; no transfer in progress.
  2294.          425 Can't open data connection.
  2295.          226 Closing data connection.
  2296.              Requested file action successful (for example, file
  2297.              transfer or file abort).
  2298.          426 Connection closed; transfer aborted.
  2299.          227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
  2300.           
  2301.          230 User logged in, proceed.
  2302.          530 Not logged in.
  2303.          331 User name okay, need password.
  2304.          332 Need account for login.
  2305.          532 Need account for storing files.
  2306.           
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316. Postel & Reynolds                                              [Page 40]
  2317.  
  2318.  
  2319.  
  2320.                                                                         
  2321. RFC 959                                                     October 1985
  2322. File Transfer Protocol
  2323.  
  2324.  
  2325.          150 File status okay; about to open data connection.
  2326.          250 Requested file action okay, completed.
  2327.          257 "PATHNAME" created.
  2328.          350 Requested file action pending further information.
  2329.          450 Requested file action not taken.
  2330.              File unavailable (e.g., file busy).
  2331.          550 Requested action not taken.
  2332.              File unavailable (e.g., file not found, no access).
  2333.          451 Requested action aborted. Local error in processing.
  2334.          551 Requested action aborted. Page type unknown.
  2335.          452 Requested action not taken.
  2336.              Insufficient storage space in system.
  2337.          552 Requested file action aborted.
  2338.              Exceeded storage allocation (for current directory or
  2339.              dataset).
  2340.          553 Requested action not taken.
  2341.              File name not allowed.
  2342.          
  2343.  
  2344.       4.2.2 Numeric  Order List of Reply Codes
  2345.  
  2346.          110 Restart marker reply.
  2347.              In this case, the text is exact and not left to the
  2348.              particular implementation; it must read:
  2349.                   MARK yyyy = mmmm
  2350.              Where yyyy is User-process data stream marker, and mmmm
  2351.              server's equivalent marker (note the spaces between markers
  2352.              and "=").
  2353.          120 Service ready in nnn minutes.
  2354.          125 Data connection already open; transfer starting.
  2355.          150 File status okay; about to open data connection.
  2356.           
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374. Postel & Reynolds                                              [Page 41]
  2375.  
  2376.  
  2377.  
  2378.                                                                         
  2379. RFC 959                                                     October 1985
  2380. File Transfer Protocol
  2381.  
  2382.  
  2383.          200 Command okay.
  2384.          202 Command not implemented, superfluous at this site.
  2385.          211 System status, or system help reply.
  2386.          212 Directory status.
  2387.          213 File status.
  2388.          214 Help message.
  2389.              On how to use the server or the meaning of a particular
  2390.              non-standard command.  This reply is useful only to the
  2391.              human user.
  2392.          215 NAME system type.
  2393.              Where NAME is an official system name from the list in the
  2394.              Assigned Numbers document.
  2395.          220 Service ready for new user.
  2396.          221 Service closing control connection.
  2397.              Logged out if appropriate.
  2398.          225 Data connection open; no transfer in progress.
  2399.          226 Closing data connection.
  2400.              Requested file action successful (for example, file
  2401.              transfer or file abort).
  2402.          227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
  2403.          230 User logged in, proceed.
  2404.          250 Requested file action okay, completed.
  2405.          257 "PATHNAME" created.
  2406.           
  2407.          331 User name okay, need password.
  2408.          332 Need account for login.
  2409.          350 Requested file action pending further information.
  2410.           
  2411.          421 Service not available, closing control connection.
  2412.              This may be a reply to any command if the service knows it
  2413.              must shut down.
  2414.          425 Can't open data connection.
  2415.          426 Connection closed; transfer aborted.
  2416.          450 Requested file action not taken.
  2417.              File unavailable (e.g., file busy).
  2418.          451 Requested action aborted: local error in processing.
  2419.          452 Requested action not taken.
  2420.              Insufficient storage space in system.
  2421.           
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432. Postel & Reynolds                                              [Page 42]
  2433.  
  2434.  
  2435.  
  2436.                                                                         
  2437. RFC 959                                                     October 1985
  2438. File Transfer Protocol
  2439.  
  2440.  
  2441.          500 Syntax error, command unrecognized.
  2442.              This may include errors such as command line too long.
  2443.          501 Syntax error in parameters or arguments.
  2444.          502 Command not implemented.
  2445.          503 Bad sequence of commands.
  2446.          504 Command not implemented for that parameter.
  2447.          530 Not logged in.
  2448.          532 Need account for storing files.
  2449.          550 Requested action not taken.
  2450.              File unavailable (e.g., file not found, no access).
  2451.          551 Requested action aborted: page type unknown.
  2452.          552 Requested file action aborted.
  2453.              Exceeded storage allocation (for current directory or
  2454.              dataset).
  2455.          553 Requested action not taken.
  2456.              File name not allowed.
  2457.          
  2458.  
  2459. 5.  DECLARATIVE SPECIFICATIONS
  2460.  
  2461.    5.1.  MINIMUM IMPLEMENTATION
  2462.  
  2463.       In order to make FTP workable without needless error messages, the
  2464.       following minimum implementation is required for all servers:
  2465.  
  2466.          TYPE - ASCII Non-print
  2467.          MODE - Stream
  2468.          STRUCTURE - File, Record
  2469.          COMMANDS - USER, QUIT, PORT,
  2470.                     TYPE, MODE, STRU,
  2471.                       for the default values
  2472.                     RETR, STOR,
  2473.                     NOOP.
  2474.  
  2475.       The default values for transfer parameters are:
  2476.  
  2477.          TYPE - ASCII Non-print
  2478.          MODE - Stream
  2479.          STRU - File
  2480.  
  2481.       All hosts must accept the above as the standard defaults.
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490. Postel & Reynolds                                              [Page 43]
  2491.  
  2492.  
  2493.  
  2494.                                                                         
  2495. RFC 959                                                     October 1985
  2496. File Transfer Protocol
  2497.  
  2498.  
  2499.    5.2.  CONNECTIONS
  2500.  
  2501.       The server protocol interpreter shall "listen" on Port L.  The
  2502.       user or user protocol interpreter shall initiate the full-duplex
  2503.       control connection.  Server- and user- processes should follow the
  2504.       conventions of the Telnet protocol as specified in the
  2505.       ARPA-Internet Protocol Handbook [1].  Servers are under no
  2506.       obligation to provide for editing of command lines and may require
  2507.       that it be done in the user host.  The control connection shall be
  2508.       closed by the server at the user's request after all transfers and
  2509.       replies are completed.
  2510.  
  2511.       The user-DTP must "listen" on the specified data port; this may be
  2512.       the default user port (U) or a port specified in the PORT command.
  2513.       The server shall initiate the data connection from his own default
  2514.       data port (L-1) using the specified user data port.  The direction
  2515.       of the transfer and the port used will be determined by the FTP
  2516.       service command.
  2517.  
  2518.       Note that all FTP implementation must support data transfer using
  2519.       the default port, and that only the USER-PI may initiate the use
  2520.       of non-default ports.
  2521.  
  2522.       When data is to be transferred between two servers, A and B (refer
  2523.       to Figure 2), the user-PI, C, sets up control connections with
  2524.       both server-PI's.  One of the servers, say A, is then sent a PASV
  2525.       command telling him to "listen" on his data port rather than
  2526.       initiate a connection when he receives a transfer service command.
  2527.       When the user-PI receives an acknowledgment to the PASV command,
  2528.       which includes the identity of the host and port being listened
  2529.       on, the user-PI then sends A's port, a, to B in a PORT command; a
  2530.       reply is returned.  The user-PI may then send the corresponding
  2531.       service commands to A and B.  Server B initiates the connection
  2532.       and the transfer proceeds.  The command-reply sequence is listed
  2533.       below where the messages are vertically synchronous but
  2534.       horizontally asynchronous:
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548. Postel & Reynolds                                              [Page 44]
  2549.  
  2550.  
  2551.  
  2552.                                                                         
  2553. RFC 959                                                     October 1985
  2554. File Transfer Protocol
  2555.  
  2556.  
  2557.          User-PI - Server A                User-PI - Server B
  2558.          ------------------                ------------------
  2559.          
  2560.          C->A : Connect                    C->B : Connect
  2561.          C->A : PASV
  2562.          A->C : 227 Entering Passive Mode. A1,A2,A3,A4,a1,a2
  2563.                                            C->B : PORT A1,A2,A3,A4,a1,a2
  2564.                                            B->C : 200 Okay
  2565.          C->A : STOR                       C->B : RETR
  2566.                     B->A : Connect to HOST-A, PORT-a
  2567.  
  2568.                                 Figure 3
  2569.  
  2570.       The data connection shall be closed by the server under the
  2571.       conditions described in the Section on Establishing Data
  2572.       Connections.  If the data connection is to be closed following a
  2573.       data transfer where closing the connection is not required to
  2574.       indicate the end-of-file, the server must do so immediately.
  2575.       Waiting until after a new transfer command is not permitted
  2576.       because the user-process will have already tested the data
  2577.       connection to see if it needs to do a "listen"; (remember that the
  2578.       user must "listen" on a closed data port BEFORE sending the
  2579.       transfer request).  To prevent a race condition here, the server
  2580.       sends a reply (226) after closing the data connection (or if the
  2581.       connection is left open, a "file transfer completed" reply (250)
  2582.       and the user-PI should wait for one of these replies before
  2583.       issuing a new transfer command).
  2584.  
  2585.       Any time either the user or server see that the connection is
  2586.       being closed by the other side, it should promptly read any
  2587.       remaining data queued on the connection and issue the close on its
  2588.       own side.
  2589.  
  2590.    5.3.  COMMANDS
  2591.  
  2592.       The commands are Telnet character strings transmitted over the
  2593.       control connections as described in the Section on FTP Commands.
  2594.       The command functions and semantics are described in the Section
  2595.       on Access Control Commands, Transfer Parameter Commands, FTP
  2596.       Service Commands, and Miscellaneous Commands.  The command syntax
  2597.       is specified here.
  2598.  
  2599.       The commands begin with a command code followed by an argument
  2600.       field.  The command codes are four or fewer alphabetic characters.
  2601.       Upper and lower case alphabetic characters are to be treated
  2602.       identically.  Thus, any of the following may represent the
  2603.       retrieve command:
  2604.  
  2605.  
  2606. Postel & Reynolds                                              [Page 45]
  2607.  
  2608.  
  2609.  
  2610.                                                                         
  2611. RFC 959                                                     October 1985
  2612. File Transfer Protocol
  2613.  
  2614.  
  2615.                   RETR    Retr    retr    ReTr    rETr
  2616.  
  2617.       This also applies to any symbols representing parameter values,
  2618.       such as A or a for ASCII TYPE.  The command codes and the argument
  2619.       fields are separated by one or more spaces.
  2620.  
  2621.       The argument field consists of a variable length character string
  2622.       ending with the character sequence <CRLF> (Carriage Return, Line
  2623.       Feed) for NVT-ASCII representation; for other negotiated languages
  2624.       a different end of line character might be used.  It should be
  2625.       noted that the server is to take no action until the end of line
  2626.       code is received.
  2627.  
  2628.       The syntax is specified below in NVT-ASCII.  All characters in the
  2629.       argument field are ASCII characters including any ASCII
  2630.       represented decimal integers.  Square brackets denote an optional
  2631.       argument field.  If the option is not taken, the appropriate
  2632.       default is implied.
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664. Postel & Reynolds                                              [Page 46]
  2665.  
  2666.  
  2667.  
  2668.                                                                         
  2669. RFC 959                                                     October 1985
  2670. File Transfer Protocol
  2671.  
  2672.  
  2673.       5.3.1.  FTP COMMANDS
  2674.  
  2675.          The following are the FTP commands:
  2676.  
  2677.             USER <SP> <username> <CRLF>
  2678.             PASS <SP> <password> <CRLF>
  2679.             ACCT <SP> <account-information> <CRLF>
  2680.             CWD  <SP> <pathname> <CRLF>
  2681.             CDUP <CRLF>
  2682.             SMNT <SP> <pathname> <CRLF>
  2683.             QUIT <CRLF>
  2684.             REIN <CRLF>
  2685.             PORT <SP> <host-port> <CRLF>
  2686.             PASV <CRLF>
  2687.             TYPE <SP> <type-code> <CRLF>
  2688.             STRU <SP> <structure-code> <CRLF>
  2689.             MODE <SP> <mode-code> <CRLF>
  2690.             RETR <SP> <pathname> <CRLF>
  2691.             STOR <SP> <pathname> <CRLF>
  2692.             STOU <CRLF>
  2693.             APPE <SP> <pathname> <CRLF>
  2694.             ALLO <SP> <decimal-integer>
  2695.                 [<SP> R <SP> <decimal-integer>] <CRLF>
  2696.             REST <SP> <marker> <CRLF>
  2697.             RNFR <SP> <pathname> <CRLF>
  2698.             RNTO <SP> <pathname> <CRLF>
  2699.             ABOR <CRLF>
  2700.             DELE <SP> <pathname> <CRLF>
  2701.             RMD  <SP> <pathname> <CRLF>
  2702.             MKD  <SP> <pathname> <CRLF>
  2703.             PWD  <CRLF>
  2704.             LIST [<SP> <pathname>] <CRLF>
  2705.             NLST [<SP> <pathname>] <CRLF>
  2706.             SITE <SP> <string> <CRLF>
  2707.             SYST <CRLF>
  2708.             STAT [<SP> <pathname>] <CRLF>
  2709.             HELP [<SP> <string>] <CRLF>
  2710.             NOOP <CRLF>
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722. Postel & Reynolds                                              [Page 47]
  2723.  
  2724.  
  2725.  
  2726.                                                                         
  2727. RFC 959                                                     October 1985
  2728. File Transfer Protocol
  2729.  
  2730.  
  2731.       5.3.2.  FTP COMMAND ARGUMENTS
  2732.  
  2733.          The syntax of the above argument fields (using BNF notation
  2734.          where applicable) is:
  2735.  
  2736.             <username> ::= <string>
  2737.             <password> ::= <string>
  2738.             <account-information> ::= <string>
  2739.             <string> ::= <char> | <char><string>
  2740.             <char> ::= any of the 128 ASCII characters except <CR> and
  2741.             <LF>
  2742.             <marker> ::= <pr-string>
  2743.             <pr-string> ::= <pr-char> | <pr-char><pr-string>
  2744.             <pr-char> ::= printable characters, any
  2745.                           ASCII code 33 through 126
  2746.             <byte-size> ::= <number>
  2747.             <host-port> ::= <host-number>,<port-number>
  2748.             <host-number> ::= <number>,<number>,<number>,<number>
  2749.             <port-number> ::= <number>,<number>
  2750.             <number> ::= any decimal integer 1 through 255
  2751.             <form-code> ::= N | T | C
  2752.             <type-code> ::= A [<sp> <form-code>]
  2753.                           | E [<sp> <form-code>]
  2754.                           | I
  2755.                           | L <sp> <byte-size>
  2756.             <structure-code> ::= F | R | P
  2757.             <mode-code> ::= S | B | C
  2758.             <pathname> ::= <string>
  2759.             <decimal-integer> ::= any decimal integer
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780. Postel & Reynolds                                              [Page 48]
  2781.  
  2782.  
  2783.  
  2784.                                                                         
  2785. RFC 959                                                     October 1985
  2786. File Transfer Protocol
  2787.  
  2788.  
  2789.    5.4.  SEQUENCING OF COMMANDS AND REPLIES
  2790.  
  2791.       The communication between the user and server is intended to be an
  2792.       alternating dialogue.  As such, the user issues an FTP command and
  2793.       the server responds with a prompt primary reply.  The user should
  2794.       wait for this initial primary success or failure response before
  2795.       sending further commands.
  2796.  
  2797.       Certain commands require a second reply for which the user should
  2798.       also wait.  These replies may, for example, report on the progress
  2799.       or completion of file transfer or the closing of the data
  2800.       connection.  They are secondary replies to file transfer commands.
  2801.  
  2802.       One important group of informational replies is the connection
  2803.       greetings.  Under normal circumstances, a server will send a 220
  2804.       reply, "awaiting input", when the connection is completed.  The
  2805.       user should wait for this greeting message before sending any
  2806.       commands.  If the server is unable to accept input right away, a
  2807.       120 "expected delay" reply should be sent immediately and a 220
  2808.       reply when ready.  The user will then know not to hang up if there
  2809.       is a delay.
  2810.  
  2811.       Spontaneous Replies
  2812.  
  2813.          Sometimes "the system" spontaneously has a message to be sent
  2814.          to a user (usually all users).  For example, "System going down
  2815.          in 15 minutes".  There is no provision in FTP for such
  2816.          spontaneous information to be sent from the server to the user.
  2817.          It is recommended that such information be queued in the
  2818.          server-PI and delivered to the user-PI in the next reply
  2819.          (possibly making it a multi-line reply).
  2820.  
  2821.       The table below lists alternative success and failure replies for
  2822.       each command.  These must be strictly adhered to; a server may
  2823.       substitute text in the replies, but the meaning and action implied
  2824.       by the code numbers and by the specific command reply sequence
  2825.       cannot be altered.
  2826.  
  2827.       Command-Reply Sequences
  2828.  
  2829.          In this section, the command-reply sequence is presented.  Each
  2830.          command is listed with its possible replies; command groups are
  2831.          listed together.  Preliminary replies are listed first (with
  2832.          their succeeding replies indented and under them), then
  2833.          positive and negative completion, and finally intermediary
  2834.  
  2835.  
  2836.  
  2837.  
  2838. Postel & Reynolds                                              [Page 49]
  2839.  
  2840.  
  2841.  
  2842.                                                                         
  2843. RFC 959                                                     October 1985
  2844. File Transfer Protocol
  2845.  
  2846.  
  2847.          replies with the remaining commands from the sequence
  2848.          following.  This listing forms the basis for the state
  2849.          diagrams, which will be presented separately.
  2850.  
  2851.             Connection Establishment
  2852.                120
  2853.                   220
  2854.                220
  2855.                421
  2856.             Login
  2857.                USER
  2858.                   230
  2859.                   530
  2860.                   500, 501, 421
  2861.                   331, 332
  2862.                PASS
  2863.                   230
  2864.                   202
  2865.                   530
  2866.                   500, 501, 503, 421
  2867.                   332
  2868.                ACCT
  2869.                   230
  2870.                   202
  2871.                   530
  2872.                   500, 501, 503, 421
  2873.                CWD
  2874.                   250
  2875.                   500, 501, 502, 421, 530, 550
  2876.                CDUP
  2877.                   200
  2878.                   500, 501, 502, 421, 530, 550
  2879.                SMNT
  2880.                   202, 250
  2881.                   500, 501, 502, 421, 530, 550
  2882.             Logout
  2883.                REIN
  2884.                   120
  2885.                      220
  2886.                   220
  2887.                   421
  2888.                   500, 502
  2889.                QUIT
  2890.                   221
  2891.                   500
  2892.  
  2893.  
  2894.  
  2895.  
  2896. Postel & Reynolds                                              [Page 50]
  2897.  
  2898.  
  2899.  
  2900.                                                                         
  2901. RFC 959                                                     October 1985
  2902. File Transfer Protocol
  2903.  
  2904.  
  2905.             Transfer parameters
  2906.                PORT
  2907.                   200
  2908.                   500, 501, 421, 530
  2909.                PASV
  2910.                   227
  2911.                   500, 501, 502, 421, 530
  2912.                MODE
  2913.                   200
  2914.                   500, 501, 504, 421, 530
  2915.                TYPE
  2916.                   200
  2917.                   500, 501, 504, 421, 530
  2918.                STRU
  2919.                   200
  2920.                   500, 501, 504, 421, 530
  2921.             File action commands
  2922.                ALLO
  2923.                   200
  2924.                   202
  2925.                   500, 501, 504, 421, 530
  2926.                REST
  2927.                   500, 501, 502, 421, 530
  2928.                   350
  2929.                STOR
  2930.                   125, 150
  2931.                      (110)
  2932.                      226, 250
  2933.                      425, 426, 451, 551, 552
  2934.                   532, 450, 452, 553
  2935.                   500, 501, 421, 530
  2936.                STOU
  2937.                   125, 150
  2938.                      (110)
  2939.                      226, 250
  2940.                      425, 426, 451, 551, 552
  2941.                   532, 450, 452, 553
  2942.                   500, 501, 421, 530
  2943.                RETR
  2944.                   125, 150
  2945.                      (110)
  2946.                      226, 250
  2947.                      425, 426, 451
  2948.                   450, 550
  2949.                   500, 501, 421, 530
  2950.  
  2951.  
  2952.  
  2953.  
  2954. Postel & Reynolds                                              [Page 51]
  2955.  
  2956.  
  2957.  
  2958.                                                                         
  2959. RFC 959                                                     October 1985
  2960. File Transfer Protocol
  2961.  
  2962.  
  2963.                LIST
  2964.                   125, 150
  2965.                      226, 250
  2966.                      425, 426, 451
  2967.                   450
  2968.                   500, 501, 502, 421, 530
  2969.                NLST
  2970.                   125, 150
  2971.                      226, 250
  2972.                      425, 426, 451
  2973.                   450
  2974.                   500, 501, 502, 421, 530
  2975.                APPE
  2976.                   125, 150
  2977.                      (110)
  2978.                      226, 250
  2979.                      425, 426, 451, 551, 552
  2980.                   532, 450, 550, 452, 553
  2981.                   500, 501, 502, 421, 530
  2982.                RNFR
  2983.                   450, 550
  2984.                   500, 501, 502, 421, 530
  2985.                   350
  2986.                RNTO
  2987.                   250
  2988.                   532, 553
  2989.                   500, 501, 502, 503, 421, 530
  2990.                DELE
  2991.                   250
  2992.                   450, 550
  2993.                   500, 501, 502, 421, 530
  2994.                RMD
  2995.                   250
  2996.                   500, 501, 502, 421, 530, 550
  2997.                MKD
  2998.                   257
  2999.                   500, 501, 502, 421, 530, 550
  3000.                PWD
  3001.                   257
  3002.                   500, 501, 502, 421, 550
  3003.                ABOR
  3004.                   225, 226
  3005.                   500, 501, 502, 421
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012. Postel & Reynolds                                              [Page 52]
  3013.  
  3014.  
  3015.  
  3016.                                                                         
  3017. RFC 959                                                     October 1985
  3018. File Transfer Protocol
  3019.  
  3020.  
  3021.             Informational commands
  3022.                SYST
  3023.                   215
  3024.                   500, 501, 502, 421
  3025.                STAT
  3026.                   211, 212, 213
  3027.                   450
  3028.                   500, 501, 502, 421, 530
  3029.                HELP
  3030.                   211, 214
  3031.                   500, 501, 502, 421
  3032.             Miscellaneous commands
  3033.                SITE
  3034.                   200
  3035.                   202
  3036.                   500, 501, 530
  3037.                NOOP
  3038.                   200
  3039.                   500 421
  3040.  
  3041.  
  3042.  
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070. Postel & Reynolds                                              [Page 53]
  3071.  
  3072.  
  3073.  
  3074.                                                                         
  3075. RFC 959                                                     October 1985
  3076. File Transfer Protocol
  3077.  
  3078.  
  3079. 6.  STATE DIAGRAMS
  3080.  
  3081.    Here we present state diagrams for a very simple minded FTP
  3082.    implementation.  Only the first digit of the reply codes is used.
  3083.    There is one state diagram for each group of FTP commands or command
  3084.    sequences.
  3085.  
  3086.    The command groupings were determined by constructing a model for
  3087.    each command then collecting together the commands with structurally
  3088.    identical models.
  3089.  
  3090.    For each command or command sequence there are three possible
  3091.    outcomes: success (S), failure (F), and error (E).  In the state
  3092.    diagrams below we use the symbol B for "begin", and the symbol W for
  3093.    "wait for reply".
  3094.  
  3095.    We first present the diagram that represents the largest group of FTP
  3096.    commands:
  3097.  
  3098.       
  3099.                                1,3    +---+
  3100.                           ----------->| E |
  3101.                          |            +---+
  3102.                          |
  3103.       +---+    cmd    +---+    2      +---+
  3104.       | B |---------->| W |---------->| S |
  3105.       +---+           +---+           +---+
  3106.                          |
  3107.                          |     4,5    +---+
  3108.                           ----------->| F |
  3109.                                       +---+
  3110.       
  3111.  
  3112.       This diagram models the commands:
  3113.  
  3114.          ABOR, ALLO, DELE, CWD, CDUP, SMNT, HELP, MODE, NOOP, PASV,
  3115.          QUIT, SITE, PORT, SYST, STAT, RMD, MKD, PWD, STRU, and TYPE.
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128. Postel & Reynolds                                              [Page 54]
  3129.  
  3130.  
  3131.  
  3132.                                                                         
  3133. RFC 959                                                     October 1985
  3134. File Transfer Protocol
  3135.  
  3136.  
  3137.    The other large group of commands is represented by a very similar
  3138.    diagram:
  3139.  
  3140.       
  3141.                                3      +---+
  3142.                           ----------->| E |
  3143.                          |            +---+
  3144.                          |
  3145.       +---+    cmd    +---+    2      +---+
  3146.       | B |---------->| W |---------->| S |
  3147.       +---+       --->+---+           +---+
  3148.                  |     | |
  3149.                  |     | |     4,5    +---+
  3150.                  |  1  |  ----------->| F |
  3151.                   -----               +---+
  3152.       
  3153.  
  3154.       This diagram models the commands:
  3155.  
  3156.          APPE, LIST, NLST, REIN, RETR, STOR, and STOU.
  3157.  
  3158.    Note that this second model could also be used to represent the first
  3159.    group of commands, the only difference being that in the first group
  3160.    the 100 series replies are unexpected and therefore treated as error,
  3161.    while the second group expects (some may require) 100 series replies.
  3162.    Remember that at most, one 100 series reply is allowed per command.
  3163.  
  3164.    The remaining diagrams model command sequences, perhaps the simplest
  3165.    of these is the rename sequence:
  3166.  
  3167.       
  3168.       +---+   RNFR    +---+    1,2    +---+
  3169.       | B |---------->| W |---------->| E |
  3170.       +---+           +---+        -->+---+
  3171.                        | |        |
  3172.                 3      | | 4,5    |
  3173.          --------------  ------   |
  3174.         |                      |  |   +---+
  3175.         |               ------------->| S |
  3176.         |              |   1,3 |  |   +---+
  3177.         |             2|  --------
  3178.         |              | |     |
  3179.         V              | |     |
  3180.       +---+   RNTO    +---+ 4,5 ----->+---+
  3181.       |   |---------->| W |---------->| F |
  3182.       +---+           +---+           +---+
  3183.       
  3184.  
  3185.  
  3186. Postel & Reynolds                                              [Page 55]
  3187.  
  3188.  
  3189.  
  3190.                                                                         
  3191. RFC 959                                                     October 1985
  3192. File Transfer Protocol
  3193.  
  3194.  
  3195.    The next diagram is a simple model of the Restart command:
  3196.  
  3197.       
  3198.       +---+   REST    +---+    1,2    +---+
  3199.       | B |---------->| W |---------->| E |
  3200.       +---+           +---+        -->+---+
  3201.                        | |        |
  3202.                 3      | | 4,5    |
  3203.          --------------  ------   |
  3204.         |                      |  |   +---+
  3205.         |               ------------->| S |
  3206.         |              |   3   |  |   +---+
  3207.         |             2|  --------
  3208.         |              | |     |
  3209.         V              | |     |
  3210.       +---+   cmd     +---+ 4,5 ----->+---+
  3211.       |   |---------->| W |---------->| F |
  3212.       +---+        -->+---+           +---+
  3213.                   |      |
  3214.                   |  1   |
  3215.                    ------
  3216.       
  3217.  
  3218.          Where "cmd" is APPE, STOR, or RETR.
  3219.  
  3220.    We note that the above three models are similar.  The Restart differs
  3221.    from the Rename two only in the treatment of 100 series replies at
  3222.    the second stage, while the second group expects (some may require)
  3223.    100 series replies.  Remember that at most, one 100 series reply is
  3224.    allowed per command.
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244. Postel & Reynolds                                              [Page 56]
  3245.  
  3246.  
  3247.  
  3248.                                                                         
  3249. RFC 959                                                     October 1985
  3250. File Transfer Protocol
  3251.  
  3252.  
  3253.    The most complicated diagram is for the Login sequence:
  3254.  
  3255.       
  3256.                             1
  3257.       +---+   USER    +---+------------->+---+
  3258.       | B |---------->| W | 2       ---->| E |
  3259.       +---+           +---+------  |  -->+---+
  3260.                        | |       | | |
  3261.                      3 | | 4,5   | | |
  3262.          --------------   -----  | | |
  3263.         |                      | | | |
  3264.         |                      | | | |
  3265.         |                 ---------  |
  3266.         |               1|     | |   |
  3267.         V                |     | |   |
  3268.       +---+   PASS    +---+ 2  |  ------>+---+
  3269.       |   |---------->| W |------------->| S |
  3270.       +---+           +---+   ---------->+---+
  3271.                        | |   | |     |
  3272.                      3 | |4,5| |     |
  3273.          --------------   --------   |
  3274.         |                    | |  |  |
  3275.         |                    | |  |  |
  3276.         |                 -----------
  3277.         |             1,3|   | |  |
  3278.         V                |  2| |  |
  3279.       +---+   ACCT    +---+--  |   ----->+---+
  3280.       |   |---------->| W | 4,5 -------->| F |
  3281.       +---+           +---+------------->+---+
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302. Postel & Reynolds                                              [Page 57]
  3303.  
  3304.  
  3305.  
  3306.                                                                         
  3307. RFC 959                                                     October 1985
  3308. File Transfer Protocol
  3309.  
  3310.  
  3311.    Finally, we present a generalized diagram that could be used to model
  3312.    the command and reply interchange:
  3313.  
  3314.       
  3315.                ------------------------------------
  3316.               |                                    |
  3317.       Begin   |                                    |
  3318.         |     V                                    |
  3319.         |   +---+  cmd   +---+ 2         +---+     |
  3320.          -->|   |------->|   |---------->|   |     |
  3321.             |   |        | W |           | S |-----|
  3322.          -->|   |     -->|   |-----      |   |     |
  3323.         |   +---+    |   +---+ 4,5 |     +---+     |
  3324.         |     |      |    | |      |               |
  3325.         |     |      |   1| |3     |     +---+     |
  3326.         |     |      |    | |      |     |   |     |
  3327.         |     |       ----  |       ---->| F |-----
  3328.         |     |             |            |   |
  3329.         |     |             |            +---+
  3330.          -------------------
  3331.               |
  3332.               |
  3333.               V
  3334.              End
  3335.       
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360. Postel & Reynolds                                              [Page 58]
  3361.  
  3362.  
  3363.  
  3364.                                                                         
  3365. RFC 959                                                     October 1985
  3366. File Transfer Protocol
  3367.  
  3368.  
  3369. 7.  TYPICAL FTP SCENARIO
  3370.  
  3371.    User at host U wanting to transfer files to/from host S:
  3372.  
  3373.    In general, the user will communicate to the server via a mediating
  3374.    user-FTP process.  The following may be a typical scenario.  The
  3375.    user-FTP prompts are shown in parentheses, '---->' represents
  3376.    commands from host U to host S, and '<----' represents replies from
  3377.    host S to host U.
  3378.  
  3379.       LOCAL COMMANDS BY USER              ACTION INVOLVED
  3380.  
  3381.       ftp (host) multics<CR>         Connect to host S, port L,
  3382.                                      establishing control connections.
  3383.                                      <---- 220 Service ready <CRLF>.
  3384.       username Doe <CR>              USER Doe<CRLF>---->
  3385.                                      <---- 331 User name ok,
  3386.                                                need password<CRLF>.
  3387.       password mumble <CR>           PASS mumble<CRLF>---->
  3388.                                      <---- 230 User logged in<CRLF>.
  3389.       retrieve (local type) ASCII<CR>
  3390.       (local pathname) test 1 <CR>   User-FTP opens local file in ASCII.
  3391.       (for. pathname) test.pl1<CR>   RETR test.pl1<CRLF> ---->
  3392.                                      <---- 150 File status okay;
  3393.                                            about to open data
  3394.                                            connection<CRLF>.
  3395.                                      Server makes data connection
  3396.                                      to port U.
  3397.       
  3398.                                      <---- 226 Closing data connection,
  3399.                                          file transfer successful<CRLF>.
  3400.       type Image<CR>                 TYPE I<CRLF> ---->
  3401.                                      <---- 200 Command OK<CRLF>
  3402.       store (local type) image<CR>
  3403.       (local pathname) file dump<CR> User-FTP opens local file in Image.
  3404.       (for.pathname) >udd>cn>fd<CR>  STOR >udd>cn>fd<CRLF> ---->
  3405.                                      <---- 550 Access denied<CRLF>
  3406.       terminate                      QUIT <CRLF> ---->
  3407.                                      Server closes all
  3408.                                      connections.
  3409.  
  3410. 8.  CONNECTION ESTABLISHMENT
  3411.  
  3412.    The FTP control connection is established via TCP between the user
  3413.    process port U and the server process port L.  This protocol is
  3414.    assigned the service port 21 (25 octal), that is L=21.
  3415.  
  3416.  
  3417.  
  3418. Postel & Reynolds                                              [Page 59]
  3419.  
  3420.  
  3421.  
  3422.                                                                         
  3423. RFC 959                                                     October 1985
  3424. File Transfer Protocol
  3425.  
  3426.  
  3427. APPENDIX I -  PAGE STRUCTURE
  3428.  
  3429.    The need for FTP to support page structure derives principally from
  3430.    the  need to support efficient transmission of files between TOPS-20
  3431.    systems, particularly the files used by NLS.
  3432.  
  3433.    The file system of TOPS-20 is based on the concept of pages.  The
  3434.    operating system is most efficient at manipulating files as pages.
  3435.    The operating system provides an interface to the file system so that
  3436.    many applications view files as sequential streams of characters.
  3437.    However, a few applications use the underlying page structures
  3438.    directly, and some of these create holey files.
  3439.  
  3440.    A TOPS-20 disk file consists of four things: a pathname, a page
  3441.    table, a (possibly empty) set of pages, and a set of attributes.
  3442.  
  3443.    The pathname is specified in the RETR or STOR command.  It includes
  3444.    the directory name, file name, file name extension, and generation
  3445.    number.
  3446.  
  3447.    The page table contains up to 2**18 entries.  Each entry may be
  3448.    EMPTY, or may point to a page.  If it is not empty, there are also
  3449.    some page-specific access bits; not all pages of a file need have the
  3450.    same access protection.
  3451.  
  3452.       A page is a contiguous set of 512 words of 36 bits each.
  3453.  
  3454.    The attributes of the file, in the File Descriptor Block (FDB),
  3455.    contain such things as creation time, write time, read time, writer's
  3456.    byte-size, end-of-file pointer, count of reads and writes, backup
  3457.    system tape numbers, etc.
  3458.  
  3459.    Note that there is NO requirement that entries in the page table be
  3460.    contiguous.  There may be empty page table slots between occupied
  3461.    ones.  Also, the end of file pointer is simply a number.  There is no
  3462.    requirement that it in fact point at the "last" datum in the file.
  3463.    Ordinary sequential I/O calls in TOPS-20 will cause the end of file
  3464.    pointer to be left after the last datum written, but other operations
  3465.    may cause it not to be so, if a particular programming system so
  3466.    requires.
  3467.  
  3468.    In fact, in both of these special cases, "holey" files and
  3469.    end-of-file pointers NOT at the end of the file, occur with NLS data
  3470.    files.
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476. Postel & Reynolds                                              [Page 60]
  3477.  
  3478.  
  3479.  
  3480.                                                                         
  3481. RFC 959                                                     October 1985
  3482. File Transfer Protocol
  3483.  
  3484.  
  3485.    The TOPS-20 paged files can be sent with the FTP transfer parameters:
  3486.    TYPE L 36, STRU P, and MODE S (in fact, any mode could be used).
  3487.  
  3488.    Each page of information has a header.  Each header field, which is a
  3489.    logical byte, is a TOPS-20 word, since the TYPE is L 36.
  3490.  
  3491.    The header fields are:
  3492.  
  3493.       Word 0: Header Length.
  3494.  
  3495.          The header length is 5.
  3496.  
  3497.       Word 1: Page Index.
  3498.  
  3499.          If the data is a disk file page, this is the number of that
  3500.          page in the file's page map.  Empty pages (holes) in the file
  3501.          are simply not sent.  Note that a hole is NOT the same as a
  3502.          page of zeros.
  3503.  
  3504.       Word 2: Data Length.
  3505.  
  3506.          The number of data words in this page, following the header.
  3507.          Thus, the total length of the transmission unit is the Header
  3508.          Length plus the Data Length.
  3509.  
  3510.       Word 3: Page Type.
  3511.  
  3512.          A code for what type of chunk this is.  A data page is type 3,
  3513.          the FDB page is type 2.
  3514.  
  3515.       Word 4: Page Access Control.
  3516.  
  3517.          The access bits associated with the page in the file's page
  3518.          map.  (This full word quantity is put into AC2 of an SPACS by
  3519.          the program reading from net to disk.)
  3520.  
  3521.    After the header are Data Length data words.  Data Length is
  3522.    currently either 512 for a data page or 31 for an FDB.  Trailing
  3523.    zeros in a disk file page may be discarded, making Data Length less
  3524.    than 512 in that case.
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534. Postel & Reynolds                                              [Page 61]
  3535.  
  3536.  
  3537.  
  3538.                                                                         
  3539. RFC 959                                                     October 1985
  3540. File Transfer Protocol
  3541.  
  3542.  
  3543. APPENDIX II -  DIRECTORY COMMANDS
  3544.  
  3545.    Since UNIX has a tree-like directory structure in which directories
  3546.    are as easy to manipulate as ordinary files, it is useful to expand
  3547.    the FTP servers on these machines to include commands which deal with
  3548.    the creation of directories.  Since there are other hosts on the
  3549.    ARPA-Internet which have tree-like directories (including TOPS-20 and
  3550.    Multics), these commands are as general as possible.
  3551.  
  3552.       Four directory commands have been added to FTP:
  3553.  
  3554.          MKD pathname
  3555.  
  3556.             Make a directory with the name "pathname".
  3557.  
  3558.          RMD pathname
  3559.  
  3560.             Remove the directory with the name "pathname".
  3561.  
  3562.          PWD
  3563.  
  3564.             Print the current working directory name.
  3565.  
  3566.          CDUP
  3567.  
  3568.             Change to the parent of the current working directory.
  3569.  
  3570.    The  "pathname"  argument should be created (removed) as a
  3571.    subdirectory of the current working directory, unless the "pathname"
  3572.    string contains sufficient information to specify otherwise to the
  3573.    server, e.g., "pathname" is an absolute pathname (in UNIX and
  3574.    Multics), or pathname is something like "<abso.lute.path>" to
  3575.    TOPS-20.
  3576.  
  3577.    REPLY CODES
  3578.  
  3579.       The CDUP command is a special case of CWD, and is included to
  3580.       simplify the implementation of programs for transferring directory
  3581.       trees between operating systems having different syntaxes for
  3582.       naming the parent directory.  The reply codes for CDUP be
  3583.       identical to the reply codes of CWD.
  3584.  
  3585.       The reply codes for RMD be identical to the reply codes for its
  3586.       file analogue, DELE.
  3587.  
  3588.       The reply codes for MKD, however, are a bit more complicated.  A
  3589.       freshly created directory will probably be the object of a future
  3590.  
  3591.  
  3592. Postel & Reynolds                                              [Page 62]
  3593.  
  3594.  
  3595.  
  3596.                                                                         
  3597. RFC 959                                                     October 1985
  3598. File Transfer Protocol
  3599.  
  3600.  
  3601.       CWD command.  Unfortunately, the argument to MKD may not always be
  3602.       a suitable argument for CWD.  This is the case, for example, when
  3603.       a TOPS-20 subdirectory is created by giving just the subdirectory
  3604.       name.  That is, with a TOPS-20 server FTP, the command sequence
  3605.  
  3606.          MKD MYDIR
  3607.          CWD MYDIR
  3608.  
  3609.       will fail.  The new directory may only be referred to by its
  3610.       "absolute" name; e.g., if the MKD command above were issued while
  3611.       connected to the directory <DFRANKLIN>, the new subdirectory
  3612.       could only be referred to by the name <DFRANKLIN.MYDIR>.
  3613.  
  3614.       Even on UNIX and Multics, however, the argument given to MKD may
  3615.       not be suitable.  If it is a "relative" pathname (i.e., a pathname
  3616.       which is interpreted relative to the current directory), the user
  3617.       would need to be in the same current directory in order to reach
  3618.       the subdirectory.  Depending on the application, this may be
  3619.       inconvenient.  It is not very robust in any case.
  3620.  
  3621.       To solve these problems, upon successful completion of an MKD
  3622.       command, the server should return a line of the form:
  3623.  
  3624.          257<space>"<directory-name>"<space><commentary>
  3625.  
  3626.       That is, the server will tell the user what string to use when
  3627.       referring to the created  directory.  The directory name can
  3628.       contain any character; embedded double-quotes should be escaped by
  3629.       double-quotes (the "quote-doubling" convention).
  3630.  
  3631.       For example, a user connects to the directory /usr/dm, and creates
  3632.       a subdirectory, named pathname:
  3633.  
  3634.          CWD /usr/dm
  3635.          200 directory changed to /usr/dm
  3636.          MKD pathname
  3637.          257 "/usr/dm/pathname" directory created
  3638.  
  3639.       An example with an embedded double quote:
  3640.  
  3641.          MKD foo"bar
  3642.          257 "/usr/dm/foo""bar" directory created
  3643.          CWD /usr/dm/foo"bar
  3644.          200 directory changed to /usr/dm/foo"bar
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650. Postel & Reynolds                                              [Page 63]
  3651.  
  3652.  
  3653.  
  3654.                                                                         
  3655. RFC 959                                                     October 1985
  3656. File Transfer Protocol
  3657.  
  3658.  
  3659.       The prior existence of a subdirectory with the same name is an
  3660.       error, and the server must return an "access denied" error reply
  3661.       in that case.
  3662.  
  3663.          CWD /usr/dm
  3664.          200 directory changed to /usr/dm
  3665.          MKD pathname
  3666.          521-"/usr/dm/pathname" directory already exists;
  3667.          521 taking no action.
  3668.  
  3669.       The failure replies for MKD are analogous to its file  creating
  3670.       cousin, STOR.  Also, an "access denied" return is given if a file
  3671.       name with the same name as the subdirectory will conflict with the
  3672.       creation of the subdirectory (this is a problem on UNIX, but
  3673.       shouldn't be one on TOPS-20).
  3674.  
  3675.       Essentially because the PWD command returns the same type of
  3676.       information as the successful MKD command, the successful PWD
  3677.       command uses the 257 reply code as well.
  3678.  
  3679.    SUBTLETIES
  3680.  
  3681.       Because these commands will be most useful in transferring
  3682.       subtrees from one machine to another, carefully observe that the
  3683.       argument to MKD is to be interpreted as a sub-directory of  the
  3684.       current working directory, unless it contains enough information
  3685.       for the destination host to tell otherwise.  A hypothetical
  3686.       example of its use in the TOPS-20 world:
  3687.  
  3688.          CWD <some.where>
  3689.          200 Working directory changed
  3690.          MKD overrainbow
  3691.          257 "<some.where.overrainbow>" directory created
  3692.          CWD overrainbow
  3693.          431 No such directory
  3694.          CWD <some.where.overrainbow>
  3695.          200 Working directory changed
  3696.  
  3697.          CWD <some.where>
  3698.          200 Working directory changed to <some.where>
  3699.          MKD <unambiguous>
  3700.          257 "<unambiguous>" directory created
  3701.          CWD <unambiguous>
  3702.  
  3703.       Note that the first example results in a subdirectory of the
  3704.       connected directory.  In contrast, the argument in the second
  3705.       example contains enough information for TOPS-20 to tell that  the
  3706.  
  3707.  
  3708. Postel & Reynolds                                              [Page 64]
  3709.  
  3710.  
  3711.  
  3712.                                                                         
  3713. RFC 959                                                     October 1985
  3714. File Transfer Protocol
  3715.  
  3716.  
  3717.       <unambiguous> directory is a top-level directory.  Note also that
  3718.       in the first example the user "violated" the protocol by
  3719.       attempting to access the freshly created directory with a name
  3720.       other than the one returned by TOPS-20.  Problems could have
  3721.       resulted in this case had there been an <overrainbow> directory;
  3722.       this is an ambiguity inherent in some TOPS-20 implementations.
  3723.       Similar considerations apply to the RMD command.  The point is
  3724.       this: except where to do so would violate a host's conventions for
  3725.       denoting relative versus absolute pathnames, the host should treat
  3726.       the operands of the MKD and RMD commands as subdirectories.  The
  3727.       257 reply to the MKD command must always contain the absolute
  3728.       pathname of the created directory.
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766. Postel & Reynolds                                              [Page 65]
  3767.  
  3768.  
  3769.  
  3770.                                                                         
  3771. RFC 959                                                     October 1985
  3772. File Transfer Protocol
  3773.  
  3774.  
  3775. APPENDIX III - RFCs on FTP
  3776.  
  3777.    Bhushan, Abhay, "A File Transfer Protocol", RFC 114 (NIC 5823),
  3778.    MIT-Project MAC, 16 April 1971.
  3779.  
  3780.    Harslem, Eric, and John Heafner, "Comments on RFC 114 (A File
  3781.    Transfer Protocol)", RFC 141 (NIC 6726), RAND, 29 April 1971.
  3782.  
  3783.    Bhushan, Abhay, et al, "The File Transfer Protocol", RFC 172
  3784.    (NIC 6794), MIT-Project MAC, 23 June 1971.
  3785.  
  3786.    Braden, Bob, "Comments on DTP and FTP Proposals", RFC 238 (NIC 7663),
  3787.    UCLA/CCN, 29 September 1971.
  3788.  
  3789.    Bhushan, Abhay, et al, "The File Transfer Protocol", RFC 265
  3790.    (NIC 7813), MIT-Project MAC, 17 November 1971.
  3791.  
  3792.    McKenzie, Alex, "A Suggested Addition to File Transfer Protocol",
  3793.    RFC 281 (NIC 8163), BBN, 8 December 1971.
  3794.  
  3795.    Bhushan, Abhay, "The Use of "Set Data Type" Transaction in File
  3796.    Transfer Protocol", RFC 294 (NIC 8304), MIT-Project MAC,
  3797.    25 January 1972.
  3798.  
  3799.    Bhushan, Abhay, "The File Transfer Protocol", RFC 354 (NIC 10596),
  3800.    MIT-Project MAC, 8 July 1972.
  3801.  
  3802.    Bhushan, Abhay, "Comments on the File Transfer Protocol (RFC 354)",
  3803.    RFC 385 (NIC 11357), MIT-Project MAC, 18 August 1972.
  3804.  
  3805.    Hicks, Greg, "User FTP Documentation", RFC 412 (NIC 12404), Utah,
  3806.    27 November 1972.
  3807.  
  3808.    Bhushan, Abhay, "File Transfer Protocol (FTP) Status and Further
  3809.    Comments", RFC 414 (NIC 12406), MIT-Project MAC, 20 November 1972.
  3810.  
  3811.    Braden, Bob, "Comments on File Transfer Protocol", RFC 430
  3812.    (NIC 13299), UCLA/CCN, 7 February 1973.
  3813.  
  3814.    Thomas, Bob, and Bob Clements, "FTP Server-Server Interaction",
  3815.    RFC 438 (NIC 13770), BBN, 15 January 1973.
  3816.  
  3817.    Braden, Bob, "Print Files in FTP", RFC 448 (NIC 13299), UCLA/CCN,
  3818.    27 February 1973.
  3819.  
  3820.    McKenzie, Alex, "File Transfer Protocol", RFC 454 (NIC 14333), BBN,
  3821.    16 February 1973.
  3822.  
  3823.  
  3824. Postel & Reynolds                                              [Page 66]
  3825.  
  3826.  
  3827.  
  3828.                                                                         
  3829. RFC 959                                                     October 1985
  3830. File Transfer Protocol
  3831.  
  3832.  
  3833.    Bressler, Bob, and Bob Thomas, "Mail Retrieval via FTP", RFC 458
  3834.    (NIC 14378), BBN-NET and BBN-TENEX, 20 February 1973.
  3835.  
  3836.    Neigus, Nancy, "File Transfer Protocol", RFC 542 (NIC 17759), BBN,
  3837.    12 July 1973.
  3838.  
  3839.    Krilanovich, Mark, and George Gregg, "Comments on the File Transfer
  3840.    Protocol", RFC 607 (NIC 21255), UCSB, 7 January 1974.
  3841.  
  3842.    Pogran, Ken, and Nancy Neigus, "Response to RFC 607 - Comments on the
  3843.    File Transfer Protocol", RFC 614 (NIC 21530), BBN, 28 January 1974.
  3844.  
  3845.    Krilanovich, Mark, George Gregg, Wayne Hathaway, and Jim White,
  3846.    "Comments on the File Transfer Protocol", RFC 624 (NIC 22054), UCSB,
  3847.    Ames Research Center, SRI-ARC, 28 February 1974.
  3848.  
  3849.    Bhushan, Abhay, "FTP Comments and Response to RFC 430", RFC 463
  3850.    (NIC 14573), MIT-DMCG, 21 February 1973.
  3851.  
  3852.    Braden, Bob, "FTP Data Compression", RFC 468 (NIC 14742), UCLA/CCN,
  3853.    8 March 1973.
  3854.  
  3855.    Bhushan, Abhay, "FTP and Network Mail System", RFC 475 (NIC 14919),
  3856.    MIT-DMCG, 6 March 1973.
  3857.  
  3858.    Bressler, Bob, and Bob Thomas "FTP Server-Server Interaction - II",
  3859.    RFC 478 (NIC 14947), BBN-NET and BBN-TENEX, 26 March 1973.
  3860.  
  3861.    White, Jim, "Use of FTP by the NIC Journal", RFC 479 (NIC 14948),
  3862.    SRI-ARC, 8 March 1973.
  3863.  
  3864.    White, Jim, "Host-Dependent FTP Parameters", RFC 480 (NIC 14949),
  3865.    SRI-ARC, 8 March 1973.
  3866.  
  3867.    Padlipsky, Mike, "An FTP Command-Naming Problem", RFC 506
  3868.    (NIC 16157), MIT-Multics, 26 June 1973.
  3869.  
  3870.    Day, John, "Memo to FTP Group (Proposal for File Access Protocol)",
  3871.    RFC 520 (NIC 16819), Illinois, 25 June 1973.
  3872.  
  3873.    Merryman, Robert, "The UCSD-CC Server-FTP Facility", RFC 532
  3874.    (NIC 17451), UCSD-CC, 22 June 1973.
  3875.  
  3876.    Braden, Bob, "TENEX FTP Problem", RFC 571 (NIC 18974), UCLA/CCN,
  3877.    15 November 1973.
  3878.  
  3879.  
  3880.  
  3881.  
  3882. Postel & Reynolds                                              [Page 67]
  3883.  
  3884.  
  3885.  
  3886.                                                                         
  3887. RFC 959                                                     October 1985
  3888. File Transfer Protocol
  3889.  
  3890.  
  3891.    McKenzie, Alex, and Jon Postel, "Telnet and FTP Implementation -
  3892.    Schedule Change", RFC 593 (NIC 20615), BBN and MITRE,
  3893.    29 November 1973.
  3894.  
  3895.    Sussman, Julie, "FTP Error Code Usage for More Reliable Mail
  3896.    Service", RFC 630 (NIC 30237), BBN, 10 April 1974.
  3897.  
  3898.    Postel, Jon, "Revised FTP Reply Codes", RFC 640 (NIC 30843),
  3899.    UCLA/NMC, 5 June 1974.
  3900.  
  3901.    Harvey, Brian, "Leaving Well Enough Alone", RFC 686 (NIC 32481),
  3902.    SU-AI, 10 May 1975.
  3903.  
  3904.    Harvey, Brian, "One More Try on the FTP", RFC 691 (NIC 32700), SU-AI,
  3905.    28 May 1975.
  3906.  
  3907.    Lieb, J., "CWD Command of FTP", RFC 697 (NIC 32963), 14 July 1975.
  3908.  
  3909.    Harrenstien, Ken, "FTP Extension: XSEN", RFC 737 (NIC 42217), SRI-KL,
  3910.    31 October 1977.
  3911.  
  3912.    Harrenstien, Ken, "FTP Extension: XRSQ/XRCP", RFC 743 (NIC 42758),
  3913.    SRI-KL, 30 December 1977.
  3914.  
  3915.    Lebling, P. David, "Survey of FTP Mail and MLFL", RFC 751, MIT,
  3916.    10 December 1978.
  3917.  
  3918.    Postel, Jon, "File Transfer Protocol Specification", RFC 765, ISI,
  3919.    June 1980.
  3920.  
  3921.    Mankins, David, Dan Franklin, and Buzz Owen, "Directory Oriented FTP
  3922.    Commands", RFC 776, BBN, December 1980.
  3923.  
  3924.    Padlipsky, Michael, "FTP Unique-Named Store Command", RFC 949, MITRE,
  3925.    July 1985.
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940. Postel & Reynolds                                              [Page 68]
  3941.  
  3942.  
  3943.  
  3944.                                                                         
  3945. RFC 959                                                     October 1985
  3946. File Transfer Protocol
  3947.  
  3948.  
  3949. REFERENCES
  3950.  
  3951.    [1]  Feinler, Elizabeth, "Internet Protocol Transition Workbook",
  3952.         Network Information Center, SRI International, March 1982.
  3953.  
  3954.    [2]  Postel, Jon, "Transmission Control Protocol - DARPA Internet
  3955.         Program Protocol Specification", RFC 793, DARPA, September 1981.
  3956.  
  3957.    [3]  Postel, Jon, and Joyce Reynolds, "Telnet Protocol
  3958.         Specification", RFC 854, ISI, May 1983.
  3959.  
  3960.    [4]  Reynolds, Joyce, and Jon Postel, "Assigned Numbers", RFC 943,
  3961.         ISI, April 1985.
  3962.  
  3963.  
  3964.  
  3965.  
  3966.  
  3967.  
  3968.  
  3969.  
  3970.  
  3971.  
  3972.  
  3973.  
  3974.  
  3975.  
  3976.  
  3977.  
  3978.  
  3979.  
  3980.  
  3981.  
  3982.  
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988.  
  3989.  
  3990.  
  3991.  
  3992.  
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998. Postel & Reynolds                                              [Page 69]
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.