[BACK]Return to start-session.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / OpenXM-specs

Annotation of OpenXM/doc/OpenXM-specs/start-session.tex, Revision 1.5

1.5     ! takayama    1: %% $OpenXM: OpenXM/doc/OpenXM-specs/start-session.tex,v 1.4 2000/01/24 12:32:49 noro Exp $
1.1       noro        2: //&jp \section{TCP/IP でのセッションのスタート}
1.2       noro        3: //&eg \section{How to start a session on TCP/IP}
1.1       noro        4:
1.2       noro        5: \subsection{Standard I/O on OX servers}
                      6:
                      7: /*&jp
                      8: サーバの実装を容易にするために, サーバは, 起動時に file descriptor 3,
                      9: 4 がそれぞれクライアントからの入力, クライアントへの出力用に open され
                     10: ていると仮定する. すなわち, サーバ自体が通信を成立させるための socket
                     11: 操作を行う必要はない. 但し, OX message の効率よい送受信のために, data
                     12: のバッファリングを行うことはサーバ側の責任である. UNIX においては,
                     13: file descriptor へのbuffer の attach は {\tt fdopen()} で行うことがで
                     14: きる.
                     15: */
                     16:
                     17: /*&eg
                     18: In order to make it easy to implement servers, one can assume that
                     19: any server has two opened socket descriptors 3 and 4,
                     20: which are for input from a client and for output to a client respectively.
                     21: That is, servers do not have to do socket operations to establish
                     22: connections. However servers are responsible for buffering data
                     23: to exchange OX messages efficiently. Note that associating a buffered stream
                     24: with a descriptor can be done by {\tt fdopen()}.
                     25: */
                     26:
                     27: \subsection{Launcher}
                     28: /*&jp
                     29: サーバは, クライアントから起動されるが, TCP/IP 接続のためには socket の
                     30: 生成から始まる一連の操作が必要である. 一方で, すでに述べたように, サーバ
                     31: 自体はそういう機能はもたない. launcher は, この両者の橋渡しをする application
                     32: である. launcher の働きは次の通りである.
                     33:
                     34: \begin{enumerate}
                     35: \item launcher はクライアントが起動する. launcher には使用する port 番号,
                     36: サーバ application のファイル名が伝えられる.
                     37: \item client はまず launcher と通信を成立させる. この際, one time password
                     38: が用いられる場合もある.
                     39: \item launcher は新しいプロセスを起動し, そのプロセスにおいて client と通信
                     40: を成立させる. そして, その通信路が file descriptor の 3, 4 となるように
                     41: セットし, サーバを exec する.
                     42: \end{enumerate}
                     43:
                     44: 以上の操作のあと, launcher はコントロールサーバとなり, 自身が作った
                     45: したサーバの制御を行う.
                     46: */
                     47: /*&eg
                     48: Though there need several socket operations to establish a
1.3       noro       49: connection over TCP/IP, servers do not have any functionality for
1.2       noro       50: connection establishment.
                     51: An application called {\it launcher} is provided to start servers
                     52: and to establish connections as follows.
                     53:
                     54: \begin{enumerate}
                     55: \item A launcher is invoked from a client.
                     56: When the launcher is invoked, the client
                     57: informs the launcher of a port number for TCP/IP connection
                     58: and the name of a server.
                     59: \item The launcher and the client establish a connection with the
                     60: specified port number. One time password may be used to prevent
                     61: launcher spoofing.
                     62: \item The launcher creates a process and establishes a connection
                     63: to the client. Then the launcher arranges for the newly created descriptors
                     64: to be 3 and 4, and executes the specified server.
                     65: \end{enumerate}
                     66:
                     67: After finishing the above task as a launcher, the launcher process
                     68: acts as a control server and controls the server process created by
                     69: itself.
                     70: */
                     71:
                     72: //&jp \subsection{byte order の決定}
                     73: //&eg \subsection{Negotiation of the byte order}
