home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / burroughs / b68kerdoc.txt < prev    next >
Text File  |  2020-01-01  |  23KB  |  531 lines

  1.                 B6800 KERMIT DOCUMENTATION
  2.                 ----- ------ -------------
  3.  
  4.                         12/12/84
  5.  
  6.                 Randy McLaughlin
  7.                 Metro-II
  8.                 360 Colborne
  9.                 St Paul, MN 55102
  10.         (612)227-9261
  11.  
  12.  
  13. Accompanying this document are several files which may be of assistance
  14. to anyone attempting to implement Kermit on Burroughs Large System com-
  15. puters.  We implemented Kermit on a B6800 for communications with
  16. Kermit on an Altos 586 running under Xenix.  Because this implementation
  17. depends upon NDL support, users of Bx900 and A-series machines will not
  18. be able to implement Kermit without writing similar NDLII code.  Users
  19. of smaller Burroughs machines will also find that the NDL and the main
  20. program, which is written in ALGOL are also not applicable to their
  21. environment.  In any case, I hope that the enclosed files are at least
  22. helpful as a model for other implementations.
  23.  
  24. The following files are included:
  25.     B68KERMIT.ALG    This is the source of the B6800 ALGOL program.
  26.     B68KERMIT.NDL    NDL request sets to replace READTELETYPE and
  27.                 WRITETELETYPE and associated DEFINE's.
  28.     B68KERMIT.DOC    This file--documentation of the B6800 Kermit.
  29.  
  30. Appendixes to this document provide the source for the following programs
  31. which we use on the Altos to simplify communication with B6800 Kermit.
  32.     kersh               XENIX shell for specifying files to be trans-
  33.                             ferred and for initiating Kermit on the
  34.                             B6800 for each transfer.
  35.     crend.c             A program used by KERSH to send a message to
  36.                             the B6800 terminated by a CR rather that
  37.                             a NEWLINE.
  38.     waitkerm            A program used by KERSH.  Once Kermit has been
  39.                             RUN on the B6800, WAITKERM waits for the
  40.                             B6800 Kermit to signal that it is running.
  41.  
  42.  
  43. SOME HISTORY
  44. ---- -------
  45. My original approach to implementing Kermit was to write a single
  46. ALGOL program which provided the entire Kermit service, from
  47. packetizing and depacketizing messages to specification of files
  48. to transfer.  This program, once run, would stay in the mix until
  49. specifically told to terminate.  It would then process any number of
  50. file transfers requested from the remote end.
  51.  
  52. One big problem with the above aproach was that Kermit was too sluggish.
  53. A file transfer would frequently fail because of the delay imposed
  54. transferring the data from the DCP to the main system, waking the DCC,
  55. and then waking the Kermit application.  Especially in a full mix,
  56. Kermit would simply take too long to acknowledge a packet.  I thus
  57. resorted to moving the depacketing and acknowledgement functions to
  58. NDL.  The path towards this solution was guided by earlier work I
  59. had done implementing a different, but somewhat similar protocol for
  60. file transfers to and from Apples.  As Kermit, and the earlier Apple
  61. program we not MCS's, but were instead run under CANDE, and because
  62. the same line had to accomodate both the file transfer protocol and
  63. the generic TTY interface, I had to resort to some tricks to get the
  64. NDL to switch protocols.
  65.  
  66. I also encountered problems which again were familiar from work on the
  67. Apple interface.  One is that the file naming conventions on the B6800
  68. do not correspond to either those on an Apple or a UNIX machine.  Both
  69. Kermit and the Apple program assume that one intends to use the same
  70. name for the file on both ends of the transfer.  I therefore wanted to
  71. provide facilities for specifying the file name for both ends of the
  72. link.  Another more substantial problem is that the B6800 likes to
  73. work with fixed record length, whereas the other machines use a vari-
  74. able length format.  When transfering from the B6800 to another computer
  75. simply stripping off trailing blanks and separating records with a
  76. CR and a LF.  Coming the other way though, either a facility had to
  77. be provided to allow specification of record and block sizes, or some
  78. kind of assumption had to be made.  Although additional code could have
  79. been added to allow specification of these parameters inside of a large
  80. continuous B6800 Kermit, human interaction with a program on the other
  81. machine would be cleaner and easier, and these attributes can be spec-
  82. ified at run time under CANDE without any additional code.
  83.  
  84. Thus the decision was made to change the B6800 Kermit to exist only for
  85. the duration of a single file transfer, returning to CANDE between
  86. transfers.  This also allowed any additional file manipulation to be
  87. done under CANDE without subjecting the user to manually terminating
  88. and reinitiating the transfer.  This was also natural considering the
  89. frequency that only a single file needs to be transferred.  The name
  90. of the file, its record and block size, and any other attributes are
  91. thus specified through the mechanism of file equation.  Indeed,
  92. the direction of transfer is specified through use of the MYUSE file
  93. attribute.  A shell was then written on the Altos to ask for the per-
  94. tenent attributes, format them into a CANDE RUN statement and pass it
  95. on to the B6800.  This was much easier to write and to use than the
  96. older approach.
  97.  
  98. THE NDL TO PROGRAM INTERFACE
  99. --- --- -- ------- ---------
  100. Because any program except an MCS has very little control over NDL and
  101. because of the requirement that generic TTY traffic not be affected
  102. in any way by the imposition of the Kermit protocol on top of the TTY
  103. protocol, no obvious means existed for the Kermit program to tell the
  104. NDL that it should now expect and acknowledge Kermit packets.  However
  105. a slighly tricky means did exist for communicating this state change.
  106. This trick relies on two unlikely elements in the format of data to be
  107. transmitted which when occuring together signify the special state
  108. change signal.  One is the specific request that no carriage control
  109. be done (ALGOL WRITE(<filename> [STOP], ...) ).  In our shop, this is
  110. used only infrequently.  The other key to a protocol signal is that the
  111. first character of the message begins with an EBCDIC character in the
  112. range 4"B0" to 4"BF".  Since these do not translate to any ASCII char-
  113. acter, they resemble an invalid punch on a WFL deck--something you
  114. should never find in the first (or any other position) of a record.
  115.  
  116. Most of the characters were already defined for Apple protocol state
  117. changes, but 4"BF" was not, and was chosen to represent a Kermit
  118. protocol selection.  At this point the only Kermit protocol service
  119. available in NDL is to automatically receive and acknowledge data
  120. ("D") packets.
  121.  
  122. To initiate Kermit auto receive in the NDL then, the Kermit program
  123. writes (with STOP) a message consisting of the 4"BF" character,
  124. the Pad Count (as found in an "S" packet), the Pad Character,
  125. the maximum packet length, the sequence number of the packet last
  126. recieved (which will be acked), and the type of packet involved.
  127. At this point only the sequence number (in the range 4"20" to 4"5F")
  128. is significant, the other values are ignored.  The message must consist
  129. of exactly this number of characters to be seen as a request to
  130. initiate Kermit auto receive.
  131.  
  132. The NDL will then verify proper formation of packets, sequence numbers,
  133. and checksums.  If the packet is a "D" (data) packet, it is then either
  134. ACKed or NAKed depending on the results of the tests.  If a packet other
  135. than a "D" packet is received, it is passed through the DCP to the
  136. program and NDL auto receive is terminated, returning the NDL to normal
  137. TTY handling.  In order to distinguish data from packets received in
  138. auto receive mode from packets which are passed through unchecked and
  139. unprocessed, data from auto receive packets is marked by a leading
  140. 4"BF" character.  Any messages read by the Kermit application which are
  141. not preceded  by the 4"BF" mark must be verified programmatically for
  142. form and content and programmatically acknowledged.  There are sit-
  143. uations where only the single 4"BF" character is returned to the appli-
  144. cation.  In this case auto receive is still in force, no data is present
  145. and the message can be ignored.  A break indication (bit 13 in the IO
  146. result word) indicates a timeout has occured, probably because Kermit
  147. at the other end has terminated without warning.
  148.  
  149. Note that when NDL auto receive is initiated, it will issue an ACK for
  150. a packet of the sequence number specified in the characters following
  151. 4"BF".  The sequence number is then incremented, and auto receive ini-
  152. tiated.  Messages then read by the application which start with the
  153. 4"BF" auto receive mark need no acknowledgement from the application.
  154. Once a message is read which is not marked with 4"BF", it and subsequent
  155. messages must be acknowledged in the appropriate manner from the appli-
  156. cation unless auto receive is reinitiated.  Auto receive can be re-
  157. initiated, if needed, the same way it is originally initiated.  Remember
  158. that the first action of such an initiation is to send an ACK packet.
  159.  
  160.  
  161. THE NDL REQUEST SETS
  162. --- --- ------- ----
  163. Included with this tape are replacement READTELETYPE and WRITETELETYPE
  164. NDL request sets.  These work with unmodified SPEEDSENSE and CONTENTION
  165. controls.  These request sets make heavy use of the DEFINE facility
  166. and a number of defines are also included at the beginning of the file.
  167. Those DEFINEs which precede the READTELETYPE request are common to both
  168. requests and should be placed in your NDL before the first declaration
  169. of a control or request.  Because of the close relationship between
  170. the Kermit protocol and our local Apple file xfer protocol, I have not
  171. attempted to untangle them and have included all of these two request
  172. sets as currently implemented.  This should probably have no effect on
  173. your operation, as the Apple code will only be entered if specifically
  174. requested by use of the WRITE([STOP]) construct and a leading 4"B0" to
  175. 4"BE" code, something not likely to accidently occur.  If you desire
  176. cleaner code, or if you have local patches to incorporate, I leave
  177. the task of modifying (and more painfully, testing) the request sets
  178. to you.
  179.  
  180. I have selected sequence ranges such that the supplied code can be
  181. dropped right in in some empty ranges in the 34PR1 SYMBOL/SOURCENDL.
  182. Be sure to patch out the original READTELETYPE and WRITETELETYPE
  183. requests.
  184.  
  185. One other important patch which must be made is to change the
  186. declaration of all terminals using the new request sets to specify
  187. CODE = ASCII(BINARY).  As this will vary depending upon the structure
  188. of your NDL, I have not attempted to include any lines of this patch
  189. in the provided file.
  190.  
  191.  
  192. THE KERMIT ALGOL PROGRAM
  193. --- ------ ----- -------
  194. As described above, the B6800 Kermit application is written in ALGOL,
  195. handles one file transfer (in either direction) and relies upon
  196. file attribute equation for specification of what to transfer and
  197. the format of the file.  The file to be transfered from or to has
  198. an internal name of FYLE and defaults to KIND=DISK and FRAMESIZE=8.
  199. If MYUSE is INPUT then FYLE will be the source of a file transfer from
  200. the B6800 to your other computer.  If MYUSE is OUTPUT the file transfer
  201. will be from your other computer into FYLE.  TITLE will have to be
  202. set to actual name of the B6800 file involved in the transfer.
  203. You may also want to set NEWFILE to an appropriate value.
  204.  
  205. If MYUSE is INPUT, setting the DEPENDENTSPECS attribute is usually the
  206. only other attribute equation needed.  It will then allow the system
  207. to set the record and block sizes as appropriate.  Any other relevant
  208. attributes may also be equated as well.
  209.  
  210. If MYUSE is OUTPUT, you will need to specify MAXRECSIZE and BLOCKSIZE.
  211. By default, these will be in character (byte) units, though the
  212. FRAMESIZE attribute may be used to override this default.  You may
  213. let the system calculate a default AREASIZE or set this attribute
  214. specifically.  Likewise with AREAS.  Of course, you can set any other
  215. attributes as well.
  216.  
  217. The Kermit protocol specifies that an "F" packet must sent from the
  218. sender to the receiver of a file before file transfer commences.  This
  219. packet is conventionally used to provide the name of the file to trans-
  220. fer to at the receiving end.  When the B6800 is the receiver, the
  221. content of this packet is ignored, relying instead upon file equation
  222. at run time.  When the B6800 is the sender, though, the other computer
  223. will be expecting the "F" packet to contain a file name.  Since the name
  224. used on the B6800 probably differs from the name to be used on the
  225. other computer, this name must also be specified at run time.  The
  226. mechanism for specifying this is through a string parameter to the
  227. program.  This parameter must also be provided when the B6800 serves as
  228. the receiver, but is ignored and may consist of an empty string.
  229.  
  230. In addition, at the time the Kermit application is run, it may be
  231. placed into monitor mode by specifying a TASKVALUE of 1.  This is
  232. done by the task equation VALUE=1 from CANDE.  Since TASKVALUE defaults
  233. to zero, the TASKVALUE equation needs only to be made when monitor mode
  234. is to be requested.  When in monitor mode, all traffic to the remote
  235. (datacom) file is sent in both character and hex representations to
  236. the printer.  This can be quite useful in debugging situations and
  237. I would reccommend setting it the first few times you run Kermit, both
  238. to check what is going on and to provide a baseline example should you
  239. later encounter trouble or make modifications.
  240.  
  241. To summarize the syntax for running the Kermit application from CANDE is
  242. as follows:
  243.     To transfer a file to the B6800:
  244.         --- RUN KERMIT(""); ------------------------>
  245.                              !              A
  246.                              --- VALUE=1; --!
  247.  
  248.         >---FILE FYLE(MYUSE=OUT,MAXRECSIZE=<mrsz>,BLOCKSIZE=<blksz> -->
  249.  
  250.         >---TITLE=<B6800 file title>, <any other attibutes>   ) ---!
  251.  
  252.         Where <mrsz> ::= size of a record in characters
  253.               <blksz>::= size of a block in characters
  254.               <B6800 file title> ::= a name for the file to be created
  255.               <any other attributes> ::= any other file attribute
  256.                                          equations which should be used
  257.  
  258.  
  259.     To transfer from the B6800:
  260.         --- RUN KERMIT("<destination file name">);------------------>
  261.                                                    !             A
  262.                                                    --- VALUE=1;--!
  263.  
  264.         >----FILE FYLE(MYUSE=IN,DEPENDENTSPECS,TITLE=<B6800 name> -->
  265.  
  266.         >----<any other attributes> --- ) -----!
  267.  
  268.         Where <destination file name> ::= the name of the file to trans-
  269.                                           fer to
  270.               <B6800 name>  ::= the name of the file on the B6800 from
  271.                                 which to transfer data.
  272.               <any other attributes> ::= any other file attribute
  273.                                          equations which apply
  274.  
  275.  
  276.     For example:
  277.  
  278.         RUN KERMIT("");VALUE=1;FILE FYLE(MYUSE=OUT,MAXRECSIZE=90,
  279.                         BLOCKSIZE=1800,TITLE="A/NEW/FILE/IS/BORN")
  280.  
  281.             Will start Kermit receiving a file to be named
  282.             A/NEW/FILE/IS/BORN under your usercode.  Monitor mode
  283.             is requested.
  284.  
  285.  
  286.         RUN KERMIT("/usr/randy/junk.file");FILE FYLE(MYUSE=IN,
  287.                     DEPENDENTSPECS,TITLE="(BURRO)JUNK/FILE")
  288.  
  289.             Will start Kermit sending JUNK/FILE from the BURRO usercode
  290.         to the other computer where it will create a file called
  291.         /usr/randy/junk.file.  Monitor mode is not requested.
  292.  
  293. The Kermit application is designed for an environment where someone
  294. who wishes to initiate a file transfer to or from the B6800 is at
  295. a terminal connected to a micro or mini computer using the "connect"
  296. facility of Kermit, or some other terminal program to allow logging
  297. on to the B6800 and initiating Kermit on the B6800.  Once initiated,
  298. Kermit will verify the file attributes specified and if no error is
  299. found, Kermit will open its remote file and send a DEL character to
  300. indicate that it is up and running.  If an attribute error is found
  301. or if for some other reason Kermit finds that it cannot perform the
  302. requested transfer, Kermit will send a message describing the error
  303. followed by a NAK character.  Using a terminal program (or Kermit
  304. "connect") the user would have to wait while the B6800 started its
  305. Kermit until seeing CANDE return the "?#" indication that it has
  306. opened a remote file, and then waiting briefly to see if any error
  307. messages are sent before terminating the terminal connection and
  308. initiating their local Kermit.  I have included the source for a program
  309. which does that waiting.  It sends the text of all messages received
  310. from the B6800 to default output (presumably the operator's terminal)
  311. until B6800 Kermit send either a DEL or a NAK, at which point the program
  312. terminates.  The source for this program, waitkerm.c can be found in 
  313. Appendix C.
  314.  
  315. I have also included a XENIX shell which allows a user to initiate any
  316. number of Kermit transfers to/from the B6800.  It forms the proper
  317. CANDE RUN statement, sends it to CANDE and then uses waitkerm to wait
  318. for B6800 Kermit to signal its presence.  The shell will then fire off
  319. a local Kermit to communicate with B6800 Kermit.  I would suggest that
  320. you use it, or a similar shell or program to similarly isolate the user
  321. from the complexities of the interface, or at least to reduce the volume
  322. of typing necessary to get things going.
  323.  
  324. Because the B6800 expects lines entered from a terminal to terminate with
  325. a CR, rather than a newline, the ECHO command doesn't work.  The source for
  326. a simple echo program which emits a CR rather than a NL is included in 
  327. Appendix B.  It produces a program called crend, which is used in many places
  328. in the inclulded shell.
  329.  
  330. If B6800 Kermit encounters an error that it cannot resolve, it will send
  331. an "E" packet before terminating.  The "E" packet will contain a
  332. description of the error encountered.  Not all Kermits display the
  333. text contained in an "E" packet, but I would reccommend adding that
  334. capability so you can be aware of what happened if B6800 Kermit decides
  335. to abandon you.
  336.  
  337. I have included only the source for the Kermit application.  If you
  338. wish to use it as is, it requires only a simple ALGOL compile.  No
  339. unusual task or file equations are needed at compile time.
  340.  
  341. APPENDIX A.   
  342. -------- -
  343. Kersh, a UNIX shell for initiating Kermit transfers to/from a B6800:
  344.  
  345. tty=/dev/tty5
  346. speed=1200
  347. setmode $tty $speed &
  348.  
  349. trap " " 2
  350. trap " " 3
  351. echo A program to dial the B6800 was initiated at this point
  352. echo Wait for the B6800 to respond, then log on, and then hit control-c
  353. kermit cle $tty 3
  354.  
  355. while test "$RESPONSE" != "q"
  356. do
  357.     echo '(s)end, (r)eceive, (c)onnect or (q)uit?'
  358.     read RESPONSE
  359.  
  360.     case $RESPONSE in
  361.      Q)      
  362.             RESPONSE="q"
  363.             ;;
  364.     d|D)
  365.         echo 'set debug on(+) or off(-)?'
  366.         read DEBUG
  367.         if test "$DEBUG" = on
  368.         then DEBUG="+"
  369.         fi
  370.         ;;
  371.     c|C)
  372.         echo Connecting to remote system.
  373.         echo Type control-c to return to local system.
  374.         kermit cle $tty 3
  375.         ;;
  376.     s|r|S|R)
  377.             case $RESPONSE in
  378.                     s|S)    echo Enter name of local file to send
  379.                     read LOCNAME
  380.                 echo  Enter name of file to create remotely
  381.                  read RMTNAME
  382.                 echo What is the maximum record size?
  383.                 read MAXRSZ
  384.                 echo What is the block size to be?
  385.                 read BLKSZ
  386.                 echo Enter any other attributes for destination file
  387.  
  388.                 read ATTB
  389.                 echo -n 'R KERMIT("");' >$tty
  390.                 if test "$DEBUG" = +
  391.                 then echo -n "VALUE=1;" > $tty
  392.                 fi
  393.                 echo -n 'FILE FYLE(MYUSE=OUT,MAXRECSIZE=' >$tty   
  394.                 echo -n "$MAXRSZ, BLOCKSIZE= $BLKSZ" >$tty
  395.                 echo -n ',TITLE=' "$RMTNAME" > $tty
  396.                 if test "$ATTB" != ""
  397.                 then   echo -n ", $ATTB" > $tty
  398.                 fi 
  399.                 crend ')' > $tty
  400.                 ;;
  401.               R|r)      echo Enter name of remote file to copy
  402.                     read RMTNAME
  403.                 echo Enter name of file to create locally  
  404.                 read LOCNAME
  405.                 echo Enter any other attributes for the remote file
  406.                 read ATTB
  407.                 echo -n "R KERMIT(\"$LOCNAME\");" > $tty
  408.                 if test "$DEBUG" = +
  409.                 then echo -n "VALUE=1;" > $tty
  410.                 fi
  411.                 echo -n 'FILE FYLE(MYUSE=IN,'  > $tty
  412.                 echo -n 'DEPENDENTSPECS,TITLE=' > $tty
  413.                 echo -n "$RMTNAME" > $tty
  414.                 if test "$ATTB" != ""
  415.                 then echo -n ", $ATTB" > $tty
  416.                 fi
  417.                 crend ')' > $tty
  418.                 ;;
  419.         *)        ;;
  420.         esac
  421.  
  422.         echo Waiting for kermit on the remote system.
  423.         if waitkerm $tty
  424.         then
  425.             case $RESPONSE in
  426.                    r|R) kermit rldm $tty 
  427.             ;;
  428.             s|S) kermit sld $tty $LOCNAME
  429.             ;;
  430.             esac
  431.  
  432.             crend > $tty
  433.             crend ?END > $tty
  434.         else echo
  435.         fi
  436.         ;;
  437.     *)  ;;
  438.     esac
  439.  
  440. done
  441.  
  442. echo -n terminating
  443. crend > $tty
  444. echo -n '.'
  445. sleep 2 
  446. crend '?END' >$tty
  447. echo -n '.'
  448. sleep 2 
  449. crend SA REC >$tty
  450. echo -n '.'
  451. sleep 2 
  452. crend BYE >$tty
  453. echo -n '.'
  454. kill -9 `ps -a|grep tty5|grep setmode|awk '{print $1}'`
  455. stty 0 >$tty
  456. echo
  457.  
  458.  
  459. APPENDIX B.
  460. -------- --
  461. crend-- an echo program which terminates a line with a CR instead of a NL:
  462.  
  463. main (argc,argv)
  464. int argc;
  465. char *argv[];
  466.   {
  467.     while (--argc>0)
  468.         printf("%s%c",*++argv,(argc>1)?' ':'\r');
  469.   }
  470.  
  471.  
  472. APPENDIX C.
  473. -------- -
  474. waitkerm-- a program which waits for B6800 Kermit to start functioning:
  475.  
  476. /* This program waits for the B6800 Kermit program to come up and signal
  477.    that it is ready.  It will normally return zero but will return a non-
  478.    zero value if B6800 Kermit did not properly begin.
  479.  
  480.    The name of the line to the B6800 is specified in the command line following
  481.    waitkerm.
  482.  
  483.    For example, to wait for kermit to come up on a B6800 connected thru a modem
  484.    which is connected to the TTY5 port:
  485.     waitkerm /dev/tty5
  486. */
  487. #include <stdio.h>
  488. #include <signal.h>
  489. #include <sgtty.h>
  490. struct sgttyb termio;
  491.  
  492. main(argc,argv)  
  493.     int argc;
  494.     char **argv;
  495. {
  496.     int cflag, fd;
  497.     char c, getone();
  498.     int failure(), success();
  499.  
  500.     signal(SIGHUP, failure);
  501.     signal(SIGINT, success);
  502.     setbuf(stdin,(char *)0);
  503.     setbuf(stdout,(char *)0);
  504.     setbuf(stderr,(char *)0);  
  505.  
  506.     if ((fd = open (*++argv,2)) < 0) {
  507.     printf("Can't open %s\n",*argv);
  508.     exit(1);
  509.     }
  510.     ioctl(fd,TIOCGETP,&termio);  /* get the terminal io structure */
  511.     termio.sg_flags &= ~(ECHO | CRMOD);  /* turn off echo and crmod modes */
  512.     termio.sg_flags |= CBREAK;  /* return each character as soon as typed */
  513.     ioctl(fd,TIOCSETP,&termio);
  514.  
  515.     while (c != '\177') {
  516.     read(fd,&c,1);
  517.     if (c == '\025') failure();
  518.         putchar(c);
  519.     }
  520.     exit(0);     
  521. }
  522. success()
  523. {
  524.     exit(0);
  525. }
  526. failure()
  527. {
  528.     exit(1);
  529. }
  530.  
  531.