home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / e / byte.mss < prev    next >
Text File  |  2020-01-01  |  87KB  |  1,624 lines

  1. @Comment(-*-SCRIBE-*-)
  2. @Comment(SCRIBE Text Formatter Input for the KERMIT Byte Article)
  3.  
  4. @Make<Text>
  5. @Use<Bibliography="byte.bib">
  6.  
  7. @Style<Justification On, Hyphenation On, WidestBlank 1.4, Spacing 2,
  8.         Spread 0.2, Indent 2, HyphenBreak Off, SingleSided>
  9. @Style<References=StdNumeric,BibSelect=Complete,Bibsequence=Numeric,
  10.     Citationtype=Brackets>
  11.  
  12. @Comment(Set desired spacing around various environments)
  13.  
  14. @Modify<Quotation,Indentation 0, Above 2, Below 2, Spacing 1.2, Spread 0.2>
  15. @Modify<Example, Above 2, Below 2, Blanklines Hinge, Spacing 1.2, Spread 0.2>
  16. @Modify<Verbatim,Above 2, Below 2, Leftmargin 0>
  17. @Modify<ProgramExample, Above 2, Below 2,Leftmargin 0, Spacing 1.2, Spread 0.2>
  18. @Modify<Description,Above 2,Below 2, Spacing 1.2,Spread 0.2>
  19. @Modify<Enumerate,Above 2,Below 2, Spacing 1.2,Spread 0.2>
  20. @Modify<Itemize,Above 2,Below 2, Spacing 1.2,Spread 0.5>
  21. @textform(dd="--")
  22. @define<Section,use B,above 3.5,below 2.2,need 6,break,indent 0,
  23.     initialize "* ">
  24. @define<Subsection,use I,above 2.5, below 2.2, need 4, break, indent 0,
  25.     initialize ". ">
  26. @define<Maxim=text,use I,above 2.2,below 2.2,leftmargin +4,rightmargin +4,
  27.     break, continue>
  28.  
  29. @Comment(Printing Device Dependencies)
  30.  
  31. @Define<Q,FaceCode R>
  32. @Case<Device,
  33.  LPT="@use(Auxfile='BYTMLP.AUX')
  34.     @Style(linewidth 72, PaperLength 11 inches,BottomMargin 5 spacings)
  35.     @Modify(ProgramExample,LongLines Keep)",
  36.  Printronix="@use(AuxFile='BYTMPX.AUX')
  37.     @Style(LineWidth 72, PaperLength 11 inches,BottomMargin 5 spacings)
  38.     @Modify(ProgramExample,LongLines Keep)",
  39.  PagedFile="@use(AuxFile='BYTMPF.AUX')
  40.     @Style(LineWidth 72, PaperLength 10.8 inches)
  41.     @Style(TopMargin 3 spacings,BottomMargin 6 Spacings)
  42.     @Modify(ProgramExample,LongLines Keep)
  43.     @Modify(Enumerate,Spread 1)",
  44.  Diablo="@Use(Auxfile='BYTDIA.AUX')
  45.     @TypeWheel(Titan 10)",
  46.  Imprint10="@Use(AuxFile='BYTIMP.AUX')
  47.     @Style<FontFamily SmallRoman12,Spacing 2.2,Spread 0.4,SingleSided>
  48.     @Define<Q,FaceCode U>
  49.     @Modify<Verbatim,FaceCode U>
  50.     @Modify<Example,FaceCode U>",
  51.  X9700="@Use<AuxFile='BYTX9.AUX'>
  52.     @Define<Q,FaceCode U>
  53.     @Modify(Verbatim,FaceCode U)
  54.     @Modify<Example,FaceCode U>
  55.     @Style<FontFamily Univers10>
  56.     @Use<HyphenDic=`KER:MANUAL.HYP'>",
  57.  Postscript="@Style<Spacing 1, Spread 1, Indent 0>
  58.     @textform{dd='@y[M]'}
  59.     @define<Section,use B,above 3.5,below 2.2,need 6,break,indent 0,
  60.     initialize '@y[B] '>
  61.     @define<Subsection,use I,above 2.5, below 2.2, need 4, break, indent 0,
  62.     initialize '@y[N] '>
  63.     @define<Maxim=text,use I,above 2.2,below 2.2,leftmargin +4,rightmargin +4,
  64.     break, continue>
  65.     @Define<Q,FaceCode T>
  66.     @Modify(Verbatim,FaceCode T)
  67.     @Modify(Example,FaceCode T)
  68.     @Style(FontFamily TimesRoman10,fontscale 10.5)"
  69.  >
  70. @set<page=1>
  71. @begin(center)
  72. @MajorHeading(KERMIT)
  73.  
  74. @Heading<A Simple File Transfer Protocol for Microcomputers and Mainframes>
  75.  
  76. @blankspace(1.5)
  77. Frank da Cruz,@ @ Bill Catchings
  78. @blankspace(0.5)
  79. Columbia University Center for Computing Activities
  80. New York, N.Y.  10027
  81. @i<May 1983>@foot<This is the original manuscript of the article
  82. published in BYTE Magazine as "Kermit: A File Transfer Protocol for
  83. Universities", June and July 1984.  Some minor editorial differences exist
  84. between this manuscript and the article as published.  The Kermit file transfer
  85. protocol is named after Kermit the Frog, star of the television series THE
  86. MUPPET SHOW, used by permission of Henson Associates, Inc.>
  87. @end(center)
  88. @blankspace(0.5inch)
  89.  
  90. During recent years, the technical press has focused a lot of attention on
  91. developments in computer networking@dd()the IEEE 802 committee, TCP/IP, SNA,
  92. the latest VLSI Ethernet interface, fibre optics, satellite
  93. communications, broadband versus baseband.  But little attention
  94. has been given to the single mechanism that may be the most widely used
  95. in the real world for direct interprocessor communication: the so-@|called
  96. ``asynchronous protocol'', which is to be found in some form at almost every
  97. institution where there is a need to transfer files between microcomputers and
  98. central computers.
  99.  
  100. Columbia University is such an institution.  Large timesharing computers at a
  101. central site are complemented by many smaller systems scattered in the
  102. laboratories and departments.  The past few years have witnessed the inexorable
  103. progress of diverse microcomputers, word processors, and professional
  104. workstations into offices and laboratories throughout the University, and into
  105. the homes or dormitory rooms of faculty, students, and staff.  As soon as these
  106. small machines began to appear, their users asked for ways to exchange files
  107. with the central and departmental systems.
  108.  
  109. At the same time, student use of our central systems was growing at an
  110. astonishing rate.  We could no longer afford to provide students with perpetual
  111. online disk storage; we began to issue IDs per course, per term.  With the
  112. decreased longevity of the IDs came the need for students to economically
  113. archive their files.  Given a reliable way to from the central mainframes and
  114. back, microcomputers with floppy disks could provide inexpensive removable
  115. media ideal for this purpose.
  116.  
  117. The situation called for a file transfer mechanism that could work among all
  118. our computers, large and small.  We knew of none that could handle the required
  119. diversity.  Some were intended for use between microcomputers, others between
  120. large computers, but none specifically addressed the need for communication
  121. among the widest possible range of computers, particularly between micros and
  122. our IBM and DEC mainframes.  Most commercial packages served a limited set of
  123. systems, and their cost would have been prohibitive when multiplied by the
  124. large number of machines we needed to support.
  125.  
  126. So we embarked on our own project.  We were not well-@|versed in these matters
  127. at the outset; we learned as we proceeded, and we're still learning.  This
  128. article discusses some of the issues and tradeoffs that came up in the design,
  129. and illustrates them in terms of our result, the KERMIT protocol for
  130. point-@|to-@|point file transfer over telecommunication lines.  Because
  131. commercial local area networking products are expensive, not yet widely
  132. available, and unsuitable for one-@|shot or long-@|haul applications, humble
  133. asynchronous protocols such as KERMIT are likely to be with us for a long time
  134. to come.
  135.  
  136. It is assumed the reader is familiar with common computing and
  137. telecommunications terminology, and with the ASCII alphabet, which is listed
  138. at the end of this article for reference.
  139.  
  140. @section(The Communication Medium)
  141.  
  142. The only communication medium common to all computers, large and small, is the
  143. asynchronous serial telecommunication line, used for connecting terminals to
  144. computers.  Standards for this medium are
  145. almost universally followed@dd()connectors, voltages, and signals (EIA RS-232-C
  146. @cite<--RS232>), character encoding (ASCII, ANSI X3.4-1977 @cite<--A34>), and
  147. bit transmission sequence (ANSI X3.15-1976 @cite<--A315,--A316>).  Serial
  148. connections can be made in many ways: dedicated local lines (``null modem''
  149. cables), leased telephone circuits, dialup connections.  Dialup connections
  150. can be initiated manually from the home or office using an inexpensive acoustic
  151. coupler, or automatically from one computer to another using a programmable
  152. dialout mechanism.  The asynchronous serial line offers the ordinary user a
  153. high degree of convenience and control in establishing intersystem connections,
  154. at relatively low cost.
  155.  
  156. Once two computers are connected with a serial line, information can be
  157. transferred from one machine to the other, provided one side can be instructed
  158. to send the information and the other to receive it.  But right away, several
  159. important factors come into play:
  160. @Begin(Enumerate)
  161. @i<Noise>@dd()It is rarely safe to assume that there will be no electrical
  162. interference on a line; any long or switched data communication line will have
  163. occasional interference, or noise, which typically results in garbled or extra
  164. characters.  Noise corrupts data, perhaps in subtle ways that might not be
  165. noticed until it's too late.
  166.  
  167. @i<Synchronization>@dd()Data must not come in faster than the receiving machine
  168. can handle it.  Although line speeds at the two ends of the connection may
  169. match, the receiving machine might not be able to process a steady stream of
  170. input at that speed.  Its central processor may be too slow or
  171. too heavily loaded, or its buffers too full or too small.  The typical symptom
  172. of a synchronization problem is lost data; most operating systems will simply
  173. discard incoming data they are not prepared to receive.
  174.  
  175. @i<Line Outages>@dd()A line may stop working for short periods because of
  176. a faulty connector, loss of power, or similar reason.  On dialup or switched
  177. connections, such intermittent failures will cause carrier to drop and the
  178. connection to be closed, but for any connection in which the carrier signal is
  179. not used, the symptom will be lost data.
  180. @End(Enumerate)
  181. Other communication media, such as the parallel data bus, have safeguards
  182. built in to prevent or minimize these effects.  For instance, distances may be
  183. strictly limited, the environment controlled; special signals may be available
  184. for synchronization, and so forth.  The serial telecommunication line provides
  185. no such safeguards, and we must therefore regard it as an intrinsically
  186. unreliable medium.
  187.  
  188. @Section(Getting Reliable Communication over an Unreliable Medium)
  189.  
  190. To determine whether data has been transmitted between two machines
  191. correctly and completely, the
  192. two machines can compare the data before and after transmission.
  193. A scheme that is commonly used for file transfer employs
  194. cooperating programs running simultaneously on each machine, communicating in a
  195. well-@|defined, concise language.  The sending program divides outbound data
  196. into discrete pieces, adding to each piece special information describing the
  197. data for the receiving program.  The result is called a ``packet''.  The
  198. receiver separates the description from the data and determines whether
  199. they still match.  If so, the packet is acknowledged and the transfer proceeds.
  200. If not, the packet is ``negatively acknowledged'' and the sender retransmits
  201. it; this procedure repeats for each packet until it is received correctly.
  202.  
  203. The process is called a communication @i<protocol>@dd()a set of rules for
  204. forming and transmitting packets, carried out by programs that embody those
  205. rules.  Protocols vary in complexity; our preference was for a simple approach
  206. that could be realized in almost any language on almost any computer by a
  207. programmer of moderate skill, allowing the protocol to be adapted easily to new
  208. systems.
  209.  
  210. @Section(Accommodating Diverse Systems)
  211.  
  212. Most systems agree how to communicate at the lowest levels@dd()the EIA RS-232-C
  213. asynchronous communication line and the ASCII character set@dd()but there is
  214. rarely agreement beyond that.  To avoid a design that might lock out some kinds
  215. of systems, we must consider certain important ways in which systems can
  216. differ.
  217.  
  218. @SubSection(Mainframes vs Micros)
  219.  
  220. A distinction must first be made between @i<micros> and @i<mainframes>.  These
  221. terms are not used perjoratively; a ``micro'' could be a powerful workstation,
  222. and a ``mainframe'' could be a small minicomputer.  For our purposes, a
  223. micro is any single-@|user system in which the serial communication port is
  224. strictly an external device.  A mainframe is any system which is ``host'' to
  225. multiple simultaneous terminal users, who log in to ``jobs'', and where a
  226. user's terminal is the job's ``controlling terminal''.  Some mainframe systems
  227. allow users to ``assign'' another terminal line on the same machine as an
  228. external input/@|output device.
  229.  
  230. Mainframe operating system terminal drivers usually treat a job's controlling
  231. terminal specially.  Full duplex systems echo incoming characters on the
  232. controlling terminal, but not on an assigned line.  System command interpreters
  233. or user processes might take special action on certain characters on the
  234. controlling line, but not on an assigned line (for instance, control-C under
  235. CP/M or most DEC operating systems).  Messages sent to a job's controlling
  236. terminal from other jobs could interfere with transmission of data.  The
  237. ability of a system to test for the availability of input on a serial line
  238. might depend on whether the line is the job's controlling terminal or an
  239. assigned device; CP/M and IBM VM/370 are examples of such systems.
  240. CP/M can test for data @i<only> at the console, VM can test @i<anywhere but>
  241. the console.
  242.  
  243. Output to a job's controlling terminal may be reformatted by the operating
  244. system: control characters may be translated to printable equivalents, lower
  245. case letters specially flagged or translated to upper case (or vice versa),
  246. tabs expanded to spaces.  In addition, based on the terminal's
  247. declared ``width'' and ``length'', long lines might be ``wrapped around'' or
  248. truncated, formfeeds translated to a series of linefeeds, and the system may
  249. want to pause at the end of each screenful of output.  Input from a job's
  250. controlling terminal may also be handled specially: lower case letters may be
  251. converted to upper case, linefeed may be supplied when carriage return is
  252. typed, control characters may invoke special functions like line editing or
  253. program interruption.  The DECSYSTEM-20 is an example of a computer where any
  254. of these might happen.
  255.  
  256. The moral here is that care must be taken to disable special handling of a
  257. mainframe job's controlling terminal when it is to be a vehicle for
  258. interprocessor communication.  But some systems simply do not allow
  259. certain of these features to be disabled, so file transfer protocols must be
  260. designed around them.
  261.  
  262. @SubSection(Line Access)
  263.  
  264. Line access can be either @i<full> or @i<half duplex>.  If full duplex,
  265. transmission can occur in both directions at once.  If half duplex, the two
  266. sides must take turns sending, each signaling the other when the line is free;
  267. data sent out of turn is discarded, or it can cause a break in
  268. synchronization.  On mainframes, the host echoes characters typed at the
  269. terminal in full duplex, but not in half duplex.  Naturally, echoing is
  270. undesirable during file transfer.  Full duplex systems can usually accommodate
  271. half duplex communication, but not vice versa.  IBM mainframes are the most
  272. prevalent half duplex systems.
  273.  
  274. @SubSection(Buffering and Flow Control)
  275.  
  276. Some systems cannot handle sustained bursts of input on a telecommunications
  277. line; the input buffer can fill up faster than it can be emptied, especially at
  278. high line speeds.  Some systems attempt to buffer ``typeahead'' (unrequested
  279. input), while others discard it.  Those that buffer typeahead may or may not
  280. provide a mechanism to test or clear the buffer.
  281.  
  282. Systems may try to regulate how fast characters come in using a
  283. @i<flow control> mechanism, either in the data stream (XON/XOFF) or in
  284. parallel to it (modem control signals) @cite<--mcn>, but no two systems can be
  285. assumed to honor the same conventions for flow control, or to do it at all.
  286. Even when flow control is being done, the control signals themselves are
  287. subject to noise corruption.
  288.  
  289. Our experiments with several host computers revealed that a burst of more than
  290. about a line's worth of characters (60-100 characters) into a terminal port at
  291. moderate speed could result in loss of data@dd()or worse@dd()on some hosts.  For
  292. instance, the communications front end of the DECSYSTEM-2060 is designed on the
  293. statistical assumption that all terminal input comes from human fingers, and it
  294. cannot allocate buffers fast enough when this assumption is violated by sending
  295. continuous data simultaneously from several microcomputers attached to terminal
  296. ports.
  297.  
  298. @SubSection(Character Interpretation)
  299.  
  300.  Systems can differ in how they interpret characters that arrive
  301. at the terminal port.  A host can accept some characters as sent, ignore
  302. others, translate others, take special action on others.  Communications front
  303. ends or multiplexers might swallow certain characters (typically DC1, DC3) for
  304. flow control, padding (NUL or DEL), or for transfer of control (``escape'').
  305. The characters that typically trigger special behavior are the ASCII control
  306. characters, 0-31 and 127.  For instance, of these 33 control characters, 17
  307. invoke special functions of our DECSYSTEM-20 command processor.  However, all
  308. hosts and communication processors we've encountered allow any ``printable''
  309. character (ASCII 32-126) to reach an application program, even though the
  310. character may be
  311. translated to a different encoding, like EBCDIC @cite<--EBCDIC>, for internal
  312. use.
  313.  
  314. Some operating systems allow an application to input a character at a time,
  315. others delay passing the characters to the program until a ``logical record''
  316. has been detected, usually a sequence of characters terminated by carriage
  317. return or linefeed.  Some record oriented systems like IBM VM/370 discard the
  318. terminator, others keep it.  And there are different ways of keeping it@dd()UNIX
  319. translates carriage return into linefeed; most DEC operating systems keep the
  320. carriage return but also add a linefeed.
  321.  
  322. @SubSection(Timing Out)
  323.  
  324. Hosts may or may not have the ability to ``time out''.  When exchanging
  325. messages with another computer, it is desirable to be able to issue an input
  326. request without waiting forever should the incoming data be lost.  A
  327. lost message could result in a protocol ``deadlock'' in which one system is
  328. waiting forever for the message while the other waits for a
  329. response.  Some systems can set timer interrupts to allow escape from
  330. potentially blocking operations; others, including many microcomputers, can
  331. not do so.  When timeouts are not possible, they may be simulated by
  332. sleep-@|and-@|test or loop-@|and-@|test operations, or deadlocked systems may
  333. be awakened by manual intervention.
  334.  
  335. @SubSection(File Organization)
  336.  
  337. Some computers store all files in a uniform way, such as the linear stream of
  338. bytes that is a UNIX file.  Other computers may have more complicated or
  339. diverse file organizations and access methods: record-@|oriented storage with
  340. its many variations, exemplified in IBM OS/360 or DEC RMS.  Even simple
  341. microcomputers can present complications when files are treated as uniform
  342. data to be transferred; for instance under CP/M, the ends of binary and text
  343. files are determined differently.  A major question in any operating system is
  344. whether a file is specified sufficiently by its contents and its name, or if
  345. additional external information is required to make the file valid.  A simple
  346. generalized file transfer facility can be expected to transmit a file's name
  347. and contents, but not every conceivable attribute a file might possess.
  348.  
  349.  Designers of expensive networks have gone to great lengths to pass file
  350. attributes along when transferring files between unlike systems.  For instance,
  351. the DECnet Data Access Protocol @cite<--DAP> supports 42 different ``generic
  352. system capabilities'' (like whether files can be preallocated, appended to,
  353. accessed randomly, etc), 8 data types (ASCII, EBCDIC, executable, etc), 4
  354. organizations (sequential, relative, indexed, hashed), 5 record formats (fixed,
  355. variable, etc), 8 record attributes (for format control), 14 file allocation
  356. attributes (byte size, record size, block size, etc), 28 access options
  357. (supersede, update, append, rewind, etc), 26 device characteristics (terminal,
  358. directory structured, shared, spooled, etc), various access options (new, old,
  359. rename, password, etc), in addition to the better known file attributes like
  360. name, creation date, protection code, and so on.  All this was deemed necessary
  361. even when the designers had only a small number of machines to worry about, all
  362. from a single vendor.
  363.  
  364. The ARPA network, which attempts to provide services for many more machines
  365. from many vendors, makes some simplifying assumptions and sets some
  366. restrictions in its File Transfer Protocol (FTP) @cite<--ARPA>.  All files are
  367. forced into certain categories with respect to encoding (ASCII, EBCDIC, image),
  368. record format control, byte size, file structure (record or stream), and it is
  369. generally left to the host FTP implementation to do the necessary
  370. transformations.  No particular provision is made, or can be made, to ensure
  371. that such transformations are invertible.
  372.  
  373. DECnet is able to provide invertibility for operating systems like VMS or RSX,
  374. which can store the necessary file attributes along with the file.  But simpler
  375. file systems, like those of TOPS-10 or TOPS-20, can lose vital information
  376. about incoming files.  For instance, if VMS
  377. requires some type of file to have a specific blocksize, while TOPS-20
  378. has no concept of block size, then the blocksize will be
  379. lost upon transfer from VMS to TOPS-20 and cannot be restored automatically
  380. when the file is sent back, leaving the result potentially unusable.
  381.  
  382. Invertibility is a major problem, with no simple solution.
  383. Fortunately, most file transfer between unlike systems involves only textual
  384. information@dd()data, documents, program source@dd()which is sequential in
  385. organization, and for which any required transformations (e.g.@ blocked to
  386. stream, EBCDIC to ASCII) are simple and not dependent on any special
  387. file attributes.
  388.  
  389. In fact, invertability @i<can> be achieved if that is the primary goal of a
  390. file transfer protocol.  All the external attributes of a file can be encoded
  391. and included with the contents of the file to be stored on the remote system.
  392. For unlike systems, this can render the file less than useful on the target
  393. system, but allows it to be restored correctly upon return.  However, it
  394. is more commonly desired that textual files remain intelligible when
  395. transferred to a foreign system, even if transformations must be made.  To
  396. allow the necessary transformations to take place on textual files between
  397. unlike systems, there must be a standard way of representing these files during
  398. transmission.
  399.  
  400. @SubSection(Binary Files versus Parity)
  401.  
  402. Each ASCII character is represented by a string of 7 bits.  Printable ASCII
  403. files can be transmitted in a straightforward fashion, because ASCII
  404. transmission is designed for them: a serial stream of 8-bit characters, 7 bits
  405. for data and 1 for parity, framed by start and stop bits for the benefit of
  406. the hardware@cite(--A315).  The parity bit is added as a check on the integrity
  407. of a character; some systems always transmit parity, others insist on
  408. parity for incoming characters, still others ignore the parity bit for
  409. communication purposes and pass it along to the software, while still others
  410. discard it altogether.  In addition, communication front ends or common
  411. carriers might usurp the parity bit, regardless of what the system itself may
  412. do.
  413.  
  414. Computer file systems generally store an ASCII file as a sequence of either
  415. 7-bit or 8-bit bytes.  8-bit bytes are more common, in which the 8th bit of
  416. each byte is superfluous.  Besides files composed of ASCII characters,
  417. however, computers also have ``binary'' files, in which every bit is
  418. meaningful; examples include executable ``core images'' of programs, numbers
  419. stored in ``internal format'', databases with imbedded pointers.  Such binary
  420. data must be mapped to ASCII characters for transmission over serial
  421. lines.  When two systems allow the user-@|level software to control the parity
  422. bit, the ANSI standards @cite<--A34,--A315> may be stretched to permit the
  423. transmission of 8 data bits per character, which corresponds to the byte size
  424. of most machines.  But since not all computers allow this flexibility, the
  425. ability to transfer binary data in this fashion cannot be assumed.
  426.  
  427. @SubSection(Software)
  428.  
  429. Finally, systems differ in the application software they have.  In particular,
  430. no system can be assumed to have a particular programming language.  Even
  431. widespread languages like FORTRAN and BASIC may be lacking from some computers,
  432. either because they have not been implemented, or because they are proprietary
  433. and have not been purchased.  Even when two different systems support the same
  434. language, it is unrealistic to expect the two implementations of the language
  435. to be totally compatible.  A general purpose file transfer protocol should
  436. not be geared towards the features any particular language.
  437.  
  438. @Section(KERMIT)
  439.  
  440. Our protocol, which we call KERMIT, addresses the problems outlined above by
  441. setting certain minimal standards for transmission, and providing a mapping
  442. between disk storage organization, machine word and byte size, and the
  443. transmission medium.
  444.  
  445. KERMIT has the following characteristics:
  446. @begin<itemize>
  447. Communication takes place over ordinary terminal connections.
  448.  
  449. Communication is half duplex.  This allows both full and half duplex systems to
  450. participate, and it eliminates the echoing that would otherwise occur for
  451. characters arriving at a host job's controlling terminal.
  452.  
  453. The packet length is variable, but the maximum is 96
  454. characters so that most hosts can take packets in without buffering problems.
  455.  
  456. Packets are sent in alternate directions; a reply is required for each
  457. packet.  This is to allow half duplex systems to participate, and to prevent
  458. buffer overruns that would occur on some systems if packets were sent back to
  459. back.
  460.  
  461. A timeout facility, when available, allows transmission to resume after lost
  462. packets.
  463.  
  464. All transmission is in ASCII.  Any non-ASCII hosts are responsible for
  465. conversion.  ASCII control characters are prefixed and then converted to
  466. printable characters during transmission to ensure that they arrive as sent.  A
  467. single ASCII control character (normally SOH) is used to mark the beginning of
  468. a packet.
  469.  
  470. Binary files can be transmitted by a similar prefix scheme, or by use of the
  471. parity bit when both sides have control of it.
  472.  
  473. Logical records (lines) in textual files are terminated during transmission
  474. with quoted carriage-@|return/@|linefeed sequences, which are transparent to
  475. the protocol and may appear anywhere in a packet.  Systems that delimit records
  476. in other ways are responsible for conversion, if they desire the distinction
  477. between records to be preserved across unlike systems.
  478.  
  479. Only a file's name and contents are transmitted@dd()no attributes.  It is the
  480. user's responsibility to see that the file is stored correctly on the target
  481. system.  Within this framework, invertible transfer of text files can be
  482. assured, but invertible transfer of non-@|text files depends on the
  483. capabilities of the particular implementations of KERMIT and the host
  484. operating systems.
  485.  
  486. KERMIT has no special knowledge of the host on the other side.  No attempt
  487. is made to ``integrate'' the two sides.  Rather, KERMIT is designed to
  488. work more or less uniformly on all systems.
  489.  
  490. KERMIT need not be written in any particular language.  It is not a portable
  491. program, but a portable protocol.
  492. @end<itemize>
  493.  
  494.  Thus KERMIT accommodates itself to many systems by conforming to a common
  495. subset of their features.  But the resulting simplicity and generality allow
  496. KERMIT on any machine to communicate with KERMIT on any other machine,
  497. micro-@|to-@|mainframe, micro-@|to-@|micro, mainframe-@|to-@|mainframe.  The
  498. back-@|and-@|forth exchange of packets keeps the two sides synchronized; the
  499. protocol can be called ``asynchronous'' only because the communication
  500. hardware itself operates asynchronously.
  501.  
  502. As far as the user is concerned, KERMIT is a do-@|it-@|yourself operation.  For
  503. instance, to transfer files between your micro and a mainframe, you would run
  504. KERMIT on your micro, put KERMIT into terminal emulation mode, which
  505. ``connects'' you to the mainframe, log in and run KERMIT on the mainframe,
  506. then ``escape'' back to the micro and issue commands to the micro's KERMIT to
  507. send or fetch the desired files.  Any inconvenience implicit in this procedure
  508. is a consequence of the power it gives the ordinary user to establish reliable
  509. connections between computers that could not otherwise be connected.
  510.  
  511. @Section(Packets)
  512.  
  513. KERMIT packets need to contain the data that is being transferred, plus minimum
  514. information to assure (with high probability) that the expected data arrives
  515. completely and correctly.  Several issues come up when designing the packet
  516. layout: how to represent data, how to delimit fields within the packet, how to
  517. delimit the packet itself, how to arrange the fields within the packet.  Since
  518. the transmission medium itself is character-@|oriented, it is not feasible to
  519. transmit bit strings of arbitrary length, as do the bit-@|oriented protocols
  520. like HDLC and SDLC @cite<--MCN>.  Therefore the smallest unit of information in
  521. a packet must be the ASCII character.  As we will see, this precludes some
  522. techniques that are used with other communication media.
  523.  
  524. @SubSection(Control Fields)
  525.  
  526. Most popular protocol definitions view the packet as layers of
  527. information, which pass through a hierarchy of protocol levels, each level
  528. adding its own information at the ends of an outbound packet or stripping its
  529. information from the ends of an incoming packet, and then passing the result
  530. along to the next level in the hierarchy.  The fields for each layer must be
  531. arranged so that they can be found, identified, and interpreted correctly at
  532. the appropriate level.
  533.  
  534. Since KERMIT packets are short, it is important to minimize the amount
  535. of control information per packet.  It would be convenient to limit the control
  536. fields to one character each.  Since we have 95 printable characters to work
  537. with (128 ASCII characters, less DEL and the 32 control characters), we can
  538. represent values from 0 to 94 with a single character.
  539. @Begin(Itemize)
  540. The @i<packet sequence number> is used to detect missing or duplicate packets.
  541. It is unlikely that a large number of packets could be lost, especially since
  542. packet @i<n> is acknowledged before packet @i<n+1> is sent.  So the
  543. sequence number can be a small quantity, which ``wraps around'' to its minimum
  544. value when it exceeds a specified maximum value.
  545.  
  546. To prevent long packets, a small maximum length can be enforced
  547. by specifying the @i<packet length> with a single character; since there are 95
  548. printable ASCII characters, this would be the maximum length,
  549. depending on how we count the control fields.
  550.  
  551. The @i<checksum> can be of fixed length.  The actual length depends on the
  552. desired balance between and efficiency and error detection.
  553. @End(Itemize)
  554.  
  555. The packet length and checksum act together to detect corrupted, missing, or
  556. extra characters.  These are the essential fields for promoting error-@|free
  557. transmission.  But so far, we've only considered packets that carry actual file
  558. data; we will also require special packets composed only of control
  559. information, for instance to tell the remote host the name of the file that is
  560. about to come, or to tell it that the transmission is complete.  This can be
  561. accomplished with a @i<packet type> field.  The number of
  562. functions we need to specify in this field is small, so a single character can
  563. suffice here too.
  564.  
  565. @SubSection(Packet Framing)
  566.  
  567. We choose to mark the beginning of a packet with a distinguished start
  568. character, SOH (Start Of Header, @w<ASCII 1>, Control-A).  This character
  569. cannot appear anywhere else within the packet.  SOH was chosen because, unlike
  570. most other control characters, it is generally accepted upon input at a job's
  571. controlling terminal as a data character, rather than an interrupt or break
  572. character on most mainframes.  This is probably no accident, since it was
  573. originally intended for this use by the designers of the ASCII
  574. alphabet@cite<--A328>.  Should a system be incapable of sending or receiving
  575. SOH, it is possible to redefine the start-@|of-@|packet character to be any
  576. other control character; the two sides need not use the same one.
  577.  
  578. There are three principal options for recognizing the end of a packet:
  579. a fixed length, a distinguished packet-@|end character, and
  580. a length field.  There are arguments for and against each involving what
  581. happens when characters, particularly a length or terminator, is lost or
  582. garbled, which will be mentioned later.  KERMIT uses a length field.
  583.  
  584. To take in a packet, a KERMIT program gets characters from the line until it
  585. encounters the SOH.  The next character is the length; KERMIT reads and decodes
  586. the length and then reads that many subsequent characters to complete the
  587. packet.  If another SOH is encountered before the count is exhausted, the
  588. current packet is forgotten and a new one is started.  This stratagy allows
  589. arbitrary amounts of noise to be generated spontaneously between
  590. packets without interfering with the protocol.
  591.  
  592. @SubSection(Encoding)
  593.  
  594. When transmitting textual data, KERMIT terminates logical records with
  595. carriage-@|return linefeed combinations (CRLFs).  On record oriented systems,
  596. trailing blanks or length fields are removed and a CRLF appended to outbound
  597. records, with the inverse operation performed on incoming records.  On stream
  598. oriented systems, incoming CRLFs may be translated to some other terminator.
  599. Files, of course, need not have logical records, in which case record
  600. processing can be skipped altogether, and the file can be treated as a long
  601. string of bytes.  This is known as ``image'' transfer, and can also be used
  602. between like systems where no transformations are necessary.
  603.  
  604. In order to make each character in the packet printable, KERMIT ``quotes'' any
  605. unprintable character by transforming it to a printable one and precedes it
  606. with a special prefix character.  The prefix is normally ``#''; the
  607. transformation is done by complementing bit 6 (adding or subtracting 64@-<10>,
  608. modulo 64).  Thus control-A becomes ``#A'',
  609. control-Z becomes ``#Z'', US (control-@|underscore on most terminals) becomes
  610. ``#_''.  The prefix character is also used to quote itself: ``##''.  Upon
  611. input, the reverse transformation is performed.  Printable characters are not
  612. tranformed.  The assumption is that most files to be transferred are printable,
  613. and printable files contain relatively few control characters;
  614. when this is true, the character stream is not significantly lengthened by
  615. quoting.  For binary files, the average quoting overhead will be 26.6% if all
  616. bit patterns are equally likely, since the characters that must be quoted (the
  617. control characters, plus DEL, and ``#'' itself) comprise 26.6% of the ASCII
  618. alphabet.
  619.  
  620. KERMIT also provides a scheme for indicating the status of the 8th bit when
  621. transferring binary files between systems that must use the 8th bit for parity.
  622. A byte whose 8th bit is set is preceded by another special quoting character,
  623. ``&''.  If the low-@|order 7 bits coincide with an ASCII control character,
  624. then control-@|character quoting is also done.  For instance, the byte
  625. 10000001@-<2> would be transmitted as ``&#A''.  The ``&'' character itself can
  626. be included as data by quoting it (#&), and the control-@|quote character may
  627. have its 8th bit set (&##).  8th-bit quoting is only done when necessary; if
  628. both sides can control the parity bit, then its value is preserved during
  629. transmission.  If the 8th bit is set randomly on binary files, then 8th-bit
  630. quoting will add 50% character overhead.  For some kinds of binary data, it
  631. could be less; for instance, positive binary numbers in 2's complement notation
  632. do not to have their high-@|order bits set, in which case at least one byte per
  633. word will not be quoted.
  634.  
  635. A third kind of ``quoting'' implements rudimentary data compression.  At low
  636. speeds, the bottleneck in file transmission is likely to be the line itself, so
  637. any measure that can cut down on use of the line would be welcome.  The special
  638. prefix character ``~'' indicates that the next character is a repeat count (a
  639. single character, encoded printably) and that the character after that (which
  640. may also have control or 8th-bit prefixes) is repeated so many times.  For
  641. instance ``~}A'' indicates a series of 93 letter A's; ``~H&#B'' indicates
  642. a series of 40 control-B's with the parity bit set.  The repeat count
  643. prefix itself can be included as text by quoting it with ``#''.
  644.  
  645. To keep the protocol simple, no other transformations are done.  At this point,
  646. however, it might be worth mentioning some things we did @i(not) do to the
  647. data:
  648. @Begin(Itemize)
  649. @i(Fancy Data compression).  If the data is known to be (or
  650. resemble) English text, a Huffman encoding @cite(--HUF,--DEK) based on the
  651. frequency of characters in English text could be used.  A Huffman code
  652. resembles Morse code, which has variable length characters whose boundaries
  653. can always be distinguished.  The more frequent the character, the shorter the
  654. bit string to represent it.  Of course, this scheme can backfire if the
  655. character distribution of the data is very different from the one assumed.
  656. In any case, variable length characters and ASCII transmission don't mix well.
  657.  
  658. @i(Error Correcting Codes).  Techniques, such as Hamming codes @cite<--HAM>,
  659. exist for detecting and correcting errors on a per-@|character basis.  These
  660. are expensive in resources and complex to program.  KERMIT uses per-@|packet
  661. block check techniques, which are explained below.
  662.  
  663. @i(Nibble Encoding).  To circumvent problems with control and 8-bit characters,
  664. it would have been possible to divide every character into two 4-bit
  665. ``nibbles'', sending each nibble as a printable character (e.g.@ a hexadecimal
  666. digit).  The character overhead caused by this scheme would would always be
  667. 100%.  But it would be an easy way to transfer binary files.
  668. @End(Itemize)
  669.  
  670. @SubSection(Error Detection)
  671.  
  672. Character parity and Hamming codes are forms of ``vertical redundancy checks''
  673. (VRCs), formed by combining all the bits of a character in one way or another.
  674. The other kind of check that can be used is the ``longitudinal redundancy
  675. check'' (LRC), which produces a ``block check character'' formed by some
  676. combination of each character within a sequence.  The sending side computes the
  677. LRC and sends it with the packet; the receiving side recomputes it for
  678. comparison.  There are various forms of LRCs.  One form produces a ``column
  679. parity'' character, or ``logical sum'', whose bits are the exclusive-@|ORs of
  680. the corresponding bits of the data characters.  Another is the ``checksum''
  681. which is the arithmetic sum of all the characters in the sequence, 
  682. interpreted numerically.  Another is the ``Cyclic Redundancy Check'' (CRC)
  683. @cite<--MAR,--PRZ>, which passes the characters through what amounts to a shift
  684. register with imbedded feedback loops, producing a block check in which each
  685. bit is effected in many ways by the preceding characters.
  686.  
  687. All of these techniques will catch single-@|bit errors.  They vary in their
  688. ability to detect other kinds of errors.  For instance, a double-@|bit column
  689. error will always go undetected with column parity, since the result of XORing
  690. any two bits together is the same as XORing their complements, whereas half the
  691. possible double bit errors can be caught by addition because of the carry
  692. into the next bit position.  CRC does even better by rippling the effect of a
  693. data bit multiply through the block check character, but the method is complex,
  694. and a software implementation of CRC can be inscrutable.
  695.  
  696. Standard, base-level KERMIT employs a single-@|character arithmetic checksum,
  697. which is simple to program, is low in overhead, and has proven quite adequate
  698. in practice.  The sum is formed by adding together the ASCII values of each
  699. character in the packet except the SOH and the checksum itself, and including
  700. any quoting characters.  Even non-@|ASCII hosts must do this calculation in
  701. ASCII.  The result can approach 12,000@-<10> in the worst case.  The binary
  702. representation of this number is 10111011100000, which is 14 bits long.  This
  703. is much more than one character's worth of bits, but we can make the
  704. observation that every character included in the sum has contributed to the
  705. low order 7 bits, so we can discard some high order bits and still have a
  706. viable validity check.
  707.  
  708. The KERMIT protocol also allows other block check options, including a
  709. two-@|character checksum and a three-@|character 16-@|bit CRC.  The
  710. two-@|character checksum is simply the low order 12 bits of the arithmetic sum,
  711. broken into two printable characters.  The CRC sequence is formed from the
  712. 16-bit quantity generated by the CCITT-@|recommended polynomial
  713. @i<X>@+(16)+@i<X>@+(12)+@i<X>@+(5)+1 which is also used in some form with other
  714. popular transmission techniques, like ISO HDLC and IBM SDLC @cite<--MCN>.  The
  715. high order 4 bits of the CRC go into the first character, the middle 6 into the
  716. second, and the low order 6 into the third.
  717.  
  718. Some care must be taken in the formation of the single-@|character block check.
  719. Since it must be expressed as a single printable character, values of the high
  720. order data bits may be lost, which could result in undetected errors,
  721. especially when transferring binary files.  Therefore, we extract the 7th and
  722. 8th bits of the sum and add them back to the low order bits; if the arithmetic
  723. sum of all the characters is @i(S), then the value of the single-@|character
  724. KERMIT checksum is given by
  725. @example<(@i<S> + ((@i<S> AND 300)/100)) AND 77>
  726. (numbers are in octal notation).  This ensures that the checksum, terse though
  727. it is, reflects every bit from every character in the packet.
  728.  
  729. The probability that an error will not be caught by a correctly transmitted
  730. arithmetic checksum is the ratio of the number of possible errors that cancel
  731. each other out to the total number of possible errors, which works out to be
  732. something like 1/2@+(@i<n>), where @i<n> is the number of bits in the
  733. checksum, assuming all errors are equally likely.  This is 1/64 for the single
  734. character checksum, and 1/4096 for the 2-@|character checksum.  But the
  735. probability that errors will go undetected by this method @i(under real
  736. conditions) cannot be easily derived, because all kinds of errors are not
  737. equally likely.  A 16-@|bit CRC will detect all single and double bit errors,
  738. all messages with an odd number of bits in error, all error bursts shorter
  739. than 16 bits, and better than 99.99% of longer bursts @cite<--MAR>.  These
  740. probabilities all assume, of course, that the block check has been identified
  741. correctly, i.e. that the length field points to it, and that no intervening
  742. characters have been lost or spuriously added.
  743.  
  744. A final note on parity@dd()a parity bit on each character combined with a
  745. logical sum of all the characters (VRC @i<and> LRC) would allow detection
  746. @i<and> correction of single-@|bit errors without retransmission by
  747. pinpointing the ``row'' and ``column'' of the bad bit.  But control of the
  748. parity bit cannot be achieved on every system, so we use the parity bit for
  749. binary data when we can, or surrender it to the communication hardware if we
  750. must.  If we have use of the 8th bit for data, then it is figured into the
  751. block check; if we do not, then it must be omitted from the block check in
  752. case it has been changed by agents beyond the knowledge or control of the
  753. KERMIT program.
  754.  
  755. @SubSection(Packet Layout)
  756.  
  757. KERMIT packets have the format:
  758. @begin<example>
  759. +------+-----------+-----------+------+------------+-------+
  760. | MARK | char(LEN) | char(SEQ) | TYPE |    DATA    | CHECK |
  761. +------+-----------+-----------+------+------------+-------+
  762. |                  |           |                   |       |
  763. |                  |           +-- (application) --+       |    
  764. |                  |                               |       |
  765. |                  +-------------- (session) ------+       |
  766. |                                                          |
  767. +--------------------------------- (data link) ------------+
  768. @end<example>
  769. where all fields consist of ASCII characters,
  770. and the @i<char> function converts a number in the range 0-94@-<10> to a
  771. printable ASCII character by adding 32@-<10>.
  772.  
  773. In terms of the ISO network reference model @cite<--ISO>, 8-bit bytes are
  774. presented to the KERMIT program by the hardware and operating system software
  775. comprising the physical link layer.  Correct transmission is ensured by the
  776. packet-@|level routines that implement the data link layer using the outer
  777. ``skin'' of the packet@dd()the MARK, LEN, and CHECK fields.  The network and
  778. transport layers are moot, since KERMIT is a point-@|to-@|point affair, in
  779. which the user personally makes all the required connections.  The session
  780. layer is responsible for requesting retransmission of missing packets or
  781. ignoring redundant ones, based on the SEQ field; the presentation layer is
  782. responsible for any data conversions (EBCDIC/ASCII, insertion or stripping of
  783. CRLFs, etc).  Finally, the remainder of the packet, the TYPE and DATA fields,
  784. are the province of the application layer; our application, of course, is file
  785. transfer.  In any particular implementation, however, the organization of the
  786. program may not strictly follow this model.  For instance, since transmission
  787. is always in stream ASCII, IBM implementations must convert from EBCDIC and
  788. insert CRLFs @i<before> checksum computation.
  789.  
  790. The fields of a KERMIT packet are as follows:
  791. @begin<description,leftmargin +10,indent -10,spread 0.5>
  792. @u<MARK>@\Start-of-packet character, normally SOH (ASCII 1).
  793.  
  794. @u<LEN>@\The number of ASCII characters, including quoting characters
  795. and the checksum, within the packet that follow this
  796. field, in other words the packet length minus two.  Since this number is
  797. expressed as a single character via the @i(char) function, packet character
  798. counts of 0 to 94@-<10> are permitted, and 96@-<10> is the maximum
  799. total packet length.
  800.  
  801. @u<SEQ>@\The packet sequence number, modulo 100@-<8>.  The sequence
  802. numbers ``wraps around'' to 0 after each group of 64@-<10> packets.
  803.  
  804. @u<TYPE>@\The packet type, a single printable ASCII character, one of the
  805. following:
  806. @begin<description,spread 0, leftmargin +4, indent -4, above 1>
  807. D@\Data
  808.  
  809. Y@\Acknowledge (ACK)
  810.  
  811. N@\Negative Acknowledge (NAK)
  812.  
  813. S@\Send Initiate (Send-Init)
  814.  
  815. R@\Receive Initiate
  816.  
  817. B@\Break Transmission (EOT)
  818.  
  819. F@\File Header
  820.  
  821. Z@\End of file (EOF)
  822.  
  823. E@\Error
  824. @end<description>
  825. @begin<description,leftmargin +4, indent -4>
  826. G@\Generic Command.  A single character in the data field, possibly
  827. followed by operands, requests host-@|independent remote execution the
  828. specified command:
  829. @begin<description,leftmargin +4,indent -4,above 1,below 1,spread 0>
  830. L@\Logout, Bye.
  831.  
  832. F@\Finish, but don't logout.
  833.  
  834. D@\Directory query (followed by optional file specification).
  835.  
  836. U@\Disk usage query.
  837.  
  838. E@\Erase (followed by file specification).
  839.  
  840. T@\Type (followed by file specification).
  841.  
  842. Q@\Query server status.
  843.  
  844. and others.
  845. @end<description>
  846.  
  847. C@\Host Command.  The data field contains a string to be executed as a system
  848. dependent (literal) command by the host.
  849.  
  850. X@\Text display header, to indicate the arrival of text to be displayed on the
  851. screen, for instance as the result of a generic or host command executed at the
  852. other end.  Operation is exactly like a file transfer.
  853. @end<description>
  854.  
  855. @u<DATA>@\The ``contents'' of the packet, if any contents are required in the
  856. given type of packet, interpreted according to the packet type.  Nonprintable
  857. ASCII characters are prefixed with quote characters and then
  858. ``uncontrollified''.  Characters with the 8th bit set may also be prefixed, and
  859. a repeated character can be prefixed by a count.
  860. A prefixed sequence may not be broken across packets.
  861.  
  862. @u<CHECK>@\The block check sequence, based on all the characters in
  863. the packet between, but not including, the mark and the check itself, one,
  864. two, or three characters in length as described above, each
  865. character transformed by @i<char>.  Normally, the single-@|character checksum
  866. is used.
  867. @end<description>
  868.  The packet may be followed by any line terminator required by the
  869. host, carriage return (ASCII 15) by default.  Line terminators are not part of
  870. the packet, and are not included in the count or checksum.  Terminators are not
  871. necessary to the protocol, and are invisible to it, as are any characters that
  872. may appear between packets.  If a host cannot do single character input from a
  873. TTY line, then a terminator will be required for that host.
  874.  
  875. Here are some sample KERMIT data packets:
  876. @begin(example)
  877. ^AE"D   No celestial body has required J
  878. ^AE#Das much labor for the study of its#
  879. ^AE$D#M#Jmotion as the moon.  Since ClaA
  880. ^AE%Dirault (1747), who indicated a way7
  881. ^AE&D of#M#Jconstructing a theory conta5
  882. @end(example)
  883. The ``@q<^A>'' represents the SOH (or Control-A) character.  In the final
  884. packet shown, 
  885. ``@q<E>'' is
  886. the length.  The ASCII value of the ``@q<E>'' character is 69@-<10>, less 32
  887. (the @i<unchar> transformation, which is the opposite of @i<char>)
  888. gives a length of 37.  The next character tells the
  889. packet sequence number, in this case 6 (``@q<&>'' is ASCII 38).  The next is
  890. the packet type ``@q<D>'' for Data.  The next characters,
  891. ``@q< of#M#Jconstructing a theory conta>'',
  892. form the data; note the prefixed carriage return and line feed.  The
  893. final character, ``@q<5>'' is the checksum, which represents the number 21 (all
  894. numbers in this paragraph are in decimal).
  895.  
  896. @SubSection(Effects of Packet Corruption)
  897.  
  898. What are the consequences of transmission errors in the various fields?  If
  899. the SOH is garbled, the packet will be treated as interpacket garbage, and
  900. lost.  If any other character within the packet is garbled into SOH, the
  901. current packet will be discarded, and a new (spurious) packet detected.  If
  902. the length is garbled into a smaller number, then a character from the data
  903. field will be misinterpreted as the checksum; if larger, then the program will
  904. probably become stuck trying to input characters that will not be sent until
  905. one side or the other times out and retransmits.  If the sequence number,
  906. type, any of the data characters, or the checksum itself is garbled, the
  907. checksum should be wrong.  If characters are lost, there will most likely be a
  908. timeout.  If noise characters are spontaneously generated, they will be
  909. ignored if they are between packets, or will cause the wrong character to be
  910. interpreted as the checksum if they come during packet transmission.
  911.  
  912. Most kinds of errors are caught by the checksum comparison, and are handled by
  913. immediate retransmission.  Timeouts are more costly because the line sits idle
  914. for the timeout period.  The packet design minimizes the necessity for timeouts
  915. due to packet corruption: the only fields that can be corrupted to cause a
  916. timeout are the SOH and the packet length, and the latter only half the time.
  917. Lost characters, however, can produce the same effect (as they would with a
  918. fixed-@|length block protocol).  Had a
  919. distinguished end-@|of-@|packet character been used rather than a length field,
  920. then there would be a timeout every time it was corrupted.  It is always better
  921. to retransmit immediately than to time out.
  922.  
  923. @Section(Protocol)
  924.  
  925. The KERMIT protocol can be described as a set of @i<states> and a set of
  926. @i[transitions] that define, for a given event, what action to take and what
  927. new state to change to.  The inherent simplicity of the design, particularly
  928. the requirement that each packet must be acknowledged, reduces the number of
  929. states and actions, and the amount of state information that must be
  930. maintained, to a minimum.
  931.  
  932. Here is a simplified version of a state diagram for KERMIT receiving a file:
  933. @begin<verbatim,group,longlines keep>
  934.  
  935.                             +--------------+
  936.                             | Receive Init |
  937.                             +--------------+
  938.                                     |
  939.                                     | (Get Send Init Packet)
  940.                                     |
  941.            (Get EOT Packet)         V
  942.                             +--------------+
  943.   (Done) <------------------| Receive File |<---------------+
  944.                             +--------------+                |
  945.                                     |                       |
  946.                                     | (Get File             | (Get EOF Packet)
  947.                                     |  Header Packet)       |
  948.                                     V                       |
  949.                             +--------------+                |
  950.                     +------>| Receive Data |----------------+
  951.                     |       +--------------+
  952.                     |               |
  953.                     |               | (Get Data Packet)
  954.                     |               |
  955.                     +---------------+
  956. @end<verbatim>
  957. For simplicity,
  958. some transitions are not shown in the diagram:
  959. @begin<itemize>
  960.  If in any state a bad packet is received or a timeout occurs, a null
  961. transition back to the same state occurs, with a NAK for the expected packet.
  962.  
  963. In any state an error may occur that can cause the transfer to terminate.  For
  964. instance, the target disk might fill up.  The side that encountered the error
  965. sends an error packet, containing an informative error message, and quits.
  966. Upon receipt of the error packet, the other side displays the message on the
  967. screen (if it is in control of the screen) and also quits.
  968.  
  969. Actions that are taken on each transition, such as opening a file when a File
  970. Header packet is received, are not shown; in particular each packet
  971. successfully received is ACK'd.
  972. @end<itemize>
  973.  
  974. The receiver starts out in Receive Init state and waits for the other side to
  975. send a Send-@|Init packet.  If any other kind of packet is received, or the
  976. Send-@|Init does not arrive within the timeout interval, a NAK is sent.
  977. Timeouts or NAKs can occur up to a threshold which, when exceeded for a
  978. particular packet, causes the
  979. protocol to assume that the connection has become unusable, and to give up.
  980. After the Send-@|Init arrives, the state becomes Receive File; KERMIT waits for
  981. a File Header packet containing the name of the file which is to come.  When
  982. the file header arrives, KERMIT opens a new file using the name provided
  983. (perhaps transformed to suit local naming conventions, or to avoid a name
  984. collision), and switches to Receive Data state.  KERMIT then receives the
  985. contents of the file, until an EOF (End Of File) packet arrives.  At that point
  986. KERMIT switches back to Receive File state.  If another file is to be sent,
  987. another File Header packet will follow, otherwise an EOT (End Of Transmission)
  988. packet will terminate the transfer.  The distinction between EOF and EOT,
  989. plus the File Header itself, allows files to be
  990. sent in groups.  EOF marks the end of a file, EOT marks the end of a group.
  991. This distinction also allows the two sides to disconnect cleanly: the EOF must
  992. be ACK'd before the sender will believe the file has been transmitted
  993. correctly; the EOT will follow, but if the ACK which is sent in response is
  994. lost, no harm will be done since both sides are terminating anyway.
  995.  
  996. The state transitions for a sending KERMIT are similar.  In each state, instead
  997. of waiting for particular packet types, KERMIT sends the appropriate packet and
  998. waits for an ACK.  If the ACK does not arrive within the allotted time, or a
  999. NAK appears instead of an ACK, the same packet is retransmitted.  A send
  1000. operation begins with a Send-Init packet, includes one or more files, each
  1001. starting with a File Header, followed by one or more data packets, followed by
  1002. EOF.  When all the specified files have been sent, an EOT packet closes the
  1003. connection and terminates the operation.
  1004. @begin<verbatim,group>
  1005.  
  1006.                             +-----------+
  1007.                             | Send Init |
  1008.                             +-----------+
  1009.                                     |
  1010.                                     | (Get Good ACK)
  1011.                                     |
  1012.    (No more files to send)          V
  1013.   +----------+              +-----------+
  1014.   | Send EOT |<-------------| Send File |<---------------+
  1015.   +----------+              +-----------+                |
  1016.                                     |                    |
  1017.                                     | (Good ACK)         | (EOF)
  1018.                                     |                    |
  1019.                                     V                    |
  1020.                             +-----------+                |
  1021.                     +------>| Send Data |----------------+
  1022.                     |       +-----------+
  1023.                     |               |
  1024.                     |               | (Good ACK)
  1025.                     |               |
  1026.                     +---------------+
  1027. @end<verbatim>
  1028.  
  1029. Base-@|level KERMIT provides that during any particular transaction, the sender
  1030. is the ``master'' and the receiver is the ``slave''.  These roles may be
  1031. reversed in the next transaction; any KERMIT implementation is capable of
  1032. acting as either master or slave.  In addition, mainframe implementations may
  1033. also be put in a kind of permanent slave, or ``server'', mode in which all
  1034. commands come in command packets from the master, or ``user'' KERMIT.
  1035.  
  1036. @subsection(Initial Connection)
  1037.  
  1038.  To allow a diverse group of computers to communicate with one another, an
  1039. exchange takes places during initial connection in which the two sides
  1040. ``configure'' each other.  The sending KERMIT includes setup parameters in its
  1041. Send-@|Init packet and the receiving KERMIT responds with an ACK packet
  1042. containing the corresponding parameters as they apply to itself.  The Data
  1043. field of the Send-@|Init packet looks like this:
  1044. @begin<example,leftmargin +2,longlines keep>
  1045.  1      2      3      4      5      6      7      8      9      10     
  1046. +------+------+------+------+------+------+------+------+------+-------------
  1047. | MAXL | TIME | NPAD | PADC | EOL  | QCTL | QBIN | CHKT | REPT |  CAPAS...
  1048. +------+------+------+------+------+------+------+------+------+-------------
  1049. @end<example>
  1050. The fields are as follows (the first and second person ``I'' and ``you'' are
  1051. used to distinguish the two sides).  Fields are encoded printably using the
  1052. @i<char> function (ASCII value + 32@-<10>) unless indicated otherwise.
  1053. @begin<description,leftmargin +8,indent -8>
  1054. @u<MAXL>@\The maximum length packet I want to receive, a number up to 94@-<10>.You respond with the maximum you want me to send.
  1055. This allows systems to adjust to each other's buffer sizes, or to the condition
  1056. of the transmission medium.
  1057.  
  1058. @u<TIME>@\The number of seconds after which I want you to time me out while
  1059. waiting for a packet from me.  You respond with the
  1060. amount of time I should wait for packets from you.  This allows the two sides
  1061. to accommodate to different line speeds or other factors that could cause
  1062. timing problems.
  1063.  
  1064. @u<NPAD>@\The number of padding characters I want to precede each incoming
  1065. packet; you respond in kind.  Padding may be necessary
  1066. for a half duplex system that requires some time to change the direction of
  1067. transmission.
  1068.  
  1069. @u<PADC>@\The control character I need for padding, if any, XOR'd with 100
  1070. octal to make it printable.  You respond in kind.  Normally NUL (ASCII 0), some
  1071. systems use DEL (ASCII 177).  This field is ignored if the value NPAD is zero.
  1072.  
  1073. @u<EOL>@\The character I need to terminate an incoming packet, if any.  You
  1074. respond in kind.  Most systems that require a line terminator for terminal
  1075. input accept carriage return for this purpose.  (Can you see the Catch-22
  1076. here?)
  1077.  
  1078. @u<QCTL>@\The printable ASCII character I will use to quote control characters
  1079. and prefix characters, normally ``#''.  You respond with the one you will use.
  1080.  
  1081. @u<QBIN>@\The printable ASCII character I want to use to quote characters which
  1082. have the 8th bit set, for transmitting binary files when one or both systems
  1083. cannot use the parity bit for data.  Since this kind of quoting increases both
  1084. processor and transmission overhead, it is normally to be avoided.
  1085.  
  1086. @u<CHKT>@\Check Type, the method for detecting errors.  ``1'' for
  1087. single-@|character checksum (the normal method), ``2'' for two-@|character
  1088. checksum, ``3'' for three-@|character CRC-@|CCITT.  If your response
  1089. agrees, the designated method will be used; otherwise the single-@|character
  1090. checksum will be used.  Other check types may also be added.
  1091.  
  1092. @u<REPT>@\The prefix character I will use to indicate
  1093. a repeated character.  This can be any printable character other than blank
  1094. (which denotes no repeat count prefix), but
  1095. ``~'' is recommended.  If you don't respond identically,
  1096. repeat counts will not be done.  Groups of 4 or more identical characters 
  1097. may be transmitted more efficiently using a repeat count, though an individual
  1098. implementation may wish to set a higher threshhold.
  1099.  
  1100. @u<CAPAS>@\An extendable bit mask encoded printably, to indicate whether
  1101. certain advanced capabilities, such as file-@|attribute packets, are supported.
  1102.  
  1103. @i<@ux[Reserved Fields]>@\The next four fields are reserved for future use.
  1104. Sites wishing to add their own parameters to the
  1105. initial connection exchange should start at the fifth field after the
  1106. capability mask in order to remain compatible with other KERMIT programs.
  1107.  @end<description>
  1108. Naturally, the three prefix characters must be distinct and should be chosen to
  1109. be uncommonly used printable characters, to minimize further overhead from
  1110. having to prefix them when they are found in the data.
  1111.  
  1112.  Trailing fields within the DATA field may be omitted, in which case they will
  1113. assume appropriate defaults.  Defaults for intermediate fields can be elected
  1114. by setting those fields to blank.  Every parameter has an appropriate default,
  1115. and in fact the entire data field of the Send Init packet or its ACK may be
  1116. left empty to accept all defaults.  The more exotic paramaters are at the end,
  1117. and reflect more recent developments in the KERMIT protocol; earlier
  1118. implementations can still communicate with newer ones, since there will not be
  1119. agreement to use these options.  The Send-@|Init mechanism preserves
  1120. compatibility from the very earliest KERMIT to the very newest.
  1121.  
  1122. There is no protracted negotiation; everything must be settled in a single
  1123. exchange.  Some parameters, however, are outside the scope of this exchange and
  1124. must be set even before the very first packet is sent.  For instance, if the
  1125. receiving computer can only read characters with odd parity but the sending
  1126. computer sends them with even parity, the Send-@|Init packet will never arrive
  1127. successfully.  In cases like this, the user may have to issue some preliminary
  1128. commands to inform one or both KERMITs about the vagaries of the other system.
  1129. Another example is the packet terminator (EOL) mentioned above@dd()if the
  1130. receiving KERMIT requires one that the sending KERMIT doesn't know about, the
  1131. Send-@|Init will never get through.  
  1132.  
  1133. For these reasons, most implementations of KERMIT provide SET commands for all
  1134. the parameters listed above, and some others as well.
  1135.  
  1136. @subsection(Rules and Heuristics)
  1137.  
  1138. During a file transfer, one KERMIT sends information packets@dd()file headers,
  1139. data, and so forth, and the other KERMIT sends only ACKs or NAKs in response.
  1140. The most important rule in the KERMIT protocol is
  1141. @maxim<@b(1.) ``Wait for a response before sending the next packet.''>
  1142. This prevents buffer overruns, and allows participation by half duplex systems.
  1143. Of course, KERMIT should not wait forever; a timeout should occur after a few
  1144. seconds if the expected packet has not arrived.  Upon timeout, a sending KERMIT
  1145. retransmits the current packet; a receiving KERMIT re-ACKs the current packet
  1146. or NAKs the expected one.
  1147.  
  1148. Some interesting heuristics are used in the KERMIT protocol to boost efficiency
  1149. and improve error recovery.  A number of important rules take care of the cases
  1150. when packets are lost in transmission.  The first can be stated as
  1151. @maxim<@b(2.) ``A NAK for the next packet implies an ACK for the current
  1152. packet.''>
  1153. A NAK with packet number @i<n+1> means the receiving KERMIT got packet
  1154. @i<n>, sent an ACK that was never received, and not knowing that the ACK didn't
  1155. get through (since we don't ACK an ACK), is now waiting for packet @i<n+1>,
  1156. which was never sent.  In this case, we simply send packet @i<n+1>.
  1157. An important exception is when the missing ACK is for a Send-@|Init packet; do
  1158. you see why?  The next rule,
  1159. @maxim<@b(3.) ``ACK and discard redundant packets.''>
  1160. handles the situation where the same packet arrives again.  The
  1161. sending KERMIT timed out waiting for an ACK which was sent, but lost, and
  1162. retransmitted the packet.  The receiver must discard the redundant data and ACK
  1163. the packet again; to do otherwise could have undesirable effects, like adding
  1164. the same data to a file twice or opening the same file multiple times.
  1165. Note that the situation resulting from a lost ACK depends upon which side times
  1166. out first.
  1167.  
  1168. KERMIT must handle another situation arising from possible lost packets:
  1169. @maxim<@b(4.) ``NAK the expected command.''>
  1170. The potential problem occurs in either the Receive Init state or when a KERMIT
  1171. server is waiting for a command.  In either case KERMIT won't know whether
  1172. communication has begun if the other side's initial packet was lost.  KERMIT
  1173. can't assume the other side will time out and retransmit, so it must check
  1174. periodically by sending a NAK for packet zero.  If KERMIT gets no response it
  1175. assumes nothing has happened yet and goes back to sleep for a while.
  1176.  
  1177. But sending periodic NAKs opens the door to the @i<buffering problem>.  Some
  1178. systems buffer input for a device; when a program isn't looking for input some
  1179. or all the input is saved by the computer for future requests.  This can cause
  1180. problems when talking to a KERMIT server or sending a file to a KERMIT in
  1181. receive wait.  If some time has elapsed since activating the remote KERMIT and
  1182. escaping back and starting up the local KERMIT, a number of NAKs may have
  1183. accumulated in the local KERMIT's input buffer, so:
  1184. @maxim<@b(5.) ``Clear the input buffer at the beginning of a transfer.''>
  1185. If the input buffer is not cleared, the local KERMIT will think the remote side
  1186. is having trouble receiving the first packet.  In an effort to get the packet
  1187. through, it will be sent again; this repeats for every NAK waiting in the input
  1188. buffer.  By the time the first ACK is finally encountered in the buffer, a
  1189. number of duplicates of the first packet will have been sent out.  If this
  1190. number exceeds the NAK threshhold, the connection will be
  1191. broken.  If not, however, the second packet will be retransmitted once for each
  1192. of the extra ACKs the remote KERMIT correctly sent for the duplicate first
  1193. packets.  This can continue throughout the file transfer, causing each
  1194. packet to be sent many times.  So, in addition,
  1195. @maxim<@b(6.) ``Clear the input buffer after reading each packet.''>
  1196. Any computer that buffers its input should clear its input buffer before the
  1197. transfer and after each packet that arrives successfully.  But since not all
  1198. systems provide a clear-@|buffer function, we may add another rule:
  1199. @maxim<@b(7.) ``Discard redundant ACKs.''>
  1200. In the situation just described, the first packet would be sent out multiple
  1201. times, once for each buffered NAK.  Upon receipt of the first ACK, the second
  1202. packet would go out, but the next response would be another ACK for the first
  1203. packet; by rule @b<7>, KERMIT would simply take in the redundant ACK, ignore
  1204. it, and look for the next ACK, until it got the desired one, in violation of
  1205. the spirit of Rule @b<1>.
  1206.  
  1207. If we allowed ourselves to violate Rule @b<1>, we could add a final rule,
  1208. @i<``An ACK for packet n also ACKs all previous packets,''>
  1209. as is done in network protocols like DDCMP @cite<--DDCMP>, allowing data
  1210. packets to be sent in a continuous stream.  KERMIT cannot use this rule for
  1211. many reasons: sequence number wraparound, buffer overflows, locking out half
  1212. duplex systems (how can they NAK a bad packet if they can't get control of the
  1213. line?).  Thus if we violate rule @b<1>, it must be only in a very minor way.
  1214.  
  1215. @subsection<Example>
  1216.  
  1217. Here is a sequence of packets from a real file transfer.  Each packet
  1218. starts with Control-A, shown as @q<^A>.
  1219. @begin<example,longlines keep>
  1220. ^A) SH( @@-#^                                  @i<Send Init>
  1221. ^A) YH( @@-#%                                  @i<ACK for Send Init>
  1222. ^A+!FMOON.DOC2                                @i<File Header>
  1223. ^A#!Y?                                        @i<ACK for File Header>
  1224. ^AE"D   No celestial body has required J      @i<First Data packet>
  1225. ^A#"Y@@                                        @i<ACK for first Data packet>
  1226. ^AE#Das m%%%uch labor for the study of its#   @i<Second Data packet, Bad>
  1227. ^A##N8                                        @i<NAK for second Data packet>
  1228. ^AE#Das much labor for the study of its#      @i<Second Data packet again>
  1229. ^A##YA                                        @i<ACK for second Data packet>
  1230. ^AE$D#M#Jmotion as the moon.  Since ClaA      @i<etc...>
  1231. ^A#$YB
  1232.  
  1233. @i<(many packets omitted here)>
  1234.  
  1235. ^AD"Dout 300 terms are sufficient.#M#JU       @i<Last Data packet>
  1236. ^A#"Y@@                                        @i<ACK for last Data>
  1237. ^A##ZB                                        @i<EOF>
  1238. ^A##YA                                        @i<ACK for EOF>
  1239. ^A#$B+                                        @i<EOT>
  1240. ^A#$YB                                        @i<ACK for EOT>
  1241. @end<example>
  1242. In the first packet, we see following the control-A the packet length ``@q<)>''
  1243. (41@-<10>, less 32, or 9), followed by the packet type, S (Send-@|Init),
  1244. followed by the appropriate parameter declarations: maximum packet length is H
  1245. (72-32@q<=>40), timeout is ``@q<(>'' (40-32@q<=>8), number of padding
  1246. characters is 0 (space@q<=>32-32@q<=>0), the padding character is 0,
  1247. end-@|of-@|line is ``@q<->'' (45-32@q<=>13, the ASCII value of carriage
  1248. return), the control-quote character is ``#'', and the remaining fields are
  1249. omitted, defaulting to appropriate values.  The final character ``@q<^>'' is
  1250. the single-@|character checksum, computed as follows (all numbers and
  1251. computations in octal, and ``@q<sp>'' represents a space):
  1252. @begin<example,group>
  1253. )    sp   S     H     (    sp   @@     -    #
  1254. 51 + 40 + 123 + 110 + 50 + 40 + 100 + 55 + 43 = 674
  1255.  
  1256. 674 + (674/300) = 676
  1257.  
  1258. 676 AND 77 = 76;
  1259.  
  1260. char(76) = 76+40 = 136 = "^"
  1261. @end<example>
  1262. The receiver ACKs with its own parameters,
  1263. which are the same.  Then comes the file header, the file, EOF, and EOT.  One
  1264. data packet was corrupted by a burst of ``@q<%>'' characters, NAK'd, and
  1265. retransmitted.
  1266.  
  1267. @Section(Performance)
  1268.  
  1269. For text files (documents or program source), assuming an average line length
  1270. of 40 with lines separated by a carriage-@|return/@|linefeed pair, the only
  1271. control characters normally found in the text file, we see about 5% overhead
  1272. for prefixing of control characters.  Assuming no line terminators for packets
  1273. (although one or both sides may require them), no retransmissions or timeouts,
  1274. and no time wasted for the line to turn around between packet and response,
  1275. then for average packet length @i(p), using a single-@|character checksum, the
  1276. KERMIT protocol overhead consists of:
  1277.  
  1278. @begin<verbatim, facecode R, leftmargin +4>
  1279.   5 control field characters in the data packet
  1280.   5 characters in the acknowledgement packet
  1281. + 0.05@i<p> for control character quoting
  1282. @end<verbatim>
  1283.  
  1284. This gives 10/@i<p> + 0.05 overhead.  E.g.@ if the packet length is 40, there
  1285. is 30% overhead.  If @i<p> is 96 (the maximum), there is about 15%.  These
  1286. figures will vary with the average line length and the frequency of other
  1287. control characters (like tabs and formfeeds) in the file, and will go up with
  1288. immediate retransmissions, and @i<way> up with delayed retransmissions.  For
  1289. binary files, the quoting overhead will be higher.  But transmission overhead
  1290. can also go down dramatically if prefix encoding is used for repeated
  1291. characters, depending on the nature of the data (binary data containing many
  1292. zeroes, highly indented or columnar data or program text will tend to benefit).
  1293. Each file transfer also gets
  1294. a fixed overhead for the preliminary (Send Init, File Header) and terminating
  1295. (EOF, EOT) packets.
  1296.  
  1297.  If the mainframe end of a connection is heavily loaded, it may take
  1298. considerable time to digest and process incoming characters before replying.
  1299. On half duplex mainframes, there may be a pause between sending and receiving,
  1300. even if the load is light; this might be used to advantage by preparing the
  1301. next packet in advance while waiting for the current ACK.  Another problem may
  1302. occur on heavily loaded mainframes@dd()undesirable timeouts.  Timeouts are
  1303. intended to detect lost packets.  A heavily loaded system may take longer than
  1304. the timeout interval to send a packet.  For this reason, mainframe KERMITs
  1305. should take the requested timeout interval only as a minimum, and should adjust
  1306. it for each packet based on the current system load, up to a reasonable
  1307. maximum.
  1308.  
  1309. On a noisy line, there is a greater likelihood of corrupted packets and
  1310. therefore of retransmission overhead.  Performance on noisy lines can be
  1311. improved by reducing the packet length, and thus the probability that any
  1312. particular packet will be corrupted, and the amount of time required to
  1313. retransmit a corrupted packet.  A KERMIT program can unilaterally adjust the
  1314. packet length according to the number of retransmissions that are occurring.
  1315. Short packets cut down on retransmission overhead, long packets cut down on
  1316. character overhead.
  1317.  
  1318. @Section(``User Interface'')
  1319.  
  1320. KERMIT was designed from a mainframe perspective.  Like many mainframe
  1321. programs, KERMIT issues a prompt, the user types a command, KERMIT executes the
  1322. command and issues another prompt, and so on until the user exits from the
  1323. program.  Much care is devoted to the command parser, even on microcomputer
  1324. versions.  The goal is to provide English-@|like commands composed of sequences
  1325. of keywords or operands, with abbreviations possible for any keyword in any
  1326. field down to the minimum unique length, and with ``?'' help available at any
  1327. point in a command.  Not all implementations need follow this model, but most
  1328. do.
  1329.  
  1330. The basic commands are SEND and RECEIVE.  These allow most KERMITs to exchange
  1331. files.  Operands can be the name of a single file, or a file group designator
  1332. (e.g.@ with ``wildcards'') to transmit multiple files in a single operation.
  1333. Although some systems may not provide wildcard file processing, the KERMIT
  1334. protocol allows it.
  1335.  
  1336. The CONNECT command provides the mechanism for logging in and typing commands
  1337. at the remote host, which is necessary in order to start the KERMIT on that
  1338. side.   The CONNECT facility provides character-@|at-@|a-@|time transmission,
  1339. parity selection, remote or local eching,
  1340. and the ability to send any character, including the ``escape
  1341. character'' that must be used to get back to the local KERMIT.  However, there
  1342. is no error detection or correction during CONNECT, just as there normally is
  1343. none between an ordinary terminal and a host.
  1344.  
  1345. When two systems are dissimilar, a SET command is provided to allow them to
  1346. accommodate each other's peculiarities, for instance SET PARITY ODD to add
  1347. odd parity to all outbound
  1348. characters, or SET LOCAL-ECHO to do local
  1349. echoing when connected as a terminal to a half duplex system.  The SET command
  1350. must sometimes be used to supply information to the target system on how to
  1351. store an incoming file with respect to block size, byte size, record format,
  1352. record length.
  1353.  
  1354. Most KERMIT implementations take special care to reassure the user during
  1355. file transfer.  The names of the files being transferred are shown, and a
  1356. dynamic display is made of the packet traffic, showing successful transmission
  1357. of packets as well as timeouts and retransmissions.  Messages are issued when
  1358. the user connects to the remote system or escapes back from it, and KERMIT
  1359. prompts identify the implementation.  Helpful error messages
  1360. are displayed when necessary; these may emanate from either the local or
  1361. the remote system.  The final disposition of the transfer is clearly stated,
  1362. complete or failed.
  1363.  
  1364. The actions required of the KERMIT user depend upon the degree to which the
  1365. KERMIT programs involved have implemented the specification.  Minimal
  1366. implementations require that the user connect to the remote host, start KERMIT
  1367. there, issue a SEND (or RECEIVE) command, escape back to the local machine, and
  1368. issue the complementary RECEIVE (or SEND) command.  All this must be done for
  1369. each transfer.  More advanced implementations allow the remote side to run as a
  1370. ``server'' and to take all its instructions in special command packets from the
  1371. local KERMIT; all that is required of the user on the remote end is to connect
  1372. initially in order to start the server.  The server will even log itself out
  1373. upon command from the local KERMIT.  A minimal server can process commands to
  1374. send files, receive files, and shut itself down.
  1375.  
  1376. Here is an example of a session in which the user of an IBM PC gets files
  1377. from a DECSYSTEM-20.  The actions shown are required for minimal KERMIT
  1378. implementations.  The parts the user types are underlined, comments begin
  1379. with ``@q<!>'' or appear in italics.  Everything else is system typeout.
  1380. @begin<example,need 6,longlines keep>
  1381. @tabclear@tabDivide(3)
  1382. A>@u[kermit]@\! Run Kermit on the PC.
  1383. Kermit V1.20
  1384.  
  1385. Kermit-86>@\! This is the Kermit prompt for the PC.
  1386. Kermit-86>@u[connect]@\! Connect to the DEC-20.
  1387. [Connecting to host. Type CTRL-]C to return to PC.]
  1388.  
  1389. @\! You are now connected to the DEC-20.
  1390. Columbia University CU20B@\! The system prints its herald.
  1391. @@@ux[terminal vt52]@\! Set your terminal type (optional).
  1392. @@@ux[login my-id password]@\! Login using normal login method.
  1393.  
  1394. @i<(The DEC-20 prints various messages.)>
  1395.  
  1396. @@@u[kermit]@\! Run Kermit on the DEC-20.
  1397. Kermit-20>@\! This is Kermit-20's prompt.
  1398. Kermit-20>@ux[send *.for]@\! Send all FORTRAN files.
  1399. @ux<^]c>@\! Type the escape sequence to return to the PC.
  1400. [Back at PC.]
  1401. Kermit-86>@u[receive]@\! Tell the PC files are coming.
  1402.  
  1403. @i<(The progress of the transfer is shown continuously on the screen.)>
  1404.  
  1405. Transfer Complete.
  1406. Kermit-86>@ux[connect]@\! Get back to the DEC-20.
  1407. [Connecting to host. Type CTRL-]C to return to PC.]
  1408. Kermit-20>@u[exit]@\! Get out of Kermit-20.
  1409. @@@ux<logout>@\! Logout from the DEC-20.
  1410.  
  1411. Logged out Job 55, User MY-ID, Account MY-ACCOUNT, TTY 146,
  1412.   at 24-Apr-83 15:18:56,  Used 0:00:17 in 0:21:55
  1413.  
  1414. @ux<^]c>@\! Now "escape" back to the PC,
  1415. [Back at PC.]
  1416. Kermit-86>@ux<exit>@\! and exit from the PC's Kermit.
  1417. @End<Example>
  1418.  
  1419. The session is somewhat simpler when the remote KERMIT is being run as a
  1420. server.  The user must still CONNECT, log in, and start KERMIT on the remote
  1421. end, but need never again CONNECT to issue subsequent SEND, RECEIVE, EXIT, or
  1422. LOGOUT commands, even though many transactions may take place.  All actions
  1423. can be initiated from the PC.
  1424.  
  1425. @Section(Advanced Features)
  1426.  
  1427. An optional feature of the KERMIT protocol is a special packet designed to
  1428. express the attributes of a file in a compact and generic manner.  The receiver
  1429. may either attempt to use the attributes to the incoming file, or archive them
  1430. for later use.  Attributes include not only file characteristics but also the
  1431. intended disposition@dd()store, print, submit for batch processing, send as
  1432. mail, etc.  Other optional features include mechanisms for gracefully
  1433. interrupting, delaying, or suspending operations in progress; alternate forms
  1434. of packet data encoding; filename conversion, local file management, raw data
  1435. transmission and capture; command macro definition, etc.
  1436.  
  1437. Although KERMIT was never intended to fulfill the role of a general purpose
  1438. network server, its design has made it simple to add new functions.  A KERMIT
  1439. server has the ability to accept commands in packets from a remote KERMIT.
  1440. The basic commands are for sending or fetching files and for shutting down the
  1441. server.  Other commands may require display of text at the user's terminal,
  1442. which is controlled by the local KERMIT.  For example, a directory listing
  1443. could be requested; the resulting text is sent back to the local KERMIT
  1444. exactly as if a file were being transferred, except the destination is the
  1445. user's screen, rather than a disk file.  (Or it could be disk file too.)  With
  1446. this ability in place, it is possible to implement all sorts of commands, for
  1447. instance to delete a file, show who's logged in, inquire about disk space,
  1448. verify access to a directory, submit batch jobs, send messages, and so forth.
  1449.  
  1450. The ability of the KERMIT server to perform host functions can be added very
  1451. simply under certain operating systems.  For instance, under UNIX
  1452. @cite<--UNIX>, KERMIT can ``fork'' a @i<shell> with commands to perform any
  1453. function possible under UNIX, redirecting the standard output through a process
  1454. (KERMIT itself) that encapsulates it into KERMIT packets and sends it along.
  1455.  
  1456. A server with these capabilities could provide convenient access to a
  1457. timesharing system by users at personal workstations, without requiring the
  1458. users to be directly involved with the host.  If, for instance, workstations
  1459. had dedicated connections to a host, and the host had dedicated KERMIT servers
  1460. for each such line, users could get access to and manage their host files
  1461. completely by commands typed at the workstation.  Taking this idea one step
  1462. further, the workstation system software could be modified to make the whole
  1463. process transparent by incorporating a KERMIT-@|like protocol in its file
  1464. access logic@dd()fetching and updating host files as necessary behind the user's
  1465. back.  Since the demands placed on a host by KERMIT are relatively modest, many
  1466. more simultaneous users could probably be serviced in this way.  This approach
  1467. could be a relatively painless entree into the distributed, networked
  1468. environment of tomorrow.  When local area network protocols become mature and
  1469. the hardware economical and widespread, KERMIT can be replaced by ``the real
  1470. thing''.  But for the ordinary computer user for whom dedicated connections are
  1471. impractical, ``do-@|it-@|yourself'' KERMIT, or some facility like it, will be a
  1472. valuable tool for years to come.
  1473.  
  1474. @section(Conclusion)
  1475.  
  1476. The need for a cheap, convenient file transfer capability among diverse
  1477. systems is pressing, and there are certainly many efforts similar to ours
  1478. under way at many places.  We hope that this article may contribute to those
  1479. efforts; we don't claim to have the last word on any of the issues raised
  1480. here, and expect that this article may flush some other approaches out of the
  1481. woodwork.  We have billed KERMIT as a ``simple'' protocol; anyone who has read
  1482. this far will begin to appreciate what must go into the more complicated
  1483. protocols used in real networks, or when ``integration'' of micro and
  1484. mainframe is a major goal@dd()demand paging of remote files, remote database
  1485. queries, distributed editing and computation.
  1486.  
  1487. Meanwhile, the KERMIT protocol has been proven successful, and continues to
  1488. grow in popularity.  As of this writing, implementations exist for
  1489. more than 50 computer systems.  Some of the major ones include:
  1490. @begin<format,leftmargin +4>
  1491. @tabclear()@tabdivide(3)
  1492. @u<Machine>@\@ux<Operating System>@\@u<Language>
  1493. DECsystem-10@\TOPS-10@\MACRO-10
  1494. DECSYSTEM-20@\TOPS-20@\MACRO-20
  1495. IBM 370 Series@\VM/CMS@\IBM Assembler
  1496. VAX-11@\VMS@\Bliss-32
  1497. VAX, SUN, PDP-11, etc@\UNIX@\C
  1498. PDP-11@\RT-11, RSX, RSTS@\MACRO-11
  1499. 8080, 8085, or Z80@\CP/M@\8080 ASM
  1500. 8086, 8088@\PC DOS, MS DOS@\IBM PC Assembler
  1501. Apple II 6502@\Apple DOS@\DEC-10/20 CROSS
  1502. @end<format>
  1503. Some of these have been contributed or enhanced by the institutions listed in
  1504. the acknowledgements, below.  No single implementation necessarily includes all
  1505. the features mentioned in this article, but all are able to communicate at
  1506. least at base level.  Additional implementations are in preparation, and
  1507. present ones are being enhanced.
  1508.  
  1509. Columbia University is willing to provide all KERMIT programs, sources,
  1510. manuals, and other documentation to computing centers, academic or corporate,
  1511. in return for a modest fee to cover costs for media, printing, postage, labor,
  1512. and computing resources.  Only magnetic tape and listings can be shipped.  We
  1513. cannot produce floppy disks; instructions are included for bootstrapping the
  1514. microcomputer implementations from the mainframe computers.  Details will be
  1515. provided on request; write to:
  1516. @begin<verbatim,group,facecode R,leftmargin +4>
  1517. KERMIT Distribution
  1518. Columbia University Center for Computing Activities
  1519. 7th Floor, Watson Laboratory
  1520. 612 West 115th Street
  1521. New York, NY  10025
  1522. @end<verbatim>
  1523.  
  1524. The protocol specification supplemented by examples of existing KERMIT
  1525. implementations allows new implementations to be created with relative ease.
  1526. In the past, KERMIT implementors have shared their work with other KERMIT
  1527. users by contributing it to the Columbia KERMIT library.  We hope that this
  1528. practice will continue until KERMIT has spread throughout the known world.
  1529.  
  1530. @Section(Acknowledgements)
  1531.  
  1532. In designing the initial KERMIT protocol, we studied several models, primarily
  1533. the ANSI recommendation @cite<--A328>.  Others include the Stanford University
  1534. DIALNET project, the University of Utah ``Small FTP'' project, and the Stanford
  1535. University Medical Center TTYFTP project.  And we examined some real networks,
  1536. like ARPANET and DECnet.
  1537.  
  1538. Acknowledgements also to the many sites that have contributed new KERMIT
  1539. implementations or enhanced old ones: Stevens Institute of Technology, Digital
  1540. Equipment Corporation, the National Institutes of Health, Cornell University,
  1541. the University of Toronto, the University of Tennessee, the University of
  1542. Toledo, Cerritos College, and many others.  Thanks to Dr.@ Howard Eskin for
  1543. help with this article.
  1544.  
  1545. @newpage()
  1546. @Section(The ASCII Alphabet)
  1547. @begin<verbatim,spacing 1,need 20>
  1548. @u<Dec Oct Character  Dec Oct>
  1549. @blankspace(0.4)
  1550. 000 000    NUL (^@@)   064 100 @@
  1551. 001 001    SOH (^A)   065 101 A
  1552. 002 002    STX (^B)   066 102 B
  1553. 003 003    ETX (^C)   067 103 C
  1554. 004 004    EOT (^D)   068 104 D
  1555. 005 005    ENQ (^E)   069 105 E
  1556. 006 006    ACK (^F)   070 106 F
  1557. 007 007    BEL (^G)   071 107 G
  1558. 008 010    BS  (^H)   072 110 H
  1559. 009 011    HT  (^I)   073 111 I
  1560. 010 012    LF  (^J)   074 112 J
  1561. 011 013 VT  (^K)   075 113 K
  1562. 012 014    FF  (^L)   076 114 L
  1563. 013 015    CR  (^M)   077 115 M
  1564. 014 016    SO  (^N)   078 116 N
  1565. 015 017    SI  (^O)   079 117 O
  1566. 016 020    DLE (^P)   080 120 P
  1567. 017 021    DC1 (^Q)   081 121 Q
  1568. 018 022    DC2 (^R)   082 122 R
  1569. 019 023    DC3 (^S)   083 123 S
  1570. 020 024    DC4 (^T)   084 124 T
  1571. 021 025    NAK (^U)   085 125 U
  1572. 022 026    SYN (^V)   086 126 V
  1573. 023 027    ETB (^W)   087 127 W
  1574. 024 030    CAN (^X)   088 130 X 
  1575. 025 031    EM  (^Y)   089 131 Y
  1576. 026 032    SUB (^Z)   090 132 Z
  1577. 027 033    ESC (^[)   091 133 [
  1578. 028 034    FS  (^\)   092 134 \
  1579. 029 035    GS  (^])   093 135 ]
  1580. 030 036    RS  (^^)   094 136 ^
  1581. 031 037    US  (^_)   095 137 _
  1582. 032 040        (SP)   096 140 `
  1583. 033 041    !          097 141 a
  1584. 034 042    "          098 142 b
  1585. 035 043    #          099 143 c
  1586. 036 044    $          100 144 d
  1587. 037 045    %          101 145 e
  1588. 038 046    &          102 146 f
  1589. 039 047    '          103 147 g
  1590. 040 050    (          104 150 h
  1591. 041 051    )          105 151 i
  1592. 042 052    *          106 152 j
  1593. 043 053    +          107 153 k
  1594. 044 054    ,          108 154 l
  1595. 045 055    -          109 155 m
  1596. 046 056    .          110 156 n
  1597. 047 057    /          111 157 o
  1598. 048 060 0          112 160 p
  1599. 049 061 1          113 161 q
  1600. 050 062 2          114 162 r
  1601. 051 063 3          115 163 s
  1602. 052 064 4          116 164 t
  1603. 053 065 5          117 165 u
  1604. 054 066 6          118 166 v
  1605. 055 067 7          119 167 w
  1606. 056 070 8          120 170 x
  1607. 057 071 9          121 171 y
  1608. 058 072 :          122 172 z
  1609. 059 073 ;          123 173 {
  1610. 060 074 <          124 174 |
  1611. 061 075 =          125 175 }
  1612. 062 076 >          126 176 ~
  1613. 063 077 ?          127 177 DEL
  1614. @end<verbatim>
  1615.  
  1616. @newpage()
  1617. @Section(References)
  1618.  
  1619. The following publications provided useful guidance or diversion in the
  1620. development of KERMIT.
  1621.  
  1622. @Bibliography
  1623.  
  1624.