1.1       noro       74: /*&jp
                     75: コントロールプロセス, 計算プロセス
                     76: ともに, 起動直後に
                     77: 1 byte のデータを書き出し flush する.
                     78: そのあと, 1 byte のデータを読み込む.
                     79: クライアントはコントロールプロセス, 計算プロセス
                     80: につながるファイルディスクリプタの両方から
                     81: まず 1 byte のデータを読む.
                     82: そのあと
                     83: 1 byte のデータを書き出し flush する.
                     84: 1 byte のデータは,
                     85: {\tt 0}, {\tt 1}, {\tt FF} のどれかであり,
                     86: {\tt 0} は以下の通信において {\tt int32} をおくるのに,
                     87: network byte order を使用したい,
                     88: {\tt 1} は以下の通信において {\tt int32} をおくるのに,
                     89: little endian を使用したい,
                     90: {\tt FF} は以下の通信において {\tt int32} をおくるのに,
                     91: big endian を使用したい,
                     92: という意味である.
                     93: 両者の希望が一致しない場合はつねに {\tt 0} (network byte order)
                     94: を使用する.
                     95: Network byte order しか実装していないシステムでは,
                     96: {\tt 0} をおくればよい.
                     97: ただし効率が問題となる通信において, network byte order への変換は
                     98: おおきなボトルネックとなることがあることを了解しておくべきである.
1.2       noro       99: */
                    100: /*&eg
1.4       noro      101: A client and a server exchange one byte data soon after
1.2       noro      102: the communication has started as follows.
                    103:
                    104: \begin{itemize}
                    105: \item The server writes one byte representing the preferable byte order
                    106: to the client,
                    107: then waits for one byte to come from the client.
                    108: \item After reading the byte, the client writes one byte representing the
                    109: preferable byte order to the server.
                    110: \end{itemize}
                    111:
                    112: The one byte data is {\tt 0}, {\tt 1} or {\tt 0xFF}.
                    113: {\tt 0} means that one wants to use the network byte order to
                    114: send 16 or 32bit quantities.
                    115: {\tt 1} means that one wants to use the little endian order.
1.3       noro      116: {\tt 0xFF} means that one wants to use the big endian order.
                    117: On each side, if the preference coincides with each other then
1.2       noro      118: the byte order is used. Otherwise the network byte order is used.
                    119:
                    120: If a system implements only the network byte order, then
                    121: it is sufficient to send always {\tt 0}.
                    122: However unnecessary byte order conversion may add large overhead
                    123: and it is often a bottle-neck on fast networks.
                    124: */
1.1       noro      125:
                    126: \begin{verbatim}
                    127: #define OX_BYTE_NETWORK_BYTE_ORDER    0
                    128: #define OX_BYTE_LITTLE_ENDIAN         1
                    129: #define OX_BYTE_BIG_ENDIAN         0xff
                    130: \end{verbatim}
                    131:
