home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / protocol / kproto.txt < prev    next >
Text File  |  2020-01-01  |  208KB  |  4,221 lines

  1.  
  2.                             KERMIT PROTOCOL MANUAL
  3.  
  4.                                  Sixth Edition
  5.  
  6.  
  7.  
  8.                                  Frank da Cruz
  9.  
  10.               Columbia University Center for Computing Activities
  11.                            New York, New York 10027
  12.  
  13.  
  14.                                    June 1986
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                             Copyright (C) 1981,1986
  22.             Trustees of Columbia University in the City of New York
  23.  
  24.        Permission is granted to any individual or institution to copy or
  25.         use this document and the programs described in it, except for
  26.                         explicitly commercial purposes.
  27.  
  28.  
  29.                          PREFACE TO THE SIXTH EDITION
  30.  
  31. The sixth edition (June 1986) of the Kermit Protocol Manual is being issued for
  32. two major reasons: to correct minor errors in the fifth edition, and to include
  33. new  sections  on  two major protocol extensions: long packets and sliding win-
  34. dows.  No attempt has been made to reorganize, rewrite,  or  otherwise  improve
  35. the  protocol  manual.    The Kermit protocol has been presented in an entirely
  36. different -- hopefully more thorough, organized, coherent, and useful  (if  not
  37. more  formal)  --  manner  in  the book, "Kermit, A File Transfer Protocol," by
  38. Frank da Cruz, Digital Press, Bedford MA (1987), ISBN 0-932376-88-6, DEC  order
  39. number EY-6705E-DP.  If you have the book, you won't need this protocol manual.
  40. On the other hand, if you don't have the book, this manual should still contain
  41. all  the necessary information.  The Kermit Protocol Manual will continue to be
  42. freely distributed in perpetuity.
  43.  
  44. The bare-bones C-language Kermit program that appeared as an appendix  in  pre-
  45. vious editions has been removed.  It was not a particularly good example of how
  46. to write a Kermit program, and made the manual unnecessarily thick.  For sample
  47. Kermit  programs,  see  the  source  code for any of the hundreds of Kermit im-
  48. plementations, or follow the program fragments in the book.
  49.  
  50.  
  51.                          PREFACE TO THE FIFTH EDITION
  52.  
  53. The fifth edition (March 1984) attempts to clarify some fine  points  that  had
  54. been  left  ambiguous in the 4th edition, particularly with respect to when and
  55. how prefix encoding is done, and when it is not, and  about  switching  between
  56. block  check  types.   A mechanism is suggested (in the Attributes section) for
  57. file archiving, and several attributes have been  rearranged  and  some  others
  58. added  (this should do no harm, since no one to date has attempted to implement
  59. the attributes packet).  A more complete protocol state table  is  provided,  a
  60. few minor additions are made to the collection of packet types.
  61.  
  62.  
  63.                          PREFACE TO THE FOURTH EDITION
  64.  
  65. The  fourth  edition (November 1983) of the Kermit Protocol Manual incorporates
  66. some new ideas that grew from our experience in attempting to implement some of
  67. the features described in earlier editions, particularly user/server functions.
  68. These include a mechanism to allow batch transfers to be interrupted gracefully
  69. for  either the current file or the entire batch of files; a "capability mask";
  70. a protocol extension for passing file attributes.  In addition, numbers are now
  71. written  in  decimal  notation  rather  than octal, which was confusing to many
  72. readers.  Also, several incompatible changes were made in minor areas where  no
  73. attempts at an implementation had yet been made; these include:
  74.  
  75.    - The format and interpretation of the operands to the server commands.
  76.  
  77.    - Usurpation  of the reserved fields 10-11 of the Send-Init packet, and
  78.      addition of new reserved fields.
  79.  
  80. Most of the remaining material has been rewritten and reorganized, and much new
  81. material  added, including a section on the recommended vocabulary for documen-
  82. tation and commands.
  83.  
  84. The previous edition of the Protocol Manual attempted to define "protocol  ver-
  85. sion  3";  this  edition abandons that concept.  Since Kermit development is an
  86. unorganized, disorderly, distributed enterprise, no requirement can be  imposed
  87. on  Kermit  implementors  to include a certain set of capabilities in their im-
  88. plementations.  Rather,  in  this  edition  we  attempt  to  define  the  basic
  89. functionality of Kermit, and then describe various optional functions.
  90.  
  91. The  key  principle  is  that any implementation of Kermit should work with any
  92. other, no matter how advanced the one or how primitive the other.  The capabily
  93. mask and other Send-Init fields attempt to promote this principle.
  94.  
  95.  
  96.  
  97.                                ACKNOWLEDGEMENTS
  98.  
  99. Bill  Catchings and I designed the basic Kermit protocol at Columbia University
  100. in 1981.  For ideas, we looked at some of the ANSI models (X3.57,  X3.66),  the
  101. ISO OSI model, some real-world "asynchronous protocols" (including the Stanford
  102. Dialnet and TTYFTP projects, the University of Utah Small FTP project), as well
  103. as at file transfer on full-blown networks like DECnet and ARPAnet.
  104.  
  105. Bill  wrote  the  first  two  programs  to  implement the protocol, one for the
  106. DEC-20, one for a CP/M-80 microcomputer, and in the process worked out most  of
  107. the details and heuristics required for basic file transfer.  Meanwhile, Daphne
  108. Tzoar and Vace Kundakci, also of Columbia, worked out  the  additional  details
  109. necessary  for IBM mainframe communication, while writing IBM VM/CMS and PC-DOS
  110. versions.
  111.  
  112. Much credit should also go to Bernie Eiben of Digital Equipment Corporation for
  113. promoting  widespread  use  of  Kermit and for adding many insights into how it
  114. should operate, to Nick Bush and Bob McQueen of Stevens Institute  of  Technol-
  115. ogy,  for  many  contributions to the "advanced" parts of the protocol, and for
  116. several major Kermit implementations, and to Leslie Spira and her group at  The
  117. Source  Telecomputing  for  adding full-duplex sliding window capability to the
  118. Kermit protocol.
  119.  
  120. Thanks to the many people all over the world who have  contributed  new  Kermit
  121. implementations,  who have helped with Kermit distribution through various user
  122. groups, and who have contributed to the quality of the protocol  and  its  many
  123. implementations  by  reporting  or  fixing problems, criticizing the design, or
  124. suggesting new features.  In particular, thanks to Ted Toal of Nevada City, CA,
  125. for a detailed list of corrections to the fifth edition of this manual.
  126.  
  127. And  above  all,  thanks  to  Christine  Gianone for taking charge of Kermit at
  128. Columbia; for keeping it alive, healthy, and strong; for promoting its develop-
  129. ment  and  use  all  over  the  world;  for setting its tone and direction; for
  130. fostering its spirit.  Without her guidance  and  perserverance,  Kermit  might
  131. have faded from the scene years ago.
  132.  
  133. The  Kermit  protocol  was  named after Kermit the Frog, star of the television
  134. series THE MUPPET SHOW.  The name is used by permission of  Henson  Associates,
  135. Inc., New York City.
  136.  
  137.  
  138.                                   DISCLAIMER
  139.  
  140. No  warranty of the software nor of the accuracy of the documentation surround-
  141. ing it is expressed or implied, and neither the authors nor Columbia University
  142. acknowledge any liability resulting from program or documentation errors.
  143.  
  144. 1. Introduction
  145.  
  146. This manual describes the  Kermit  protocol.  It is assumed that you understand
  147. the purpose and operation of the Kermit file transfer  facility,  described  in
  148. the  Kermit  Users Guide, and basic terminology of data communications and com-
  149. puter programming.
  150.  
  151.  
  152. 1.1. Background
  153.  
  154. The Kermit file transfer protocol is intended for use in an  environment  where
  155. there  may  be  a  diverse  mixture of computers -- micros, personal computers,
  156. workstations, laboratory computers, timesharing systems -- from  a  variety  of
  157. manufacturers.    All  these systems need have in common is the ability to com-
  158. municate in ASCII over ordinary serial telecommunication lines.
  159.  
  160. Kermit was originally designed at Columbia University to meet the need for file
  161. transfer  between  our  DECSYSTEM-20  and IBM 370-series mainframes and various
  162. microcomputers.  It turned out that the diverse characteristics of these  three
  163. kinds of systems resulted in a design that was general enough to fit almost any
  164. system.  The IBM mainframe, in  particular,  strains  most  common  assumptions
  165. about how computers communicate.
  166.  
  167. 1.2. Overview
  168.  
  169. The  Kermit  protocol is specifically designed for character-oriented transmis-
  170. sion over serial telecommunication lines.  The design allows for  the  restric-
  171. tions and peculiarities of the medium and the requirements of diverse operating
  172. environments -- buffering, duplex, parity, character  set,  file  organization,
  173. etc.   The protocol is carried out by Kermit programs on each end of the serial
  174. connection sending "packets" back and forth; the sender sends file names,  file
  175. contents,  and  control  information;  the receiver acknowledges (positively or
  176. negatively) each packet.
  177.  
  178. The packets have a layered design, more or less in keeping with  the  ANSI  and
  179. ISO  philosophies,  with  the  outermost  fields used by the data link layer to
  180. verify data integrity, the next by the session layer to verify continuity,  and
  181. the data itself at the application level.
  182.  
  183. Connections between systems are established by the ordinary user.  In a typical
  184. case, the user runs Kermit on a microcomputer, enters terminal emulation,  con-
  185. nects  to  a remote host computer (perhaps by dialing up), logs in, runs Kermit
  186. on the remote host, and then issues commands to that Kermit  to  start  a  file
  187. transfer,  "escapes"  back  to the micro, and issues commands to that Kermit to
  188. start its side of the file transfer.  Files may be  transferred  singly  or  in
  189. groups.
  190.  
  191. Basic  Kermit  provides only file transfer, and that is provided for sequential
  192. files only, though the protocol attempts to allow for various types of  sequen-
  193. tial  files.    Microcomputer  implementations  of  Kermit are also expected to
  194. provide terminal emulation, to facilitate the initial connection.
  195.  
  196. More advanced implementations simplify the "user interface" somewhat by  allow-
  197. ing  the  Kermit  on  the  remote host to run as a "server", which can transfer
  198. files in either direction upon command from the local "user" Kermit.  The serv-
  199. er  can  also  provide  additional functionality, such as file management, mes-
  200. sages, mail, and so forth.  Other optional features  also  exist,  including  a
  201. variety  of  block  check  types,  a mechanism for passing 8-bit data through a
  202. 7-bit communication link, a way to compressing a repeated sequence  of  charac-
  203. ters, and so forth.
  204.  
  205. As  local area networks become more popular, inexpensive, and standardized, the
  206. demand for Kermit and similar protocols may dwindle, but will never wither away
  207. entirely.   Unlike hardwired networks, Kermit gives the ordinary user the power
  208. to establish reliable error-free connections between any  two  computers;  this
  209. may always be necessary for one-shot or long-haul connections.
  210.  
  211. 1.3. General Terminology
  212.  
  213. TTY:  This  is the term commonly used for a device which is connected to a com-
  214. puter over an EIA RS-232 serial telecommunication line.  This  device  is  most
  215. commonly  an  ASCII  terminal,  but  it  may be a microcomputer or even a large
  216. multi-user computer emulating  an  ASCII  terminal.    Most  computers  provide
  217. hardware (RS-232 connectors and UARTs) and software (device drivers) to support
  218. TTY connections; this is what makes TTY-oriented file transfer  protocols  like
  219. Kermit possible on almost any system at little or no cost.
  220.  
  221. LOCAL:  When two machines are connected, the LOCAL machine is the one which you
  222. interact with directly, and which is in control of the terminal.    The  "local
  223. Kermit"  is the one that runs on the local machine.  A local Kermit always com-
  224. municates over an external device (the micro's communication port, an  assigned
  225. TTY line, etc).
  226.  
  227. REMOTE:  The REMOTE machine is the one on the far side of the connection, which
  228. you must interact with "through" the local machine.  The "remote  Kermit"  runs
  229. on the remote machine.  A remote Kermit usually communicates over its own "con-
  230. sole", "controlling terminal", or "standard i/o" device.
  231.  
  232. HOST: Another word for "computer", usually meaning a computer that can  provide
  233. a home for multiple users or applications.  This term should be avoided in Ker-
  234. mit lore, unless preceded immediately by LOCAL or REMOTE, to denote which  host
  235. is meant.
  236.  
  237. SERVER:  An  implementation of remote Kermit that can accept commands in packet
  238. form from a local Kermit program, instead of directly from the user.
  239.  
  240. USER: In addition to its usual use to denote  the  person  using  a  system  or
  241. program,  "user"  will also be used refer to the local Kermit program, when the
  242. remote Kermit is a server.
  243.  
  244. 1.4. Numbers
  245.  
  246. All numbers in the following text are expressed in decimal (base  10)  notation
  247. unless otherwise specified.
  248.  
  249. Numbers  are  also  referred  to  in terms of their bit positions in a computer
  250. word.  Since Kermit may be implemented on computers with various word sizes, we
  251. start  numbering  the  bits from the "right" -- bit 0 is the least significant.
  252. Bits 0-5 are the 6 least significant bits; if they were all  set  to  one,  the
  253. value would be 63.
  254.  
  255. A  special  quirk  in  terminology,  however, refers to the high order bit of a
  256. character as it is transmitted on the communication line,  as  the  "8th  bit".
  257. More  properly, it is bit 7, since we start counting from 0.  References to the
  258. "8th bit" generally are with regard to that bit which ASCII  transmission  sets
  259. aside  for  use  as a parity bit.  Kermit concerns itself with whether this bit
  260. can be usurped for the transmission of data, and  if  not,  it  may  resort  to
  261. "8th-bit prefixing".
  262.  
  263. 1.5. Character Set
  264.  
  265. All  characters  are in ASCII  (American national Standard Code for Information
  266. Interchange) representation, ANSI standard X3.4-1968.  All  implementations  of
  267. Kermit  transmit and receive characters only in ASCII.  The ASCII character set
  268. is listed in Appendix III.
  269.  
  270. ASCII character mnemonics:
  271.  
  272. NUL     Null, idle, ASCII character 0.
  273. SOH     Start-of-header, ASCII character 1 (Control-A).
  274. SP      Space, blank, ASCII 32.
  275. CR      Carriage return, ASCII 13 (Control-M).
  276. LF      Linefeed, ASCII 10 (Control-J).
  277. CRLF    A carriage-return linefeed sequence.
  278. DEL     Delete, rubout, ASCII 127.
  279.  
  280. A control character is considered to be any byte whose low order 7 bits are  in
  281. the  range 0 through 31, or equal to 127.  In this document, control characters
  282. are written in several ways:
  283.  
  284. Control-A
  285.         This  denotes  ASCII  character 1, commonly referred to as "Control-A".
  286.         Control-B is ASCII character 2, and so forth.
  287.  
  288. CTRL-A  This is a common abbreviation for "Control-A".  A control character  is
  289.         generally  typed  at a computer terminal by holding down the key marked
  290.         CTRL and pressing the corresponding alphabetic character, in this  case
  291.         "A".
  292.  
  293. ^A      "Uparrow"  notation  for  CTRL-A.  Many computer systems "echo" control
  294.         characters in this fashion.
  295.  
  296. A printable ASCII character is considered to be any character in the  range  32
  297. (SP) through 126 (tilde).
  298.  
  299. 1.6. Conversion Functions
  300.  
  301. Several  conversion functions are useful in the description of the protocol and
  302. in the program example.  The machine that Kermit runs on need operate  only  on
  303. integer data; these are functions that operate upon the numeric value of single
  304. ASCII characters.
  305.  
  306. tochar(x) = x+32
  307.     Transforms  the  integer  x,  which is assumed to lie in the range 0 to 94,
  308.     into a printable ASCII character; 0 becomes SP, 1 becomes  "!",  3  becomes
  309.     "#", etc.
  310.  
  311. unchar(x) = x-32
  312.     Transforms the character x, which is assumed to be in the  printable  range
  313.     (SP through tilde), into an integer in the range 0 to 94.
  314.  
  315. ctl(x) = x XOR 64
  316.     Maps  between  control  characters  and  their  printable  representations,
  317.     preserving the high-order bit.  If x is a control character, then
  318.  
  319.         x = ctl(ctl(x))
  320.  
  321.     that  is,  the same function is used to controllify and uncontrollify.  The
  322.     argument is assumed to be a true control character (0 to 31,  or  127),  or
  323.     the  result  of  applying  CTL to a true control character (i.e. 63 to 95).
  324.     The transformation is a mnemonic one -- ^A becomes A and vice versa.
  325.  
  326. 1.7. Protocol Jargon
  327.  
  328. A Packet is a clearly delimited string of  characters,  comprised  of  "control
  329. fields" nested around data; the control fields allow a Kermit program to deter-
  330. mine whether the data has been transmitted correctly and completely.  A  packet
  331. is the unit of transmission in the Kermit protocol.
  332.  
  333. ACK  stands  for "Acknowledge".  An ACK is a packet that is sent to acknowledge
  334. receipt of another packet.  Not to be confused with the ASCII character ACK.
  335.  
  336. NAK stands for "Negative Acknowledge".  A NAK is a packet sent to  say  that  a
  337. corrupted  or incomplete packet was received, the wrong packet was received, or
  338. an expected packet was not received.  Not to be confused with the ASCII charac-
  339. ter NAK.
  340.  
  341. A  timeout is an event that can occur if expected data does not arrive within a
  342. specified amount of time.  The program generating the input request can  set  a
  343. "timer  interrupt"  to  break  it out of a nonresponsive read, so that recovery
  344. procedures may be activated.
  345.  
  346.  
  347. 2. Environment
  348.  
  349. 2.1. System Requirements
  350.  
  351. The Kermit protocol requires that:
  352.  
  353.    - The host can send and receive characters using 7- or 8-bit ASCII  en-
  354.      coding  over  an  EIA RS-232 physical connection, either hardwired or
  355.      dialup.
  356.  
  357.    - All printable ASCII characters are acceptable as input  to  the  host
  358.      and  will  not  be  transformed  in any way[If they are translated to
  359.      another character set, like EBCDIC, the Kermit program must  be  able
  360.      to  reconstruct  the packet as it appeared on the communication line,
  361.      before transformation.].  Similarly, any intervening network or  com-
  362.      munications   equipment   ("smart  modems",  TELENET,  terminal  con-
  363.      centrators, port selectors, etc) must not transform  or  swallow  any
  364.      printable ASCII characters.
  365.  
  366.    - A  single  ASCII  control  character  can pass from one system to the
  367.      other without transformation.  This  character  is  used  for  packet
  368.      synchronization.  The character is normally Control-A (SOH, ASCII 1),
  369.      but can be redefined.
  370.  
  371.    - If a host requires a line terminator for terminal  input,  that  ter-
  372.      minator  must  be a single ASCII control character, such as CR or LF,
  373.      distinct from the packet synchronization character.
  374.  
  375.    - When using a job's controlling terminal for file transfer, the system
  376.      must  allow  the  Kermit  program to set the terminal to no echo, in-
  377.      finite width (no "wraparound" or CRLF insertion by the operating sys-
  378.      tem), and no "formatting" of incoming or outgoing characters (for in-
  379.      stance, raising lowercase letters to uppercase, transforming  control
  380.      characters to printable sequences, etc).  In short, the terminal must
  381.      be put in "binary" or "raw" mode, and, hopefully, restored afterwards
  382.      to normal operation.
  383.  
  384.    - The  host's terminal input processor should be capable of receiving a
  385.      single burst of 40 to 100 characters at normal  transmission  speeds.
  386.      This is the typical size of packet.
  387.  
  388. Note  that  most  of  these requirements rule out the use of Kermit through IBM
  389. 3270 / ASCII protocol converters, except those (like the Series/1 or 7171  run-
  390. ning the Yale ASCII package) that can be put in "transparant mode."
  391.  
  392. Kermit does not require:
  393.  
  394.    - That the connection run at any particular baud rate.
  395.  
  396.    - That  the  system can do  XON/XOFF or any other kind of flow control.
  397.      System- or hardware-level flow control can help, but it's not  neces-
  398.      sary.  See section 3.7.
  399.  
  400.    - That  the system is capable of full duplex operation.  Any mixture of
  401.      half and full duplex systems is supported.
  402.  
  403.    - That the system can transmit or receive 8-bit  bytes.    Kermit  will
  404.      take advantage of 8-bit connections to send binary files; if an 8-bit
  405.      connection is not possible, then binary files may be  sent  using  an
  406.      optional prefix encoding.
  407.  
  408.  
  409. 2.2. Printable Text versus Binary Data
  410.  
  411. For  transmission  between  unlike systems, files must be assigned to either of
  412. two catagories: printable text or binary.
  413.  
  414. A printable text file is one that can make sense on an unlike system -- a docu-
  415. ment,  program  source,  textual data, etc.  A binary file is one that will not
  416. (and probably can not) make sense on an unlike system -- an executable program,
  417. numbers stored in internal format, etc.  On systems with 8-bit bytes, printable
  418. ASCII files will have the high order bit of each byte  set  to  zero(There  are
  419. some  exceptions,  such as systems that store text files in so-called "negative
  420. ASCII", or text files produced by word processors that use the high  order  bit
  421. to  indicate  underline or boldface attributes.)  (since ASCII is a 7-bit code)
  422. whereas binary files will use the high order bit of  each  byte  for  data,  in
  423. which case its value can vary from byte to byte.
  424.  
  425. Many  computers  have no way to distinguish a printable file from a binary file
  426. -- especially one originating from an unlike system -- so the user may have  to
  427. give  an explicit command to Kermit to tell it whether to perform these conver-
  428. sions.
  429.  
  430. 2.2.1. Printable Text Files
  431.  
  432. A primary goal of Kermit is for printable text files to be useful on the target
  433. system after transfer.  This requires a standard representation for text during
  434. transmission.  Kermit's standard is simple: 7-bit ASCII characters, with "logi-
  435. cal  records"  (lines) delimited by CRLFs.  It is the responsibility of systems
  436. that do not store printable files in this fashion to perform the necessary con-
  437. versions  upon  input  and  output.    For instance, IBM mainframes might strip
  438. trailing blanks on output and add them back on input; UNIX would prepend  a  CR
  439. to its normal record terminator, LF, upon output and discard it upon input.  In
  440. addition, IBM mainframes must do EBCDIC/ASCII translation for text files.
  441.  
  442. No other conversions (e.g. tab expansion) are performed upon text files.   This
  443. representation  is  chosen  because  it  corresponds  to the way text files are
  444. stored on most microcomputers and on many other systems.  In many common cases,
  445. no transformations are necessary at all.
  446.  
  447. 2.2.2. Binary Files
  448.  
  449. Binary files are transmitted as though they were a sequence of characters.  The
  450. difference from printable files is that the status of the  "8th  bit"  must  be
  451. preserved.  When binary files are transmitted to an unlike system, the main ob-
  452. jective is that they can be brought back to the original system  (or  one  like
  453. it)  intact;  no special conversions should be done during transmission, except
  454. to make the data fit the transmission medium.
  455.  
  456. For binary files, eight bit character transmission is permissible  as  long  as
  457. the  two  Kermit programs involved can control the value of the parity bit, and
  458. no intervening communications equipment will change its value.  In  that  case,
  459. the  8th  bit  of  a transmitted character will match that of the original data
  460. byte, after any control-prefixing has been done.  When one or both sides cannot
  461. control  the  parity  bit,  a  special  prefix  character  may  be inserted, as
  462. described below.
  463.  
  464. Systems that do not store binary data in 8-bit bytes, or whose word size is not
  465. a  multiple  of 8, may make special provisions for "image mode" transfer of bi-
  466. nary files.  This may be done within the basic protocol by having the two sides
  467. implicitly  agree  upon  a  scheme  for packing the data into 7- or 8-bit ASCII
  468. characters, or else the more flexible (but optional)  file  attributes  feature
  469. may  be  used.    The  former method is used on PDP-10 36-bit word machines, in
  470. which text is stored five 7-bit bytes per word; the value of the "odd  bit"  is
  471. sent as the parity bit of every 5th word.
  472.  
  473. 3. File Transfer
  474.  
  475. The file transfer protocol takes place over a transaction.  A transaction is an
  476. exchange of packets beginning with a Send-Init (S) packet, and  ending  with  a
  477. Break  Transmission  (B)  or Error (E) packet(A transaction should also be con-
  478. sidered terminated when one side or the other has stopped  without  sending  an
  479. Error  packet.),  and may include the transfer of one or more files, all in the
  480. same direction.  In order to minimize the unforseen, Kermit packets do not con-
  481. tain  any control characters except one specially designated to mark the begin-
  482. ning of a packet.  Except for the packet marker, only printable characters  are
  483. transmitted.   The following sequence characterizes basic Kermit operation; the
  484. sender is the machine that is  sending  files;  the  receiver  is  the  machine
  485. receiving the files.
  486.  
  487.    1. The  sender  transmits  a  Send-Initiate  (S)  packet to specify its
  488.       parameters (packet length, timeout, etc; these are explained below).
  489.  
  490.    2. The receiver sends an ACK (Y) packet, with its own parameters in the
  491.       data field.
  492.  
  493.    3. The  sender  transmits  a File-Header (F) packet, which contains the
  494.       file's name in the data field.  The receiver ACKs the F packet, with
  495.       no data in the data field of the ACK (optionally, it may contain the
  496.       name under which the receiver will store the file).
  497.  
  498.    4. The sender sends the contents of the file, in Data (D) packets.  Any
  499.       data not in the printable range is prefixed and replaced by a print-
  500.       able equivalent.  Each D packet is acknowledged before the next  one
  501.       is sent.
  502.  
  503.    5. When  all  the  file data has been sent, the sender sends an End-Of-
  504.       File (Z) packet.  The receiver ACKs it.
  505.  
  506.    6. If there is another file to send, the process is repeated  beginning
  507.       at step 3.
  508.  
  509.    7. When  no  more files remain to be sent, the sender transmits an End-
  510.       Of-Transmission (B) packet.  The receiver ACKs it.   This  ends  the
  511.       transaction, and closes the logical connection (the physical connec-
  512.       tion remains open).
  513.  
  514. Each packet has a sequence number, starting with 0 for the Send Init.  The ack-
  515. nowledgment  (ACK or NAK) for a packet has the same packet number as the packet
  516. being acknowledged.  Once an acknowledgment is successfully received the packet
  517. number is increased by one, modulo 64.
  518.  
  519. If  the  sender  is remote, it waits for a certain amount of time (somewhere in
  520. the 5-30 second range) before transmitting the Send-Init, to give the user time
  521. to escape back to the local Kermit and tell it to receive files.
  522.  
  523. Each  transaction  starts fresh, as if no previous transaction had taken place.
  524. For example, the sequence number is set back to zero, and parameters are  reset
  525. to their default or user-selected values.
  526.  
  527. 3.1. Conditioning the Terminal
  528.  
  529. Kermit is most commonly run with the user sitting at a microcomputer, connected
  530. through a communications port to a remote timesharing system.  The remote  Ker-
  531. mit is using its job's own "controlling terminal" for file transfer.  While the
  532. microcomputer's port is an ordinary device,  a  timesharing  job's  controlling
  533. terminal  is  a special one, and often performs many services that would inter-
  534. fere with normal operation of Kermit.  Such services include echoing  (on  full
  535. duplex systems), wrapping lines by inserting carriage return linefeed sequences
  536. at the terminal width, pausing at the end of a screen or  page  full  of  text,
  537. displaying  system  messages, alphabetic case conversion, control character in-
  538. tepretation, and so forth.  Mainframe Kermit programs  should  be  prepared  to
  539. disable  as  many  of  these  services  as possible before packet communication
  540. begins, and to restore them to their original condition at the end of a  trans-
  541. action.   Disabling these services is usually known as "putting the terminal in
  542. binary mode."
  543.  
  544. Kermit's use  of  printable  control  character  equivalents,  variable  packet
  545. lengths,  redefinable markers and prefixes, and allowance for any characters at
  546. all to appear between packets with no adverse effects provide a great  deal  of
  547. adaptability for those systems that do not allow certain (or any) of these fea-
  548. tures to be disabled.
  549.  
  550. 3.2. Timeouts, NAKs, and Retries
  551.  
  552. If a Kermit program is capable of setting a timer interrupt, or setting a  time
  553. limit on an input request, it should do so whenever attempting to read a packet
  554. from the communication line, whether sending or receiving files.  Having read a
  555. packet, it should turn off the timer.
  556.  
  557. If the sender times out waiting for an acknowledgement, it should send the same
  558. packet again, repeating the process a certain number of times  up  to  a  retry
  559. limit,  or  until  an  acknowledgement  is received.  If the receiver times out
  560. waiting for a packet, it can send either a NAK packet for the  expected  packet
  561. or another ACK for the last packet it got.  The latter is preferred.
  562.  
  563. If  a  packet from the sender is garbled or lost in transmission (the latter is
  564. detected by a timeout, the former by a bad checksum), the receiver sends a  NAK
  565. for  the  garbled  or  missing packet.  If an ACK or a NAK from the receiver is
  566. garbled or lost, the sender ignores it; in that case, one  side  or  the  other
  567. will time out and retransmit.
  568.  
  569. A  retry  count  is  maintained,  and  there is a retry threshold, normally set
  570. around 5.  Whenever a packet is resent -- because of a timeout, or  because  it
  571. was  NAK'd  --  the counter is incremented.  When it reaches the threshold, the
  572. transaction is terminated and the counter reset.
  573.  
  574. If neither side is capable of timing out, a facility  for  manual  intervention
  575. must  be  available on the local Kermit.  Typically, this will work by sampling
  576. the keyboard (console) periodically; if input, such as a CR, appears, then  the
  577. same  action  is  taken as if a timeout had occurred.  The local Kermit keeps a
  578. running display of the packet number or byte count on the screen to  allow  the
  579. user  to  detect  when traffic has stopped.  At this point, manual intervention
  580. should break the deadlock.
  581.  
  582. Shared systems which can become sluggish when heavily used should adjust  their
  583. own  timeout intervals on a per-packet basis, based on the system load, so that
  584. file transfers won't fail simply because the system was too slow.
  585.  
  586. Normally, only one side should be doing timeouts, preferably the side with  the
  587. greatest  knowledge  of  the  "environment"  --  system load, baud rate, and so
  588. forth, so as to optimally adjust the timeout interval for each packet.  If both
  589. sides  are  timing  out, their intervals should differ sufficiently to minimize
  590. collisions.
  591.  
  592. 3.3. Errors
  593.  
  594. During file transfer, the sender may encounter an i/o error on the disk, or the
  595. receiver  may  attempt  to write to a full or write-protected device.  Any con-
  596. dition that will prevent successful transmission of the file is called a "fatal
  597. error".    Fatal  errors  should be detected, and the transfer shut down grace-
  598. fully, with the pertinent information provided to  the  user.    Error  packets
  599. provide a mechanism to do this.
  600.  
  601. If  a fatal error takes place on either the sending or receiving side, the side
  602. which encountered the error should send an Error (E) packet.  The E packet con-
  603. tains  a  brief  textual  error message in the data field.  Both the sender and
  604. receiver should be prepared to receive an Error packet at any time  during  the
  605. transaction.   Both the sender and receiver of the Error packet should halt, or
  606. go back into into user command mode (a server should return to  server  command
  607. wait).  The side that is local should print the error message on the screen.
  608.  
  609. There  is no provision for sending nonfatal error messages, warnings, or infor-
  610. mation messages during a transaction.  It would be possible to add such a  fea-
  611. ture,  but  this  would require both sides agree to use it through setting of a
  612. bit in the capability mask, since older Kermits that did not know about such  a
  613. feature would encounter an unexpected packet type and would enter the fatal er-
  614. ror state.  In any case, the utility of such a feature is  questionable,  since
  615. there is no guarantee that the user will be present to see such messages at the
  616. time they are sent; even if they are saved up for later perusal in  a  "message
  617. box", their significance may be long past by the time the user reads them.  See
  618. the section on Robustness, below.
  619.  
  620. 3.4. Heuristics
  621.  
  622. During any transaction, several heuristics are useful:
  623.  
  624.    1. A NAK for the current packet is equivalent to an ACK  for  the  pre-
  625.       vious  packet  (modulo  64).    This handles the common situation in
  626.       which a packet is successfully received, and then ACK'd, but the ACK
  627.       is lost.  The ACKing side then times out waiting for the next packet
  628.       and NAKs it.  The side that receives a  NAK  for  packet  n+1  while
  629.       waiting for an ACK for packet n simply sends packet n+1.
  630.  
  631.    2. If  packet  n  arrives more than once, simply ACK it and discard it.
  632.       This can happen when the first ACK was lost.  Resending the  ACK  is
  633.       necessary  and  sufficient -- don't write the packet out to the file
  634.       again!
  635.  
  636.    3. When opening a connection, discard the contents of the line's  input
  637.       buffer  before  reading  or sending the first packet.  This is espe-
  638.       cially important if the other side is in receive mode (or acting  as
  639.       a  server), in which case it may have been sending out periodic NAKs
  640.       for your expected SEND-INIT or command packet.    If  you  don't  do
  641.       this,  you  may  find  that there are sufficient NAKs to prevent the
  642.       transfer -- you send a Send-Init, read the response, which is an old
  643.       NAK,  so  you  send another Send-Init, read the next old NAK, and so
  644.       forth, up to the retransmission limit, and give up before getting to
  645.       the  ACKs  that are waiting in line behind all the old NAKs.  If the
  646.       number of NAKs is below the cutoff, then each packet may  be  trans-
  647.       mitted multiply.
  648.  
  649.    4. Similarly, before sending a packet, you should clear the input buff-
  650.       er (after looking for any required handshake character).  Failure to
  651.       clear  the buffer could result in propogation of the repetition of a
  652.       packet caused by stacked-up NAKs.
  653.  
  654.    5. If an ACK arrives for a packet that has already been  ACK'd,  simply
  655.       ignore  the redundant ACK and wait for the next ACK, which should be
  656.       on its way.
  657.  
  658. 3.5. File Names
  659.  
  660. The syntax for file names can vary widely from system  to  system.    To  avoid
  661. problems,  it is suggested that filenames be represented in the File Header (F)
  662. packet in a "normal form", by default (that is, there should be  an  option  to
  663. override such conversions).
  664.  
  665.    1. Delete  all  pathnames  and  attributes from the file specification.
  666.       The file header packet should not contain directory or device names;
  667.       if  it  does, it may cause the recipient to try to store the file in
  668.       an inaccessible or nonexistent area, or it  may  result  in  a  very
  669.       strange filename.
  670.  
  671.    2. After  stripping  any  pathname,  convert  the remainder of the file
  672.       specification to the form "name.type", with no restriction on length
  673.       (except that it fit in the data field of the F packet), and:
  674.  
  675.          a. Include no more than one dot.
  676.          b. Not begin or end with a dot.
  677.          c. The name and type fields contain digits and uppercase letters.
  678.  
  679. Special  characters like "$", "_", "-", "&", and so forth should be disallowed,
  680. since they're sure to cause problems on one system or another.
  681.  
  682. The recipient, of course, cannot depend upon the sender to follow this  conven-
  683. tion,  and should still take precautions.  However, since most file systems em-
  684. body the notion of a file name and a file  type,  this  convention  will  allow
  685. these items to be expressed in a way that an unlike system can understand.  The
  686. particular notation is chosen simply because it is the most common.
  687.  
  688. The recipient must worry about the length of the name and type  fields  of  the
  689. file  name.    If  either  is  too long, they must be truncated.  If the result
  690. (whether truncated or not) is the same as the name of a file that  already  ex-
  691. ists  in the same area, the recipient should have the ability to take some spe-
  692. cial action to avoid writing over the original file.
  693.  
  694. Kermit implementations that convert  file  specifications  to  normal  form  by
  695. default  should  have  an  option to override this feature.  This would be most
  696. useful when transferring files between like systems, perhaps used  in  conjunc-
  697. tion with "image mode" file transfer.  This could allow, for instance, one UNIX
  698. system to send an entire directory tree to another UNIX system.
  699.  
  700. 3.6. Robustness
  701.  
  702. A major feature of the Kermit protocol is  the  ability  to  transfer  multiple
  703. files.    Whether  a particular Kermit program can actually send multiple files
  704. depends on the capabilities of the program and the host operating  system  (any
  705. Kermit program can receive multiple files).
  706.  
  707. If  a  Kermit  program can send multiple files, it should make every attempt to
  708. send the entire group specified.  If it fails to send  a  particular  file,  it
  709. should  not  terminate the entire batch, but should go on the the next one, and
  710. proceed until an attempt has been made to send each file in the group.
  711.  
  712. Operating in this robust manner, however, gives rise to  a  problem:  the  user
  713. must  be  notified of a failure to send any particular file.  Unfortunately, it
  714. is not sufficient to print a message to the screen since the user  may  not  be
  715. physically  present.   A better solution would be to have the sender optionally
  716. keep a log of the  transaction, giving the name of each file for which  an  at-
  717. tempt was made, and stating whether the attempt was successful, and if not, the
  718. reason.  Additional aids to robustness are described in the  Optional  Features
  719. section, below.
  720.  
  721. 3.7. Flow Control
  722.  
  723. On full duplex connections, XON/XOFF flow control can generally be used in con-
  724. junction with Kermit file transfer with no ill effects.  This is because  XOFFs
  725. are  sent  in the opposite direction of packet flow, so they will not interfere
  726. with the packets themselves.  XON/XOFF, therefore, need not be  implemented  by
  727. the  Kermit  program,  but  can  done  by  the host system.  If the host system
  728. provides this capability, it should be  used  --  if  both  sides  can  respond
  729. XON/XOFF  signals,  then  buffer  overruns  and  the  resulting  costly  packet
  730. retransmissions can be avoided.
  731.  
  732. Beware, however, of the following situation: remote Kermit is sending  periodic
  733. NAKs, local system is buffering them on the operating system level (because the
  734. user has not started the local end of the file transfer yet); local line buffer
  735. becomes  full, local systems sends XOFF, remote starts buffering them up on its
  736. end, user finally starts file transfer  on  local  end,  clears  buffer,  local
  737. operating  system  sends  XON, and then all the remotely buffered NAKs show up,
  738. causing the packet echoing problem described above, despite the  buffer  clear-
  739. ing.
  740.  
  741. Flow control via modem signals can also be used when available.
  742.  
  743. Note  that  flow  control should not be confused with "handshake" or "line tur-
  744. naround" techniques that are  used  on  simplex  or  half-duplex  communication
  745. lines.  In fact, the two techniques are mutually exclusive.
  746.  
  747. 3.8. Basic Kermit Protocol State Table
  748.  
  749. The  Kermit  protocol  can be described as a set of states and transitions, and
  750. rules for what to do when changing from one state to another.    State  changes
  751. occur  based  on  the type of packets that are sent or received, or errors that
  752. may occur.  Packets always go back and forth; the sender of a file always sends
  753. data  packets of some kind (init, header, data) and the receiver always returns
  754. ACK or NAK packets.
  755.  
  756. Upon entering a given state, a certain kind of packet is either being  sent  or
  757. is expected to arrive -- this is shown on top of the description of that state.
  758. As a result of the action, various responses may occur; these are shown in  the
  759. EVENT column.  For each event, an appropriate ACTION is taken, and the protocol
  760. enters a NEW STATE.
  761.  
  762. The following table specifies basic Kermit operation.  Timeouts and error  con-
  763. ditions  have been omitted from the following table for simplicity, but the ac-
  764. tion is as described above.  Server operation and some of the advanced features
  765. are also omitted.  A full-blown state table is given subsequently.
  766.  
  767.     STATE   EVENT           ACTION                      NEW STATE
  768.  
  769.          -- SEND STATES --
  770.  
  771.     Send Send-Init Packet:
  772.     S       Get NAK,bad ACK (None)                          S
  773.             Get good ACK    Set remote's params, open file  SF
  774.             (Other)         (None)                          A
  775.  
  776.     Send File-Header Packet
  777.     SF      Get NAK,bad ACK (None)                          SF
  778.             Get good ACK    Get bufferful of file data      SD
  779.             (Other)         (None)                          A
  780.  
  781.     Send File-Data Packet
  782.     SD      Get NAK,bad ACK (None)                          SD
  783.             Get good ACK    Get bufferful of file data      SD
  784.             (End of file)   (None)                          SZ
  785.             (Other)         (None)                          A
  786.  
  787.     Send EOF Packet
  788.     SZ      Get NAK,bad ACK (None)                          SZ
  789.             Get good ACK    Get next file to send           SF
  790.             (No more files) (None)                          SB
  791.             (Other)         (None)                          A
  792.  
  793.     Send Break (EOT) Packet
  794.     SB      Get NAK,bad ACK (None)                          SB
  795.             Get good ACK    (None)                          C
  796.             (Other)         (None)                          A
  797.  
  798.  
  799.          -- RECEIVE STATES --
  800.  
  801.     Wait for Send-Init Packet
  802.     R       Get Send-Init   ACK w/local params              RF
  803.             (Other)         (None)                          A
  804.  
  805.     Wait for File-Header Packet
  806.     RF      Get Send-Init   ACK w/local params
  807.                              (previous ACK was lost)        RF
  808.             Get Send-EOF    ACK (prev ACK lost)             RF
  809.             Get Break       ACK                             C
  810.             Get File-Header Open file, ACK                  RD
  811.             (Other)         (None)                          A
  812.  
  813.     Wait for File-Data Packet
  814.     RD      Get previous
  815.              packet(D,F)    ACK it again                    RD
  816.             Get EOF         ACK it, close the file          RF
  817.             Get good data   Write to file, ACK              RD
  818.             (Other)         (None)                          A
  819.  
  820.  
  821.          -- STATES COMMON TO SENDING AND RECEIVING --
  822.  
  823.     C       (Send Complete)                                 start
  824.     A       ("Abort")                                       start
  825.  
  826. 4. Packet Format
  827.  
  828. 4.1. Fields
  829.  
  830. The  Kermit  protocol is built around exchange of packets of the following for-
  831. mat:
  832.  
  833.     +------+-------------+-------------+------+------------+-------+
  834.     | MARK | tochar(LEN) | tochar(SEQ) | TYPE |    DATA    | CHECK |
  835.     +------+-------------+-------------+------+------------+-------+
  836.  
  837. where all fields consist of ASCII characters.  The fields are:
  838.  
  839. MARK    The synchronization character that marks the beginning of  the  packet.
  840.         This should normally be CTRL-A, but may be redefined.
  841.  
  842. LEN     The  number  of  ASCII  characters  within  the packet that follow this
  843.         field, in other words the packet length minus two.  Since  this  number
  844.         is  transformed to a single character via the tochar() function, packet
  845.         character counts of 0 to 94 (decimal) are permitted, and  96  (decimal)
  846.         is  the  maximum total packet length.  The length does not include end-
  847.         of-line or padding characters, which are outside  the  packet  and  are
  848.         strictly  for  the  benefit  of  the operating system or communications
  849.         equipment, but it does include the block check characters.
  850.  
  851. SEQ     The packet sequence number, modulo 64, ranging from 0 to 63.   Sequence
  852.         numbers "wrap around" to 0 after each group of 64 packets.
  853.  
  854. TYPE    The  packet type, a single ASCII character.  The following packet types
  855.         are required:
  856.  
  857.         D   Data packet
  858.         Y   Acknowledge (ACK)
  859.         N   Negative acknowledge (NAK)
  860.         S   Send initiate (exchange parameters)
  861.         B   Break transmission (EOT)
  862.         F   File header
  863.         Z   End of file (EOF)
  864.         E   Error
  865.         Q   Reserved for internal use
  866.         T   Reserved for internal use
  867.  
  868. The NAK packet is used only to  indicate  that  the  expected  packet  was  not
  869.         received correctly, never to supply other kinds of information, such as
  870.         refusal to perform a requested service.  The NAK packet always  has  an
  871.         empty  data  field.    The T "packet" is used internally by many Kermit
  872.         programs to indicate that a timeout occurred.
  873.  
  874. DATA    The "contents" of the packet, if any contents are required in the given
  875.         type  of  packet,  interpreted  according  to the packet type.  Control
  876.         characters (bytes whose low order 7 bits are in the ASCII control range
  877.         0-31, or 127) are preceded by a special prefix character, normally "#",
  878.         and "uncontrollified" via ctl().  A prefixed sequence may not be broken
  879.         across  packets.  Logical records in printable files are delimited with
  880.         CRLFs, suitably prefixed (e.g. "#M#J").  Logical records need not  cor-
  881.         respond  to  packets.  Any prefix characters are included in the count.
  882.         Optional encoding for 8-bit data and repeated characters  is  described
  883.         later.   The data fields of all packets are subject to prefix encoding,
  884.         except the S, I, and A packets and their acknowledgements,  which  must
  885.         not be encoded.
  886.  
  887. CHECK   A  block check on the characters in the packet between, but not includ-
  888.         ing, the mark and the block check itself.  The check for each packet is
  889.         computed  by  both hosts, and must agree if a packet is to be accepted.
  890.         A single-character arithmetic checksum is the normal and required block
  891.         check.    Only  six  bits of the arithmetic sum are included.  In order
  892.         that all the bits of each data character contribute to  this  quantity,
  893.         bits  6  and  7  of the final value are added to the quantity formed by
  894.         bits 0-5.  Thus if s is the arithmetic sum  of  the  ASCII  characters,
  895.         then
  896.  
  897.             check = tochar((s + ((s AND 192)/64)) AND 63)
  898.  
  899.         This  is  the  default  block check, and all Kermits must be capable of
  900.         performing it.  Other optional block check types are described later.
  901.  
  902.         The block check is based on the ASCII values of all the  characters  in
  903.         the  packet, including control fields and prefix characters.  Non-ASCII
  904.         systems must translate to ASCII before performing the block check  cal-
  905.         culation.
  906.  
  907. 4.2. Terminator
  908.  
  909. Any  line  terminator  that  is  required  by the system may be appended to the
  910. packet; this is carriage return (ASCII 15) by default.   Line  terminators  are
  911. not  considered part of the packet, and are not included in the count or check-
  912. sum.  Terminators are not necessary to the protocol, and are invisible  to  it,
  913. as  are  any  characters  that may appear between packets.  If a host cannot do
  914. single character input from a TTY line, then a terminator will be required when
  915. sending  to  that host.  The terminator can be specified in the initial connec-
  916. tion exchange.
  917.  
  918. Some Kermit implementations also use  the  terminator  for  another  reason  --
  919. speed.    Some  systems  are  not fast enough to take in a packet and decode it
  920. character by character at high baud rates; by blindly reading and  storing  all
  921. characters  between  the MARK and the EOL, they are able to absorb the incoming
  922. characters at full speed and then process them at their own rate.
  923.  
  924. 4.3. Other Interpacket Data
  925.  
  926. The space between packets may be used for any  desired  purpose.    Handshaking
  927. characters  may  be necessary on certain connections, others may require screen
  928. control or other sequences to keep the packets flowing.
  929.  
  930. 4.4. Encoding, Prefixing, Block Check
  931.  
  932. MARK, LEN, SEQ, TYPE, and CHECK are control fields.  Control fields are  always
  933. literal single-character fields, except that the CHECK field may be extended by
  934. one or two additional check characters.   Each  control  field  is  encoded  by
  935. tochar() or taken literally, but never prefixed.  The control fields never con-
  936. tain 8-bit data.
  937.  
  938. The DATA field contains a string  of  data  characters  in  which  any  control
  939. characters  are  encoded  printably  and preceded with the control prefix.  The
  940. decision to prefix a character in this way depends upon whether its low order 7
  941. bits  are in the ASCII control range, i.e. 0-31 or 127.  Prefix characters that
  942. appear in the data must themselves be prefixed by the control prefix,  but  un-
  943. like  control  characters, these retain their literal value in the packet.  The
  944. character to be prefixed is considered a prefix character if  its  low-order  7
  945. bits  corresponds  to  an  active  prefix  character,  such  as  #  (ASCII 35),
  946. regardless of the setting of its high-order bit.
  947.  
  948. During decoding, any character that follows the control prefix, but is  not  in
  949. the  control  range,  is  taken  literally.   Thus, it does no harm to prefix a
  950. printable character, even if that character does not happen  to  be  an  active
  951. prefix.
  952.  
  953. The treatment of the high order ("8th") bit of a data byte is as follows:
  954.  
  955.    - If  the  communication channel allows 8 data bits per character, then
  956.      the original value of the 8th bit is retained in the prefixed charac-
  957.      ter.  For instance, a data byte corresponding to a Control-A with the
  958.      8th bit set would be send as a control prefix, normally "#",  without
  959.      the 8th bit set, followed by ctl(^A) with the 8th bit set.  In binary
  960.      notation, this would be
  961.  
  962.          00100011 11000001
  963.  
  964.      In this case, the 8th bit is figured into all  block  check  calcula-
  965.      tions.
  966.  
  967.    - If  the  communication channel or one of the hosts requires parity on
  968.      each character, and both sides are capable of 8th-bit prefixing, then
  969.      the  8th bit will be used for parity, and must not be included in the
  970.      block check.  8th bit prefixing is an  option  feature  described  in
  971.      greater detail in Section 6, below.
  972.  
  973.    - If parity is being used but 8th-bit prefixing is not being done, then
  974.      the value of the 8th bit of each data byte will be  lost  and  binary
  975.      files will not be transmitted correctly.  Again, the 8th bit does not
  976.      figure into the block check.
  977.  
  978. The data fields of all packets are subject to prefix encoding, except S, I, and
  979. A packets, and the ACKs to those packets (see below).
  980.  
  981. 5. Initial Connection
  982.  
  983. Initial connection occurs when the user has started up a Kermit program on both
  984. ends of the physical connection.  One Kermit has been directed (in one  way  or
  985. another) to send a file, and the other to receive it.
  986.  
  987. The  receiving  Kermit  waits for a "Send-Init" packet from the sending Kermit.
  988. It doesn't matter whether the sending Kermit is started  before  or  after  the
  989. receiving  Kermit  (if  before,  the  Send-Init  packet should be retransmitted
  990. periodically until the receiving Kermit acknowledges it).  The  data  field  of
  991. the  Send-Init  packet  is  optional;  trailing  fields can be omitted (or left
  992. blank, i.e. contain a space) to accept or specify default values.
  993.  
  994. The Send-Init packet contains a string of configuration information in its data
  995. field.   The receiver sends an ACK for the Send-Init, whose data field contains
  996. its own configuration parameters.  The data field of the Send-Init and the  ACK
  997. to  the  Send-Init  are literal, that is, there is no prefix encoding.  This is
  998. because the two parties will not know how to do prefix encoding until after the
  999. configuration data is exchanged.
  1000.  
  1001. It  is  important to note that newly invented fields are added at the right, so
  1002. that old Kermit programs that do not have code to handle the  new  fields  will
  1003. act  as  if  they  were  not there.  For this reason, the default value for any
  1004. field, indicated by blank, should result in the behavior that  occurred  before
  1005. the new field was defined or added.
  1006.  
  1007.    1      2      3      4      5      6      7      8      9      10...
  1008.   +------+------+------+------+------+------+------+------+------+-------
  1009.   | MAXL | TIME | NPAD | PADC | EOL  | QCTL | QBIN | CHKT | REPT | CAPAS
  1010.   +------+------+------+------+------+------+------+------+------+-------
  1011.  
  1012. The  fields  are as follows (the first and second person "I" and "you" are used
  1013. to distinguish the two sides).  Fields are encoded printably using the tochar()
  1014. function unless indicated otherwise.
  1015.  
  1016. 1. MAXL   The  maximum  length  packet  I  want  to  receive, a number up to 94
  1017.           (decimal).  (This really means the biggest value I want to see  in  a
  1018.           LEN  field.)  You respond with the maximum you want me to send.  This
  1019.           allows systems to adjust to each other's buffer sizes, or to the con-
  1020.           dition of the transmission medium.
  1021.  
  1022. 2. TIME   The  number  of  seconds  after which I want you to time me out while
  1023.           waiting for a packet from me.  You respond with the amount of time  I
  1024.           should  wait  for packets from you.  This allows the two sides to ac-
  1025.           commodate to different line speeds or other factors that could  cause
  1026.           timing  problems.    Only  one side needs to time out.  If both sides
  1027.           time out, then the timeout intervals should not be close together.
  1028.  
  1029. 3. NPAD   The number of padding characters I  want  to  precede  each  incoming
  1030.           packet;  you  respond in kind.  Padding may be necessary when sending
  1031.           to a half duplex system that requires some time to change the  direc-
  1032.           tion  of  transmission,  although  in practice this situation is more
  1033.           commonly handled by a "handshake" mechanism.
  1034.  
  1035. 4. PADC   The control character I need for  padding,  if  any,  transformed  by
  1036.           ctl()  (not  tochar())  to  make  it printable.  You respond in kind.
  1037.           Normally NUL (ASCII 0), some systems use DEL (ASCII 127).  This field
  1038.           is to be ignored if the value NPAD is zero.
  1039.  
  1040. 5. EOL    The  character  I  need to terminate an incoming packet, if any.  You
  1041.           respond in kind.  Most systems that require  a  line  terminator  for
  1042.           terminal input accept carriage return for this purpose (note, because
  1043.           there is no way to specify that no EOL should be sent, it would  have
  1044.           been  better  to  use  ctl() for this field rather than tochar(), but
  1045.           it's too late now).
  1046.  
  1047. 6. QCTL   (verbatim) The printable ASCII character I will use to quote  control
  1048.           characters,  normally  and  by default "#".  You respond with the one
  1049.           you will use.
  1050.  
  1051. The following fields relate to the use  of  OPTIONAL  features  of  the  Kermit
  1052. protocol, described in section 6.
  1053.  
  1054. 7. QBIN   (verbatim)  The  printable  ASCII  character  I  want to use to quote
  1055.           characters which have the 8th bit set, for transmitting binary  files
  1056.           when  the  parity  bit  cannot  be used for data.  Since this kind of
  1057.           quoting increases both processor and  transmission  overhead,  it  is
  1058.           normally  to be avoided.  If used, the quote character must be in the
  1059.           range ASCII 33-62 ("!" through ">") or 96-126 ("`" through "~"),  but
  1060.           different  from  the control-quoting character.  This field is inter-
  1061.           preted as follows:
  1062.  
  1063.           Y   I agree to 8-bit quoting if you request it (I don't need it).
  1064.           N   I will not do 8-bit quoting (I don't know how).
  1065.           &   (or any other character in the range 33-62 or 96-126) I  need  to
  1066.               do  8-bit  quoting  using  this character (it will be done if the
  1067.               other Kermit puts a Y in this field, or responds  with  the  same
  1068.               prefix  character,  such  as &).  The recommended 8th-bit quoting
  1069.               prefix character is "&".
  1070.           Anything Else : 8-bit quoting will not be done.
  1071.  
  1072. Note that this scheme allows either side to initiate the request, and the order
  1073.           does  not  matter.  For instance, a micro capable of 8-bit communica-
  1074.           tion will normally put a "Y" in this field whereas a  mainframe  that
  1075.           uses  parity will always put an "&".  No matter who sends first, this
  1076.           combination will result in election of 8th-bit quoting.
  1077.  
  1078. 8. CHKT   (Verbatim) Check Type, the method for  detecting  errors.    "1"  for
  1079.           single-character  checksum  (the normal and required method), "2" for
  1080.           two-character checksum (optional), "3" for three-character  CRC-CCITT
  1081.           (optional).    If your response agrees, the designated method will be
  1082.           used; otherwise the single-character checksum will be used.
  1083.  
  1084. 9. REPT   The prefix character I will use to  indicate  a  repeated  character.
  1085.           This  can  be  any  printable  character  in the range ASCII 33-62 or
  1086.           96-126, but different from the control and 8th-bit prefixes.  SP (32)
  1087.           denotes no repeat count processing is to be done.  Tilde ("~") is the
  1088.           recommended and normal repeat prefix.  If  you  don't  respond  iden-
  1089.           tically,  repeat  counts will not be done.  Groups of at least 3 or 4
  1090.           identical characters may be  transmitted  more  efficiently  using  a
  1091.           repeat  count,  though an individual implementation may wish to set a
  1092.           different threshhold.
  1093.  
  1094. 10-?. CAPAS
  1095.           A bit mask, in which each bit position corresponds to a capability of
  1096.           Kermit, and is set to 1 if that capability is present, or 0 if it  is
  1097.           not.     Each  character  contains  a  6-bit  field  (transformed  by
  1098.           tochar()), whose low order bit is set to 1 if another capability byte
  1099.           follows,  and  to  0  in  the last capability byte.  The capabilities
  1100.           defined so far are:
  1101.  
  1102.             #1  Reserved
  1103.             #2  Reserved
  1104.             #3  Ability to accept "A" packets (file attributes)
  1105.             #4  Ability to do full duplex sliding window protocol
  1106.             #5  Ability to transmit and receive extended-length packets
  1107.  
  1108. The capability byte as defined so far would then look like:
  1109.  
  1110.            bit5 bit4 bit3 bit2 bit1 bit0
  1111.           +----+----+----+----+----+----+
  1112.           | #1 | #2 | #3 | #4 | #5 |  0 |
  1113.           +----+----+----+----+----+----+
  1114.  
  1115.           If all these capabilities were "on", the value of the byte  would  be
  1116.           76  (octal).    When  capability 6 is added, the capability mask will
  1117.           look like this:
  1118.  
  1119.            bit5 bit4 bit3 bit2 bit1 bit0    bit5 bit4 bit3 bit2 bit1 bit0
  1120.           +----+----+----+----+----+----+   +----+----+----+----+----+----+
  1121.           | #1 | #2 | #3 | #4 | #5 |  1 |   | #6 | -- | -- | -- | -- |  0 |
  1122.           +----+----+----+----+----+----+   +----+----+----+----+----+----+
  1123.  
  1124. CAPAS+1. WINDO
  1125.           Window size (see section 7.2).
  1126.  
  1127. CAPAS+2. MAXLX1
  1128.           Extended packet length (see section 7.1).
  1129.  
  1130. CAPAS+3. MAXLX2
  1131.           Extended packet length (see section 7.1).
  1132.  
  1133. The  receiving  Kermit  responds with an ACK ("Y") packet in the same format to
  1134. indicate its own preferences, options, and parameters.  The ACK need  not  con-
  1135. tain  the same number of fields as the the Send-Init.  From that point, the two
  1136. Kermit programs are  "configured"  to  communicate  with  each  other  for  the
  1137. remainder  of  the  transaction.  In the case of 8th-bit quoting, one side must
  1138. specify the character to be used, and the other must agree with a  "Y"  in  the
  1139. same  field, but the order in which this occurs does not matter.  Similarly for
  1140. checksums -- if one side requests 2 character  checksums  and  the  other  side
  1141. responds  with  a  "1"  or with nothing at all, then single-character checksums
  1142. will be done, since not all implementations can be expected to  do  2-character
  1143. checksums or CRCs.  And for repeat counts; if the repeat field of the send-init
  1144. and the ACK do not agree, repeat processing will not be done.
  1145.  
  1146. All Send-Init fields are optional.  The data field may be left  totally  empty.
  1147. Similarly,  intervening fields may be defaulted by setting them to blank.  Ker-
  1148. mit implementations should know what to do in these  cases,  namely  apply  ap-
  1149. propriate defaults.  The defaults should be:
  1150.  
  1151.     MAXL:   80
  1152.     TIME:   5 seconds
  1153.     NPAD:   0, no padding
  1154.     PADC:   0 (NUL)
  1155.     EOL:    CR (carriage return)
  1156.     QCTL:   the character "#"
  1157.     QBIN:   space, can't do 8-bit quoting
  1158.     CHKT:   "1", single-character checksum
  1159.     REPT:   No repeat count processing
  1160.     CAPAS:  All zeros (no special capabilities)
  1161.     WINDO:  Blank (zero) - no sliding windows
  1162.     MAXLX1: Blank (zero) - no extended length packets
  1163.     MAXLX2: Blank (zero) - no extended length packets
  1164.  
  1165. There are no prolonged negotiations in the initial connection sequence -- there
  1166. is one Send-Init and one ACK in reply.  Everything must be settled in this  ex-
  1167. change.
  1168.  
  1169. The  very first Send-Init may not get through if the sending Kermit makes wrong
  1170. assumptions about the receiving host.  For instance, the receiving host may re-
  1171. quire  certain  parity,  some  padding,  handshaking,  or a special end of line
  1172. character in order to read the Send-Init packet.  For this reason, there should
  1173. be  a way for the user the user to specify whatever may be necessary to get the
  1174. first packet through.
  1175.  
  1176. A parity field is not provided in the Send-Init packet because it could not  be
  1177. of use.  If the sender requires a certain kind of parity, it will also be send-
  1178. ing it.  If the receiver does not know this in advance, i.e. before getting the
  1179. Send-Init, it will not be able to read the Send-Init packet.
  1180. 6. Optional Features
  1181.  
  1182. The foregoing sections have discussed basic, required operations for any Kermit
  1183. implementation.  The following sections discuss optional and advanced features.
  1184.  
  1185.  
  1186. 6.1. 8th-Bit and Repeat Count Prefixing
  1187.  
  1188. Prefix quoting of control characters is mandatory.  In addition, prefixing  may
  1189. also  be  used for 8-bit quantities or repeat counts, when both Kermit programs
  1190. agree to do so.  8th-bit prefixing can allow 8-bit  binary  data  pass  through
  1191. 7-bit  physical  links.    Repeat count prefixing can improve the throughput of
  1192. certain kinds of files  dramatically;  binary  files  (particularly  executable
  1193. programs) and structured text (highly indented or columnar text) tend to be the
  1194. major beneficiaries.
  1195.  
  1196. When more than one type of prefixing is in effect, a single data character  can
  1197. be  preceded  by  more  than one prefix character.  Repeat count processing can
  1198. only be requested by the sender, and will only be used by  the  sender  if  the
  1199. receiver  agrees.   8th-bit prefixing is a special case because its use is nor-
  1200. mally not desirable, since it increases both processing and transmission  over-
  1201. head.   However, since it is the only straightforward mechanism for binary file
  1202. transfer available to those systems that usurp the parity bit, a receiver  must
  1203. be  able  to  request the sender to do 8th-bit quoting, since most senders will
  1204. not normally do it by default.
  1205.  
  1206. The repeat prefix is followed immediately by a single-character  repeat  count,
  1207. encoded  printably  via  tochar(),  followed  by  the character itself (perhaps
  1208. prefixed by control or 8th bit prefixes, as explained below).  The repeat count
  1209. may  express values from 0 to 94.  If a character appears more than 94 times in
  1210. a row, it must be "cut off" at 94, emitted with all appropriate  prefixes,  and
  1211. "restarted".    The following table should clarify Kermit's prefixing mechanism
  1212. (the final line shows how a sequence of 120 consecutive NULs would be encoded):
  1213.  
  1214.                  Prefixed           With
  1215.     Character    Representation     Repeat Count for 8
  1216.        A            A                ~(A   ["(" is ASCII 40 - 32 = 8]
  1217.        ^A           #A               ~(#A
  1218.        'A           &A               ~(&A
  1219.        '^A          &#A              ~(&#A
  1220.        #            ##               ~(##
  1221.        '#           &##              ~(&##
  1222.        &            #&               ~(#&
  1223.        '&           &#&              ~(&#&
  1224.        ~            #~               ~(#~
  1225.        '~           &#~              ~(&#~
  1226.        NUL          #@               ~~#@~:#@ [120 NULs]
  1227.  
  1228. A represents any printable character, ^A represents any control  character,  'x
  1229. represents  any  character  with  the 8th bit set.  The # character is used for
  1230. control-character prefixing, and the & character  for  8-bit  prefixing.    The
  1231. repeat  count must always precede any other prefix character.  The repeat count
  1232. is taken literally (after transformation by unchar(); for instance "#" and  "&"
  1233. immediately  following  a  "~"  denote repeat counts, not control characters or
  1234. 8-bit characters.  The control prefix character "#" is most  closely  bound  to
  1235. the  data  character,  then  the  8-bit prefix, then the repeat count; in other
  1236. words, the order is: repeat prefix and count, 8-bit prefix, control prefix, and
  1237. the  data  character itself.  To illustrate, note that &#A is not equivalent to
  1238. #&A.
  1239.  
  1240. When the parity bit is available for data, then 8th-bit prefixing should not be
  1241. done, and the 8th bit of the prefixed character will have the same value as the
  1242. 8th bit of the original data byte.  In that case, the table looks like this:
  1243.  
  1244.                  Prefixed           With
  1245.     Character    Representation     Repeat Count for 8
  1246.        'A           'A               ~('A
  1247.        '^A          #'A              ~(#'A
  1248.        '#           #'#              ~(#'#
  1249.        '&           '&               ~('&
  1250.        '~           #'~              ~(#'~
  1251.  
  1252. Note that since 8th bit prefixing is not being done, "&" is not being  used  as
  1253. an  8th  bit  prefix  character,  so  it does not need to be prefixed with "#".
  1254. Also, note that the 8th bit is set on the final  argument  of  the  repeat  se-
  1255. quence, no matter how long, and not on any of the prefix characters.
  1256.  
  1257. Finally, remember the following rules:
  1258.  
  1259.    - Prefixed sequences must not be broken across packets.
  1260.  
  1261.    - Control, 8th-bit, and repeat count prefixes must be distinct.
  1262.  
  1263.    - Data  fields  of  all  packets  must pass through the prefix encoding
  1264.      mechanism, except for S, I, and A packets, and ACKs to those packets,
  1265.      whose data fields must not be encoded.
  1266.  
  1267. In the first rule above, note that a prefixed sequence means a single character
  1268. and all its prefixes, like ~%&#X, not  a  sequence  like  #M#J,  which  is  two
  1269. prefixed sequences.
  1270.  
  1271.  
  1272. 6.2. Server Operation
  1273.  
  1274. A  Kermit server is a Kermit program running remotely with no "user interface".
  1275. All commands to the server arrive in packets from the  local  Kermit.    SERVER
  1276. operation  is  much  more  convenient than basic operation, since the user need
  1277. never again interact directly with the remote Kermit program after once  start-
  1278. ing  it  up in server mode, and therefore need not issue complementary SEND and
  1279. RECEIVE commands on the two sides to get a file  transfer  started;  rather,  a
  1280. single command (such as SEND or GET) to the local Kermit suffices.  Kermit ser-
  1281. vers can also provide services beyond file transfer.
  1282.  
  1283. Between transactions, a Kermit server waits for packets containing server  com-
  1284. mands.  The packet sequence number is always set back to 0 after a transaction.
  1285. A Kermit server in command wait should be looking for  packet  0,  and  command
  1286. packets  sent to servers should also be packet 0.  Certain server commands will
  1287. result in the exchange of multiple packets.  Those operations  proceed  exactly
  1288. like file transfer.
  1289.  
  1290. A  Kermit  server program waiting for a command packet is said to be in "server
  1291. command wait".  Once put into server command  wait,  the  server  should  never
  1292. leave  it  until it gets a command packet telling it to do so.  This means that
  1293. after any transaction is terminated, either normally or by any kind  of  error,
  1294. the server must go back into command wait.  While in command wait, a server may
  1295. elect to send out periodic NAKs for packet  0,  the  expected  command  packet.
  1296. Since  the  user  may  be disconnected from the server for long periods of time
  1297. (hours), the interval between these NAKs should be  significantly  longer  than
  1298. the  normal timeout interval (say, 30-60 seconds, rather than 5-10).  The peri-
  1299. odic NAKs are useful for breaking the deadlock that  would  occur  if  a  local
  1300. program was unable to time out, and sent a command that was lost.  On the other
  1301. hand, they can cause problems for local Kermit programs that cannot clear their
  1302. input  buffers,  or  for  systems that do XON/XOFF blindly, causing the NAKs to
  1303. buffered in the server's host system output buffer, to be suddenly released  en
  1304. masse  when  an XON appears.  For this reason, servers should have an option to
  1305. set the command-wait wakeup interval, or to disable it altogher.
  1306.  
  1307. Server operation must be implemented in two places: in the server  itself,  and
  1308. in  any  Kermit  program  that will be communicating with a server.  The server
  1309. must have code to read the server commands from packets and  respond  to  them.
  1310. The  user Kermit must have code to parse the user's server-related commands, to
  1311. form the server command packets, and to handle the responses  to  those  server
  1312. commands.
  1313.  
  1314.  
  1315. 6.2.1. Server Commands
  1316.  
  1317. Server  commands  are listed below.  Not all of them have been implemented, and
  1318. some may never be, but their use should  be  reserved.    Although  server-mode
  1319. operation  is optional, certain commands should be implemented in every server.
  1320. These include Send-Init (S), Receive-Init (R),  and  the  Generic  Logout  (GL)
  1321. and/or  Finish (GF) commands.  If the server receives a command it does not un-
  1322. derstand, or cannot execute, it should respond with an Error  (E)  packet  con-
  1323. taining a message like "Unimplemented Server Command" and both sides should set
  1324. the packet sequence number back to 0, and the server should  remain  in  server
  1325. command wait.  Only a GL or GF command should terminate server operation.
  1326.  
  1327. Server commands are as follows:
  1328.  
  1329. S   Send Initiate (exchange parameters, server waits for a file).
  1330. R   Receive Initiate (ask the server to send the specified files).
  1331. I   Initialize (exchange parameters).
  1332. X   Text header.  Allows transfer of text to the user's screen in response to a
  1333.     generic or host command.  This works just like file  transfer  except  that
  1334.     the  destination "device" is the screen rather than a file.  Data field may
  1335.     contain a filename, title, or other heading.
  1336. C   Host Command.  The data field contains a string to be executed as a command
  1337.     by the host system command processor.
  1338. K   Kermit  Command.   The data field contains a string in the interactive com-
  1339.     mand language of the Kermit server (normally a SET command) to be  executed
  1340.     as if it were typed in at command level.
  1341. G   Generic  Kermit Command.  Single character in data field (possibly followed
  1342.     by operands, shown in {braces}, optional fields  in  [brackets])  specifies
  1343.     the command:
  1344.  
  1345.     I   Login [{*user[*password[*account]]}]
  1346.     C   CWD, Change Working Directory [{*directory[*password]}]
  1347.     L   Logout, Bye
  1348.     F   Finish (Shut down the server, but don't logout).
  1349.     D   Directory [{*filespec}]
  1350.     U   Disk Usage Query [{*area}]
  1351.     E   Erase (delete) {*filespec}
  1352.     T   Type {*filespec}
  1353.     R   Rename {*oldname*newname}
  1354.     K   Copy {*source*destination}
  1355.     W   Who's logged in? (Finger) [{*user ID or network host[*options]}]
  1356.     M   Send a short Message {*destination*text}
  1357.     H   Help [{*topic}]
  1358.     Q   Server Status Query
  1359.     P   Program {*[program-filespec][*program-commands]}
  1360.     J   Journal {*command[*argument]}
  1361.     V   Variable {*command[*argument[*argument]]}
  1362.  
  1363. Asterisk  as  used  above ("*") represents a single-character length field, en-
  1364.     coded using tochar(), for the operand that follows it; thus lengths from  0
  1365.     to  94  may  be  specified.    This  allows multiple operands to be clearly
  1366.     delimited regardless of their contents.
  1367.  
  1368. Note that field length encoding is used within the data field  of  all  Generic
  1369. command  packets,  but not within the data fields of the other packets, such as
  1370. S, I, R, X, K, and C.
  1371.  
  1372. All server commands that send  arguments  in  their  data  fields  should  pass
  1373. through  the  prefix  encoding  mechanism.   Thus if a data character or length
  1374. field happens to correspond to an active prefix character, it  must  itself  be
  1375. prefixed.    The field length denotes the length of the field before prefix en-
  1376. coding and (hopefully) after prefix decoding.  For example, to send  a  generic
  1377. command  with  two  fields,  "ABC"  and  "ZZZZZZZZ",  first each field would be
  1378. prefixed by tochar() of its length,  in  this  case  tochar(3)  and  tochar(8),
  1379. giving  "#ABC(ZZZZZZZZ".   But "#" is the normal control prefix character so it
  1380. must be prefixed itself, and the eight Z's can be  condensed  to  3  characters
  1381. using a repeat prefix (if repeat counts are in effect), so the result after en-
  1382. coding would be "##ABC(~(Z" (assuming the repeat prefix is tilde  ("~").    The
  1383. recipient  would  decode this back into the original "#ABC(ZZZZZZZZ" before at-
  1384. tempting to extract the two fields.
  1385.  
  1386. Since a generic command must fit into a single packet, the program sending  the
  1387. command  should  ensure  that the command actually fits, and should not include
  1388. length fields that point beyond the end  of  the  packet.    Servers,  however,
  1389. should be defensive and not attempt to process any characters beyond the end of
  1390. the data field, even if the argument length field would lead them to do so.
  1391.  
  1392.  
  1393. 6.2.2. Timing
  1394.  
  1395. Kermit does not provide a mechanism for  suspending  and  continuing  a  trans-
  1396. action.    This  means that text sent to the user's screen should not be frozen
  1397. for long periods (i.e. not longer than  the  timeout  period  times  the  retry
  1398. threshold).
  1399.  
  1400. Between  transactions,  when  the  server has no tasks pending, it may send out
  1401. periodic NAKs (always with type 1 checksums) to prevent a deadlock  in  case  a
  1402. command  was  sent  to  it  but  was lost.  These NAKs can pile up in the local
  1403. "user" Kermit's input buffer (if it has one), so  the  user  Kermit  should  be
  1404. prepared  to  clear  its  input  buffer  before  sending a command to a server.
  1405. Meanwhile, servers should recognize that some systems provide no function to do
  1406. this  (or  even  when they do, the process can be foiled by system flow control
  1407. firmware) and should therefore provide a way turn off or slow down the command-
  1408. wait NAKs.
  1409.  
  1410.  
  1411. 6.2.3. The R Command
  1412.  
  1413. The  R  packet, generally sent by a local Kermit program whose user typed a GET
  1414. command, tells the server to send the files specified by the name in  the  data
  1415. field  of the R packet.  Since we can't assume that the two Kermits are running
  1416. on like systems, the local (user) Kermit must parse the file specification as a
  1417. character string, send it as-is (but encoded) to the server, and let the server
  1418. take care of validating its syntax and looking up the file.  If the server  can
  1419. open and read the specified file, it sends a Send-Init (S) packet -- not an ac-
  1420. knowledgement! -- to the user, and then completes the file-sending transaction,
  1421. as described above.
  1422.  
  1423. If  the server cannot send the file, it should respond with an error (E) packet
  1424. containing a reason, like "File not found" or "Read access required".
  1425.  
  1426. Thus, the only two valid responses to a successfully received R packet are an S
  1427. packet or an E packet.  The R packet is not ACK'd.
  1428.  
  1429.  
  1430. 6.2.4. The K Command
  1431.  
  1432. The  K  packet  can contain a character string which the server interprets as a
  1433. command in its own interactive command language.  This facility is  useful  for
  1434. achieving  the  same effect as a direct command without having to shut down the
  1435. server, connect back to the remote system, continue it (or start  a  new  one),
  1436. and issue the desired commands.  The server responds with an ACK if the command
  1437. was executed successfully, or an error packet otherwise.  The most  likely  use
  1438. for the K packet might be for transmitting SET commands, e.g. for switching be-
  1439. tween text and binary file modes.
  1440.  
  1441.  
  1442. 6.2.5. Short and Long Replies
  1443.  
  1444. Any request made of a server may be answered in either of  two  ways,  and  any
  1445. User  Kermit  that  makes  such a request should be prepared for either kind of
  1446. reply:
  1447.  
  1448.    - A short reply.  This consists of a single ACK packet, which may  con-
  1449.      tain  text  in  its  data field.  For instance, the user might send a
  1450.      disk space query to the server, and the server might ACK the  request
  1451.      with  a  short character string in the data field, such as "12K bytes
  1452.      free".  The user Kermit should display this text on the screen.
  1453.  
  1454.    - A long reply.  This proceeds exactly like a  file  transfer  (and  in
  1455.      some  cases  it  may  be a file transfer).  It begins with one of the
  1456.      following:
  1457.  
  1458.         * A File-Header (F) packet (optionally followed by one or more At-
  1459.           tributes packets; these are discussed later);
  1460.  
  1461.         * A Text-Header (X) packet.
  1462.  
  1463.         * A Send-Init (S) Packet, followed by an X or F packet.
  1464.  
  1465.      After  the  X or F packet comes an arbitrary number of Data (D) pack-
  1466.      ets, then an End-Of-File (Z) packet, and finally a Break-Transmission
  1467.      (B) packet, as for ordinary file transfer.
  1468.  
  1469. A  long reply should begin with an S packet unless an I-packet exchange has al-
  1470. ready taken place, and the type 1 (single-character) block check is being used.
  1471.  
  1472.  
  1473. 6.2.6. Additional Server Commands
  1474.  
  1475. The following server commands request the server to perform  tasks  other  than
  1476. sending  or receiving files.  Almost any of these can have either short or long
  1477. replies.  For instance, the Generic Erase (GE) command may elicit a simple ACK,
  1478. or  a  stream  of  packets  containing the names of all the files it erased (or
  1479. didn't erase).  These commands are now described in more detail; arguments  are
  1480. as  provided in commands typed to the user Kermit (subject to prefix encoding);
  1481. no transformations to any kind of normal or canonic form are done --  filenames
  1482. and other operands are in the syntax of the server's host system.
  1483.  
  1484. I   Login.  For use when a Kermit server is kept perpetually running on a dedi-
  1485.     cated line.  This lets a new user obtain an identity on the  server's  host
  1486.     system.    If the data field is empty, this removes the user's identity, so
  1487.     that the next user does not get access to it.
  1488.  
  1489. L   Logout, Bye.  This shuts down the server entirely, causing the  server  it-
  1490.     self  to  log  out  its  own job.  This is for use when the server has been
  1491.     started up manually by the user, who then wishes to shut it down  remotely.
  1492.     For a perpetual, dedicated server, this command simply removes the server's
  1493.     access rights to the current user's files, and leaves  the  server  waiting
  1494.     for a new login command.
  1495.  
  1496. F   Finish.    This  is  to allow the user to shut down the server, putting its
  1497.     terminal back into normal (as opposed to binary or raw) mode,  and  putting
  1498.     the server's job back at system command level, still logged in, so that the
  1499.     user can connect back to the job.  For a perpetual, dedicated server,  this
  1500.     command behaves as the L (BYE) command.
  1501.  
  1502. C   CWD.    Change  Working Directory.  This sets the default directory or area
  1503.     for file transfer on the server's host.  With  no  operands,  this  command
  1504.     sets the default area to be the user's own default area.
  1505.  
  1506. D   Directory.    Send  a  directory listing to the user.  The user program can
  1507.     display it on the terminal or store it in a  file,  as  it  chooses.    The
  1508.     directory  listing  should contain file sizes and creation dates as well as
  1509.     file names, if possible.  A wildcard or other file-group designator may  be
  1510.     specified  to  ask  the  server  list  only  those files that match.  If no
  1511.     operand is given, all files in the current area should be shown.
  1512.  
  1513. U   Disk Usage Query.  The server responds with the amount of  space  used  and
  1514.     the  amount  left  free to use, in K bytes (or other units, which should be
  1515.     specified).
  1516.  
  1517. E   Erase (delete).  Delete the specified file or file group.
  1518.  
  1519. T   Type.  Send the specified file or file group, indicating (by starting  with
  1520.     an  X  packet rather than an F packet, or else by using the Type attribute)
  1521.     that the file is to be displayed on the screen, rather than stored.
  1522.  
  1523. R   Rename.  Change the name of the file or files as indicated.  The string in-
  1524.     dicating  the  new  name  may  contain other attributes, such as protection
  1525.     code, permitted in file specifications by the host.
  1526.  
  1527. K   Copy.  Produce a new copy of the file or file group, as indicated,  leaving
  1528.     the source file(s) unmodified.
  1529.  
  1530. W   Who's  logged  in? (Finger).  With no arguments, list all the users who are
  1531.     logged in on the server's host  system.    If  an  argument  is  specified,
  1532.     provide more detailed information on the specified user or network host.
  1533.  
  1534. M   Short  Message.    Send  the given short (single-packet) message to the in-
  1535.     dicated user's screen.
  1536.  
  1537. P   Program.  This command has two  arguments,  program  name  (filespec),  and
  1538.     command(s)  for  the program.  The first field is required, but may be left
  1539.     null (i.e. zero length).  If it is null, the currently  loaded  program  is
  1540.     "fed"  the specified command.  If not null, the specified program is loaded
  1541.     and started; if a program command is given it is fed to the program  as  an
  1542.     initial  command  (for instance, as a command line argument on systems that
  1543.     support that concept).  In any case, the output of the program is sent back
  1544.     in packets as either a long or short reply, as described above.
  1545.  
  1546. J   Journal.  This command controls server transaction logging.  The data field
  1547.     contains one of the following:
  1548.  
  1549.     +   Begin/resume logging transactions.  If a filename is given,  close  any
  1550.         currently  open transaction and then open the specified file as the new
  1551.         transaction log.  If no name given, but a log file  was  already  open,
  1552.         resume  logging  to that file.  If no filename was given and no log was
  1553.         open,  the  server  should  open  a  log  with  a  default  name,  like
  1554.         TRANSACTION.LOG.
  1555.  
  1556.     -   Stop  logging transactions, but don't close the current transaction log
  1557.         file.
  1558.  
  1559.     C   Stop logging and close the current log.
  1560.  
  1561.     S   Send the transaction log as a file.  If it was open, close it first.
  1562.  
  1563. Transaction logging is the recording of the progress of  file  transfers.    It
  1564.     should  contain entries showing the name of each file transferred, when the
  1565.     transfer began and ended, whether it completed successfully,  and  if  not,
  1566.     why.
  1567.  
  1568. V   Set  or Query a variable.  The command can be S or Q. The first argument is
  1569.     the variable name.  The second argument, if any, is the value.
  1570.  
  1571.     S   Set the specified variable to the specified value.   If  the  value  is
  1572.         null,  then  undefine  the  variable.   If the variable is null then do
  1573.         nothing.  If the variable did not exist before, create it.  The  server
  1574.         should respond with an ACK if successful, and Error packet otherwise.
  1575.  
  1576.     Q   Query  the  value  of  the named variable.  If no variable is supplied,
  1577.         display the value of all active variables.  The  server  responds  with
  1578.         either  a  short or long reply, as described above.  If a queried vari-
  1579.         able does not exist, a null value is returned.
  1580. Variables are named by character strings, and  have  character  string  values,
  1581.     which may be static or dynamic.  For instance, a server might have built-in
  1582.     variables like "system name" which never  changes,  or  others  like  "mail
  1583.     status"  which,  when queried, cause the server to check to see if the user
  1584.     has any new mail.
  1585.  
  1586.  
  1587. 6.2.7. Host Commands
  1588.  
  1589. Host commands are conceptually simple, but may be hard  to  implement  on  some
  1590. systems.  The C packet contains a text string in its data field which is simply
  1591. fed to the server's host system command processor; any output from the  proces-
  1592. sor  is  sent  back  to  the  user in Kermit packets, as either a short or long
  1593. reply.
  1594.  
  1595. Implementation of this facility under UNIX, with its forking process  structure
  1596. and i/o redirection via pipes, is quite natural.  On other systems, it could be
  1597. virtually impossible.
  1598.  
  1599.  
  1600. 6.2.8. Exchanging Parameters Before Server Commands
  1601.  
  1602. In basic Kermit, the Send-Init exchange is always sufficient to  configure  the
  1603. two  sides  to  each  other.   During server operation, on the other hand, some
  1604. transactions may not begin with a Send-Init packet.   For  instance,  when  the
  1605. user  sends  an  R  packet to ask the server to send a file, the server chooses
  1606. what block check option to use.  Or if the user requests a  directory  listing,
  1607. the server does not know what packet length to use.
  1608.  
  1609. The solution to this problem is the "I" (Init-Info) packet.  It is exactly like
  1610. a Send-Init packet, and the ACK works the same way too.  However, receipt of an
  1611. I  packet  does not cause transition to file-send state.  The I-packet exchange
  1612. simply allows the two sides to set their parameters,  in  preparation  for  the
  1613. next transaction.
  1614.  
  1615. Servers  should  be  able to receive and ACK "I" packets when in server command
  1616. wait.  User Kermits need not send "I" packets, however; in that case, the serv-
  1617. er  will  assume  all  the  defaults for the user listed on page 9, or whatever
  1618. parameters have been set by other means (e.g. SET commands typed to the  server
  1619. before it was put in server mode).
  1620.  
  1621. User  Kermits  which send I packets should be prepared to receive and ignore an
  1622. Error packet in response.  This could happen if the server has not  implemented
  1623. I packets.
  1624.  
  1625. The  I  packet,  together  with  its  ACK,  constitute  a complete transaction,
  1626. separate from the S-packet or other exchange that follows it.  The packet  num-
  1627. ber remains at zero after the I-packet exchange.
  1628.  
  1629.  
  1630. 6.3. Alternate Block Check Types
  1631.  
  1632. There are two optional kinds of block checks:
  1633.  
  1634. Type 2
  1635.     A two-character checksum based on the low order 12 bits of  the  arithmetic
  1636.     sum  of  the  characters in the packet (from the LEN field through the last
  1637.     data character, inclusive) as follows:
  1638.  
  1639.                  1              2
  1640.         --------+----------------+---------------+
  1641.         ...data | tochar(b6-b11) | tochar(b0-b5) |
  1642.         --------+----------------+---------------+
  1643.  
  1644.     For instance, if the 16-bit result is 154321 (octal), then the 2  character
  1645.     block check would be "C1".
  1646.  
  1647. Type 3
  1648.     Three-character 16-bit CRC-CCITT. The CRC calculation treats  the  data  it
  1649.     operates  upon  as  a  string  of  bits with the low order bit of the first
  1650.     character first and the high order bit of the last character last.  The in-
  1651.     itial value of the CRC is taken as 0; the 16-bit CRC is the remainder after
  1652.                                                     16  12  5
  1653.     dividing the data bit string by the polynomial X  +X  +X +1 (this  calcula-
  1654.     tion  can  actually  be  done  a  character at a time, using a simple table
  1655.     lookup algorithm).  The result is represented as three printable characters
  1656.     at the end of the packet, as follows:
  1657.  
  1658.                  1               2              3
  1659.         --------+-----------------+----------------+---------------+
  1660.         ...data | tochar(b12-b15) | tochar(b6-b11) | tochar(b0-b5) |
  1661.         --------+-----------------+----------------+---------------+
  1662.  
  1663.     For  instance, if the 16-bit result is 154321 (octal), then the 3 character
  1664.     block check would be "-C1".  The CRC technique chosen here agrees with many
  1665.     hardware implementations (e.g. the VAX CRC instruction).
  1666.  
  1667. Here is an algorithm for Kermit's CRC-CCITT calculation:
  1668.  
  1669.       crc = 0                                   Start CRC off at 0
  1670.       i = <position of LEN field>               First byte to include
  1671.  
  1672.   A:  c = <byte at position i>                  Get current byte
  1673.       if (parity not NONE) then c = c AND 127;  Mask off any parity bit
  1674.       q = (crc XOR c) AND 15;                   Do low-order 4 bits
  1675.       crc = (crc / 16) XOR (q * 4225);
  1676.       q = (crc XOR (c / 16)) AND 015;           And high 4 bits
  1677.       crc = (crc / 16) XOR (q * 4225);
  1678.       i = i + 1                                 Position of next byte
  1679.       LEN = LEN - 1                             Decrement packet length
  1680.       if (LEN > 0) goto A                       Loop till done
  1681.  
  1682.   At this point, the crc variable contains the desired quantity.
  1683.  
  1684. Thanks to Andy Lowry of Columbia's CS department for this "tableless" CRC algo-
  1685. rithm (actually, it uses a table with one entry -- 4225).  AND is  the  bitwise
  1686. AND  operation,  XOR  the  bitwise exclusive OR, "*" is multiplication, and "/"
  1687. signifies integer division ("crc / 16" is equivalent to shifting the crc  quan-
  1688. tity 4 bits to the right).
  1689.  
  1690. The single-character checksum has proven quite adequate in practice.  The other
  1691. options can be used only if both sides agree to do so via Init packet (S or  I)
  1692. exchange.    The  2 and 3 character block checks should only be used under con-
  1693. ditions of severe line noise and packet corruption.
  1694.  
  1695. Since type 2 and 3 block checks are optional, not all Kermits can  be  expected
  1696. to  understand  them.  Therefore, during initial connection, communication must
  1697. begin using the type 1 block check.  If type 2 or 3 block checks are agreed  to
  1698. during  the  "I"  or  "S" packet exchange, the switch will occur only after the
  1699. Send-Init has been sent and ACK'd with a type 1 block check.  This  means  that
  1700. the  first  packet  with a type 2 or 3 block check must always be an "F" or "X"
  1701. packet.  Upon completion of a transaction, both sides must switch back to  type
  1702. 1  (to  allow  for  the  fact that neither side has any way of knowing when the
  1703. other side has been stopped and restarted).  The transaction is  over  after  a
  1704. "B"  or  "E" packet has been sent and ACK'd, or after any error that terminates
  1705. the transaction prematurely or abnormally.
  1706.  
  1707. A consequence of the foregoing rule is that if a type 2 or 3 block check is  to
  1708. be  used,  a  long  reply  sent  by  the server must begin with a Send-Init (S)
  1709. packet, even if an I packet exchange had already occurred.   If  type  1  block
  1710. checks  are  being used, the S packet can be skipped and the transfer can start
  1711. with an X or F packet.
  1712.  
  1713. A server that has completed a transaction and is awaiting  a  new  command  may
  1714. send  out periodic NAKs for that command (packet 0).  Those NAKs must have type
  1715. 1 block checks.
  1716.  
  1717. The use of alternate block check types can cause certain  complications.    For
  1718. instance, if the server gets a horrible error (so bad that it doesn't even send
  1719. an error packet) and reverts to command wait, sending NAKs for packet 0 using a
  1720. type  1  block  check,  while  a transfer using type 2 or 3 block checks was in
  1721. progress, neither side will be able to read the other's packets.  Communication
  1722. can  also  grind to a halt if A sends a Send-Init requesting, say, type 3 block
  1723. checks, B ACKs the request, switches to type 3 and waits for the X or F  packet
  1724. with a type 3 block check, but the ACK was lost, so A resends the S packet with
  1725. a type 1 block check.  Situations like this will ultimately resolve  themselves
  1726. after  the  two  sides retransmit up to their retry threshhold, but can be rec-
  1727. tified earlier by the use of two heuristics:
  1728.  
  1729.    - The packet reader can assume that if the  packet  type  is  "S",  the
  1730.      block check type is 1.
  1731.  
  1732.    - A  NAK  packet  never has anything in its data field.  Therefore, the
  1733.      block check type can always be deduced by the packet reader from  the
  1734.      length  field of a NAK.  In fact, it is the value of the length field
  1735.      minus 2.  A NAK can therefore be thought of as a kind  of  "universal
  1736.      synchronizer".
  1737.  
  1738. These  heuristics tend to violate the layered nature of the protocol, since the
  1739. packet reader should normally be  totally  unconcerned  with  the  packet  type
  1740. (which  is  of  interest  to  the  application  level  which invokes the packet
  1741. reader).  A better design would have had each packet include  an  indicator  of
  1742. the  type  of its own block check; this would have allowed the block check type
  1743. to be changed dynamically during a transaction to adapt to changing conditions.
  1744. But it's too late for that now...
  1745.  
  1746.  
  1747. 6.4. Interrupting a File Transfer
  1748.  
  1749. This  section  describes  an  optional  feature of the Kermit protocol to allow
  1750. graceful interruption of file transfer.  This feature is  unrelated  to  server
  1751. operation.
  1752.  
  1753. To interrupt sending a file, send an EOF ("Z") packet in place of the next data
  1754. packet, including a "D" (for Discard) in the data field.   The  recipient  ACKs
  1755. the  Z  packet normally, but does not retain the file.  This does not interfere
  1756. with older Kermits on the receiving end; they will not inspect the  data  field
  1757. and  will close the file normally.  The mechanism can be triggered by typing an
  1758. interrupt character at the console  of  the  sending  Kermit  program.    If  a
  1759. (wildcard) file group is being sent, it is possible to skip to the next file or
  1760. to terminate the entire batch; the protocol is the same in either case, but the
  1761. desired action could be selected by different interrupt characters, e.g. CTRL-X
  1762. to skip the current file, CTRL-Z to skip the rest of the batch.
  1763.  
  1764. To interrupt receiving a file, put an "X" in the data field of  an  ACK  for  a
  1765. Data packet.  To interrupt receiving an entire file group, use a "Z".  The user
  1766. could trigger this mechanism by typing an interrupt character, say, CTRL-X  and
  1767. CTRL-Z,  respectively,  at  the  receiving Kermit's console.  A sender that was
  1768. aware of the new feature, upon  finding  one  of  these  codes,  would  act  as
  1769. described  above, i.e. send a "Z" packet with a "D" code; a sender that did not
  1770. implement this feature would simply ignore the codes and continue sending.   In
  1771. this  case, and if the user wanted the whole batch to be cancelled (or only one
  1772. file was being sent), the receiving Kermit program, after determining that  the
  1773. sender  had ignored the "X" or "Z" code, could send an Error (E) packet to stop
  1774. the transfer.
  1775.  
  1776. The sender may also choose to send a Z packet containing the  D  code  when  it
  1777. detects  that the file it is sending cannot be sent correctly and completely --
  1778. for instance, after sending some packets correctly, it gets an i/o error  read-
  1779. ing the file.  Or, it notices that the "8th bit" of a file byte is set when the
  1780. file is being sent as a text file and no provision has been made for  transmit-
  1781. ting the 8th bit.
  1782.  
  1783.  
  1784. 6.5. Transmitting File Attributes
  1785.  
  1786. The  optional  Attributes  (A)  packet provides a mechanism for the sender of a
  1787. file to provide additional information about it.  This packet can  be  sent  if
  1788. the  receiver has indicated its ability to process it by setting the Attributes
  1789. bit in the capability mask.    If  both  sides  set  this  bit  in  the  Kermit
  1790. capability  mask, then the sender, after sending the filename in the "F" packet
  1791. and receiving an acknowledgement, may (but does not have to) send an "A" packet
  1792. to provide file attribute information.
  1793.  
  1794. Setting the Attributes bit in the capability mask does not indicate support for
  1795. any particular attributes, only that the receiver is prepared to accept the "A"
  1796. packet.
  1797.  
  1798. The  attributes  are given in the data field of the "A" packet.  The data field
  1799. consists of 0 or more subfields, which may occur in any order.   Each  subfield
  1800. is of the following form:
  1801.  
  1802.     +-----------+----------------+------+
  1803.     | ATTRIBUTE | tochar(LENGTH) | DATA |
  1804.     +-----------+----------------+------+
  1805.  
  1806. where
  1807.  
  1808. ATTRIBUTE is a single printable character other than space,
  1809.  
  1810. LENGTH    is  the  length  of  the  data characters (0 to 94), with 32 added to
  1811.           produce a single printable character, and
  1812.  
  1813. DATA      is length characters worth of data, all printable characters.
  1814.  
  1815. No quoting or prefixing is done on any of this data.
  1816.  
  1817. More than one attribute packet may be sent.  The only requirement is  that  all
  1818. the A packets for a file must immediately follow its File header (or X) packet,
  1819. and precede the first Data packet.
  1820.  
  1821. There may be 93 different attributes, one for each of the  93  printable  ASCII
  1822. characters other than space.  These are assigned in ASCII order.
  1823.  
  1824. ! (ASCII 33)
  1825.           Length.  The data field gives the length in  K  (1024)  bytes,  as  a
  1826.           printable decimal number, e.g. "!#109".  This will allow the receiver
  1827.           to determine in advance whether there  is  sufficient  room  for  the
  1828.           file, and/or how long the transfer will take.
  1829.  
  1830. " (ASCII 34)
  1831.           Type.  The data field can contain some indicator of the nature of the
  1832.           file.     Operands  are  enclosed  in  {braces},  optional  items  in
  1833.           [brackets].  The braces and brackets do not actually  appear  in  the
  1834.           packet.
  1835.  
  1836.           A[{xx}] ASCII  text,  containing no 8-bit quantities, logical records
  1837.                   (lines) delimited by the (quoted) control character  sequence
  1838.                   {xx},  represented  here  by  its printable counterpart (MJ =
  1839.                   CRLF, J = LF, etc).  For instance  AMJ  means  that  the  ap-
  1840.                   pearance  of  #M#J  (the  normal prefixed CRLF sequence) in a
  1841.                   file data packet indicates the end of a record, assuming  the
  1842.                   current  control  prefix is "#".  If {xx} is omitted, MJ will
  1843.                   be assumed.
  1844.  
  1845.           B[{xx}] Binary.  {xx} indicates in what manner the file is binary:
  1846.  
  1847.                   8   (default) The file is a sequence of  8-bit  bytes,  which
  1848.                       must  be saved as is.  The 8th bit may be sent "bare", or
  1849.                       prefixed according to  the  Send-Init  negotiation  about
  1850.                       8th-bit prefixing.
  1851.  
  1852.                   36  The  file  is  a PDP-10 format binary file, in which five
  1853.                       7-bit bytes are fit into one 36-bit word, with the  final
  1854.                       bit of each word being represented as the "parity bit" of
  1855.                       every 5th character (perhaps prefixed).
  1856.  
  1857.           D{x}    Moved from here to FORMAT attribute
  1858.  
  1859.           F{x}    Moved from here to FORMAT attribute
  1860.  
  1861.           I[{x}]  Image.  The file is being sent exactly as it  is  represented
  1862.                   on  the  system  of  origin.    For use between like systems.
  1863.                   There are {x} usable bits per  character,  before  prefixing.
  1864.                   For  instance,  to  send binary data from a system with 9-bit
  1865.                   bytes, it might be convenient to send three 6-bit  characters
  1866.                   for every two 9-bit bytes.  Default {x} is 8.
  1867.  
  1868. # (ASCII 35)
  1869.           Creation Date, expressed as "[yy]yymmdd[ hh:mm[:ss]]"  (ISO  standard
  1870.           date  format), e.g. 831009 23:59.  The time is optional; if given, it
  1871.           should be in 24-hour format, and the seconds may be  omitted,  and  a
  1872.           single space should separate the time from the date.
  1873.  
  1874. $ (ASCII 36)
  1875.           Creator's ID, expressed as a character string of the given length.
  1876.  
  1877. % (ASCII 37)
  1878.           Account to charge the file to, character string.
  1879.  
  1880. & (ASCII 38)
  1881.           Area in which to store the file, character string.
  1882.  
  1883. ' (ASCII 39)
  1884.           Password for above, character string.
  1885.  
  1886. ( (ASCII 40)
  1887.           Block Size.  The file has, or is to be stored with, the  given  block
  1888.           size.
  1889.  
  1890. ) (ASCII 41)
  1891.           Access:
  1892.  
  1893.           N   New, the normal case -- create a new file of the given name.
  1894.           S   Supersede (overwrite) any file of the same name.
  1895.           A   Append to file of the given name.
  1896.  
  1897. * (ASCII 42)
  1898.           Encoding:
  1899.  
  1900.           A   ASCII, normal ASCII encoding with any necessary prefixing, etc.
  1901.           H   Hexadecimal "nibble" encoding.
  1902.           E   EBCDIC (sent as if it were a binary file).
  1903.           X   Encrypted.
  1904.           Q{x}
  1905.               Huffman Encoded for compression.  First x bytes of the  file  are
  1906.               the key.
  1907.  
  1908. + (ASCII 43)
  1909.           Disposition (operands are specified in the syntax of  the  receiver's
  1910.           host system):
  1911.  
  1912.           M{user(s)}      Send the file as Mail to the specified user(s).
  1913.  
  1914.           O{destination}  Send  the  file  as  a  lOng  terminal message to the
  1915.                           specified destination (terminal, job, or user).
  1916.  
  1917.           S[{options}]    Submit the file as a batch job,  with  any  specified
  1918.                           options.
  1919.  
  1920.           P[{options}]    Print   the  file  on  a  system  printer,  with  any
  1921.                           specified options, which  may  specify  a  particular
  1922.                           printer, forms, etc.
  1923.  
  1924.           T               Type the file on the screen.
  1925.  
  1926.           L[{aaa}]        Load  the  file  into memory at the given address, if
  1927.                           any.
  1928.  
  1929.           X[{aaa}]        Load the file into memory at the  given  address  and
  1930.                           eXecute it.
  1931.  
  1932.           A               Archive the file; save the file together with the at-
  1933.                           tribute packets that preceded it, so that it  can  be
  1934.                           sent  back  to  the system of origin with all its at-
  1935.                           tributes intact.  A file stored in this way should be
  1936.                           specially  marked  so  that  the Kermit that sends it
  1937.                           back will recognize the attribute information as dis-
  1938.                           tinct from the file data.
  1939.  
  1940. , (ASCII 44)
  1941.           Protection.  Protection code for the  file,  in  the  syntax  of  the
  1942.           receiver's host file system.  With no operand, store according to the
  1943.           system's default protection for the destination area.
  1944.  
  1945. - (ASCII 45)
  1946.           Protection.    Protection  code  for  the  file  with  respect to the
  1947.           "public" or "world", expressed generically in a 6-bit quantity  (made
  1948.           printable by tochar()), in which the bits have the following meaning:
  1949.  
  1950.           b0: Read Access
  1951.           b1: Write Access
  1952.           b2: Execute Access
  1953.           b3: Append Access
  1954.           b4: Delete Access
  1955.           b5: Directory Listing
  1956.  
  1957. A  one in the bit position means allow the corresponding type of access, a zero
  1958.           means prohibit it.  For example, the letter "E" in this  field  would
  1959.           allow  read,  execute,  and  directory  listing access (unchar("E") =
  1960.           69-32 = 37 = 100101 binary).
  1961.  
  1962. . (ASCII 46)
  1963.           Machine  and  operating system of origin.  This is useful in conjunc-
  1964.           tion with the archive disposition attribute.  It allows a file,  once
  1965.           archived, to be transferred among different types of systems, retain-
  1966.           ing its archive status, until it finds its way to a machine with  the
  1967.           right  characteristics  to de-archive it.  The systems are denoted by
  1968.           codes; the first character is the major system designator, the second
  1969.           designates the specific model or operating system.  A third character
  1970.           may be added to make further  distinctions,  for  instance  operating
  1971.           system version.  The systems below do not form a complete collection;
  1972.           many more can and probably will be added.
  1973.  
  1974.           A   Apple microcomputers
  1975.  
  1976.               1   Apple II, DOS
  1977.               2   Apple III
  1978.               3   Macintosh
  1979.               4   Lisa
  1980.           B   Sperry (Univac) mainframes
  1981.  
  1982.               1   1100 series, EXEC
  1983.               2   9080, VS9
  1984.  
  1985.           C   CDC mainframes
  1986.  
  1987.               1   Cyber series, NOS
  1988.               2   Cyber series, NOS-BE
  1989.               3   Cyber series, NOS-VE
  1990.               4   Cyber series, SCOPE
  1991.  
  1992.           D   DEC Systems
  1993.  
  1994.               1   DECsystem-10/20, TOPS-10
  1995.               2   DECsystem-10/20, TOPS-20
  1996.               3   DECsystem-10/20, TENEX
  1997.               4   DECsystem-10/20, ITS
  1998.               5   DECsystem-10/20, WAITS
  1999.               6   DECsystem-10/20, MAXC
  2000.               7   VAX-11, VMS
  2001.               8   PDP-11, RSX-11
  2002.               9   PDP-11, IAS
  2003.               A   PDP-11, RSTS/E
  2004.               B   PDP-11, RT-11
  2005.               C   Professional-300, P/OS
  2006.               D   Word Processor (WPS or DECmate), WPS
  2007.  
  2008.           E   Honeywell mainframes
  2009.  
  2010.               1   MULTICS systems
  2011.               2   DPS series, running CP-6
  2012.               3   DPS series, GCOS
  2013.               4   DTSS
  2014.  
  2015.           F   Data General machines
  2016.  
  2017.               1   RDOS
  2018.               2   AOS
  2019.               3   AOS/VS
  2020.  
  2021.           G   PR1ME machines, PRIMOS
  2022.  
  2023.           H   Hewlett-Packard machines
  2024.  
  2025.               1   HP-1000, RTE
  2026.               2   HP-3000, MPE
  2027.  
  2028.           I   IBM 370-series and compatible mainframes
  2029.  
  2030.               1   VM/CMS
  2031.               2   MVS/TSO
  2032.               3   DOS
  2033.               4   MUSIC
  2034.               5   GUTS
  2035.               6   MTS
  2036.  
  2037.           J   Tandy microcomputers, TRSDOS
  2038.  
  2039.           K   Atari computers
  2040.  
  2041.               1   Home computers, DOS
  2042.               2   ST series
  2043.  
  2044.           L   Commodore micros
  2045.  
  2046.               1   Pet
  2047.               2   64
  2048.               3   Amiga
  2049.  
  2050.           M   Miscellaneous mainframes and  minis  with  proprietary  operation
  2051.               systems:
  2052.  
  2053.               1   Gould/SEL minis, MPX
  2054.               2   Harris, VOS
  2055.               3   Perkin-Elmer minis, OS/32
  2056.               4   Prime, Primos
  2057.               5   Tandem, Nonstop
  2058.               6   Cray, CTSS
  2059.               7   Burroughs (subtypes may be necessary here)
  2060.               8   GEC 4000, OS4000
  2061.               9   ICL machines
  2062.               A   Norsk Data, Sintran III
  2063.               B   Nixdorf machines
  2064.  
  2065.           N   Miscellaneous micros and workstations:
  2066.  
  2067.               1   Acorn BBC Micro
  2068.               2   Alpha Micro
  2069.               3   Apollo Aegis
  2070.               4   Convergent, Burroughs, and similar systems with CTOS, BTOS
  2071.               5   Corvus, CCOS
  2072.               6   Cromemco, CDOS
  2073.               7   Intel x86/3x0, iRMX-x86
  2074.               8   Intel MDS, ISIS
  2075.               9   Luxor ABC-800, ABCDOS
  2076.               A   Perq
  2077.               B   Motorola, Versados
  2078.  
  2079.           O-T Reserved
  2080.  
  2081.           U   Portable Operating or File Systems
  2082.  
  2083.               1   UNIX
  2084.               2   Software Tools
  2085.               3   CP/M-80
  2086.               4   CP/M-86
  2087.               5   CP/M-68K
  2088.               6   MP/M
  2089.               7   Concurrent CP/M
  2090.               8   MS-DOS
  2091.               9   UCSD p-System
  2092.               A   MUMPS
  2093.               B   LISP
  2094.               C   FORTH
  2095.               D   OS-9
  2096.  
  2097. / (ASCII 47)
  2098.           Format of the data within the packets.
  2099.  
  2100.           A{xx}           Variable length delimited records, terminated by  the
  2101.                           character  sequence {xx}, where xx is a string of one
  2102.                           or more control characters, represented here by their
  2103.                           unprefixed  printable  equivalents,  e.g. MJ for ^M^J
  2104.                           (CRLF).
  2105.  
  2106.           D{x}            Variable length undelimited records.    Each  logical
  2107.                           record  begins  with  an  {x}-character ASCII decimal
  2108.                           length field (similar to ANSI tape format "D").   For
  2109.                           example,  "D$"  would indicate 4-digit length fields,
  2110.                           like "0132".
  2111.  
  2112.           F{xxxx}         Fixed-length  undelimited  records.    Each   logical
  2113.                           record is {xxxx} bytes long.
  2114.  
  2115.           R{x}            For record-oriented transfers, to be used in combina-
  2116.                           tion with one of  the  formats  given  above.    Each
  2117.                           record  begins  (in  the  case of D format, after the
  2118.                           length field) with an x-character long position field
  2119.                           indicating the byte position within the file at which
  2120.                           this record is to be stored.
  2121.  
  2122.           M{x}            For record-oriented transfers, to be used in combina-
  2123.                           tion  with  one  of the formats given above.  Maximum
  2124.                           record length for a variable-length record.
  2125.  
  2126. 0 (ASCII 48)
  2127.           Special  system-dependent parameters for storing the file on the sys-
  2128.           tem of origin, for specification of exotic attributes not covered ex-
  2129.           plicitly by any of the Kermit attribute descriptors.  These are given
  2130.           as a character string in the system's own  language,  for  example  a
  2131.           list of DCB parameters in IBM Job Control Language.
  2132.  
  2133. 1-@ (ASCII 49)
  2134.           Exact byte count of the file as it is stored on the sender's  system,
  2135.           before any conversions (e.g. to canonic form).  Of limited usefulness
  2136.           when transferring text files  between  systems  that  represent  text
  2137.           boundaries differently.
  2138.  
  2139. 2-@ (ASCII 50-64)
  2140.           Reserved
  2141.  
  2142. Other attributes can be imagined, and can be added later if needed.    However,
  2143. two important points should be noted:
  2144.  
  2145.    - The  receiver may have absolutely no way of honoring, or even record-
  2146.      ing, a given attribute.  For instance, CP/M-80 has no slot for  crea-
  2147.      tion  date  or  creator's ID in its FCB; the DEC-20 has no concept of
  2148.      block size, etc.
  2149.  
  2150.    - The sender may have no way of determining the correct values  of  any
  2151.      of  the  attributes.  This is particularly true when sending files of
  2152.      foreign origin.
  2153.  
  2154. The "A" packet mechanism only provides a way to send certain information  about
  2155. a  file to the receiver, with no provision or guarantee about what the receiver
  2156. may do with it.  That information may be  obtained  directly  from  the  file's
  2157. directory entry (FCB, FDB, ...), or specified via user command.
  2158.  
  2159. The  ACK  to  the  "A"  packet  may in turn have information in its data field.
  2160. However, no complicated negotiations about file attributes may take  place,  so
  2161. the  net  result  is that the receiver may either refuse the file or accept it.
  2162. The receiver may reply to the "A" packet with any of the following codes in the
  2163. data field of the ACK packet:
  2164.  
  2165. <null>  (empty data field) I accept the file, go ahead and send it.
  2166.  
  2167. N[{xxx}]
  2168.         I refuse the file as specified, don't send it; {xxx}  is  a  string  of
  2169.         zero  or more of the attribute characters listed above, to specify what
  2170.         attributes I object to (e.g. "!" means it's too long, "&" means I don't
  2171.         have write access to the specified area, etc).
  2172.  
  2173. Y[{xxx}]
  2174.         I agree to receive the file, but I cannot honor attributes {xxx}, so  I
  2175.         will store the file according to my own defaults.
  2176.  
  2177. Y       (degenerate case of Y{xxx}, equivalent to <null>, above)
  2178.  
  2179. How  the  receiver  actually  replies  is an implementation decision.  A NAK in
  2180. response to the "A" packet means, of course, that the receiver did not  receive
  2181. the "A" correctly, not that it refuses to receive the file.
  2182.  
  2183.  
  2184. 6.6. Advanced Kermit Protocol State Table
  2185.  
  2186. The  simple  table  presented  previously  is sufficient for a basic Kermit im-
  2187. plementation.  The following is a state table for the full Kermit protocol, in-
  2188. cluding  both server mode and sending commands to a server Kermit.  It does not
  2189. include handling of the file attributes packet (A).   Note  that  states  whose
  2190. names  start  with "Send" always send a packet each time they are entered (even
  2191. when the previous state was the same).  States whose name  starts  with  "Rec",
  2192. always  wait for a packet to be received (up to the timeout value), and process
  2193. the received packet.  States whose names do not include either send or  receive
  2194. do  not  process  packets  directly.  These are states which perform some local
  2195. operation and then change to another state.
  2196.  
  2197. The initial state is determined by the user's  command.    A  "server"  command
  2198. enters  at Rec_Server_Idle.  A "send" command enters at Send_Init.  A "receive"
  2199. command (the old non-server version, not a "get" command) enters  at  Rec_Init.
  2200. Any  generic command, the "get" command, and the "host" command enter at either
  2201. Send_Server_Init or Send_Gen_Cmd, depending upon the expected response.
  2202.  
  2203. Under "Rec'd Msg", the packet type of the incoming message is  shown,  followed
  2204. by the packet number in parentheses; (n) means the current packet number, (n-1)
  2205. and (n+1) mean the previous and next packet  numbers  (modulo  64),  (0)  means
  2206. packet  number zero. Following the packet number may be slash and a letter, in-
  2207. dicating some special signal in the data field.  For instance Z(n)/D  indicates
  2208. a Z (EOF) packet, sequence number n, with a "D" in the data field.
  2209.  
  2210. Under  "Action",  "r+"  means  that the retry count is incremented and compared
  2211. with a threshhold; if the threshhold is exceeded, an Error packet is  sent  and
  2212. the  state  changes  to  "Abort".    "n+"  means  that the packet number is in-
  2213. cremented, modulo 64, and the retry count, r, is set back to zero.
  2214.  
  2215. State   Rec'd Msg       Action                  Next state
  2216.  
  2217. Rec_Server_Idle -- Server idle, waiting for a message
  2218.  
  2219.     Set n and r to 0
  2220.  
  2221.         I(0)            Send ACK                Rec_Server_Idle
  2222.         S(0)            Process params,
  2223.                          ACK with params, n+    Rec_File
  2224.         R(0)            Save file name          Send_Init
  2225.  
  2226.         K, C or G(0)    Short reply:
  2227.                          ACK(0)/reply           Rec_Server_Idle
  2228.                         Long reply:
  2229.                          init needed            Send_Init
  2230.                          init not needed, n+    Open_File
  2231.  
  2232.         Timeout         Send NAK(0)             Rec_Server_Idle
  2233.         Other           Send E                  Rec_Server_Idle
  2234.  
  2235. Rec_Init -- Entry point for non-server RECEIVE command
  2236.  
  2237.     Set n and r to 0
  2238.  
  2239.         S(0)            Process params, send
  2240.                          ACK with params, n+    Rec_File
  2241.         Timeout         Send NAK(0), r+         Rec_Init
  2242.         Other           Send E                  Abort
  2243.  
  2244. Rec_File -- Look for a file header or EOT message
  2245.  
  2246.         F(n)            Open file, ACK, n+      Rec_Data
  2247.         X(n)            Prepare to type on
  2248.                          screen, ACK, n+        Rec_Data
  2249.         B(n)            ACK                     Complete
  2250.         S(n-1)          ACK with params, r+     Rec_File
  2251.         Z(n-1)          ACK, r+                 Rec_File
  2252.         Timeout         Resend ACK(n), r+       Rec_File
  2253.         Other           Send E                  Abort
  2254.  
  2255. Rec_Data -- Receive data up to end of file
  2256.  
  2257.         D(n)            Store data, ACK, n+;
  2258.                          If interruption wanted
  2259.                          include X or Z in ACK  Rec_Data
  2260.         D(n-1)          Send ACK, r+            Rec-Data
  2261.         Z(n)            Close file, ACK, n+     Rec_File
  2262.         Z(n)/D          Discard file, ACK, n+   Rec_File
  2263.         F(n-1)          Send ACK, r+            Rec_Data
  2264.         X(n-1)          Send ACK, r+            Rec_Data
  2265.         Timeout         Send ACK(n-1), r+       Rec_Data
  2266.         Other           Send E                  Abort
  2267.  
  2268.  
  2269. Send_Init -- Also entry for SEND command
  2270.  
  2271.     Set n and r to 0, send S(0) with parameters
  2272.  
  2273.         Y(0)            Process params, n+      Open_File
  2274.         N, Timeout      r+                      Send_Init
  2275.         Other           r+                      Send_Init
  2276.  
  2277. Open_File -- Open file or set up text to send
  2278.  
  2279.                                                 Send_File
  2280.  
  2281. Send_File -- Send file or text header
  2282.  
  2283.     Send F or X(n)
  2284.  
  2285.         Y(n), N(n+1)    Get first buffer of     Send_Data or Send_Eof if
  2286.                          data, n+                empty file or text
  2287.         N, Timeout      r+                      Send_File
  2288.         Other                                   Abort
  2289.  
  2290. Send_Data -- Send contents of file or textual information
  2291.  
  2292.     Send D(n) with current buffer
  2293.  
  2294.         Y(n), N(n+1)    n+, Get next buffer     Send_Data or Send_Eof if
  2295.                                                  at end of file or text
  2296.         Y(n)/X or Z     n+                      Send_Eof
  2297.         N, Timeout      r+                      Send_Data
  2298.         Other                                   Abort
  2299.  
  2300. Send_Eof -- Send end of file indicator
  2301.  
  2302.     Send Z(n); if interrupting send Z(n)/D
  2303.  
  2304.         Y(n), N(n+1)    Open next file, n+      Send_File if more, or
  2305.                                                 Send_Break if no more
  2306.                                                  or if interrupt "Z".
  2307.         N, Timeout      r+                      Send_Eof
  2308.         Other                                   Abort
  2309.  
  2310. Send_Break -- End of Transaction
  2311.  
  2312.     Send B(n)
  2313.  
  2314.         Y(n), N(0)                              Complete
  2315.         N(n), Timeout                           Send_Break
  2316.         Other                                   Abort
  2317.  
  2318. Send_Server_Init - Entry for Server commands which expect large response.
  2319.  
  2320.     Send I(0) with parameters
  2321.  
  2322.         Y(0)            Process params          Send_Gen_Cmd
  2323.         N, Timeout      r+                      Send_Server_Init
  2324.         E               Use default params      Send_Gen_Cmd
  2325.         Other                                   Abort
  2326.  
  2327. Send_Gen_Cmd - Entry for Server commands which expect short response (ACK)
  2328.  
  2329.     Send G, R or C(0)
  2330.  
  2331.         S(0)            Process params,
  2332.                          ACK with params, n+    Rec_File
  2333.         X(1)            Setup to type on
  2334.                          terminal, n+           Rec_Data
  2335.         Y(0)            Type data on TTY        Complete
  2336.         N, Timeout      r+                      Send_Gen_Cmd
  2337.         Other                                   Abort
  2338.  
  2339. Complete -- Successful Completion of Transaction
  2340.  
  2341.         Set n and r to 0;
  2342.         If server, reset params, enter Rec_Server_Idle
  2343.         otherwise exit
  2344.  
  2345. Abort -- Premature Termination of Transaction
  2346.  
  2347.     Reset any open file, set n and r to 0
  2348.  
  2349.         If server, reset params, enter Rec_Server_Idle
  2350.         otherwise exit
  2351.  
  2352. Exit, Logout states
  2353.         Exit or Logout
  2354.  
  2355. Note that the generic commands determine the next state as follows:
  2356.  
  2357.    1. If the command is not supported, an error packet  is  sent  and  the
  2358.       next state is "Abort".
  2359.  
  2360.    2. If  the  command generates a response which can be fit into the data
  2361.       portion of an ACK, an ACK is sent with the text  (quoted  as  neces-
  2362.       sary) in the data portion.
  2363.  
  2364.    3. If the command generates a large response or must send a file, noth-
  2365.       ing is sent from the Rec_Server_Idle state, and the  next  state  is
  2366.       either  Send_Init  (if either no I message was received or if alter-
  2367.       nate block check types are to be used), or Open_File (if an  I  mes-
  2368.       sage  was  received  and  the  single character block check is to be
  2369.       used).
  2370.  
  2371.    4. If the command is Logout, an ACK  is  sent  and  the  new  state  is
  2372.       Logout.
  2373.  
  2374.    5. If the command is Exit, an ACK is sent and the new state is Exit.
  2375. 7. Performance Extensions
  2376.  
  2377. The  material in this chapter was added in 1985-86 to address the inherent per-
  2378. formance problems of a stop-and-wait protocol like Kermit.
  2379.  
  2380.  
  2381. 7.1. Long Packets
  2382.  
  2383. A method is provided to allow the formation of long Kermit packets.   Questions
  2384. as  to  the  desirability  or  appropriateness  of this extension to the Kermit
  2385. protocol are not addressed.  All numbers are in decimal (base 10) notation, all
  2386. arithmetic is integer arithmetic.
  2387.  
  2388. In  order  for  long  packets  to be exchanged, the sender must set the bit for
  2389. Capability #5 (the LONGP bit) in the CAPAS field of  the  Send-Init  (S  or  I)
  2390. packet,
  2391.  
  2392.      bit5 bit4 bit3 bit2 bit1 bit0
  2393.     +----+----+----+----+----+----+
  2394.     | #1 | #2 | #3 | #4 | #5 |  0 |
  2395.     +----+----+----+----+----+----+
  2396.                            ^
  2397.                            |
  2398.                          LONGP
  2399.  
  2400. and  also  furnish  the  MAXLX1 and MAXLX2 (extended length 1 and 2) fields, as
  2401. follows:
  2402.  
  2403.         10              CAPAS+1  CAPAS+2  CAPAS+3
  2404.     ---+-------+-     -+--------+--------+--------+
  2405.        | CAPAS |  ...  | WINDO  | MAXLX1 | MAXLX2 |
  2406.     ---+-------+-     -+--------+--------+--------+
  2407.                         ^
  2408.                         |
  2409.                       (currently field 11, because CAPAS is still 1 byte)
  2410.  
  2411. where WINDO is the window size (a  separate  Kermit  protocol  extension),  and
  2412. MAXLX1  and MAXLX2 are each a printable ASCII character in the range SP (space,
  2413. ASCII 32) to ~ (tilde, ASCII 126), formed as follows:
  2414.  
  2415.     MAXLX1 = tochar(m / 95)
  2416.     MAXLX2 = tochar(m MOD 95)
  2417.  
  2418. (where m is the intended maximum length, / signifies integer division, and  MOD
  2419. is  the  modulus  operator),  to indicate the longest extended-length packet it
  2420. will accept as input.  The receiver responds with an ACK packet having the same
  2421. bit  also  set in the CAPAS field, and with the MAXLX1 and MAXLX2 fields set to
  2422. indicate the maximum length packet it will accept.
  2423.  
  2424. The maximum length expressible by this construct is 95 x 94 + 94, or 9024.
  2425.  
  2426. Since the sender can not know in advance whether the receiver is capable of ex-
  2427. tended  headers, the Send-Init MAXL field must also be set in the normal manner
  2428. for compatibility.
  2429.  
  2430. If the receiver responds favorably to an extended-length packet bid  (that  is,
  2431. if  its  ACK has the LONGP bit set in the CAPAS field), then the combined value
  2432. of its MAXLX1,MAXLX2 fields is  used.    If  the  LONGP  bit  is  set  but  the
  2433. MAXLX1,MAXLX2 pair is missing, then the value 500 will be used by default.
  2434.  
  2435. If  the  response  is  unfavorable  (the LONGP bit is not set in the receiver's
  2436. CAPAS field), then extended headers will not be used and the  MAXL  field  will
  2437. supply the maximum packet length.
  2438.  
  2439. After  the Send-Init has been sent and acknowledged with agreement to allow ex-
  2440. tended headers, all packets up to and including the B or E  packet  which  ter-
  2441. minates  the  transaction  (and its acknowledgement) are allowed -- but not re-
  2442. quired -- to have extended headers; extended and normal packets may  be  freely
  2443. mixed by both Kermits.
  2444.  
  2445. The  normal  Kermit  packet length field (LEN) specifies the number of bytes to
  2446. follow, up to and including the block check.  Since at least 3 bytes must  fol-
  2447. low  (SEQ,  TYPE, and CHECK), a value of 0, 1, or 2 is never encountered in the
  2448. LEN field of a valid unextended Kermit packet.  When extended packets have been
  2449. negotiated,  the LEN field is treated as follows for the duration of the trans-
  2450. action:
  2451.  
  2452.    - If unchar(LEN) > 2 then the packet is a normal, unextended packet.
  2453.    - If unchar(LEN) = 0 then the packet has a "Type 0" extended header.
  2454.    - If unchar(LEN) = 1 or 2, the packet is invalid and  should  cause  an
  2455.      Error.
  2456.  
  2457. "Lengths"  of  1  and  2  are  reserved for future use in Type 1 and 2 extended
  2458. headers, yet to be specified.
  2459.  
  2460. A Type 0 extended packet has the following layout:
  2461.  
  2462. +------+-----+-----+------+-------+-------+--------+----       ----+-------+
  2463. | MARK |     | SEQ | TYPE | LENX1 | LENX2 | HCHECK |  DATA ....    | CHECK |
  2464. +------+-----+-----+------+-------+-------+--------+----       ----+-------+
  2465.                           | Extended Header        |
  2466.  
  2467. The blank length field (SP = tochar(0)) indicates that the  first  3  bytes  of
  2468. what  is  normally the data field is now an extended header of Type 0, in which
  2469. the number of bytes remaining in the packet, up  to  and  including  the  block
  2470. check, is
  2471.  
  2472.     extended-length = (95 x unchar(LENX1)) + unchar(LENX2)
  2473.  
  2474. and  HCHECK  is  a  header  checksum, formed exactly like a Type-1 Kermit block
  2475. check, but from the sum of the ASCII values of the SEQ, TYPE, LENX1, and  LENX2
  2476. fields:
  2477.  
  2478.      s = LEN + SEQ + TYPE + LENX1 + LENX2
  2479.  
  2480.      HCHECK = tochar((s + ((s & 192)/64)) & 63)
  2481.  
  2482. where & is the bitwise AND operator.
  2483.  
  2484. Since  the value of the extended length field must be known accurately in order
  2485. to locate the end of the packet and the packet block check, it  is  vital  that
  2486. this  information  not  be  corrupted  before  it is used.  The header checksum
  2487. prevents this.
  2488.  
  2489. The extended header, like the normal  header  itself,  is  not  prefix-encoded.
  2490. This  is  because  it  is  used at datalink level, before decoding takes place.
  2491. Therefore the entity responsible for building packets must leave  3  spaces  at
  2492. the  beginning  of  the  data field, and the datalink function (spack) fills in
  2493. LENX1, LENX2, and HCHECK based upon the data actually entered into the  packet,
  2494. after encoding.  The packet receiving datalink function (rpack) behaves accord-
  2495. ingly.
  2496.  
  2497. The packet block check is formed in the usual manner, based on all packet bytes
  2498. beginning  with  LEN and ending with the last character in the data field.  The
  2499. block check may be Type 1, 2, or 3, depending upon  what  was  negotiated,  but
  2500. longer  packets  are  more  likely to be corrupted than shorter ones and should
  2501. therefore have higher-order block checks if possible.  This proposal  does  not
  2502. change the way block check type is negotiated, and does not require that Type 2
  2503. or 3 block check be implemented.
  2504.  
  2505. With long packets, the possibility  exists  that  the  arithmetic  sum  of  the
  2506. characters  in  a  packet will exceed 2^15, and will overflow a 16-bit word, or
  2507. become negative.  The checksum function would have  to  be  modified  to  guard
  2508. against  this,  for instance by always setting the high four bits of the sum to
  2509. zero before adding in the next byte.
  2510.  
  2511. Implementation can be a bit tricky.  The Kermit program should be set up to use
  2512. normal,  untextended  packets  by  default -- that is, to mimic the behavior of
  2513. original, "classic" Kermit.  Even  when  the  program  believes  itself  to  be
  2514. capable  of  sending  and  receiving  long packets, it has no knowledge of what
  2515. devices may lie along the communication path, whose buffers might not  be  long
  2516. enough  to  accommodate  bursts  of  data  of the desired length.  Long packets
  2517. should be elected when the user has explicitly elected them with a SET command.
  2518. The current SET SEND PACKET-LENGTH <n> command will do; if the number is larger
  2519. than 94, then the program will -- transparently to the user -- try to negotiate
  2520. long  packets.    A finer degree of control can be accomplished by included SET
  2521. commands to explicitly enable or disable the use of long packets.
  2522.  
  2523. Once long packets are successfully negotiated, the program should  be  prepared
  2524. to  back  off  when errors occur, since the very size of the packets may be the
  2525. cause of the errors.  Upon timeout or receipt of a NAK (or extra copies of  the
  2526. previous  packet),  the  sender  should  be prepared to reconstruct the current
  2527. packet at, say,  half  its  size,  down  to  some  reasonable  minimum,  before
  2528. retransmission.    Even  when  the  size  itself is not the problem, this makes
  2529. retransmission less painful under noisy conditions.
  2530.  
  2531. Long packets and sliding windows may be used  at  the  same  time,  though  the
  2532. benefits from doing so may not be worth the trouble of coding the dynamic buff-
  2533. er allocation required (for n buffers of size m, negotiated at Send-Init time).
  2534. It's  also  worth  noting  that the benefit/cost ratio of long packets declines
  2535. after a length of about 1000, at which point the benefit of  additional  length
  2536. is less than 1%, and the cost of retransmission is very high.
  2537.  
  2538.  
  2539. 7.2. Sliding Windows
  2540.  
  2541. The sliding window extension to Kermit was proposed and developed by a group at
  2542. The Source Telecomputing in McLean, Virginia, led by Leslie Spira and including
  2543. Hugh  Matlock  and John Mulligan, who wrote the following material.  Like other
  2544. extensions, this one is designed for "upward compatibility" with  Kermits  that
  2545. do not support this extension.
  2546.  
  2547. The  windowing  protocol  as  defined  for the Kermit file transfer protocol is
  2548. based on the main premise of continuously sending data packets up to the number
  2549. defined by a set window size.  These data packets are continuously acknowledged
  2550. by the receive side and the ideal transfer occurs as long as  they  are  trans-
  2551. mitted  with good checksums, they are transmitted in sequential order and there
  2552. are no lost data packets or acknowledgements.   The  various  error  conditions
  2553. define  the  details  of the windowing protocol and are best examined on a case
  2554. basis.
  2555.  
  2556. There are five stages that describe the overall sequence of events in the  Ker-
  2557. mit  protocol.  Three of these stages deviate from the original protocol in or-
  2558. der to add the windowing feature.  Stages 1 through 5 are briefly described  on
  2559. the  following  page.    The  three  stages (1, 3 and 4) which deviate from the
  2560. original protocol are then described in greater detail in the pages  that  fol-
  2561. low.
  2562.  
  2563.  
  2564. 7.2.1. Overall Sequence of Events
  2565.  
  2566. STAGE 1 - Propose and Accept Windowing
  2567.     The send side requests windowing in the transmission of  the  Send-Initiate
  2568.     (S)  packet.  The receive side accepts windowing by sending an acknowledge-
  2569.     ment (ACK packet) for the Send-Initiate packet.
  2570.  
  2571. STAGE 2 - Send and Accept File-Header Packet
  2572.     The  send  side  transmits  the  File-Header  (F)  packet and waits for the
  2573.     receive side to acknowledge it prior to transmitting any data.
  2574.  
  2575. STAGE 3 - Transfer Data
  2576.     The  sending  routine  transmits Data (D) packets one after the other until
  2577.     the protocol window is closed.  The receiving side ACKs good  data,  stores
  2578.     data to disk as necessary and NAKs bad data.
  2579.  
  2580.     When  the  sender  receives  an ACK, the window may be rotated and the next
  2581.     packet sent.  If the sender receives a NAK, the data  packet  concerned  is
  2582.     retransmitted.
  2583.  
  2584. STAGE 4 - Send and Accept End_of_File Packet
  2585.     As the sender is reading the file for data  to  send,  it  will  eventually
  2586.     reach  the end of the file.  It then waits until all outstanding data pack-
  2587.     ets have been acknowledged, and then sends an End-of_File (Z) packet.
  2588.  
  2589.     When the receive side gets the End-of-File packet it stores the rest of the
  2590.     data to disk, closes the file, and ACKs the End-of_File packet.
  2591.  
  2592.     The protocol then returns to Stage 2, sending and acknowledging any further
  2593.     File-Header (F) packets.
  2594.  
  2595. STAGE 5 - End of Transmission
  2596.     Once the End-of-File packet has been sent and acknowledged and there are no
  2597.     more files to send, the sender transmits the End-of-Transmission (B) packet
  2598.     in  order  to  end  the  ongoing  transaction.  Once the receiver ACKs this
  2599.     packet, the transaction is ended and the logical connection closed.
  2600.  
  2601.  
  2602. Stage 1 - Propose and Accept Windowing
  2603.  
  2604. The initial connection as currently defined for the Kermit protocol  will  need
  2605. to  change  only  in  terms  of  the contents of the Send-Initiate packet.  The
  2606. receiving Kermit waits for the sending Kermit to transmit the Send-Initiate (S)
  2607. packet and the sending packet does not proceed with any additional transmission
  2608. until the ACK has been returned by the receiver.
  2609.  
  2610. The contents of the Send-Init packet, however, will be slightly revised.    The
  2611. data  field of the Send-Init packet currently contains all of the configuration
  2612. parameters.  The first six fields of the Send-Init packet are fixed as follows:
  2613.  
  2614.    1        2        3        4        5        6
  2615.   +--------+--------+--------+--------+--------+--------+
  2616.   | MAXL   | TIME   | NPAD   | PADC   | EOL    | QCTL   |
  2617.   +--------+--------+--------+--------+--------+--------+
  2618.  
  2619. Fields 7 through 10 are optional features of Kermit and fields 7 through 9 will
  2620. also remain unchanged as defined for the existing protocol:
  2621.  
  2622.    7        8        9        10
  2623.   +--------+--------+--------+--------+
  2624.   | QBIN   | CHKT   | REPT   | CAPAS  |
  2625.   +--------+--------+--------+--------+
  2626.  
  2627. The  windowing capability constitutes a fourth capability and the fourth bit of
  2628. the capability field will be set to 1 if the Kermit implementation  can  handle
  2629. windowing:
  2630.  
  2631.      bit5 bit4 bit3 bit2 bit1 bit0
  2632.     +----+----+----+----+----+----+
  2633.     | #1 | #2 | #3 | #4 | #5 |  0 |
  2634.     +----+----+----+----+----+----+
  2635.                       ^
  2636.                       |
  2637.                      SWC (sliding window capability)
  2638.  
  2639. The remaining fields of the Send-Init packet are either reserved for future use
  2640. by the standard Kermit protocol or reserved  for  local  site  implementations.
  2641. The  four  fields  following the capability field are reserved for the standard
  2642. Kermit protocol.  The field following the capability mask is  used  to  specify
  2643. the "Window Size":
  2644.  
  2645.         10              CAPAS+1  CAPAS+2  CAPAS+3
  2646.     ---+-------+-     -+--------+--------+--------+
  2647.        | CAPAS |  ...  | WINDO  | MAXLX1 | MAXLX2 |
  2648.     ---+-------+-     -+--------+--------+--------+
  2649.                         ^
  2650.                         |
  2651.                       (currently field 11, because CAPAS is still 1 byte)
  2652.  
  2653. WINDO is the window size to be used, encoded printably using the tochar() func-
  2654. tion.  The window size may range from 1 to 31 inclusive.
  2655.  
  2656. The sender will specify the window size it wishes to use and the receiver  will
  2657. reply  (in  the  ACK packet) with the window size it wishes to use.  The window
  2658. size actually used will be the minimum of the two.   If  the  receiver  replies
  2659. with a window size of 0 then no windowing will be done.
  2660.  
  2661.  
  2662. Stage 3 - Transfer Data
  2663.  
  2664. The  sequence  of events required for the transmission of data packets and con-
  2665. firmation of receipts constitute the main functions of the windowing  protocol.
  2666. There are four main functions which can be identified within this stage.  These
  2667. are:
  2668.  
  2669.    - the sender's processing of the data packets,
  2670.    - the receiver's handling of incoming packets,
  2671.    - the sender's handling of the confirmations,
  2672.    - the error handling on both sides.
  2673.  
  2674. The following discussion details the specific  actions  required  for  each  of
  2675. these  functions.  Refer to the state table at the end of this document for the
  2676. specific action taken on a "received message" basis for the full protocol.
  2677.  
  2678. The Sender's Processing of Data Packets
  2679.  
  2680. The sender instigates the transmission by sending the  first  data  packet  and
  2681. then  operating  in a cyclical mode of sending data until the defined window is
  2682. closed.
  2683.  
  2684. Data to be sent must be read from  the  file,  encoded  into  the  Kermit  Data
  2685. packet,  and  saved  in  a Send-Table.  A Send-Table entry consists of the data
  2686. packet itself (which makes convenient the re-send of a  NAK'd  packet),  a  bit
  2687. which  keeps  track of whether the packet has been ACK'd (the ACK'd bit), and a
  2688. retry counter.  The table is large enough to  hold  all  the  packets  for  the
  2689. protocol window.
  2690.  
  2691. Before  each  transmission, the input buffer is checked and input is processed,
  2692. as described below.  Transmission is stopped if the protocol  window  "closes",
  2693. that is, if the Send-Table is full.
  2694.  
  2695. The Receiver's Handling of Incoming Packets
  2696.  
  2697. The  receiver  keeps  its own table as it receives incoming data packets.  This
  2698. allows the receiver to receive subsequent packets while it  is  waiting  for  a
  2699. re-send  of  an erroneous or lost packet.  In other words, the incoming packets
  2700. do not have to be received in sequential order and can still be written to disk
  2701. in order.
  2702.  
  2703. A  Receive-Table  entry consists of the data packet, a bit which keeps track of
  2704. whether a good version of the packet has been received (the ACK'd bit),  and  a
  2705. retry  counter  for  the NAKs we send to request retransmissions of the packet.
  2706. The table is large enough to hold all the packets for the protocol window.
  2707.  
  2708. The different possibilities for a received packet are:
  2709.  
  2710.    1. A new packet, the next sequential one (the usual case)
  2711.    2. A new packet, not the next sequential one (some were lost)
  2712.    3. An old packet, retransmitted
  2713.    4. An unexpected data packet
  2714.    5. Any packet with a bad checksum
  2715.  
  2716. These are now discussed separately:
  2717.  
  2718.    1. The next new packet has sequence number <one past the  latest  table
  2719.       entry>.    The packet is ACK'd, and the Receive-Table is checked for
  2720.       space.  If it is full (already contains  window_size  entries)  then
  2721.       the  oldest  entry  is written to disk.  (This entry should have the
  2722.       ACK'd bit set.  If not, the receiver aborts the file transfer.)  The
  2723.       received  packet is then stored in the Receive-Table, with the ACK'd
  2724.       bit set.
  2725.  
  2726.    2. If the packet received has sequence number in the  range  <two  past
  2727.       the latest table entry> to <window_size past the latest table entry>
  2728.       then it is a new packet, but some have been lost.  (The upper  limit
  2729.       here  represents the highest packet the sender could send within its
  2730.       protocol window.  Note that the requirement to test for this case is
  2731.       what limits the maximum window_size to half of the range of possible
  2732.       sequence numbers) We ACK the packet, and NAK all packets  that  were
  2733.       skipped.    (The skipped packets are those from <one past the latest
  2734.       table entry> to <one before the received packet>) The  Receive-Table
  2735.       is then checked.  The table may have to be rotated to accomodate the
  2736.       packet, as with case 1.  (This time, several table entries may  have
  2737.       to  be written to disk.  As before, if any do not have the ACK'd bit
  2738.       set, they will trigger an abort.)  The packet is then stored in  the
  2739.       table, and the ACK'd bit set.
  2740.  
  2741.    3. A  retransmitted  packet will have sequence number in the range <the
  2742.       oldest table entry> to <the latest table  entry>.    The  packet  is
  2743.       ACK'd, then placed in the table, setting the ACK'd bit.
  2744.  
  2745.    4. A  packet with sequence number outside of the range from <the oldest
  2746.       table entry> to <window_size past the latest  table  entry>  is  ig-
  2747.       nored.
  2748.  
  2749.    5. If the packet received has a bad checksum, we must decide whether to
  2750.       generate a NAK, and if so, with what sequence number.  The best  ac-
  2751.       tion  may  depend  on the configuration and channel error rate.  For
  2752.       now, we adopt the following heuristic:  If there are unACK'd entries
  2753.       in  our  Receive-Table, we send a NAK for the oldest one.  Otherwise
  2754.       we ignore the packet.  (Notice that this  will  occur  in  a  common
  2755.       case:    when  things  have  been going smoothly and one packet gets
  2756.       garbled.  In this case, when we later receive  the  next  packet  we
  2757.       will NAK for this one as described under Case 2 above.)
  2758.  
  2759. The Sender's Handling of Confirmations
  2760.  
  2761. The  sender's  receipt of confirmations controls the rotation of the Send-Table
  2762. and normally returns the sender to  a  sending  state.    The  sender's  action
  2763. depends  on  the  packet  checksum,  the type of confirmation (ACK or NAK), and
  2764. whether the  confirmation  is  within  the  high  and  low  boundaries  of  the
  2765. Send-Table.
  2766.  
  2767. If the checksum is bad the packet is ignored.
  2768.  
  2769. When  the  sender receives an ACK, the sequence number is examined.  If the se-
  2770. quence number is outside of the current table boundaries, then the ACK is  also
  2771. ignored.  If the sequence number is inside of the current table boundaries then
  2772. the ACK'd bit for that packet is marked.  If the entry is at the low  boundary,
  2773. this  enables  a  "rotation"  of the table.  The low boundary is changed to the
  2774. next sequential entry for which the ACK'd bit is not set.  This frees space  in
  2775. the table to allow further transmissions.
  2776.  
  2777. When  the  sender receives a NAK, the table boundaries are checked.  A NAK out-
  2778. side of the table boundary is ignored and a NAK inside the table  boundary  in-
  2779. dicates  that  the  sender must re-send the packet.  The sender first tests the
  2780. packet's retry counter against the retry threshold.  If the threshold has  been
  2781. reached,  then  the  transfer is stopped (by going to the Abort state).  Other-
  2782. wise, the retry counter is incremented and the packet re-sent.
  2783.  
  2784. Error Handling for Both Sides
  2785.  
  2786. Three situations are discussed here:  Sender timeout, Receiver timeout, and in-
  2787. valid packets.
  2788.  
  2789. If  certain  packets are lost, each side may "hang", waiting for the other.  To
  2790. get things moving when this happens  each  may  have  a  "timeout  limit",  the
  2791. longest they will wait for something from the other side.
  2792.  
  2793. If  the  sender's  timeout condition is triggered, then it will send the oldest
  2794. unACK'd packet.  This will be the first one in the Send-Table.
  2795.  
  2796. If the receiver's timeout condition is triggered, then it will send a  NAK  for
  2797. the  "most  desired  packet".    This  is  defined as either the oldest unACK'd
  2798. packet, or if none are unACK'd, then the next packet to be  received  (sequence
  2799. number  <latest  table  entry  plus  one>).   The packet retry count is not in-
  2800. cremented by this NAK; instead we depend on the timeout retry count,  discussed
  2801. next.
  2802.  
  2803. For  either the sender or receiver, the timeout retry count is incremented each
  2804. time a timeout occurs.  If the timeout retry limit is exceeded  then  the  side
  2805. aborts  the  file  transfer.  Each side resets the retry count to zero whenever
  2806. they receive a packet.
  2807.  
  2808. In addition, as with the existing Kermit, any invalid packet types received  by
  2809. either side will cause an Error packet and stop the file transfer.
  2810.  
  2811.  
  2812. Stage 4 - Send and Accept End of File Packet
  2813.  
  2814. There  are several ways to end the file transfer.  The first is the normal way,
  2815. when the sender encounters an end-of-file condition when reading  the  file  to
  2816. get a packet for transmission.  The second is because of a sender side user in-
  2817. terrupt.  The third is because of a receiver side  user  interrupt.    Both  of
  2818. these  cause  the  received  file to be discarded.  In addition either side may
  2819. stop the transfer with an Error packet if an  unrecoverable  error  is  encoun-
  2820. tered.
  2821.  
  2822. Normal End of File Handling
  2823.  
  2824. When  the  sender  reaches the end of file, it must wait until all data packets
  2825. have been acknowledged before sending the End-of-File (Z) packet.  To  do  this
  2826. it must be able to check the end-of-file status when it processes ACKs.  If the
  2827. ACK causes the Send-Table to be emptied and the end-of-file has  been  reached,
  2828. then  a  transition  is  made to the Send_Eof state which sends the End_of_File
  2829. packet.
  2830.  
  2831. When the receiver gets the End_of_File packet, it writes the  contents  of  the
  2832. Receive-Table  to  the  file  (suitably  decoded) and closes the file.  (If any
  2833. entries do not have the ACK'd bit set, or if errors occur in writing the  file,
  2834. the  receiver  aborts  the file transfer.)  If the operation is successful, the
  2835. receiver sends an ACK.  It then sets its sequence  number  to  the  End_of_File
  2836. packet sequence number and goes to Rcv_File state.
  2837.  
  2838.  
  2839. File Transfer Interruptions
  2840.  
  2841. Sender User Interrupt
  2842.     Whenever the sender checks for input from the data communications line,  it
  2843.     should also check for user input.  If that indicates that the file transfer
  2844.     should be stopped, the sender goes directly to the Send_Eof state and sends
  2845.     an  End_of_File  packet  with  the Discard indication.  It will not have to
  2846.     wait for outstanding packets to be ACK'd.
  2847.  
  2848.     When the receiver gets the End_of_File packet with the  Discard  indication
  2849.     it  discards  the  file, sets its sequence number to the End_of_File packet
  2850.     sequence number, and goes to RcvFile state.
  2851.  
  2852. Receiver User Interrupt
  2853.     Whenever  the  receiver checks for input from the data communications line,
  2854.     it also should check for user input.   If  that  indicates  that  the  file
  2855.     transfer  should be stopped, the receiver sets an "interrupt indication" of
  2856.     X (for "stop this file transfer") or of Z (for  "stop  the  batch  of  file
  2857.     transfers").   When the receiver later sends an ACK, it places an X or Z in
  2858.     the data field.
  2859.  
  2860.     When the sender gets this ACK, it goes to the Send_Eof state and sends  the
  2861.     End_of_File packet with the Discard indication, as above.
  2862.  
  2863.     When  the receiver gets the End_of_File packet with the Discard indication,
  2864.     it discards the file, sets its sequence number to  the  End_of_File  packet
  2865.     sequence number, and goes to RcvFile state.
  2866.  
  2867.  
  2868. Low Level Protocol Requirements
  2869.  
  2870. The windowing protocol makes certain assumptions about the underlying transmis-
  2871. sion and reception mechanism.
  2872.  
  2873. First, it must provide a full-duplex channel so that messages may be  sent  and
  2874. received simultaneously.
  2875.  
  2876. Second,  it  will prove advantageous to be able to buffer several received mes-
  2877. sages at the low level before processing them at the Kermit level.  This is for
  2878. two  reasons.  The first is that the Kermit windowing level of the protocol may
  2879. take a while to process one input, and meanwhile  several  others  may  arrive.
  2880. The  second  reason is to support XON/XOFF flow control.  If Kermit receives an
  2881. XOFF from the data communications line, it must wait for an XON before  sending
  2882. its  packet.  While it is waiting, the low level receive must be able to accept
  2883. input.  Otherwise a deadlock situation could arise with  each  side  flow  con-
  2884. trolled, waiting for the other.
  2885.  
  2886.  
  2887. Kermit Windowing Protocol State Table
  2888.  
  2889. The  following  table shows the inputs expected, the actions performed, and the
  2890. succeeding states for the Send_Data_Windowing and Rcv_Data_Windowing states.
  2891.  
  2892. If both sides agree on windowing in the Send Init  exchange,  then  instead  of
  2893. entering  the  old  Send_Data or Rcv_Data states from Send_File or Rcv_File, we
  2894. enter the new Send_Data_Windowing or Rcv_Data_Windowing.
  2895.  
  2896. SEND_DATA_WINDOWING (SDW)
  2897.  
  2898. Rec'd Msg                Action                          Next State
  2899.  
  2900. No input/Window closed  (1) Wait for input                   SDW
  2901. No input/Window open    (2) Read file, encode packet,        SDW
  2902.                             Place in table, mark unACK'd,
  2903.                             Send packet
  2904.  
  2905. ACK/ X or Z             (3) set interrupt indicator (X/Z)  Send_Eof
  2906. ACK/outside table        -ignore-                            SDW
  2907. ACK/inside table        (4) mark pkt ACK'd,         SDW or Send_Eof
  2908.                             if low rotate table,
  2909.                             if file eof & table empty
  2910.                                then goto Send_Eof
  2911.  
  2912. NAK/outside table        -ignore-                            SDW
  2913. NAK/inside table        (5) test retry limit,                SDW
  2914.                             re-send DATA packet
  2915.  
  2916. Bad checksum            -ignore-                             SDW
  2917.  
  2918. Timeout                 (6) re-send oldest unACK'd pkt       SDW
  2919.  
  2920. User interrupt          (7) set interrupt indicator (X/Z)  Send_Eof
  2921.  
  2922. Other                   (8) send Error                      Quit
  2923.  
  2924. RCV_DATA_WINDOWING (RDW)
  2925.  
  2926. Rec'd Msg                Action                          Next State
  2927.  
  2928. DATA/new                (1) send ACK                         RDW
  2929.                             if table full: file & rotate
  2930.                             store new pkt in table
  2931. DATA/old                (2) send ACK, store in table         RDW
  2932. DATA/unexpected         -ignore-                             RDW
  2933.  
  2934. Z/discard               (3) discard file                   Rcv_File
  2935. Z/                      (4) write table to file & close    Rcv_File
  2936.                             if OK send ACK, else Error     or Quit
  2937.  
  2938. Bad checksum            (5) send NAK for oldest unACK'd      RDW
  2939.  
  2940. Timeout                 (6) send NAK for most desired pkt    RDW
  2941.  
  2942. User Interrupt          (7) Set interrupt indicator X or Z   RDW
  2943.  
  2944. Other                   (8) send Error pkt                  Quit
  2945.  
  2946.  
  2947. 7.2.2. Questions and Answers about Sliding Windows
  2948.  
  2949. Q.  What is the purpose of the "windowing" extension?
  2950.  
  2951. A.  The object is to speed up file transfers using Kermit.  The  increase  will
  2952.     be  especially  noticeable over the data networks (such as Telenet and Tym-
  2953.     net) and over connections using satellite links.  This is because there are
  2954.     long communications delays over these connections.
  2955.  
  2956. Q.  How does it work?
  2957.  
  2958. A.  Basically,  it  allows you to send several packets out in a row before get-
  2959.     ting the first acknowledgment back.  The number of packets that can be sent
  2960.     out is set by the "window size", hence the name windowing.
  2961.  
  2962. Q.  Could you explain in more detail?
  2963.  
  2964. A.  Right  now, a system sending a file transmits one packet of data, then does
  2965.     nothing more until it gets back an acknowledgment that the packet has  been
  2966.     received.    Once  it  gets  an acknowledgment, it sends the next packet of
  2967.     data.  Over standard direct-dial land-based phone lines,  the  transmission
  2968.     delays  are  relatively small.  However, the public data networks or satel-
  2969.     lite links can introduce delays of up to several seconds round trip.  As  a
  2970.     result, the sending system ends up spending much more time waiting than ac-
  2971.     tually sending data.
  2972.  
  2973.     With the new windowing enhancement, the sending system will be able to keep
  2974.     sending data continuously, getting the acknowledgments back later.  It only
  2975.     has to stop sending data if it reaches the  end  of  the  current  "window"
  2976.     without getting an acknowledgment for the first packet in the current "win-
  2977.     dow".
  2978.  
  2979. Q.  What size is the "window"?
  2980.  
  2981. A.  The window size can vary depending on what the two ends of  the  connection
  2982.     agree  on.  The suggested standard window size will be 8 packets.  The max-
  2983.     imum is 31 packets.
  2984.  
  2985.     The Kermit sequence numbering is modulo 64 (it "wraps" back to the 1st  se-
  2986.     quence  number after the 64th sequence number).  It is helpful to limit the
  2987.     maximum window size to 31 to avoid problems  (ambiguous  sequence  numbers)
  2988.     under certain error conditions.
  2989.  
  2990. Q.  Is windowing in effect throughout a Kermit session?
  2991.  
  2992. A.  No,  it  is  only  in effect during the actual data transfer (data packets)
  2993.     portion of a file transfer.  Windowing begins with the first data packet (D
  2994.     packet type), and stops when you get an End-of-File packet (Z packet type).
  2995.  
  2996. Q.  Why does it stop when you get to the End-of-File packet?
  2997.  
  2998. A.  This is done primarily to avoid having more than one file open at once.
  2999.  
  3000. Q.  Why  will  windowing  be  especially helpful at higher baud rates over com-
  3001.     munications paths that have delays?
  3002.  
  3003. A.  As you increase the baud rate, the  transmission  speed  of  the  data  in-
  3004.     creases, but you do not change the delay caused by the communications path.
  3005.     As a result, the delay becomes more and more significant.
  3006.  
  3007.     Assume, for example, that your communications path introduces a delay of  1
  3008.     second  each  way  for  packets, for a total delay of 2 seconds round trip.
  3009.     Assume also that your packets have 900 bits in  them  so  it  takes  you  3
  3010.     seconds to send a packet at 300 baud (this is roughly equivalent to a typi-
  3011.     cal Kermit packet).
  3012.  
  3013.     WITHOUT windowing, here is what happens:
  3014.  
  3015.     If at 300 baud you transmitted data for 3 seconds (sending 900 bits),  then
  3016.     waited  2 seconds for each acknowledgment, your throughput would be roughly
  3017.     180 baud.  (Total time for each transmission = 5 seconds.  900/5 = 180).
  3018.  
  3019.     However, if you went to 2400 baud, you would transmit data for 3/8  second,
  3020.     then  wait 2 seconds for an acknowledgment.  (Total time for each transmis-
  3021.     sion = 2 and 3/8 seconds).  The throughput would increase only to about 378
  3022.     baud. (900 / 2.375 = 378).
  3023.  
  3024.     The delay becomes the limiting factor; in this case, with this packet size,
  3025.     the delay sets an outside limit of 450 baud (900 / 2 second delay  =  450),
  3026.     no matter how fast the modem speed.
  3027.  
  3028.     WITH  windowing,  the throughput should be close to the actual transmission
  3029.     speed.  It should be possible to send data nearly continuously.  The  exact
  3030.     speed  will  depend  on the window size, length of transmission delays, and
  3031.     error rate.
  3032.  
  3033. Q.  Are there any new packet types introduced by this extension?
  3034.  
  3035. A.  No, the only change is to the contents of the Send-Init packet, to  arrange
  3036.     for  windowing if both sides can do it.  If either side cannot, Kermit will
  3037.     work as it does now.  Adding an extension such as this was provided for  in
  3038.     the  original Kermit definition.  See section 3 of the windowing definition
  3039.     for details.
  3040.  
  3041. Q.  On the receive side, in section 4.2, why does the definition say that writ-
  3042.     ing to disk is done when the Receive-Table becomes full rather than as soon
  3043.     as you get a good packet?
  3044.  
  3045. A.  The definition was phrased this way because  it  makes  the  logic  of  the
  3046.     receive side clearer and simpler to implement.
  3047.  
  3048.     Actually,  you  could  also write a packet to disk when it is a good packet
  3049.     and it is the earliest entry in the receive table.  This approach  has  the
  3050.     disadvantage that you don't know at this point that the sender has received
  3051.     your ACK, so you have to be prepared to handle the same packet later on  if
  3052.     the  sender never gets the ACK, times out, and sends the same packet again.
  3053.     Thus you have to be prepared to deal with packets previous to  the  current
  3054.     window; you will have to ACK such a packet if it has been received properly
  3055.     before.
  3056.  
  3057.     By writing packets to disk only when the receive table becomes  full,  (the
  3058.     oldest  packet)  you  know that the sender has received your ACK (otherwise
  3059.     the sender could not have rotated the window to the n+1  position  to  send
  3060.     the  current  packet, where n is the window size).  This makes it very easy
  3061.     to stay in synch with the sender.  The disadvantage  of  this  approach  is
  3062.     that  when you receive the End-of-File packet, you have to take the time to
  3063.     write all the remaining packets in the Receive-Table to disk.
  3064.  
  3065. Q.  Could you briefly explain what happens if a single packet gets corrupted?
  3066.  
  3067. A.  In essence, the receiver will ignore the bad packet.  When it gets the next
  3068.     good  packet,  it  will  realize (because packets are numbered) that one or
  3069.     more packets were lost, and NAK those packets.  The receiver  continues  to
  3070.     accept good data.
  3071.  
  3072.     As  long as the sender's window does not become "blocked", the only loss of
  3073.     throughput will be the time it takes to transmit the NAK'd packets.
  3074.  
  3075. Q.  There are currently two proposals for Kermit extensions: the Windowing  ex-
  3076.     tension  and a proposal for extended packet lengths.  What are the relative
  3077.     advantages  and  disadvantages  of  sliding  windows  and  extended  packet
  3078.     lengths?
  3079.  
  3080. A.  What is best depends on the exact conditions and systems involved in a par-
  3081.     ticular file transfer.  There are some general rules however.
  3082.  
  3083.     Windowing helps more and more as the communications path delays get longer.
  3084.  
  3085.     Windowing is also more and more helpful as the baud rate goes up.
  3086.  
  3087.     Increased packet length is most helpful on circuits with low  error  rates.
  3088.     If the error rate is high, it is difficult for a long packet to get through
  3089.     uncorrupted.  Also, it then  takes  longer  to  re-transmit  the  corrupted
  3090.     packet.
  3091.  
  3092.     On  some  machines, the CPU time to process a packet is relatively constant
  3093.     no matter what the packet length, so longer packets can reduce CPU time.
  3094.  
  3095. Q.  Are extended packet lengths and sliding windows mutually exlusive?
  3096.  
  3097. A.  No, there is no real reason that they would have to be.    As  a  practical
  3098.     matter,  it  is slightly easier to implement windowing if you know the max-
  3099.     imum packet size ahead of time, since you can then just  use  an  array  to
  3100.     store  your  data.    In standard Kermit, you know automactically that your
  3101.     maximum packet length is 94, so you can just go ahead and dimension an  ar-
  3102.     ray at 94 by Window-size.
  3103.  
  3104.     If you are going to use both extended packet length and windowing, you need
  3105.     to select the maximum packet length and window-size so that the combination
  3106.     does not exceed the available memory for each side of the transfer.
  3107.  
  3108.     In  addition, it is possible to see the desired relationship between packet
  3109.     size and windowing for various baud rates and communications delays.    For
  3110.     the  common  case  of  an error corrected by one retransmission of the cor-
  3111.     rupted packet, the minimum window size  needed  for  continuous  throughput
  3112.     (the window never gets "blocked") can be calculated by:
  3113.  
  3114.                     4 x delay x baud rate
  3115.       WS  >   1 +  ------------------------
  3116.                        packet-size x 10          (this is the # of bits)
  3117.  
  3118.     Windowing  always  helps  (the minimal continuous throughput window size is
  3119.     always greater than 1).
  3120.  
  3121.     In the above equation, the "4" derives  from  the  fact  that  a  corrupted
  3122.     packet has 4 transit times involved:
  3123.  
  3124.        - Original (bad checksum) packet
  3125.        - NAK for the packet
  3126.        - Retransmission of packet
  3127.        - ACK for retransmission.
  3128.  
  3129.     All of this must happen before the window becomes blocked.
  3130.  
  3131.     The  "delay"  is  the  effective maximum one-way communications path delay,
  3132.     which includes any CPU delays.
  3133.  
  3134.     Strictly speaking, the "packet-size" should have  the  length  of  the  ACK
  3135.     packets added to it.
  3136.  
  3137.     As an example, if you assume a 2-second (one-way) delay, at 1200 baud, with
  3138.     a packet size of 94, the minimum  window  size  for  continuous  throughput
  3139.     would be:
  3140.  
  3141.               4 x 2 x 1200
  3142.        WS  >  ------------    =   10.2
  3143.                 94 x 10
  3144.  
  3145.     Under  these  circumstances, a window size of at least 11 should be chosen,
  3146.     if possible.
  3147.  
  3148.  
  3149. 7.2.3. More Q-and-A About Windows
  3150.  
  3151. While reading the following questions and answers, keep in mind that the Kermit
  3152. windowing  definiton was developed to handle a common situation of long circuit
  3153. delays with possible moderate error rates.  Kermit does not need this  type  of
  3154. extension  for  clean  lines  with  insignificant delays - Kermit could be left
  3155. alone, or use Extended Packet Lengths, in such environments.
  3156.  
  3157. Long delays with significant error rates will occur under two obvious and  com-
  3158. mon conditions:
  3159.  
  3160.    1. Local  phone  line  (of  uncertain  quality) to Public Data Networks
  3161.       (such as Telenet).
  3162.  
  3163.    2. Satellite phone links.  These  often  occur  with  the  lower-priced
  3164.       phone  services,  which often also have noisier lines.  In addition,
  3165.       satellite links will increase as more people need to  transfer  data
  3166.       overseas.
  3167.  
  3168. The  above  conditions  will  become more common, as well increased baud rates,
  3169. which make the delays more significant.
  3170.  
  3171. As an aside, note that the benefit of Extended Packet Lengths over  the  Public
  3172. Data  Networks  is  limited  by the number of outstanding bytes the PDN allows.
  3173. (Internally, the PDNs require end-to-end acknowledgement.  They use  their  own
  3174. windowing  system within the network.)  I don't currently know the exact impact
  3175. of this.
  3176.  
  3177. Now on to the questions...
  3178.  
  3179. Q.  Can sliding windows be done on half-duplex channels?  Are any modifications
  3180.     to the proposal required?
  3181.  
  3182. A.  An underlying assumption in the development of windowing was that there was
  3183.     a full-duplex channel.
  3184.  
  3185.     The intent of windowing is to try to keep the sender  continuously  sending
  3186.     data.   Obviously, this is not possible on a half-duplex channel.  A better
  3187.     solution for half-duplex channels  would  be  to  use  an  extended  packet
  3188.     length.
  3189.  
  3190.     An  attempt  to  use windowing on half-duplex really is just a way of doing
  3191.     extended packet lengths.  The sender would send out  a  group  of  packets,
  3192.     then wait and get a group of ACKS.  It would be better to simply send out a
  3193.     large packet, which would have less overhead.
  3194.  
  3195. Q.  Is the cost in complexity for sliding windows worth the increase in perfor-
  3196.     mance?
  3197.  
  3198. A.  Under  the conditions described above (long delays and possibly significant
  3199.     error rates) windowing can increase performance by a factor  of  2,  3,  or
  3200.     more,  especially at higher baud rates.  This increase is necessary to make
  3201.     Kermit viable under some conditions.  With classic Kermit over  the  Public
  3202.     Data  Networks,  I  have  had througput as low as 250 baud over a 1200 baud
  3203.     circuit (with a negligible error rate).  Windowing should allow  throughput
  3204.     close to the maximum baud rate.
  3205.  
  3206.     Windowing is most helpful when the delay is significant in relation to data
  3207.     sending time.  Any delay becomes more significant as users move  to  higher
  3208.     baud rates (2400 baud and beyond).
  3209.  
  3210.     The  complexity  of  implementing  windowing has yet to be fully evaluated.
  3211.     The first implementation (for the IBM  PC  using  C-Kermit)  proved  to  be
  3212.     fairly  manageable.  It appears that the windowing logic can be implemented
  3213.     so that Kermit Classic uses the same code, but with a  window  size  of  1,
  3214.     which should avoid having to keep separate sections of code.
  3215.  
  3216.     The  windowing  definiton was developed with the idea of keeping changes to
  3217.     Kermit to a minimum.  No new packet types were  developed,  ACKs  and  NAKS
  3218.     were  kept  the  same,  and  windowing is in effect only during actual data
  3219.     transfer (D packets).  We tried to define the protocol  so  that  a  window
  3220.     size of 1 was the same as the current classic Kermit.
  3221.  
  3222.     These  factors should help reduce the complexity of implementing windowing.
  3223.     We currently have a working implementation of Kermit for the IBM  PC  going
  3224.     through testing.
  3225.  
  3226.     It's fun to see the modem "Send" light stay on constantly!
  3227.  
  3228. Q.  Why doesn't the Windowing proposal use a "bulk ACK"?
  3229.  
  3230. A.  There  are a couple of possibilities for ways to use some sort of "bulk" or
  3231.     combined ACK.  We looked at them when developing the Windowing  definition.
  3232.     We did not see any advantages that outweighed the disadvantages.
  3233.  
  3234.     Here are two possible ways of changing how ACKs would work:
  3235.  
  3236.        1. An  ACK for any packet would also ACK all previous packets.  The
  3237.           concept that an ACK would also ACK all  previous  packets  seems
  3238.           attractive  at  first, since it would appear to reduce overhead.
  3239.           However, it has a major drawback in that you then must  re-synch
  3240.           when  you  get errors.  This is because, once you have an error,
  3241.           you have to send a NAK, then stop and wait for a re-transmission
  3242.           of the NAK'd packet, before you send out any more ACKs.  (If you
  3243.           sent out an ACK for a later packet, it would imply that you  had
  3244.           received  the  NAK'd  packet.    Not  until  you  safely get the
  3245.           re-transmission can you go ahead.)  This would negate one of the
  3246.           nicest  parts  of  windowing as it is defined now, which is that
  3247.           the sender can transmit  continuously,  including  during  error
  3248.           recovery,  as  long  as  the window does not become blocked.  It
  3249.           does not appear to us that the reduction in the number  of  ACKs
  3250.           sent  is  worth  this penalty.  In addition, this is a departure
  3251.           from the way ACKs in Kermit work now.  It seemed best to make as
  3252.           few  changes  to Kermit as possible.  If this facility turns out
  3253.           to be useful, it would be better to introduce a new packet  type
  3254.           (or  other  means  of  distinguishing  regular  ACKs  from "Bulk
  3255.           ACKS").
  3256.  
  3257.        2. A new "Bulk ACK" packet type could be developed.  This  did  not
  3258.           seem  to  us to be a good idea, since it required defining a new
  3259.           packet type.  We were trying to fit windowing  in  with  as  few
  3260.           changes  to  Kermit  as  possible.    A "Bulk ACK", in which one
  3261.           packet could contain a whole string of ACKs and NAKs, also seems
  3262.           like  a  good  idea at first.  The penalty here is a little more
  3263.           subtle.  First, if you lose a "Bulk ACK" packet, you  lose  more
  3264.           information  and  it takes longer to get things flowing smoothly
  3265.           again.  Second, and probably more importantly, efficient window-
  3266.           ing  depends  on  the window never becoming "blocked" (i.e., the
  3267.           sender can always keep sending).  A "Bulk ACK"  interferes  with
  3268.           this to some extent, because if you have a long delay, the "Bulk
  3269.           ACK" with its multiple individual ACKs may not get back  to  the
  3270.           sender  in  time  to  prevent  the window from becoming blocked.
  3271.           With the current definition of windowing, returning an  ACK  for
  3272.           each  packet  gets  the  ACKs (or NAKs) to the sender as soon as
  3273.           possible.  This provides the best chance for keeping the  window
  3274.           open  so  that the sender can transmit continually.  Once again,
  3275.           remember the conditions under which windowing  is  most  useful:
  3276.           long  delays  with  significant  error  rates.  Under these con-
  3277.           ditions, individual ACKs have advantages.  If  these  conditions
  3278.           don't apply, it may not be necessary to use windowing, or it may
  3279.           be better to use extended packet lengths.
  3280. 8. Kermit Commands
  3281.  
  3282. The following list of Kermit commands and terms is suggested.  It  is  not  in-
  3283. tended  to  recommend  a particular style of command parsing, only to promote a
  3284. consistent vocabulary, both in documentation and in choosing the names for com-
  3285. mands.
  3286.  
  3287.  
  3288. 8.1. Basic Commands
  3289.  
  3290. SEND    This verb tells a Kermit program to send one or more files from its own
  3291.         file structure.
  3292.  
  3293. RECEIVE This verb should tell a Kermit program to expect one or more  files  to
  3294.         arrive.
  3295.  
  3296. GET     This  verb  should  tell a user Kermit to send one or more files.  Some
  3297.         Kermit implementations have separate RECEIVE and GET  commands;  others
  3298.         use RECEIVE for both purposes, which creates confusion.
  3299.  
  3300. Since  it  can be useful, even necessary, to specify different names for source
  3301. and destination files, these commands should take operands as follows (optional
  3302. operands in [brackets]):
  3303.  
  3304. SEND local-source-filespec [remote-destination-filespec]
  3305.         If the destination file specification is included, this will go in  the
  3306.         file header packet, instead of the file's local name.
  3307.  
  3308. RECEIVE [local-destination-filespec]
  3309.         If the destination filespec is given, the incoming file will be  stored
  3310.         under that name, rather than the one in the file header pakcet.
  3311.  
  3312. GET remote-source-filespec [local-destination-filespec]
  3313.         If the destination filespec is given, the incoming file will be  stored
  3314.         under that name, rather than the one in the file header packet.
  3315.  
  3316. If  a file group is being sent or received, alternate names should not be used.
  3317. It may be necessary to adopt  a  multi-line  syntax  for  these  commands  when
  3318. filespecs may contain characters that are also valid command field delimiters.
  3319.  
  3320.  
  3321. 8.2. Program Management Commands
  3322.  
  3323. EXIT    Leave  the  Kermit  program, doing whatever cleaning up must be done --
  3324.         deassigning of devices, closing of files, etc.
  3325.  
  3326. QUIT    Leave the Kermit program without cleaning up, in such a  manner  as  to
  3327.         allow further manipulation of the files and devices.
  3328.  
  3329. PUSH    Preserve  the  current  Kermit environment and enter the system command
  3330.         processor.
  3331.  
  3332. TAKE    Read and execute Kermit program commands from a local file.
  3333.  
  3334. LOG     Specify a log for file transfer transactions, or for  terminal  session
  3335.         logging.
  3336.  
  3337.  
  3338. 8.3. Terminal Emulation Commands
  3339.  
  3340. CONNECT This  verb,  valid  only  for a local Kermit, means to go into terminal
  3341.         emulation mode; present the illusion of being directly connected  as  a
  3342.         terminal  to the remote system.  Provide an "escape character" to allow
  3343.         the user to "get back" to the local system.  The escape character, when
  3344.         typed,  should take a single-character argument; the following are sug-
  3345.         gested:
  3346.  
  3347.             0   (zero) Transmit a NUL
  3348.             B   Transmit a BREAK
  3349.             C   Close the connection, return to local Kermit command level
  3350.             P   Push to system command processor
  3351.             Q   Quit logging (if logging is being done)
  3352.             R   Resume logging
  3353.             S   Show status of connection
  3354.             ?   Show the available arguments to the escape character
  3355.             (a second copy  of  the  escape  character):  Transmit  the  escape
  3356.                 character itself
  3357.  
  3358. Lower  case  equivalents should be accepted.  If any invalid argument is typed,
  3359.         issue a beep.
  3360.  
  3361. Also see the SET command.
  3362.  
  3363.  
  3364. 8.4. Special User-Mode Commands
  3365.  
  3366. These commands are used only by Users of Servers.
  3367.  
  3368. BYE     This command sends a message to the remote server to  log  itself  out,
  3369.         and upon successful completion, terminate the local Kermit program.
  3370.  
  3371. FINISH  This  command  causes  the remote server to shut itself down gracefully
  3372.         without logging out its job, leaving the local Kermit at Kermit command
  3373.         level, allowing the user to re-CONNECT to the remote job.
  3374.  
  3375.  
  3376. 8.5. Commands Whose Object Should Be Specified
  3377.  
  3378. Some  Kermit implementations include various local file management services and
  3379. commands to invoke them.  For instance, an implementation might  have  commands
  3380. to  let  you  get  directory  listings, delete files, switch disks, and inquire
  3381. about free disk space without having to exit and restart the program.   In  ad-
  3382. dition,  remote  servers may also provide such services.  A user Kermit must be
  3383. able to distinguish between commands aimed at its own system and those aimed at
  3384. the remote one.  When any confusion is possible, such a command may be prefixed
  3385. by one of the following "object prefixes":
  3386.  
  3387. REMOTE  Ask the remote Kermit server to provide this service.
  3388.  
  3389. LOCAL   Perform the service locally.
  3390.  
  3391. If the "object prefix" is omitted, the command should be executed locally.  The
  3392. services include:
  3393.  
  3394. LOGIN   This  should  be  used  in its timesharing sense, to create an identity
  3395.         ("job", "session", "access", "account") on the system.
  3396.  
  3397. LOGOUT  To terminate a session that was initiated by LOGIN.
  3398.  
  3399. COPY    Make a new copy of the specified file with the specified name.
  3400.  
  3401. CWD     Change Working Directory.  This is ugly, but more  natural  verbs  like
  3402.         CONNECT and ATTACH are too imprecise.  CWD is the ARPAnet file transfer
  3403.         standard command to invoke this function.
  3404.  
  3405. DIRECTORY
  3406.         Provide  a  list  of  the  names, and possibly other attributes, of the
  3407.         files in the current working directory (or the specified directory).
  3408.  
  3409. DELETE  Delete the specified files.
  3410.  
  3411. ERASE   This could be a synomym for DELETE, since its meaning is clear.
  3412.  
  3413.             (It doesn't seem wise to include UNDELETE  or  UNERASE  in  the
  3414.             standard  list; most systems don't support such a function, and
  3415.             users' expectations should not be toyed with...)
  3416.  
  3417. KERMIT  Send a command to the remote Kermit server in its own interactive  com-
  3418.         mand syntax.
  3419.  
  3420. RENAME  Change the name of the specified file.
  3421.  
  3422. TYPE    Display the contents of the specified file(s) at the terminal.
  3423.  
  3424. SPACE   Tell how much space is used and available for storing files in the cur-
  3425.         rent working directory (or the specified directory).
  3426.  
  3427. SUBMIT  Submit the specified file(s) for background (batch) processing.
  3428.  
  3429. PRINT   Print the specified file(s) on a printer.
  3430.  
  3431. MOUNT   Request a mount of the specified tape, disk, or other removable storage
  3432.         medium.
  3433.  
  3434. WHO     Show  who  is  logged in (e.g. to a timesharing system), or give infor-
  3435.         mation about a specified user or network host.
  3436.  
  3437. MAIL    Send electronic mail to the specified user(s).
  3438.  
  3439. MESSAGE Send a terminal message (on a network or timesharing system).
  3440.  
  3441. HELP    Give brief information about how to use Kermit.
  3442.  
  3443. SET     Set various parameters relating to debugging, transmission, file  mode,
  3444.         and so forth.
  3445.  
  3446. SHOW    Display settings of SET parameters, capabilities in force, etc.
  3447.  
  3448. STATISTICS
  3449.         Give information about the performance of the most recent file transfer
  3450.         -- elapsed time, effective baud rate, various counts, etc.
  3451.  
  3452. HOST    Pass  the  given command string to the specified (i.e. remote or local)
  3453.         host for execution in its own command language.
  3454.  
  3455. LOGGING Open or close a transaction or debugging log.
  3456.  
  3457.  
  3458. 8.6. The SET Command
  3459.  
  3460. A SET command should be provided to allow the user to tailor  a  connection  to
  3461. the  peculiarities  of the communication path, the local or remote file system,
  3462. etc.  Here are some parameters that should be SET-able:
  3463.  
  3464. BLOCK-CHECK
  3465.         Specify  the type of block check to be used: single character checksum,
  3466.         two-character checksum, 3-character CRC.
  3467.  
  3468. DEBUGGING
  3469.         Display  or  log  the  packet  traffic,  packet numbers, and/or program
  3470.         states.  Useful for debugging new versions of  Kermit,  novel  combina-
  3471.         tions of Kermit programs, etc.
  3472.  
  3473. DELAY   How  many seconds a remote (non-server) Kermit should wait before send-
  3474.         ing the Send-Init packet, to give the user time to escape back  to  the
  3475.         local Kermit and type a RECEIVE command.
  3476.  
  3477. DISPLAY Style of file transfer display (NONE, SERIAL, SCREEN, etc).
  3478.  
  3479. DUPLEX  For terminal emulation, specify FULL or HALF duplex echoing.
  3480.  
  3481. END-OF-LINE
  3482.         Specify any line terminator that must be used after a packet.
  3483.  
  3484. ESCAPE  Specify the escape character for terminal emulation.
  3485.  
  3486. FILE attributes
  3487.         Almost  any  of  the  attributes listed above in the Attributes section
  3488.         (6.5).  The most common need is to tell the Kermit program  whether  an
  3489.         incoming or outbound file is text or binary.
  3490.  
  3491. FLOW-CONTROL
  3492.         Specify the flow control mechanism for  the  line,  such  as  XON/XOFF,
  3493.         ENQ/ACK,  DTR/CTS,  etc.  Allow flow control to be turned off (NONE) as
  3494.         well as on.  Flow control is done only on full-duplex connections.
  3495.  
  3496. HANDSHAKE
  3497.         Specify  any  line-access  negotiation  that  must be used or simulated
  3498.         during file transfer.  For instance, a half duplex  system  will  often
  3499.         need to "turn the line around" after sending a packet, in order to give
  3500.         you permission to reply.  A common handshake is XON (^Q);  the  current
  3501.         user of the line transmits an XON when done transmitting data.
  3502.  
  3503. LINE    Specify  the line or device designator for the connection.  This is for
  3504.         use in a Kermit program that can run in either remote  or  local  mode;
  3505.         the  default  line  is the controlling terminal (for remote operation).
  3506.         If an external device is used, local operation is presumed.
  3507.  
  3508. LOG     Specify a local file in which to keep a log of the transaction.   There
  3509.         may  be logs for debugging purposes (packet traffic, state transitions,
  3510.         etc) and for auditing purposes (to record the name and  disposition  of
  3511.         each file transferred).
  3512.  
  3513. MARKER  Change  the  start-of-packet marker from the default of SOH (CTRL-A) to
  3514.         some other control character, in case one or both systems has  problems
  3515.         using CTRL-A for this purpose.
  3516.  
  3517. PACKET-LENGTH
  3518.         The maximum length for a packet.  This should normally be no less  than
  3519.         30  or  40, and can be greater than 94 only if the long-packet protocol
  3520.         extension is available, in which case it can be a much  larger  number,
  3521.         up  to  the maximum size allowed for the particular Kermit program (but
  3522.         never greater than 9024).  Short packets can be an advantage  on  noisy
  3523.         lines;  they  reduce  the  probabily  of a particular packet being cor-
  3524.         rupted, as well as the retransmission overhead when corruption does oc-
  3525.         cur.  Long packets boost performance on clean lines.
  3526.  
  3527. PADDING The  number  of  padding  characters  that  should  be sent before each
  3528.         packet, and what the padding character should be.  Rarely necessary.
  3529.  
  3530. PARITY  Specify the parity (ODD, EVEN, MARK, SPACE, NONE) of the physical  con-
  3531.         nection.   If other than none, the "8th bit" cannot be used to transmit
  3532.         data and must not be used by either side in block check computation.
  3533.  
  3534. PAUSE   How many seconds to pause after receiving a packet before  sending  the
  3535.         next  packet.  Normally 0, but when a system communication processor or
  3536.         front end has trouble keeping up with the traffic, a  short  pause  be-
  3537.         tween  packets  may  allow it to recover its wits; hopefully, something
  3538.         under a second will suffice.
  3539.  
  3540. PREFIX  Change the default prefix for control characters, 8-bit characters,  or
  3541.         repeated quantities.
  3542.  
  3543. PROMPT  Change  the  program's  prompt.  This is useful when running Kermit be-
  3544.         tween two systems whose prompt is  the  same,  to  eliminate  confusion
  3545.         about which Kermit you are talking to.
  3546.  
  3547. REPEAT-COUNT-PROCESSING
  3548.         Change the default for repeat count processing.  Normally, it  will  be
  3549.         done if both Kermit programs agree to do it.
  3550.  
  3551. RETRY   The  maximum number of times to attempt to send or receive a packet be-
  3552.         fore giving up.  The normal number is about 5, but the user  should  be
  3553.         able  to  adjust it according to the condition of the line, the load on
  3554.         the systems, etc.
  3555.  
  3556. TIMEOUT Specify the length of the timer to set when waiting for a packet to ar-
  3557.         rive.
  3558.  
  3559. WINDOW-SIZE
  3560.         Maximum number of unacknowledged packets outstanding, when the  sliding
  3561.         window option is available, usually between 4 and 31.
  3562.  
  3563.  
  3564. 8.7. Macros, the DEFINE Command
  3565.  
  3566. In  addition  to the individual set commands, a "macro" facility is recommended
  3567. to allow users to combine the characteristics of specific systems into a single
  3568. SET option.  For example:
  3569.  
  3570.     DEFINE IBM = PARITY ODD, DUPLEX HALF, HANDSHAKE XON
  3571.     DEFINE UNIX = PARITY NONE, DUPLEX FULL
  3572.     DEFINE TELENET = PARITY MARK
  3573.  
  3574. This  could  be done by providing a fancy runtime parser for commands like this
  3575. (which could be automatically TAKEn from the user's Kermit initialization  file
  3576. upon program startup), or simply hardwired into the SET command table.
  3577.  
  3578. With  these  definitions  in  place, the user would simply type "SET IBM", "SET
  3579. UNIX", and so forth, to set up the program to communication to the remote  sys-
  3580. tem.
  3581. 9. Kermit Programs
  3582.  
  3583.  
  3584. 9.1. Terminal emulation
  3585.  
  3586. The local system must be able to act as a terminal so that the user can connect
  3587. to the remote system, log in, and start up the remote Kermit.
  3588.  
  3589. Terminal emulation should be provided by any Kermit program that runs  locally,
  3590. so that the user need not exit and restart the local Kermit program in order to
  3591. switch between terminal and protocol operation.  On smaller  systems,  this  is
  3592. particularly important for various reasons -- restarting the program and typing
  3593. in all the necessary SET commands is too inconvenient  and  time-consuming;  in
  3594. some  micros,  switching  in and out of terminal emulation may cause carrier to
  3595. drop, etc.
  3596.  
  3597. Only bare-bones terminal emulation need be supplied by Kermit; there is no need
  3598. to  emulate  any  particular  kind of "smart" terminal.  Simple "dumb" terminal
  3599. emulation is sufficient to do the job.  Emulation of fancier terminals is  nice
  3600. to  have, however, to take advantage of the remote system's editing and display
  3601. capabilities.  In some cases, microcomputer firmware will take  care  of  this.
  3602. To build emulation for a particular type of terminal into the program, you must
  3603. interpret and act upon escape sequences as they arrive at the port.
  3604.  
  3605. No error checking is done during  terminal  emulation.    It  is  "outside  the
  3606. protocol"; characters go back and forth "bare".  In this sense, terminal emula-
  3607. tion through Kermit is no better than actually using a real terminal.
  3608.  
  3609. Some Kermit implementations may allow logging of the terminal emulation session
  3610. to  a  local  file.  Such a facility allows "capture" of remote typescripts and
  3611. files, again with no error checking or  correction.    When  this  facility  is
  3612. provided,  it is also desirable to have a convenient way of "toggling" the log-
  3613. ging on and off.
  3614.  
  3615. If the local system does not provide system- or  firmware-level  flow  control,
  3616. like  XON/XOFF,  the  terminal emulation program should attempt to simulate it,
  3617. especially if logging is being done.
  3618.  
  3619. The terminal emulation facility should be able to handle either remote or local
  3620. echoing (full or half duplex), any required handshake, and it should be able to
  3621. transmit any parity required by the remote side or the communication medium.
  3622.  
  3623. A terminal emulator works by continuously sampling both console input from  the
  3624. local  terminal and input from the communication line.  Simple input and output
  3625. functions will not suffice, however, since if you ask for input from a  certain
  3626. device  and  there is none available, you will generally block until input does
  3627. become available, during which time you will be missing input  from  the  other
  3628. device.    Thus  you  must  have  a  way to bounce back and forth regardless of
  3629. whether input is available.  Several mechanisms are commonly used:
  3630.  
  3631.    - Continuously jump back and forth between the port status register and
  3632.      the  console  status  register,  checking  the  status bits for input
  3633.      available.  This is only  practical  on  single-user,  single-process
  3634.      systems, where the CPU has nothing else to do.
  3635.  
  3636.    - Issue an ordinary blocking input request for the port, but enable in-
  3637.      terrupts on console input, or vice versa.
  3638.  
  3639.    - Handle port input in one process and console input in another, paral-
  3640.      lel process.  The UNIX Kermit program listed in this manual uses this
  3641.      method.
  3642.  
  3643. Any input at the port should be displayed immediately on the screen.  Any input
  3644. from the console should be output immediately to the port.  In addition, if the
  3645. connection is half duplex, console input should also be sent immediately to the
  3646. screen.
  3647.  
  3648. The  terminal  emulation  code must examine each console character to determine
  3649. whether it is the "escape character".  If so, it should take the next character
  3650. as  a  special command, which it executes.  These commands are described above,
  3651. in section 8.3.
  3652.  
  3653. The terminal emulator should be able to send every ASCII character, NUL through
  3654. DEL,  and  it  should  also  be able to transmit a BREAK signal (BREAK is not a
  3655. character, but an "escape" from ASCII transmission in which a 0 is put  on  the
  3656. line  for  about  a  quarter  of a second, regardless of the baud rate, with no
  3657. framing bits).  BREAK is important when  communicating  with  various  systems,
  3658. such as IBM mainframes.
  3659.  
  3660. Finally, it is sometimes necessary to perform certain transformations on the CR
  3661. character that is normally typed to end a line of input.  Some systems use  LF,
  3662. EOT, or other characters for this function.  To complicate matters, intervening
  3663. communications equipment (particularly the public packet-switched networks) may
  3664. have  their  own independent requirements.  Thus if using Kermit to communicate
  3665. over, say, TRANSPAC with a system that uses  LF  for  end-of-line,  it  may  be
  3666. necessary to transform CR into LFCR (linefeed first -- the CR tells the network
  3667. to send the packet, which will contain the LF, and the host  uses  the  LF  for
  3668. termination).  The user should be provided with a mechanism for specifying this
  3669. transformation, a command like "SET CR sequence".
  3670.  
  3671.  
  3672. 9.2. Writing a Kermit Program
  3673.  
  3674. Before writing a new implementation of Kermit or modifying an old one, first be
  3675. sure  to  contact the Kermit Distribution center at Columbia University to make
  3676. sure that you're not duplicating someone else's effort, and that you  have  all
  3677. the  latest material to work from.  If you do write or significantly modify (or
  3678. document) a Kermit program, please send it back to Columbia so that it  can  be
  3679. included  in  the  standard Kermit distribution and others can benifit from it.
  3680. It is only through this kind of sharing that Kermit has grown from  its  modest
  3681. beginnings to its present scale.
  3682.  
  3683. The following sections provide some hints on Kermit programming.
  3684.  
  3685.  
  3686. 9.2.1. Program Organization
  3687.  
  3688. A  basic  Kermit  implementation  can  usually be written as a relatively small
  3689. program, self-contained in a single source file.  However, it is often the case
  3690. that  a  program  written  to run on one system will be adapted to run on other
  3691. systems as well.  In that case, it is best to avoid  having  totally  divergent
  3692. sources,  because when new features are added to (or bugs fixed in) the system-
  3693. independent parts of the program -- i.e. to the protocol itself -- only one im-
  3694. plementation will reap the benefits initially, and the other will require pain-
  3695. ful, error-prone "retrofitting" to bring it up to the same level.
  3696.  
  3697. Thus, if there is any chance that a Kermit program will run on  more  than  one
  3698. machine, or under more than one operating system, or support more than one kind
  3699. of port or modem, etc, it is desirable to isolate the system-dependent parts in
  3700. a way that makes the common parts usable by the various implementations.  There
  3701. are several approaches:
  3702.  
  3703.    1. Runtime support.  If possible, the program can inspect the  hardware
  3704.       or  inquire  of  the system about relevant parameters, and configure
  3705.       itself dynamically at startup time.  This is hardly ever possible.
  3706.  
  3707.    2. Conditional compilation (or assembly).  If the number of systems  or
  3708.       options  to  be supported is small, the system dependent code can be
  3709.       enclosed in conditional compilation brackets (like IF IBMPC .... EN-
  3710.       DIF).  However, as the number of system dependencies to be supported
  3711.       grows, this method becomes unwieldy and  error-prone  --  installing
  3712.       support  for  system  X  tends to break the pre-existing support for
  3713.       system Y.
  3714.  
  3715.    3. Modular composition.  When there is a potentially  large  number  of
  3716.       options  a  program  should  support,  it  should  be broken up into
  3717.       separate modules (source  files),  with  clearly  specified,  simple
  3718.       calling conventions.  This allows people with new options to provide
  3719.       their own support for them in an easy way, without  endangering  any
  3720.       existing support.  Suggested modules for a Kermit program are:
  3721.  
  3722.    4.
  3723.  
  3724.          - System-Indendent  protocol  handling:  state  switching, packet
  3725.            formation, encoding (prefixing) and decoding, etc.
  3726.  
  3727.          - User Interface: the command parser.  Putting this in a separate
  3728.            module  allows  plug-in  of  command parsers to suit the user's
  3729.            taste, to mimic the style of the host system command parser  or
  3730.            some popular application, etc.
  3731.  
  3732.          - Screen i/o: This module would contain the screen control codes,
  3733.            cursor positioning routines, etc.
  3734.  
  3735.          - Port i/o: Allows support of various port hardware.  This module
  3736.            can  define the port status register location, the status bits,
  3737.            and so forth, and can implement the functions to read and write
  3738.            characters at the port.
  3739.  
  3740.          - Modem  control:  This  module would support any kind of "intel-
  3741.            ligent" modem, which is not simply a transparent  extension  of
  3742.            the  communications  port.  Such modems may accept special com-
  3743.            mands to perform functions like dialing out, redialing a recent
  3744.            number,  hanging  up, etc., and may need special initialization
  3745.            (for instance, setting modem signals like DTR).
  3746.  
  3747.          - Console input: This module would supply  the  function  to  get
  3748.            characters  from  the  console;  it would know about the status
  3749.            register  locations  and  bits,  interrupt  structure,  key-to-
  3750.            character   mappings,   etc.,  and  could  also  implement  key
  3751.            redefinitions, keystroke macros,  programmable  function  keys,
  3752.            expanded control and meta functions, etc.
  3753.  
  3754.          - Terminal  Emulation:  This  module  would  interpret escape se-
  3755.            quences in the incoming character  stream  (obtained  from  the
  3756.            port i/o module) for the particular type of terminal being emu-
  3757.            lated and interpret them by making appropriate  calls  the  the
  3758.            screen i/o module, and it would send user typein (obtained from
  3759.            the console input module) out the serial port (again using  the
  3760.            port  i/o module).  Ideally, this module could be replacable by
  3761.            other modules to emulate different  kinds  of  terminals  (e.g.
  3762.            ANSI, VT52, ADM3A, etc).
  3763.  
  3764.          - File i/o: This module contains all the knowledge about the host
  3765.            system's file structure; how to open and close  files,  perform
  3766.            "get next file" operations, read and write files, determine and
  3767.            set their attributes, detect the end of a file, and  so  forth,
  3768.            and  provides  the  functions,  including  buffering,  to get a
  3769.            character from a file and put a character  to  a  file.    This
  3770.            module  may  also  provide  file  management services for local
  3771.            files -- directory listings, deleting, renaming,  copying,  and
  3772.            so forth.
  3773.  
  3774.          - Definitions  and  Data: Separate modules might also be kept for
  3775.            compile-time parameter definitions and for global runtime data.
  3776. 9.2.2. Programming Language
  3777.  
  3778. The language to be used in writing a Kermit program is more than  a  matter  of
  3779. taste.    The  primary consideration is that the language provide the necessary
  3780. functionality and speed.  For instance, a microcomputer implementation of BASIC
  3781. may  not  allow  the  kind of low-level access to device registers needed to do
  3782. terminal emulation, or to detect console input during file transfer, or even if
  3783. it  can  do  these things, it might not be able to run fast enough do drive the
  3784. communication line at the desired baud rate.
  3785.  
  3786. The second consideration in choosing a language is portability.  This  is  used
  3787. in  two  senses:  (1)  whether the language is in the public domain (or, equiv-
  3788. alently, provided "free" as part of the basic system), and (2)  whether  it  is
  3789. well  standardized and in wide use on a variety of systems.  A language that is
  3790. portable in both senses is to be preferred.
  3791.  
  3792. Whatever programming language is selected, it is important that  all  lines  in
  3793. the  program source be kept to 80 characters or less (after expansion of tabs).
  3794. This is because Kermit material must often be shipped over RJE and other  card-
  3795. format communication links.
  3796.  
  3797. In  addition,  it is important that the names of all files used in creating and
  3798. supporting a particular Kermit implementation be (possibly  a  subset)  of  the
  3799. form NAME.TYPE, where NAME is limited to six characters, and TYPE is limited to
  3800. three, and where the NAME of each file begin with a common  2  or  3  character
  3801. prefix.    This is so that all related files will be grouped together in an al-
  3802. phabetic directory listing, and so when all of the hundreds of  Kermit  related
  3803. files  are  placed together on a tape, all names will be both legal and unique,
  3804. especially on systems (like PDP-11 operating  systems)  with  restrictive  file
  3805. naming conventions.
  3806.  
  3807.  
  3808. 9.2.3. Documentation
  3809.  
  3810. A  new  Kermit program should be thoroughly documented; one of the hallmarks of
  3811. Kermit is its documentation.  The documentation should  be  at  both  the  user
  3812. level  (how  to  use  the  program,  what the commands are, etc, similar to the
  3813. documentation presently found in the Kermit Users  Guide),  and  the  implemen-
  3814. tation  level  (describe system dependencies, give pointers for adapting to new
  3815. systems, and so forth).    In  addition,  programs  themselves  should  contain
  3816. copious  commentary.   Like program source, documentation should be kept within
  3817. 80-character lines.
  3818.  
  3819. If possible, a section for the implementation should be written for the  Kermit
  3820. User  Guide using the UNILOGIC Scribe formatting language (subsets of which are
  3821. also to be found in some microcomputer text processing software such as Perfect
  3822. Writer  or  Final  Word),  using  the  same general conventions as the existing
  3823. Scribe-format implementation sections.
  3824.  
  3825. Kermit programs should also contain a revision history, in which each change is
  3826. briefly  explained,  assigned an "edit number", and the programmer and site are
  3827. identified.  The lines or sections comprising the edit should  be  marked  with
  3828. the corresponding edit number, and the Kermit program, upon startup, should an-
  3829. nounce its version and edit numbers, so that when users complain of problems we
  3830. will know what version of the program is in question.
  3831.  
  3832. The version number changes when the functionality has been changed sufficiently
  3833. to require major revisions of user documentation.  The edit number  should  in-
  3834. crease  (monotonically,  irrespective  of  version number) whenever a change is
  3835. made to the program.  The edit numbers are very important for  program  manage-
  3836. ment;  after  shipping  out a version of, say, CP/M Kermit-80, we often receive
  3837. many copies of it, each containing its own set of changes, which we must recon-
  3838. cile in some manner.  Edit numbers help a great deal here.
  3839.  
  3840.  
  3841. 9.2.4. Bootstrapping
  3842.  
  3843. Finally,  a  bootstrap  procedure should be provided.  Kermit is generally dis-
  3844. tributed on magnetic tape to large central sites; the users at those sites need
  3845. ways of "downloading" the various implementations to their micros and other lo-
  3846. cal systems.  A simple bootstrap procedure would consist  of  precise  instruc-
  3847. tions  on  how  to accomplish an "unguarded" capture of the program.  Perhaps a
  3848. simple, short program can be written for each each end that will  do  the  job;
  3849. listings and instructions can be provided for the user to type in and run these
  3850. programs.
  3851. I. Packet Format and Types
  3852.  
  3853. Basic Kermit Packet Layout
  3854.  
  3855.  
  3856.        |<------Included in CHECK------>|
  3857.        |                               |
  3858. +------+-----+-----+------+------ - - -+-------+
  3859. | MARK | LEN | SEQ | TYPE | DATA       | CHECK |<terminator>
  3860. +------+-----+-----+------+------ - - -+-------+
  3861.              |                                 |
  3862.              |<--------LEN-32 characters------>|
  3863.  
  3864.  MARK   A real control character, usually CTRL-A.
  3865.   LEN   One character, length of remainder of packet + 32, max 95
  3866.   SEQ   One character, packet sequence number + 32, modulo 64
  3867.  TYPE   One character, an uppercase letter
  3868. CHECK   One, two, or three characters, as negotiated.
  3869.  
  3870. <terminator>  Any control character required for reading the packet.
  3871.  
  3872. Kermit Extended Packet Layout
  3873.  
  3874.        |<-------------------------Included in CHECK------------->|
  3875.        |                                                         |
  3876.        |<-------Included in HCHECK------->|                      |
  3877.        |                                  |                      |
  3878. +------+-----+-----+------+-------+-------+--------+----- - - - -+-------+
  3879. | MARK |     | SEQ | TYPE | LENX1 | LENX2 | HCHECK | DATA        | CHECK |
  3880. +------+-----+-----+------+-------+-------+--------+----- - - - -+-------+
  3881.         blank                                      |                     |
  3882.                                                    |<------------------->|
  3883.                     LX1=LENX1-32, LX2=LX2-32         95 x LX1 + LX2 chars
  3884.  
  3885. HCHECK is a single-character type 1 checksum
  3886.  
  3887. Initialization String
  3888.  
  3889.  1       2       3       4       5       6       7       8       9       10
  3890. +-------+-------+-------+-------+-------+-------+-------+-------+-------+- -
  3891. | MAXL  | TIME  | NPAD  | PADC  | EOL   | QCTL  | QBIN  | CHKT  | REPT  |
  3892. +-------+-------+-------+-------+-------+-------+-------+-------+-------+- -
  3893.  
  3894.      10              CAPAS+1  CAPAS+2  CAPAS+3
  3895. - --+-------+-     -+--------+--------+--------+- -
  3896.     | CAPAS    ... 0| WINDO  | MAXLX1 | MAXLX1 |
  3897. - --+-------+-     -+--------+--------+--------+- -
  3898.  
  3899. MAXL    Maximum length (0-94) +32
  3900. TIME    Timeout, seconds (0-94) +32
  3901. NPAD    Number of pad characters (0-94) +32
  3902. EOL     Packet terminator (0-63) +32
  3903. QCTL    Control prefix, literal
  3904. QBIN    8th bit prefix, literal
  3905. CHKT    Block check type {1,2,3}, literal
  3906. REPT    Repeat count prefix, literal
  3907. CAPAS   Extendable capabilities mask, ends when value-32 is even
  3908. WINDO   Window size (0-31) +32
  3909. MAXLX1  High part of extended packet maximum length (int(max/95)+32)
  3910. MAXLX2  Low part of extended packet maximum length (mod(max,95)+32)
  3911.  
  3912. Packet Types
  3913.  
  3914. Y   Acknowledgment (ACK).  Data according to what kind of packet is  being  ac-
  3915.     knowledged.
  3916. N   Negative Acknowledgment (NAK).  Data field always empty.
  3917. S   Send  Initiation.    Data  field  contains unencoded initialization string.
  3918.     Tells receiver to expect files.  ACK to this packet also contains unencoded
  3919.     initialization string.
  3920. I   Initialize.   Data field contains unencoded initialization string.  Sent to
  3921.     server to set parameters prior to a command.  ACK to this packet also  con-
  3922.     tains unencoded initialization string.
  3923. F   File  Header.    Indicates  file data about to arrive for named file.  Data
  3924.     field contains encoded file name.  ACK to this packet may  contain  encoded
  3925.     name receiver will store file under.
  3926. X   Text  Header.   Indicates screen data about to arrive.  Data field contains
  3927.     encoded heading for display.
  3928. A   File Attributes.  Data field contains unencoded attributes.  ACK  may  con-
  3929.     tain unencoded corresponding agreement or refusal, per attribute.
  3930. D   Data  Packet.    Data  field contains encoded file or screen data.  ACK may
  3931.     contain X to interrupt sending this file,  Z  to  interrupt  entire  trans-
  3932.     action.
  3933. Z   End of file.  Data field may contain D for Discard.
  3934. B   Break transmission.
  3935. E   Error.  Data field contains encoded error message.
  3936. R   Receive Initiate.  Data field contains encoded file name.
  3937. C   Host  Command.    Data  field  contains  encoded command for host's command
  3938.     processor.
  3939. K   Kermit Command.  Data field contains encoded  command  for  Kermit  command
  3940.     processor.
  3941. T   Timeout psuedopacket, for internal use.
  3942. Q   Block check error psuedopacket, for internal use.
  3943. G   Generic Kermit Command.  Data field contains a single character subcommand,
  3944.     followed by zero or more length-encoded operands, encoded after formation:
  3945.  
  3946.     I   Login [<%user[%password[%account]]>]
  3947.     C   CWD, Change Working Directory [<%directory[%password]>]
  3948.     L   Logout, Bye
  3949.     F   Finish (Shut down the server, but don't logout).
  3950.     D   Directory [<%filespec>]
  3951.     U   Disk Usage Query [<%area>]
  3952.     E   Erase (delete) <%filespec>
  3953.     T   Type <%filespec>
  3954.     R   Rename <%oldname%newname>
  3955.     K   Copy <%source%destination>
  3956.     W   Who's logged in? [<%user ID or network host[%options]>]
  3957.     M   Send a short Message <%destination%text>
  3958.     H   Help [<%topic>]
  3959.     Q   Server Status Query
  3960.     P   Program <%[program-filespec][%program-commands]>
  3961.     J   Journal <%command[%argument]>
  3962.     V   Variable <%command[%argument[%argument]]>
  3963. II. List of Features
  3964.  
  3965. There's no true linear scale along which to rate  Kermit  implementations.    A
  3966. basic,  minimal  implementation provides file transfer in both directions, and,
  3967. for microcomputers (PC's, workstations, other single  user  systems),  terminal
  3968. emulation.  Even within this framework, there can be variations.  For instance,
  3969. can the program send a file group in a single command, or  must  a  command  be
  3970. issued for each file?  Can it time out?  Here is a list of features that may be
  3971. present; for any Kermit implementation, the documentation should  show  whether
  3972. these features exist, and how to invoke them.
  3973.  
  3974.    - File  groups.    Can  it send a group of files with a single command,
  3975.      using "wildcard", pattern, or list notation?    Can  it  successfully
  3976.      send or receive a group of files of mixed types?  Can it recover from
  3977.      an error on a particular file and go on to the next one?  Can it keep
  3978.      a log of the files involved showing the disposition of each?
  3979.  
  3980.    - Filenames.  Can it take action to avoid overwriting a local file when
  3981.      a new file of the same name arrives?  Can it convert filenames to and
  3982.      from legal or "normal form"?
  3983.  
  3984.    - File types.  Can binary as well as text files be transmitted?
  3985.  
  3986.    - 8th-Bit  prefixing.    Can  it  send and receive 8-bit data through a
  3987.      7-bit channel using the prefixing mechanism?
  3988.  
  3989.    - Repeat-Count processing.  Can it send and receive data with  repeated
  3990.      characters replaced by a prefix sequence?
  3991.  
  3992.    - Terminal  Emulation.    Does  it  have a terminal emulation facility?
  3993.      Does it emulate a particular terminal?  To  what  extent?    Does  it
  3994.      provide  various  communication  options, such as duplex, parity, and
  3995.      handshake selection?  Can it transmit all ASCII characters?   Can  it
  3996.      transmit BREAK?  Can it log the remote session locally?
  3997.  
  3998.    - Communications Options.  Can duplex, parity, handshake, and line ter-
  3999.      minator be specified for file transfer?
  4000.  
  4001.    - Block Check Options.   In  addition  to  the  basic  single-character
  4002.      checksum,  can the two-character checksum and the three-character CRC
  4003.      be selected?
  4004.  
  4005.    - Basic Server.  Can it run in server mode, accepting commands to  send
  4006.      or receive files, and to shut itself down?
  4007.  
  4008.    - Advanced  Server.    Can  it  accept server commands to delete files,
  4009.      provide directory listings, send messages, and forth?
  4010.  
  4011.    - Issue Commands to Server.  Can it send  commands  to  a  server,  and
  4012.      handle all possible responses?
  4013.  
  4014.    - Host  Commands.  Can it parse and send remote "host commands"?  If it
  4015.      is a server, can it pass these commands to the  host  system  command
  4016.      processor and return the results to the local user Kermit?
  4017.  
  4018.    - Interrupt  File  Transfers.   Can it interrupt sending or receiving a
  4019.      file?  Can it respond to interrupt requests from the other side?
  4020.  
  4021.    - Local File Management Services.  Are  there  commands  to  get  local
  4022.      directory listings, delete local files, and so forth?
  4023.  
  4024.    - File  Attributes.  Can it send file attribute information about local
  4025.      files, and can deal with incoming file attribute  information?    Can
  4026.      alternate dispositions be specified.  Can files be archived?
  4027.  
  4028.    - Long Packets.  Is the long packet protocol extension implemented?
  4029.  
  4030.    - Sliding  Windows.    Is  the  sliding  window  protocol extension im-
  4031.      plemented?
  4032.  
  4033.    - Debugging Capability.    Can  packet  traffic  be  logged,  examined,
  4034.      single-stepped?
  4035.  
  4036.    - Frills.    Does  it have login scripts?  Raw download/upload?  A DIAL
  4037.      command and modem control?  Phone directories?
  4038. III. The ASCII Character Set
  4039.  
  4040. ASCII Code (ANSI X3.4-1968)
  4041.  
  4042. There are 128 characters in the ASCII (American national Standard Code for  In-
  4043. formation Interchange) "alphabet".  The characters are listed in order of ASCII
  4044. value; the columns are labeled as follows:
  4045.  
  4046. Bit             Even parity bit for ASCII character.
  4047. ASCII Dec       Decimal (base 10) representation.
  4048. ASCII Oct       Octal (base 8) representation.
  4049. ASCII Hex       Hexadecimal (base 16) representation.
  4050. EBCDIC Hex      EBCDIC hexadecimal equivalent for Kermit translate tables.
  4051. Char            Name or graphical representation of character.
  4052. Remark          Description of character.
  4053.  
  4054. The first group consists of nonprintable 'control' characters:
  4055.  
  4056.      .....ASCII.... EBCDIC
  4057. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4058.  0   000   000   00   00    NUL   ^@, Null, Idle
  4059.  1   001   001   01   01    SOH   ^A, Start of heading
  4060.  1   002   002   02   02    STX   ^B, Start of text
  4061.  0   003   003   03   03    ETX   ^C, End of text
  4062.  1   004   004   04   37    EOT   ^D, End of transmission
  4063.  0   005   005   05   2D    ENQ   ^E, Enquiry
  4064.  0   006   006   06   2E    ACK   ^F, Acknowledge
  4065.  1   007   007   07   2F    BEL   ^G, Bell, beep, or fleep
  4066.  1   008   010   08   16    BS    ^H, Backspace
  4067.  0   009   011   09   05    HT    ^I, Horizontal tab
  4068.  0   010   012   0A   25    LF    ^J, Line feed
  4069.  1   011   013   0B   0B    VT    ^K, Vertical tab
  4070.  0   012   014   0C   0C    FF    ^L, Form feed (top of page)
  4071.  1   013   015   0D   0D    CR    ^M, Carriage return
  4072.  1   014   016   0E   0E    SO    ^N, Shift out
  4073.  0   015   017   0F   0F    SI    ^O, Shift in
  4074.  1   016   020   10   10    DLE   ^P, Data link escape
  4075.  0   017   021   11   11    DC1   ^Q, Device control 1, XON
  4076.  0   018   022   12   12    DC2   ^R, Device control 2
  4077.  1   019   023   13   13    DC3   ^S, Device control 3, XOFF
  4078.  0   020   024   14   3C    DC4   ^T, Device control 4
  4079.  1   021   025   15   3D    NAK   ^U, Negative acknowledge
  4080.  1   022   026   16   32    SYN   ^V, Synchronous idle
  4081.  0   023   027   17   26    ETB   ^W, End of transmission block
  4082.  0   024   030   18   18    CAN   ^X, Cancel
  4083.  1   025   031   19   19    EM    ^Y, End of medium
  4084.  1   026   032   1A   3F    SUB   ^Z, Substitute
  4085.  0   027   033   1B   27    ESC   ^[, Escape, prefix, altmode
  4086.  1   028   034   1C   1C    FS    ^\, File separator
  4087.  0   029   035   1D   1D    GS    ^], Group separator
  4088.  0   030   036   1E   1E    RS    ^^, Record separator
  4089.  1   031   037   1F   1F    US    ^_, Unit separator
  4090. The last four are usually associated with the  control  version  of  backslash,
  4091. right  square  bracket,  uparrow (or circumflex), and underscore, respectively,
  4092. but some terminals do not transmit these control characters.
  4093. The following characters are printable:
  4094. First, some punctuation characters.
  4095.  
  4096.      .....ASCII.... EBCDIC
  4097. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4098.  1   032   040   20   40    SP    Space, blank
  4099.  0   033   041   21   5A    !     Exclamation mark
  4100.  0   034   042   22   7F    "     Doublequote
  4101.  1   035   043   23   7B    #     Number sign, pound sign
  4102.  0   036   044   24   5B    $     Dollar sign
  4103.  1   037   045   25   6C    %     Percent sign
  4104.  1   038   046   26   50    &     Ampersand
  4105.  0   039   047   27   7D    '     Apostrophe, accent acute
  4106.  0   040   050   28   4D    (     Left parenthesis
  4107.  1   041   051   29   5D    )     Right parenthesis
  4108.  1   042   052   2A   5C    *     Asterisk, star
  4109.  0   043   053   2B   4E    +     Plus sign
  4110.  1   044   054   2C   6B    ,     Comma
  4111.  0   045   055   2D   60    -     Dash, hyphen, minus sign
  4112.  0   046   056   2E   4B    .     Period, dot
  4113.  1   047   057   2F   61    /     Slash
  4114. Numeric characters:
  4115.  
  4116.      .....ASCII.... EBCDIC
  4117. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4118.  0   048   060   30   F0    0     Zero
  4119.  1   049   061   31   F1    1     One
  4120.  1   050   062   32   F2    2     Two
  4121.  0   051   063   33   F3    3     Three
  4122.  1   052   064   34   F4    4     Four
  4123.  0   053   065   35   F5    5     Five
  4124.  0   054   066   36   F6    6     Six
  4125.  1   055   067   37   F7    7     Seven
  4126.  1   056   070   38   F8    8     Eight
  4127.  0   057   071   39   F9    9     Nine
  4128. More punctuation characters:
  4129.  
  4130.      .....ASCII.... EBCDIC
  4131. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4132.  0   058   072   3A   7A    :     Colon
  4133.  1   059   073   3B   5E    ;     Semicolon
  4134.  0   060   074   3C   4C    <     Left angle bracket
  4135.  1   061   075   3D   7E    =     Equal sign
  4136.  1   062   076   3E   6E    >     Right angle bracket
  4137.  0   063   077   3F   6F    ?     Question mark
  4138.  1   064   100   40   7C    @     "At" sign
  4139. Upper-case alphabetic characters (letters):
  4140.  
  4141.      .....ASCII.... EBCDIC
  4142. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4143.  0   065   101   41   C1    A
  4144.  0   066   102   42   C2    B
  4145.  1   067   103   43   C3    C
  4146.  0   068   104   44   C4    D
  4147.  1   069   105   45   C5    E
  4148.  1   070   106   46   C6    F
  4149.  0   071   107   47   C7    G
  4150.  0   072   110   48   C8    H
  4151.  1   073   111   49   C9    I
  4152.  1   074   112   4A   D1    J
  4153.  0   075   113   4B   D2    K
  4154.  1   076   114   4C   D3    L
  4155.  0   077   115   4D   D4    M
  4156.  0   078   116   4E   D5    N
  4157.  1   079   117   4F   D6    O
  4158.  0   080   120   50   D7    P
  4159.  1   081   121   51   D8    Q
  4160.  1   082   122   52   D9    R
  4161.  0   083   123   53   E2    S
  4162.  1   084   124   54   E3    T
  4163.  0   085   125   55   E4    U
  4164.  0   086   126   56   E5    V
  4165.  1   087   127   57   E6    W
  4166.  1   088   130   58   E7    X
  4167.  0   089   131   59   E8    Y
  4168.  0   090   132   5A   E9    Z
  4169. More punctuation characters:
  4170.  
  4171.      .....ASCII.... EBCDIC
  4172. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4173.  1   091   133   5B   AD    [     Left square bracket
  4174.  0   092   134   5C   E0    \     Backslash
  4175.  1   093   135   5D   BD    ]     Right square bracket
  4176.  1   094   136   5E   5F    ^     Circumflex, up arrow
  4177.  0   095   137   5F   6D    _     Underscore, left arrow
  4178.  0   096   140   60   79    `     Accent grave
  4179. Lower-case alphabetic characters (letters):
  4180.  
  4181.      .....ASCII.... EBCDIC
  4182. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4183.  1   097   141   61   81    a
  4184.  1   098   142   62   82    b
  4185.  0   099   143   63   83    c
  4186.  1   100   144   64   84    d
  4187.  0   101   145   65   85    e
  4188.  0   102   146   66   86    f
  4189.  1   103   147   67   87    g
  4190.  1   104   150   68   88    h
  4191.  0   105   151   69   89    i
  4192.  0   106   152   6A   91    j
  4193.  1   107   153   6B   92    k
  4194.  0   108   154   6C   93    l
  4195.  1   109   155   6D   94    m
  4196.  1   110   156   6E   95    n
  4197.  0   111   157   6F   96    o
  4198.  1   112   160   70   97    p
  4199.  0   113   161   71   98    q
  4200.  0   114   162   72   99    r
  4201.  1   115   163   73   A2    s
  4202.  0   116   164   74   A3    t
  4203.  1   117   165   75   A4    u
  4204.  1   118   166   76   A5    v
  4205.  0   119   167   77   A6    w
  4206.  0   120   170   78   A7    x
  4207.  1   121   171   79   A8    y
  4208.  1   122   172   7A   A9    z
  4209. More punctuation characters:
  4210.  
  4211.      .....ASCII.... EBCDIC
  4212. Bit  Dec   Oct  Hex  Hex    Char  Remarks
  4213.  0   123   173   7B   C0     {    Left brace (curly bracket)
  4214.  1   124   174   7C   4F     |    Vertical bar
  4215.  0   125   175   7D   D0     }    Right brace (curly bracket)
  4216.  0   126   176   7E   A1     ~    Tilde
  4217.  
  4218. Finally, one more nonprintable character:
  4219.  
  4220.  0    127   177  7F   07    DEL   Delete, rubout
  4221.