FILE TRANSFER PROTOCOL (FTP)の目次 (概要付き)

はじめに

作成した目次

  • 1. INTRODUCTION

The objectives of FTP are 1) to promote sharing of files (computer programs and/or data), 2) to encourage indirect or implicit (via programs) use of remote computers, 3) to shield a user from variations in file storage systems among hosts, and 4) to transfer data reliably and efficiently.

  • 2. OVERVIEW

In this section, the history, the terminology, and the FTP model are discussed.

FTP has had a long evolution over the years.

    • 2.2. TERMINOLOGY

ASCII The ASCII character set is as defined in the ARPA-Internet Protocol Handbook.

    • 2.3. THE FTP MODEL

With the above definitions in mind, the following model (shown in Figure 1) may be diagrammed for an FTP service.

  • 3. DATA TRANSFER FUNCTIONS

Files are transferred only via the data connection.

    • 3.1. DATA REPRESENTATION AND STORAGE

Data is transferred from a storage device in the sending host to a storage device in the receiving host.

      • 3.1.1. DATA TYPES

Data representations are handled in FTP by a user specifying a representation type.

        • 3.1.1.1. ASCII TYPE

This is the default type and must be accepted by all FTP implementations.

This type is intended for efficient transfer between hosts which use EBCDIC for their internal character representation.

        • 3.1.1.3. IMAGE TYPE

The data are sent as contiguous bits which, for transfer, are packed into the 8-bit transfer bytes.

        • 3.1.1.4. LOCAL TYPE

The data is transferred in logical bytes of the size specified by the obligatory second parameter, Byte size.

        • 3.1.1.5. FORMAT CONTROL

The types ASCII and EBCDIC also take a second (optional) parameter; this is to indicate what kind of vertical format control, if any, is associated with a file.

          • 3.1.1.5.1. NON PRINT

This is the default format to be used if the second (format) parameter is omitted.

          • 3.1.1.5.2. TELNET FORMAT CONTROLS

