home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / misc~1 / 123 / stcitdoc.arc / NETHACK.DOC < prev    next >
Encoding:
Text File  |  1987-11-08  |  12.6 KB  |  318 lines

  1. NETHACK.DOC
  2.  
  3.  
  4.  
  5.                 Once over lightly
  6.  
  7.     This section provides a Utopian view of the Citadel auto
  8. networking protocol -- it ignores possible foulup points, and
  9. generally assumes that the gremlins of the world don't exist, and
  10. are gonadless in any case. Irrelevant complexities and gremlins are
  11. covered in following sections.
  12.  
  13. FLOW DIAGRAM
  14.  
  15.    -----------------
  16.    |     CALL      |
  17.    | STABILIZATION |
  18.    -----------------    RECEIVER TELLS CALLER CAN'T HANDLE COMMAND
  19.        |                           +-------------------<-----+
  20.        |                           |                         |
  21.    ----------------     ----------------      ------------    ^
  22.    | CALLER SENDS |->---| CALLER SENDS |--->--| RECEIVER |--->|
  23.    | ID & NAME    |     |   COMMAND    |      | RESPONDS |    |
  24.    ----------------     ----------------      ------------    V
  25.                    |                              |
  26.                    |                              |
  27.                    |                        --------------
  28.                    |                        |  RECEIVER  |
  29.                    |                        |   TELLS    |
  30.                    ^                        |   CALLER   |
  31.                    |                        | CAN HANDLE |
  32.                    |                        |  COMMAND   |
  33.                    |                        --------------
  34.                    |                              |
  35.                    |                              |
  36.                    |  UNLESS COMMAND IS    ----------------
  37.                    +------------<----------| DO SPECIFIED |
  38.                      'HANGUP'          |    ACTION    |
  39.                                ----------------
  40.  
  41.     The key is in having a reliable WC protocol available, because
  42. all commands are sent via WC protocol.
  43.  
  44.  
  45. --------------------------------------------------------------------
  46.  
  47.             CALL STABILIZATION
  48.  
  49.  
  50.     The purpose of this process is to establish quickly and
  51. efficiently that the caller is another system on the net that wishes
  52. to give the receiver some info.  Here is the process (sort of)
  53. graphically:
  54.  
  55.          Caller           |             Receiver
  56.          ------           |             --------
  57.              Systems detect carrier
  58.     Wait for full second       |        Wait for full second
  59.     Send following 3 bytes:       |        Begin waiting for the
  60.          7               |        following three bytes:
  61.          13            |            7
  62.          69            |            13
  63.     and wait 4 seconds.        |            69
  64.     If have not received a       |         After the 4 second
  65.     correct response (see       |         response wait, the Receiver
  66.     Receiver column), then       |         can switch bauds if it
  67.     resend the above 3 bytes.       |         is running in a SEARCHBAUD
  68.     This looping process should    |         configuration.  If get the
  69.     only be repeated 20 times.       |         above 3 bytes, then respond
  70.     If, on the 20th try, still       |         instantly with the following:
  71.     have not received a correct    |            ~7
  72.     response, HANGUP.           |            ~13
  73.     If have received a correct       |            ~69
  74.     response, send an ACK.       |         and then wait for an ACK.
  75.                    |         This should end CALL
  76.                    |         STABILIZATION.
  77.  
  78.    So, essentially, the caller waits a second, and then sends a 3
  79. byte sequence to the receiver.  When the receiver receives those 3
  80. bytes successfully, it replies with the logical negation of those 3
  81. bytes.  The caller then sends an ACK back, indicating that the call
  82. is stabilized. If 20 times the protocol fails, then the caller hangs
  83. up, assuming something was wrong.
  84.  
  85.  
  86. --------------------------------------------------------------------
  87.  
  88.           CALLER SENDS NAME, ID, AND PASSWORD
  89.  
  90.  
  91.    After receiving the ACK indicating end of CALL STABILIZATION,
  92. both will use Ward Christensen protocol for data exchange. Therefore,
  93. the next byte originates with the receiver, and that byte is the
  94. startup NAK.  The caller sends, in this order, nodeid, nodename, and
  95. the password (if any) it needs to get access to the other system.
  96.  
  97.    nodeid, nodename, password: Are normal null-terminated C strings.
  98.  
  99.    So, for example, let's say that a system using the nodename
  100. "buffalo" and with a nodeId of "US 612 477 0927" called some other
  101. system. After the WC session was over, the receiver's buffer or
  102. temporary file would look like this
  103.  
  104.      Id        name
  105. US 612 477 0927<0>Buffalo<0><0>[nulls]
  106.  
  107.    If WC fails at this point, the systems should hangup.
  108.  
  109.    If `Buffalo' is calling a system that needs the password `Gloopza',
  110. the receiver's buffer would look like this
  111.  
  112.      ID            name     password
  113. US 612 477 0927<0>Buffalo<0>Gloopza<0>[nulls]
  114.  
  115.  
  116. --------------------------------------------------------------------
  117.  
  118.             COMMAND REQUESTS
  119.  
  120.  
  121.     So, what happens next?  It's a loop, in which the caller tells
  122. the receiver that he wants to do thus-and-so, the receiver responds
  123. with either "Fine, let's get on with it," or "Nope, [reason]".
  124.  
  125.     In more detail, it looks like this.  First, remember that all
  126. communication is via WC protocol.  A 'complete' command is a 1-byte
  127. command followed by 0 to 4 null terminated strings, followed by a
  128. null byte.  Currently, the strings can only be 19 characters long. 
  129. So, for instance, if we were to send only a single byte command, the
  130. sector received by the Receiver would look like this:
  131.  
  132.  <command-byte><0>[rest of sector, irrelevant]
  133.  
  134.     A command that also needs to send, say, two strings to the
  135. receiver would look like this:
  136.  
  137.  <command-byte><string1><string2><0>[rest of sector, irrelevant]
  138.  
  139.     Where string1 and string2 are null-terminated.  These nulls (for
  140. the strings) should not* be mistaken for the end of command null!
  141.  
  142.     So, the receiver has received the command.  At this point, the
  143. receiver must decide if he wants to (or can) execute the command
  144. requested by the caller.  If he can, he just sends back (via WC) one
  145. byte, called GOOD, and then does what the command implies is next.
  146.  
  147.     If, for any number of reasons, he can't, he should then send
  148. back one byte, called BAD, and a null-terminated string (< 126
  149. characters) that is simply text that tells the caller why he can't
  150. execute, e.g., facility not supported, this room doesn't exist, etc.
  151. If BAD is sent back, then the caller does the next thing on his list
  152. of things to do.
  153.  
  154.     At this point, the protocol is finished and the receiver should
  155. hangup. In the future, this may have more added on for generalizing
  156. networking.
  157.  
  158. The actual values of BAD and GOOD:
  159.             BAD:  0
  160.             GOOD: 1
  161.  
  162.  
  163.  
  164. --------------------------------------------------------------------
  165.  
  166.             NET MESSAGE FORMAT
  167.  
  168.  
  169.     The format for all messages on the net (currently only the net
  170. Mail) consists of a collection of C strings (text followed by a null)
  171. that represents all the data associated each message.  Each field is
  172. identified by the first character of text in that field, and each
  173. identifier is unique. The fields may come in any order, with the
  174. exception that the Message text itself is the last field. Any data
  175. following the null byte that ends the Message field is assumed to be
  176. part of the next message, or the almost inevitable garbage that
  177. occurs in the last sector of a WC transfer.
  178.  
  179.     All data is straight ASCII, ended with a null byte, including
  180. those fields that could* be encoded in binary.
  181.  
  182.     The following fields and identifiers are currently supported.
  183.  
  184. Identifier    Data                    Max Length
  185. ----------    ----                    ----------
  186. 'A'        Author of current message.        125
  187. 'D'        Date on which message was written.    19
  188. 'N'        Name of system which message was    19
  189.         written on.
  190. 'O'        ID of system which message was written    19
  191.         on (i.e., "US 612 866 1804").
  192. 'R'        Room which message was originally    19
  193.         written in.
  194. 'S'        Message ID on source system, in old    19
  195.         CP/M Citadel 8-bit style (i.e., 32 bit
  196.         number split into two 16 bitters.  See
  197.         below in the example).
  198. 'T'        Recipient of message (normally for    125
  199.         private Mail).
  200. 'C'        Time message was written.        19
  201. 'M'        Message text, all CRs changed to Line    9999
  202.         Feeds.
  203. 'Z'        Network routing code, in the form    21
  204.         @<sigchar><message-id of routing system>
  205.  
  206.     So, a message on Test System (nodeId US 612 866 1804, nodeName
  207. 'C86 Test System') that looks like this:
  208.  
  209.    86Feb01 @ 10:01 from John Flash in Other Citadels>
  210.    This is a test.
  211.  
  212.  
  213.     with a message ID of 5644 might look like this during
  214. transmission on the net:
  215.  
  216. D86Feb01<0>C10:01<0>S0 5644<0>NC-86 Test System<0>OUS 612 8661804<0>AJohn
  217. <space>Flash<0>ROther Citadels<0>Z@LUS 612 8661804<0>MThis is a test<LF><0>
  218.  
  219.    Clear as mud, right?
  220.  
  221.  
  222. --------------------------------------------------------------------
  223.  
  224.             CURRENTLY SUPPORTED FACILITIES
  225.  
  226.     So, what's available?  The following.
  227.  
  228.     NORMAL_MAIL: This is simply a request for the receiver to accept
  229. for delivery to users on the receiver's system of mail from the
  230. caller.  The command simply consists 1 byte -- no string parameters.
  231. If the receiver signals back that he can handle this facility (and
  232. he'd better, this is the first and most basic one of the network!),
  233. then the caller sends all Mail messages destined for the receiver to
  234. the receiver via WC protocol -- i.e., the receiver, after sending
  235. back the GOOD byte, goes into WC receive mode. The value of the
  236. command byte for NORMAL_MAIL is 1.
  237.  
  238.  
  239.     ROOM_FILE_REQUEST: This is a request that the receiver send to
  240. the caller the file that is in the named room.  The 'complete'
  241. command for this facility is the byte followed by two strings.  The
  242. first string is the room where the file is (supposedly) located, the
  243. second string is the name of the file that the caller wants (this
  244. must be unambiguous).  For example, if the user wanted the file
  245. named FOOBAR that resides in the room Neologisms, the command
  246. sequence (sent via WC) would look like this:
  247.  
  248. <ROOM_FILE_REQUEST command byte>Neologisms<0>FOOBAR<0><0>
  249.  
  250.     The second <0> after FOOBAR indicates that FOOBAR is the last
  251. parameter for this command.
  252.  
  253.     The receiver then must evaluate what it has just read. 
  254. Supposing that it supports file transfers, it must then determine if
  255. the room exists and if it is a directory room.  If not, it would
  256. send back a BAD byte and a string indicating the problem.  If the
  257. room is there and is directory, then it must query the directory to
  258. see if the requested file (FOOBAR).  If it's not there, then, again,
  259. the receiver sends back a BAD byte and a string indicating the
  260. problem.  If it is found, then the receiver sends back a GOOD byte
  261. (via WC) and then goes into WC send mode; the caller, upon receipt
  262. of the GOOD byte, goes into WC receive mode.  The receiver then
  263. sends via WC the requested file.  The value of the ROOM_FILE_REQUEST
  264. is 2.
  265.  
  266.  
  267.     AMBIGUOUS_FILE_TRANSFERS: This is an expansion of the above
  268. facility, allowing the request of multiple files from a given
  269. Directory room.  Data format for the request is the same as above,
  270. with the exception that the command byte's value will (of course) be
  271. different.  The receiver then checks for the existence of the room,
  272. and whether or not it is a directory room.  If either is false, then
  273. it replies BAD to the caller, along with a reason.  If both are true,
  274. then the receiver replies GOOD.
  275.  
  276.     The files that match the given ambiguous file name (the match
  277. itself depends on the receiver's operating system) are now sent. 
  278. Each file ("filename") that matches goes through the following
  279. sequential process.
  280.  
  281.  a) The receiver sends the filename and the size of the file (the
  282.     size calculated in 128 byte sectors) through WC protocol.  Both
  283.     the file name and the size are C strings. For instance, if the
  284.     file SEX.ED is to be sent, and is 12877 bytes long, the receiver
  285.     would send to the caller the following data block:
  286.  
  287.            SEX.ED<0>101<0><rest of sector, irrelevant>
  288.  
  289.     Note that the size of the sectors is 101 rather than 100 -- the
  290.     size is rounded up.
  291.  
  292.  b) After finishing the above data, the receiver then sends the file
  293.     itself, also (of course) via WC.
  294.  
  295.     At the moment, the file size is not used for anything. However,
  296. it may prove useful in the future, since sending a file can be
  297. aborted by the caller by sending a CAN rather than a NAK.
  298.  
  299.     When the receiver has no more files to send, the file name ""
  300. (i.e., just a 0 byte rather than a file name) is sent. 
  301. AMBIGUOUS_FILE_REQUEST command byte value is 3.
  302.  
  303.     In STadel, AMBIGUOUS_FILE_REQUEST is slowly obsoleting FILE_REQUEST,
  304. because a single file request is merely an ambiguous file request with
  305. an unambiguous name.
  306.  
  307.  
  308.     HANGUP: This command is a simple 1-byte command that tells the
  309. receiver to hang up.  Upon receipt, the receiver doesn't bother with
  310. replying to the caller -- he just hangs up. Obviously, the caller
  311. should have completed all other commands by now.  The value of the
  312. HANGUP byte is 0.
  313.  
  314.  
  315.  
  316.     Other commands can (and will) be integrated into this structure
  317. with little difficulty.
  318.