Network Working Group J. Postel Request for Comments: 959 J. Reynolds ISI Obsoletes RFC: 765 (IEN 149) October 1985 FILE TRANSFER PROTOCOL (FTP) この記述について   この記述は File Transfer Protocol (FTP) の公開仕様書である。この記述の   配布は無制限である。   以下の新しい追加的命令がこの仕様書のバージョンに含まれている。 CDUP (Change to Parent Directory), SMNT (Structure Mount), STOU (Store Unique), RMD (Remove Directory), MKD (Make Directory), PWD (Print Directory), and SYST (System).   この仕様書が以前の版と互換性を保っている事に注意。 1. イントロダクション   FTP の目的は 1)コンピュータのプログラムやデータのシェアを促進する 2)リ   モートコンピュータの (プログラム経由での) 使用を間接的に、もしくは暗黙   的に奨励する 3)ホスト間のファイル保存システムの変化からユーザを保護する   そして 4)確実に、能率的にデータを転送することである。端末のユーザによる   有用なディレクトリを通して、FTP は主にプログラムによりユーザに対してデ   ザインされている。   この仕様書の試みは、maxi-hosts, mini-hosts, personal workstations,   そして TACs のユーザたちの多様なニーズを簡単に満足させ、簡単に実装させ   るためのプロトコルデザインである。   この文章は Transmission Control Protocol (TCP) [2] と Telnet Protocol   [3] の知識を仮定している。これらのドキュメントは ARPA-Internete プロト   コルハンドブック [1] に含まれている。 2. オーバービュー   このセクションでは、履歴、用語、そして FTP モデルが論議される。このセ   クションで定義される言葉は FTP でのみ特別な重要性を持つようなものであ   る。用語のいくつかは FTP モデルに対して非常に特徴的である: 読んでいる   人は単語を再検討している間、FTP モデルのセクションに行くかもしれない。 2.1. 履歴     FTP は長年の間に大きな進化があった。付録 III は RFC の年代別編集で     ある。これらは 1971 年に最初に提案された、M.I.T. (RFC 114) のホス     トで施行するために開発されたファイル転送メカニズムと RFC141 でのコ     メントと論議を含んでいる。     RFC172 はホストコンピュータ (IMPs ターミナルを含む) 間のファイル転     送に対するユーザレベルを原点としたプロトコルを供給している。この改     訂は RFC285 であり、RFC 281 では将来的な変更を提案しているのに対     して、追加的な面から FTP を再評価している。"Set Data Type" 処理の     使用は January 1982 に RFC 294 で提案されている。     RFC 354 は RFC 264 と 265 に obsolute されている。ファイル転送プロ     トコルは ARPANET 上のホスト間でのファイル転送のためのプロトコルと     して現在定義されていた。FTP の主な機能はホスト間で能率的に、確実に     ファイルを転送し、リモートファイルストレージの性能の便利な使用をで     きる様にするように定義されていた。RFC 385 RFC 354 obsoleted RFCs 264 and 265. The File Transfer Protocol was now defined as a protocol for file transfer between HOSTs on the ARPANET, with the primary function of FTP defined as transfering files efficiently and reliably among hosts and allowing the convenient use of remote file storage capabilities. RFC 385 further commented on errors, emphasis points, and additions to the protocol, while RFC 414 provided a status report on the working server and user FTPs. RFC 430, issued in 1973, (among other RFCs too numerous to mention) presented further comments on FTP. Finally, an "official" FTP document was published as RFC 454. By July 1973, considerable changes from the last versions of FTP were made, but the general structure remained the same. RFC 542 was published as a new "official" specification to reflect these changes. However, many implementations based on the older specification were not updated. In 1974, RFCs 607 and 614 continued comments on FTP. RFC 624 proposed further design changes and minor modifications. In 1975, RFC 686 entitled, "Leaving Well Enough Alone", discussed the differences between all of the early and later versions of FTP. RFC 691 presented a minor revision of RFC 686, regarding the subject of print files. Motivated by the transition from the NCP to the TCP as the underlying protocol, a phoenix was born out of all of the above efforts in RFC 765 as the specification of FTP for use on TCP. This current edition of the FTP specification is intended to correct some minor documentation errors, to improve the explanation of some protocol features, and to add some new optional commands. In particular, the following new optional commands are included in this edition of the specification: CDUP - Change to Parent Directory SMNT - Structure Mount STOU - Store Unique RMD - Remove Directory MKD - Make Directory PWD - Print Directory SYST - System This specification is compatible with the previous edition. A program implemented in conformance to the previous specification should automatically be in conformance to this specification. 2.2. 用語 ASCII     ASCII 文字セットは ARPA-Internet プロトコルハンドブックで定義され     ているものである。FTP では ASCII 文字は 8ビットコードセットの下位     半分であると定義される (符号ビットが 0 であるような)。 アクセスコントロール     アクセスコントロールはシステムの使用とそのシステムでのファイルを与     えられたユーザのアクセスを定義する。アクセスコントロールはファイル     への権限のない使用や偶発的な使用を妨げるために必要である。これはア     クセスコントロールを適用する server-FTP プロセスの権利である。 バイトサイズ     FTP では重要な 2つのバイトサイズがある。ファイルの論理バイトとデー     タ転送に使われる転送バイトサイズである。転送バイトサイズは常に 8     ビットである。転送バイトサイズは、システムに保存されるデータのサイ     ズもデータ構造の処理のための論理バイトサイズも必要としない。 制御接続     コマンドと応答の交換のための、USER-PI と SERVER-PI 間のコミュニ     ケーションパス。この接続は Telnet プロトコルに準ずる。 データ接続     指定されたモードとタイプにおける、データが転送される全二重接続。転     送されたデータは、ファイルの一部分、ファイル全体もしくはファイルの     数の可能性がある。経路は server-DTP と user-DTP 間、もしくは二つの     server-DTP 間だろう。 データポート     データ接続を開始するための、送信側の転送プロセスからの接続を受ける     データポート上で "listen" する受信側データ転送プロセス。 DTP     データ接続を確立し、管理するデータ転送プロセス。DTP は受信側にも送     信側にもなりうる。 行末     行末シーケンス印字可能な行の分割を定義する。シーケンスはキャリッジ     リターンとそれに続くラインフィードである。 EOF     転送されたファイルの終了を定義している end-of-file 状態。 EOR     転送されたレコードの終了を定義する end-of-record 状態。 エラー復旧     ホストシステムや転送プロセスの失敗のような任意のエラーから復旧する     ためユーザに許される手続き。FTP ではエラー復旧は与えられたチェック     ポイントでのファイル転送再開を行う可能性がある。 FTP コマンド     user-FTP から server-FTP プロセスへの送られる制御情報を含んだコマ     ンドセット。 ファイル     任意の長さ、パス名によって個別に識別された (プログラムを含む) コン     ピュータデータの要求されたセット。 モード     データ接続経由で転送されるデータのモード。モードは EOR と EOF を含     めて転送間のデータフォーマットを定義する。FTP における転送モードは     転送モードの章で記述される。 NVT     Telnet プロトコルで定義されているネットワーク仮想端末 (Network     Virtual Terminal)。 NVFS     ネットワーク仮想ファイルシステム (Network Virtual File System)。     標準的なコマンドと慣例的パス名の標準的なネットワークファイルシステ     ムを定義する概念。 ページ     ファイルはページと呼ばれる独立した部分のセットとして構造化されてい     るかもしれない。FTP は独立したインデックス化されたページとして不連     続なファイルの転送をサポートする。 パス名     パス名はファイルを識別するためにユーザからファイルシステムに入力さ     れなければならない文字列であると定義される。パス名は通常、デバイス     名と/もしくはディレクトリ名、そしてファイル名の仕様を含んでいる。     FTP は標準的なパス名慣例をまだ記述していない。それぞれのユーザは転     送において必要となるファイルシステムのファイル名慣例に従わなければ     ならない。 PI     プロトコルインタープリタ。プロトコルのユーザ側とサーバ側は user-PI     と server-PI で実装されるはっきりしたルールを持たなければならない。 レコード     シーケンシャルファイルはレコードと呼ばれる連続した部分のいくつかと     して構造化されているかもしれない。レコード構造は FTP でサポートされ     ているが、ファイルはレコード構造を持つ必要はない。 応答     応答は FTP コマンドの応答としてコントロール接続経由でサーバから     ユーザに送られる (肯定的もしくは否定的) 通知である。応答の一般的な     形態は終了コード (エラーコードを含む) とそれに続くテキスト文字列で     ある。このコードはプログラムによるユーザのためのものであり、テキス     トは人間のユーザのためである。 server-DTP     通常 "送信側" 状態となる、データポートを "listen" しているデータ接     続を確立するデータ転送プロセス。これは転送のためのパラメータを設定     して保存し、その PI からのコマンドのデータを転送する。DTP はデータ     ポート上の接続を初期化する他、受付のために "受信側" にもなりうる。 server-FTP プロセス     user-FTP プロセスと可能であれば別のサーバと協力してファイル転送の     機能を実行するプロセスもしくはそのセット。この機能はプロトコルイン     タープリタ (PI) とデータ転送プロセス (DTP) からなる。 server-PI     user-PI からの接続のためにポート L 上で "listen" し、コントロール     コミュニケーション接続を確立するサーバプロトコルインタープリタ。     user-PI からの標準的な FTP コマンドを受け付け、応答を送信し、     server-DTP を管理する。 タイプ     データの転送と保存のために使用されるデータ表現タイプ。タイプはデー     タ保存とデータ転送時の間に、任意の変化を意味する。FTP で定義されて     いる表現タイプはデータ接続の章において記述される。 user     ファイル転送サービスを行う人もしくはそれを希望する人のためのプロセ     ス。人のユーザは server-FTP と直接相互にプロセスを行うが、user-FTP     プロセスの使用は、プロトコル設計がオートマトンに行うため実行される。 user-DTP     server-FTP プロセスから接続のためのデータポートを "listen" してい     るデータ転送プロセス。もし 2つのサーバがそれらの間でデータを転送す     るなら、user-DTP は使用されない。 user-FTP プロセス     一つかそれ以上の server-FTP プロセスと協力してファイル転送の機能を     ともに実行する、プロトコルインタープリタ、データ転送プロセスおよび     ユーザインターフェース。ユーザインターフェースはユーザとコマンド対     応対話で使用されるローカルな言語を許可する。 user-PI     server-FTP プロセスとポート U からコントロール接続を開始し、FTP コ     マンドを開始し、もしプロセスがファイル転送の一部なら user-DTP を管     理するユーザプロトコルインタープリタ。 2.3. THE FTP MODEL   上記の定義を考えると、以下のモデル (Figure 1 を見よ) は FTP サービスに   対して図式化されたものである。 ------------- |/---------\| || User || -------- ||Interface|<--->| User | |\----^----/| -------- ---------- | | | |/------\| FTP Commands |/----V----\| ||Server|<---------------->| User || || PI || FTP Replies || PI || |\--^---/| |\----^----/| | | | | | | -------- |/--V---\| Data |/----V----\| -------- | File |<--->|Server|<---------------->| User |<--->| File | |System| || DTP || Connection || DTP || |System| -------- |\------/| |\---------/| -------- ---------- ------------- Server-FTP USER-FTP NOTES: 1. The data connection may be used in either direction. 2. The data connection need not exist all of the time. Figure 1 Model for FTP Use   Figure 1 で記述されているモデルでは、ユーザプロトコルインタープリタが   コントロール接続を開始する。コントロール接続は Telnet プロトコルにした   がう。ユーザの開始において、標準的な FTPコマンドは user-PI によって生   成され、コントロール接続経由でサーバプロセスに転送される(ユーザは、た   とえば TAC ターミナルから server-FTP に直接コントロール接続を確立する。   そして独立して標準的な FTP コマンドを生成し、user-PI プロセスを無視す   る)。標準的な応答はコマンドの応答としてコントロール接続を使って server-PI   から user-PI に送られる。   FTP コマンドはデータ接続 (データポート、転送モード、表示タイプ、構造)   とファイルシステム操作の性質 (保存、取り出し、追加、削除、その他) に対   するパラメータを記述する。userDTP やその指定されたものは、記述された   データポート上で "listen" すべきであり、そしてサーバは記述されたパラ   メータにしたがって、データ接続とデータ転送を開始する。データポートが、   コントロール接続経由の FTP コマンドを開始するホストと同じである必要が   ないことに注意すべきである。しかし、ユーザや user-FTP プロセスは記述さ   れたデータポート上での "listen" を保証しなければならない。また、データ   接続は同時に送信したり受信したりすることに対して使われると言うことも注   意する。   ほかの状況において、どちらもローカルホストでないような2つのホスト間で   ファイルを転送することを望んでいるかもしれない。ユーザは2つのサーバに   コントロール接続をセットアップし、それらの間のデータ接続に対してアレン   ジする。この方法で、コントロール情報は user-PI に渡されるが、データは   サーバデータ転送プロセスの間で転送される。以下はこの server-server 相   互接続のモデルである。 Control ------------ Control ---------->| User-FTP |<----------- | | User-PI | | | | "C" | | V ------------ V -------------- -------------- | Server-FTP | Data Connection | Server-FTP | | "A" |<---------------------->| "B" | -------------- Port (A) Port (B) -------------- Figure 2   プロトコルは、コントロール接続がデータ転送プロセスの状態にある間オープ   ンされていることを必要とする。これは、FTP サービスを終了するときにコン   トロール接続を閉じる要求を行うユーザの責任である。もしコントロール接続   が終了コマンドなしに閉じてしまったら、サーバはデータ転送を以上終了する   だろう。 FTP と Telnet の関係は:     FTP はコントロール接続で Telnet プロトコルを使用する。これは2つの     方法で達成される: 第一に、 user-PI や server-PI がそれらの手順にお     いて直接 Telnet プロトコルの規則を実装している; そして、第二に、     user-PI や server-PI はシステムに存在する Telnet モジュールを使う。     実装のそれぞれ、コードの共有、そしてモジュールプログラミングは2つ     めのアプローチを指示している。効率と独立は最初のアプローチを指示し     ている。実際には、FTP は Telnet プロトコルをほとんど応答しない。そ     れで最初のアプローチは大きなコードの量を必然的に巻き込む必要はない。 3. データ転送機能   ファイルはデータ接続を経由してのみ転送される。コントロール接続はコマン   ドの転送のために使用される。そしてそれは実行されるための機能を記述する。   そしてそのコマンドに対する応答を返す (FTP 応答セクション参照)。いくつ   かのコマンドはホスト間のデータの転送に関係している。これらのデータ転送   コマンドは、どの用にデータのビットが伝達されるかを記述する MODE コマン   ド、そして、データが表現される方法を定義するために使われる STRUcture と   TYPE コマンドを含んでいる。伝達と表現はファイル構造属性に依存している。   そして、もし "Compressed" 伝達モードが使用されたら、詰めているバイトの   性質は表現タイプに依存している。 3.1. データ表現と保存   データは送信しているホストの保存デバイスから受信しているホストの保存デ   バイスに転送される。これはしばしば二つのシステムでのデータ保存方法が異   なるために、データの確実な転送を行うために必要となる。たとえば、   NVT-ASCII は異なるシステムで異なるデータ保存方法を持つ。DEC TOPS-20s   は一般的に、左に正規化された (left-justified) 36ビットワードの 5 つの   7ビット ASCII 文字として NVT-ASCII を保存する。IBM マシーンの MVT-ASCII   は 8ビット EBCDIC コードとして NVT-ASCII を保存する。Multics は 36ビッ   トワードの 4 つの 9ビット文字として NVT-ASCII を保存する。これは、異な   るシステムの間でテキストを転送するときに、標準的な NVT-ASCII 表現で文   字を変換するために望ましいものである。寿送信を行うサイトは標準的な表現   とそれらの内部的な表現とで必要な変換を行わなければならないだろう。   ワード長が異なるホストシステムの間ではバイナリデータ (非文字コード) の   転送を行うとき、表現において異なる問題が発生する。これは、送り側がどの   ようにデータを送信して、受けが我がそれを保存するとしても、いつも解決で   きない。たとえば、32 ビットワード長システムから 36 ビットワード長シス   テムに 32 ビットバイトを転送するとき、これは (効率と有用性から) 後者の   システムにおいて 36 ビットワードを右に正規化された (right-justified)   32 ビットバイトを保存することが望ましい。多くの場合、ユーザはデータの   表現と変換機能に記述するオプションを持つだろう。これは FTP が非常に制   限さえ他データタイプ表現にたいして供給していることに注意する。制限され   た能力のこれを超える望まれた変換は、直接ユーザにより行われる。 3.1.1. データタイプ     データ表現はユーザがデータ表現の記述することにより FTPで処理される。     このタイプは暗黙的に (ASCII か EBCDIC として) もしくは明白に (ロー     カルバイトとして)、"論理バイトサイズ" として参照されるような解釈に     対するバイトサイズとして定義する。これはデータ接続で転送に対して使     用されるバイトサイズ、"転送バイトサイズ" と呼ばれるものについて何も     しないと言うこと、そして2つは混乱されないに注意。たとえば、NVT-ASCII     は 8 ビットの論理バイトサイズをもつ。もしタイプが Local バイトなら、     TYPE コマンドは第2パラメータにローカルバイトサイズを記述する義務を     持つ。転送バイトサイズは常に 8 ビットである。 3.1.1.1. ASCII 型       これはデフォルトのタイプであり、すべての FTP 実装で受け入れら       れなければならない。これは第一に、両方のホストがより便利な       EBCDIC タイプを探しているとき以外に、テキストファイルの転送に       対して目的を持つ。       送り側は内部的な文字表現から標準的な 8 ビット NVT-ASCII 表現に       変換を行う (Telnet 規格書参照)。受け側はデータを標準的な形式か       ら内部的な形式に変換する。       NVT 標準に従い、 シーケンスはテキストの行末をあらわすの       に必要なところで使用される (データ表現と保存のセクションの終わ       りのファイル構造の論議参照)。       標準 NVT-ASCII 表現を使うことは、データが 8 ビットバイトとして       解釈されなければならないことを意味する。       ASCII と EBCDIC タイプのフォーマットパラメータは以下で論議する。 3.1.1.2. EBCDIC 型       このタイプは、内部文字表現に EBCDIC を使っているホスト間で効率       的な転送のために用意されている。       転送のために、データは 8 ビット EBCDIC 文字として表現される。       文字コードは EBCDIC と ASCII タイプの機能的な規格の間でのみ異       なる。       行末 (end-of-record --構造の論議参照 -- に対する) は構造を示す       ことの目的で、 EBCDIC タイプではたぶんめったに使われないだろう。       しかし 文字が使われる必要はある。 3.1.1.3. IMAGE 型       データは転送を行うために、8 ビット転送バイトにパックされた連続       したビットとして送られる。受け取り側のサイトでは連続したビット       としてデータを保存しなければならない。保存システムの構造は、同       じ都合の良い境界 (バイト、ワードもしくはブロック) にファイル       (もしくはレコード増こうファイルに対してはそれぞれのレコード)       のパディングを必要とするだろう。すべてゼロにならなければならな       いこのパディングはファイルの終わり (もしくはそれぞれのレコード       の終わり) においてのみ起こるだろう。そして、もしファイルが読み       出されるときパディングが取り除かれるために、パディングビットを       識別する方法がなければならない。パディング変換は保存サイトで       ファイルプロセスをユーザに可能にするためによく公開されている。       イメージタイプは効果的なファイルの保存、読み出し、そしてバイナ       リデータの転送を目的とする。これは、このタイプがすべての FTP       実装により受け入れられるような推奨である。 3.1.1.4. LOCAL 型       データは省略不可能な2つめのパラメータ、バイトサイズにより指定       されるサイズの論理バイトで転送される。バイトサイズの値は10進整       数でなければならない; デフォルトの値はない。論理バイトサイズは       転送バイトサイズと同じ時には必要とされない。もしバイトサイズに       違いがあるなら、論理バイトは連続してパックされ、転送バイト境界       を無視し、最後にどんな必要なパディングも無視した形で送られるだ       ろう。       データが受け側のホストに届いたとき、論理バイトサイズに依存した       ホストに特有な方法で変換されるだろう。この変換は可逆である (も       し同じパラメータが使われたなら同一のファイルを取り出すことが出       来る)。そしてそれは FTP 実装によって公開されるべきである。       たとえば、36 ビット浮動小数点数値を 32 ビットワードのホストに       送るユーザは、36 の論理バイトサイズのローカルバイトとしてデー       タを送ることが出来る。受け取り側のホストでは、論理バイトが簡単       に操作することが出来ることから、それらを保存することになってい       る; この例では 36 ビット論理バイトを 64 ビットダブルワードにお       くことで十分である。       別の例では、36 ビットワードサイズのホストの 1 組が TYPE L 36       を使うことで互いにデータを送る。データは、9 転送バイトが 2 つ       のホストのワードを運ぶので、 8 ビット転送バイトにパックされる。 3.1.1.5. フォーマット制御       ASCII と EBCDIC は第二のパラメータ (オプション) をとることが出       来る; これは、もしそうなら、ある種の vertical フォーマットコン       トロールがファイルに関連していることを示す。以下のデータ表示タ       イプが FTP で定義されている。       文字ファイルは3つの目的のうちの一つのためにあるホストに転送さ       れる: 出力のため、保存、バックアップのため、処理のためである。       もしファイルが出力のために送られるなら、受け取り側のホストはど       のように vertical フォーマットコントロールがあらわされているか       を知らなければならない。第二の場合は、ホストにファイルが保存で       き、そしてあとで正確に同じファイルにそれを回復されなければなら       ない。最後に、あるホストから別のホストにファイルを移動すること       が出来、過度のトラブルなしに第2のホストでファイルを処理できる       べきである。単体の ASCII や EBCDIC フォーマットはこれらの状況       のすべてを満たさない。それゆえ、これらのタイプは以下の 3つの       フォーマットの一つをみたすため、第2のパラメータを持つ。 3.1.1.5.1. NON PRINT         これは2番目のパラメータを省略したときに使用されるデフォル         トである。非出力フォーマットはすべての FTP 実装に受け入れ         られなければならない。         ファイルは vertical フォーマット情報を含んでいない必要があ         る。もしこれが出力プロセスに渡されるなら、このプロセスはス         ペーシングとマージングに標準値を使用するだろう。         通常は、このフォーマットは処理したり保存するためだけと想定         されたファイルに使用されるだろう。 3.1.1.5.2. TELNET FORMAT CONTROLS         ファイルはプリンタプロセスが適切に処理する ASCII/EBCDIC 垂         直方向制御フォーマット (, , , , のよ         うな) を含んでいる。 (性格にはこのシーケンス) も         end-of-line 示す。 3.1.1.5.2. CARRIAGE CONTROL (ASA)         ファイルは ASA (FORTRAN)縦方向制御フォーマットを含んでいる         (RFC 740 Appendix C; Communications of the ACM, Vol.4,         No.10, p606, October 1964 参照)。行や ASA 標準に従うレコー         ドフォーマットにおいて、最初の文字は印字可能文字ではない。         代わりに、レコードの前の余白を取るため、紙の縦移動を決定す         るために使用される。         ASA 標準では以下の制御文字を定義している。 文字 縦方向の空白 blank 紙を上に一行移動 0 紙を上に位置行移動 1 紙を次のページの先頭に移動 + 上書き印刷のように移動しない         明らかに、構造的な存在の最後を区別するためにプリンタプロセ         スに対していくつかの方法がなければならない。もしファイルが         レコード構造 (以下を参照) を持つ場合に問題になる。明らかに         レコードは転送と保存の間にマークされるであろう。もしファイ         ルがレコード構造を持たないなら、 行末シーケンスは印         刷行のセパレータとして使用される。しかし、これらのフォー         マットエフェクタは ASA コントロールによってオーバーライド         される。 3.1.2. データ構造       異なるタイプ表現の追加において、FTP は記述されたファイルの構造       を許している。FTP において 3 種類のファイル構造が定義されている: file-structure, 内部構造を持たない、データバイトの連続し たシーケンスとして考えられるファイル。 record-structure, シーケンシャルレコードとして構成されてい るファイル。 and page-structure, 独立したインデックス化されたページとして 構成されたファイル。       file-structure は、もし STRUcture コマンドが使用されずに、ファ       イルとレコード構造がすべての FTP 実装によって "テキスト" ファ       イル (TYPE ASCII や EBCDIC のような) として受けられるべきなら       ばデフォルトとして仮定される。ファイル構造はファイルの転送モー       ド (Transmission Modes 参照) とファイルの解釈・保存の両方に影       響する。       "自然な" ファイル構造はホストが保存しているファイルに依存する       であろう。ソースコードファイルは IBM メインフレーム上で固定さ       れた長さのレコードとして保存されるが、DEC TOPS-20 では       のような行に分割された文字のストリームとして保存される。もしそ       のような本質的に異なるサイト間でのファイルの転送が有用ならば、       一つのサイトに対してファイルに関する別のサイトの推定の認識に対       するいくつかの方法が必要となる。       当然いくつかのサイトが file-oriented であり、別のものは       record-oriented であるので、片方の構造を持つファイルが別の構造       を持つホストに送られるならば問題となる。もしテキストファイルが       file-oriented のホストに record-structure で送られるなら、その       ホストはレコード構造をベースにしたファイルに内部的な変換を適用       すべきである。明らかに、この変換は有用であるが、同一のファイル       をレコード構造に戻すために invertible でなければならない。       file-structure で record-oritented ホストに送られたファイルの       場合、ホストがレコードにファイルを分割するために使われるローカ       ルで処理可能なものはどういう基準かという疑問が生じる。もしこの       分割が必要ならば、FTP 実装はデリミタとして行末シーケンス       (ASCII の もしくは EBCDIC の ) を使用すべきである。       もしある FTP 実装がこの技術を適用するなら、file-structure に       ファイルを戻す逆の変換も用意すべきである。 3.1.2.1. ファイル構造       ファイル構造は STRUcture コマンドが使用されない場合、デフォル       トとして想定される。       file-structure において内部構造はなくファイルはデータバイトの       連続したシーケンスとして考えられる。 3.1.2.2. レコード構造       レコード構造はすべての FTP 実装により (TYPE ASCII や EBCDIC の       ファイルのような) "テキスト" ファイルとして受け入れられる。       record-structure においてファイルはシーケンシャルレコードで構       成される。 3.1.2.3. ページ構造       連続しないようなファイルの転送のため、FTP ではページ構造を定義       する。このタイプのファイルはしばしば "ランダムアクセスファイル"       もしくは "holey ファイル" として知られる。これらのファイルにお       いて (ファイルデスクリプタのような) 全体としてのファイル       (ページアクセスコントロールのような) ファイルのセクション、も       しくは両方に関係している情報が存在する。FTP では、ファイルのセ       クションはページと呼ぶ。       さまざまなページサイズと関連する情報を供給するため、それぞれの       ページはぺージヘッダといっしょに送られる。ページヘッダは以下に       定義されたフィールドを持つ。 ヘッダ長           このバイトを含むページヘッダにおける論理バイト数。最小           のヘッダ長は 4 である。 ページインデックス           ファイルのこのセクションの論理ページ番号。これはこの           ページの転送シーケンス数ではなく、ファイルのこのページ           を識別するために使用されるインデックスである。 データ長           ページデータの論理バイト数。最小のデータ長は 0 である。 ページタイプ           ページのタイプ。以下のようなページタイプが定義されてい           る。 0 = 最後のページ             これはページ化された構造の転送の終端をあらわすため             に使用される。ヘッダの長さは 4、データの長さは 0             でなければならない。 1 = 単純なページ             これは制御情報に関係しているページレベルの無い単純             なページ化されたファイルの通常のタイプである。ヘッ             ダ長は 4 でなければならない。 2 = 記述ページ             このタイプは全体としてのファイルに対する説明的な情             報を転送するために使用される。 3 = アクセス制限されたページ             このタイプはコントロール情報にアクセスするページレ             ベルと一緒のページかされたファイルに対する追加的な             ヘッダフィールドを含んでいる。 オプション的フィールド           それ以外のヘッダフィールドはページごとの制御情報を供給           するために使用されるであろう。たとえば、ページごとのア           クセスコントロールなどである。         すべてのフィールドは長さにおいて 1 論理バイトである。論理         バイトサイズは TYPE コマンドにより記述される。それ以外の詳         細やページ構造の特性は Appendix I を参照。     A note of caution about parameters: もし戻すバージョンが元々転送さ     れたバージョンと同じなら、ファイルは同じパラメータで保存され、戻さ     れなければならない。逆に言えば、もし保存や戻すことに使用されるパラ     メータが同じなら、FTP 実装はオリジナルと同じファイルに戻さなければ     ならない。 3.2. データ接続の確立     転送データの機構は適切なポートにデータ接続を準備することと転送のた     めのパラメータを選択することから成り立つ。ユーザと server-DTP の両     方はデフォルトのデータポートを持つ。ユーザプロセスのデフォルトデー     タポートはコントロールコネクションポートと同じ (U) である。サーバ     プロセスデフォルトデータポートはコントロールコネクションポートから     一つ前のポート (L-1) である。     転送バイトサイズは 8-bit バイトである。このバイトサイズはデータの     実際の転送に対してのみ関連している。ホストのファイルシステムの範囲     内でのデータの表現とは何ら関係はない。     受動的なデータ転送プロセス (これは user-DTP もしくは二次     server-DTP だろう) は転送要求コマンドを送るより前に "リッスン" す     る。FTP 要求コマンドはデータ転送の命令で決定する。転送要求を受け     取ったサーバはそのポートにデータ接続を開始する。その接続が確立した     とき、データ転送は DTP 間で開始し、server-PI は user-PI に最終確認     を返す。     あらゆる FTP 実装はデフォルトデータポートの使用をサポートしなけれ     ばならないし、USER-PI のみデフォルトでないポートに変更することを行     える。     ユーザが PORT コマンドを使って代わりのデータポートを送るのは可能で     ある。ユーザは TAC ラインプリンタ上にダンプされたりサードパーティ     ホストから戻されたファイルを望んでいるかもしれない。後者ならば、     user-PI は SERVER-pi の両方の制御接続を設定する。この時片方のサー     バが猛火多能のものが開始する予定の接続に対して (FTP コマンドで)     "listen" していることを伝えられる。user-PI は片方の server-PI にも     う片方のサーバのデータポートをあらわす PORT コマンドを送る。最終的     に、両方が適切な転送コマンドを送られる。ユーザコントローラとサーバ     の間で送られるコマンドと応答の正確なシーケンスは FTP 応答のセクショ     ンで定義される。     一般的には、データ接続を維持すること -- 開始して終了する -- はサー     バの責任である。この例外は user-DTP が EOF を示すことでクローズさ     れる接続を要求する転送モードでデータを送信しているときである。サー     バは以下のような状況でデータ接続をクローズ *しなければならない*。       1.サーバが EOF を示すためのクローズを必要とした転送モードで        データを送りきった。       2.サーバがユーザから ABORT コマンドを受信した。       3.ポートの記述がユーザかからコマンドにより変更された。       4.コントロール接続が合法的にもしくは別の方法でクローズされた。       5.回復不能なエラー状況が発生した。     さもなければクローズはサーバのオプションである。サーバが 250 か     226 によりユーザプロセスに示さなければならない行使は応答だけする。 3.3. データ接続管理     Defaul Data Connection Ports: すべての FTP 実装はデフォルトのデー     タポートの使用をサポートしなければならず、User-PI のみがデフォルト     でないポートの使用を開始できる。     Nogotiation Non-Default Data Ports: User-PI は PORT コマンドでデ     フォルトでないユーザ側データポートを記述するかもしれない。User-PI     はサーバ側に PASV コマンドでデフォルトでないサーバ側データポートの     識別のためのリクエストを送るかもしれない。接続がアドレスのペアによ     り定義されているため、これらの動作のいずれも別のデータ接続を得るた     めに十分であり、データ接続の両端で新しいポートを使うための両方のコ     マンドを行う許可を与える。     Reuse of the Data Connection: データ転送にストリームモードを使うと     き、ファイルの終了は接続のクローズで示されなければならない。これは     信頼できる接続を保証している間、タイムアウトの接続レコードを持続に     対して必要なため、もし複数のファイルがそのセッションにおいて転送さ     れる時問題となる。したがってその接続はもう一度オープンできない。       この問題には 2つの解決がある。最初のものは非デフォルトポートに       ネゴシエーションする事だ。二つ目は別の転送モードを使う事である。       転送モードのコメント。ストリーム転送モードはもしそれが早まって       クローズしたかどうかを決定できないため、本来当てにならない。       別の転送モード (Block, Compressed) はファイル終了を示すために接       続をクローズすることはない。これらはデータ接続がファイルの終了       を決定するために解析される事ができる十分な FTP 符号化を持ってい       る。したがって、これらのモードの一つを使う事は複数のファイル転       送のためにデータ接続をオープンしておく事ができる。 3.4. 転送モード     データを転送する事における次の考慮は、適切な転送モードを選ぶ事であ     る。3つのモードが存在する: データをフォーマットし、処理の再開が可     能なもの、効果的な転送のためにデータの圧縮も行うもの、ほとんどもし     くはまったく処理されていないデータを渡すものである。最後の場合、     モードは処理のタイプを決定するための構造属性に相互に作用する。圧縮     モードでは、表現タイプはより満たされたバイトを決定する。     すべてのデータ転送は、明白に言明された end-of-file (EOF) で完了す     るか、データ接続のクローズにより暗黙的になされなければならない。     レコード構造をもつファイルに対して、すべての end-of-record マーク     (EOR) は明確であり、最後の一つも含まれる。ページ構造で転送された     ファイルに対して、"last-page" ページタイプが使われる。     注意: このセクションの残りでは、"転送バイト" を意味するバイトは明     らかに別だと状態かされたところは除外する。     標準化された転送の目的のため、送信しているホストは転送モードとファ     イル構造により、その内部的に規定された表現の行末もしくはレコードの     終わりの表現が変換されるだろう。そして、受信しているホストではその     内部的な表現への逆変換を行うだろう。IBM メインフレームレコードカウ     ントフィールドは別のホストでは認識されない。それでレコードの終わり     情報はストリームモードにおいて2バイトの制御コードに、もしくは     Block や Compressed モードディスクリプタにおいてフラグ化されたビッ     トに変換されるだろう。レコード構造を持たない ASCII や EBCDIC ファ     イル内の行末はそれぞれ により示されるべきである。こ     れらの変換がいくつかのシステムで暗に行われるため、レコード構造を持     たないテキストファイルを同一システムで転送することは、バイナリ表現     と転送にストリームモードを使う事を希望する。     以下の転送モードが FTP で定義されている。 3.4.1. ストリームモード       データはバイトのストリームとして転送される。使われている表現タ       イプに制限はなく、レコード構造は許される。       レコード構造化されたファイルにおいて EOR と EOF はそれぞれ 2バ       イト制御コードにより示される。制御コードの最初のバイトはエス       ケープ文字のどれでも良い。第 2のバイトは In a record structured file EOR and EOF will each be indicated by a two-byte control code. The first byte of the control code will be all ones, the escape character. The second byte will have the low order bit on and zeros elsewhere for EOR and the second low order bit on for EOF; that is, the byte will have value 1 for EOR and value 2 for EOF. EOR and EOF may be indicated together on the last byte transmitted by turning both low order bits on (i.e., the value 3). If a byte of all ones was intended to be sent as data, it should be repeated in the second byte of the control code.       もし構造がファイル構造なら、EOF はデータ接続のクローズする送信       しているホストにより示され、すべてのバイトはデータバイトである。 3.4.2. ブロックモード The file is transmitted as a series of data blocks preceded by one or more header bytes. The header bytes contain a count field, and descriptor code. The count field indicates the total length of the data block in bytes, thus marking the beginning of the next data block (there are no filler bits). The descriptor code defines: last block in the file (EOF) last block in the record (EOR), restart marker (see the Section on Error Recovery and Restart) or suspect data (i.e., the data being transferred is suspected of errors and is not reliable). This last code is NOT intended for error control within FTP. It is motivated by the desire of sites exchanging certain types of data (e.g., seismic or weather data) to send and receive all the data despite local errors (such as "magnetic tape read errors"), but to indicate in the transmission that certain portions are suspect). Record structures are allowed in this mode, and any representation type may be used. The header consists of the three bytes. Of the 24 bits of header information, the 16 low order bits shall represent byte count, and the 8 high order bits shall represent descriptor codes as shown below. Block Header +----------------+----------------+----------------+ | Descriptor | Byte Count | | 8 bits | 16 bits | +----------------+----------------+----------------+ The descriptor codes are indicated by bit flags in the descriptor byte. Four codes have been assigned, where each code number is the decimal value of the corresponding bit in the byte. Code Meaning 128 End of data block is EOR 64 End of data block is EOF 32 Suspected errors in data block 16 Data block is a restart marker With this encoding, more than one descriptor coded condition may exist for a particular block. As many bits as necessary may be flagged. The restart marker is embedded in the data stream as an integral number of 8-bit bytes representing printable characters in the language being used over the control connection (e.g., default--NVT-ASCII). (Space, in the appropriate language) must not be used WITHIN a restart marker. For example, to transmit a six-character marker, the following would be sent: +--------+--------+--------+ |Descrptr| Byte count | |code= 16| = 6 | +--------+--------+--------+ +--------+--------+--------+ | Marker | Marker | Marker | | 8 bits | 8 bits | 8 bits | +--------+--------+--------+ +--------+--------+--------+ | Marker | Marker | Marker | | 8 bits | 8 bits | 8 bits | +--------+--------+--------+ 3.4.3. 圧縮モード 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. If n>0 bytes (up to 127) of regular data are sent, these n bytes are preceded by a byte with the left-most bit set to 0 and the right-most 7 bits containing the number n. Byte string: 1 7 8 8 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |0| n | | d(1) | ... | d(n) | +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ ^ ^ |---n bytes---| of data String of n data bytes d(1),..., d(n) Count n must be positive. To compress a string of n replications of the data byte d, the following 2 bytes are sent: Replicated Byte: 2 6 8 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ |1 0| n | | d | +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+ A string of n filler bytes can be compressed into a single byte, where the filler byte varies with the representation type. If the type is ASCII or EBCDIC the filler byte is (Space, ASCII code 32, EBCDIC code 64). If the type is Image or Local byte the filler is a zero byte. Filler String: 2 6 +-+-+-+-+-+-+-+-+ |1 1| n | +-+-+-+-+-+-+-+-+ The escape sequence is a double byte, the first of which is the escape byte (all zeros) and the second of which contains descriptor codes as defined in Block mode. The descriptor codes have the same meaning as in Block mode and apply to the succeeding string of bytes. Compressed mode is useful for obtaining increased bandwidth on very large network transmissions at a little extra CPU cost. It can be most effectively used to reduce the size of printer files such as those generated by RJE hosts. 3.5. エラー回復と再開 There is no provision for detecting bits lost or scrambled in data transfer; this level of error control is handled by the TCP. However, a restart procedure is provided to protect users from gross system failures (including failures of a host, an FTP-process, or the underlying network). The restart procedure is defined only for the block and compressed modes of data transfer. It requires the sender of data to insert a special marker code in the data stream with some marker information. The marker information has meaning only to the sender, but must consist of printable characters in the default or negotiated language of the control connection (ASCII or EBCDIC). The marker could represent a bit-count, a record-count, or any other information by which a system may identify a data checkpoint. The receiver of data, if it implements the restart procedure, would then mark the corresponding position of this marker in the receiving system, and return this information to the user. In the event of a system failure, the user can restart the data transfer by identifying the marker point with the FTP restart procedure. The following example illustrates the use of the restart procedure. The sender of the data inserts an appropriate marker block in the data stream at a convenient point. The receiving host marks the corresponding data point in its file system and conveys the last known sender and receiver marker information to the user, either directly or over the control connection in a 110 reply (depending on who is the sender). In the event of a system failure, the user or controller process restarts the server at the last server marker by sending a restart command with server's marker code as its argument. The restart command is transmitted over the control connection and is immediately followed by the command (such as RETR, STOR or LIST) which was being executed when the system failure occurred. 4. ファイル転送機能 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. The user protocol interpreter is responsible for sending FTP commands and interpreting the replies received; the server-PI interprets commands, sends replies and directs its DTP to set up the data connection and transfer the data. If the second party to the data transfer (the passive transfer process) is the user-DTP, then it is governed through the internal protocol of the user-FTP host; if it is a second server-DTP, then it is governed by its PI on command from the user-PI. The FTP replies are discussed in the next section. In the description of a few of the commands in this section, it is helpful to be explicit about the possible replies. 4.1. FTP コマンド 4.1.1. アクセス制御コマンド The following commands specify access control identifiers (command codes are shown in parentheses). USER NAME (USER) The argument field is a Telnet string identifying the user. The user identification is that which is required by the server for access to its file system. This command will normally be the first command transmitted by the user after the control connections are made (some servers may require this). Additional identification information in the form of a password and/or an account command may also be required by some servers. Servers may allow a new USER command to be entered at any point in order to change the access control and/or accounting information. This has the effect of flushing any user, password, and account information already supplied and beginning the login sequence again. All transfer parameters are unchanged and any file transfer in progress is completed under the old access control parameters. PASSWORD (PASS) The argument field is a Telnet string specifying the user's password. This command must be immediately preceded by the user name command, and, for some sites, completes the user's identification for access control. Since password information is quite sensitive, it is desirable in general to "mask" it or suppress typeout. It appears that the server has no foolproof way to achieve this. It is therefore the responsibility of the user-FTP process to hide the sensitive password information. ACCOUNT (ACCT) The argument field is a Telnet string identifying the user's account. The command is not necessarily related to the USER command, as some sites may require an account for login and others only for specific access, such as storing files. In the latter case the command may arrive at any time. There are reply codes to differentiate these cases for the automation: when account information is required for login, the response to a successful PASSword command is reply code 332. On the other hand, if account information is NOT required for login, the reply to a successful PASSword command is 230; and if the account information is needed for a command issued later in the dialogue, the server should return a 332 or 532 reply depending on whether it stores (pending receipt of the ACCounT command) or discards the command, respectively. CHANGE WORKING DIRECTORY (CWD) This command allows the user to work with a different directory or dataset for file storage or retrieval without altering his login or accounting information. Transfer parameters are similarly unchanged. The argument is a pathname specifying a directory or other system dependent file group designator. CHANGE TO PARENT DIRECTORY (CDUP) This command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory. The reply codes shall be identical to the reply codes of CWD. See Appendix II for further details. STRUCTURE MOUNT (SMNT) This command allows the user to mount a different file system data structure without altering his login or accounting information. Transfer parameters are similarly unchanged. The argument is a pathname specifying a directory or other system dependent file group designator. REINITIALIZE (REIN) This command terminates a USER, flushing all I/O and account information, except to allow any transfer in progress to be completed. All parameters are reset to the default settings and the control connection is left open. This is identical to the state in which a user finds himself immediately after the control connection is opened. A USER command may be expected to follow. LOGOUT (QUIT) This command terminates a USER and if file transfer is not in progress, the server closes the control connection. If file transfer is in progress, the connection will remain open for result response and the server will then close it. If the user-process is transferring files for several USERs but does not wish to close and then reopen connections for each, then the REIN command should be used instead of QUIT. An unexpected close on the control connection will cause the server to take the effective action of an abort (ABOR) and a logout (QUIT). 4.1.2. 転送パラメータコマンド 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. The default value is the last specified value, or if no value has been specified, the standard default value is as stated here. This implies that the server must "remember" the applicable default values. The commands may be in any order except that they must precede the FTP service request. The following commands specify data transfer parameters: DATA PORT (PORT) The argument is a HOST-PORT specification for the data port to be used in data connection. There are defaults for both the user and server data ports, and under normal circumstances this command and its reply are not needed. If this command is used, the argument is the concatenation of a 32-bit internet host address and a 16-bit TCP port address. This address information is broken into 8-bit fields and the value of each field is transmitted as a decimal number (in character string representation). The fields are separated by commas. A port command would be: PORT h1,h2,h3,h4,p1,p2 where h1 is the high order 8 bits of the internet host address. PASSIVE (PASV) This command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command. The response to this command includes the host and port address this server is listening on. REPRESENTATION TYPE (TYPE) The argument specifies the representation type as described in the Section on Data Representation and Storage. Several types take a second parameter. The first parameter is denoted by a single Telnet character, as is the second Format parameter for ASCII and EBCDIC; the second parameter for local byte is a decimal integer to indicate Bytesize. The parameters are separated by a (Space, ASCII code 32). The following codes are assigned for type: \ / A - ASCII | | N - Non-print |-><-| T - Telnet format effectors E - EBCDIC| | C - Carriage Control (ASA) / \ I - Image L - Local byte Byte size The default representation type is ASCII Non-print. If the Format parameter is changed, and later just the first argument is changed, Format then returns to the Non-print default. FILE STRUCTURE (STRU) The argument is a single Telnet character code specifying file structure described in the Section on Data Representation and Storage. The following codes are assigned for structure: F - File (no record structure) R - Record structure P - Page structure The default structure is File. TRANSFER MODE (MODE) The argument is a single Telnet character code specifying the data transfer modes described in the Section on Transmission Modes. The following codes are assigned for transfer modes: S - Stream B - Block C - Compressed The default transfer mode is Stream. 4.1.3. FTP サービスコマンド The FTP service commands define the file transfer or the file system function requested by the user. The argument of an FTP service command will normally be a pathname. The syntax of pathnames must conform to server site conventions (with standard defaults applicable), and the language conventions of the control connection. The suggested default handling is to use the last specified device, directory or file name, or the standard default defined for local users. The commands may be in any order except that a "rename from" command must be followed by a "rename to" command and the restart command must be followed by the interrupted service command (e.g., STOR or RETR). The data, when transferred in response to FTP service commands, shall always be sent over the data connection, except for certain informative replies. The following commands specify FTP service requests: RETRIEVE (RETR) This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to the server- or user-DTP at the other end of the data connection. The status and contents of the file at the server site shall be unaffected. STORE (STOR) This command causes the server-DTP to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist. STORE UNIQUE (STOU) This command behaves like STOR except that the resultant file is to be created in the current directory under a name unique to that directory. The 250 Transfer Started response must include the name generated. APPEND (with create) (APPE) This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site. ALLOCATE (ALLO) This command may be required by some servers to reserve sufficient storage to accommodate the new file to be transferred. The argument shall be a decimal integer representing the number of bytes (using the logical byte size) of storage to be reserved for the file. For files sent with record or page structure a maximum record or page size (in logical bytes) might also be necessary; this is indicated by a decimal integer in a second argument field of the command. This second argument is optional, but when present should be separated from the first by the three Telnet characters R . This command shall be followed by a STORe or APPEnd command. The ALLO command should be treated as a NOOP (no operation) by those servers which do not require that the maximum size of the file be declared beforehand, and those servers interested in only the maximum record or page size should accept a dummy value in the first argument and ignore it. RESTART (REST) The argument field represents the server marker at which file transfer is to be restarted. This command does not cause file transfer but skips over the file to the specified data checkpoint. This command shall be immediately followed by the appropriate FTP service command which shall cause file transfer to resume. RENAME FROM (RNFR) This command specifies the old pathname of the file which is to be renamed. This command must be immediately followed by a "rename to" command specifying the new file pathname. RENAME TO (RNTO) This command specifies the new pathname of the file specified in the immediately preceding "rename from" command. Together the two commands cause a file to be renamed. ABORT (ABOR) This command tells the server to abort the previous FTP service command and any associated transfer of data. The abort command may require "special action", as discussed in the Section on FTP Commands, to force recognition by the server. No action is to be taken if the previous command has been completed (including data transfer). The control connection is not to be closed by the server, but the data connection must be closed. There are two cases for the server upon receipt of this command: (1) the FTP service command was already completed, or (2) the FTP service command is still in progress. In the first case, the server closes the data connection (if it is open) and responds with a 226 reply, indicating that the abort command was successfully processed. In the second case, the server aborts the FTP service in progress and closes the data connection, returning a 426 reply to indicate that the service request terminated abnormally. The server then sends a 226 reply, indicating that the abort command was successfully processed. DELETE (DELE) This command causes the file specified in the pathname to be deleted at the server site. If an extra level of protection is desired (such as the query, "Do you really wish to delete?"), it should be provided by the user-FTP process. REMOVE DIRECTORY (RMD) This command causes the directory specified in the pathname to be removed as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative). See Appendix II. MAKE DIRECTORY (MKD) This command causes the directory specified in the pathname to be created as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative). See Appendix II. PRINT WORKING DIRECTORY (PWD) This command causes the name of the current working directory to be returned in the reply. See Appendix II. LIST (LIST) This command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current information on the file. A null argument implies the user's current working or default directory. The data transfer is over the data connection in type ASCII or type EBCDIC. (The user must ensure that the TYPE is appropriately ASCII or EBCDIC). Since the information on a file may vary widely from system to system, this information may be hard to use automatically in a program, but may be quite useful to a human user. NAME LIST (NLST) This command causes a directory listing to be sent from server to user site. The pathname should specify a directory or other system-specific file group descriptor; a null argument implies the current directory. The server will return a stream of names of files and no other information. The data will be transferred in ASCII or EBCDIC type over the data connection as valid pathname strings separated by or . (Again the user must ensure that the TYPE is correct.) This command is intended to return information that can be used by a program to further process the files automatically. For example, in the implementation of a "multiple get" function. SITE PARAMETERS (SITE) This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol. The nature of these services and the specification of their syntax can be stated in a reply to the HELP SITE command. SYSTEM (SYST) This command is used to find out the type of operating system at the server. The reply shall have as its first word one of the system names listed in the current version of the Assigned Numbers document [4]. STATUS (STAT) This command shall cause a status response to be sent over the control connection in the form of a reply. The command may be sent during a file transfer (along with the Telnet IP and Synch signals--see the Section on FTP Commands) in which case the server will respond with the status of the operation in progress, or it may be sent between file transfers. In the latter case, the command may have an argument field. If the argument is a pathname, the command is analogous to the "list" command except that data shall be transferred over the control connection. If a partial pathname is given, the server may respond with a list of file names or attributes associated with that specification. If no argument is given, the server should return general status information about the server FTP process. This should include current values of all transfer parameters and the status of connections. HELP (HELP) This command shall cause the server to send helpful information regarding its implementation status over the control connection to the user. The command may take an argument (e.g., any command name) and return more specific information as a response. The reply is type 211 or 214. It is suggested that HELP be allowed before entering a USER command. The server may use this reply to specify site-dependent parameters, e.g., in response to HELP SITE. NOOP (NOOP) This command does not affect any parameters or previously entered commands. It specifies no action other than that the server send an OK reply. The File Transfer Protocol follows the specifications of the Telnet protocol for all communications over the control connection. Since the language used for Telnet communication may be a negotiated option, all references in the next two sections will be to the "Telnet language" and the corresponding "Telnet end-of-line code". Currently, one may take these to mean NVT-ASCII and . No other specifications of the Telnet protocol will be cited. FTP commands are "Telnet strings" terminated by the "Telnet end of line code". The command codes themselves are alphabetic characters terminated by the character (Space) if parameters follow and Telnet-EOL otherwise. The command codes and the semantics of commands are described in this section; the detailed syntax of commands is specified in the Section on Commands, the reply sequences are discussed in the Section on Sequencing of Commands and Replies, and scenarios illustrating the use of commands are provided in the Section on Typical FTP Scenarios. FTP commands may be partitioned as those specifying access-control identifiers, data transfer parameters, or FTP service requests. Certain commands (such as ABOR, STAT, QUIT) may be sent over the control connection while a data transfer is in progress. Some servers may not be able to monitor the control and data connections simultaneously, in which case some special action will be necessary to get the server's attention. The following ordered format is tentatively recommended: 1. User system inserts the Telnet "Interrupt Process" (IP) signal in the Telnet stream. 2. User system sends the Telnet "Synch" signal. 3. User system inserts the command (e.g., ABOR) in the Telnet stream. 4. Server PI, after receiving "IP", scans the Telnet stream for EXACTLY ONE FTP command. (For other servers this may not be necessary but the actions listed above should have no unusual effect.) 4.2. FTP 応答     File Transfer Protocol コマンドの応答はファイル転送のプロセスにお     ける要求と動作の同調を保証し、ユーザプロセスが常にサーバの状態を知     る事を保証するために考案されている。それぞれのコマンドは最低一つ、     さらにはそれ以上の応答を生成しなければならない。後者の場合、複合応     答は簡単に区別でなければならない。付加的にいくつかのコマンドは     USER, PASS や ACCT, RNFR, RNTO のようなシーケンシャルグループで起     こる。応答はもし直前のすべてのコマンドが成功であったなら、中間的な     状態の存在が示される。シーケンシャルにおけるどんなポイントでの失敗     も、開始するところからの全シーケンシャルの繰り返しが必要である。       コマンド-応答シーケンスの詳細は以下のステートダイアグラムの       セットにおいて明白に定義される。 An FTP reply consists of a three digit number (transmitted as three alphanumeric characters) followed by some text. The number is intended for use by automata to determine what state to enter next; the text is intended for the human user. It is intended that the three digits contain enough encoded information that the user-process (the User-PI) will not need to examine the text and may either discard it or pass it on to the user, as appropriate. In particular, the text may be server-dependent, so there are likely to be varying texts for each reply code. A reply is defined to contain the 3-digit code, followed by Space , followed by one line of text (where some maximum line length has been specified), and terminated by the Telnet end-of-line code. There will be cases however, where the text is longer than a single line. In these cases the complete text must be bracketed so the User-process knows when it may stop reading the reply (i.e. stop processing input on the control connection) and go do other things. This requires a special format on the first line to indicate that more than one line is coming, and another on the last line to designate it as the last. At least one of these must contain the appropriate reply code to indicate the state of the transaction. To satisfy all factions, it was decided that both the first and last line codes should be the same. Thus the format for multi-line replies is that the first line will begin with the exact required reply code, followed immediately by a Hyphen, "-" (also known as Minus), followed by text. The last line will begin with the same code, followed immediately by Space , optionally some text, and the Telnet end-of-line code. For example: 123-First line Second line 234 A line beginning with numbers 123 The last line The user-process then simply needs to search for the second occurrence of the same reply code, followed by (Space), at the beginning of a line, and ignore all intermediary lines. If an intermediary line begins with a 3-digit number, the Server must pad the front to avoid confusion. This scheme allows standard system routines to be used for reply information (such as for the STAT reply), with "artificial" first and last lines tacked on. In rare cases where these routines are able to generate three digits and a Space at the beginning of any line, the beginning of each text line should be offset by some neutral text, like Space. This scheme assumes that multi-line replies may not be nested. The three digits of the reply each have a special significance. This is intended to allow a range of very simple to very sophisticated responses by the user-process. The first digit denotes whether the response is good, bad or incomplete. (Referring to the state diagram), an unsophisticated user-process will be able to determine its next action (proceed as planned, redo, retrench, etc.) by simply examining this first digit. A user-process that wants to know approximately what kind of error occurred (e.g. file system error, command syntax error) may examine the second digit, reserving the third digit for the finest gradation of information (e.g., RNTO command without a preceding RNFR). There are five values for the first digit of the reply code: 1yz Positive Preliminary reply The requested action is being initiated; expect another reply before proceeding with a new command. (The user-process sending another command before the completion reply would be in violation of protocol; but server-FTP processes should queue any commands that arrive while a preceding command is in progress.) This type of reply can be used to indicate that the command was accepted and the user-process may now pay attention to the data connections, for implementations where simultaneous monitoring is difficult. The server-FTP process may send at most, one 1yz reply per command. 2yz Positive Completion reply The requested action has been successfully completed. A new request may be initiated. 3yz Positive Intermediate reply The command has been accepted, but the requested action is being held in abeyance, pending receipt of further information. The user should send another command specifying this information. This reply is used in command sequence groups. 4yz Transient Negative Completion reply The command was not accepted and the requested action did not take place, but the error condition is temporary and the action may be requested again. The user should return to the beginning of the command sequence, if any. It is difficult to assign a meaning to "transient", particularly when two distinct sites (Server- and User-processes) have to agree on the interpretation. Each reply in the 4yz category might have a slightly different time value, but the intent is that the user-process is encouraged to try again. A rule of thumb in determining if a reply fits into the 4yz or the 5yz (Permanent Negative) category is that replies are 4yz if the commands can be repeated without any change in command form or in properties of the User or Server (e.g., the command is spelled the same with the same arguments used; the user does not change his file access or user name; the server does not put up a new implementation.) 5yz Permanent Negative Completion reply The command was not accepted and the requested action did not take place. The User-process is discouraged from repeating the exact request (in the same sequence). Even some "permanent" error conditions can be corrected, so the human user may want to direct his User-process to reinitiate the command sequence by direct action at some point in the future (e.g., after the spelling has been changed, or the user has altered his directory status.) The following function groupings are encoded in the second digit: x0z Syntax - These replies refer to syntax errors, syntactically correct commands that don't fit any functional category, unimplemented or superfluous commands. x1z Information - These are replies to requests for information, such as status or help. x2z Connections - Replies referring to the control and data connections. x3z Authentication and accounting - Replies for the login process and accounting procedures. x4z Unspecified as yet. x5z File system - These replies indicate the status of the Server file system vis-a-vis the requested transfer or other file system action. The third digit gives a finer gradation of meaning in each of the function categories, specified by the second digit. The list of replies below will illustrate this. Note that the text associated with each reply is recommended, rather than mandatory, and may even change according to the command with which it is associated. The reply codes, on the other hand, must strictly follow the specifications in the last section; that is, Server implementations should not invent new codes for situations that are only slightly different from the ones described here, but rather should adapt codes already defined. A command such as TYPE or ALLO whose successful execution does not offer the user-process any new information will cause a 200 reply to be returned. If the command is not implemented by a particular Server-FTP process because it has no relevance to that computer system, for example ALLO at a TOPS20 site, a Positive Completion reply is still desired so that the simple User-process knows it can proceed with its course of action. A 202 reply is used in this case with, for example, the reply text: "No storage allocation necessary." If, on the other hand, the command requests a non-site-specific action and is unimplemented, the response is 502. A refinement of that is the 504 reply for a command that is implemented, but that requests an unimplemented parameter. 4.2.1 機能グループによる応答コード 200 Command okay. 500 Syntax error, command unrecognized. This may include errors such as command line too long. 501 Syntax error in parameters or arguments. 202 Command not implemented, superfluous at this site. 502 Command not implemented. 503 Bad sequence of commands. 504 Command not implemented for that parameter. 110 Restart marker reply. In this case, the text is exact and not left to the particular implementation; it must read: MARK yyyy = mmmm Where yyyy is User-process data stream marker, and mmmm server's equivalent marker (note the spaces between markers and "="). 211 System status, or system help reply. 212 Directory status. 213 File status. 214 Help message. On how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user. 215 NAME system type. Where NAME is an official system name from the list in the Assigned Numbers document. 120 Service ready in nnn minutes. 220 Service ready for new user. 221 Service closing control connection. Logged out if appropriate. 421 Service not available, closing control connection. This may be a reply to any command if the service knows it must shut down. 125 Data connection already open; transfer starting. 225 Data connection open; no transfer in progress. 425 Can't open data connection. 226 Closing data connection. Requested file action successful (for example, file transfer or file abort). 426 Connection closed; transfer aborted. 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). 230 User logged in, proceed. 530 Not logged in. 331 User name okay, need password. 332 Need account for login. 532 Need account for storing files. 150 File status okay; about to open data connection. 250 Requested file action okay, completed. 257 "PATHNAME" created. 350 Requested file action pending further information. 450 Requested file action not taken. File unavailable (e.g., file busy). 550 Requested action not taken. File unavailable (e.g., file not found, no access). 451 Requested action aborted. Local error in processing. 551 Requested action aborted. Page type unknown. 452 Requested action not taken. Insufficient storage space in system. 552 Requested file action aborted. Exceeded storage allocation (for current directory or dataset). 553 Requested action not taken. File name not allowed. 4.2.2 応答コードの数値順リスト 110 Restart marker reply. In this case, the text is exact and not left to the particular implementation; it must read: MARK yyyy = mmmm Where yyyy is User-process data stream marker, and mmmm server's equivalent marker (note the spaces between markers and "="). 120 Service ready in nnn minutes. 125 Data connection already open; transfer starting. 150 File status okay; about to open data connection. 200 Command okay. 202 Command not implemented, superfluous at this site. 211 System status, or system help reply. 212 Directory status. 213 File status. 214 Help message. On how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user. 215 NAME system type. Where NAME is an official system name from the list in the Assigned Numbers document. 220 Service ready for new user. 221 Service closing control connection. Logged out if appropriate. 225 Data connection open; no transfer in progress. 226 Closing data connection. Requested file action successful (for example, file transfer or file abort). 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). 230 User logged in, proceed. 250 Requested file action okay, completed. 257 "PATHNAME" created. 331 User name okay, need password. 332 Need account for login. 350 Requested file action pending further information. 421 Service not available, closing control connection. This may be a reply to any command if the service knows it must shut down. 425 Can't open data connection. 426 Connection closed; transfer aborted. 450 Requested file action not taken. File unavailable (e.g., file busy). 451 Requested action aborted: local error in processing. 452 Requested action not taken. Insufficient storage space in system. 500 Syntax error, command unrecognized. This may include errors such as command line too long. 501 Syntax error in parameters or arguments. 502 Command not implemented. 503 Bad sequence of commands. 504 Command not implemented for that parameter. 530 Not logged in. 532 Need account for storing files. 550 Requested action not taken. File unavailable (e.g., file not found, no access). 551 Requested action aborted: page type unknown. 552 Requested file action aborted. Exceeded storage allocation (for current directory or dataset). 553 Requested action not taken. File name not allowed. 5. 宣言の仕様 5.1. 最小限の実装     エラーメッセージを必要としない以外の FTP 動作可能なものを作るため、     最小限以下の実装がすべてのサーバに必要である。 TYPE - ASCII Non-print MODE - Stream STRUCTURE - File, Record COMMANDS - USER, QUIT, PORT, TYPE, MODE, STRU, for the default values RETR, STOR, NOOP.     転送パラメータのデフォルト値は: TYPE - ASCII Non-print MODE - Stream STRU - File     すべてのホストは標準のデフォルトとして上記のものを受け入れなければ     ならない。 5.2. 接続     サーバプロトコルインタープリタはポート L で "listen" していると仮     定する。ユーザやユーザプロトコルインタープリタは全二重制御接続を開     始するだろう。サーバもしくはユーザプロセスは ARPA-Internet     Protocol Handbook [1] において記述されているような Telnet プロトコ     ルの慣例に適応すべきである。サーバはコマンドライン編集を備える義務     はなく、それはユーザホストでなされる。コントロール接続はすべての転     送と応答が完了した後にユーザの要求によってサーバからクローズされる。     user-DTP は記述されたデータポート上で "listen" されなければならな     い。これはデフォルトのユーザポート (U) もしくは PORT コマンドで記     述されたポートである。サーバは記述されたデータポートを使ってそのデ     フォルトデータポート (L-1) からデータ接続を開始する。転送の方向と     使われているポートは FTP サービスコマンドによって決定されるだろう。     すべての FTP 実装はデフォルトポートでのデータ転送をサポートしなけ     ればならず、USER-PI のみが非デフォルトポートを使って開始できる。     データが二つのサーバ A と B の間を転送されているとき (Figure 2 参     照)、user-PI, C は両方の server-PI の制御接続を設定する。A と呼ば     れる片方のサーバは、転送サービスコマンドを受けるとき、接続を開始す     るのではなく、そのデータポート上で "listen" している事を伝える     PASV コマンドを送る。user-PI がその PASV コマンド (これは接続待ち     しているホストとポートの識別を含んでいる) の通知を受けたとき、     user-PI は B に PORT コマンドで A のポートを送り、その応答が返され     る。このとき user-PI は A と B にサービスコマンドに相当するものを     送信できる。サーバ B は接続と転送を開始する。コマンド応答シーケン     スは以下のように送られる。ここでメッセージは垂直方向に同期であるが     水平方向に非同期である。 User-PI - Server A User-PI - Server B ------------------ ------------------ C->A : Connect C->B : Connect C->A : PASV A->C : 227 Entering Passive Mode. A1,A2,A3,A4,a1,a2 C->B : PORT A1,A2,A3,A4,a1,a2 B->C : 200 Okay C->A : STOR C->B : RETR B->A : Connect to HOST-A, PORT-a Figure 3     データ接続はデータ接続の確立の章で述べられた状態のもとでサーバによ     りクローズされる。もし、接続をクローズする事が end-of-file で示さ     れる必要のないデータ転送となる次のデータ接続がクローズされるなら、     サーバはすぐにそうしなければならない。新しい転送コマンドの後で待機     している事は、ユーザプロセス "listen" する必要があるかどうかを見る     ためにデータ接続をすでにテストした可能性があるため許されていない     (ユーザは転送リクエストを送信する *前に* クローズされたデータポー     ト上で "listen" しなければならない事に注意)。ここでは経過状態を妨     げるため、サーバはデータ接続を閉じた後に応答 (226) を送る (もしく     はその接続がすでにオープンされたままとなっているなら、"file     transfer completed" (250) が送られ、user-PI は新しい転送コマンドを     発行する前にこれらの応答の一つを待たなければならない)。     どんな場合でもユーザやサーバは状態が別の再度によりクローズされてい     るかどうかを参照しなければならない。これは接続上で待っている残りの     すべてのデータを早急に読み込み、自分自身側にクローズを発行すべきで     ある。 5.3. コマンド     コマンドは FTP コマンドの章で述べられているような制御接続上での     Telnet 文字列である。コマンド機能とセマンティクスはアクセス制御コ     マンド、転送パラメータコマンド、FTP サービスコマンドおよびその他の     のコマンドの章で述べられている。コマンドの構文がここで記述される。     コマンドはコマンドコードとそれに続く引数フィールドで開始する。コマ     ンドコードは 4文字かそれ以下の英文である。英文の大文字と小文字は同     じように扱われる。したがって、以下のどれも取り出すコマンドを表して     いる。 RETR Retr retr ReTr rETr     これはパラメータ値を表す A や ASCII TYPE のような、すべてのシンボ     ルにも適用される。コマンドコードと引数フィールドは一つ以上の空白に     より区切られる。     引数フィールドは NVT-ASCII に対する文字シーケンス (キャリッ     ジリターン、ラインフィード) で終了する、さまざまな長さの文字列で成     り立つ。サーバが行末コードを受け取るまでのあいだ何も動作しないとい     うことに注意すべきである。     構文は NVT-ASCII 以下で記述される。引数フィールドのすべての文字は     10進整数値を表すすべての ASCII を含む ASCII 文字である。角括弧はオ     プション的な引数フィールドを示す。もしオプションが取られなければ、     適切なデフォルト値が暗黙的に使用される。 5.3.1. FTP コマンド       以下のものが FTP コマンドである: 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 コマンド引数       上記の引数フィールド (適用している BNF 表記を使っている) の構       文は: ::= ::= ::= ::= | ::= 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. コマンドと応答のシーケンス The communication between the user and server is intended to be an alternating dialogue. As such, the user issues an FTP command and the server responds with a prompt primary reply. The user should wait for this initial primary success or failure response before sending further commands. Certain commands require a second reply for which the user should also wait. These replies may, for example, report on the progress or completion of file transfer or the closing of the data connection. They are secondary replies to file transfer commands. One important group of informational replies is the connection greetings. Under normal circumstances, a server will send a 220 reply, "awaiting input", when the connection is completed. The user should wait for this greeting message before sending any commands. If the server is unable to accept input right away, a 120 "expected delay" reply should be sent immediately and a 220 reply when ready. The user will then know not to hang up if there is a delay. Spontaneous Replies Sometimes "the system" spontaneously has a message to be sent to a user (usually all users). For example, "System going down in 15 minutes". There is no provision in FTP for such spontaneous information to be sent from the server to the user. It is recommended that such information be queued in the server-PI and delivered to the user-PI in the next reply (possibly making it a multi-line reply). The table below lists alternative success and failure replies for each command. These must be strictly adhered to; a server may substitute text in the replies, but the meaning and action implied by the code numbers and by the specific command reply sequence cannot be altered. Command-Reply Sequences In this section, the command-reply sequence is presented. Each command is listed with its possible replies; command groups are listed together. Preliminary replies are listed first (with their succeeding replies indented and under them), then positive and negative completion, and finally intermediary replies with the remaining commands from the sequence following. This listing forms the basis for the state diagrams, which will be presented separately. Connection Establishment 120 220 220 421 Login USER 230 530 500, 501, 421 331, 332 PASS 230 202 530 500, 501, 503, 421 332 ACCT 230 202 530 500, 501, 503, 421 CWD 250 500, 501, 502, 421, 530, 550 CDUP 200 500, 501, 502, 421, 530, 550 SMNT 202, 250 500, 501, 502, 421, 530, 550 Logout REIN 120 220 220 421 500, 502 QUIT 221 500 Transfer parameters PORT 200 500, 501, 421, 530 PASV 227 500, 501, 502, 421, 530 MODE 200 500, 501, 504, 421, 530 TYPE 200 500, 501, 504, 421, 530 STRU 200 500, 501, 504, 421, 530 File action commands ALLO 200 202 500, 501, 504, 421, 530 REST 500, 501, 502, 421, 530 350 STOR 125, 150 (110) 226, 250 425, 426, 451, 551, 552 532, 450, 452, 553 500, 501, 421, 530 STOU 125, 150 (110) 226, 250 425, 426, 451, 551, 552 532, 450, 452, 553 500, 501, 421, 530 RETR 125, 150 (110) 226, 250 425, 426, 451 450, 550 500, 501, 421, 530 LIST 125, 150 226, 250 425, 426, 451 450 500, 501, 502, 421, 530 NLST 125, 150 226, 250 425, 426, 451 450 500, 501, 502, 421, 530 APPE 125, 150 (110) 226, 250 425, 426, 451, 551, 552 532, 450, 550, 452, 553 500, 501, 502, 421, 530 RNFR 450, 550 500, 501, 502, 421, 530 350 RNTO 250 532, 553 500, 501, 502, 503, 421, 530 DELE 250 450, 550 500, 501, 502, 421, 530 RMD 250 500, 501, 502, 421, 530, 550 MKD 257 500, 501, 502, 421, 530, 550 PWD 257 500, 501, 502, 421, 550 ABOR 225, 226 500, 501, 502, 421 Informational commands SYST 215 500, 501, 502, 421 STAT 211, 212, 213 450 500, 501, 502, 421, 530 HELP 211, 214 500, 501, 502, 421 Miscellaneous commands SITE 200 202 500, 501, 530 NOOP 200 500 421 6. ステージダイアグラム Here we present state diagrams for a very simple minded FTP implementation. Only the first digit of the reply codes is used. There is one state diagram for each group of FTP commands or command sequences. The command groupings were determined by constructing a model for each command then collecting together the commands with structurally identical models. For each command or command sequence there are three possible outcomes: success (S), failure (F), and error (E). In the state diagrams below we use the symbol B for "begin", and the symbol W for "wait for reply". We first present the diagram that represents the largest group of FTP commands: 1,3 +---+ ----------->| E | | +---+ | +---+ cmd +---+ 2 +---+ | B |---------->| W |---------->| S | +---+ +---+ +---+ | | 4,5 +---+ ----------->| F | +---+ This diagram models the commands: ABOR, ALLO, DELE, CWD, CDUP, SMNT, HELP, MODE, NOOP, PASV, QUIT, SITE, PORT, SYST, STAT, RMD, MKD, PWD, STRU, and TYPE. The other large group of commands is represented by a very similar diagram: 3 +---+ ----------->| E | | +---+ | +---+ cmd +---+ 2 +---+ | B |---------->| W |---------->| S | +---+ --->+---+ +---+ | | | | | | 4,5 +---+ | 1 | ----------->| F | ----- +---+ This diagram models the commands: APPE, LIST, NLST, REIN, RETR, STOR, and STOU. Note that this second model could also be used to represent the first group of commands, the only difference being that in the first group the 100 series replies are unexpected and therefore treated as error, while the second group expects (some may require) 100 series replies. Remember that at most, one 100 series reply is allowed per command. The remaining diagrams model command sequences, perhaps the simplest of these is the rename sequence: +---+ RNFR +---+ 1,2 +---+ | B |---------->| W |---------->| E | +---+ +---+ -->+---+ | | | 3 | | 4,5 | -------------- ------ | | | | +---+ | ------------->| S | | | 1,3 | | +---+ | 2| -------- | | | | V | | | +---+ RNTO +---+ 4,5 ----->+---+ | |---------->| W |---------->| F | +---+ +---+ +---+ The next diagram is a simple model of the Restart command: +---+ REST +---+ 1,2 +---+ | B |---------->| W |---------->| E | +---+ +---+ -->+---+ | | | 3 | | 4,5 | -------------- ------ | | | | +---+ | ------------->| S | | | 3 | | +---+ | 2| -------- | | | | V | | | +---+ cmd +---+ 4,5 ----->+---+ | |---------->| W |---------->| F | +---+ -->+---+ +---+ | | | 1 | ------ Where "cmd" is APPE, STOR, or RETR. We note that the above three models are similar. The Restart differs from the Rename two only in the treatment of 100 series replies at the second stage, while the second group expects (some may require) 100 series replies. Remember that at most, one 100 series reply is allowed per command. The most complicated diagram is for the Login sequence: 1 +---+ USER +---+------------->+---+ | B |---------->| W | 2 ---->| E | +---+ +---+------ | -->+---+ | | | | | 3 | | 4,5 | | | -------------- ----- | | | | | | | | | | | | | | --------- | | 1| | | | V | | | | +---+ PASS +---+ 2 | ------>+---+ | |---------->| W |------------->| S | +---+ +---+ ---------->+---+ | | | | | 3 | |4,5| | | -------------- -------- | | | | | | | | | | | | ----------- | 1,3| | | | V | 2| | | +---+ ACCT +---+-- | ----->+---+ | |---------->| W | 4,5 -------->| F | +---+ +---+------------->+---+ Finally, we present a generalized diagram that could be used to model the command and reply interchange: ------------------------------------ | | Begin | | | V | | +---+ cmd +---+ 2 +---+ | -->| |------->| |---------->| | | | | | W | | S |-----| -->| | -->| |----- | | | | +---+ | +---+ 4,5 | +---+ | | | | | | | | | | | 1| |3 | +---+ | | | | | | | | | | | | ---- | ---->| F |----- | | | | | | | | +---+ ------------------- | | V End 7. 典型的な FTP シナリオ   ホスト S に対してファイル転送を希望している、ホスト U のユーザ:   一般的に、ユーザは user-FTP プロセスを媒介としてサーバに通信するだろう。   以下はその典型的なシナリオである。   user-FTP プロンプトは括弧で表され、ホスト U からホスト S のコマンドの   表現として '---->'、ホスト S からホスト U に返される表現として '<----'   を表す。 LOCAL COMMANDS BY USER ACTION INVOLVED ftp (host) multics Connect to host S, port L, establishing control connections. <---- 220 Service ready . username Doe USER Doe----> <---- 331 User name ok, need password. password mumble PASS mumble----> <---- 230 User logged in. retrieve (local type) ASCII (local pathname) test 1 User-FTP opens local file in ASCII. (for. pathname) test.pl1 RETR test.pl1 ----> <---- 150 File status okay; about to open data connection. Server makes data connection to port U. <---- 226 Closing data connection, file transfer successful. type Image TYPE I ----> <---- 200 Command OK store (local type) image (local pathname) file dump User-FTP opens local file in Image. (for.pathname) >udd>cn>fd STOR >udd>cn>fd ----> <---- 550 Access denied terminate QUIT ----> Server closes all connections. 8. 接続の確立   FTP コントロール接続はユーザプロセスのポート U とサーバプロセスポート   L の間で TCP 経由で確立される。このプロトコルはサービスポート 21 (8進   数で 25) に割り当てられ、L=21 である。 付録 I - ページ構造 The need for FTP to support page structure derives principally from the need to support efficient transmission of files between TOPS-20 systems, particularly the files used by NLS. The file system of TOPS-20 is based on the concept of pages. The operating system is most efficient at manipulating files as pages. The operating system provides an interface to the file system so that many applications view files as sequential streams of characters. However, a few applications use the underlying page structures directly, and some of these create holey files. A TOPS-20 disk file consists of four things: a pathname, a page table, a (possibly empty) set of pages, and a set of attributes. The pathname is specified in the RETR or STOR command. It includes the directory name, file name, file name extension, and generation number. The page table contains up to 2**18 entries. Each entry may be EMPTY, or may point to a page. If it is not empty, there are also some page-specific access bits; not all pages of a file need have the same access protection. A page is a contiguous set of 512 words of 36 bits each. The attributes of the file, in the File Descriptor Block (FDB), contain such things as creation time, write time, read time, writer's byte-size, end-of-file pointer, count of reads and writes, backup system tape numbers, etc. Note that there is NO requirement that entries in the page table be contiguous. There may be empty page table slots between occupied ones. Also, the end of file pointer is simply a number. There is no requirement that it in fact point at the "last" datum in the file. Ordinary sequential I/O calls in TOPS-20 will cause the end of file pointer to be left after the last datum written, but other operations may cause it not to be so, if a particular programming system so requires. In fact, in both of these special cases, "holey" files and end-of-file pointers NOT at the end of the file, occur with NLS data files. The TOPS-20 paged files can be sent with the FTP transfer parameters: TYPE L 36, STRU P, and MODE S (in fact, any mode could be used). Each page of information has a header. Each header field, which is a logical byte, is a TOPS-20 word, since the TYPE is L 36. The header fields are: Word 0: Header Length. The header length is 5. Word 1: Page Index. If the data is a disk file page, this is the number of that page in the file's page map. Empty pages (holes) in the file are simply not sent. Note that a hole is NOT the same as a page of zeros. Word 2: Data Length. The number of data words in this page, following the header. Thus, the total length of the transmission unit is the Header Length plus the Data Length. Word 3: Page Type. A code for what type of chunk this is. A data page is type 3, the FDB page is type 2. Word 4: Page Access Control. The access bits associated with the page in the file's page map. (This full word quantity is put into AC2 of an SPACS by the program reading from net to disk.) After the header are Data Length data words. Data Length is currently either 512 for a data page or 31 for an FDB. Trailing zeros in a disk file page may be discarded, making Data Length less than 512 in that case. 付録 II - ディレクトリコマンド Since UNIX has a tree-like directory structure in which directories are as easy to manipulate as ordinary files, it is useful to expand the FTP servers on these machines to include commands which deal with the creation of directories. Since there are other hosts on the ARPA-Internet which have tree-like directories (including TOPS-20 and Multics), these commands are as general as possible. Four directory commands have been added to FTP: MKD pathname Make a directory with the name "pathname". RMD pathname Remove the directory with the name "pathname". PWD Print the current working directory name. CDUP Change to the parent of the current working directory. The "pathname" argument should be created (removed) as a subdirectory of the current working directory, unless the "pathname" string contains sufficient information to specify otherwise to the server, e.g., "pathname" is an absolute pathname (in UNIX and Multics), or pathname is something like "" to TOPS-20. REPLY CODES The CDUP command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory. The reply codes for CDUP be identical to the reply codes of CWD. The reply codes for RMD be identical to the reply codes for its file analogue, DELE. The reply codes for MKD, however, are a bit more complicated. A freshly created directory will probably be the object of a future CWD command. Unfortunately, the argument to MKD may not always be a suitable argument for CWD. This is the case, for example, when a TOPS-20 subdirectory is created by giving just the subdirectory name. That is, with a TOPS-20 server FTP, the command sequence MKD MYDIR CWD MYDIR will fail. The new directory may only be referred to by its "absolute" name; e.g., if the MKD command above were issued while connected to the directory , the new subdirectory could only be referred to by the name . Even on UNIX and Multics, however, the argument given to MKD may not be suitable. If it is a "relative" pathname (i.e., a pathname which is interpreted relative to the current directory), the user would need to be in the same current directory in order to reach the subdirectory. Depending on the application, this may be inconvenient. It is not very robust in any case. To solve these problems, upon successful completion of an MKD command, the server should return a line of the form: 257"" That is, the server will tell the user what string to use when referring to the created directory. The directory name can contain any character; embedded double-quotes should be escaped by double-quotes (the "quote-doubling" convention). For example, a user connects to the directory /usr/dm, and creates a subdirectory, named pathname: CWD /usr/dm 200 directory changed to /usr/dm MKD pathname 257 "/usr/dm/pathname" directory created An example with an embedded double quote: MKD foo"bar 257 "/usr/dm/foo""bar" directory created CWD /usr/dm/foo"bar 200 directory changed to /usr/dm/foo"bar The prior existence of a subdirectory with the same name is an error, and the server must return an "access denied" error reply in that case. CWD /usr/dm 200 directory changed to /usr/dm MKD pathname 521-"/usr/dm/pathname" directory already exists; 521 taking no action. The failure replies for MKD are analogous to its file creating cousin, STOR. Also, an "access denied" return is given if a file name with the same name as the subdirectory will conflict with the creation of the subdirectory (this is a problem on UNIX, but shouldn't be one on TOPS-20). Essentially because the PWD command returns the same type of information as the successful MKD command, the successful PWD command uses the 257 reply code as well. SUBTLETIES Because these commands will be most useful in transferring subtrees from one machine to another, carefully observe that the argument to MKD is to be interpreted as a sub-directory of the current working directory, unless it contains enough information for the destination host to tell otherwise. A hypothetical example of its use in the TOPS-20 world: CWD 200 Working directory changed MKD overrainbow 257 "" directory created CWD overrainbow 431 No such directory CWD 200 Working directory changed CWD 200 Working directory changed to MKD 257 "" directory created CWD Note that the first example results in a subdirectory of the connected directory. In contrast, the argument in the second example contains enough information for TOPS-20 to tell that the directory is a top-level directory. Note also that in the first example the user "violated" the protocol by attempting to access the freshly created directory with a name other than the one returned by TOPS-20. Problems could have resulted in this case had there been an directory; this is an ambiguity inherent in some TOPS-20 implementations. Similar considerations apply to the RMD command. The point is this: except where to do so would violate a host's conventions for denoting relative versus absolute pathnames, the host should treat the operands of the MKD and RMD commands as subdirectories. The 257 reply to the MKD command must always contain the absolute pathname of the created directory. 付録 III - FTP の RFC Bhushan, Abhay, "A File Transfer Protocol", RFC 114 (NIC 5823), MIT-Project MAC, 16 April 1971. Harslem, Eric, and John Heafner, "Comments on RFC 114 (A File Transfer Protocol)", RFC 141 (NIC 6726), RAND, 29 April 1971. Bhushan, Abhay, et al, "The File Transfer Protocol", RFC 172 (NIC 6794), MIT-Project MAC, 23 June 1971. Braden, Bob, "Comments on DTP and FTP Proposals", RFC 238 (NIC 7663), UCLA/CCN, 29 September 1971. Bhushan, Abhay, et al, "The File Transfer Protocol", RFC 265 (NIC 7813), MIT-Project MAC, 17 November 1971. McKenzie, Alex, "A Suggested Addition to File Transfer Protocol", RFC 281 (NIC 8163), BBN, 8 December 1971. Bhushan, Abhay, "The Use of "Set Data Type" Transaction in File Transfer Protocol", RFC 294 (NIC 8304), MIT-Project MAC, 25 January 1972. Bhushan, Abhay, "The File Transfer Protocol", RFC 354 (NIC 10596), MIT-Project MAC, 8 July 1972. Bhushan, Abhay, "Comments on the File Transfer Protocol (RFC 354)", RFC 385 (NIC 11357), MIT-Project MAC, 18 August 1972. Hicks, Greg, "User FTP Documentation", RFC 412 (NIC 12404), Utah, 27 November 1972. Bhushan, Abhay, "File Transfer Protocol (FTP) Status and Further Comments", RFC 414 (NIC 12406), MIT-Project MAC, 20 November 1972. Braden, Bob, "Comments on File Transfer Protocol", RFC 430 (NIC 13299), UCLA/CCN, 7 February 1973. Thomas, Bob, and Bob Clements, "FTP Server-Server Interaction", RFC 438 (NIC 13770), BBN, 15 January 1973. Braden, Bob, "Print Files in FTP", RFC 448 (NIC 13299), UCLA/CCN, 27 February 1973. McKenzie, Alex, "File Transfer Protocol", RFC 454 (NIC 14333), BBN, 16 February 1973. Bressler, Bob, and Bob Thomas, "Mail Retrieval via FTP", RFC 458 (NIC 14378), BBN-NET and BBN-TENEX, 20 February 1973. Neigus, Nancy, "File Transfer Protocol", RFC 542 (NIC 17759), BBN, 12 July 1973. Krilanovich, Mark, and George Gregg, "Comments on the File Transfer Protocol", RFC 607 (NIC 21255), UCSB, 7 January 1974. Pogran, Ken, and Nancy Neigus, "Response to RFC 607 - Comments on the File Transfer Protocol", RFC 614 (NIC 21530), BBN, 28 January 1974. Krilanovich, Mark, George Gregg, Wayne Hathaway, and Jim White, "Comments on the File Transfer Protocol", RFC 624 (NIC 22054), UCSB, Ames Research Center, SRI-ARC, 28 February 1974. Bhushan, Abhay, "FTP Comments and Response to RFC 430", RFC 463 (NIC 14573), MIT-DMCG, 21 February 1973. Braden, Bob, "FTP Data Compression", RFC 468 (NIC 14742), UCLA/CCN, 8 March 1973. Bhushan, Abhay, "FTP and Network Mail System", RFC 475 (NIC 14919), MIT-DMCG, 6 March 1973. Bressler, Bob, and Bob Thomas "FTP Server-Server Interaction - II", RFC 478 (NIC 14947), BBN-NET and BBN-TENEX, 26 March 1973. White, Jim, "Use of FTP by the NIC Journal", RFC 479 (NIC 14948), SRI-ARC, 8 March 1973. White, Jim, "Host-Dependent FTP Parameters", RFC 480 (NIC 14949), SRI-ARC, 8 March 1973. Padlipsky, Mike, "An FTP Command-Naming Problem", RFC 506 (NIC 16157), MIT-Multics, 26 June 1973. Day, John, "Memo to FTP Group (Proposal for File Access Protocol)", RFC 520 (NIC 16819), Illinois, 25 June 1973. Merryman, Robert, "The UCSD-CC Server-FTP Facility", RFC 532 (NIC 17451), UCSD-CC, 22 June 1973. Braden, Bob, "TENEX FTP Problem", RFC 571 (NIC 18974), UCLA/CCN, 15 November 1973. McKenzie, Alex, and Jon Postel, "Telnet and FTP Implementation - Schedule Change", RFC 593 (NIC 20615), BBN and MITRE, 29 November 1973. Sussman, Julie, "FTP Error Code Usage for More Reliable Mail Service", RFC 630 (NIC 30237), BBN, 10 April 1974. Postel, Jon, "Revised FTP Reply Codes", RFC 640 (NIC 30843), UCLA/NMC, 5 June 1974. Harvey, Brian, "Leaving Well Enough Alone", RFC 686 (NIC 32481), SU-AI, 10 May 1975. Harvey, Brian, "One More Try on the FTP", RFC 691 (NIC 32700), SU-AI, 28 May 1975. Lieb, J., "CWD Command of FTP", RFC 697 (NIC 32963), 14 July 1975. Harrenstien, Ken, "FTP Extension: XSEN", RFC 737 (NIC 42217), SRI-KL, 31 October 1977. Harrenstien, Ken, "FTP Extension: XRSQ/XRCP", RFC 743 (NIC 42758), SRI-KL, 30 December 1977. Lebling, P. David, "Survey of FTP Mail and MLFL", RFC 751, MIT, 10 December 1978. Postel, Jon, "File Transfer Protocol Specification", RFC 765, ISI, June 1980. Mankins, David, Dan Franklin, and Buzz Owen, "Directory Oriented FTP Commands", RFC 776, BBN, December 1980. Padlipsky, Michael, "FTP Unique-Named Store Command", RFC 949, MITRE, July 1985. 参照 [1] Feinler, Elizabeth, "Internet Protocol Transition Workbook", Network Information Center, SRI International, March 1982. [2] Postel, Jon, "Transmission Control Protocol - DARPA Internet Program Protocol Specification", RFC 793, DARPA, September 1981. [3] Postel, Jon, and Joyce Reynolds, "Telnet Protocol Specification", RFC 854, ISI, May 1983. [4] Reynolds, Joyce, and Jon Postel, "Assigned Numbers", RFC 943, ISI, April 1985. ============================================ 和訳制作: “● [〒] 1999 by ToRA. <|V __________________________________________________ V> From: torao@mars.dti.ne.jp Location: http://www.mars.dti.ne.jp/~torao/index.html