The file contains ASCII/EBCDIC vertical format controls (i.

          • 3.1.1.5.2. CARRIAGE CONTROL (ASA)

The file contains ASA (FORTRAN) vertical format control characters.

      • 3.1.2. DATA STRUCTURES

In addition to different representation types, FTP allows the structure of a file to be specified.

        • 3.1.2.1. FILE STRUCTURE

File structure is the default to be assumed if the STRUcture command has not been used.

        • 3.1.2.2. RECORD STRUCTURE

Record structures must be accepted for "text" files (i.

        • 3.1.2.3. PAGE STRUCTURE

To transmit files that are discontinuous, FTP defines a page structure.

    • 3.2. ESTABLISHING DATA CONNECTIONS

The mechanics of transferring data consists of setting up the data connection to the appropriate ports and choosing the parameters for transfer.

    • 3.3. DATA CONNECTION MANAGEMENT

Default Data Connection Ports: All FTP implementations must support use of the default data connection ports, and only the User-PI may initiate the use of non-default ports.

    • 3.4. TRANSMISSION MODES

The next consideration in transferring data is choosing the appropriate transmission mode.

      • 3.4.1. STREAM MODE

The data is transmitted as a stream of bytes.

      • 3.4.2. BLOCK MODE

The file is transmitted as a series of data blocks preceded by one or more header bytes.

      • 3.4.3. COMPRESSED MODE

There are three kinds of information to be sent: regular data, sent in a byte string; compressed data, consisting of replications or filler; and control information, sent in a two-byte escape sequence.

    • 3.5. ERROR RECOVERY AND RESTART

There is no provision for detecting bits lost or scrambled in data transfer; this level of error control is handled by the TCP.

  • 4. FILE TRANSFER FUNCTIONS

The communication channel from the user-PI to the server-PI is established as a TCP connection from the user to the standard server port.

    • 4.1. FTP COMMANDS
      • 4.1.1. ACCESS CONTROL COMMANDS

The following commands specify access control identifiers (command codes are shown in parentheses).

      • 4.1.2. TRANSFER PARAMETER COMMANDS

All data transfer parameters have default values, and the commands specifying data transfer parameters are required only if the default parameter values are to be changed.

      • 4.1.3. FTP SERVICE COMMANDS

The FTP service commands define the file transfer or the file system function requested by the user.

    • 4.2. FTP REPLIES

Replies to File Transfer Protocol commands are devised to ensure the synchronization of requests and actions in the process of file transfer, and to guarantee that the user process always knows the state of the Server.

      • 4.2.1 Reply Codes by Function Groups

200 Command okay.

      • 4.2.2 Numeric Order List of Reply Codes

110 Restart marker reply.

  • 5. DECLARATIVE SPECIFICATIONS
    • 5.1. MINIMUM IMPLEMENTATION

In order to make FTP workable without needless error messages, the following minimum implementation is required for all servers: TYPE - ASCII Non-print MODE - Stream STRUCTURE - File, Record COMMANDS - USER, QUIT, PORT, TYPE, MODE, STRU, for the default values RETR, STOR, NOOP.

    • 5.2. CONNECTIONS

The server protocol interpreter shall "listen" on Port L.

    • 5.3. COMMANDS

The commands are Telnet character strings transmitted over the control connections as described in the Section on FTP Commands.

      • 5.3.1. FTP COMMANDS

The following are the FTP commands: USER PASS ACCT CWD CDUP SMNT QUIT REIN PORT PASV TYPE STRU MODE RETR STOR STOU APPE ALLO [ R ] REST RNFR RNTO ABOR DELE RMD MKD PWD LIST [ ] NLST [ ] SITE SYST STAT [ ] HELP [ ] NOOP

      • 5.3.2. FTP COMMAND ARGUMENTS

The syntax of the above argument fields (using BNF notation where applicable) is: ::= ::= ::= ::= | ::= any of the 128 ASCII characters except and ::= ::= | ::= printable characters, any ASCII code 33 through 126 ::= ::= , ::= ,,, ::= , ::= any decimal integer 1 through 255 ::= N | T | C ::= A [ ] | E [ ] | I | L ::= F | R | P ::= S | B | C ::= ::= any decimal integer

    • 5.4. SEQUENCING OF COMMANDS AND REPLIES

The communication between the user and server is intended to be an alternating dialogue.

  • 6. STATE DIAGRAMS

Here we present state diagrams for a very simple minded FTP implementation.

  • 7. TYPICAL FTP SCENARIO

User at host U wanting to transfer files to/from host S: In general, the user will communicate to the server via a mediating user-FTP process.

  • 8. CONNECTION ESTABLISHMENT

The FTP control connection is established via TCP between the user process port U and the server process port L.

作り方

  1. http://tools.ietf.org/html/rfc959のテキストをエディタ(今回はサクラエディタ)にコピーする。
  2. 下記のマクロを実行する。
  3. 手作業で不要な行を削除する。
マクロ
//ページヘッダを取り除く
S_ReplaceAll('^Postel.*\r\n', '', 30);
S_ReplaceAll('^ \r\n', '', 30);
S_ReplaceAll('^RFC.*\r\n', '', 30);
S_ReplaceAll('^File.*\r\n', '', 30);
//セクションと内容をタブ区切りの一覧にする。
S_ReplaceAll('^( *\d\.[^\r]*)', '#\r\n#\1\t', 30);
S_ReplaceAll('^ *', '', 30);
S_ReplaceAll('^([^#][^\r]*)\r', '\1 \r', 30);
S_ReplaceAll('^\r\n', '', 30);
S_ReplaceAll('([^#])\r\n', '\1', 30);
//内容を先頭文のみにする。
S_ReplaceAll('(\d)\.', '\1\$', 30);
S_ReplaceAll('\.', '.\r\n', 30);
S_ReplaceAll('^[^#].*\r\n', '', 30);
S_ReplaceAll('#', '', 30);
S_ReplaceAll('\$', '.', 30);
//セクションをリスト記法にする。
S_ReplaceAll('^', '-', 30);
S_ReplaceAll('^- {3}', '--', 30);
S_ReplaceAll('^-- {3}', '---', 30);
S_ReplaceAll('^--- {3}', '----', 30);
S_ReplaceAll('^---- {3}', '-----', 30);
//内容を引用記法にする。
S_ReplaceAll('\t', '\r\n>>\r\n', 30);
S_ReplaceAll('^(-)', '<<\r\n\1', 30);

おわりに

後で、マクロを一行ずつ実行したときのテキストの変化を載せます。