home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 500s / rfc542.txt < prev    next >
Text File  |  1992-10-14  |  101KB  |  2,301 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.                                                   File Transfer Protocol
  12.                                                          (Aug. 12, 1973)
  13.                                                        RFC 542 NIC 17759
  14.  
  15.  
  16. Nancy J. Neigus                            See Also:  RFCs 354, 454, 495
  17. Bolt Beranek and Newman, Inc.
  18. Cambridge, Mass.
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.               File Transfer Protocol for the ARPA Network
  43.  
  44.                                                   File Transfer Protocol
  45.                                                          (Aug. 12, 1973)
  46.                                                        RFC 542 NIC 17759
  47.  
  48.  
  49.                                 PREFACE
  50.  
  51. This document is the result of several months discussion via RFC
  52. (relevant numbers are 430, 448, 454, 463, 468, 478, 480), followed by a
  53. meeting of the FTP committee at BBN on March 16, followed by further
  54. communication among committee members.  There are a considerable number
  55. of changes for the last "official" version, see RFCs 354, 385, but the
  56. gross structure remains the same.  The places to look for differences
  57. are (1) in the definitions pf types and modes, (2) in the specification
  58. of the data connection and data sockets, (3) in the command-reply
  59. sequences, (4) in the functions dependent on the TELNET protocol (FTP
  60. has been altered to correspond to the new TELNET spec).  The model has
  61. been clarified and enlarged to allow inter-server file transfer, and
  62. several new commands have been added to accommodate more specialized (or
  63. site-specific) functions.  It is my belief that this new specificiation
  64. reflects the views expressed by the committee at the above-mentioned
  65. meeting and in subsequent conversations.
  66.  
  67. The large number of incompatibilities would complicate a phased
  68. implementation schedule, such as is in effect for the TELNET protocol.
  69. Therefore we have assigned a new socket, decimal 21, as a temporary
  70. logger socket for the new version and a change-over date of 1 February
  71. 1974.  Until that date the old (354, 385) version of FTP will be
  72. available on Socket 3 and the new version (attached) should be
  73. implemented on Socket 21.  On 1 February the new version will shift to
  74. Socket 3 and the old disappear from view.
  75.  
  76. The File Transfer protocol should be considered stable at least until
  77. February, though one should feel free to propose further changes via
  78. RFC.  (Implementation of new commands on an experimental basis is
  79. encouraged and should also be reported by RFC.)  In addition, members of
  80. the FTP committee may be contacted directly about changes.  Based on
  81. attendance at the March 16 meeting, they are:
  82.  
  83.    Abhay Bhushan MIT-DMCG
  84.    Bob Braden UCLA-CCN
  85.    Bob Bressler BBN-NET
  86.    Bob Clements BBN-TENEX
  87.    John Day ILL-ANTS
  88.    Peter Deutsch PARC-MAXC
  89.    Wayne Hathaway AMES-67
  90.    Mike Kudlick SRI-ARC
  91.    Alex McKenzie BBN-NET
  92.    Bob Merryman UCSD-CC
  93.    Nancy Neigus BBN-NET
  94.    Mike Padlipsky MIT-Multics
  95.    Jim Pepin USC-44
  96.    Ken Pogran MIT-Multics
  97.    Jon Postel UCLA-NMC
  98.  
  99.  
  100.                                    1
  101.  
  102.                                                   File Transfer Protocol
  103.                                                          (Aug. 12, 1973)
  104.                                                        RFC 542 NIC 17759
  105.                                                                         
  106.                                                                         
  107.    Milton Reese FNWC
  108.    Brad Reussow HARV-10
  109.    Marc Seriff MIT-DMCG
  110.    Ed Taft HARV-10
  111.    Bob Thomas BBN-TENEX
  112.    Ric Werme CMU-10
  113.    Jim White SRI-ARC
  114.  
  115. I would especially like to thank Bob Braden, Ken Pogran, Wayne Hathaway,
  116. Jon Postel, Ed Taft and Alex McKenzie for their help in preparing this
  117. document.
  118.  
  119. NJN/jm
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.                                    2
  159.  
  160.                                                   File Transfer Protocol
  161.                                                          (Aug. 12, 1973)
  162.                                                        RFC 542 NIC 17759
  163.                                                                         
  164.                                                                         
  165.                          FILE TRANSFER PROTOCOL
  166.  
  167. INTRODUCTION
  168.  
  169.    The File Transfer Protocol (FTP) is a protocol for file transfer
  170.    between Hosts (including Terminal Interface Message Processors
  171.    (TIPs)) on the ARPA Computer Network (ARPANET).  The primary function
  172.    of FTP is to transfer files efficiently and reliably among Hosts and
  173.    to allow the convenient use of remote file storage capabilities.
  174.  
  175.    The objectives of FTP are 1) to promote sharing of files (computer
  176.    programs and/or data), 2) to encourage indirect or implicit (via
  177.    programs) use of remote computers, 3) to shield a user from
  178.    variations in file storage systems among Hosts, and 4) to transfer
  179.    data reliably and efficiently.  FTP, though usable directly by a user
  180.    at a terminal, is designed mainly for use by programs.
  181.  
  182.    The attempt in this specification is to satisfy the diverse needs of
  183.    users of maxi-Hosts, mini-Hosts, TIPs, and the Datacomputer, with a
  184.    simple, and easily implemented protocol design.
  185.  
  186.    This paper assumes knowledge of the following protocols described in
  187.    NIC #7104:
  188.  
  189.       The Host-Host Protocol
  190.  
  191.       The Initial Connection Protocol
  192.  
  193.       The TELNET Protocol
  194.  
  195. DISCUSSION
  196.  
  197.    In this section, the terminology and the FTP model are discussed.
  198.    The terms defined in this section are only those that have special
  199.    significance in FTP.
  200.  
  201.    TERMINOLOGY
  202.  
  203.       ASCII
  204.  
  205.          The USASCII character set as defined in NIC #7104.  In FTP,
  206.          ASCII characters are defined to be the lower half of an
  207.          eight-bit code set (i.e., the most significant bit is zero).
  208.  
  209.       access controls
  210.  
  211.          Access controls define users' access privileges to the use of a
  212.          system, and to the files in that system.  Access controls are
  213.          necessary to prevent unauthorized or accidental use of files.
  214.  
  215.  
  216.                                    3
  217.  
  218.                                                   File Transfer Protocol
  219.                                                          (Aug. 12, 1973)
  220.                                                        RFC 542 NIC 17759
  221.                                                                         
  222.                                                                         
  223.          It is the prerogative of a server-FTP process to provide access
  224.          controls.
  225.  
  226.       byte size
  227.  
  228.          The byte size specified for the transfer of data.  The data
  229.          connection is opened with this byte size.  The data connection
  230.          byte size is not necessarily the byte size in which data is to
  231.          be stored in a system, nor the logical byte size for
  232.          interpretation of the structure of the data.
  233.  
  234.       data connection
  235.  
  236.          A simplex connection over which data is transferred, in a
  237.          specified byte size, mode and type. The data transferred may be
  238.          a part of a file, an entire file or a number of files.  The
  239.          path may be between a server-DTP and a user-DTP, or between two
  240.          server-DTPs.
  241.  
  242.       data socket
  243.  
  244.          The passive data transfer process "listens" on the data socket
  245.          for an RFC from the active transfer process (server) in order
  246.          to open the data connection.  The server has fixed data
  247.          sockets; the passive process may or may not.
  248.  
  249.       EOF
  250.  
  251.          The end-of-file condition that defines the end of a file being
  252.          transferred.
  253.  
  254.       EOR
  255.  
  256.          The end-of-record condition that defines the end of a record
  257.          being transferred.
  258.  
  259.       error recovery
  260.  
  261.          A procedure that allows a user to recover from certain errors
  262.          such as failure of either Host system or transfer process.  In
  263.          FTP, error recovery may involve restarting a file transfer at a
  264.          given checkpoint.
  265.  
  266.       FTP commands
  267.  
  268.          A set of commands that comprise the control information flowing
  269.          from the user-FTP to the server-FTP process.
  270.  
  271.  
  272.  
  273.  
  274.                                    4
  275.  
  276.                                                   File Transfer Protocol
  277.                                                          (Aug. 12, 1973)
  278.                                                        RFC 542 NIC 17759
  279.                                                                         
  280.                                                                         
  281.       file
  282.  
  283.          An ordered set of computer data (including programs), of
  284.          arbitrary length, uniquely identified by a pathname.
  285.  
  286.       mode
  287.  
  288.          The mode in which data is to be transferred via the data
  289.          connection. The mode defines the data format during transfer
  290.          including EOR and EOF.  The transfer modes defined in FTP are
  291.          described in the Section on Transmission Modes.
  292.  
  293.       NVT
  294.  
  295.          The Network Virtual Terminal as defined in the ARPANET TELNET
  296.          Protocol.
  297.  
  298.       NVFS
  299.  
  300.          The Network Virtual File System.  A concept which defines a
  301.          standard network file system with standard commands and
  302.          pathname conventions.  FTP only partially embraces the NVFS
  303.          concept at this time.
  304.  
  305.       pathname
  306.  
  307.          Pathname is defined to be the character string which must be
  308.          input to a file system by a user in order to identify a file.
  309.          Pathname normally contains device and/or directory names, and
  310.          file name specification.  FTP does not yet specify a standard
  311.          pathname convention.  Each user must follow the file naming
  312.          conventions of the file systems he wishes to use.
  313.  
  314.       record
  315.  
  316.          A sequential file may be structured as a number of contiguous
  317.          parts called records.  Record structures are supported by FTP
  318.          but a file need not have record structure.
  319.  
  320.       reply
  321.  
  322.          A reply is an acknowledgment (positive or negative) sent from
  323.          server to user via the TELNET connections in response to FTP
  324.          commands.  The general form of a reply is a completion code
  325.          (including error codes) followed by a text string.  The codes
  326.          are for use by programs and the text is usually intended for
  327.          human users.
  328.  
  329.  
  330.  
  331.  
  332.                                    5
  333.  
  334.                                                   File Transfer Protocol
  335.                                                          (Aug. 12, 1973)
  336.                                                        RFC 542 NIC 17759
  337.                                                                         
  338.                                                                         
  339.       server-DTP
  340.  
  341.          The data transfer process, in its normal "active" state,
  342.          establishes the data connection by RFC to the "listening" data
  343.          socket, sets up parameters for transfer and storage, and
  344.          tranfers data on command from its PI.  The DTP can be placed in
  345.          a "passive" state to listen for, rather than initiate, an RFC
  346.          on the data socket.
  347.  
  348.       server-FTP process
  349.  
  350.          A process or set of processes which perform the function of
  351.          file transfer in cooperation with a user-FTP process and,
  352.          possibly, another server.  The functions consist of a protocol
  353.          interpreter (PI) and a data transfer process (DTP).
  354.  
  355.       server-PI
  356.  
  357.          The protocol interpreter "listens" on Socket 3 for an ICP from
  358.          a user-PI and establishes a TELNET communication connection.
  359.          It receives standard FTP commands from the user-PI, sends
  360.          replies, and governs the server-DTP.
  361.  
  362.       TELNET connections
  363.  
  364.          The full-duplex communication path between a user-PI and a
  365.          server-PI.  The TELNET connections are established via the
  366.          standard ARPANET Initial Connection Protocol (ICP).
  367.  
  368.       type
  369.  
  370.          The data representation type used for data transfer and
  371.          storage.  Type implies certain transformations between the time
  372.          of data storage and data transfer.  The representation types
  373.          defined in FTP are described in the Section on Establishing
  374.          Data Connections.
  375.  
  376.       user
  377.  
  378.          A human being or a process on behalf of a human being wishing
  379.          to obtain file transfer service.  The human user may interact
  380.          directly with a server-FTP process, but use of a user-FTP
  381.          process is preferred since the protocol design is weighted
  382.          towards automata.
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.                                    6
  391.  
  392.                                                   File Transfer Protocol
  393.                                                          (Aug. 12, 1973)
  394.                                                        RFC 542 NIC 17759
  395.                                                                         
  396.                                                                         
  397.       user-DTP
  398.  
  399.          The data transfer process "listens" on the data socket for an
  400.          RFC from a server-FTP process.  If two servers are transferring
  401.          data between them, the user-DTP is inactive.
  402.  
  403.       user-FTP process
  404.  
  405.          A set of functions including a protocol interpreter, a data
  406.          transfer process and a user interface which together perform
  407.          the function of file transfer in cooperation with one or more
  408.          server-FTP processes.  The user interface allows a local
  409.          language to be used in the command-reply dialogue with the
  410.          user.
  411.  
  412.       user-PI
  413.  
  414.          The protocol interpreter initiates the ICP to the server-FTP
  415.          process, initiates FTP commands, and governs the user-DTP if
  416.          that process is part of the file transfer.
  417.  
  418.    THE FTP MODEL
  419.  
  420.    With the above definitions in mind, the following model (shown in
  421.    Figure 1) may be diagrammed for an FTP service.
  422.  
  423.                                          -------------
  424.                                          !/---------\!
  425.                                          !!   User  !!    --------
  426.                                          !!Interface!<--->! User !
  427.                                          !\----:----/!    --------
  428.                ----------                !     V     !
  429.                !/------\!  FTP Commands  !/---------\!
  430.                !!Server!<-----------------!   User  !!
  431.                !!  PI  !----------------->!    PI   !!
  432.                !\--:---/!   FTP Replies  !\----:----/!
  433.                !   V    !                !     V     !
  434.    --------    !/------\!      Data      !/---------\!    --------
  435.    ! File !<--->!Server!<---------------->!  User   !<--->! File !
  436.    !System!    !! DTP  !!   Connections  !!   DTP   !!    !System!
  437.    --------    !\------/!                !\---------/!    --------
  438.                ----------                -------------
  439.  
  440.                Server-FTP                   User-FTP
  441.  
  442.    NOTES: 1. The data connection may be in either direction.
  443.           2. The data connection need not exist all of the time.
  444.  
  445.                      Figure 1  Model for FTP Use
  446.  
  447.  
  448.                                    7
  449.  
  450.                                                   File Transfer Protocol
  451.                                                          (Aug. 12, 1973)
  452.                                                        RFC 542 NIC 17759
  453.                                                                         
  454.                                                                         
  455.    In the model described in Figure 1, the user-protocol interpreter
  456.    initiates the TELNET connections. At the initiation of the user,
  457.    standard FTP commands are generated by the user-PI and transmitted to
  458.    the server process via the TELNET connections.  (The user may
  459.    establish a direct TELNET connection to the server-FTP, from a TIP
  460.    terminal for example, and generate standard FTP commands himself,
  461.    by-passing the user-FTP process.) Standard replies are sent from the
  462.    server-PI to the user-PI over the TELNET connections in response to
  463.    the commands.
  464.  
  465.    The FTP commands specify the parameters for the data connection (data
  466.    socket, byte size, transfer mode, representation type, and structure)
  467.    and the nature of file system operation (store, retrieve, append,
  468.    delete, etc.).  The user-DTP or its designate should "listen" on the
  469.    specified data socket, and the server initiate the data connection
  470.    and data transfer in accordance with the specified parameters.  It
  471.    should be noted that the data socket need not be in the same Host
  472.    that initiates the FTP commands via the TELNET connections, but the
  473.    user or his user-FTP process must ensure a "listen" on the specified
  474.    data socket.  It should also be noted that two data connections, one
  475.    for send and the other for receive, may exist simultaneously.
  476.  
  477.    In another situation a user might wish to transfer files between two
  478.    Hosts, neither of which is his local Host. He sets up TELNET
  479.    connections to the two servers and then arranges for a data
  480.    connection between them.  In this manner control information is
  481.    passed to the user-PI but data is transferred between he server data
  482.    transfer processes.  Following is a model of this server-server
  483.    interaction.
  484.  
  485.    
  486.                  TELNET     ------------    TELNET
  487.                  -----------! User-FTP !------------
  488.                  ! -------->! User-PI  !<--------- !
  489.                  ! !        !   "C"    !         ! !
  490.                  V !        ------------         ! V
  491.          --------------                        --------------
  492.          ! Server-FTP !   Data Connection      ! Server-FTP !
  493.          !    "A"     !<-----------------------!    "B"     !
  494.          -------------- Socket(A)    Socket(B) --------------
  495.    
  496.    
  497.    
  498.                              Figure 2
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.                                    8
  507.  
  508.                                                   File Transfer Protocol
  509.                                                          (Aug. 12, 1973)
  510.                                                        RFC 542 NIC 17759
  511.  
  512.  
  513.    The protocol requires that the TELNET connections be open while data
  514.    transfer is in progress.  It is the responsibility of the user to
  515.    request the closing of the TELNET connections when finished using the
  516.    FTP service, while it is the server who takes the action.  The server
  517.    may abort data transfer if the TELNET connections are closed without
  518.    command.
  519.  
  520. DATA TRANSFER FUNCTIONS
  521.  
  522.    Files are transferred only via the data connection(s).  The TELNET
  523.    connection is used for the transfer of commands, which describe the
  524.    functions to be performed, and the replies to these commands (see the
  525.    Section on FTP Replies).  Several commands are concerned with the
  526.    transfer of data between Hosts.  These data transfer commands include
  527.    the BYTE, MODE, and SOCKet commands which specify how the bits of the
  528.    data are to be transmitted, and the STRUcture and TYPE commands,
  529.    which are used to define the way in which the data are to be
  530.    represented. The transmission and representation are basically
  531.    independent but "Stream" transmission mode is dependent on the file
  532.    structure attribute and if "Compressed" transmission mode is used the
  533.    nature of the filler byte depends on the representation type.
  534.  
  535.    DATA REPRESENTATION AND STORAGE
  536.  
  537.    Data is transferred from a storage device in the sending Host to a
  538.    storage device in the receiving Host.  Often it is necessary to
  539.    perform certain transformations on the data because data storage
  540.    representations in the two systems are different.  For example,
  541.    NVT-ASCII has different data storage representations in diffeent
  542.    systems.  PDP-10's generally store NVT-ASCII as five 7-bit ASCII
  543.    characters, left-justified in a 36-bit word. 360's store NVT-ASCII as
  544.    8-bit EBCDIC codes. Multics stores NVT-ASCII as four 9-bit characters
  545.    in a 36-bit word.  It may be desirable to convert characters into the
  546.    standard NVT-ASCII representation when transmitting text between
  547.    dissimilar systems.  The sending and receiving sites would have to
  548.    perform the necessary transformations between the standard
  549.    representation and their internal representations.
  550.  
  551.    A different problem in representation arises when transmitting binary
  552.    data (not character codes) between Host systems with different word
  553.    lengths.  It is not always clear how the sender should send data, and
  554.    the receiver store it.  For example, when transmitting 32-bit bytes
  555.    from a 32-bit word-length system to a 36-bit word-length system, it
  556.    may be desirable (for reasons of efficiency and usefulness) to store
  557.    the 32-bit bytes right-justified in a 36-bit word in the latter
  558.    system.  In any case, the user should have the option of specifying
  559.    data representation and transformation functions.  It should be noted
  560.    that FTP provides for very limited data type representations.
  561.    Transformations desired beyond this limited capability should be
  562.  
  563.  
  564.                                    9
  565.  
  566.                                                   File Transfer Protocol
  567.                                                          (Aug. 12, 1973)
  568.                                                        RFC 542 NIC 17759
  569.  
  570.  
  571.    performed by the user directly or via the use of the Data
  572.    Reconfiguration Sevice (DRS, RFC #138, NIC #6715).  Additonal
  573.    representation types may be defined later if there is a demonstrable
  574.    need.
  575.  
  576.    Data representations are handled in FTP by a user specifying a
  577.    representation type.  This type may implicitly (as in ASCII or
  578.    EBCDIC) or explicitly (as in Local byte) define a byte size for
  579.    interpretation which is referred to as the "logical byte size."  This
  580.    has nothing to do with the byte size used for transmission over the
  581.    data connection(s) (called the "transfer byte size") and the two
  582.    should not be confused.  For example, NVT-ASCII has a logical byte
  583.    size of 8 bits but an ASCII file might be transferred using a
  584.    transfer byte size of 32.  If the type is Local byte, then the TYPE
  585.    command has an obligatory second parameter specifying the logical
  586.    byte size.
  587.  
  588.    The types ASCII and EBCDIC also take a second (optional) parameter;
  589.    this is to indicate what kind of vertical format control, if any, is
  590.    associated with a file.  The following data representation types are
  591.    defined in FTP:
  592.  
  593.       ASCII Format
  594.  
  595.          This is the default type and must be accepted by all FTP
  596.          implementations.  It is intended primarily for the transfer of
  597.          text files, except when both Hosts would find the EBCDIC type
  598.          more convenient.
  599.  
  600.          The sender converts the data from his internal character
  601.          representation to the standard 8-bit NVT-ASCII representation
  602.          (see the TELNET specification).  The receiver will convert the
  603.          data from the standard form to his own internal form.
  604.  
  605.          In accordance with the NVT standard, the <CRLF> sequence should
  606.          be used, where necessary, to denote the end of a line of text.
  607.          (See the discussion of file structure at the end of the Section
  608.          on Data Representation and Storage).
  609.  
  610.          Using the standard NVT-ASCII representation means that data
  611.          must be interpreted as 8-bit bytes.  If the BYTE command (see
  612.          the Section on Transfer Parameter Commands) specifies a
  613.          transfer byte size different from 8 bits, the 8-bit ASCII
  614.          characters should be packed contiguously without regard for
  615.          transfer byte boundaries.
  616.  
  617.          The Format parameter for ASCII and EBCDIC types is discussed
  618.          below.
  619.  
  620.  
  621.  
  622.                                    10
  623.  
  624.                                                   File Transfer Protocol
  625.                                                          (Aug. 12, 1973)
  626.                                                        RFC 542 NIC 17759
  627.                                                                         
  628.                                                                         
  629.       EBCDIC Format
  630.  
  631.          This type is intended for efficient transfer between Hosts
  632.          which use EBCDIC for their internal character representation.
  633.  
  634.          For transmission the data are represented as 8-bit EBCDIC
  635.          characters.  The character code is the only difference between
  636.          the functional specifications of EBCDIC and ASCII types.
  637.  
  638.          End-of-line (as opposed to end-of-record--see the discussion of
  639.          structure) will probably be rarely used with EBCDIC type for
  640.          purposes of denoting structure, but where it is necessary the
  641.          <NL> character should be used.
  642.  
  643.    A character file may be transferred to a Host for one of three
  644.    purposes: for printing, for storage and later retrieval, or for
  645.    processing.  If a file is sent for printing, the receiving Host must
  646.    know how the vertical format control is represented.  In the second
  647.    case, it must be possible to store a file at a Host and then retrieve
  648.    it later in exactly the same form.  Finally, it ought to be possible
  649.    to move a file from one Host to another and process the file at the
  650.    second Host without undue trouble.  A single ASCII or EBCDIC format
  651.    does not satisfy all these conditions and so these types have a
  652.    second parameter specifying one of the following three formats:
  653.  
  654.       Non-print
  655.  
  656.          This is the default format to be used if the second (format)
  657.          parameter is omitted.  Non-print format must be accepted by all
  658.          FTP implementations.
  659.  
  660.          The file need contain no vertical format information.  If it is
  661.          passed to a printer process, this process may assume standard
  662.          values for spacing and margins.
  663.  
  664.          Normally, this format will be used with files destined for
  665.          processing or just storage.
  666.  
  667.       TELNET Format Controls
  668.  
  669.          The file contains ASCII/EBCDIC vertical format controls (i.e.,
  670.          <CR>, <LF>, <NL>, <VT>, <FF>) which the printer process will
  671.          interpret appropriately.  <CRLF>, in exactly this sequence,
  672.          also denotes end-of-line.
  673.  
  674.       Carriage Control (ASA)
  675.  
  676.          The file contains ASA (FORTRAN) vertical format control
  677.          characters.  (See NWG/RFC #189 Appendix C and Communications of
  678.  
  679.  
  680.                                    11
  681.  
  682.                                                   File Transfer Protocol
  683.                                                          (Aug. 12, 1973)
  684.                                                        RFC 542 NIC 17759
  685.                                                                         
  686.                                                                         
  687.          the ACM, Vol. 7, No. 10, 606 (Oct. 1964)).  In a line or a
  688.          record, formatted according to the ASA Standard, the first
  689.          character is not to be printed.  Instead it should be used to
  690.          determine the vertical movement of the paper which should take
  691.          place before the rest of the record is printed.  The ASA
  692.          Standard specifies the following control characters:
  693.  
  694.             Character     Vertical Spacing
  695.  
  696.             blank         Move paper up one line
  697.             0             Move paper up two lines
  698.             1             Move paper to top of next page
  699.             +             No movement, i.e., overprint
  700.  
  701.          Clearly there must be some way for a printer process to
  702.          distinguish the end of the structural entity.  If a file has
  703.          record structure (see below) this is no problem; records will
  704.          be explicitly marked during transfer and storage.  If the file
  705.          has no record structure, the <CRLF> end-of-line sequence is
  706.          used to separate printing lines, but these format effectors are
  707.          overridden by the ASA controls.
  708.  
  709.       Image
  710.  
  711.          The data are sent as contiguous bits which, for transfer, are
  712.          packed into transfer bytes of the size specified in the BYTE
  713.          command.  The receiving site must store the data as contiguous
  714.          bits.  The structure of the storage system might necessitate
  715.          the padding of the file (or of each record, for a
  716.          record-structured file) to some convenient boundary (byte, word
  717.          or block).  This padding, which must be all zeroes, may occur
  718.          only at the end of the file (or at the end of each record) and
  719.          there must be a way of identifying the padding bits so that
  720.          they may be stripped off if the file is retrieved.  The padding
  721.          transformation should be well publicized to enable a user to
  722.          process a file at the storage site.
  723.  
  724.          Image type is intended for the efficient storage and retrieval
  725.          of files and for the transfer of binary data.  It is
  726.          recommended that this type be accepted by all FTP
  727.          implementations.
  728.  
  729.       Local byte Byte size
  730.  
  731.          The data is transferred in logical bytes of the size specified
  732.          by the obligatory second parameter, Byte size.  The value of
  733.          Byte size must be a decimal integer; there is no default value.
  734.          The logical byte size is not necessarily the same as the
  735.          transfer byte size.  If there is a difference in byte sizes,
  736.  
  737.  
  738.                                    12
  739.  
  740.                                                   File Transfer Protocol
  741.                                                          (Aug. 12, 1973)
  742.                                                        RFC 542 NIC 17759
  743.                                                                         
  744.                                                                         
  745.          then the logical bytes should be packed contiguously,
  746.          disregarding transfer byte boundaries and with any necessary
  747.          padding at the end.
  748.  
  749.          When the data reaches the receiving Host it will be transformed
  750.          in a manner dependent on the logical byte size and the
  751.          particular Host.  This transformation must be invertible (that
  752.          is an identical file can be retrieved if the same parameters
  753.          are used) and should be well publicized by the FTP
  754.          implementors.
  755.  
  756.          This type is intended for the transfer of structured data.  For
  757.          example, a user sending 36-bit floating-point numbers to a Host
  758.          with a 32-bit word could send his data as Local byte with a
  759.          logical byte size of 36.  The receiving Host would then be
  760.          expected to store the logical bytes so that they could be
  761.          easily manipulated; in this example putting the 36-bit logical
  762.          bytes into 64-bit double words should suffice.
  763.  
  764.    A note of caution about parameters:  a file must be stored and
  765.    retrieved with the same parameters if the retrieved version is to be
  766.    identical to the version originally transmitted.  Conversely, FTP
  767.    implementations must return a file identical to the original if the
  768.    parameters used to store and retrieve a file are the same.
  769.  
  770.    In addition to different representation types, FTP allows the
  771.    structure of a file to be specified.  Currently two file structures
  772.    are recognized in FTP: file-structure, where there is no internal
  773.    structure, and record-structure, where the file is made up of
  774.    records.  File-structure is the default, to be assumed if the
  775.    STRUcture command has not been used but both structures must be
  776.    accepted for "text" files (i.e., files with TYPE ASCII or EBCDIC) by
  777.    all FTP implementations.  The structure of a file will affect both
  778.    the transfer mode of a file (see the Section on Transmission Modes)
  779.    and the interpretation and storage of the file.
  780.  
  781.    The "natural" structure of a file will depend on which Host stores
  782.    the file.  A source-code file will usually be stored on an IBM 360 in
  783.    fixed length records but on a PDP-10 as a stream of characters
  784.    partitioned into lines, for example by <CRLF>.  If the transfer of
  785.    files between such disparate sites is to be useful, there must be
  786.    some way for one site to recognize the other's assumptions about the
  787.    file.
  788.  
  789.    With some sites being naturally file-oriented and others naturally
  790.    record-oriented there may be problems if a file with one structure is
  791.    sent to a Host oriented to the other.  If a text file is sent with
  792.    record-structure to a Host which is file oriented, then that Host
  793.    should apply an internal transformation to the file based on the
  794.  
  795.  
  796.                                    13
  797.  
  798.                                                   File Transfer Protocol
  799.                                                          (Aug. 12, 1973)
  800.                                                        RFC 542 NIC 17759
  801.                                                                         
  802.                                                                         
  803.    record structure.  Obviously this transformation should be useful but
  804.    it must also be invertible so that an identical file may be
  805.    retreieved using record structure.
  806.  
  807.    In the case of a file being sent with file-structure to a
  808.    record-oriented Host, there exists the question of what criteria the
  809.    Host should use to divide the file into records which can be
  810.    processed locally.  If this division is necessary the FTP
  811.    implementation should use the end-of-line sequence, <CRLF> for ASCII,
  812.    or <NL> for EBCDIC text files, as the delimiter.  If an FTP
  813.    implementation adopts this technique, it must be prepared to reverse
  814.    the transformation if the file is retrieved with file-structure.
  815.  
  816.    ESTABLISHING DATA CONNECTIONS
  817.  
  818.    The mechanics of transferring data consists of setting up the data
  819.    connection to the appropriate sockets and choosing the parameters for
  820.    transfer--byte size and mode. Both the user and the server-DTPs have
  821.    default data sockets; these are the two sockets (for send and
  822.    receive) immediately following the standard ICP TELNET socket ,i.e.,
  823.    (U+4) and (U+5) for the user-process and (S+2), (S+3) for the server.
  824.    The use of default sockets will ensure the security of the data
  825.    transfer, without requiring the socket information to be explicitly
  826.    exchanged.
  827.  
  828.    The byte size for the data connection is specified by the BYTE
  829.    command, or, if left unspecified, defaults to 8-bit bytes.  This byte
  830.    size is relevant only for the actual transfer of the data; it has no
  831.    bearing on representation of the data within a Host's file system.
  832.    The protocol does not require servers to accept all possible byte
  833.    sizes. Since the use of various byte sizes is intended for efficiency
  834.    of transfer, servers may implement only those sizes for which their
  835.    data transfer is efficient including the default byte size of 8 bits.
  836.  
  837.    The passive data transfer process (this may be a user-DTP or a second
  838.    server-DTP) shall "listen" on the data socket prior to sending a
  839.    transfer request command.  The FTP request command determines the
  840.    direction of the data transfer and thus which data socket (odd or
  841.    even) is to be used in establishing the connection.  The server, upon
  842.    receiving the transfer request, will initiate the data connection by
  843.    RFC to the appropriate socket using the specified (or default) byte
  844.    size.  When the connection is opened, the data transfer begins
  845.    between DTP's, and the server-PI sends a confirming reply to the
  846.    user-PI.
  847.  
  848.    It is possible for the user to specify an alternate data socket by
  849.    use of the SOCK command.  He might want a file dumped on a TIP line
  850.    printer or retrieved from a third party Host.  In the latter case the
  851.    user-PI sets up TELNET connections with both server-PI's and sends
  852.  
  853.  
  854.                                    14
  855.  
  856.                                                   File Transfer Protocol
  857.                                                          (Aug. 12, 1973)
  858.                                                        RFC 542 NIC 17759
  859.                                                                         
  860.                                                                         
  861.    each a SOCK command indicating the fixed data sockets of the other.
  862.    One server is then told (by an FTP command) to "listen" for an RFC
  863.    which the other will initiate and finally both are sent the
  864.    appropriate transfer commands.  The exact sequence of commands and
  865.    replies sent between the user-controller and the servers is defined
  866.    in the Section on FTP Replies.
  867.  
  868.    In general it is the server's responsibility to maintain the data
  869.    connection--to initiate the RFC's and the closes.  The exception to
  870.    this is when the user-DTP is sending the data in a transfer mode that
  871.    requires the connection to be closed to indicate EOF.  The server
  872.    MUST close the data connection under the following conditions:
  873.  
  874.       1. The server has completed sending data in a transfer mode that
  875.          requires a close to indicate EOF.
  876.  
  877.       2. The server receives an ABORT command from the user.
  878.  
  879.       3. The socket or byte size specification is changed by a command
  880.          from the user.
  881.  
  882.       4. The TELNET connections are closed legally or otherwise.
  883.  
  884.       5. An irrecoverable error condition occurs.
  885.  
  886.    Otherwise the close is a server option, the exercise of which he must
  887.    indicate to the user-process by an appropriate reply.
  888.  
  889.    TRANSMISSION MODES
  890.  
  891.    The next consideration in transferring data is choosing the
  892.    appropriate transmission mode.  There are three modes: one which
  893.    formats the data and allows for restart procedures; one which also
  894.    compresses the data for efficient transfer; and one which passes the
  895.    data with little or no processing.  In this last case the mode
  896.    interacts with the structure attribute to determine the type of
  897.    processing.  In the compressed mode the representation type
  898.    determines the filler byte.
  899.  
  900.    All data transfers must be completed with an end-of-file (EOF) which
  901.    may be explicitly stated or implied by the closing of the data
  902.    connection.  For files with record structure, all the end-of-record
  903.    markers (EOR) are explicit, including the final one.
  904.  
  905.    Note:  In the rest of this section, byte means "transfer byte" except
  906.    where explicitly stated otherwise.
  907.  
  908.  
  909.  
  910.  
  911.  
  912.                                    15
  913.  
  914.                                                   File Transfer Protocol
  915.                                                          (Aug. 12, 1973)
  916.                                                        RFC 542 NIC 17759
  917.                                                                         
  918.                                                                         
  919.    The following transmission modes are defined in FTP:
  920.  
  921.       Stream
  922.  
  923.          The data is transmitted as a stream of bytes.  There is no
  924.          restriction on the representation type used; record structures
  925.          are allowed, in which case the transfer byte size must be at
  926.          least 3 bits!
  927.  
  928.          In a record structured file EOR and EOF will each be indicated
  929.          by a two-byte control code of whatever byte size is used for
  930.          the transfer.  The first byte of the control code will be all
  931.          ones, the escape character.  The second byte will have the low
  932.          order bit on and zeroes elsewhere for EOR and the second low
  933.          order bit on for EOF; that is, the byte will have value 1 for
  934.          EOR and value 2 for EOF.  EOR and EOF may be indicated together
  935.          on the last byte transmitted by turning both low order bits on,
  936.          i.e., the value 3.  If a byte of all ones was intended to be
  937.          sent as data, it should be repeated in the second byte of the
  938.          control code.
  939.  
  940.          If the file does not have record structure, the EOF is
  941.          indicated by the sending Host closing the data connection and
  942.          all bytes are data bytes.
  943.  
  944.    For the purpose of standardized transfer, the sending Host will
  945.    translate his internal end of line or end of record denotation into
  946.    the representation prescribed by the transfer mode and file
  947.    structure, and the receiving Host will perform the inverse
  948.    translation to his internal denotation.  An IBM 360 record count
  949.    field may not be recognized at another Host, so the end of record
  950.    information may be transferred as a two byte control code in Stream
  951.    mode or as a flagged bit in a Block or Compressed mode descriptor.
  952.    End of line in an ASCII or EBCDIC file with no record structure
  953.    should be indicated by <CRLF> or <NL>, respectively.  Since these
  954.    transformations imply extra work for some systems, identical systems
  955.    transferring non-record structured text files might wish to use a
  956.    binary representation and stream mode for the transfer.
  957.  
  958.       Block
  959.  
  960.          The file is transmitted as a series of data blocks preceded by
  961.          one or more header bytes.  The header bytes contain a count
  962.          field, and descriptor code.  The count field indicates the
  963.          total length of the data block in bytes, thus marking the
  964.          beginning of the next data block (there are no filler bits).
  965.          The descriptor code defines:  last block in the file (EOF) last
  966.          block in the record (EOR), restart marker (see the Section on
  967.          Error Recovery and Restart) or suspect data (i.e., the data
  968.  
  969.  
  970.                                    16
  971.  
  972.                                                   File Transfer Protocol
  973.                                                          (Aug. 12, 1973)
  974.                                                        RFC 542 NIC 17759
  975.  
  976.  
  977.          being transferred is suspected of errors and is not reliable).
  978.          This last code is NOT intended for error control within FTP.
  979.          It is motivated by the desire of sites exchanging certain types
  980.          of data (e.g., seismic or weather data) to send and receive all
  981.          the data despite local errors (such as "magnetic tape read
  982.          errors"), but to indicate in the transmission that certain
  983.          portions are suspect).  Record structures are allowed in this
  984.          mode, and any representation type may be used.  There is no
  985.          restriction on the transfer byte size.
  986.  
  987.          The header consists of the smallest integral number of bytes
  988.          whose length is greater than or equal to 24 bits.  Only the
  989.          LEAST significant 24 bits (right-justified) of header shall
  990.          have information; the remaining most significant bits are
  991.          "don't care" bits.  Of the 24 bits of header information, the
  992.          16 low order bits shall represent byte count, and the 8 high
  993.          order bits shall represent descriptor codes as shown below.
  994.  
  995.          Integral number of bytes greater than or equal to 24 bits
  996.          --------------------------------------------------------
  997.          !    Don't care    !    Descriptor    !    Byte Count  !
  998.          !  0 to 231 bits   !      8 bits      !     16 bits    !
  999.          --------------------------------------------------------
  1000.          
  1001.  
  1002.          The descriptor codes are indicated by bit flags in the
  1003.          descriptor byte.  Four codes have been assigned, where each
  1004.          code number is the decimal value of the corresponding bit in
  1005.          the byte.
  1006.  
  1007.             Code     Meaning
  1008.             
  1009.              128     End of data block is EOR
  1010.               64     End of data block is EOF
  1011.               32     Suspected errors in data block
  1012.               16     Data block is a restart marker
  1013.             
  1014.  
  1015.          With this encoding more than one descriptor coded condition may
  1016.          exist for a particular block.  As many bits as necessary may be
  1017.          flagged.
  1018.  
  1019.          The restart marker is embedded in the data stream as an
  1020.          integral number of 8-bit bytes representing printable
  1021.          characters in the language being used over the TELNET
  1022.          connection (e.g., default--NVT-ASCII).  These marker bytes are
  1023.          right-justified in the smallest integral number of transfer
  1024.          bytes greater than or equal to 8 bits.  For example, if the
  1025.  
  1026.  
  1027.  
  1028.                                    17
  1029.  
  1030.                                                   File Transfer Protocol
  1031.                                                          (Aug. 12, 1973)
  1032.                                                        RFC 542 NIC 17759
  1033.                                                                         
  1034.                                                                         
  1035.          byte size is 7 bits, the restart marker byte would be one byte
  1036.          right-justified per two 7-bit bytes as shown below:
  1037.  
  1038.                  Two 7-bit bytes
  1039.             -------------------------
  1040.             !        !  Marker Char !
  1041.             !        !     8 bits   !
  1042.             -------------------------
  1043.  
  1044.          If the transfer byte size is 16 or more bits, the maximum
  1045.          possible number of complete marker bytes should be packed,
  1046.          right-justified, into each transfer byte.  The restart marker
  1047.          should begin in the first marker byte.  If there are any unused
  1048.          marker bytes, these should be filled with the character <SP>
  1049.          (Space, in the appropriate language).  <SP> must not be used
  1050.          WITHIN a restart marker.  For example, to transmit a
  1051.          six-character marker with a 36-bit transfer byte size, the
  1052.          following three 36-bit bytes would be sent:
  1053.  
  1054.             ------------------------------------------
  1055.             ! Don't care !Descriptor! Byte count = 2 !
  1056.             !   12 bits  ! code = 16!                !
  1057.             ------------------------------------------
  1058.             
  1059.             ------------------------------------------
  1060.             !    ! Marker ! Marker ! Marker ! Marker !
  1061.             !    ! 8 bits ! 8 bits ! 8 bits ! 8 bits !
  1062.             ------------------------------------------
  1063.             
  1064.             ------------------------------------------
  1065.             !    ! Marker ! Marker ! Space  ! Space  !
  1066.             !    ! 8 bits ! 8 bits ! 8 bits ! 8 bits !
  1067.             ------------------------------------------
  1068.             
  1069.  
  1070.       Compressed
  1071.  
  1072.          The file is transmitted as series of bytes of the size
  1073.          specified by the BYTE command.  There are three kinds of
  1074.          information to be sent:  regular data, sent in a byte string;
  1075.          compressed data, consisting of replications or filler; and
  1076.          control information, sent in a two-byte escape sequence.  If
  1077.          the byte size is B bits and n>0 bytes of regular data are sent,
  1078.          these n bytes are preceded by a byte with the left-most bit set
  1079.          to 0 and the right-most B-1 bits containing the number n.
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.                                    18
  1087.  
  1088.                                                   File Transfer Protocol
  1089.                                                          (Aug. 12, 1973)
  1090.                                                        RFC 542 NIC 17759
  1091.                                                                         
  1092.                                                                         
  1093.                         1  B-1    B        B
  1094.                        -------  ------   ------
  1095.          Byte string:  !0! n !  !d(1)!...!d(n)!
  1096.                        -------  ------   ------
  1097.                                 ^             ^
  1098.                                 !---n bytes---!
  1099.                                     of data
  1100.  
  1101.             String of n data bytes d(1),..., d(n)
  1102.             Count n must be positive
  1103.  
  1104.          To compress a string of n replications of the data byte d, the
  1105.          following 2 bytes are sent:
  1106.  
  1107.          
  1108.                               2     B-2       B
  1109.                            ---------------  ------
  1110.          Replicated Byte:  ! 1 0 !   n   !  ! d  !
  1111.                            ---------------  ------
  1112.  
  1113.          A string of n filler bytes can be compressed into a single
  1114.          byte, where the filler byte varies with the representation
  1115.          type.  If the type is ASCII or EBCDIC the filler byte is <SP>
  1116.          (Space, ASCII code 32., EBCDIC code 64).  If the transfer byte
  1117.          size is not 8, the expanded byte string should be filled with
  1118.          8-bit <SP> characters in the manner described in the definition
  1119.          of ASCII representation type (see the Section on Data
  1120.          Representation and Storage).  If the type is Image or Local
  1121.          byte the filler is a zero byte.
  1122.  
  1123.                             2     B-2
  1124.                          ---------------
  1125.          Filler String:  ! 1 1 !   n   !
  1126.                          ---------------
  1127.  
  1128.          The escape sequence is a double byte, the first of which is the
  1129.          escape byte (all zeroes) and the second of which contains
  1130.          descriptor codes as defined in Block mode.  This implies that
  1131.          the byte size must be at least 8 bits, which is not much of a
  1132.          restriction for efficiency in this mode.  The descriptor codes
  1133.          have the same meaning as in Block mode and apply to the
  1134.          succeeding string of bytes.
  1135.  
  1136.          Compressed mode is useful for obtaining increased bandwidth on
  1137.          very large network transmissions at a little extra CPU cost.
  1138.          It is most efficient when the byte size chosen is that of the
  1139.          word size of the transmitting Host, and can be most effectively
  1140.          used to reduce the size of printer files such as those
  1141.          generated by RJE Hosts.
  1142.  
  1143.  
  1144.                                    19
  1145.  
  1146.                                                   File Transfer Protocol
  1147.                                                          (Aug. 12, 1973)
  1148.                                                        RFC 542 NIC 17759
  1149.                                                                         
  1150.                                                                         
  1151.    ERROR RECOVERY AND RESTART
  1152.  
  1153.    There is no provision for detecting bits lost or scrambled in data
  1154.    transfer.  This issue is perhaps handled best at the NCP level where
  1155.    it benefits most users.  However, a restart procedure is provided to
  1156.    protect users from gross system failures (including failures of a
  1157.    Host, an FTP-process, or the IMP subnet).
  1158.  
  1159.    The restart procedure is defined only for the block and compressed
  1160.    modes of data transfer.  It requires the sender of data to insert a
  1161.    special marker code in the data stream with some marker information.
  1162.    The marker information has meaning only to the sender, but must
  1163.    consist of printable characters in the default or negotiated language
  1164.    of the TELNET connection.  The marker could represent a bit-count, a
  1165.    record-count, or any other information by which a system may identify
  1166.    a data checkpoint.  The receiver of data, if it implements the
  1167.    restart procedure, would then mark the corresponding position of this
  1168.    marker in the recieving system, and return this information to the
  1169.    user.
  1170.  
  1171.    In the event of a system failure, the user can restart the data
  1172.    transfer by identifying the marker point with the FTP restart
  1173.    procedure.  The following example illustrates the use of the restart
  1174.    procedure.
  1175.  
  1176.    The sender of the data inserts an appropriate marker block in the
  1177.    data stream at a convenient point.  The receiving Host marks the
  1178.    corresponding data point in its file system and conveys the last
  1179.    known sender and receiver marker information to the user, either
  1180.    directly or over the TELNET connection in a 251 reply (depending on
  1181.    who is the sender).  In the event of a system failure, the user or
  1182.    controller process restarts the server at the last server marker by
  1183.    sending a restart command with server's marker code as its argument.
  1184.    The restrart command is transmitted over the TELNET connection and is
  1185.    immediately followed by the command (such as RETR, STOR or LIST)
  1186.    which was being executed when the system failure occurred.
  1187.  
  1188. FILE TRANSFER FUNCTIONS
  1189.  
  1190.    The communication channel from the user-PI to the server-PI is
  1191.    established by ICP from the user to a standard server socket.  The
  1192.    user protocol interpreter is responsible for sending FTP commands and
  1193.    interpreting the replies received; the server-PI interprets commands,
  1194.    sends replies and directs its DTP to set up the data connection and
  1195.    transfer the data.  If the second party to the data transfer (the
  1196.    passive transfer process) is the user-DTP then it is governed through
  1197.    the internal protocol of the user-FTP Host; if it is a second
  1198.    server-DTP then it is governed by its PI on command from the user-PI.
  1199.  
  1200.  
  1201.  
  1202.                                    20
  1203.  
  1204.                                                   File Transfer Protocol
  1205.                                                          (Aug. 12, 1973)
  1206.                                                        RFC 542 NIC 17759
  1207.                                                                         
  1208.                                                                         
  1209.    FTP COMMANDS
  1210.  
  1211.    The File Transfer Protocol follows the specifications of the TELNET
  1212.    protocol for all communications over the TELNET connection - see NIC
  1213.    #7104.  Since, in the future, the language used for TELNET
  1214.    communication may be a negotiated option, all references in the next
  1215.    two sections will be to the "TELNET language" and the corresponding
  1216.    "TELNET end of line code".  Currently one may take these to mean
  1217.    NVT-ASCII and <CRLF>.  No other specifications of the TELNET protocol
  1218.    will be cited.
  1219.  
  1220.    FTP commands are "TELNET strings" terminated by the "TELNET end of
  1221.    line code".  The command codes themselves are alphabetic characters
  1222.    terminated by the character <SP> (Space) if parameters follow and
  1223.    TELNET-EOL otherwise.  The command codes and the semantics of
  1224.    commands are described in this section; the detailed syntax of
  1225.    commands is specified in the Section on Commands, the reply sequences
  1226.    are discussed in the Section on Sequencing of Commands and Replies,
  1227.    and scenarios illustrating the use of commands are provided in the
  1228.    Section on Typical FTP Scenarios.
  1229.  
  1230.    FTP commands may be partitioned as those specifying access-control
  1231.    identifiers, data transfer parameters, or FTP service requests.
  1232.    Certain commands (such as ABOR, STAT, BYE) may be sent over the
  1233.    TELNET connections while a data transfer is in progress.  Some
  1234.    servers may not be able to monitor the TELNET and data connections
  1235.    simultaneously, in which case some special action will be necessary
  1236.    to get the server's attention.  The exact form of the "special
  1237.    action" is related to decisions currently under review by the TELNET
  1238.    committee; but the following ordered format is tentatively
  1239.    recommended:
  1240.  
  1241.       1. User system inserts the TELNET "Interrupt Process" (IP) signal
  1242.          in the TELNET stream.
  1243.  
  1244.       2. User system sends the TELNET "Synch" signal
  1245.  
  1246.       3. User system inserts the command (e.g., ABOR) in the TELNET
  1247.          stream.
  1248.  
  1249.       4. Server PI,, after receiving "IP", scans the TELNET stream for
  1250.          EXACTLY ONE FTP command.
  1251.  
  1252.    (For other servers this may not be necessary but the actions listed
  1253.    above should have no unusual effect.)
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.                                    21
  1261.  
  1262.                                                   File Transfer Protocol
  1263.                                                          (Aug. 12, 1973)
  1264.                                                        RFC 542 NIC 17759
  1265.                                                                         
  1266.                                                                         
  1267.    ACCESS CONTROL COMMANDS
  1268.  
  1269.    The following commands specify access control identifiers (command
  1270.    codes are shown in parentheses).
  1271.  
  1272.       USER NAME (USER)
  1273.  
  1274.          The argument field is a TELNET string identifying the user.
  1275.          The user identification is that which is required by the server
  1276.          for access to its file system.  This command will normally be
  1277.          the first command transmitted by the user after the TELNET
  1278.          connections are made (some servers may require this).
  1279.          Additional identification information in the form of a password
  1280.          and/or an account command may also be required by some servers.
  1281.          Servers may allow a new USER command to be entered at any point
  1282.          in order to change the access control and/or accounting
  1283.          information.  This has the effect of flushing any user,
  1284.          password, and account information already supplied and
  1285.          beginning the login sequence again.  All transfer parameters
  1286.          are unchanged and any file transfer in progress is completed
  1287.          under the old acccount.
  1288.  
  1289.       PASSWORD (PASS)
  1290.  
  1291.          The argument field is a TELNET string identifying the user's
  1292.          password.  This command must be immediately preceded by the
  1293.          user name command, and, for some sites, completes the user's
  1294.          identification for access control.  Since password information
  1295.          is quite sensitive, it is desirable in general to "mask" it or
  1296.          suppress typeout.  It appears that the server has no foolproof
  1297.          way to achieve this.  It is therefore the responsibility of the
  1298.          user-FTP process to hide the sensitive password information.
  1299.  
  1300.       ACCOUNT (ACCT)
  1301.  
  1302.          The argument field is a TELNET string identifying the user's
  1303.          account.  The command is not necessarily related to the USER
  1304.          command, as some sites may require an account for login and
  1305.          others only for specific access, such as storing files.  In the
  1306.          latter case the command may arrive at any time.  There are two
  1307.          reply codes to differentiate these cases for the automaton:
  1308.          when account information is required for login, the response to
  1309.          a successful PASSword command is reply code 331; then if a
  1310.          command other than ACCounT is sent, the server may remember it
  1311.          and return a 331 reply, prepared to act on the command after
  1312.          the account information is received; or he may flush the
  1313.          command and return a 433 reply asking for the account.  On the
  1314.          other hand, if account information is NOT required for login,
  1315.          the reply to a successful PASSword command is 230; and if the
  1316.  
  1317.  
  1318.                                    22
  1319.  
  1320.                                                   File Transfer Protocol
  1321.                                                          (Aug. 12, 1973)
  1322.                                                        RFC 542 NIC 17759
  1323.  
  1324.  
  1325.          information is needed for a command issued later in the
  1326.          dialogue, the server should return a 331 or 433 reply depending
  1327.          on whether he stores (pending receipt of the ACCounT command)
  1328.          or discards the command, respectively.
  1329.  
  1330.       REINITIALIZE (REIN)
  1331.  
  1332.          This command terminates a USER, flushing all I/O and account
  1333.          information, except to allow any transfer in progress to be
  1334.          completed.  All parameters are reset to the default settings
  1335.          and the TELNET connection is left open.  This is identical to
  1336.          the state in which a user finds himself immediately after the
  1337.          ICP is completed and the TELNET connections are opened.  A USER
  1338.          command may be expected to follow.
  1339.  
  1340.       LOGOUT (BYE)
  1341.  
  1342.          This command terminates a USER and if file transfer is not in
  1343.          progress, the server closes the TELNET connection.  If file
  1344.          transfer is in progress, the connection will remain open for
  1345.          result response and the server will then close it.  If the
  1346.          user-process is transferring files for several USERs but does
  1347.          not wish to close and then reopen connections for each, then
  1348.          the REIN command should be used instead of BYE.
  1349.  
  1350.          An unexpected close on the TELNET connection will cause the
  1351.          server to take the effective action of an abort (ABOR) and a
  1352.          logout (BYE).
  1353.  
  1354.    TRANSFER PARAMETER COMMANDS
  1355.  
  1356.    All data transfer parameters have default values, and the commands
  1357.    specifying data transfer parameters are required only if the default
  1358.    parameter values are to be changed.  The default value is the last
  1359.    specified value, or if no value has been specified, the standard
  1360.    default value as stated here.  This implies that the server must
  1361.    "remember" the applicable default values.  The commands may be in any
  1362.    order except that they must precede the FTP service request.  The
  1363.    following commands specify data transfer parameters.
  1364.  
  1365.       BYTE SIZE (BYTE)
  1366.  
  1367.          The argument is a decimal integer (1 through 255) specifying
  1368.          the byte size for the data connection.  The default byte size
  1369.          is 8 bits.  A server may reject certain byte sizes that he has
  1370.          not implemented.
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.                                    23
  1377.  
  1378.                                                   File Transfer Protocol
  1379.                                                          (Aug. 12, 1973)
  1380.                                                        RFC 542 NIC 17759
  1381.                                                                         
  1382.                                                                         
  1383.       DATA SOCKET (SOCK)
  1384.  
  1385.          The argument is a HOST-SOCKET specification for the data socket
  1386.          to be used in data connection.  There may be two data sockets,
  1387.          one for transfer from the "active" DTP to the "passive" DTP and
  1388.          one for "passive" to "active".  An odd socket number defines a
  1389.          send socket and an even socket number defines a receive socket.
  1390.          The default HOST is the user Host to which TELNET connections
  1391.          are made.  The default data sockets are (U+4) and (U+5) where U
  1392.          is the socket number used in the TELNET ICP and the TELNET
  1393.          connections are on sockets (U+2) and (U+3).  The server has
  1394.          fixed data sockets (S+2) and (S+3) as well, and under normal
  1395.          circimstances this command and its reply are not needed.
  1396.  
  1397.       PASSIVE (PASV)
  1398.  
  1399.          This command requests the server-DTP to "listen" on both of his
  1400.          data sockets and to wait for an RFC to arrive for one socket
  1401.          rather than initiate one upon receipt of a transfer command.
  1402.          It is assumed the server has already received a SOCK command to
  1403.          indicate the foreign socket from which the RFC will arrive to
  1404.          ensure the security of the transfer.
  1405.  
  1406.       REPRESENTATION TYPE (TYPE)
  1407.  
  1408.          The argument specifies the representation type as described in
  1409.          the Section on Data Representation and Storage.  Several types
  1410.          take a second parameter.  The first parameter is denoted by a
  1411.          single TELNET character, as is the second Format parameter for
  1412.          ASCII and EBCDIC; the second parameter for local byte is a
  1413.          decimal integer to indicate Bytesize.  The parameters are
  1414.          separated by a <SP> (Space, ASCII code 32.).  The following
  1415.          codes are assigned for type:
  1416.  
  1417.             
  1418.                       \    /
  1419.             A - ASCII !    ! N - Non-print
  1420.                       !-><-! T - TELNET format effectors
  1421.             E - EBCDIC!    ! C - Carriage Control (ASA)
  1422.                       /    \
  1423.             I - Image
  1424.             
  1425.             L # - Local byte Bytesize
  1426.             
  1427.             
  1428.  
  1429.          The default representation type is ASCII Non-print.  If the
  1430.          Format parameter is changed, and later just the first argument
  1431.          is changed, Format then returns to the Non-print default.
  1432.  
  1433.  
  1434.                                    24
  1435.  
  1436.                                                   File Transfer Protocol
  1437.                                                          (Aug. 12, 1973)
  1438.                                                        RFC 542 NIC 17759
  1439.                                                                         
  1440.                                                                         
  1441.       FILE STRUCTURE (STRU)
  1442.  
  1443.          The argument is a single TELNET character code specifying file
  1444.          structure described in the Section on Data Representation and
  1445.          Storage.  The following codes are assigned for structure:
  1446.  
  1447.             F - File (no record structure)
  1448.             R - Record structure
  1449.  
  1450.          The default structure is File  (i.e., no records).
  1451.  
  1452.       TRANSFER MODE (MODE)
  1453.  
  1454.          The argument is a single TELNET character code specifying the
  1455.          data transfer modes described in the Section on Transmission
  1456.          Modes.  The following codes are assigned for transfer modes:
  1457.  
  1458.             S - Stream
  1459.             B - Block
  1460.             C - Compressed
  1461.  
  1462.          The default transfer mode is Stream.
  1463.  
  1464.    FTP SERVICE COMMANDS
  1465.  
  1466.    The FTP service commands define the file transfer or the file system
  1467.    function requested by the user.  The argument of an FTP service
  1468.    command will normally be a pathname.  The syntax of pathnames must
  1469.    conform to server site conventions (with standard defaults
  1470.    applicable), and the language conventions of the TELNET connection.
  1471.    The suggested default handling is to use the last specified device,
  1472.    directory or file name, or the standard default defined for local
  1473.    users.  The commands may be in any order except that a "rename from"
  1474.    command must be followed by a "rename to" command and the restart
  1475.    command must be followed by the interrupted service command.  The
  1476.    data, when transferred in response to FTP service commands, shall
  1477.    always be sent over the data connection, except for certain
  1478.    informative replies.  The following commands specify FTP service
  1479.    requests:
  1480.  
  1481.       RETRIEVE (RETR)
  1482.  
  1483.          This command causes the server-DTP to transfer a copy of the
  1484.          file, specified in the pathname, to the server- or user-DTP at
  1485.          the other end of the data connection.  The status and contents
  1486.          of the file at the server site shall be unaffected.
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.                                    25
  1493.  
  1494.                                                   File Transfer Protocol
  1495.                                                          (Aug. 12, 1973)
  1496.                                                        RFC 542 NIC 17759
  1497.                                                                         
  1498.                                                                         
  1499.       STORE (STOR)
  1500.  
  1501.          This command causes the server-DTP to accept the data
  1502.          transferred via the data connection and to store the data as a
  1503.          file at the server site.  If the file specified in the pathname
  1504.          exists at the server site then its contents shall be replaced
  1505.          by the data being transferred.  A new file is created at the
  1506.          server site if the file specified in the pathname does not
  1507.          already exist.
  1508.  
  1509.       APPEND (with create) (APPE)
  1510.  
  1511.          This command causes the server-DTP to accept the data
  1512.          transferred via the data connection and to store the data in a
  1513.          file at the server site.  If the file specified in the pathname
  1514.          exists at the server site, then the data shall be appended to
  1515.          that file; otherwise the file specified in the pathname shall
  1516.          be created at the server site.
  1517.  
  1518.       ALLOCATE (ALLO)
  1519.  
  1520.          This command may be required by some servers to reserve
  1521.          sufficient storage to accommodate the new file to be
  1522.          transferred.  The argument shall be a decimal integer
  1523.          representing the number of bytes (using the logical byte size)
  1524.          of storage to be reserved for the file.  For files sent with
  1525.          record structure a maximum record size (in logical bytes) might
  1526.          also be necessary; this is indicated by a decimal integer in a
  1527.          second argument field of the command.  This second argument is
  1528.          optional, but when present should be separated from the first
  1529.          by the three TELNET characters <SP> R <SP>.  This command shall
  1530.          be followed by a STORe or APPEnd command.  The ALLO command
  1531.          should be treated as a NOOP (no operation) by those servers
  1532.          which do not require that the maximum size of the file be
  1533.          declared beforehand, and those servers interested in only the
  1534.          maximum record size should accept a dummy value in the first
  1535.          argument and ignore it.
  1536.  
  1537.       RESTART (REST)
  1538.  
  1539.          The argument field represents the server marker at which file
  1540.          transfer is to be restarted.  This command does not cause file
  1541.          transfer but "spaces" over the file to the specified data
  1542.          checkpoint.  This command shall be immediately followed by the
  1543.          appropriate FTP service command which shall cause file transfer
  1544.          to resume.
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.                                    26
  1551.  
  1552.                                                   File Transfer Protocol
  1553.                                                          (Aug. 12, 1973)
  1554.                                                        RFC 542 NIC 17759
  1555.                                                                         
  1556.                                                                         
  1557.       RENAME FROM (RNFR)
  1558.  
  1559.          This command specifies the file which is to be renamed.  This
  1560.          command must be immediately followed by a "rename to" command
  1561.          specifying the new file pathname.
  1562.  
  1563.       RENAME TO (RNTO)
  1564.  
  1565.          This command specifies the new pathname of the file specified
  1566.          in the immediately preceding "rename from" command.  Together
  1567.          the two commands cause a file to be renamed.
  1568.  
  1569.       ABORT (ABOR)
  1570.  
  1571.          This command indicates to the server to abort the previous FTP
  1572.          service command and any associated transfer of data.  The abort
  1573.          command may require "special action", as discussed in the
  1574.          Section on FTP Commands, to force recognition by the server.
  1575.          No action is to be taken if the previous command has been
  1576.          completed (including data transfer).  The TELNET connections
  1577.          are not to be closed by the server, but the data connection
  1578.          must be closed.  An appropriate reply should be sent by the
  1579.          server in all cases.
  1580.  
  1581.       DELETE (DELE)
  1582.  
  1583.          This command causes the file specified in the pathname to be
  1584.          deleted at the server site.  If an extra level of protection is
  1585.          desired (such as the query, "DO you really wish to delete?"),
  1586.          it should be provided by the user-FTP process.
  1587.  
  1588.       LIST (LIST)
  1589.  
  1590.          This command causes a list to be sent from the server to the
  1591.          passive DTP.  If the pathname specifies a directory, the server
  1592.          should transfer a list of files in the specified directory.  If
  1593.          the pathname specifies a file then the server should send
  1594.          current information on the file.  A null argument implies the
  1595.          user's current working or default directory.  The data transfer
  1596.          is over the data connection in type ASCII or type EBCDIC.  (The
  1597.          user must ensure that the TYPE is appropriately ASCII or
  1598.          EBCDIC).
  1599.  
  1600.       NAME-LIST (NLST)
  1601.  
  1602.          This command causes a directory listing to be sent from server
  1603.          to user site.  The pathname should specify a directory or other
  1604.          system-specific file group descriptor; a null argument implies
  1605.          the current directory.  The server will return a stream of
  1606.  
  1607.  
  1608.                                    27
  1609.  
  1610.                                                   File Transfer Protocol
  1611.                                                          (Aug. 12, 1973)
  1612.                                                        RFC 542 NIC 17759
  1613.                                                                         
  1614.                                                                         
  1615.          names of files and no other information.  The data will be
  1616.          transferred in ASCII or EBCDIC type over the data connection as
  1617.          valid pathname strings separated by <CRLF> or <NL>.  (Again the
  1618.          user must ensure that the TYPE is correct.)
  1619.  
  1620.       SITE PARAMETERS (SITE)
  1621.  
  1622.          This command is used by the server to provide services specific
  1623.          to his system that are essential to file transfer but not
  1624.          sufficiently universal to be included as commands in the
  1625.          protocol.  The nature of these services and the specification
  1626.          of their syntax can be stated in a reply to the HELP SITE
  1627.          command.
  1628.  
  1629.       STATUS (STAT)
  1630.  
  1631.          This command shall cause a status response to be sent over the
  1632.          TELNET connection in the form of a reply.  The command may be
  1633.          sent during a file transfer (along with the TELNET IP and Synch
  1634.          signals--see the Section on FTP Commands) in which case the
  1635.          server will respond with the status of the operation in
  1636.          progress, or it may be sent between file transfers.  In the
  1637.          latter case the command may have an argument field.  If the
  1638.          argument is a pathname, the command is analogous to the "list"
  1639.          command except that data shall be trasferred over the TELNET
  1640.          connection.  If a partial pathname is given, the server may
  1641.          respond with a list of file names or attributes associated with
  1642.          that specification.  If no argument is given, the server should
  1643.          return general status information about the server FTP process.
  1644.          This should include current values of all transfer parameters
  1645.          and the status of connections.
  1646.  
  1647.       HELP (HELP)
  1648.  
  1649.          This command shall cause the server to send helpful information
  1650.          regarding its implementation status over the TELNET connection
  1651.          to the user.  The command may take an argument (e.g., any
  1652.          command name) and return more specific information as a
  1653.          response.  The reply is type Oxx, general system status.  It is
  1654.          suggested that HELP be allowed before entering a USER command.
  1655.          The server may use this reply to specify site-dependent
  1656.          parameters, e.g., in response to HELP SITE.
  1657.  
  1658.       NOOP (NOOP)
  1659.  
  1660.          This command does not affect any parameters or previously
  1661.          entered commands. It specifies no action other than that the
  1662.          server send a 200 reply.
  1663.  
  1664.  
  1665.  
  1666.                                    28
  1667.  
  1668.                                                   File Transfer Protocol
  1669.                                                          (Aug. 12, 1973)
  1670.                                                        RFC 542 NIC 17759
  1671.                                                                         
  1672.                                                                         
  1673.    MISCELLANEOUS COMMANDS
  1674.  
  1675.    There are several functions that utilize the services of file
  1676.    transfer but go beyond it in scope.  These are the Mail and Remote
  1677.    Job Entry functions.  It is suggested that these become auxiliary
  1678.    protocols that can assume recognition of file transfer commands on
  1679.    the part of the server, i.e., they may depend on the core of FTP
  1680.    commands.  The command sets specific to Mail and RJE will be given in
  1681.    separate documents.
  1682.  
  1683.    Commands that are closely related to file transfer but not proven
  1684.    essential to the protocol may be implemented by servers on an
  1685.    experimental basis.  The command name should begin with an X and may
  1686.    be listed in the HELP command.  The official command set is
  1687.    expandable from these experiments; all experimental commands or
  1688.    proposals for expanding the official command set should be announced
  1689.    via RFC.  An example of a current experimental command is:
  1690.  
  1691.       Change Working Directory (XCWD)
  1692.  
  1693.          This command allows the user to work with a different directory
  1694.          or dataset for file storage or retrieval without altering his
  1695.          login or accounting information.  Transfer parameters are
  1696.          similarly unchanged.  The argument is a pathname specifying a
  1697.          directory or other system dependent file group designator.
  1698.  
  1699.    FTP REPLIES
  1700.  
  1701.    The server sends FTP replies over the TELNET connection in response
  1702.    to user FTP commands.  The FTP replies constitute the acknowledgment
  1703.    or completion code (including errors).  The FTP-server replies are
  1704.    formatted for human or program interpretation.  Single line replies
  1705.    consist of a leading three-digit numeric code followed by a space,
  1706.    followed by a one-line text explanation of the code.  For replies
  1707.    that contain several lines of text, the first line will have a
  1708.    leading three-digit numeric code followed immediately by the
  1709.    character "-" (Hyphen, ASCII code 45), and possibly some text.  All
  1710.    succeeding continuation lines except the last are constrained NOT to
  1711.    begin with three digits; the last line must repeat the numeric code
  1712.    of the first line and be followed immediately by a space.  For
  1713.    example:
  1714.  
  1715.       100-First Line
  1716.       Continuation Line
  1717.       Another Line
  1718.       100 Last Line
  1719.  
  1720.    It is possible to nest (but not overlap) a reply withiin a multi-line
  1721.  
  1722.  
  1723.  
  1724.                                    29
  1725.  
  1726.                                                   File Transfer Protocol
  1727.                                                          (Aug. 12, 1973)
  1728.                                                        RFC 542 NIC 17759
  1729.                                                                         
  1730.                                                                         
  1731.    reply.  The same format for matched number-coded first and last lines
  1732.    holds.
  1733.  
  1734.    The numeric codes are assigned by groups and for ease of
  1735.    interpretation by programs in a manner consistent with other
  1736.    protocols such as the RJE protocol.  The three digits of the code are
  1737.    to be interpreted as follows:
  1738.  
  1739.       1. The first digit specifies type of response as indicated below:
  1740.  
  1741.          0xx  These replies are purely informative and constitute
  1742.               neither a positive nor a negative acknowledgment.
  1743.  
  1744.          1xx  Informative replies to status inquiries.  These constitute
  1745.               a positive acknowledgment to the status command.
  1746.  
  1747.          2xx  Positive acknowledgment of previous command or other
  1748.               successful action.
  1749.  
  1750.          3xx  Incomplete information.  Activity cannot proceed without
  1751.               further specification and input.
  1752.  
  1753.          4xx  Unsuccessful reply.  The request is correctly specified
  1754.               but the server is unsuccessful in correctly fulfilling it.
  1755.  
  1756.          5xx  Incorrect or illegal command.  The command or its
  1757.               parameters were invalid or incomplete from a syntactic
  1758.               viewpoint, or the command is inconsistent with a previous
  1759.               command.  The command in question has been completely
  1760.               ignored.
  1761.  
  1762.          6xx-9xx  Reserved for future expansion.
  1763.  
  1764.       2. The second digit specifies the general category to which the
  1765.          response refers:
  1766.  
  1767.          x00-x29  General purpose replies, not assignable to other
  1768.               categories.
  1769.  
  1770.          x3x  Primary access.  Informative replies to the "log-on"
  1771.               attempt.
  1772.  
  1773.          x4x  Secondary access.  The primary server is commenting on its
  1774.               ability to access a secondary service.
  1775.  
  1776.          x5x  FTP results.
  1777.  
  1778.          x6x  RJE results.
  1779.  
  1780.  
  1781.  
  1782.                                    30
  1783.  
  1784.                                                   File Transfer Protocol
  1785.                                                          (Aug. 12, 1973)
  1786.                                                        RFC 542 NIC 17759
  1787.                                                                         
  1788.                                                                         
  1789.          x7x  Mail Portocol results.
  1790.  
  1791.          x8x-x9x  Reserved for future expansion.
  1792.  
  1793.       3. The final digit specifies a particular message type.  Since the
  1794.          code is designed for an automaton process to interpret, it is
  1795.          not necessary for every variation of a reply to have a unique
  1796.          number.  Only the basic meaning of replies need have unique
  1797.          numbers.  The text of a reply can explain the specific reason
  1798.          for that reply to a human user.
  1799.  
  1800.    Each TELNET line delimited by a numeric code and the TELNET EOL (or
  1801.    group of text lines bounded by coded lines) that is sent by the
  1802.    server is intended to be a complete reply message. It should be noted
  1803.    that the text of replies is intended for a human user. Only the reply
  1804.    codes and in some instances the first line of text are intended for
  1805.    programs.
  1806.  
  1807.    The assigned reply codes relating to FTP are:
  1808.  
  1809.    000  Announcing FTP.
  1810.    010  Message from system operator.
  1811.    020  Exected delay.
  1812.    030  Server availability information.
  1813.    050  FTP commentary or user information.
  1814.    100  System status reply.
  1815.    110  System busy doing...
  1816.    150  File status reply.
  1817.    151  Directory listing reply.
  1818.    200  Last command received correctly.
  1819.    201  An ABORT has terminated activity, as requested.
  1820.    202  Abort request ignored, no activity in progress.
  1821.    230  User is "logged in".  May proceed.
  1822.    231  User is "logged out".  Service terminated.
  1823.    232  Logout command noted, will complete when transfer done.
  1824.    233  User is "logged out".  Parameters reinitialized.
  1825.    250  FTP file transfer started correctly.
  1826.    251  FTP Restart-marker reply.
  1827.       Text is:  MARK yyyy = mmmm
  1828.          where 'yyyy' is user's data stream marker (yours)
  1829.          and mmmm is server's equivalent marker (mine)
  1830.       (Note the spaces between the markers and '=').
  1831.    252  FTP transfer completed correctly.
  1832.    253  Rename completed.
  1833.    254  Delete completed.
  1834.    257  Closing the data connection, transfer completed.
  1835.    300  Connection greeting message, awaiting input.
  1836.    301  Current command incomplete (no <CRLF> for long time).
  1837.    330  Enter password.
  1838.  
  1839.  
  1840.                                    31
  1841.  
  1842.                                                   File Transfer Protocol
  1843.                                                          (Aug. 12, 1973)
  1844.                                                        RFC 542 NIC 17759
  1845.                                                                         
  1846.                                                                         
  1847.    331  Enter account (if account required as part of login sequence).
  1848.    332  Login first, please.
  1849.    400  This service not implemented.
  1850.    401  This service not accepting users now, goodbye.
  1851.    402  Command not implemented for requested value or action.
  1852.    430  Log-on time or tries exceeded, goodbye.
  1853.    431  Log-on unsuccessful.  User and/or password invalid.
  1854.    432  User not valid for this service.
  1855.    433  Cannot transfer files without valid account.  Enter account and
  1856.         resend command.
  1857.    434  Log-out forced by operator action.  Phone site.
  1858.    435  Log-out forced by system problem.
  1859.    436  Service shutting down, goodbye.
  1860.    450  FTP:  File not found.
  1861.    451  FTP:  File access denied to you.
  1862.    452  FTP:  File transfer incomplete, data connection closed.
  1863.    453  FTP:  File transfer incomplete, insufficient storage space.
  1864.    454  FTP:  Cannot connect to your data socket.
  1865.    455  FTP:  File system error not covered by other reply codes.
  1866.    456  FTP:  Name duplication; rename failed.
  1867.    457  FTP:  Transfer parameters in error.
  1868.    500  Last command line completely unrecognized.
  1869.    501  Syntax of last command is incorrect.
  1870.    502  Last command incomplete, parameters missing.
  1871.    503  Last command invalid (ignored), illegal parameter combination.
  1872.    504  Last command invalid, action not possible at this time.
  1873.    505  Last command conflicts illegally with previous command(s).
  1874.    506  Last command not implemented by the server.
  1875.    507  Catchall error reply.
  1876.    550  Bad pathname specification (e.g., syntax error).
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.                                    32
  1899.  
  1900.                                                   File Transfer Protocol
  1901.                                                          (Aug. 12, 1973)
  1902.                                                        RFC 542 NIC 17759
  1903.                                                                         
  1904.                                                                         
  1905. DECLARATIVE SPECIFICATIONS
  1906.  
  1907.    MINIMUM IMPLEMENTATION
  1908.  
  1909.    In order to make FTP workable without needless error messages, the
  1910.    following minimum implementation is required for servers:
  1911.  
  1912.       
  1913.       TYPE - ASCII Non-print
  1914.       MODE - Stream
  1915.       STRUCTURE - File
  1916.                   Record
  1917.       BYTE - 8
  1918.       COMMANDS - USER, BYE, SOCK,
  1919.                  TYPE, BYTE, MODE, STRU,
  1920.                    for the default values
  1921.                  RETR, STOR,
  1922.                  NOOP.
  1923.       
  1924.  
  1925.    The initial default values for transfer parameters are:
  1926.  
  1927.       
  1928.       TYPE - ASCII Non-print
  1929.       BYTE - 8
  1930.       MODE - Stream
  1931.       STRU - File
  1932.       
  1933.  
  1934.    All Hosts must accept the above as the standard defaults.
  1935.  
  1936.    CONNECTIONS
  1937.  
  1938.    The server protocol interpreter shall "listen" on Socket 3.  The user
  1939.    or user protocol interpreter shall initiate the full-duplex TELNET
  1940.    connections performing the ARPANET standard initial connection
  1941.    protocol (ICP) to server Socket 3.  Server- and user- processes
  1942.    should follow the conventions of the TELNET protocol as specified in
  1943.    NIC #7104.  Servers are under no obligation to provide for editing of
  1944.    command lines and may specify that it be done in the user Host.  The
  1945.    TELNET connections shall be closed by the server at the user's
  1946.    request after all transfers and replies are completed.
  1947.  
  1948.    The user-DTP must "listen" on the specified data sockets (send and/or
  1949.    receive); these may be the default user sockets (U+4) and (U+5) or a
  1950.    socket specified in the SOCK command.  The server shall initiate the
  1951.    data connection from his own fixed sockets (S+2) and (S+3) using the
  1952.    specified user data socket and byte size (default - 8 bits).  The
  1953.  
  1954.  
  1955.  
  1956.                                    33
  1957.  
  1958.                                                   File Transfer Protocol
  1959.                                                          (Aug. 12, 1973)
  1960.                                                        RFC 542 NIC 17759
  1961.                                                                         
  1962.                                                                         
  1963.    direction of the transfer and the sockets used will be determined by
  1964.    the FTP service command.
  1965.  
  1966.    When data is to be transferred between two servers, A and B (refer to
  1967.    Figure 2), the user-PI, C, sets up TELNET connections with both
  1968.    server-PI's.  He then sends A's fixed sockets, S(A), to B in a SOCK
  1969.    command and B's to A; replies are returned.  One of the servers, say
  1970.    A, is then sent a PASV command telling him to "listen" on his data
  1971.    sockets rather than initiate an RFC when he receives a transfer
  1972.    service command.  When the user-PI receives an acknowledgment to the
  1973.    PASV command, he may send (in either order) the corresponding service
  1974.    commands to A and B.  Server B initiates the RFC and the transfer
  1975.    proceeds.  The command-reply sequence is listed below where the
  1976.    messages are vertically synchronous but horizontally asynchronous:
  1977.  
  1978.       User-PI - Server A                User-PI - Server B
  1979.       ------------------                ------------------
  1980.       
  1981.       C->A : ICP                        C->B : ICP
  1982.       C->A : SOCK HOST-B, SKT-S(B)      C->B : SOCK HOST-A, SKT-S(A)
  1983.       A->C : 200 Okay                   B->C : 200 Okay
  1984.       C->A : PASV
  1985.       A->C : 200 Okay
  1986.       C->A : STOR                       C->B : RETR
  1987.       
  1988.  
  1989.    The data connection shall be closed by the server under the
  1990.    conditions described in the Section on Establishing Data Connections.
  1991.    If the server wishes to close the connection after a transfer where
  1992.    it is not required, he should do so immediately after the file
  1993.    transfer is completed.  He should not wait until after a new transfer
  1994.    command is received because the user-process will have already tested
  1995.    the data connection to see if it needs to do a "listen"; (recall that
  1996.    the user must "listen" on a closed data socket BEFORE sending the
  1997.    transfer request).  To prevent a race condition here, the server
  1998.    sends a secondary reply (257) after closing the data connection (or
  1999.    if the connection is left open, a "file transfer completed" reply
  2000.    (252) and the user-PI should wait for one of these replies before
  2001.    issuing a new transfer command.
  2002.  
  2003.    COMMANDS
  2004.  
  2005.    The commands are TELNET character string transmitted over the TELNET
  2006.    connections as described in the Section on FTP Commands.  The command
  2007.    functions and semantics are described in the Section on Access
  2008.    Control Commands, Transfer Parameter Commands, FTP Service Commands,
  2009.    and Miscellaneous Commands.  The command syntax is specified here.
  2010.  
  2011.    The commands begin with a command code followed by an argument field.
  2012.  
  2013.  
  2014.                                    34
  2015.  
  2016.                                                   File Transfer Protocol
  2017.                                                          (Aug. 12, 1973)
  2018.                                                        RFC 542 NIC 17759
  2019.                                                                         
  2020.                                                                         
  2021.    The command codes are four or fewer alphabetic characters.  Upper and
  2022.    lower case alphabetic characters are to be treated identically.  Thus
  2023.    any of the following may represent the retrieve command:
  2024.  
  2025.       RETR    Retr    retr    ReTr    rETr
  2026.  
  2027.    This also applies to any symbols representing parameter values, such
  2028.    as A or a for ASCII TYPE.  The command codes and the argument fields
  2029.    are separated by one or more spaces.
  2030.  
  2031.    The argument field consists of a variable length character string
  2032.    ending with the character sequence <CRLF> (Carriage Return, Linefeed)
  2033.    for NVT-ASCII representation; for other negotiated languages a
  2034.    different end of line character might be used.  It should be noted
  2035.    that the server is to take NO action until the end of line code is
  2036.    received.
  2037.  
  2038.    The syntax is specified below in NVT-ASCII.  All characters in the
  2039.    argument field are ASCII characters including any ASCII represented
  2040.    decimal integers.  Square brackets denote an optional argument field.
  2041.    If the option is not taken, the appropriate default is implied.
  2042.  
  2043.    The following are all the currently defined FTP commmands:
  2044.  
  2045.       USER <SP> <username> <CRLF>
  2046.       PASS <SP> <password> <CRLF>
  2047.       ACCT <SP> <acctno> <CRLF>
  2048.       REIN <CRLF>
  2049.       BYE <CRLF>
  2050.       BYTE <SP> <byte size> <CRLF>
  2051.       SOCK <SP> <Host-socket> <CRLF>
  2052.       PASV <CRLF>
  2053.       TYPE <SP> <type code> <CRLF>
  2054.       STRU <SP> <structure code> <CRLF>
  2055.       MODE <SP> <mode code> <CRLF>
  2056.       RETR <SP> <pathname> <CRLF>
  2057.       STOR <SP> <pathname> <CRLF>
  2058.       APPE <SP> <pathname> <CRLF>
  2059.       ALLO <SP> <decimal integer> [<SP> R <SP> <decimal integer>] <CRLF>
  2060.       REST <SP> <marker> <CRLF>
  2061.       RNFR <SP> <pathname> <CRLF>
  2062.       RNTO <SP> <pathname> <CRLF>
  2063.       ABOR <CRLF>
  2064.       DELE <SP> <pathname> <CRLF>
  2065.       LIST [<SP> <pathname>] <CRLF>
  2066.       NLST  [<SP> <pathname>] <CRLF>
  2067.       SITE <SP> <string> <CRLF>
  2068.       STAT [<SP> <pathname>] <CRLF>
  2069.       HELP [<SP> <string>] <CRLF>
  2070.  
  2071.  
  2072.                                    35
  2073.  
  2074.                                                   File Transfer Protocol
  2075.                                                          (Aug. 12, 1973)
  2076.                                                        RFC 542 NIC 17759
  2077.                                                                         
  2078.                                                                         
  2079.       NOOP <CRLF>
  2080.  
  2081.    The syntax of the above argument fields (using BNF notation where
  2082.    applicable ) is:
  2083.  
  2084.       <username> ::= <string>
  2085.       <password> ::= <string>
  2086.       <acctno> ::= <string>
  2087.       <string> ::= <char>|<char><string>
  2088.       <char> ::= any of the 128 ASCII characters except <CR> and <LF>
  2089.       <marker> ::= <pr string>
  2090.       <pr string> ::= <pr char>|<pr char><pr string>
  2091.       <pr char> ::= any ASCII code 33. through 126., printable
  2092.          characters
  2093.       <byte size> ::= any decimal integer 1 through 255
  2094.       <Host-socket> ::= <socket>|<Host number>, <socket>
  2095.       <Host-number> ::= a decimal integer specifying an ARPANET Host.
  2096.       <socket> ::= decimal integer between 0 and (2**32)-1
  2097.       <form code> ::= N|T|C
  2098.       <type code> ::= A[<SP> <form code>]|E [SP> <form code>]|I|
  2099.       L <SP> <byte size>
  2100.       <structure code> ::= F|R
  2101.       <mode code> ::= S|B|C
  2102.       <pathname> ::= <string>
  2103.  
  2104.    SEQUENCING OF COMMANDS AND REPLIES
  2105.  
  2106.    The communication between the user and server is intended to be an
  2107.    alternating dialogue.  As such, the user issues an FTP command and
  2108.    the server responds with a prompt primary reply.  The user should
  2109.    wait for this initial primary success or failure response before
  2110.    sending further commands.
  2111.  
  2112.    Certain commands require a second reply for which the user should
  2113.    also wait.  These replies may, for example, report on the progress or
  2114.    completion of file transfer or the closing of the data connection.
  2115.    They are secondary replies to file transfer commands.
  2116.  
  2117.    The third class of replies are informational and spontaneous replies
  2118.    which may arrive at any time.  The user-PI should be prepared to
  2119.    receive them.  These replies are listed below as sponteneous.
  2120.  
  2121.    One important group of spontaneous replies is the connection
  2122.    greetings.  Under normal circumstances, a server will send a 300
  2123.    reply, "awaiting input", when the ICP is completed.  The user should
  2124.    wait for this greeting message before sending any commands.  If the
  2125.    server is unable to accept input right away, he should send a 000
  2126.    "announcing FTP" or a 020 "expected delay" reply immediately and a
  2127.  
  2128.  
  2129.  
  2130.                                    36
  2131.  
  2132.                                                   File Transfer Protocol
  2133.                                                          (Aug. 12, 1973)
  2134.                                                        RFC 542 NIC 17759
  2135.                                                                         
  2136.                                                                         
  2137.    300 reply when ready.  The user will then know not to hang up if
  2138.    there is a delay.
  2139.  
  2140.    The table below lists alternative success and failure replies for
  2141.    each command.  These must be strictly adhered to; a server may
  2142.    substitute text in the replies, but the meaning and action implied by
  2143.    the code numbers and by the specific command reply sequence cannot be
  2144.    altered.
  2145.  
  2146.                    COMMAND-REPLY CORRESPONDENCE TABLE
  2147.  
  2148.    COMMAND             SUCCESS         FAILURE
  2149.  
  2150.    USER                230,330         430-432,500-505,507
  2151.    PASS                230,330         430-432,500-507
  2152.    ACCT                230             430-432,500-507
  2153.    REIN                232,233         401,436,500-507
  2154.       Secondary Reply  300
  2155.    BYE                 231,232         500-505,507
  2156.    BYTE                200,331         402,500-505,507
  2157.    SOCK                200,331         500-505,507
  2158.    PASV                200,331         500-507
  2159.    TYPE                200,331         402,500-505,507
  2160.    STRU                200,331         500-505,507
  2161.    MODE                200,331         402,500-505,507
  2162.    RETR                250             402,433,450,451,454,455,457,
  2163.                                          500-505,507,550
  2164.       Secondary Reply  252,257         452
  2165.    STOR                250             402,433,451,454,455,457,
  2166.                                          500-505,507,550
  2167.       Secondary Reply  252,257         452,453
  2168.    APPE                250             402,433,451,454,455,457,500-507,
  2169.                                          550
  2170.       Secondary Reply  252,257         452,453
  2171.    ALLO                200,331         402,500-507
  2172.    REST                200,331         500-507
  2173.    RNFR                200             402,433,450,451,455,500-507,550
  2174.    RNTO                253             402,433,450,451,455,456,500-507,
  2175.                                          550
  2176.    ABOR                201,202,331     500-507
  2177.    DELE                254             402,433,450,451,455,500-507,550
  2178.    LIST                250             402,433,450,451,454,455,457,
  2179.                                          500-507,550
  2180.       Secondary Reply  252,257         452
  2181.    NLST                250             402,433,450,451,454,455,457,
  2182.                                          500-507,550
  2183.       Secondary Reply  252,257         452
  2184.    SITE                200,331         402,500-507
  2185.  
  2186.  
  2187.                                    37
  2188.  
  2189.                                                   File Transfer Protocol
  2190.                                                          (Aug. 12, 1973)
  2191.                                                        RFC 542 NIC 17759
  2192.                                                                         
  2193.                                                                         
  2194.    STAT                100,110,        450,451,455,500-507,550
  2195.                          150,151,331
  2196.    HELP                030,050         500-507
  2197.    NOOP                200             500-505,507
  2198.    Spontaneous Replies 000,010,020,    400,401,434-436
  2199.                          300,301,251,255
  2200.  
  2201.    TYPICAL FTP SCENARIOS
  2202.  
  2203.    TIP User wanting to transfer file from Host X to local printer:
  2204.  
  2205.       1. TIP user opens TELNET connections by ICP to Host X socket 3.
  2206.  
  2207.       2. The following commands and replies are exchanged:
  2208.  
  2209.          TIP                       HOST X
  2210.  
  2211.          <---------- 300 Awaiting input <CRLF>
  2212.          USER username <CRLF> ---------->
  2213.          <---------- 330 Enter Password <CRLF>
  2214.          PASS password <CRLF> ---------->
  2215.          <---------- 230 User logged in <CRLF>
  2216.          SOCK 65538 <CRLF> ---------->
  2217.          <---------- 200 Commmand received OK<CRLF>
  2218.          RETR this.file <CRLF> ---------->
  2219.             (Host X initiates data connection to TIP socket 65538,
  2220.              i.e., PORT 1 receive)
  2221.          <---------- 250 File transfer started <CRLF>
  2222.          <---------- 252 File transfer completed <CRLF>
  2223.          BYE<CRLF>         ---------->
  2224.          <---------- 231 User logged out <CRLF>
  2225.  
  2226.       3. Host X closes the TELNET and data connections.
  2227.  
  2228.          Note: The TIP user should be in line mode.
  2229.  
  2230.    User at Host U wanting to transfer files to/from Host S:
  2231.  
  2232.    In general the user will communicate to the server via a mediating
  2233.    user-FTP process.  The following may be a typical scenario.  The
  2234.    user-FTP prompts are shown in parentheses, '---->' represents
  2235.    commands from Host U to Host S, and '<----' represents replies from
  2236.    Host S to Host U.
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.                                    38
  2245.  
  2246.                                                   File Transfer Protocol
  2247.                                                          (Aug. 12, 1973)
  2248.                                                        RFC 542 NIC 17759
  2249.                                                                         
  2250.                                                                         
  2251.       LOCAL COMMANDS BY USER              ACTION INVOLVED
  2252.  
  2253.       ftp (host) multics<CR>         ICP to Host S, socket 3,
  2254.                                      establishing TELNET connections
  2255.                                      <---- 330 Awaiting input <CRLF>
  2256.       username Doe <CR>              USER Doe<CRLF>---->
  2257.                                      <---- 330 password<CRLF>
  2258.       password mumble <CR>           PASS mumble<CRLF>---->
  2259.                                      <---- 230 Doe logged in.<CRLF>
  2260.       retrieve (local type) ASCII<CR>
  2261.       (local pathname) test 1 <CR>   User-FTP opens local file in ASCII.
  2262.       (for.pathname) testp11<CR>     RETR test.p11<CRLF> ---->
  2263.                                      Server makes data connection to
  2264.       (U+4)
  2265.                                      <---- 250 File transfer starts
  2266.       <CRLF>
  2267.                                      <---- 252 File transfer
  2268.       complete<CRLF>
  2269.       type Image<CR>                 TYPE I<CRLF> ---->
  2270.                                      <---- 200 Command OK<CRLF>
  2271.       byte 36<CR>                    BYTE 36<CR>LF ---->
  2272.                                      <---- 200 Command OK<CRLF>
  2273.       store (local type) image<CR>
  2274.       (local pathname) file dump<CR> User-FTP opens local file in Image.
  2275.       (for.pathname) >udd>cn>fd<CR>  STOR >udd>cn>fd<CRLF> ---->
  2276.                                      <---- 451 Access denied<CRLF>
  2277.       terminate                      BYE <CRLF> ---->
  2278.                                      Server closes all connections.
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.                                    39