home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / misc / bytedoc.txt < prev    next >
Text File  |  2020-01-01  |  93KB  |  2,911 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                       1
  8.                                 KERMIT 
  9.  
  10.    A SIMPLE FILE TRANSFER PROTOCOL FOR MICROCOMPUTERS AND MAINFRAMES
  11.  
  12.  
  13.  
  14.  
  15.                      Frank da Cruz,  Bill Catchings
  16.  
  17.           Columbia University Center for Computing Activities
  18.                          New York, N.Y.  10027
  19.                                 May 1983
  20.  
  21.  
  22.  
  23.  
  24.  
  25.   During  recent  years, the technical press has focused a lot of atten-
  26.  
  27. tion on developments in computer networking -- the IEEE  802  committee,
  28.  
  29. TCP/IP, SNA, the latest VLSI Ethernet interface, fibre optics, satellite
  30.  
  31. communications,  broadband  versus  baseband.   But little attention has
  32.  
  33. been given to the single mechanism that may be the most widely  used  in
  34.  
  35. the  real  world  for direct interprocessor communication: the so-called
  36.  
  37. ``asynchronous protocol'', which is to be found in some form  at  almost
  38.  
  39. every  institution  where  there  is  a  need  to transfer files between
  40.  
  41. microcomputers and central computers.
  42.  
  43.   Columbia University is such an institution.   Large  timesharing  com-
  44.  
  45. _______________
  46.  
  47.   1
  48.    This  is  the  original  manuscript  of the article published in BYTE
  49. Magazine as "Kermit: A File Transfer Protocol  for  Universities",  June
  50. and  July  1984.    Some  minor editorial differences exist between this
  51. manuscript and the article as  published.    The  Kermit  file  transfer
  52. protocol  is  named after Kermit the Frog, star of the television series
  53. THE MUPPET SHOW, used by permission of Henson Associates, Inc.
  54.                                    2
  55.  
  56.  
  57.  
  58.  
  59.  
  60. puters  at a central site are complemented by many smaller systems scat-
  61.  
  62. tered in the laboratories and departments.  The past few years have wit-
  63.  
  64. nessed the inexorable progress of diverse microcomputers,  word  proces-
  65.  
  66. sors, and professional workstations into offices and laboratories throu-
  67.  
  68. ghout  the University, and into the homes or dormitory rooms of faculty,
  69.  
  70. students, and staff.  As soon as these small machines began  to  appear,
  71.  
  72. their  users  asked  for  ways  to  exchange  files with the central and
  73.  
  74. departmental systems.
  75.  
  76.   At the same time, student use of our central systems was growing at an
  77.  
  78. astonishing rate.  We could no longer afford to  provide  students  with
  79.  
  80. perpetual  online  disk  storage;  we began to issue IDs per course, per
  81.  
  82. term.  With the decreased longevity of the IDs came the  need  for  stu-
  83.  
  84. dents to economically archive their files.  Given a reliable way to from
  85.  
  86. the  central mainframes and back, microcomputers with floppy disks could
  87.  
  88. provide inexpensive removable media ideal for this purpose.
  89.  
  90.   The situation called for a file transfer  mechanism  that  could  work
  91.  
  92. among  all  our  computers, large and small.  We knew of none that could
  93.  
  94. handle the required diversity.   Some  were  intended  for  use  between
  95.  
  96. microcomputers,  others  between  large computers, but none specifically
  97.  
  98. addressed the need for communication among the widest possible range  of
  99.  
  100. computers,  particularly  between micros and our IBM and DEC mainframes.
  101.  
  102. Most commercial packages served a limited set of systems, and their cost
  103.  
  104. would have been prohibitive when  multiplied  by  the  large  number  of
  105.  
  106. machines we needed to support.
  107.                                    3
  108.  
  109.  
  110.  
  111.  
  112.  
  113.   So  we  embarked on our own project.  We were not well-versed in these
  114.  
  115. matters at the outset; we learned  as  we  proceeded,  and  we're  still
  116.  
  117. learning.   This article discusses some of the issues and tradeoffs that
  118.  
  119. came up in the design, and illustrates them in terms of our result,  the
  120.  
  121. KERMIT  protocol for point-to-point file transfer over telecommunication
  122.  
  123. lines.  Because commercial local area networking products are expensive,
  124.  
  125. not yet widely available, and unsuitable for one-shot or  long-haul  ap-
  126.  
  127. plications,  humble  asynchronous protocols such as KERMIT are likely to
  128.  
  129. be with us for a long time to come.
  130.  
  131.   It is assumed  the  reader  is  familiar  with  common  computing  and
  132.  
  133. telecommunications  terminology,  and  with the ASCII alphabet, which is
  134.  
  135. listed at the end of this article for reference.
  136.  
  137.  
  138.  
  139.  
  140. * The Communication Medium
  141.  
  142.  
  143.   The only communication medium  common  to  all  computers,  large  and
  144.  
  145. small,  is the asynchronous serial telecommunication line, used for con-
  146.  
  147. necting terminals to computers.  Standards for this  medium  are  almost
  148.  
  149. universally  followed -- connectors, voltages, and signals (EIA RS-232-C
  150.  
  151. [1]), character encoding (ASCII, ANSI X3.4-1977 [2]),  and bit transmis-
  152.  
  153. sion sequence (ANSI X3.15-1976 [3, 4]).  Serial connections can be  made
  154.  
  155. in  many  ways:  dedicated  local  lines (``null modem'' cables), leased
  156.  
  157. telephone circuits, dialup connections.  Dialup connections can  be  in-
  158.  
  159. itiated  manually  from the home or office using an inexpensive acoustic
  160.                                    4
  161.  
  162.  
  163.  
  164.  
  165.  
  166. coupler, or automatically from one computer to another using a programm-
  167.  
  168. able  dialout  mechanism.    The asynchronous serial line offers the or-
  169.  
  170. dinary user a high degree of convenience and control in establishing in-
  171.  
  172. tersystem connections, at relatively low cost.
  173.  
  174.   Once two computers are connected with a serial line,  information  can
  175.  
  176. be  transferred  from one machine to the other, provided one side can be
  177.  
  178. instructed to send the information and the other to  receive  it.    But
  179.  
  180. right away, several important factors come into play:
  181.  
  182.  
  183.    1. Noise  --  It  is rarely safe to assume that there will be no
  184.       electrical interference on a line; any long or switched  data
  185.       communication  line  will  have  occasional  interference, or
  186.       noise, which typically results in garbled  or  extra  charac-
  187.       ters.  Noise corrupts data, perhaps in subtle ways that might
  188.       not be noticed until it's too late.
  189.  
  190.    2. Synchronization  --  Data  must  not  come in faster than the
  191.       receiving machine can handle it.  Although line speeds at the
  192.       two ends of the connection may match, the  receiving  machine
  193.       might not be able to process a steady stream of input at that
  194.       speed.   Its central processor may be too slow or too heavily
  195.       loaded, or its buffers too full or too small.    The  typical
  196.       symptom  of  a  synchronization  problem  is  lost data; most
  197.       operating systems will simply discard incoming data they  are
  198.       not prepared to receive.
  199.  
  200.    3. Line Outages -- A line may stop working for short periods be-
  201.       cause  of  a  faulty  connector,  loss  of  power, or similar
  202.       reason.  On dialup or switched connections, such intermittent
  203.       failures will cause carrier to drop and the connection to  be
  204.       closed, but for any connection in which the carrier signal is
  205.       not used, the symptom will be lost data.
  206.  
  207.  
  208. Other   communication  media,  such  as  the  parallel  data  bus,  have
  209.  
  210. safeguards built in to prevent or minimize these effects.  For instance,
  211.  
  212. distances may be strictly limited, the environment  controlled;  special
  213.                                    5
  214.  
  215.  
  216.  
  217.  
  218.  
  219. signals  may be available for synchronization, and so forth.  The serial
  220.  
  221. telecommunication line provides no such safeguards, and we  must  there-
  222.  
  223. fore regard it as an intrinsically unreliable medium.
  224.  
  225.  
  226.  
  227.  
  228. * Getting Reliable Communication over an Unreliable Medium
  229.  
  230.  
  231.   To  determine  whether  data has been transmitted between two machines
  232.  
  233. correctly and completely, the two machines can compare the  data  before
  234.  
  235. and  after transmission.  A scheme that is commonly used for file trans-
  236.  
  237. fer employs cooperating programs running simultaneously on each machine,
  238.  
  239. communicating in a well-defined, concise language.  The sending  program
  240.  
  241. divides outbound data into discrete pieces, adding to each piece special
  242.  
  243. information  describing  the data for the receiving program.  The result
  244.  
  245. is called a ``packet''.  The receiver separates the description from the
  246.  
  247. data and determines whether they still match.  If so, the packet is ack-
  248.  
  249. nowledged and the transfer proceeds.  If not, the packet is ``negatively
  250.  
  251. acknowledged'' and the sender retransmits it; this procedure repeats for
  252.  
  253. each packet until it is received correctly.
  254.  
  255.   The process is called a communication protocol -- a set of  rules  for
  256.  
  257. forming  and  transmitting  packets, carried out by programs that embody
  258.  
  259. those rules.  Protocols vary in complexity; our  preference  was  for  a
  260.  
  261. simple  approach that could be realized in almost any language on almost
  262.  
  263. any computer by a programmer of moderate skill, allowing the protocol to
  264.  
  265. be adapted easily to new systems.
  266.                                    6
  267.  
  268.  
  269.  
  270.  
  271.  
  272. * Accommodating Diverse Systems
  273.  
  274.  
  275.   Most  systems agree how to communicate at the lowest levels -- the EIA
  276.  
  277. RS-232-C asynchronous communication line and  the  ASCII  character  set
  278.  
  279. --  but  there  is rarely agreement beyond that.  To avoid a design that
  280.  
  281. might lock out some kinds of systems, we must consider certain important
  282.  
  283. ways in which systems can differ.
  284.  
  285.  
  286.  
  287. . Mainframes vs Micros
  288.  
  289.  
  290.   A distinction must first be made between micros and mainframes.  These
  291.  
  292. terms are not used  perjoratively;  a  ``micro''  could  be  a  powerful
  293.  
  294. workstation, and a ``mainframe'' could be a small minicomputer.  For our
  295.  
  296. purposes,  a  micro  is  any single-user system in which the serial com-
  297.  
  298. munication port is strictly an external device.  A mainframe is any sys-
  299.  
  300. tem which is ``host'' to multiple simultaneous terminal users,  who  log
  301.  
  302. in  to  ``jobs'', and where a user's terminal is the job's ``controlling
  303.  
  304. terminal''.  Some mainframe systems allow users  to  ``assign''  another
  305.  
  306. terminal line on the same machine as an external input/output device.
  307.  
  308.   Mainframe operating system terminal drivers usually treat a job's con-
  309.  
  310. trolling  terminal specially.  Full duplex systems echo incoming charac-
  311.  
  312. ters on the controlling terminal, but not on an assigned line.    System
  313.  
  314. command interpreters or user processes might take special action on cer-
  315.  
  316. tain  characters  on  the  controlling line, but not on an assigned line
  317.  
  318. (for instance, control-C under CP/M  or  most  DEC  operating  systems).
  319.                                    7
  320.  
  321.  
  322.  
  323.  
  324.  
  325. Messages  sent to a job's controlling terminal from other jobs could in-
  326.  
  327. terfere with transmission of data.  The ability of a system to test  for
  328.  
  329. the  availability  of input on a serial line might depend on whether the
  330.  
  331. line is the job's controlling terminal or an assigned device;  CP/M  and
  332.  
  333. IBM VM/370 are examples of such systems.  CP/M can test for data only at
  334.  
  335. the console, VM can test anywhere but the console.
  336.  
  337.   Output  to  a  job's  controlling  terminal  may be reformatted by the
  338.  
  339. operating system: control characters  may  be  translated  to  printable
  340.  
  341. equivalents, lower case letters specially flagged or translated to upper
  342.  
  343. case  (or  vice  versa), tabs expanded to spaces.  In addition, based on
  344.  
  345. the terminal's declared ``width'' and ``length'', long  lines  might  be
  346.  
  347. ``wrapped  around''  or  truncated,  formfeeds translated to a series of
  348.  
  349. linefeeds, and the system may want to pause at the end of each screenful
  350.  
  351. of output.  Input from a job's controlling terminal may also be  handled
  352.  
  353. specially:  lower  case letters may be converted to upper case, linefeed
  354.  
  355. may be supplied when carriage return is typed,  control  characters  may
  356.  
  357. invoke special functions like line editing or program interruption.  The
  358.  
  359. DECSYSTEM-20  is  an example of a computer where any of these might hap-
  360.  
  361. pen.
  362.  
  363.   The moral here is that care must be taken to disable special  handling
  364.  
  365. of a mainframe job's controlling terminal when it is to be a vehicle for
  366.  
  367. interprocessor communication.  But some systems simply do not allow cer-
  368.  
  369. tain  of  these features to be disabled, so file transfer protocols must
  370.  
  371. be designed around them.
  372.                                    8
  373.  
  374.  
  375.  
  376.  
  377.  
  378. . Line Access
  379.  
  380.  
  381.   Line access can be either full or half duplex.  If full duplex, trans-
  382.  
  383. mission  can  occur in both directions at once.  If half duplex, the two
  384.  
  385. sides must take turns sending, each signaling the other when the line is
  386.  
  387. free; data sent out of turn is discarded, or it can  cause  a  break  in
  388.  
  389. synchronization.  On mainframes, the host echoes characters typed at the
  390.  
  391. terminal  in full duplex, but not in half duplex.  Naturally, echoing is
  392.  
  393. undesirable during file transfer.  Full duplex systems can  usually  ac-
  394.  
  395. commodate half duplex communication, but not vice versa.  IBM mainframes
  396.  
  397. are the most prevalent half duplex systems.
  398.  
  399.  
  400.  
  401. . Buffering and Flow Control
  402.  
  403.  
  404.   Some  systems  cannot  handle  sustained bursts of input on a telecom-
  405.  
  406. munications line; the input buffer can fill up faster  than  it  can  be
  407.  
  408. emptied, especially at high line speeds.  Some systems attempt to buffer
  409.  
  410. ``typeahead''  (unrequested input), while others discard it.  Those that
  411.  
  412. buffer typeahead may or may not provide a mechanism to test or clear the
  413.  
  414. buffer.
  415.  
  416.   Systems may try to regulate how fast characters come in using  a  flow
  417.  
  418. control  mechanism,  either in the data stream (XON/XOFF) or in parallel
  419.  
  420. to it (modem control signals) [5], but no two systems can be assumed  to
  421.  
  422. honor  the  same conventions for flow control, or to do it at all.  Even
  423.  
  424. when flow control is being done, the control signals themselves are sub-
  425.                                    9
  426.  
  427.  
  428.  
  429.  
  430.  
  431. ject to noise corruption.
  432.  
  433.   Our  experiments  with several host computers revealed that a burst of
  434.  
  435. more than about a line's worth of characters (60-100 characters) into  a
  436.  
  437. terminal port at moderate speed could result in loss of data -- or worse
  438.  
  439. --  on  some  hosts.   For instance, the communications front end of the
  440.  
  441. DECSYSTEM-2060 is designed on the statistical assumption that  all  ter-
  442.  
  443. minal  input  comes  from  human fingers, and it cannot allocate buffers
  444.  
  445. fast enough when this assumption is violated by sending continuous  data
  446.  
  447. simultaneously from several microcomputers attached to terminal ports.
  448.  
  449.  
  450.  
  451. . Character Interpretation
  452.  
  453.  
  454.   Systems can differ in how they interpret characters that arrive at the
  455.  
  456. terminal  port.    A  host  can  accept  some characters as sent, ignore
  457.  
  458. others, translate others, take special action on others.  Communications
  459.  
  460. front ends or multiplexers might swallow certain  characters  (typically
  461.  
  462. DC1,  DC3)  for  flow  control, padding (NUL or DEL), or for transfer of
  463.  
  464. control (``escape'').  The characters that typically trigger special be-
  465.  
  466. havior are the ASCII control characters, 0-31 and 127.  For instance, of
  467.  
  468. these  33  control  characters,  17  invoke  special  functions  of  our
  469.  
  470. DECSYSTEM-20  command  processor.   However, all hosts and communication
  471.  
  472. processors we've encountered allow any  ``printable''  character  (ASCII
  473.  
  474. 32-126)  to  reach an application program, even though the character may
  475.  
  476. be translated to a different encoding,  like  EBCDIC [6],  for  internal
  477.                                    10
  478.  
  479.  
  480.  
  481.  
  482.  
  483. use.
  484.  
  485.   Some  operating systems allow an application to input a character at a
  486.  
  487. time, others delay  passing  the  characters  to  the  program  until  a
  488.  
  489. ``logical  record''  has been detected, usually a sequence of characters
  490.  
  491. terminated by carriage return or linefeed.  Some record oriented systems
  492.  
  493. like IBM VM/370 discard the terminator, others keep it.  And  there  are
  494.  
  495. different  ways  of  keeping  it -- UNIX translates carriage return into
  496.  
  497. linefeed; most DEC operating systems keep the carriage return  but  also
  498.  
  499. add a linefeed.
  500.  
  501.  
  502.  
  503. . Timing Out
  504.  
  505.  
  506.   Hosts  may or may not have the ability to ``time out''.  When exchang-
  507.  
  508. ing messages with another computer, it is desirable to be able to  issue
  509.  
  510. an  input  request  without  waiting forever should the incoming data be
  511.  
  512. lost.  A lost message could result in a protocol ``deadlock''  in  which
  513.  
  514. one  system is waiting forever for the message while the other waits for
  515.  
  516. a response.  Some systems can set timer interrupts to allow escape  from
  517.  
  518. potentially  blocking operations; others, including many microcomputers,
  519.  
  520. can not do so.  When timeouts are not possible, they may be simulated by
  521.  
  522. sleep-and-test or loop-and-test operations, or deadlocked systems may be
  523.  
  524. awakened by manual intervention.
  525.                                    11
  526.  
  527.  
  528.  
  529.  
  530.  
  531. . File Organization
  532.  
  533.  
  534.   Some  computers  store  all files in a uniform way, such as the linear
  535.  
  536. stream of bytes that is a UNIX file.  Other computers may have more com-
  537.  
  538. plicated or diverse  file  organizations  and  access  methods:  record-
  539.  
  540. oriented  storage with its many variations, exemplified in IBM OS/360 or
  541.  
  542. DEC RMS.  Even simple  microcomputers  can  present  complications  when
  543.  
  544. files  are treated as uniform data to be transferred; for instance under
  545.  
  546. CP/M, the ends of binary and text files are determined differently.    A
  547.  
  548. major  question  in  any operating system is whether a file is specified
  549.  
  550. sufficiently by its contents and its name, or if additional external in-
  551.  
  552. formation is required to make the file valid.  A simple generalized file
  553.  
  554. transfer facility can be expected to transmit a  file's  name  and  con-
  555.  
  556. tents, but not every conceivable attribute a file might possess.
  557.  
  558.   Designers  of  expensive  networks  have gone to great lengths to pass
  559.  
  560. file attributes along when transferring files  between  unlike  systems.
  561.  
  562. For  instance, the DECnet Data Access Protocol [7] supports 42 different
  563.  
  564. ``generic system capabilities'' (like whether files can be preallocated,
  565.  
  566. appended to, accessed randomly, etc), 8 data types (ASCII,  EBCDIC,  ex-
  567.  
  568. ecutable, etc), 4 organizations (sequential, relative, indexed, hashed),
  569.  
  570. 5 record formats (fixed, variable, etc), 8 record attributes (for format
  571.  
  572. control),  14  file allocation attributes (byte size, record size, block
  573.  
  574. size, etc), 28 access options (supersede, update, append, rewind,  etc),
  575.  
  576. 26  device  characteristics  (terminal,  directory  structured,  shared,
  577.                                    12
  578.  
  579.  
  580.  
  581.  
  582.  
  583. spooled, etc), various access options (new, old, rename, password, etc),
  584.  
  585. in  addition  to  the  better  known file attributes like name, creation
  586.  
  587. date, protection code, and so on.  All this was  deemed  necessary  even
  588.  
  589. when  the  designers had only a small number of machines to worry about,
  590.  
  591. all from a single vendor.
  592.  
  593.   The ARPA network, which attempts to provide  services  for  many  more
  594.  
  595. machines  from many vendors, makes some simplifying assumptions and sets
  596.  
  597. some restrictions in its File Transfer Protocol (FTP) [8].    All  files
  598.  
  599. are  forced  into  certain  categories  with respect to encoding (ASCII,
  600.  
  601. EBCDIC, image), record format control, byte size, file structure (record
  602.  
  603. or stream), and it is generally left to the host FTP  implementation  to
  604.  
  605. do  the  necessary transformations.  No particular provision is made, or
  606.  
  607. can be made, to ensure that such transformations are invertible.
  608.  
  609.   DECnet is able to provide invertibility for operating systems like VMS
  610.  
  611. or RSX, which can store the necessary file  attributes  along  with  the
  612.  
  613. file.    But simpler file systems, like those of TOPS-10 or TOPS-20, can
  614.  
  615. lose vital information about incoming files.  For instance, if  VMS  re-
  616.  
  617. quires some type of file to have a specific blocksize, while TOPS-20 has
  618.  
  619. no  concept of block size, then the blocksize will be lost upon transfer
  620.  
  621. from VMS to TOPS-20 and cannot be restored automatically when  the  file
  622.  
  623. is sent back, leaving the result potentially unusable.
  624.  
  625.   Invertibility  is  a  major  problem,  with  no simple solution.  For-
  626.  
  627. tunately, most file transfer between unlike systems involves  only  tex-
  628.  
  629. tual  information -- data, documents, program source -- which is sequen-
  630.                                    13
  631.  
  632.  
  633.  
  634.  
  635.  
  636. tial  in  organization,  and  for  which  any  required  transformations
  637.  
  638. (e.g. blocked to stream, EBCDIC to ASCII) are simple and  not  dependent
  639.  
  640. on any special file attributes.
  641.  
  642.   In  fact, invertability can be achieved if that is the primary goal of
  643.  
  644. a file transfer protocol.  All the external attributes of a file can  be
  645.  
  646. encoded  and  included with the contents of the file to be stored on the
  647.  
  648. remote system.  For unlike systems, this can render the file  less  than
  649.  
  650. useful on the target system, but allows it to be restored correctly upon
  651.  
  652. return.   However, it is more commonly desired that textual files remain
  653.  
  654. intelligible when transferred to a foreign  system,  even  if  transfor-
  655.  
  656. mations  must  be  made.  To allow the necessary transformations to take
  657.  
  658. place on textual files between unlike systems, there must be a  standard
  659.  
  660. way of representing these files during transmission.
  661.  
  662.  
  663.  
  664. . Binary Files versus Parity
  665.  
  666.  
  667.   Each  ASCII character is represented by a string of 7 bits.  Printable
  668.  
  669. ASCII files can be transmitted in a straightforward fashion, because AS-
  670.  
  671. CII transmission is designed for them: a serial stream of 8-bit  charac-
  672.  
  673. ters,  7  bits  for data and 1 for parity, framed by start and stop bits
  674.  
  675. for the benefit of the hardware [3].  The parity bit is added as a check
  676.  
  677. on the integrity of a character; some systems  always  transmit  parity,
  678.  
  679. others insist on parity for incoming characters, still others ignore the
  680.  
  681. parity bit for communication purposes and pass it along to the software,
  682.                                    14
  683.  
  684.  
  685.  
  686.  
  687.  
  688. while  still  others  discard it altogether.  In addition, communication
  689.  
  690. front ends or common carriers might usurp the parity bit, regardless  of
  691.  
  692. what the system itself may do.
  693.  
  694.   Computer  file  systems generally store an ASCII file as a sequence of
  695.  
  696. either 7-bit or 8-bit bytes.  8-bit bytes are more common, in which  the
  697.  
  698. 8th  bit  of  each byte is superfluous.  Besides files composed of ASCII
  699.  
  700. characters, however, computers also  have  ``binary''  files,  in  which
  701.  
  702. every  bit is meaningful; examples include executable ``core images'' of
  703.  
  704. programs, numbers stored in ``internal format'', databases with imbedded
  705.  
  706. pointers.  Such binary data must  be  mapped  to  ASCII  characters  for
  707.  
  708. transmission  over  serial lines.  When two systems allow the user-level
  709.  
  710. software to control the parity bit, the  ANSI  standards [2, 3]  may  be
  711.  
  712. stretched to permit the transmission of 8 data bits per character, which
  713.  
  714. corresponds  to  the byte size of most machines.  But since not all com-
  715.  
  716. puters allow this flexibility, the ability to transfer  binary  data  in
  717.  
  718. this fashion cannot be assumed.
  719.  
  720.  
  721.  
  722. . Software
  723.  
  724.  
  725.   Finally,  systems  differ  in  the application software they have.  In
  726.  
  727. particular, no system can be assumed to have  a  particular  programming
  728.  
  729. language.  Even widespread languages like FORTRAN and BASIC may be lack-
  730.  
  731. ing  from some computers, either because they have not been implemented,
  732.  
  733. or because they are proprietary and have not been purchased.  Even  when
  734.                                    15
  735.  
  736.  
  737.  
  738.  
  739.  
  740. two  different  systems  support the same language, it is unrealistic to
  741.  
  742. expect the two implementations of the language to be totally compatible.
  743.  
  744. A general purpose file transfer protocol should not  be  geared  towards
  745.  
  746. the features any particular language.
  747.  
  748.  
  749.  
  750.  
  751. * KERMIT
  752.  
  753.  
  754.   Our  protocol,  which  we call KERMIT, addresses the problems outlined
  755.  
  756. above by setting certain minimal standards for transmission, and provid-
  757.  
  758. ing a mapping between disk storage organization, machine word  and  byte
  759.  
  760. size, and the transmission medium.
  761.  
  762.   KERMIT has the following characteristics:
  763.  
  764.  
  765.    - Communication takes place over ordinary terminal connections.
  766.  
  767.    - Communication  is half duplex.  This allows both full and half
  768.      duplex systems to participate, and it eliminates  the  echoing
  769.      that  would  otherwise occur for characters arriving at a host
  770.      job's controlling terminal.
  771.  
  772.    - The packet length is variable, but the maximum is  96  charac-
  773.      ters  so that most hosts can take packets in without buffering
  774.      problems.
  775.  
  776.    - Packets are sent in alternate directions; a reply is  required
  777.      for each packet.  This is to allow half duplex systems to par-
  778.      ticipate,  and  to prevent buffer overruns that would occur on
  779.      some systems if packets were sent back to back.
  780.  
  781.    - A timeout facility, when available, allows transmission to re-
  782.      sume after lost packets.
  783.  
  784.    - All transmission is in ASCII.  Any non-ASCII hosts are respon-
  785.      sible for conversion.  ASCII control characters  are  prefixed
  786.      and then converted to printable characters during transmission
  787.                                    16
  788.  
  789.  
  790.  
  791.  
  792.  
  793.      to  ensure  that  they arrive as sent.  A single ASCII control
  794.      character (normally SOH) is used to mark the  beginning  of  a
  795.      packet.
  796.  
  797.    - Binary files can be transmitted by a similar prefix scheme, or
  798.      by use of the parity bit when both sides have control of it.
  799.  
  800.    - Logical records (lines) in textual files are terminated during
  801.      transmission  with  quoted carriage-return/linefeed sequences,
  802.      which are transparent to the protocol and may appear  anywhere
  803.      in  a  packet.  Systems that delimit records in other ways are
  804.      responsible for conversion, if they desire the distinction be-
  805.      tween records to be preserved across unlike systems.
  806.  
  807.    - Only a file's name and contents  are  transmitted  --  no  at-
  808.      tributes.    It  is  the user's responsibility to see that the
  809.      file is stored correctly on the target system.    Within  this
  810.      framework,  invertible  transfer of text files can be assured,
  811.      but invertible transfer  of  non-text  files  depends  on  the
  812.      capabilities  of  the particular implementations of KERMIT and
  813.      the host operating systems.
  814.  
  815.    - KERMIT has no special knowledge of the host on the other side.
  816.      No attempt is made to ``integrate'' the two  sides.    Rather,
  817.      KERMIT  is designed to work more or less uniformly on all sys-
  818.      tems.
  819.  
  820.    - KERMIT need not be written in any particular language.  It  is
  821.      not a portable program, but a portable protocol.
  822.  
  823.  
  824.   Thus  KERMIT  accommodates  itself  to many systems by conforming to a
  825.  
  826. common subset of their features.    But  the  resulting  simplicity  and
  827.  
  828. generality allow KERMIT on any machine to communicate with KERMIT on any
  829.  
  830. other   machine,   micro-to-mainframe,   micro-to-micro,   mainframe-to-
  831.  
  832. mainframe.  The back-and-forth exchange of packets keeps the  two  sides
  833.  
  834. synchronized;  the  protocol can be called ``asynchronous'' only because
  835.  
  836. the communication hardware itself operates asynchronously.
  837.  
  838.   As far as the user is concerned, KERMIT is a do-it-yourself operation.
  839.                                    17
  840.  
  841.  
  842.  
  843.  
  844.  
  845. For  instance, to transfer files between your micro and a mainframe, you
  846.  
  847. would run KERMIT on your micro, put KERMIT into terminal emulation mode,
  848.  
  849. which ``connects'' you to the mainframe, log in and run  KERMIT  on  the
  850.  
  851. mainframe,  then  ``escape'' back to the micro and issue commands to the
  852.  
  853. micro's KERMIT to send or fetch the desired files.    Any  inconvenience
  854.  
  855. implicit  in  this  procedure is a consequence of the power it gives the
  856.  
  857. ordinary user to establish reliable connections between  computers  that
  858.  
  859. could not otherwise be connected.
  860.  
  861.  
  862.  
  863.  
  864. * Packets
  865.  
  866.  
  867.   KERMIT  packets  need  to  contain the data that is being transferred,
  868.  
  869. plus minimum information to assure (with high probability) that the  ex-
  870.  
  871. pected  data  arrives  completely and correctly.  Several issues come up
  872.  
  873. when designing the packet layout: how to represent data, how to  delimit
  874.  
  875. fields  within  the packet, how to delimit the packet itself, how to ar-
  876.  
  877. range the fields within the packet.  Since the transmission  medium  it-
  878.  
  879. self  is  character-oriented, it is not feasible to transmit bit strings
  880.  
  881. of arbitrary length, as do the bit-oriented protocols like HDLC and SDLC
  882.  
  883. [5].   Therefore the smallest unit of information in a  packet  must  be
  884.  
  885. the  ASCII  character.    As we will see, this precludes some techniques
  886.  
  887. that are used with other communication media.
  888.                                    18
  889.  
  890.  
  891.  
  892.  
  893.  
  894. . Control Fields
  895.  
  896.  
  897.   Most  popular protocol definitions view the packet as layers of infor-
  898.  
  899. mation, which pass through a hierarchy of protocol  levels,  each  level
  900.  
  901. adding  its  own information at the ends of an outbound packet or strip-
  902.  
  903. ping its information from the ends of an incoming packet, and then pass-
  904.  
  905. ing the result along to the next level in the hierarchy.  The fields for
  906.  
  907. each layer must be arranged so that they can be found,  identified,  and
  908.  
  909. interpreted correctly at the appropriate level.
  910.  
  911.   Since KERMIT packets are short, it is important to minimize the amount
  912.  
  913. of  control information per packet.  It would be convenient to limit the
  914.  
  915. control fields to one character  each.    Since  we  have  95  printable
  916.  
  917. characters  to work with (128 ASCII characters, less DEL and the 32 con-
  918.  
  919. trol characters), we can represent values from 0 to  94  with  a  single
  920.  
  921. character.
  922.  
  923.  
  924.    - The packet sequence number is used to detect missing or dupli-
  925.      cate  packets.   It is unlikely that a large number of packets
  926.      could be lost, especially since packet n is  acknowledged  be-
  927.      fore  packet  n+1  is  sent.   So the sequence number can be a
  928.      small quantity, which ``wraps around'' to  its  minimum  value
  929.      when it exceeds a specified maximum value.
  930.  
  931.    - To  prevent  long  packets,  a small maximum length can be en-
  932.      forced by specifying the packet length with a  single  charac-
  933.      ter; since there are 95 printable ASCII characters, this would
  934.      be  the  maximum length, depending on how we count the control
  935.      fields.
  936.  
  937.    - The checksum can be  of  fixed  length.    The  actual  length
  938.      depends  on the desired balance between and efficiency and er-
  939.      ror detection.
  940.                                    19
  941.  
  942.  
  943.  
  944.  
  945.  
  946.   The packet length and checksum act together to detect corrupted, miss-
  947.  
  948. ing,  or extra characters.  These are the essential fields for promoting
  949.  
  950. error-free transmission.  But so far, we've only considered packets that
  951.  
  952. carry actual file data; we will also require  special  packets  composed
  953.  
  954. only  of  control  information, for instance to tell the remote host the
  955.  
  956. name of the file that is about to come, or to tell it that the transmis-
  957.  
  958. sion is complete.  This can be accomplished with a  packet  type  field.
  959.  
  960. The  number of functions we need to specify in this field is small, so a
  961.  
  962. single character can suffice here too.
  963.  
  964.  
  965.  
  966. . Packet Framing
  967.  
  968.  
  969.   We choose to mark the beginning of a packet with a distinguished start
  970.  
  971. character, SOH (Start Of Header, ASCII 1, Control-A).    This  character
  972.  
  973. cannot  appear anywhere else within the packet.  SOH was chosen because,
  974.  
  975. unlike most other control characters, it is generally accepted upon  in-
  976.  
  977. put  at a job's controlling terminal as a data character, rather than an
  978.  
  979. interrupt or break character on most mainframes.  This  is  probably  no
  980.  
  981. accident, since it was originally intended for this use by the designers
  982.  
  983. of  the  ASCII alphabet [9].  Should a system be incapable of sending or
  984.  
  985. receiving SOH, it is possible to redefine the start-of-packet  character
  986.  
  987. to  be  any other control character; the two sides need not use the same
  988.  
  989. one.
  990.  
  991.   There are three principal options for recognizing the end of a packet:
  992.                                    20
  993.  
  994.  
  995.  
  996.  
  997.  
  998. a  fixed  length,  a  distinguished  packet-end  character, and a length
  999.  
  1000. field.  There are arguments for and against each involving what  happens
  1001.  
  1002. when  characters,  particularly  a  length  or  terminator,  is  lost or
  1003.  
  1004. garbled, which will be mentioned later.  KERMIT uses a length field.
  1005.  
  1006.   To take in a packet, a KERMIT program gets characters  from  the  line
  1007.  
  1008. until  it  encounters the SOH.  The next character is the length; KERMIT
  1009.  
  1010. reads and decodes the length and then reads that many subsequent charac-
  1011.  
  1012. ters to complete the packet.  If another SOH is encountered  before  the
  1013.  
  1014. count  is  exhausted,  the  current packet is forgotten and a new one is
  1015.  
  1016. started.   This  stratagy  allows  arbitrary  amounts  of  noise  to  be
  1017.  
  1018. generated  spontaneously  between  packets  without interfering with the
  1019.  
  1020. protocol.
  1021.  
  1022.  
  1023.  
  1024. . Encoding
  1025.  
  1026.  
  1027.   When transmitting textual data, KERMIT terminates logical records with
  1028.  
  1029. carriage-return linefeed combinations (CRLFs).  On record oriented  sys-
  1030.  
  1031. tems,  trailing  blanks or length fields are removed and a CRLF appended
  1032.  
  1033. to outbound records, with the inverse operation  performed  on  incoming
  1034.  
  1035. records.    On stream oriented systems, incoming CRLFs may be translated
  1036.  
  1037. to some other terminator.  Files,  of  course,  need  not  have  logical
  1038.  
  1039. records,  in which case record processing can be skipped altogether, and
  1040.  
  1041. the file can be treated as a long string of bytes.   This  is  known  as
  1042.  
  1043. ``image''  transfer,  and can also be used between like systems where no
  1044.                                    21
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050. transformations are necessary.
  1051.  
  1052.   In  order  to  make  each  character  in  the packet printable, KERMIT
  1053.  
  1054. ``quotes'' any unprintable character by transforming it to  a  printable
  1055.  
  1056. one and precedes it with a special prefix character.  The prefix is nor-
  1057.  
  1058. mally  ``#'';  the transformation is done by complementing bit 6 (adding
  1059.  
  1060. or subtracting  64  ,  modulo  64).    Thus  control-A  becomes  ``#A'',
  1061.                   10
  1062. control-Z  becomes ``#Z'', US (control-underscore on most terminals) be-
  1063.  
  1064. comes ``#_''.  The prefix  character  is  also  used  to  quote  itself:
  1065.  
  1066. ``##''.  Upon input, the reverse transformation is performed.  Printable
  1067.  
  1068. characters  are not tranformed.  The assumption is that most files to be
  1069.  
  1070. transferred are printable, and printable files  contain  relatively  few
  1071.  
  1072. control  characters; when this is true, the character stream is not sig-
  1073.  
  1074. nificantly lengthened by quoting.  For binary files, the average quoting
  1075.  
  1076. overhead will be 26.6% if all bit patterns are equally likely, since the
  1077.  
  1078. characters that must be quoted (the control characters,  plus  DEL,  and
  1079.  
  1080. ``#'' itself) comprise 26.6% of the ASCII alphabet.
  1081.  
  1082.   KERMIT also provides a scheme for indicating the status of the 8th bit
  1083.  
  1084. when transferring binary files between systems that must use the 8th bit
  1085.  
  1086. for  parity.  A byte whose 8th bit is set is preceded by another special
  1087.  
  1088. quoting character, ``&''.  If the low-order 7 bits coincide with an  AS-
  1089.  
  1090. CII control character, then control-character quoting is also done.  For
  1091.  
  1092. instance, the byte 10000001  would be transmitted as ``&#A''.  The ``&''
  1093.                            2
  1094. character  itself  can  be  included as data by quoting it (#&), and the
  1095.  
  1096. control-quote character may have its 8th bit set (&##).  8th-bit quoting
  1097.                                    22
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103. is  only  done when necessary; if both sides can control the parity bit,
  1104.  
  1105. then its value is preserved during transmission.  If the 8th bit is  set
  1106.  
  1107. randomly  on  binary  files, then 8th-bit quoting will add 50% character
  1108.  
  1109. overhead.  For some kinds of binary data, it  could  be  less;  for  in-
  1110.  
  1111. stance,  positive  binary  numbers  in 2's complement notation do not to
  1112.  
  1113. have their high-order bits set, in which case at least one byte per word
  1114.  
  1115. will not be quoted.
  1116.  
  1117.   A third kind of ``quoting'' implements rudimentary  data  compression.
  1118.  
  1119. At  low  speeds, the bottleneck in file transmission is likely to be the
  1120.  
  1121. line itself, so any measure that can cut down on use of the  line  would
  1122.  
  1123. be  welcome.  The special prefix character ``~'' indicates that the next
  1124.  
  1125. character is a repeat count (a single character, encoded printably)  and
  1126.  
  1127. that  the  character  after that (which may also have control or 8th-bit
  1128.  
  1129. prefixes) is repeated so many times.  For instance ``~}A''  indicates  a
  1130.  
  1131. series  of 93 letter A's; ``~H&#B'' indicates a series of 40 control-B's
  1132.  
  1133. with the parity bit set.  The repeat count prefix itself can be included
  1134.  
  1135. as text by quoting it with ``#''.
  1136.  
  1137.   To keep the protocol simple, no other transformations are  done.    At
  1138.  
  1139. this point, however, it might be worth mentioning some things we did not
  1140.  
  1141. do to the data:
  1142.  
  1143.  
  1144.    - Fancy  Data  compression.    If  the  data  is known to be (or
  1145.      resemble) English text, a Huffman encoding [10, 11]  based  on
  1146.      the  frequency of characters in English text could be used.  A
  1147.      Huffman code resembles Morse code, which has  variable  length
  1148.      characters  whose boundaries can always be distinguished.  The
  1149.      more frequent the character, the shorter  the  bit  string  to
  1150.                                    23
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.      represent  it.    Of  course,  this scheme can backfire if the
  1157.      character distribution of the data is very different from  the
  1158.      one  assumed.  In any case, variable length characters and AS-
  1159.      CII transmission don't mix well.
  1160.  
  1161.    - Error Correcting Codes.  Techniques,  such  as  Hamming  codes
  1162.       [12],  exist  for  detecting  and correcting errors on a per-
  1163.      character basis.  These are expensive in resources and complex
  1164.      to program.  KERMIT uses per-packet  block  check  techniques,
  1165.      which are explained below.
  1166.  
  1167.    - Nibble  Encoding.    To  circumvent  problems with control and
  1168.      8-bit characters, it would have been possible to divide  every
  1169.      character into two 4-bit ``nibbles'', sending each nibble as a
  1170.      printable character (e.g. a hexadecimal digit).  The character
  1171.      overhead  caused  by  this  scheme would would always be 100%.
  1172.      But it would be an easy way to transfer binary files.
  1173.  
  1174.  
  1175.  
  1176. . Error Detection
  1177.  
  1178.  
  1179.   Character parity and Hamming codes are forms of ``vertical  redundancy
  1180.  
  1181. checks''  (VRCs), formed by combining all the bits of a character in one
  1182.  
  1183. way or another.  The other kind  of  check  that  can  be  used  is  the
  1184.  
  1185. ``longitudinal  redundancy check'' (LRC), which produces a ``block check
  1186.  
  1187. character'' formed by some combination of each character  within  a  se-
  1188.  
  1189. quence.  The sending side computes the LRC and sends it with the packet;
  1190.  
  1191. the  receiving  side  recomputes  it  for comparison.  There are various
  1192.  
  1193. forms of LRCs.  One form produces  a  ``column  parity''  character,  or
  1194.  
  1195. ``logical  sum'',  whose bits are the exclusive-ORs of the corresponding
  1196.  
  1197. bits of the data characters.  Another is the ``checksum'' which  is  the
  1198.  
  1199. arithmetic  sum  of  all  the  characters  in  the sequence, interpreted
  1200.  
  1201. numerically.  Another is the ``Cyclic Redundancy Check'' (CRC) [13, 14],
  1202.                                    24
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208. which  passes  the  characters  through what amounts to a shift register
  1209.  
  1210. with imbedded feedback loops, producing a block check in which each  bit
  1211.  
  1212. is effected in many ways by the preceding characters.
  1213.  
  1214.   All  of  these  techniques will catch single-bit errors.  They vary in
  1215.  
  1216. their ability to detect other kinds of errors.  For instance, a  double-
  1217.  
  1218. bit column error will always go undetected with column parity, since the
  1219.  
  1220. result  of  XORing  any  two  bits  together is the same as XORing their
  1221.  
  1222. complements, whereas half the possible double bit errors can  be  caught
  1223.  
  1224. by  addition  because of the carry into the next bit position.  CRC does
  1225.  
  1226. even better by rippling the effect of a data bit  multiply  through  the
  1227.  
  1228. block  check  character,  but  the method is complex, and a software im-
  1229.  
  1230. plementation of CRC can be inscrutable.
  1231.  
  1232.   Standard, base-level  KERMIT  employs  a  single-character  arithmetic
  1233.  
  1234. checksum, which is simple to program, is low in overhead, and has proven
  1235.  
  1236. quite  adequate  in  practice.  The sum is formed by adding together the
  1237.  
  1238. ASCII values of each character in the packet  except  the  SOH  and  the
  1239.  
  1240. checksum  itself,  and including any quoting characters.  Even non-ASCII
  1241.  
  1242. hosts must do this calculation  in  ASCII.    The  result  can  approach
  1243.  
  1244. 12,000   in the worst case.  The binary representation of this number is
  1245.       10
  1246. 10111011100000,  which  is  14  bits  long.   This is much more than one
  1247.  
  1248. character's worth of bits, but we can make the  observation  that  every
  1249.  
  1250. character  included  in the sum has contributed to the low order 7 bits,
  1251.  
  1252. so we can discard some high order bits and still have a viable  validity
  1253.  
  1254. check.
  1255.                                    25
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.   The KERMIT protocol also allows other block check options, including a
  1262.  
  1263. two-character  checksum  and  a  three-character  16-bit  CRC.  The two-
  1264.  
  1265. character checksum is simply the low order 12  bits  of  the  arithmetic
  1266.  
  1267. sum,  broken  into two printable characters.  The CRC sequence is formed
  1268.  
  1269. from the 16-bit quantity generated by the  CCITT-recommended  polynomial
  1270.  16  12  5
  1271. X  +X  +X +1  which  is also used in some form with other popular trans-
  1272.  
  1273. mission techniques, like ISO HDLC and IBM SDLC [5].  The  high  order  4
  1274.  
  1275. bits  of  the  CRC  go  into  the first character, the middle 6 into the
  1276.  
  1277. second, and the low order 6 into the third.
  1278.  
  1279.   Some care must be taken in the formation of the single-character block
  1280.  
  1281. check.  Since it must be expressed  as  a  single  printable  character,
  1282.  
  1283. values  of  the  high order data bits may be lost, which could result in
  1284.  
  1285. undetected errors, especially when transferring binary  files.    There-
  1286.  
  1287. fore,  we  extract  the 7th and 8th bits of the sum and add them back to
  1288.  
  1289. the low order bits; if the arithmetic sum of all the  characters  is  S,
  1290.  
  1291. then the value of the single-character KERMIT checksum is given by 
  1292.  
  1293.  
  1294.     (S + ((S AND 300)/100)) AND 77
  1295.  
  1296.  
  1297. (numbers  are in octal notation).  This ensures that the checksum, terse
  1298.  
  1299. though it is, reflects every bit from every character in the packet.
  1300.  
  1301.   The probability that an error will not be caught by a correctly trans-
  1302.  
  1303. mitted arithmetic checksum is the ratio of the number of possible errors
  1304.  
  1305. that cancel each other out to the total number of possible errors, which
  1306.                                   n
  1307. works out to be something like 1/2 , where n is the number  of  bits  in
  1308.                                    26
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314. the  checksum, assuming all errors are equally likely.  This is 1/64 for
  1315.  
  1316. the single character checksum, and 1/4096 for the 2-character  checksum.
  1317.  
  1318. But  the probability that errors will go undetected by this method under
  1319.  
  1320. real conditions cannot be easily derived, because all  kinds  of  errors
  1321.  
  1322. are  not equally likely.  A 16-bit CRC will detect all single and double
  1323.  
  1324. bit errors, all messages with an odd number of bits in error, all  error
  1325.  
  1326. bursts  shorter  than  16  bits, and better than 99.99% of longer bursts
  1327.  
  1328. [13].   These probabilities all assume, of course, that the block  check
  1329.  
  1330. has  been identified correctly, i.e. that the length field points to it,
  1331.  
  1332. and that no intervening characters have been lost or spuriously added.
  1333.  
  1334.   A final note on parity -- a parity bit on each character combined with
  1335.  
  1336. a logical sum of all the characters (VRC and LRC) would allow  detection
  1337.  
  1338. and  correction of single-bit errors without retransmission by pinpoint-
  1339.  
  1340. ing the ``row'' and ``column'' of the bad  bit.    But  control  of  the
  1341.  
  1342. parity  bit cannot be achieved on every system, so we use the parity bit
  1343.  
  1344. for binary data when we  can,  or  surrender  it  to  the  communication
  1345.  
  1346. hardware if we must.  If we have use of the 8th bit for data, then it is
  1347.  
  1348. figured into the block check; if we do not, then it must be omitted from
  1349.  
  1350. the  block  check  in  case  it  has  been  changed by agents beyond the
  1351.  
  1352. knowledge or control of the KERMIT program.
  1353.                                    27
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359. . Packet Layout
  1360.  
  1361.  
  1362.   KERMIT packets have the format:
  1363.  
  1364.  
  1365.     +------+-----------+-----------+------+------------+-------+
  1366.     | MARK | char(LEN) | char(SEQ) | TYPE |    DATA    | CHECK |
  1367.     +------+-----------+-----------+------+------------+-------+
  1368.     |                  |           |                   |       |
  1369.     |                  |           +-- (application) --+       |
  1370.     |                  |                               |       |
  1371.     |                  +-------------- (session) ------+       |
  1372.     |                                                          |
  1373.     +--------------------------------- (data link) ------------+
  1374.  
  1375.  
  1376. where all fields consist of ASCII characters, and the char function con-
  1377.  
  1378. verts a number in the range 0-94   to a printable ASCII character by ad-
  1379.                                 10
  1380. ding 32  .
  1381.        10
  1382.   In  terms  of  the  ISO  network reference model [15], 8-bit bytes are
  1383.  
  1384. presented to the KERMIT program by the  hardware  and  operating  system
  1385.  
  1386. software  comprising  the  physical link layer.  Correct transmission is
  1387.  
  1388. ensured by the packet-level routines that implement the data link  layer
  1389.  
  1390. using  the  outer  ``skin''  of  the  packet -- the MARK, LEN, and CHECK
  1391.  
  1392. fields.  The network and transport layers are moot, since  KERMIT  is  a
  1393.  
  1394. point-to-point  affair,  in  which the user personally makes all the re-
  1395.  
  1396. quired connections.  The session layer  is  responsible  for  requesting
  1397.  
  1398. retransmission  of  missing packets or ignoring redundant ones, based on
  1399.  
  1400. the SEQ field; the presentation layer is responsible for any  data  con-
  1401.  
  1402. versions (EBCDIC/ASCII, insertion or stripping of CRLFs, etc).  Finally,
  1403.  
  1404. the  remainder of the packet, the TYPE and DATA fields, are the province
  1405.                                    28
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411. of  the application layer; our application, of course, is file transfer.
  1412.  
  1413. In any particular  implementation,  however,  the  organization  of  the
  1414.  
  1415. program  may not strictly follow this model.  For instance, since trans-
  1416.  
  1417. mission is always in stream ASCII, IBM implementations must convert from
  1418.  
  1419. EBCDIC and insert CRLFs before checksum computation.
  1420.  
  1421.   The fields of a KERMIT packet are as follows:
  1422.  
  1423.  
  1424. MARK      Start-of-packet character, normally SOH (ASCII 1).
  1425.  
  1426. LEN       The number of ASCII characters, including  quoting  characters
  1427.           and the checksum, within the packet that follow this field, in
  1428.           other words the packet length minus two.  Since this number is
  1429.           expressed  as a single character via the char function, packet
  1430.           character counts of 0 to 94   are permitted, and 96    is  the
  1431.                                      10                      10
  1432.           maximum total packet length.
  1433.  
  1434. SEQ       The packet sequence number, modulo 100 .  The sequence numbers
  1435.                                                 8
  1436.           ``wraps around'' to 0 after each group of 64   packets.
  1437.                                                       10
  1438. TYPE      The  packet  type,  a single printable ASCII character, one of
  1439.           the following:
  1440.  
  1441.           D   Data
  1442.           Y   Acknowledge (ACK)
  1443.           N   Negative Acknowledge (NAK)
  1444.           S   Send Initiate (Send-Init)
  1445.           R   Receive Initiate
  1446.           B   Break Transmission (EOT)
  1447.           F   File Header
  1448.           Z   End of file (EOF)
  1449.           E   Error
  1450.  
  1451.  
  1452.           G   Generic Command.  A single character in  the  data  field,
  1453.               possibly  followed  by operands, requests host-independent
  1454.               remote execution the specified command:
  1455.  
  1456.               L   Logout, Bye.
  1457.               F   Finish, but don't logout.
  1458.                                    29
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.               D   Directory    query    (followed   by   optional   file
  1465.                   specification).
  1466.               U   Disk usage query.
  1467.               E   Erase (followed by file specification).
  1468.               T   Type (followed by file specification).
  1469.               Q   Query server status.
  1470.               and others.
  1471.  
  1472.           C   Host Command.  The data field contains a string to be  ex-
  1473.               ecuted  as  a  system  dependent  (literal) command by the
  1474.               host.
  1475.           X   Text display header, to indicate the arrival of text to be
  1476.               displayed on the screen, for instance as the result  of  a
  1477.               generic or host command executed at the other end.  Opera-
  1478.               tion is exactly like a file transfer.
  1479.  
  1480.  
  1481. DATA      The  ``contents''  of the packet, if any contents are required
  1482.           in the given type of  packet,  interpreted  according  to  the
  1483.           packet  type.  Nonprintable ASCII characters are prefixed with
  1484.           quote characters and  then  ``uncontrollified''.    Characters
  1485.           with  the  8th  bit  set  may also be prefixed, and a repeated
  1486.           character can be prefixed by a count.  A prefixed sequence may
  1487.           not be broken across packets.
  1488.  
  1489. CHECK     The block check sequence, based on all the characters  in  the
  1490.           packet  between, but not including, the mark and the check it-
  1491.           self, one, two, or three characters  in  length  as  described
  1492.           above,  each  character  transformed  by  char.  Normally, the
  1493.           single-character checksum is used.
  1494.  
  1495.  
  1496. The packet may be followed by any line terminator required by the  host,
  1497.  
  1498. carriage return (ASCII 15) by default.  Line terminators are not part of
  1499.  
  1500. the  packet, and are not included in the count or checksum.  Terminators
  1501.  
  1502. are not necessary to the protocol, and are invisible to it, as  are  any
  1503.  
  1504. characters  that may appear between packets.  If a host cannot do single
  1505.  
  1506. character input from a TTY line, then a terminator will be required  for
  1507.  
  1508. that host.
  1509.  
  1510.   Here are some sample KERMIT data packets:
  1511.                                    30
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.     ^AE"D   No celestial body has required J
  1518.     ^AE#Das much labor for the study of its#
  1519.     ^AE$D#M#Jmotion as the moon.  Since ClaA
  1520.     ^AE%Dirault (1747), who indicated a way7
  1521.     ^AE&D of#M#Jconstructing a theory conta5
  1522.  
  1523.  
  1524. The  ``^A''  represents  the SOH (or Control-A) character.  In the final
  1525.  
  1526. packet shown, ``E'' is the length.  The ASCII value of the ``E'' charac-
  1527.  
  1528. ter is 69  , less 32 (the unchar transformation, which is  the  opposite
  1529.          10
  1530. of  char) gives a length of 37.  The next character tells the packet se-
  1531.  
  1532. quence number, in this case 6 (``&'' is ASCII 38).    The  next  is  the
  1533.  
  1534. packet  type ``D'' for Data.  The next characters, `` of#M#Jconstructing
  1535.  
  1536. a theory conta'', form the data; note the prefixed carriage  return  and
  1537.  
  1538. line feed.  The final character, ``5'' is the checksum, which represents
  1539.  
  1540. the number 21 (all numbers in this paragraph are in decimal).
  1541.  
  1542.  
  1543.  
  1544. . Effects of Packet Corruption
  1545.  
  1546.  
  1547.   What  are  the  consequences  of  transmission  errors  in the various
  1548.  
  1549. fields?  If the SOH is garbled, the packet will  be  treated  as  inter-
  1550.  
  1551. packet  garbage,  and lost.  If any other character within the packet is
  1552.  
  1553. garbled into SOH, the current  packet  will  be  discarded,  and  a  new
  1554.  
  1555. (spurious)  packet  detected.    If the length is garbled into a smaller
  1556.  
  1557. number, then a character from the data field will be  misinterpreted  as
  1558.  
  1559. the  checksum;  if  larger,  then the program will probably become stuck
  1560.  
  1561. trying to input characters that will not be sent until one side  or  the
  1562.  
  1563. other  times  out and retransmits.  If the sequence number, type, any of
  1564.                                    31
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570. the  data  characters,  or  the checksum itself is garbled, the checksum
  1571.  
  1572. should be wrong.  If characters are lost, there will most  likely  be  a
  1573.  
  1574. timeout.   If noise characters are spontaneously generated, they will be
  1575.  
  1576. ignored if they are between packets, or will cause the  wrong  character
  1577.  
  1578. to  be  interpreted as the checksum if they come during packet transmis-
  1579.  
  1580. sion.
  1581.  
  1582.   Most kinds of errors are caught by the checksum  comparison,  and  are
  1583.  
  1584. handled  by  immediate retransmission.  Timeouts are more costly because
  1585.  
  1586. the line sits idle for the timeout period.  The packet design  minimizes
  1587.  
  1588. the  necessity  for  timeouts  due to packet corruption: the only fields
  1589.  
  1590. that can be corrupted to cause a timeout are  the  SOH  and  the  packet
  1591.  
  1592. length,  and  the  latter only half the time.  Lost characters, however,
  1593.  
  1594. can produce the same effect (as they would  with  a  fixed-length  block
  1595.  
  1596. protocol).  Had a distinguished end-of-packet character been used rather
  1597.  
  1598. than  a  length  field,  then there would be a timeout every time it was
  1599.  
  1600. corrupted.  It is always better to retransmit immediately than  to  time
  1601.  
  1602. out.
  1603.                                    32
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609. * Protocol
  1610.  
  1611.  
  1612.   The  KERMIT  protocol can be described as a set of states and a set of
  1613.  
  1614. transitions that define, for a given event, what action to take and what
  1615.  
  1616. new state to change to.  The inherent simplicity  of  the  design,  par-
  1617.  
  1618. ticularly the requirement that each packet must be acknowledged, reduces
  1619.  
  1620. the  number  of  states and actions, and the amount of state information
  1621.  
  1622. that must be maintained, to a minimum.
  1623.  
  1624.   Here is a simplified version of a state diagram for KERMIT receiving a
  1625.  
  1626. file:
  1627.  
  1628.  
  1629.  
  1630.                             +--------------+
  1631.                             | Receive Init |
  1632.                             +--------------+
  1633.                                     |
  1634.                                     | (Get Send Init Packet)
  1635.                                     |
  1636.            (Get EOT Packet)         V
  1637.                             +--------------+
  1638.   (Done) <------------------| Receive File |<---------------+
  1639.                             +--------------+                |
  1640.                                     |                       |
  1641.                                     | (Get File             | (Get EOF Packet)
  1642.                                     |  Header Packet)       |
  1643.                                     V                       |
  1644.                             +--------------+                |
  1645.                     +------>| Receive Data |----------------+
  1646.                     |       +--------------+
  1647.                     |               |
  1648.                     |               | (Get Data Packet)
  1649.                     |               |
  1650.                     +---------------+
  1651.  
  1652.  
  1653. For simplicity, some transitions are not shown in the diagram:
  1654.                                    33
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.    - If  in any state a bad packet is received or a timeout occurs,
  1661.      a null transition back to the same state occurs,  with  a  NAK
  1662.      for the expected packet.
  1663.  
  1664.    - In any state an error may occur that can cause the transfer to
  1665.      terminate.   For instance, the target disk might fill up.  The
  1666.      side that encountered the error sends an  error  packet,  con-
  1667.      taining an informative error message, and quits.  Upon receipt
  1668.      of  the  error  packet, the other side displays the message on
  1669.      the screen (if it is in control of the screen) and also quits.
  1670.  
  1671.    - Actions that are taken on each transition, such as  opening  a
  1672.      file  when a File Header packet is received, are not shown; in
  1673.      particular each packet successfully received is ACK'd.
  1674.  
  1675.  
  1676.   The receiver starts out in Receive Init state and waits for the  other
  1677.  
  1678. side  to  send  a  Send-Init  packet.    If  any other kind of packet is
  1679.  
  1680. received, or the Send-Init does not arrive within the timeout  interval,
  1681.  
  1682. a NAK is sent.  Timeouts or NAKs can occur up to a threshold which, when
  1683.  
  1684. exceeded for a particular packet, causes the protocol to assume that the
  1685.  
  1686. connection has become unusable, and to give up.  After the Send-Init ar-
  1687.  
  1688. rives,  the  state  becomes Receive File; KERMIT waits for a File Header
  1689.  
  1690. packet containing the name of the file which is to come.  When the  file
  1691.  
  1692. header arrives, KERMIT opens a new file using the name provided (perhaps
  1693.  
  1694. transformed  to  suit  local  naming  conventions,  or  to  avoid a name
  1695.  
  1696. collision), and switches to Receive Data state.   KERMIT  then  receives
  1697.  
  1698. the contents of the file, until an EOF (End Of File) packet arrives.  At
  1699.  
  1700. that  point KERMIT switches back to Receive File state.  If another file
  1701.  
  1702. is to be sent, another File Header packet will follow, otherwise an  EOT
  1703.  
  1704. (End  Of Transmission) packet will terminate the transfer.  The distinc-
  1705.  
  1706. tion between EOF and EOT, plus the File Header itself, allows  files  to
  1707.                                    34
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713. be  sent in groups.  EOF marks the end of a file, EOT marks the end of a
  1714.  
  1715. group.  This  distinction  also  allows  the  two  sides  to  disconnect
  1716.  
  1717. cleanly:  the  EOF must be ACK'd before the sender will believe the file
  1718.  
  1719. has been transmitted correctly; the EOT will  follow,  but  if  the  ACK
  1720.  
  1721. which is sent in response is lost, no harm will be done since both sides
  1722.  
  1723. are terminating anyway.
  1724.  
  1725.   The  state  transitions  for  a  sending  KERMIT are similar.  In each
  1726.  
  1727. state, instead of waiting for particular packet types, KERMIT sends  the
  1728.  
  1729. appropriate  packet  and  waits  for an ACK.  If the ACK does not arrive
  1730.  
  1731. within the allotted time, or a NAK appears instead of an ACK,  the  same
  1732.  
  1733. packet  is  retransmitted.    A  send  operation begins with a Send-Init
  1734.  
  1735. packet, includes one or more files, each starting with  a  File  Header,
  1736.  
  1737. followed  by  one  or  more data packets, followed by EOF.  When all the
  1738.  
  1739. specified files have been sent, an EOT packet closes the connection  and
  1740.  
  1741. terminates the operation.
  1742.                                    35
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.                             +-----------+
  1750.                             | Send Init |
  1751.                             +-----------+
  1752.                                     |
  1753.                                     | (Get Good ACK)
  1754.                                     |
  1755.    (No more files to send)          V
  1756.   +----------+              +-----------+
  1757.   | Send EOT |<-------------| Send File |<---------------+
  1758.   +----------+              +-----------+                |
  1759.                                     |                    |
  1760.                                     | (Good ACK)         | (EOF)
  1761.                                     |                    |
  1762.                                     V                    |
  1763.                             +-----------+                |
  1764.                     +------>| Send Data |----------------+
  1765.                     |       +-----------+
  1766.                     |               |
  1767.                     |               | (Good ACK)
  1768.                     |               |
  1769.                     +---------------+
  1770.  
  1771.  
  1772.   Base-level KERMIT provides that during any particular transaction, the
  1773.  
  1774. sender is the ``master'' and the receiver is the ``slave''.  These roles
  1775.  
  1776. may  be  reversed  in the next transaction; any KERMIT implementation is
  1777.  
  1778. capable of acting as either master or slave.  In addition, mainframe im-
  1779.  
  1780. plementations may  also  be  put  in  a  kind  of  permanent  slave,  or
  1781.  
  1782. ``server'',  mode in which all commands come in command packets from the
  1783.  
  1784. master, or ``user'' KERMIT.
  1785.                                    36
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791. . Initial Connection
  1792.  
  1793.  
  1794.   To allow a diverse group of computers to communicate with one another,
  1795.  
  1796. an  exchange  takes  places  during  initial connection in which the two
  1797.  
  1798. sides ``configure'' each other.    The  sending  KERMIT  includes  setup
  1799.  
  1800. parameters  in  its  Send-Init  packet and the receiving KERMIT responds
  1801.  
  1802. with an ACK packet containing the corresponding parameters as they apply
  1803.  
  1804. to itself.  The Data field of the Send-Init packet looks like this:
  1805.  
  1806.  
  1807.    1      2      3      4      5      6      7      8      9      10
  1808.   +------+------+------+------+------+------+------+------+------+-------------
  1809.   | MAXL | TIME | NPAD | PADC | EOL  | QCTL | QBIN | CHKT | REPT |  CAPAS...
  1810.   +------+------+------+------+------+------+------+------+------+-------------
  1811.  
  1812.  
  1813. The fields are as follows (the first and second person ``I'' and ``you''
  1814.  
  1815. are used to distinguish the two sides).  Fields  are  encoded  printably
  1816.  
  1817. using the char function (ASCII value + 32  ) unless indicated otherwise.
  1818.                                          10
  1819.  
  1820. MAXL    The  maximum  length  packet  I  want to receive, a number up to
  1821.         94  .You respond with the maximum you want me to send.  This al-
  1822.           10
  1823.         lows systems to adjust to each other's buffer sizes, or  to  the
  1824.         condition of the transmission medium.
  1825.  
  1826. TIME    The  number  of  seconds  after  which I want you to time me out
  1827.         while waiting for a packet from me.  You respond with the amount
  1828.         of time I should wait for packets from you.  This allows the two
  1829.         sides to accommodate to different line speeds or  other  factors
  1830.         that could cause timing problems.
  1831.  
  1832. NPAD    The number of padding characters I want to precede each incoming
  1833.         packet;  you  respond  in  kind.  Padding may be necessary for a
  1834.         half duplex system that requires some time to change the  direc-
  1835.         tion of transmission.
  1836.  
  1837. PADC    The control character I need for padding, if any, XOR'd with 100
  1838.         octal  to make it printable.  You respond in kind.  Normally NUL
  1839.         (ASCII 0), some systems use DEL (ASCII 177).  This field is  ig-
  1840.         nored if the value NPAD is zero.
  1841.                                    37
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847. EOL     The  character  I  need to terminate an incoming packet, if any.
  1848.         You respond in kind.  Most systems  that  require  a  line  ter-
  1849.         minator  for terminal input accept carriage return for this pur-
  1850.         pose.  (Can you see the Catch-22 here?)
  1851.  
  1852. QCTL    The printable ASCII  character  I  will  use  to  quote  control
  1853.         characters  and  prefix characters, normally ``#''.  You respond
  1854.         with the one you will use.
  1855.  
  1856. QBIN    The printable ASCII character I want to use to quote  characters
  1857.         which  have  the 8th bit set, for transmitting binary files when
  1858.         one or both systems cannot use the parity bit for data.    Since
  1859.         this  kind  of quoting increases both processor and transmission
  1860.         overhead, it is normally to be avoided.
  1861.  
  1862. CHKT    Check Type, the method for detecting errors.  ``1'' for  single-
  1863.         character  checksum (the normal method), ``2'' for two-character
  1864.         checksum, ``3'' for three-character CRC-CCITT.  If your response
  1865.         agrees, the  designated  method  will  be  used;  otherwise  the
  1866.         single-character  checksum  will be used.  Other check types may
  1867.         also be added.
  1868.  
  1869. REPT    The prefix character I will use to indicate a  repeated  charac-
  1870.         ter.    This  can  be  any  printable character other than blank
  1871.         (which denotes no repeat count  prefix),  but  ``~''  is  recom-
  1872.         mended.    If  you don't respond identically, repeat counts will
  1873.         not be done.  Groups of 4 or more identical  characters  may  be
  1874.         transmitted more efficiently using a repeat count, though an in-
  1875.         dividual implementation may wish to set a higher threshhold.
  1876.  
  1877. CAPAS   An  extendable  bit  mask encoded printably, to indicate whether
  1878.         certain advanced capabilities, such as  file-attribute  packets,
  1879.         are supported.
  1880.  
  1881. Reserved Fields
  1882.         The next four fields are reserved for future use.  Sites wishing
  1883.         to  add  their own parameters to the initial connection exchange
  1884.         should start at the fifth field after the capability mask in or-
  1885.         der to remain compatible with other KERMIT programs.
  1886.  
  1887.  
  1888. Naturally, the three prefix characters must be distinct  and  should  be
  1889.  
  1890. chosen  to  be uncommonly used printable characters, to minimize further
  1891.  
  1892. overhead from having to prefix them when they are found in the data.
  1893.  
  1894.   Trailing fields within the DATA field may be omitted,  in  which  case
  1895.  
  1896. they will assume appropriate defaults.  Defaults for intermediate fields
  1897.  
  1898. can be elected by setting those fields to blank.  Every parameter has an
  1899.                                    38
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905. appropriate  default, and in fact the entire data field of the Send Init
  1906.  
  1907. packet or its ACK may be left empty to accept all defaults.    The  more
  1908.  
  1909. exotic  paramaters  are at the end, and reflect more recent developments
  1910.  
  1911. in the KERMIT protocol; earlier implementations  can  still  communicate
  1912.  
  1913. with newer ones, since there will not be agreement to use these options.
  1914.  
  1915. The  Send-Init  mechanism preserves compatibility from the very earliest
  1916.  
  1917. KERMIT to the very newest.
  1918.  
  1919.   There is no protracted negotiation; everything must be  settled  in  a
  1920.  
  1921. single  exchange.    Some  parameters, however, are outside the scope of
  1922.  
  1923. this exchange and must be set even before the very first packet is sent.
  1924.  
  1925. For instance, if the receiving computer can only  read  characters  with
  1926.  
  1927. odd  parity  but  the  sending computer sends them with even parity, the
  1928.  
  1929. Send-Init packet will never arrive successfully.  In  cases  like  this,
  1930.  
  1931. the  user  may  have to issue some preliminary commands to inform one or
  1932.  
  1933. both KERMITs about the vagaries of the other system.  Another example is
  1934.  
  1935. the packet terminator (EOL) mentioned above -- if the  receiving  KERMIT
  1936.  
  1937. requires  one  that the sending KERMIT doesn't know about, the Send-Init
  1938.  
  1939. will never get through.
  1940.  
  1941.   For these reasons, most implementations of KERMIT provide SET commands
  1942.  
  1943. for all the parameters listed above, and some others as well.
  1944.                                    39
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950. . Rules and Heuristics
  1951.  
  1952.  
  1953.   During  a  file transfer, one KERMIT sends information packets -- file
  1954.  
  1955. headers, data, and so forth, and the other KERMIT  sends  only  ACKs  or
  1956.  
  1957. NAKs in response.  The most important rule in the KERMIT protocol is 
  1958.  
  1959.  
  1960.       1. ``Wait for a response before sending the next packet.''
  1961.  
  1962.  
  1963. This  prevents  buffer overruns, and allows participation by half duplex
  1964.  
  1965. systems.  Of course, KERMIT should not wait forever;  a  timeout  should
  1966.  
  1967. occur  after a few seconds if the expected packet has not arrived.  Upon
  1968.  
  1969. timeout, a sending KERMIT retransmits the current  packet;  a  receiving
  1970.  
  1971. KERMIT re-ACKs the current packet or NAKs the expected one.
  1972.  
  1973.   Some  interesting  heuristics are used in the KERMIT protocol to boost
  1974.  
  1975. efficiency and improve error recovery.  A number of important rules take
  1976.  
  1977. care of the cases when packets are lost in transmission.  The first  can
  1978.  
  1979. be stated as 
  1980.  
  1981.  
  1982.       2.  ``A NAK for the next packet implies an ACK for the current
  1983.  
  1984.     packet.''
  1985.  
  1986.  
  1987. A NAK with packet number n+1 means the receiving KERMIT  got  packet  n,
  1988.  
  1989. sent an ACK that was never received, and not knowing that the ACK didn't
  1990.  
  1991. get  through (since we don't ACK an ACK), is now waiting for packet n+1,
  1992.  
  1993. which was never sent.  In this case, we simply send packet n+1.  An  im-
  1994.  
  1995. portant  exception is when the missing ACK is for a Send-Init packet; do
  1996.                                    40
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002. you see why?  The next rule, 
  2003.  
  2004.  
  2005.       3. ``ACK and discard redundant packets.''
  2006.  
  2007.  
  2008. handles  the situation where the same packet arrives again.  The sending
  2009.  
  2010. KERMIT timed out waiting for an  ACK  which  was  sent,  but  lost,  and
  2011.  
  2012. retransmitted  the packet.  The receiver must discard the redundant data
  2013.  
  2014. and ACK the packet again; to do otherwise  could  have  undesirable  ef-
  2015.  
  2016. fects,  like  adding  the  same data to a file twice or opening the same
  2017.  
  2018. file multiple times.  Note that the situation resulting from a lost  ACK
  2019.  
  2020. depends upon which side times out first.
  2021.  
  2022.   KERMIT  must handle another situation arising from possible lost pack-
  2023.  
  2024. ets:  
  2025.  
  2026.  
  2027.       4. ``NAK the expected command.''
  2028.  
  2029.  
  2030. The potential problem occurs in either the Receive Init state or when  a
  2031.  
  2032. KERMIT  server  is  waiting  for a command.  In either case KERMIT won't
  2033.  
  2034. know whether communication has begun if the other side's initial  packet
  2035.  
  2036. was  lost.    KERMIT  can't  assume  the  other  side  will time out and
  2037.  
  2038. retransmit, so it must check periodically by sending a  NAK  for  packet
  2039.  
  2040. zero.    If  KERMIT gets no response it assumes nothing has happened yet
  2041.  
  2042. and goes back to sleep for a while.
  2043.  
  2044.   But sending periodic NAKs opens the door  to  the  buffering  problem.
  2045.  
  2046. Some systems buffer input for a device; when a program isn't looking for
  2047.  
  2048. input  some  or  all  the  input is saved by the computer for future re-
  2049.                                    41
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055. quests.    This  can  cause  problems when talking to a KERMIT server or
  2056.  
  2057. sending a file to a KERMIT in receive wait.  If some  time  has  elapsed
  2058.  
  2059. since activating the remote KERMIT and escaping back and starting up the
  2060.  
  2061. local  KERMIT,  a  number  of  NAKs  may  have  accumulated in the local
  2062.  
  2063. KERMIT's input buffer, so:  
  2064.  
  2065.  
  2066.       5. ``Clear the input buffer at the beginning of a transfer.''
  2067.  
  2068.  
  2069. If the input buffer is not cleared, the  local  KERMIT  will  think  the
  2070.  
  2071. remote  side is having trouble receiving the first packet.  In an effort
  2072.  
  2073. to get the packet through, it will be sent again; this repeats for every
  2074.  
  2075. NAK waiting in the input buffer.  By the time the first ACK  is  finally
  2076.  
  2077. encountered  in  the  buffer, a number of duplicates of the first packet
  2078.  
  2079. will have been sent out.  If this number exceeds the NAK threshhold, the
  2080.  
  2081. connection will be broken.  If not, however, the second packet  will  be
  2082.  
  2083. retransmitted  once  for  each  of the extra ACKs the remote KERMIT cor-
  2084.  
  2085. rectly sent for the duplicate first packets.  This can  continue  throu-
  2086.  
  2087. ghout the file transfer, causing each packet to be sent many times.  So,
  2088.  
  2089. in addition, 
  2090.  
  2091.  
  2092.       6. ``Clear the input buffer after reading each packet.''
  2093.  
  2094.  
  2095. Any computer that buffers its input should clear its input buffer before
  2096.  
  2097. the transfer and after each packet that arrives successfully.  But since
  2098.  
  2099. not  all  systems  provide  a  clear-buffer function, we may add another
  2100.  
  2101. rule:  
  2102.                                    42
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.       7. ``Discard redundant ACKs.''
  2109.  
  2110.  
  2111. In the situation just described, the first packet would be sent out mul-
  2112.  
  2113. tiple times, once for each buffered NAK.  Upon receipt of the first ACK,
  2114.  
  2115. the  second  packet would go out, but the next response would be another
  2116.  
  2117. ACK for the first packet; by rule 7, KERMIT would  simply  take  in  the
  2118.  
  2119. redundant  ACK,  ignore  it, and look for the next ACK, until it got the
  2120.  
  2121. desired one, in violation of the spirit of Rule 1.
  2122.  
  2123.   If we allowed ourselves to violate Rule 1, we could add a final  rule,
  2124.  
  2125. ``An  ACK  for  packet n also ACKs all previous packets,'' as is done in
  2126.  
  2127. network protocols like DDCMP [16], allowing data packets to be sent in a
  2128.  
  2129. continuous stream.  KERMIT cannot use this rule for  many  reasons:  se-
  2130.  
  2131. quence number wraparound, buffer overflows, locking out half duplex sys-
  2132.  
  2133. tems  (how  can  they  NAK a bad packet if they can't get control of the
  2134.  
  2135. line?).  Thus if we violate rule 1, it must be only in a very minor way.
  2136.  
  2137.  
  2138.  
  2139. . Example
  2140.  
  2141.  
  2142.   Here is a sequence of packets from a real file transfer.  Each  packet
  2143.  
  2144. starts with Control-A, shown as ^A.
  2145.                                    43
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.     ^A) SH( @-#^                                  Send Init
  2152.     ^A) YH( @-#%                                  ACK for Send Init
  2153.     ^A+!FMOON.DOC2                                File Header
  2154.     ^A#!Y?                                        ACK for File Header
  2155.     ^AE"D   No celestial body has required J      First Data packet
  2156.     ^A#"Y@                                        ACK for first Data packet
  2157.     ^AE#Das m%%%uch labor for the study of its#   Second Data packet, Bad
  2158.     ^A##N8                                        NAK for second Data packet
  2159.     ^AE#Das much labor for the study of its#      Second Data packet again
  2160.     ^A##YA                                        ACK for second Data packet
  2161.     ^AE$D#M#Jmotion as the moon.  Since ClaA      etc...
  2162.     ^A#$YB
  2163.  
  2164.     (many packets omitted here)
  2165.  
  2166.     ^AD"Dout 300 terms are sufficient.#M#JU       Last Data packet
  2167.     ^A#"Y@                                        ACK for last Data
  2168.     ^A##ZB                                        EOF
  2169.     ^A##YA                                        ACK for EOF
  2170.     ^A#$B+                                        EOT
  2171.     ^A#$YB                                        ACK for EOT
  2172.  
  2173.  
  2174. In  the  first  packet, we see following the control-A the packet length
  2175.  
  2176. ``)'' (41  , less 32, or 9), followed by the packet type, S (Send-Init),
  2177.          10
  2178. followed by  the  appropriate  parameter  declarations:  maximum  packet
  2179.  
  2180. length  is  H  (72-32=40), timeout is ``('' (40-32=8), number of padding
  2181.  
  2182. characters is 0 (space=32-32=0), the padding character is 0, end-of-line
  2183.  
  2184. is  ``-''  (45-32=13,  the  ASCII  value  of   carriage   return),   the
  2185.  
  2186. control-quote  character is ``#'', and the remaining fields are omitted,
  2187.  
  2188. defaulting to appropriate values.  The  final  character  ``^''  is  the
  2189.  
  2190. single-character checksum, computed as follows (all numbers and computa-
  2191.  
  2192. tions in octal, and ``sp'' represents a space):
  2193.  
  2194.  
  2195.     )    sp   S     H     (    sp   @     -    #
  2196.     51 + 40 + 123 + 110 + 50 + 40 + 100 + 55 + 43 = 674
  2197.                                    44
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.     674 + (674/300) = 676
  2205.  
  2206.     676 AND 77 = 76;
  2207.  
  2208.     char(76) = 76+40 = 136 = "^"
  2209.  
  2210.  
  2211. The  receiver  ACKs  with  its own parameters, which are the same.  Then
  2212.  
  2213. comes the file header, the file, EOF, and EOT.  One data packet was cor-
  2214.  
  2215. rupted by a burst of ``%'' characters, NAK'd, and retransmitted.
  2216.  
  2217.  
  2218.  
  2219.  
  2220. * Performance
  2221.  
  2222.  
  2223.   For text files (documents or program source), assuming an average line
  2224.  
  2225. length of 40 with lines separated by  a  carriage-return/linefeed  pair,
  2226.  
  2227. the  only  control  characters  normally  found in the text file, we see
  2228.  
  2229. about 5% overhead for prefixing of control characters.  Assuming no line
  2230.  
  2231. terminators for packets (although one or both sides may  require  them),
  2232.  
  2233. no  retransmissions or timeouts, and no time wasted for the line to turn
  2234.  
  2235. around between packet and response, then for average  packet  length  p,
  2236.  
  2237. using a single-character checksum, the KERMIT protocol overhead consists
  2238.  
  2239. of:
  2240.  
  2241.  
  2242.       5 control field characters in the data packet
  2243.       5 characters in the acknowledgement packet
  2244.     + 0.05p for control character quoting
  2245.  
  2246.  
  2247.   This  gives  10/p  +  0.05 overhead.  E.g. if the packet length is 40,
  2248.  
  2249. there is 30% overhead.  If p is 96 (the maximum), there  is  about  15%.
  2250.                                    45
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256. These  figures  will vary with the average line length and the frequency
  2257.  
  2258. of other control characters (like tabs and formfeeds) in the  file,  and
  2259.  
  2260. will  go  up  with  immediate  retransmissions,  and way up with delayed
  2261.  
  2262. retransmissions.  For binary files, the quoting overhead will be higher.
  2263.  
  2264. But transmission overhead can also go down dramatically if prefix encod-
  2265.  
  2266. ing is used for repeated characters, depending on the nature of the data
  2267.  
  2268. (binary data containing many zeroes, highly indented or columnar data or
  2269.  
  2270. program text will tend to benefit).  Each  file  transfer  also  gets  a
  2271.  
  2272. fixed  overhead  for  the  preliminary (Send Init, File Header) and ter-
  2273.  
  2274. minating (EOF, EOT) packets.
  2275.  
  2276.   If the mainframe end of a connection is heavily loaded,  it  may  take
  2277.  
  2278. considerable  time  to  digest  and  process  incoming characters before
  2279.  
  2280. replying.  On half duplex mainframes, there may be a pause between send-
  2281.  
  2282. ing and receiving, even if the load is light; this might be used to  ad-
  2283.  
  2284. vantage  by  preparing  the next packet in advance while waiting for the
  2285.  
  2286. current ACK.  Another problem may occur  on  heavily  loaded  mainframes
  2287.  
  2288. --  undesirable timeouts.  Timeouts are intended to detect lost packets.
  2289.  
  2290. A heavily loaded system may take longer than  the  timeout  interval  to
  2291.  
  2292. send  a  packet.  For this reason, mainframe KERMITs should take the re-
  2293.  
  2294. quested timeout interval only as a minimum, and  should  adjust  it  for
  2295.  
  2296. each  packet  based  on the current system load, up to a reasonable max-
  2297.  
  2298. imum.
  2299.  
  2300.   On a noisy line, there is a greater likelihood  of  corrupted  packets
  2301.  
  2302. and  therefore  of  retransmission overhead.  Performance on noisy lines
  2303.                                    46
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309. can  be improved by reducing the packet length, and thus the probability
  2310.  
  2311. that any particular packet will be corrupted, and the amount of time re-
  2312.  
  2313. quired  to  retransmit  a  corrupted  packet.    A  KERMIT  program  can
  2314.  
  2315. unilaterally  adjust  the  packet  length  according  to  the  number of
  2316.  
  2317. retransmissions  that  are  occurring.    Short  packets  cut  down   on
  2318.  
  2319. retransmission overhead, long packets cut down on character overhead.
  2320.  
  2321.  
  2322.  
  2323.  
  2324. * ``User Interface''
  2325.  
  2326.  
  2327.   KERMIT was designed from a mainframe perspective.  Like many mainframe
  2328.  
  2329. programs,  KERMIT  issues a prompt, the user types a command, KERMIT ex-
  2330.  
  2331. ecutes the command and issues another prompt, and so on until  the  user
  2332.  
  2333. exits  from  the  program.   Much care is devoted to the command parser,
  2334.  
  2335. even on microcomputer versions.  The goal  is  to  provide  English-like
  2336.  
  2337. commands  composed  of sequences of keywords or operands, with abbrevia-
  2338.  
  2339. tions possible for any keyword in any field down to the  minimum  unique
  2340.  
  2341. length,  and  with  ``?'' help available at any point in a command.  Not
  2342.  
  2343. all implementations need follow this model, but most do.
  2344.  
  2345.   The basic commands are SEND and RECEIVE.  These allow most KERMITs  to
  2346.  
  2347. exchange  files.    Operands can be the name of a single file, or a file
  2348.  
  2349. group designator (e.g. with ``wildcards'') to transmit multiple files in
  2350.  
  2351. a single operation.  Although some systems may not provide wildcard file
  2352.  
  2353. processing, the KERMIT protocol allows it.
  2354.  
  2355.   The CONNECT command provides the mechanism for logging in  and  typing
  2356.                                    47
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362. commands  at  the  remote host, which is necessary in order to start the
  2363.  
  2364. KERMIT on that side.  The CONNECT facility provides  character-at-a-time
  2365.  
  2366. transmission,  parity selection, remote or local eching, and the ability
  2367.  
  2368. to send any character, including the ``escape character'' that  must  be
  2369.  
  2370. used to get back to the local KERMIT.  However, there is no error detec-
  2371.  
  2372. tion  or  correction  during CONNECT, just as there normally is none be-
  2373.  
  2374. tween an ordinary terminal and a host.
  2375.  
  2376.   When two systems are dissimilar, a SET command is  provided  to  allow
  2377.  
  2378. them  to accommodate each other's peculiarities, for instance SET PARITY
  2379.  
  2380. ODD to add odd parity to all outbound characters, or SET  LOCAL-ECHO  to
  2381.  
  2382. do  local  echoing when connected as a terminal to a half duplex system.
  2383.  
  2384. The SET command must sometimes be used to supply information to the tar-
  2385.  
  2386. get system on how to store an incoming file with respect to block  size,
  2387.  
  2388. byte size, record format, record length.
  2389.  
  2390.   Most  KERMIT  implementations  take  special care to reassure the user
  2391.  
  2392. during file transfer.  The names of  the  files  being  transferred  are
  2393.  
  2394. shown, and a dynamic display is made of the packet traffic, showing suc-
  2395.  
  2396. cessful transmission of packets as well as timeouts and retransmissions.
  2397.  
  2398. Messages  are  issued when the user connects to the remote system or es-
  2399.  
  2400. capes back from it, and  KERMIT  prompts  identify  the  implementation.
  2401.  
  2402. Helpful  error  messages are displayed when necessary; these may emanate
  2403.  
  2404. from either the local or the remote system.  The  final  disposition  of
  2405.  
  2406. the transfer is clearly stated, complete or failed.
  2407.  
  2408.   The  actions  required  of  the  KERMIT user depend upon the degree to
  2409.                                    48
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415. which  the  KERMIT programs involved have implemented the specification.
  2416.  
  2417. Minimal implementations require that the  user  connect  to  the  remote
  2418.  
  2419. host, start KERMIT there, issue a SEND (or RECEIVE) command, escape back
  2420.  
  2421. to the local machine, and issue the complementary RECEIVE (or SEND) com-
  2422.  
  2423. mand.  All this must be done for each transfer.  More advanced implemen-
  2424.  
  2425. tations allow the remote side to run as a ``server'' and to take all its
  2426.  
  2427. instructions  in special command packets from the local KERMIT; all that
  2428.  
  2429. is required of the user on the remote end is to connect initially in or-
  2430.  
  2431. der to start the server.  The server will even log itself out upon  com-
  2432.  
  2433. mand  from  the  local KERMIT.  A minimal server can process commands to
  2434.  
  2435. send files, receive files, and shut itself down.
  2436.  
  2437.   Here is an example of a session in which the user of an  IBM  PC  gets
  2438.  
  2439. files  from  a DECSYSTEM-20.  The actions shown are required for minimal
  2440.  
  2441. KERMIT implementations.  The parts the user types are  underlined,  com-
  2442.  
  2443. ments  begin with ``!'' or appear in italics.  Everything else is system
  2444.  
  2445. typeout.
  2446.  
  2447.  
  2448.     A>kermit              ! Run Kermit on the PC.
  2449.     Kermit V1.20
  2450.  
  2451.     Kermit-86>            ! This is the Kermit prompt for the PC.
  2452.     Kermit-86>connect     ! Connect to the DEC-20.
  2453.     [Connecting to host. Type CTRL-]C to return to PC.]
  2454.  
  2455.                           ! You are now connected to the DEC-20.
  2456.     Columbia University CU20B                   ! The system prints its herald.
  2457.     @terminal vt52        ! Set your terminal type (optional).
  2458.     @login my-id password ! Login using normal login method.
  2459.  
  2460.     (The DEC-20 prints various messages.)
  2461.                                    49
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.     @kermit               ! Run Kermit on the DEC-20.
  2469.     Kermit-20>            ! This is Kermit-20's prompt.
  2470.     Kermit-20>send *.for  ! Send all FORTRAN files.
  2471.     ^]c                   ! Type the escape sequence to return to the PC.
  2472.     [Back at PC.]
  2473.     Kermit-86>receive     ! Tell the PC files are coming.
  2474.  
  2475.     (The progress of the transfer is shown continuously on the screen.)
  2476.  
  2477.     Transfer Complete.
  2478.     Kermit-86>connect     ! Get back to the DEC-20.
  2479.     [Connecting to host. Type CTRL-]C to return to PC.]
  2480.     Kermit-20>exit        ! Get out of Kermit-20.
  2481.     @logout               ! Logout from the DEC-20.
  2482.  
  2483.     Logged out Job 55, User MY-ID, Account MY-ACCOUNT, TTY 146,
  2484.       at 24-Apr-83 15:18:56,  Used 0:00:17 in 0:21:55
  2485.  
  2486.     ^]c                   ! Now "escape" back to the PC,
  2487.     [Back at PC.]
  2488.     Kermit-86>exit        ! and exit from the PC's Kermit.
  2489.  
  2490.  
  2491.   The session is somewhat simpler when the remote KERMIT is being run as
  2492.  
  2493. a  server.  The user must still CONNECT, log in, and start KERMIT on the
  2494.  
  2495. remote end, but need never  again  CONNECT  to  issue  subsequent  SEND,
  2496.  
  2497. RECEIVE,  EXIT,  or  LOGOUT  commands, even though many transactions may
  2498.  
  2499. take place.  All actions can be initiated from the PC.
  2500.                                    50
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506. * Advanced Features
  2507.  
  2508.  
  2509.   An  optional  feature  of  the  KERMIT  protocol  is  a special packet
  2510.  
  2511. designed to express the attributes of a file in a  compact  and  generic
  2512.  
  2513. manner.    The  receiver may either attempt to use the attributes to the
  2514.  
  2515. incoming file, or archive them for later use.   Attributes  include  not
  2516.  
  2517. only  file  characteristics  but also the intended disposition -- store,
  2518.  
  2519. print, submit for batch processing, send as mail, etc.   Other  optional
  2520.  
  2521. features  include  mechanisms  for gracefully interrupting, delaying, or
  2522.  
  2523. suspending operations in progress; alternate forms of packet data encod-
  2524.  
  2525. ing; filename conversion, local file management, raw  data  transmission
  2526.  
  2527. and capture; command macro definition, etc.
  2528.  
  2529.   Although  KERMIT  was  never intended to fulfill the role of a general
  2530.  
  2531. purpose network server, its design has made it simple to add  new  func-
  2532.  
  2533. tions.    A  KERMIT server has the ability to accept commands in packets
  2534.  
  2535. from a remote KERMIT.  The basic commands are for  sending  or  fetching
  2536.  
  2537. files and for shutting down the server.  Other commands may require dis-
  2538.  
  2539. play  of  text  at the user's terminal, which is controlled by the local
  2540.  
  2541. KERMIT.  For example,  a  directory  listing  could  be  requested;  the
  2542.  
  2543. resulting  text  is  sent  back to the local KERMIT exactly as if a file
  2544.  
  2545. were being transferred, except the destination  is  the  user's  screen,
  2546.  
  2547. rather  than  a  disk  file.  (Or it could be disk file too.)  With this
  2548.  
  2549. ability in place, it is possible to implement all sorts of commands, for
  2550.  
  2551. instance to delete a file, show who's  logged  in,  inquire  about  disk
  2552.                                    51
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558. space,  verify  access to a directory, submit batch jobs, send messages,
  2559.  
  2560. and so forth.
  2561.  
  2562.   The ability of the KERMIT server to perform host functions can be  ad-
  2563.  
  2564. ded  very  simply  under certain operating systems.  For instance, under
  2565.  
  2566. UNIX [17], KERMIT can ``fork'' a shell  with  commands  to  perform  any
  2567.  
  2568. function  possible under UNIX, redirecting the standard output through a
  2569.  
  2570. process (KERMIT itself) that encapsulates it  into  KERMIT  packets  and
  2571.  
  2572. sends it along.
  2573.  
  2574.   A  server with these capabilities could provide convenient access to a
  2575.  
  2576. timesharing system by users at personal workstations, without  requiring
  2577.  
  2578. the  users  to  be  directly  involved with the host.  If, for instance,
  2579.  
  2580. workstations had dedicated connections to a host, and the host had dedi-
  2581.  
  2582. cated KERMIT servers for each such line, users could get access  to  and
  2583.  
  2584. manage their host files completely by commands typed at the workstation.
  2585.  
  2586. Taking this idea one step further, the workstation system software could
  2587.  
  2588. be  modified  to  make  the whole process transparent by incorporating a
  2589.  
  2590. KERMIT-like protocol in its file access logic -- fetching  and  updating
  2591.  
  2592. host  files  as  necessary  behind  the  user's back.  Since the demands
  2593.  
  2594. placed on a host by KERMIT are relatively modest, many more simultaneous
  2595.  
  2596. users could probably be serviced in this way.  This approach could be  a
  2597.  
  2598. relatively  painless  entree into the distributed, networked environment
  2599.  
  2600. of tomorrow.  When local area network protocols become  mature  and  the
  2601.  
  2602. hardware economical and widespread, KERMIT can be replaced by ``the real
  2603.  
  2604. thing''.   But for the ordinary computer user for whom dedicated connec-
  2605.                                    52
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611. tions  are impractical, ``do-it-yourself'' KERMIT, or some facility like
  2612.  
  2613. it, will be a valuable tool for years to come.
  2614.  
  2615.  
  2616.  
  2617.  
  2618. * Conclusion
  2619.  
  2620.  
  2621.   The need for  a  cheap,  convenient  file  transfer  capability  among
  2622.  
  2623. diverse  systems  is  pressing,  and  there  are  certainly many efforts
  2624.  
  2625. similar to ours under way at many places.  We hope that this article may
  2626.  
  2627. contribute to those efforts; we don't claim to have the last word on any
  2628.  
  2629. of the issues raised here, and expect that this article may  flush  some
  2630.  
  2631. other  approaches  out  of  the  woodwork.    We have billed KERMIT as a
  2632.  
  2633. ``simple'' protocol; anyone who has read this  far  will  begin  to  ap-
  2634.  
  2635. preciate  what  must go into the more complicated protocols used in real
  2636.  
  2637. networks, or when ``integration'' of micro and mainframe is a major goal
  2638.  
  2639. -- demand paging of remote files, remote database  queries,  distributed
  2640.  
  2641. editing and computation.
  2642.  
  2643.   Meanwhile,  the  KERMIT  protocol has been proven successful, and con-
  2644.  
  2645. tinues to grow in popularity.  As of this writing, implementations exist
  2646.  
  2647. for more than 50 computer systems.  Some of the major ones include:
  2648.  
  2649.     Machine                Operating System       Language
  2650.     DECsystem-10           TOPS-10                MACRO-10
  2651.     DECSYSTEM-20           TOPS-20                MACRO-20
  2652.     IBM 370 Series         VM/CMS                 IBM Assembler
  2653.     VAX-11                 VMS                    Bliss-32
  2654.     VAX, SUN, PDP-11, etc  UNIX                   C
  2655.     PDP-11                 RT-11, RSX, RSTS       MACRO-11
  2656.     8080, 8085, or Z80     CP/M                   8080 ASM
  2657.     8086, 8088             PC DOS, MS DOS         IBM PC Assembler
  2658.     Apple II 6502          Apple DOS              DEC-10/20 CROSS
  2659.                                    53
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666. Some  of  these  have  been  contributed or enhanced by the institutions
  2667.  
  2668. listed in the acknowledgements, below.  No single implementation  neces-
  2669.  
  2670. sarily  includes all the features mentioned in this article, but all are
  2671.  
  2672. able to communicate at least at base level.  Additional  implementations
  2673.  
  2674. are in preparation, and present ones are being enhanced.
  2675.  
  2676.   Columbia  University  is  willing  to  provide  all  KERMIT  programs,
  2677.  
  2678. sources, manuals, and other documentation to computing centers, academic
  2679.  
  2680. or corporate, in return for a modest  fee  to  cover  costs  for  media,
  2681.  
  2682. printing,  postage,  labor, and computing resources.  Only magnetic tape
  2683.  
  2684. and listings can be shipped.  We cannot produce floppy  disks;  instruc-
  2685.  
  2686. tions  are  included for bootstrapping the microcomputer implementations
  2687.  
  2688. from the mainframe computers.  Details  will  be  provided  on  request;
  2689.  
  2690. write to:
  2691.  
  2692.  
  2693.     KERMIT Distribution
  2694.     Columbia University Center for Computing Activities
  2695.     7th Floor, Watson Laboratory
  2696.     612 West 115th Street
  2697.     New York, NY  10025
  2698.  
  2699.  
  2700.   The protocol specification supplemented by examples of existing KERMIT
  2701.  
  2702. implementations  allows  new implementations to be created with relative
  2703.  
  2704. ease.  In the past, KERMIT implementors  have  shared  their  work  with
  2705.  
  2706. other  KERMIT  users  by contributing it to the Columbia KERMIT library.
  2707.  
  2708. We hope that this practice will continue until KERMIT has spread through-
  2709.  
  2710. out the known world.
  2711.                                    54
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717. * Acknowledgements
  2718.  
  2719.  
  2720.   In  designing  the initial KERMIT protocol, we studied several models,
  2721.  
  2722. primarily  the  ANSI  recommendation [9].  other  include  the Stanford
  2723.  
  2724. University  DIALNET  project,  the  University  of  Utah  ``Small  FTP''
  2725.  
  2726. project,  and  the  Stanford  University  Medical Center TTYFTP project. 
  2727.  
  2728. And we examined some real networks, like ARPANET and DECnet.
  2729.  
  2730.   Acknowledgements also to the many sites that have contributed new KER-
  2731.  
  2732. MIT  implementations or enhanced old ones: Stevens Institute of Technol-
  2733.  
  2734. ogy, Digital Equipment Corporation, the National Institutes  of  Health,
  2735.  
  2736. Cornell  University,  the  University of Toronto, the University of Ten-
  2737.  
  2738. nessee, the University of Toledo, Cerritos College, and others.   Thanks 
  2739.  
  2740. to Dr. Howard Eskin for help with this article.
  2741.                                    55
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747. * The ASCII Alphabet
  2748.  
  2749.  
  2750. Dec Oct Character  Dec Oct
  2751. 000 000 NUL (^@)   064 100 @
  2752. 001 001 SOH (^A)   065 101 A
  2753. 002 002 STX (^B)   066 102 B
  2754. 003 003 ETX (^C)   067 103 C
  2755. 004 004 EOT (^D)   068 104 D
  2756. 005 005 ENQ (^E)   069 105 E
  2757. 006 006 ACK (^F)   070 106 F
  2758. 007 007 BEL (^G)   071 107 G
  2759. 008 010 BS  (^H)   072 110 H
  2760. 009 011 HT  (^I)   073 111 I
  2761. 010 012 LF  (^J)   074 112 J
  2762. 011 013 VT  (^K)   075 113 K
  2763. 012 014 FF  (^L)   076 114 L
  2764. 013 015 CR  (^M)   077 115 M
  2765. 014 016 SO  (^N)   078 116 N
  2766. 015 017 SI  (^O)   079 117 O
  2767. 016 020 DLE (^P)   080 120 P
  2768. 017 021 DC1 (^Q)   081 121 Q
  2769. 018 022 DC2 (^R)   082 122 R
  2770. 019 023 DC3 (^S)   083 123 S
  2771. 020 024 DC4 (^T)   084 124 T
  2772. 021 025 NAK (^U)   085 125 U
  2773. 022 026 SYN (^V)   086 126 V
  2774. 023 027 ETB (^W)   087 127 W
  2775. 024 030 CAN (^X)   088 130 X
  2776. 025 031 EM  (^Y)   089 131 Y
  2777. 026 032 SUB (^Z)   090 132 Z
  2778. 027 033 ESC (^[)   091 133 [
  2779. 028 034 FS  (^\)   092 134 \
  2780. 029 035 GS  (^])   093 135 ]
  2781. 030 036 RS  (^^)   094 136 ^
  2782. 031 037 US  (^_)   095 137 _
  2783. 032 040     (SP)   096 140 `
  2784. 033 041 !          097 141 a
  2785. 034 042 "          098 142 b
  2786. 035 043 #          099 143 c
  2787. 036 044 $          100 144 d
  2788. 037 045 %          101 145 e
  2789. 038 046 &          102 146 f
  2790. 039 047 '          103 147 g
  2791. 040 050 (          104 150 h
  2792. 041 051 )          105 151 i
  2793. 042 052 *          106 152 j
  2794.                                    56
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800. 043 053 +          107 153 k
  2801. 044 054 ,          108 154 l
  2802. 045 055 -          109 155 m
  2803. 046 056 .          110 156 n
  2804. 047 057 /          111 157 o
  2805. 048 060 0          112 160 p
  2806. 049 061 1          113 161 q
  2807. 050 062 2          114 162 r
  2808. 051 063 3          115 163 s
  2809. 052 064 4          116 164 t
  2810. 053 065 5          117 165 u
  2811. 054 066 6          118 166 v
  2812. 055 067 7          119 167 w
  2813. 056 070 8          120 170 x
  2814. 057 071 9          121 171 y
  2815. 058 072 :          122 172 z
  2816. 059 073 ;          123 173 {
  2817. 060 074 <          124 174 |
  2818. 061 075 =          125 175 }
  2819. 062 076 >          126 176 ~
  2820. 063 077 ?          127 177 DEL
  2821.                                    57
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827. * References
  2828.  
  2829.  
  2830.   The  following  publications  provided useful guidance or diversion in
  2831.  
  2832. the development of KERMIT.
  2833.  
  2834. [1]   EIA Standard RS-232-C
  2835.       Electronic Industries Association, 2001 Eye Street N.W.,
  2836.          Washington DC 20006, 1969, 1981.
  2837.  
  2838. [2]   ANSI X3.4-1977, Code for Information Interchange
  2839.       American National Standards Institute, 1430 Broadway, NYC 10018,
  2840.          1977.
  2841.  
  2842. [3]   ANSI X3.15-1976,
  2843.       Bit Sequencing of ASCII in Serial-By-Bit Data Transmission
  2844.       1976.
  2845.  
  2846. [4]   ANSI 3.16-1976, Character Structure and Character Parity Sense for
  2847.       Serial-By-Bit Data Communication in ASCII
  2848.       1976.
  2849.  
  2850. [5]   McNamara, J.E.
  2851.       Technical Aspects of Data Communication.
  2852.       Digital Press, 1982.
  2853.  
  2854. [6]   Mackenzie, C.E.
  2855.       Coded-Character Sets: History and Development.
  2856.       Addison-Wesley, 1980.
  2857.  
  2858. [7]   DNA Data Access Protocol (DAP) Functional Specification
  2859.       Digital Equipment Corporation, 1980.
  2860.       AA-K177A-TK.
  2861.  
  2862. [8]   Neigus, N.J.
  2863.       File Transfer Protocol for the ARPA Network
  2864.       Bolt Beranek and Newman, Inc., 1973.
  2865.       RFC 542, NIC 17759.  Available in the ARPANET Protocol Handbook,
  2866.          NTIS AD/A-052 594.
  2867.  
  2868. [9]   ANSI X3.28-1976, Procedures for the Use of Control Characters of
  2869.       ASCII in Specified Data Communications Links
  2870.       1976.
  2871.                                    58
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877. [10]  Pierce, J.R., and Posner, E.C.
  2878.       Applications of Communications Theory:  Introduction to Communica-
  2879.          tion Science and Systems.
  2880.       Plenum Press, 1980.
  2881.  
  2882. [11]  Knuth, D.E.
  2883.       The Art of Computer Programming.  Volume I:  Fundamental Al-
  2884.          gorithms.
  2885.       Addison-Wesley, 1973.
  2886.  
  2887. [12]  Hamming, R.W.
  2888.       Error Detecting and Error Correcting Codes.
  2889.       Bell System Technical Journal 29:147-160, April, 1950.
  2890.  
  2891. [13]  Martin, James.
  2892.       Teleprocessing Network Organization.
  2893.       Prentice-Hall, 1970.
  2894.  
  2895. [14]  Perez, Aram.
  2896.       Byte-wise CRC Calculations.
  2897.       IEEE MICRO 3(3):40-50, June, 1983.
  2898.  
  2899. [15]  ISO Reference Model for Open Systems Interconnection (OSI)
  2900.       International Organization for Standardization (ISO), 1982.
  2901.       Draft Proposal 7498.
  2902.  
  2903. [16]  DNA Digital Data Communications Message Protocol (DDCMP) Func-
  2904.       tional Specification
  2905.       Digital Equipment Corporation, 1980.
  2906.       AA-K175A-TK.
  2907.  
  2908. [17]  Thomas, R. and Yates, J.
  2909.       A User Guide to the UNIX System.
  2910.       OSBORNE/McGraw-Hill, 1982.
  2911.