1.2       noro      132: //&jp \subsection{launcher の例 : {\tt ox}}
                    133: //&eg \subsection{An example of launcher : {\tt ox}}
                    134: /*&jp
1.1       noro      135: 注意: {\tt OpenXM/src/kxx} に含まれる, {\tt ox} (コントロールプロセス,
                    136: 計算プロセスをたちあげるローンチャ)は, 標準で One Time Password
                    137: の機能をもっています.
                    138: この機能を OFF にするには {\tt -insecure} option を使用して下さい.
                    139: One Time Password は 0 で終了するバイト列であり,
                    140: コントロール, 計算双方のプロセスをたちあげるまえに,
                    141: {\tt ox} はコントロール, 計算双方のプロセスに対応する,
                    142: ふたつのポートに
                    143: One Time Password バイト列を送出しています.
                    144:
                    145: {\tt ox} (ソースは {\tt oxmain.c}, {\tt kan96xx/plugin/oxmisc.c})においては
                    146: {\tt oxTellMyByteOrder()} が, サーバについての byte order 情報の
                    147: 送出, 読み込みをやっている.
                    148: クライアントについては,
                    149: {\tt oxSetByteOrder()} が, byte order 情報の読み込み, 送出をおこなっている.
                    150:
                    151: One time パスワードは安全な通信路で配送される必要があります.
                    152: また, 現在の {\rm ox} の実装では, One time パスワードを
                    153: サーバ, クライアントに login している人はすべて見ることが
                    154: できますので, サーバ, クライアントには悪意のある人はいないと
                    155: 仮定しないといけません.
                    156: One time パスワードを安全に配送し, リモートマシンの {\rm ox}
                    157: を立ち上げるには
                    158: たとえば
                    159: {\tt ssh} を {\tt -f } オプションを用いて使用します.
                    160:
                    161: 以下は {\rm sm1} での実装, 動作例です.
                    162: ここでは, {\tt yama} の {\tt sm1} より {\tt dc1} の {\tt ox}
                    163: を立ち上げています.
1.2       noro      164: */
                    165: /*&eg
                    166: \noindent
1.4       noro      167: {\tt ox}, included in {\tt OpenXM/src/kxx},
1.2       noro      168: is a launcher to invoke an engine. After invoking an
                    169: engine, it acts as a control server. By default {\tt ox} requires
                    170: a one time password. To skip it, use {\tt -insecure} option.
                    171: A one time password is a null-terminated byte sequence and
1.4       noro      172: a client informs both a control server and an engine of
1.2       noro      173: byte sequences as one time passwords.
                    174:
                    175: {\tt ox} is created from {\tt oxmain.c} and {\tt
1.3       noro      176: kan96xx/plugin/oxmisc.c}.  In {\tt ox} \\
                    177: {\tt oxTellMyByteOrder()}
1.2       noro      178: executes the exchange of the byte order information. In a client it is
                    179: done in {\tt oxSetByteOrder()}.
                    180:
                    181: One time passwords should be sent via secure communication channels.
1.3       noro      182: Note that in the current implementation of {\tt ox}, one time passwords
1.2       noro      183: are visible to all users logging in machines on which the server
1.3       noro      184: and the client run, assuming that there is no evil person among the users.
1.2       noro      185: One may use {\tt ssh} with {\tt -f } option when one wants to send
                    186: a one time password securely to a remote machine.
                    187:
                    188: The following example shows invocation of an {\tt ox\_sm1}
1.3       noro      189: server and the communication establishment on {\rm sm1}.
                    190: In this example {\tt ox} on the host {\tt dc1} is invoked from
1.2       noro      191: {\tt sm1} on the host {\tt yama}.
                    192: */
1.1       noro      193: {\footnotesize
                    194: \begin{verbatim}
                    195: yama% sm1
                    196: sm1>(ox.sm1) run ;
                    197: ox.sm1, --- open sm1 protocol module 10/1,1999  (C) N.Takayama. oxhelp for help
                    198: sm1>[(dc1.math.kobe-u.ac.jp) (taka)] sm1connectr-ssh /ox.ccc set ;
                    199: Hello from open. serverName is yama.math.kobe-u.ac.jp and portnumber is 0
                    200: Done the initialization. port =1024
                    201: Hello from open. serverName is yama.math.kobe-u.ac.jp and portnumber is 0
                    202: Done the initialization. port =1025
                    203: [    4 , 1025 , 3 , 1024 ]
                    204: Executing the command : ssh -f dc1.math.kobe-u.ac.jp -l taka
                    205: "/home/taka/OpenXM/bin/oxlog /usr/X11R6/bin/xterm -icon
                    206: -e /home/taka/OpenXM/bin/ox -reverse -ox /home/taka/OpenXM/bin/ox_sm1
                    207: -host yama.math.kobe-u.ac.jp -data 1025 -control 1024 -pass 518158401   "
                    208: [
                    209: taka@dc1.math.kobe-u.ac.jp's password:
                    210: Trying to accept... Accepted.
                    211: Trying to accept... Accepted.
                    212:
                    213: Control port 1024 : Connected.
                    214:
                    215: Stream port 1025 : Connected.
                    216: Byte order for control process is network byte order.
                    217: Byte order for engine process is network byte order.
                    218: \end{verbatim}
                    219: }
                    220:
1.5     ! takayama  221: //&jp \subsection{OX サーバの利用例}
        !           222: //&eg \subsection{Example of using OX servers}
        !           223:
        !           224: /*&jp
        !           225: ox サーバを TCP/IP で $C$ より利用する例は
        !           226: {\tt OpenXM/doc/oxlib/test1-tcp.c} にある.
        !           227: */
        !           228: /*&eg
        !           229: An sample C source to use ox servers by TCP/IP can be found
        !           230: in {\tt OpenXM/doc/oxlib/test1-tcp.c}.
        !           231: */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>