home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / protocol / checkpoint.txt < prev    next >
Text File  |  2020-01-01  |  80KB  |  1,778 lines

  1. KERMIT CHECKPOINT RESTART CAPABILITY REQUIREMENTS
  2.  
  3. August 16, 1993
  4.  
  5. Author:
  6.  
  7. Frank da Cruz
  8. Columbia University
  9. Internet: fdc@columbia.edu
  10. Telephone: W: 854-3508, H: 866-4894
  11.  
  12. Prepared By:
  13.  
  14. Computer Sciences Corporation
  15. M/C 265
  16. 3160 Fairview Park Dr.
  17. Falls Church, VA  22042
  18.  
  19. Table of Contents
  20.  
  21. INTRODUCTION
  22. REQUIREMENTS DEFINITION
  23. DESIGN
  24.   PARAMETERS
  25.   CONTROLLING THE CHECKPOINT FEATURE
  26.   NEGOTIATION OF CHECKPOINTING PROTOCOL
  27.   THE CHECKPOINT SYNC PACKET.
  28.   THE FILE TRANSFER PHASE
  29.   SPACE-CHECKING 
  30.   TERMINATING A SUCCESSFUL TRANSACTION
  31.   TAKING CHECKPOINTS
  32.   TEXT TRANSFER MODE
  33.   BINARY TRANSFER MODE
  34.   RECORDING CHECKPOINTS
  35.   THE CHECKPOINT REQUEST AND CONFIRMATION PACKETS
  36.   THE RECOVERY FILE
  37.   THE RECOVERY PROCESS
  38.   SERVER-MODE CONSIDERATIONS
  39.   SECURITY CONSIDERATIONS
  40.   MULTI-FILE TRANSFERS
  41.   AUTOMATIC REESTABLISHMENT OF CONNECTION
  42.   RECOVERY FROM AN INTERRUPTED TRANSFER THAT WAS NOT CHECKPOINTED
  43.   SUMMARY OF NEW COMMANDS AND PROTOCOL MESSAGES
  44. PROJECT OVERVIEW
  45.   DEVELOPMENT AND IMPLEMENTATION
  46.   DOCUMENTATION
  47.   TESTING
  48.   TIMELINE
  49.   ESTIMATED BUDGET
  50.   LICENSING
  51. REFERENCES
  52.  
  53. .c.INTRODUCTION
  54.  
  55. This report outlines a method for restarting a Kermit file transfer from a
  56. point of failure that should work correctly and dependably for all types of
  57. files independent of the underlying operating system and file system, plus a
  58. tentative implementation plan for MS-DOS, Windows, OS/2, UNIX, (Open)VMS,
  59. VM/CMS, MVS/TSO, and CICS.
  60.  
  61. This is a preliminary discussion of the design, and an estimate of the cost to
  62. create this functionality.
  63.  
  64. Familiarity with Kermit file transfer protocol [1] is assumed, as well as with
  65. the operation of popular Kermit programs such as MS-DOS Kermit [2], C-Kermit
  66. [3] and IBM Mainframe Kermit [4].
  67.  
  68. .c.REQUIREMENTS DEFINITION
  69.  
  70. The fundamental requirement of this project is the addition of a
  71. restart-from-point-of-failure capability to Kermit file transfer protocol and
  72. software.  This means that the transfer of a particular file can be resumed
  73. where it was interrupted, e.g. by loss of connection, with a minimum of
  74. retransmission overhead, and with the resulting destination file exactly as it
  75. would have been if it had been transferred successfully without interruption.
  76. In particular:
  77.  
  78.  1. A checkpoint/restart-capable Kermit program should be fully interoperable
  79.     with a Kermit program that does not have this capability.
  80.  
  81.  2. Recovery must work for both text and binary files.
  82.  
  83.  3. Recovery methods must workable between any pair of
  84.     computer/operating-system platforms, and be easily adaptable to future
  85.     systems.
  86.  
  87.  4. Recovery must not require the two computers to have similar file formats.
  88.  
  89.  5. The design must not lock out any popular type of computer or file system.
  90.  
  91.  6. The design must not depend on specific capabilities that some computers or
  92.     operating systems are likely to lack.
  93.  
  94.  7. Automatic (unattended) recovery should be possible.
  95.  
  96.  8. Manual (attended) recovery must be possible when automatic recovery is not.
  97.  
  98.  9. The net result of recovery must be a received file identical to what would
  99.     have been received in an uninterrupted transfer.
  100.  
  101. 10. Within reason, the constraints of the checkpointing mechanism should not
  102.     cause checkpointed transfers to fail in cases where non-checkpointed
  103.     transfers would succeed, nor vice versa.
  104.  
  105. 11. Neither Kermit program should make assumptions about the internal
  106.     operation of the other, nor about the other's underlying file system.
  107.     
  108. 12. Checkpointing should operate independently of the underlying communication
  109.     and protocol settings.  That is, it should work uniformly on serial and
  110.     network connections, slow and fast connections, full and half duplex
  111.     connections, 7- and 8-bit connections, with or without sliding windows or
  112.     long packets, with or without text-file character-set conversion, and so
  113.     on. 
  114.  
  115. 13. It is not desirable to invent a new notation or language for recovery
  116.     information.  Ordinary Kermit commands, parsable by the existing command
  117.     parsers, should be used to record and recover checkpointing information.
  118.     Commands and terminology should be internally consistent with each
  119.     Kermit software version, and that are also uniform among versions.
  120.  
  121. To assure that our design meets these requirements, we will implement it on
  122. the following diverse platforms:
  123.  
  124.  1. PCs with MS-DOS or Windows (MS-DOS Kermit) and PCs with OS/2 (C-Kermit). 
  125.     These computers have a sequential stream-oriented file system, in which
  126.     text files consist of lines terminated by CRLF.
  127.  
  128.  2. All computers running the UNIX operating system or any of its many
  129.     variants as well as Data General MV-series computers running the AOS/VS
  130.     operating system (C-Kermit).  UNIX and AOS/VS have sequential
  131.     stream-oriented file systems, in which text files consist of lines
  132.     terminated by LF, and thus change size when they are transferred to
  133.     (say) MS-DOS.
  134.  
  135.  3. DEC VAX or Alpha AXP computers running the OpenVMS operating system
  136.     (C-Kermit).  OpenVMS has an extremely complex record-oriented file system,
  137.     with many different record formats and file attributes.  Both text and
  138.     binary files almost always change size and format when transferred to
  139.     non-VMS systems.
  140.  
  141.  4. IBM mainframes with the VM/CMS, MVS/TSO, and CICS operating systems (IBM
  142.     Mainframe Kermit-370).  IBM mainframe operating systems have complicated
  143.     record-oriented file systems, but with details and capabilities different
  144.     from those of OpenVMS.  In addition, text files are encoded in EBCDIC
  145.     rather than ASCII-based codes.  As with VMS, both text and binary files
  146.     almost always change size and format when transferred to non-VMS systems.
  147.  
  148. Thus, checkpoint/restart capability will be added to three separate Kermit
  149. software programs, each of which can be built for and/or executed on various
  150. different hardware platforms and/or software environments.  These are, at
  151. present and for the foreseeable future, the three major Kermit software
  152. programs.
  153.  
  154. It is recognized that the immediate requirements of the contractor might not
  155. call for checkpoint/restart-capable Kermit software on all these platforms,
  156. but it is essential that we obtain operational proof-of-concept over a wide
  157. variety of computers and file systems to be reasonably certain that our design
  158. is adequate to cover all contingencies.
  159.  
  160. Before checkpoint/restart capability can be added to a Kermit software
  161. program, the program must already include the following capabilities:
  162.  
  163. - Basic Kermit file transfer protocol.
  164. - Attribute packets: file modification date/time, transfer mode (text/binary).
  165. - An interactive command parser.
  166. - The ability to execute commands from files.
  167.  
  168. These capabilities are available in C-Kermit, MS-DOS Kermit, and IBM Mainframe
  169. Kermit.  Note, in particular, that long packets, sliding windows,
  170. international character sets, single shifts, locking shifts, and other
  171. optional negotiated protocol features are neither required nor prohibited.
  172.  
  173. In addition, in order to automatically establish and reestablish connections,
  174. a Kermit program must support:
  175.  
  176. - Local-mode operation
  177. - Connection-establishment commands such as DIAL or TELNET
  178. - A script programming language (INPUT, OUTPUT, IF, GOTO, etc)
  179.  
  180. These capabilities are available in MS-DOS Kermit and C-Kermit, but not in
  181. IBM Mainframe Kermit.  IBM Mainframe Kermit is never the initiator of a
  182. connection.
  183.  
  184. Finally, the underlying operating system, file system, and programming
  185. interface must provide the following capabilities:
  186.  
  187. - To restart a transfer from the point of failure, the file sender should be
  188.   capable of positioning its file pointer to a given byte or record within the
  189.   input (source) file.  Thus, the source file must be on a random-access
  190.   device.
  191.  
  192. - The file receiver is assumed to be able to append new material to the end of
  193.   an existing file, or at least to be able to append two files together.  The
  194.   destination file need not be on disk -- it can also be a printer or other
  195.   type of sequential output device.
  196.  
  197. - To keep crash-resistent recovery files, both the file sender and receiver
  198.   must be capable of appending new material to the end of an existing file.
  199.  
  200. It is believed that every operating system offers these features.
  201.  
  202. .c.DESIGN
  203.  
  204. File transfer failures can be recoverable or unrecoverable.  If the Kermit
  205. program can determine the reason for a protocol failure, it must set a return
  206. or status code accordingly, which can be tested to determine whether automatic
  207. recovery should be attempted.  This will require:
  208.  
  209. - Assignment of standard error codes for transmission in error packets.
  210.   These would be numeric strings at the head of the Error-packet field,
  211.   which would cause no problems with Kermit programs which did not
  212.   understand them, but which could be used by updated programs.
  213.  
  214. - Creation of some kind of status variable that can be queried by a script
  215.   program, e.g. \v(recovery) in MS-DOS Kermit or C-Kermit.  This variable
  216.   would be set locally, or from an incoming E-packet's error code.
  217.  
  218. A recoverable failure is one that can be handled AUTOMATICALLY by a
  219. checkpoint-restart mechanism.  These include:
  220.  
  221. - Loss of connectivity, e.g. a dialup or network connection that was dropped,
  222.   but which can be reestablished a short time later.
  223.  
  224. - System failure, e.g. one of the two systems crashed for a short time.
  225.  
  226. An unrecoverable failure is one that can NOT be handled AUTOMATICALLY by a
  227. checkpoint-restart mechanism.  Examples include:
  228.  
  229. - Destination disk filled up or storage quota exceeded.
  230.  
  231. - Incorrect communication or protocol settings that prevented the transaction
  232.   from beginning successfully.
  233.  
  234. - Lack of sufficient transparency on the communication channel; for example, a
  235.   device that changes modes when it receives a certain sequence of characters.
  236.  
  237. - A system, component, or connection method that disappeared forever, and
  238.   similar "natural disasters".
  239.  
  240. Note that most unrecoverable failures can still be recovered manually.  For
  241. example, by fixing a broken computer, changing protocol or communication
  242. settings, cleaning up a full disk.
  243.  
  244. .c2.PARAMETERS
  245.  
  246. Terminology:
  247.  
  248. - In any particular connection, the Kermit program that originated the
  249.   connection is in LOCAL MODE, and the other Kermit program is in REMOTE
  250.   mode.  Similarly, one Kermit program is the file SENDER and the other is the
  251.   file RECEIVER.
  252.  
  253. - The file being transferred is the SOURCE FILE from the SENDER's point of
  254.   view, and is the DESTINATION FILE from the receiver's point of view.
  255.  
  256. The information is required to recover a failed transfer is the information
  257. necessary and sufficient to locate and verify the source and destination
  258. files, plus the information required for the sender to interpret the contents
  259. of the source file, and the receiver to interpret the contents of the incoming
  260. data packets:
  261.  
  262. - The TYPE OF TRANSFER: TEXT or BINARY.
  263.  
  264. - The fully qualified FILE SPECIFICATION of the source file: node, device,
  265.   directory, version, etc, sufficient to locate the same file again.  If a
  266.   fully qualified name is not available, then the RELATIVE NAME plus,
  267.   separately, the DEVICE, DIRECTORY, and any other necessary location
  268.   information.
  269.  
  270. - The SIZE and MODIFICATION DATE AND TIME of the source file, to verify it has
  271.   not changed. 
  272.   
  273. - Kermit's LOCAL ACCESS METHOD for the source file: TEXT, BINARY, MACBINARY,
  274.   V-BINARY, D-BINARY, LABELED, IMAGE, BLOCK, etc.  These items depend on the
  275.   Kermit implementation and the underlying file system.
  276.  
  277. - Any QUALIFIERS necessary for the source-file access method: ORGANIZATION
  278.   (sequential, indexed, relative, random, etc), RECORD FORMAT (fixed,
  279.   variable, variable with fixed header, stream CR, stream LF, stream CRLF),
  280.   RECORD-LENGTH, CARRIAGE CONTROL, MARGINS, etc.
  281.  
  282. - For text-mode transfers, the source FILE CHARACTER-SET.
  283.  
  284. - For text-mode transfers, the TRANSFER CHARACTER-SET.
  285.  
  286. - The fully-qualified FILE SPECIFICATION of the destination file: node,
  287.   device, directory, version, etc. or the relative name plus other location
  288.   information.
  289.  
  290. - Kermit's LOCAL ACCESS METHOD for the destination file: TEXT, BINARY,
  291.   MACBINARY, V-BINARY, D-BINARY, LABELED, IMAGE, BLOCK, etc.
  292.  
  293. - Any QUALIFIERS necessary for the local access method: ORGANIZATION, RECORD
  294.   FORMAT, RECORD-LENGTH, CARRIAGE CONTROL, MARGINS, etc.
  295.  
  296. - The SIZE of the destination file, to tell whether it has changed.
  297.  
  298. - For text-mode transfers, the local FILE CHARACTER-SET of the destination
  299.   file.
  300.  
  301. The information given above points up a minor inconsistency in Kermit command
  302. nomenclature.  The command:
  303.  
  304.   SET FILE TYPE { TEXT, BINARY, <others> }
  305.  
  306. actually does two things.  It defines the local file access method, and,
  307. by implication, also the transfer mode.  Examples:
  308.  
  309.   SET FILE TYPE TEXT     -- implies TEXT transfer mode
  310.   SET FILE TYPE BINARY   -- implies BINARY transfer mode
  311.   SET FILE TYPE IMAGE    -- implies BINARY transfer mode
  312.   SET FILE TYPE V-BINARY -- implies BINARY transfer mode
  313.   SET FILE TYPE LABELED  -- implies BINARY transfer mode
  314.  
  315. Strictly speaking, these are separate issues.  We might, for example, want to
  316. transfer a text file in binary mode, but using local access methods
  317. appropriate for text files.  Or we might want to transfer a binary file in
  318. text mode in order to get CRLFs appended to each record.  It is therefore
  319. worth distinguishing, at least conceptually, between the FILE TYPE and the
  320. TRANSFER MODE, and postulating (if not requiring) the availability of a new
  321. command:
  322.  
  323.   SET TRANSFER MODE { TEXT, BINARY }
  324.  
  325. .c2.CONTROLLING THE CHECKPOINT FEATURE
  326.  
  327. Checkpoint-restart capability might add perceptible overhead to file transfer
  328. operations.  Obviously, every attempt will be made to ensure that the
  329. checkpoint-restart implemetation is as efficient as possible, but the priority
  330. must be ironclad reliability.  As currently envisioned, however, checkpointing
  331. overhead will occur because separate recovery files must be maintained, files
  332. must be closed and opened repeatedly, and additional messages must exchanged
  333. throughout file transfer.  For this reason, and for compatibility with earlier
  334. Kermit software releases, this capability WILL NOT BE USED unless specifically
  335. requested.  The command is:
  336.  
  337.   SET CHECKPOINT { ENABLED, DISABLED, ON }
  338.  
  339. ENABLED will be the default.  It means "I will do checkpointing if requested"
  340. by the other Kermit.  DISABLED means "I won't do it", period.  ON tells your
  341. Kermit program to actively negotiate the use of checkpointing with another
  342. Kermit program.  For checkpointing to take place, at least one of the Kermits
  343. must SET CHECKPOINT ON, and the other must SET CHECKPOINT ON or ENABLED.  When
  344. recoverability is always the priority, SET CHECKPOINT ON can be included in
  345. the Kermit initialization file.
  346.  
  347. There must also be a control over how frequently checkpoints are taken:
  348.  
  349.   SET CHECKPOINT INTERVAL <number>
  350.  
  351. where <number> is the number of transmitted bytes at or after which a
  352. checkpoint should be taken.  The default is implementation-dependent, and also
  353. dependent on the type and characteristics of the file.  Let's say the nominal
  354. default is around 10K.  At 2400 bps -- a common dialup transmission speed --
  355. this amounts to about 45 seconds of transfer time.  At 9600 bps, it's only
  356. about 11 seconds and, naturally, decreases with transmission speed.
  357.  
  358. Checkpoint information is kept in a separate "recovery file" by each transfer
  359. partner.  The user should be allowed to specify the name of this file, even
  360. though this can complicate checkpointing setup for the user as well as the
  361. recovery process, particularly automated recovery.  The advantage of this
  362. feature is that it allows multiple recoveries to be pending.  For example, the
  363. user might have an automated procedure that connects to several hosts or
  364. services each night and transfers some files.  If one of these operations
  365. fails, it would be desirable to go on immediately to the next one, rather than
  366. wait the indefinite amount of time required to recover from the failed one,
  367. even if more than one transfer had failed.
  368.  
  369. The following command can be used to specify the name of the recovery file:
  370.  
  371.   SET CHECKPOINT RECOVERY-FILE <filespec>  
  372.  
  373. If this command is not given, an implementation-dependent default is used,
  374. which should be a fully qualified absolute pathname, so it can be found
  375. automatically in the event of an unattended restart.  In practice, this would
  376. be a file of a certain name that is located (for example) according to the
  377. same rules as the initialization file.  Examples:
  378.  
  379.   UNIX:    .kermrf in the user's home (login) directory (rf = recovery file)
  380.   MS-DOS:  MSKERMIT.RF in the same directory as the MSKERMIT.INI file
  381.   OS/2:    CKERMIT.RF in the same directory as the CKERMIT.INI file
  382.   VMS:     CKERMIT.RF in the user's home directory
  383.   VM/CMS:  KERMIT RF A1 (???)
  384.  
  385.   NOTE: The recommended device for recovery files on PCs is the boot drive,
  386.   since drive letters of other drives can change unexpectedly, e.g. when file
  387.   servers are involved.
  388.  
  389. There are, of course, dangers in recording information in separate recovery
  390. files.  For example, there might not be sufficient disk space for a recovery
  391. file.  In particular, it will not be possible to send a file with
  392. checkpointing from a computer whose storage is completely full or
  393. write-protected; in such cases, the SET CHECKPOINT RECOVERY-FILE command
  394. allows the recovery file to be placed in a separate storage area.
  395.  
  396. More subtly, a recovery file might grow to fill available storage on the file
  397. sender, receiver, or both.  Before proceeding, let's consider this situation.
  398. Suppose that a particular file transfer would have succeeded without
  399. checkpointing, but would fail with checkpointing because the recovery file
  400. filled up the disk, or there was an I/O error writing the recovery file, or
  401. there was some kind of checkpoint-related protocol error (e.g. caused by a
  402. programming mistake).  Should the transfer fail?  The user should be given the
  403. choice.  This can be accomplished with another SET CHECKPOINT command:
  404.  
  405.   SET CHECKPOINT ERROR-ACTION { PROCEED, QUIT }
  406.  
  407. The default action should be PROCEED, so that a file transfer will not fail
  408. simply because it is checkpointed.  In this case, the transfer continues but
  409. checkpointing is canceled.  When QUIT is elected, a checkpointing failure
  410. (e.g. failure to write to the recovery file) is fatal, and the transfer is
  411. canceled by an Error packet.
  412.  
  413. SET CHECKPOINT commands can be given to the file sender or the file receiver
  414. or both.  Checkpointing may be initiated by either party to the file
  415. transfer.  CHECKPOINT ERROR-ACTION QUIT, given to either party, is sufficient
  416. to stop a transfer when a checkpointing error occurs.
  417.  
  418. Finally, there should be a command:
  419.  
  420.   SHOW CHECKPOINT
  421.  
  422. This displays the current SET CHECKPOINT settings, and whether an active
  423. recovery file exists.
  424.  
  425. .c2.NEGOTIATION OF CHECKPOINTING PROTOCOL
  426.  
  427. The protocol initialization string (the data field of the S and I packets, and
  428. of their acknowledgements) contains the following new fields for checkpoint
  429. negotiation:
  430.  
  431.        10                                     new      new
  432.    ---+-----------+-------+--------+--------+--------+--------+
  433.  ...  | CAPAS ... | WINDO | MAXLX1 | MAXLX2 | CHKPNT | CHKINT |
  434.    ---+-----------+-------+--------+--------+--------+--------+
  435.  
  436. These fields are positional.  The CAPAS field (capabilities mask), beginning
  437. at position 10, is extensible to multiple bytes by setting its low-order bit
  438. (currently it occupies only one byte).  The WINDO byte is the first byte after
  439. the last CAPAS byte (we call this position CAPAS+1, currently byte 11).
  440. MAXLX1 is at CAPAS+2, and so forth.
  441.  
  442. The Attribute Packet Capability bit must be set in the capabilities mask.
  443. If it isn't, the following items are ignored and checkpointing is not done.
  444.  
  445. If the Kermit program does not support lower-numbered fields (e.g. WINDOW,
  446. MAXLX1, MAXLX2), then their positions must be filled with blanks so that the
  447. CHKPNT field is at the CAPAS+4 position and the CHKINT field takes up the next
  448. three bytes.
  449.  
  450. The new fields are encoded as follows:
  451.  
  452. 1. CHKPNT, 1 byte, values:
  453.  
  454.      0 = WONT  I won't do it (SET CHECKPOINT DISABLED)
  455.      1 = WILL  I will do it if asked (SET CHECKPOINT ENABLED)
  456.      2 = DO    Please do it (SET CHECKPOINT ON)
  457.  
  458.    Anything else (including absence of this byte) is interpreted as WONT.
  459.    These work as follows: 
  460.   
  461.      Sender  Receiver  Checkpointing  Initiator
  462.        WONT    (any)      No            None
  463.        WILL    WONT       No            None
  464.        WILL    WILL       No            None
  465.        WILL    DO         Yes           Receiver
  466.        DO      WONT       No            None
  467.        DO      WILL       Yes           Sender
  468.        DO      DO         Yes           Both
  469.  
  470. 2. CHKINT, checkpoint interval: 3 bytes, containing a base-95 number, with
  471.    digits in the normal offset-32 notation (SP = 0, ..., ~ = 95).  Maximum
  472.    value is 857374 = 95^3 - 1.  If this field is missing from, or incomplete
  473.    in, the receiver's ACK packet, or is zero (SP SP SP), checkpointing is not
  474.    done.  The protocol should allow any checkpoint interval at all, even an
  475.    interval of one byte, but the implementation (e.g. the command parser)
  476.    can prevent the user from selecting nonsensical values.
  477.  
  478. The FILE SENDER sets this field to the largest value it can handle.  For
  479. example, if the file sender is limited to 16-bit arithmetic, it might send a
  480. value of 65536.  If the file sender has no particular limit on its checkpoint
  481. interval, it should set it to the maximum: 857374 (~~~).
  482.  
  483. The FILE RECEIVER tells the file sender the checkpoint interval that should
  484. actually be used.  This value must be no larger than the CHKINT value sent by
  485. the file sender.  It may be any value equal to or less than the sender's
  486. value.
  487.  
  488. In cases where checkpointing is supported but not elected (i.e. CHKPNT = 0),
  489. the content of the CHKINT field is immaterial.  However, if the CHKPNT field
  490. is present, then the CHKINT field is required too.  In that case, the
  491. recommended contents for the CHKINT field is "___" (three underscores) to
  492. allow easy (human) identification.
  493.  
  494. .c2.THE CHECKPOINT SYNC PACKET
  495.  
  496. At the beginning of a checkpointed (or recovery) file transfer, after the
  497. A-packet but before the first data packet, there is a CHECKPOINT SYNC packet.
  498. Its packet type is H.  Its data field contains the following information:
  499.  
  500.   <len><xfer-id><len><checkpoint-id>
  501.  
  502. The <len> fields are single-character numbers in base-95 excess-32 notation.
  503. The <xfer-id> is an identifier for this file transfer.  This is a dynamically
  504. computed quantity that should be more-or-less globally unique, and so a
  505. many-digit date-and-time stamp, accurate to at least the second, would be a
  506. good choice, for example: 930808152832.  The <checkpoint-id> is described
  507. later, but on an "original" (first attempt, non-recovery) file transfer,
  508. it is the null string, i.e. its <len> field is 0 (SP).
  509.  
  510. If the CHECKPOINT SYNC packet fails to appear when expected -- that is, if a
  511. Data (D) or End-Of-File (Z) packet appears when an H packet is expected (this
  512. should not happen) -- the transaction is cancelled with an Error packet (if
  513. CHECKPOINT ERROR-ACTION is QUIT) or else checkpointing is disabled and the
  514. file transfer proceeds.
  515.  
  516. .c2.THE FILE TRANSFER PHASE
  517.  
  518. With checkpointing enabled, normal (i.e. non-recovery) file transfer proceeds
  519. as follows.  For each file:
  520.  
  521. - The file sender sends the F packet.
  522.  
  523. - The file receiver acknowledges it.
  524.  
  525. - The file sender sends one or more A-packets.
  526.  
  527. - The file receiver acknowledges the A-packets, accepting or rejecting the
  528.   file.
  529.  
  530. If the file is accepted:
  531.  
  532. - Upon receipt of the file acceptance notification (in the ACK to the
  533.   A-packet), the file sender opens a new recovery file (overwriting any
  534.   previous recovery file of the same name), computes the Transfer ID, writes
  535.   it to the recovery file, writes the "prelude" (file name, settings, etc) to
  536.   it (discussed below), closes it, and then sends a CHECKPOINT SYNC (H) packet
  537.   with the Transfer ID and with a null (zero-length) Checkpoint ID.  If
  538.   creation and initialization of the recovery file fails, the file sender
  539.   first ensures that the recovery file is destroyed, and then sends an Error
  540.   packet if CHECKPOINT ERROR-ACTION is QUIT, otherwise sends an H packet with
  541.   a null (zero-length) Transfer ID to cancel checkpointing operations.
  542.  
  543. - Upon receipt of an H packet containing a null Transfer ID notice, the file
  544.   receiver cancels checkpointing operations if its CHECKPOINT ERROR-ACTION is
  545.   PROCEED, and ACKs the H packet, with an uppercase letter X occyping the data
  546.   field of the ACK.  If its CHECKPOINT ERROR-ACTION is QUIT, it responds with
  547.   an E packet to cancel the entire file transfer.
  548.   
  549. - Upon receipt of an H packet containing a valid, non-null Transfer ID, the
  550.   file receiver opens and initializes its own recovery file (deleting any
  551.   previous recovery file), and ACKs the H-packet.  The ACK contains the same
  552.   Transfer ID and the receiver's checkpoint ID, which, on a non-recovery
  553.   transfer, is also null.  If the file receiver failed to open and initialize
  554.   its recovery file, then, if CHECKPOINT ERROR-ACTION is PROCEED, it places an
  555.   uppercase latter X in the data field of the ACK to the H packet; if it is
  556.   QUIT, then an Error packet is sent.
  557.   
  558. - At this point, data packets will start to arrive (unless the source file is
  559.   empty).  The file receiver writes incoming file data out to a TEMPORARY FILE
  560.   rather than to the real output file.  (The temporary file, obviously, must
  561.   be created in such a way as not to overwrite any existing files.)
  562.  
  563. - Checkpoints are taken and recovery files updated as described below.
  564.  
  565. - If a fatal error occurs during the data transfer phase, an error packet is
  566.   sent and a status code should be set to indicate the cause of the failure, so
  567.   the higher-level procedures can decide whether the failure is recoverable.
  568.  
  569. - Upon receipt of a Z packet, the file receiver takes the normal actions:
  570.   closes the output file and responds with an ACK if and only if the file was
  571.   closed successfully, otherwise with an E packet.
  572.  
  573. If possible, the partial destination file's modification date / time should be
  574. reset from the A-packet value each time the file is closed, to ensure that the
  575. destination file can be correctly identified should recovery be necessary.  In
  576. any case, the date/time should be set when the file is succesfully (fully)
  577. received and closed.
  578.  
  579. .c2.SPACE-CHECKING 
  580.  
  581. An optional feature of Kermit protocol and software is the ability to check
  582. available disk space before agreeing to accept an incoming file.  The file
  583. sender includes the file size (at best, an approximation, since it does not
  584. know what transformations will be done by the receiver); the receiver
  585. compares this number against available disk space, IF IT HAS THIS ABILITY
  586. (certain operating systems, notably UNIX and MVS/TSO, offer no good way to do
  587. this).
  588.  
  589. The use of temporary files and recovery files during checkpointing must be
  590. accounted for in the space calculation -- that is, the receiver must compare
  591. available space against the incoming file's size PLUS the negotiated
  592. checkpoint interval PLUS the estimated maximum size for the recovery file
  593. (if it is on the same storage device), with the customary allowance for
  594. expansion, depending on the transfer mode and operating systems involved.
  595.  
  596. .c2.TERMINATING A SUCCESSFUL TRANSACTION
  597.  
  598. At the end of a successful transaction (B packet sent and ACK'd), both
  599. recovery files can (and should) be deleted.  Thus, recovery files are deleted
  600. at the beginning of each file transfer and at the end of the transaction (this
  601. prevents the final recovery file from remaining on disk after a transaction
  602. is completed successfully).
  603.  
  604. If the B packet is ACK'd but the ACK is never received, the sender can still
  605. delete its recovery file, because it knows the (last) file was received
  606. successfully, since the End-Of-File (Z) packet had already been ACK'd.
  607.  
  608. .c2.TAKING CHECKPOINTS
  609.  
  610. When should checkpoints be taken?  We have to satisfy the constraints of both
  611. the sender and receiver.  Record-oriented file systems cannot be expected to
  612. write out a partial record, close the file, reopen it in append mode, and
  613. finish the partial record later.  Thus checkpoints must be taken at record
  614. boundaries when one or both of the file systems involved is record-oriented.
  615. Text- and binary-mode transfers, however, must be handled in different ways.
  616.  
  617. .c2.TEXT TRANSFER MODE
  618.  
  619. We take it for granted that all computer operating systems are capable of
  620. writing out a record (line) to a text file, no matter what the record
  621. format. We do not assume that an operating system can write partial lines.
  622. Therefore, in text mode transfers, the file sender must send checkpoint
  623. requests only on record (line) boundaries.
  624.  
  625. This means that the data packet preceding a checkpoint request might not be
  626. filled to capacity and, in fact, could be very short.  This should cause no
  627. protocol or data-integrity problems, but will, of course, have a slight impact
  628. on performance.
  629.  
  630. If a text line is longer than the checkpoint interval, there is no choice but
  631. to postpone the checkpoint until the end of the record, because we can not
  632. assume that the receiver can commit a partial record to disk.
  633.  
  634. Thus, in text mode, we view the checkpoint interval as a MINIMUM rather than a
  635. maximum, which simplifies matters quite a bit.  If we had to send a checkpoint
  636. *before* the checkpoint interval, there would be a need for record-oriented
  637. lookahead, and we would still need special handling for the case in which a
  638. record was longer than the checkpoint interval.  But note that this strategy
  639. also precludes the use of in-memory buffers in lieu of temp files, since there
  640. is no limit on the amount of data that might need to be stored in such a
  641. buffer.
  642.  
  643. .c2.BINARY TRANSFER MODE
  644.  
  645. Protocols like ZMODEM include a checkpoint-restart capability for binary files
  646. based on the assumption the length, format, and layout of a binary file will be
  647. exactly the same on both ends.  Nothing special happens during a normal file
  648. transfer.  To recover a binary-mode transfer, the file receiver sends the
  649. length of the partially-received destination file back to the file sender; the
  650. file sender positions its file pointer to the corresponding next byte in the
  651. source file and resumes sending from there.  This method assumes that both
  652. systems have a stream-oriented file system in which the file length is recorded
  653. as an exact number of bytes and that a byte-oriented file pointer capability
  654. is available to the sender.  There are numerous exceptions to this model.
  655.  
  656. When transferring in binary mode, record boundaries will still be important if
  657. the file receiver has a record-oriented file system, and thus checkpoints
  658. should still occur only on record boundaries.  But in this case, how does the
  659. file sender know when to send checkpoint requests?
  660.  
  661. Conversely, the file sender might have a record-oriented file system, and can
  662. only restart a transfer from a record boundary.
  663.  
  664. In the worst case, both systems are record-oriented, but use different record
  665. lengths.
  666.  
  667. Assumptions:
  668.  
  669. 1. On record-oriented systems, binary files have either fixed-length records
  670.    or else a fixed-length "allocation unit" (e.g. blocksize).
  671.  
  672. Discussion: CMS MODULEs and VMS object files are examples of binary files with
  673. variable length records.  Each record includes a header giving its length.
  674. Normally, the record header is NOT considered part of the data.
  675.  
  676. The Kermit protocol has a mechanism for dealing with such files, but this
  677. method has never been used because when such a file is sent to a
  678. stream-oriented file system, there is no way to preserve the record boundaries
  679. without also including the record headers.  Therefore, all existing Kermit
  680. programs transfer such files by including the record headers as part of the
  681. data itself.  The receiver is ignorant of the difference between files encoded
  682. this way and ordinary stream-binary files.
  683.  
  684. To accomplish such transfers, the Kermit program on the record-oriented system
  685. is put into a special "local file mode", known only to itself, such as
  686. V-BINARY (VM/CMS) or LABELED (VMS).  Files sent in such modes to
  687. non-record-oriented systems are said to be "archived", since the result
  688. contains structuring information as well as file data, and is, in general,
  689. not useful on the system to which it has been sent.  Rather, it is designed
  690. to be sent back to the type of system on which it originated, where it can be
  691. restored to its original (useful) format.
  692.  
  693. 2. One Kermit program cannot be expected to understand the archiving format
  694.    of a different Kermit program.
  695.  
  696. 3. Checkpoint requests can NOT be initiated by the file receiver.
  697.  
  698. Therefore archived files are transferred in regular binary mode, and if record
  699. length is an issue, it must be handled with a fixed number, whose value is to
  700. be determined.
  701.  
  702. Facts:
  703.  
  704. 1. There is presently no mechanism in the A- or F-packet exchange for the file
  705.    receiver to tell the sender the destination file's record length, blocksize,
  706.    etc (let's call this the "allocation unit").
  707.  
  708. 2. It does not make sense to do this in the S-packet exchange, because the
  709.    allocation unit can change from file to file.
  710.  
  711. Therefore, we need to invent new syntax for the ACK to the A packet, in which
  712. the receiver informs the sender of its file allocation unit.  This will be the
  713. new attribute tag '3' (ASCII 51).  In the sender's attribute packet, this
  714. works in the normal way: the sender informs the receiver of its allocation
  715. unit:
  716.  
  717.   3<len><number>
  718.  
  719. e.g.:
  720.   
  721.   3#512
  722.  
  723. However, the treatment of this attribute in the receiver's ACK to the
  724. attribute packet must be different from how other items in the Attribute ACK
  725. are handled.  Normally, the file receiver's ACK contains Y or N to accept or
  726. reject the file, respectively, followed by a list of attribute tags, but with
  727. no associated data.  The '3' tag, however, will have to carry data in the
  728. Attribute ACK.  This is an ugly special case, but it is preferable to
  729. exchanging an extra packet to convey this information.  The '3' tag is
  730. followed by a single-character base-94 offset-32 length field, and then a
  731. numeric value.  A value of 0 means "I don't care", and a value of 1 means that
  732. the Kermit program is capable of writing one byte at a time to an output file
  733. (in practice, 0 and 1 would be equivalent).  A value of 2 might be used by
  734. systems (like PRIME) that can do i/o only in "words" rather than bytes.
  735. Record-oriented systems would specify values like 80, 128, 512, 800, etc.
  736.  
  737.    NOTE: The effect of this field when received by Kermit programs that
  738.    are not aware of it must be considered.  Such Kermit programs will not
  739.    understand the '3' and might misinterpret the subsequent data as
  740.    attribute tags.
  741.  
  742. Now, assuming we have a mechanism to allow the receiver to inform the sender
  743. of the destination file's allocation unit, the sender must compute a
  744. checkpoint interval that allows checkpoints to occur on record boundaries that
  745. the source and destination files share in common.  This would be a number into
  746. which both the source and destination record lengths divide evenly, and which
  747. is also in the neighborhood of the desired checkpoint interval, e.g. 10240 for
  748. 512 and 80; in the worst case it would be the product of the two numbers.
  749.  
  750. In the most common cases, e.g. UNIX, MS-DOS, etc, there are no records and
  751. therefore binary-mode checkpoints can occur anywhere at all.  In the case where
  752. only one Kermit is record-oriented, the sender can choose any value close to
  753. the negotiated checkpoint interval that is a multiple of the record size.
  754.  
  755.   NOTE: The precise mechanism for binary mode checkpointing will require
  756.   further study and refinement during the development stage.
  757.  
  758. .c2.RECORDING CHECKPOINTS
  759.  
  760. Checkpointing must be entirely consistent with sliding windows.  Checkpoint
  761. requests and confirmations should flow smoothly among the data packets, which
  762. means that checkpoint requests and confirmations can be widely separated in
  763. time.
  764.  
  765. Since checkpoint requests and confirmations are separate packets, there can
  766. never be more than 31 of them in the window, since 31 is Kermit's maximum
  767. window size.  In fact, there will always be at least one data packet between
  768. checkpoints, so no more than 16 checkpoint requests would ever be in the
  769. window.
  770.  
  771. Each checkpoint is assigned a serial number, or ID, on which the two Kermit
  772. programs can synchronize during recovery.  Since there can never be more than
  773. 16 checkpoint requests outstanding, the checkpoint ID ranges from 0 to 15 and
  774. then recycles.
  775.  
  776. To handle checkpoints in the general case (windowed as well as non-windowed
  777. transfers), the file sender keeps a checkpoint window, implemented as a
  778. 16-element array indexed by the Checkpoint ID, which contains the recovery
  779. information associated with each checkpoint.  The checkpoint window is
  780. guaranteed to contain all the checkpoints that are also in the packet window.
  781.  
  782. A CHECKPOINT RECORD is written to the recovery file for each checkpoint.
  783. The format of a checkpoint record is:
  784.  
  785.   CHECKPOINT <id> <recovery-info>
  786.  
  787. where the Checkpoint ID is a decimal number, 0-15, and the system-dependent
  788. recovery information is as follows:
  789.  
  790. - For the FILE SENDER: how to identify the point in the source file
  791.   corresponding to the checkpoint, e.g. a file pointer to the next byte to be
  792.   read from the file, or the number or location or ID of the next record.
  793.  
  794. - For the FILE RECEIVER: the size of the destination file after the checkpoint
  795.   operation is completed, expressed in units appropriate to the file system:
  796.   bytes, blocks, etc.  It is, however, essential that this number grow as each
  797.   checkpoint is recorded.
  798.  
  799. Examples:
  800.  
  801.   CHECKPOINT 0 10240
  802.   CHECKPOINT 1 20480
  803.  
  804. .c2.THE CHECKPOINT REQUEST AND CONFIRMATION PACKETS
  805.  
  806. Checkpoint requests are made by the FILE SENDER by sending a discrete packet,
  807. with a new packet type of J.  The CHECKPOINT REQUEST packet contains the
  808. Checkpoint ID as a decimal ASCII numeric string, "0"-"15", in its Data field.
  809. The CHECKPOINT CONFIRMATION packet is simply an Acknowledgement (Y) for a
  810. CHECKPOINT REQUEST packet, containing the same Checkpoint ID in the same
  811. format.  If the data field of the J packet or its ACK contains the uppercase
  812. letter X instead of a numeric Checkpoint ID, this indicates a checkpointing
  813. error, which is to be handled according to the CHECKPOINT ERROR-ACTION
  814. setting.
  815.  
  816. A checkpoint is taken as follows:
  817.  
  818. 1. Sender opens the recovery file in append mode, writes a checkpoint record
  819.    into it, and then closes it.  If this operation fails, the transfer is
  820.    canceled with an E packet, or checkpointing is canceled with a J(X) packet,
  821.    according to CHECKPOINT ERROR-ACTION.
  822.  
  823. 2. Sender sends a J packet with the checkpoint ID in the data field, for
  824.    example J3.
  825.  
  826. 3. Upon receipt of the J packet, the file receiver performs the following
  827.    actions:
  828.  
  829.    a. Closes the temp file to ensure all data has been written out to it.
  830.  
  831.    b. Creates the destination file if it doesn't exist yet.
  832.  
  833.    c. Appends the temp file to the destination file.  NOTE: There is a
  834.       window of vulnerability if the computer should crash at this point,
  835.       or if the append operation succeeds, but fills the disk: the destination
  836.       file is updated, but the update is not recorded in the recovery file.
  837.       This situation is detected and handled during the recovery operation.
  838.   
  839.    d. If and only if all the above actions were successful, and if the J
  840.       packet did not contain the "X" cancellation indicator, the file receiver
  841.       opens its recovery file in append mode, writes the current checkpoint
  842.       info to it, and closes it.
  843.  
  844.    e. Deletes the temp file, creates a new one, and opens it for write access.
  845.  
  846.    f. If and only if all the above actions were successful, the receiver sends
  847.       a CHECKPOINT CONFIRMATION (ACK with Checkpoint ID in Data field) back to
  848.       the file sender.  Otherwise, the error is handled according the the
  849.       CHECKPOINT ERROR-ACTION setting: if PROCEED, cancel checkpointing and
  850.       respond with X in the data field of the ACK; if QUIT, send an E-packet.
  851.  
  852. Observe that the connection can fail after the J packet has been sent, but
  853. before it was received, and therefore the two recovery files will be out of
  854. sync.  Similarly, the connection can fail after the ACK is sent but before it
  855. is received.  It is impossible to devise a strategy to assure that the two
  856. recovery files always WILL be in sync, especially on a long-delay connection
  857. with sliding windows active.
  858.  
  859. The simple strategy given above resolves this dilemma by ensuring that when
  860. the recovery files ARE out of sync, that the SENDER IS ALWAYS AHEAD of the
  861. receiver.  We know that it is possible for the sender to move its source-file
  862. pointer back to any desired position (byte or record), but we cannot make any
  863. such assumption about the file receiver.  For all practical purposes, the
  864. destination file could be a printer, a deck of cards, or a punched paper tape,
  865. where what is done cannot be undone.
  866.  
  867. .c2.THE RECOVERY FILE
  868.  
  869. Since a file transfer failure might have been caused by a computer crash,
  870. information about the transfer must be recoverable after a computer restart.
  871. Therefore it must be recorded on a nonvolatile device.  This would normally be
  872. in the file system as a separate file on disk.  Each Kermit program keeps its
  873. own recovery file.
  874.  
  875. The recovery file will not contain connection information such as phone
  876. number, communication settings, etc.  In order to reestablish a connection
  877. automatically from the recovery file, it would be necessary to store a
  878. password there, and this violates the most fundamental concepts of computer
  879. security.  Therefore, automatic connection reestablishment must be
  880. accomplished using other methods, to be discussed later.
  881.  
  882. The recovery file must contain sufficient information to ensure that in a
  883. recovery operation:
  884.  
  885. - The two recovery files apply to the same file transfer transaction.
  886.  
  887. - The correct source and destination files are identified for recovery, and
  888.   have not changed in the meantime. 
  889.  
  890. - All settings that affect the final result of the transfer are the same as
  891.   in the original transfer operation. 
  892.  
  893. - The two Kermit programs agree upon the exact point of failure.
  894.  
  895. The recovery file is composed of ordinary Kermit commands (some of them new)
  896. and executed just like any other command file.  Certain commands might make
  897. sense only in recovery mode; those commands could be marked as invisible or
  898. invalid in other modes.
  899.  
  900. A new recovery file is written for EACH FILE that is transferred.  No attempt
  901. is made to include transfer history for multiple files.  There are several
  902. reasons for this:
  903.  
  904. - The recovery file could become quite large.
  905.  
  906. - Processing of the recovery file could take a long time and cause a lot of
  907.   disk activity (e.g. accessing directory information for many files).
  908.  
  909. - Various complications arise when we allow the recovery file to apply to many
  910.   files.  For example, ASSERT commands (see below) could fail, causing
  911.   premature termination of a RECOVER operation, even though the file that the
  912.   ASSERT commands apply to was transferred successfully (e.g. the file was
  913.   modified after it was transferred).
  914.  
  915. - There is no particular benefit in keeping records for multiple files.  It
  916.   does not, for example, tell us which files were NOT transferred yet.
  917.  
  918. For this reason, a recovery file is created as the transfer of EACH file
  919. begins, and is destroyed (only) after the file is transferred successfully.
  920.  
  921. The first command in the recovery file should be:
  922.  
  923.   SET TRANSFER ID <text>
  924.  
  925. The transfer ID is the key that joins the sender's and receiver's recovery
  926. files together.
  927.  
  928. Each Kermit program should then write the commands corresponding to all
  929. settings that could affect the contents and form of the destination file, for
  930. example:
  931.  
  932.   SET FILE TYPE TEXT
  933.   SET FILE CHARACTER-SET CP850
  934.   SET TRANSFER CHARACTER-SET LATIN1
  935.   SET FILE ... (system-dependent things -- record length, etc)
  936.  
  937. Next we specify the direction of file transfer.
  938.  
  939.   SET TRANSFER ACTION { SEND, RECEIVE, MAIL <address>, PRINT <options> }
  940.  
  941. And then, if necessary (that is, if fully qualified file specifications are
  942. not available), we specify the current location at the time the SEND or
  943. RECEIVE command was given.  If this command appears in the recovery file, all
  944. subsequent filenames that are not fully qualified are relative to this path:
  945.  
  946.   CD <path>
  947.  
  948. In a moment, we will give the name of the file that is being transferred and
  949. make several ASSERTIONS about it.  An assertion fails if it is not
  950. true. Therefore we must ensure that if any of the subsequent commands fail,
  951. the recovery operation itself fails:
  952.  
  953.   SET TAKE ERROR ON; (This is the syntax for C-Kermit)
  954.  
  955. (This would be equivalent, in MS-DOS Kermit 3.13 and earlier, to putting the
  956. command IF FAILURE END 1 after each command.)  It is essential that processing
  957. fail if any of these assertions proves false, otherwise there is no guarantee
  958. that the recorded checkpoints are accurate.
  959.  
  960. Now we identify the file:
  961.  
  962.   SET TRANSFER FILE <name>
  963.  
  964. <name> is either a fully qualified path name or else, if a CD command was
  965. given, a path name relative to the path given in the CD command.
  966.  
  967. If the TRANSFER ACTION is SEND, MAIL, or PRINT, the Kermit program also
  968. obtains the file's size and its modification date and time, and then checks to
  969. make sure they haven't changed.  The new command, ASSERT, tells Kermit to
  970. check that the given condition is true and to FAIL if it isn't:
  971.  
  972.   ASSERT TRANSFER FILE DATE <modification-date-time>
  973.  
  974. This ensures the current modification date-and-time of the file given in the
  975. SET TRANSFER FILE command are the same as the given date and time.
  976. Similarly, the file sender also includes:
  977.  
  978.   ASSERT TRANSFER FILE SIZE <number>
  979.  
  980. to ensures that the file's size is still the one given.
  981.  
  982. The remainder of the recovery file consists of checkpoint records and a final
  983. STATUS record:
  984.  
  985.   CHECKPOINT 0 <recovery-info>
  986.   CHECKPOINT 1 <recovery-info> 
  987.   CHECKPOINT 2 <recovery-info> 
  988.   ...
  989.  
  990. At the end of a transaction, a STATUS statement records the status of the file
  991. transfer:
  992.  
  993.   STATUS <code>
  994.  
  995. The code is the numeric status code (values to be assigned).  0 means the file
  996. was transferred successfully.
  997.  
  998. If there is no STATUS statement -- that is, if the file ends on a CHECKPOINT
  999. statement -- it means the computer (or Kermit) crashed in the midst of file
  1000. transfer, and the status is assumed to be a recoverable failure.
  1001.  
  1002. SAMPLE RECOVERY FILE
  1003.  
  1004. Here is a sample recovery file for a successful file transfer, from the file
  1005. sender's point of view:
  1006.  
  1007.   ; ... PRELUDE
  1008.   SET TRANSFER ID 930719152832          ; File transfer ID
  1009.   SET FILE TYPE TEXT                    ; Transfer settings
  1010.   SET FILE CHARACTER-SET CP850
  1011.   SET TRANSFER CHARACTER-SET LATIN1
  1012.   SET TRANSFER ACTION SEND              ; We're sending files
  1013.   CD /usr/olga                          ; Current directory
  1014.   SET TAKE ERROR ON;
  1015.   SET TRANSFER FILE NAME oofa.txt       ; File identification
  1016.   ASSERT TRANSFER FILE DATE 930808125959
  1017.   ASSERT TRANSFER FILE SIZE 1234567
  1018.   ; ... CHECKPOINT HISTORY
  1019.   CHECKPOINT 0 10240                    ; Checkpoint records
  1020.   CHECKPOINT 1 20480
  1021.   CHECKPOINT 2 30720
  1022.   ...
  1023.   STATUS 0                              ; Completion status
  1024.  
  1025. .c2.THE RECOVERY PROCESS
  1026.  
  1027. A transfer failed, the connection is broken.  The user reestablishes the
  1028. connection, logs back in to the remote computer, starts Kermit, and gives the
  1029. following new command:
  1030.  
  1031.   RECOVER
  1032.  
  1033. or, to identify a non-default recovery file:
  1034.  
  1035.   RECOVER <filespec>
  1036.  
  1037. The RECOVER command enables checkpointing automatically, so if the recovery
  1038. operation itself fails, it can be recovered just like any other interrupted
  1039. file transfer for which checkpoints were taken.
  1040.  
  1041. The RECOVER command is similar to the TAKE command in that it directs the
  1042. command parser to execute commands from a file, but with certain key
  1043. differences:
  1044.  
  1045. 1. It sets a recovery-in-progress flag that persists until the transfer
  1046.    described in the recovery file is complete (or fails).
  1047.  
  1048. 2. It enables or recognizes certain commands that are invalid or ignored
  1049.    during ordinary command processing (such as CHECKPOINT and STATUS).
  1050.  
  1051. 3. It disables certain commands that are valid outside of recovery mode
  1052.    (such as SEND, RECEIVE, CONNECT, EXIT, HELP, etc), to protect against
  1053.    "hand-crafted" recovery files.
  1054.  
  1055. 4. It enters protocol mode automatically upon encountering the end of a
  1056.    valid recovery file.
  1057.  
  1058. The remote Kermit reads the recovery file, executes all the settings, makes
  1059. all the checks, etc, and if all is well, gives the KERMIT READY TO
  1060. xxx... message and enters packet mode ("xxx" is SEND or RECEIVE, depending on
  1061. the given TRANSFER ACTION).
  1062.  
  1063. Now the user escapes back to the local Kermit and gives a RECOVER command
  1064. there too.  The local Kermit reads its own recovery file.
  1065.  
  1066. When the FILE SENDER (which may be the remote or local Kermit program) reads
  1067. the checkpoint records from its recovery file, it loads them into its
  1068. checkpoint window, so in case an earlier checkpoint must be used, it can be
  1069. located immediately without having to re-read the recovery file.
  1070.  
  1071. The FILE RECEIVER (which may be the local or remote Kermit program) reads
  1072. checkpoint records until it has found the last one.  Now it compares the
  1073. <recovery-info> with the current status (most commonly, the size) of the
  1074. destination file, and then:
  1075.  
  1076.   IF THE DESTINATION FILE IS BIGGER THAN THE SIZE RECORDED IN THE
  1077.   FINAL CHECKPOINT RECORD, THE RECEIVER'S CHECKPOINT ID IS INCREMENTED
  1078.   BY ONE (modulo 16).
  1079.  
  1080. If the destination file size is larger than the final recorded checkpoint, we
  1081. know that exactly one checkpoint had been taken but not recorded.  This shuts
  1082. the "window of vulnerability" noted previously.
  1083.  
  1084. Each program enters packet mode upon encountering the end of the recovery
  1085. file, but only if the final entry was a CHECKPOINT statement or a STATUS
  1086. statement indicating a failure.  Otherwise, an error message is printed and
  1087. the RECOVER command fails because there is nothing to recover.
  1088.  
  1089. After the normal S, F, and A packet exchanges, the file sender sends the
  1090. CHECKPOINT SYNC (H) packet, and the receiver checks it.  If the Transfer IDs
  1091. don't agree, the transfer terminates in error.
  1092.  
  1093.   NOTE: If, by chance, the wrong recovery file is used on one end, and we wind
  1094.   up with two recovery files specifying the same TRANSFER ACTION (SEND or
  1095.   RECEIVE), the operation will quickly fail with an unexpected packet type.
  1096.  
  1097. Now the checkpoints from the CHECKPOINT SYNC packet are compared.  If they do
  1098. not agree, then -- by design -- the sender's will be the higher of the two,
  1099. and the sender rolls back its checkpoint to the one reported by the receiver.
  1100. This information is already loaded into the sender's checkpoint window from
  1101. the CHECKPOINT records in the recovery file.
  1102.  
  1103. Now the file sender positions the source file to the agreed-upon checkpoint
  1104. and begins sending from there.  The file receiver writes out incoming data to
  1105. temporary files and appends them to the destination file in the normal manner.
  1106. Checkpoints are appended to the SAME recovery files that were used to launch
  1107. the recovery operation.
  1108.  
  1109.   Note that the recovery-in-progress flag should inhibit the re-writing
  1110.   of the recovery-file "prelude", i.e. the material preceding the first
  1111.   CHECKPOINT record.
  1112.  
  1113. If a recovered transfer fails, the RECOVER command sets a failure code for
  1114. IF SUCCESS / IF FAILURE, and the recovery file -- perhaps with additional
  1115. checkpoints and status appended to it, is preserved so subsequent recovery
  1116. attempts can be made.
  1117.  
  1118. .c2.SERVER-MODE CONSIDERATIONS
  1119.  
  1120. Some sites might wish to run a Kermit program only in server mode.  For
  1121. example, a Kermit server might be installed as the login shell on a particular
  1122. computer for users who log in as "kermit" or "guest".  Or a Kermit server
  1123. might be set up on an Internet TCP socket, similar to an FTP server.  Escape
  1124. to command mode might be disabled for security or other reasons.
  1125.  
  1126. Kermit servers, too, can participate in checkpointed file transfers.  The
  1127. protocol and procedures are the same.  Checkpointing must be initiated by the
  1128. client program unless the server has been told to SET CHECKPOINT ON before
  1129. entering server mode.
  1130.  
  1131. In order to recover an interrupted checkpointed file transfer when a Kermit
  1132. server is involved, a new protocol message is required by which the client
  1133. program instructs the server to recover the interrupted transfer.  This will
  1134. be in the form of a "Generic" server command, packet-type G, new subtype O:
  1135.  
  1136.     +-----+--------------------+
  1137.     |  G  | O <len> <filename> |
  1138.     +-----+--------------------+
  1139.      Type   Data
  1140.  
  1141. This packet would be sent to the server when the client executed the command:
  1142.  
  1143.   REMOTE RECOVER [ <filename> ]
  1144.  
  1145. Normally, the filename would not be given, since the client would usually
  1146. have no way of knowing what it was.  Thus the <len> would normally be zero
  1147. (expressed as a SP character).
  1148.  
  1149. Upon receipt of a REMOTE RECOVER command packet, the Kermit server would
  1150. behave exactly as if it had been given an interactive RECOVER command except
  1151. that any errors would cause the server to send an error packet and return to
  1152. server command wait, rather than setting a FAILURE status and returning to the
  1153. prompt.  That is, neither success nor failure of the recovery operation should
  1154. cause the server to exit from server mode.
  1155.  
  1156. .c2.SECURITY CONSIDERATIONS
  1157.  
  1158. Kermit software programs should never give users access to files that they
  1159. would not otherwise have access to.
  1160.  
  1161.   NOTE: The statement above is subject to minor caveats.  For example,
  1162.   in UNIX, it is sometimes necessary to grant a Kermit program
  1163.   special privileges to access communication devices or UUCP lockfiles
  1164.   or UUCP lockfile directories that are not normally accessible, but
  1165.   these privileges should not otherwise amplify the user's access rights.
  1166.   See the discussion in the UNIX C-Kermit installation notes, CKUINS.DOC.
  1167.  
  1168. Managers of multiuser computer systems in which it is possible to confer
  1169. privileges on a program are always cautioned to install Kermit software as an
  1170. ordinary, unprivileged user program.  Obviously, this recommendation can not
  1171. be enforced any more for Kermit than it can for any other application software
  1172. program.  Thus any discussion of security relative to Kermit software has to
  1173. assume it is installed according to recommendations.
  1174.  
  1175. During a checkpointed file transfer, unprivileged Kermit software programs
  1176. will not create any files that the user could not have created by other
  1177. conventional means.  The additional files are the temporary files created by
  1178. the file receiver and the recovery files created by both sender and receiver.
  1179.  
  1180. Neither do recovery files themselves pose a risk, as long as the Kermit
  1181. programs are unprivileged.  Recovery files do not contain passwords or other
  1182. authentication material.  Even if users alter recovery files in an attempt to
  1183. gain access to forbidden information or resources, unprivileged Kermit
  1184. software programs will not grant them such access.  That is, Kermit software
  1185. does not run with any kind of privilege or identity in checkpointing or
  1186. recovery mode that it does not ordinarily have.
  1187.  
  1188. Thus, addition of checkpoint/restart capability to Kermit software introduces
  1189. NO NEW SECURITY RISKS.
  1190.  
  1191. .c2.MULTI-FILE TRANSFERS
  1192.  
  1193. A multi-file transfer is the transfer of a group of files in a single Kermit
  1194. TRANSACTION; that is, a series of protocol messages initiated by an S-packet
  1195. exchange and terminated by a B-packet exchange.  Zero, one, or more files may
  1196. be transferred in this way.  Multi-file transfers are typically initiated by
  1197. the use of wildcards or with an MSEND command containing a file list.
  1198.  
  1199. The file list (either directly given or the result of wildcard expansion) is
  1200. not conveyed from one Kermit to another, nor is it necessarily recorded
  1201. locally.  The order in which files are transferred cannot be guaranteed from
  1202. one transaction to another.  Thus, the files themselves -- and their
  1203. operating-system-dependent attributes -- are the database from which we must
  1204. construct recovery information.
  1205.  
  1206. The Kermit protocol already offers a mechanism to recover from multi-file
  1207. transfers at the point of failure, on a per-file basis.  To enable this type
  1208. of recovery, one of the following settings are given to the file RECEIVER:
  1209.  
  1210. SET FILE COLLISION DISCARD:
  1211.   If a file arrives that has the same name as a file that already exists in
  1212.   the current device/directory, the incoming file is refused via Kermit's
  1213.   attribute refusal mechanism, and the existing file is preserved.
  1214.  
  1215. SET FILE COLLISION UPDATE
  1216.   If a file arrives that has the same name as a file that already exists in
  1217.   the current device/directory, AND the incoming file's modification date and
  1218.   time is less than or equal to (older than) that of the existing file, the
  1219.   incoming file is refused via Kermit's attribute refusal mechanism, and the
  1220.   existing file is preserved.
  1221.  
  1222. This mechanism is independent of ordering, but entails a small amount of
  1223. overhead as S, F, and Z packet exchanges occur for each file already
  1224. transferred.
  1225.  
  1226. This mechanism can be used in conjunction with checkpoint-restart to recover a
  1227. multi-file transfer:
  1228.  
  1229. 1. Recover the file that failed.
  1230.  
  1231. 2. Resend the file group with the appropriate collision action selected
  1232.    at the receiver.
  1233.  
  1234. .c2.AUTOMATIC REESTABLISHMENT OF CONNECTION
  1235.  
  1236. Connection establishment occurs before Kermit protocol is activated, using
  1237. commands like SET PORT, SET SPEED, DIAL, CONNECT, etc, and then by
  1238. authenticating oneself to the remote host or service.  This process is easily
  1239. automated in MS-DOS Kermit or C-Kermit using a script program -- a procedure
  1240. written in the Kermit program's own command language.  Here is a crude example
  1241. that would apply to both C-Kermit and MS-DOS Kermit.
  1242.  
  1243.   set count 20             ; Try up to 20 times to transfer the file
  1244.   set checkpoint on        ; Turn on checkpointing
  1245.   askq \%p Password:       ; Prompt for password interactively
  1246.                            ; (This is used by LOGIN.SCR)
  1247.   :LOGIN
  1248.   hangup
  1249.   dial 7654321             ; Dial the phone number
  1250.   if fail end 1
  1251.   take login.scr           ; Execute the login script
  1252.   set file type text       ; Set transfer parameters
  1253.   output kermit\13         ; Start Kermit on remote end
  1254.   input 5 ermit>           ; Wait for prompt
  1255.   if failure end 1         ; No prompt, fail
  1256.   if > 0 \v(count) -
  1257.     goto recover           ; Go to separate section for recovery
  1258.  
  1259.   :FIRST                   ; First try (non-recovery)
  1260.   output receive\13        ; Send RECEIVE command
  1261.   input 5 RECEIVE...       ; Wait for packet-mode prompt
  1262.   send message.txt         ; Try to send a file
  1263.   if success end 0         ; Success, we're finished
  1264.   if not = \v(recovery) 0 -
  1265.     end 1                  ; Failure not recoverable, quit
  1266.   if count goto login      ; Recoverable, go try again.
  1267.   end 1 Too many tries.
  1268.  
  1269.   :RECOVER
  1270.   output recover\13        ; Send RECOVER command
  1271.   input 5 RECEIVE...       ; Wait for packet-mode prompt
  1272.   recover                  ; Tell local Kermit to RECOVER
  1273.   if success end 0         ; Success, we're finished
  1274.   if not = \v(recovery) 0 -
  1275.     end 1                  ; Failure not recoverable, quit
  1276.   if count goto login      ; Recoverable failure, try again
  1277.   end 1 Too many tries
  1278.  
  1279. Automated recovery is always initiated by the caller, since only the caller
  1280. knows how to reestablish the connection.  Some Kermit programs, such as
  1281. Kermit-370, are never the caller, and so need not implement any of the
  1282. connection re-establishment features.
  1283.  
  1284. .c2.RECOVERY FROM AN INTERRUPTED TRANSFER THAT WAS NOT CHECKPOINTED
  1285.  
  1286. The checkpoint/restart protocol described in this document takes place only
  1287. when: (a) both Kermit programs have implemented the checkpoint/restart
  1288. protocol, and (b) the user has enabled its use.
  1289.  
  1290. Suppose a non-checkpointed file transfer is interrupted?  Normally, the
  1291. receiving Kermit discards any incoming file that is not completely received.
  1292. However, most Kermit programs include a command:
  1293.  
  1294.   SET FILE INCOMPLETE { DISCARD, KEEP }
  1295.  
  1296. The default is DISCARD, which is proper because users should never be given
  1297. the false impression that an incomplete file transfer was successful.  To
  1298. enable the retention of partially received files, the user must give the
  1299. command to the file receiver prior to the transfer:
  1300.  
  1301.   SET FILE INCOMPLETE KEEP
  1302.  
  1303. When this option is in effect, interrupted file transfers can be recovered
  1304. manually by a somewhat laborious and error-prone process:
  1305.  
  1306. 1. The user examines the partially received destination file to determine
  1307.    exactly where the transfer was interrupted.
  1308.  
  1309. 2. The user uses a text editor or other utility to extract the as-yet
  1310.    unsent portion of the source file into a separate file.
  1311.  
  1312. 3. The user transfers the newly created source-file fragment to the
  1313.    destination system, either as a new and separate file.
  1314.  
  1315. 4. The user appends the two destination files together.
  1316.  
  1317. (Steps 3 and 4 can be combined via some trickery plus SET FILE COLLISION
  1318. APPEND, if available, on the receiving Kermit.)
  1319.  
  1320. A simple modification to existing Kermit software -- independent of the
  1321. checkpoint/restart feature and of the Kermit protocol itself -- can simplify
  1322. this process somewhat.  A new command, PSEND (Partial Send):
  1323.  
  1324.   PSEND <filename> <number>
  1325.  
  1326. can be used to tell the Kermit program to send the given file (the name of a
  1327. single file, not a wildcard or file-group specification) starting at the
  1328. position given by the <number>, where <number> is a system-dependent quantity,
  1329. representing a byte position, a record number, etc.  Meanwhile, the file
  1330. receiver is told to:
  1331.  
  1332.   SET FILE COLLISION APPEND
  1333.  
  1334. meaning: when a file arrives that has the same name as an existing file,
  1335. append the new material to the end, rather than creating a new file or
  1336. overwriting the old one.
  1337.  
  1338. To handle the case where the file sender cannot be given a starting position
  1339. that corresponds exactly to the end of the partially received destination file
  1340. (for example, if the file sender has a record-oriented file system, but the
  1341. receiver has a byte-oriented file system, or a different record size), the
  1342. following new command can be given to the file receiver:
  1343.  
  1344.   PRECEIVE <filename> <number>
  1345.  
  1346. This instructs the file receiver to write incoming bytes beginning at the
  1347. position given by <number>, possibly overwriting existing material.  PRECEIVE
  1348. capability is not necessarily possible in all operating systems.
  1349.  
  1350. It is, of course, the user's responsibility to reestablish all the original
  1351. settings before attempting this type of recovery: text vs binary, character
  1352. set, record length, etc.
  1353.  
  1354. Recovery from interrupted transfers using this method can never be automatic
  1355. (because the required information is not recorded anywhere) and is possible
  1356. only when the file receiver has been given the command SET FILE INCOMPLETE
  1357. KEEP in advance.  If this mode of recovery is always desired as a fallback
  1358. when true checkpoint/restart protocol has not been enabled or successfully
  1359. negotiated, the SET FILE INCOMPLETE KEEP command can be added to the Kermit
  1360. initialization file.
  1361.  
  1362. .c2.SUMMARY OF NEW COMMANDS AND PROTOCOL MESSAGES
  1363.  
  1364. Commands:
  1365.  
  1366. SET CHECKPOINT { ENABLED, DISABLED, OFF }
  1367. SET CHECKPOINT INTERVAL <number>
  1368. SET CHECKPOINT RECOVERY-FILE <filename>
  1369. SET CHECKPOINT ERROR-ACTION { PROCEED, QUIT }
  1370. SHOW CHECKPOINT
  1371. SET TRANSFER ID <number>
  1372. SET TRANSFER ACTION { SEND, RECEIVE, MAIL <address>, PRINT <options> }
  1373. SET TRANSFER FILE <filename>
  1374. ASSERT TRANSFER FILE DATE <modification-date-time>
  1375. ASSERT TRANSFER FILE SIZE <number>
  1376. STATUS
  1377. PSEND <filename> <position>
  1378. PRECEIVE <filename> <position>
  1379.  
  1380. Protocol Messages:
  1381.  
  1382. CAPAS mask in Initialization string must include Attribute Packets bit.
  1383. CHKPNT and CHKINT fields added to Initialization string.
  1384. New CHECKPOINT SYNC (H) packet.
  1385. New CHECKPOINT REQUEST (J) packet. 
  1386. New ALLOCATION UNIT field (Tag 3) in ACK to A-Packet.
  1387.  
  1388. .c.PROJECT OVERVIEW
  1389.  
  1390. The checkpoint-restart project will consist of five phases:
  1391.  
  1392.   1. Requirements Definition
  1393.   2. Design
  1394.   3. Development / Implementation
  1395.   4. Testing
  1396.   5. Deployment
  1397.  
  1398. The initial requirements definition and design for Kermit protocol extensions,
  1399. user interface, nomenclature, and recovery procedures are given in this
  1400. document.  This design will be refined and expanded during the development
  1401. process.
  1402.  
  1403. .c2.DEVELOPMENT AND IMPLEMENTATION
  1404.  
  1405. This is to be considered a small project that should not be subject to the
  1406. formality of controls that apply to large projects.  It will be conducted by
  1407. one principal designer, with design review by the contractor and by the other
  1408. developers, and with programming work by no more than four programmers on
  1409. three different bodies of source code.
  1410.  
  1411. Development and implementation will proceed in build-a-little, test-a-little
  1412. increments.  The individuals involved in the project will cooperate closely
  1413. at all times (primarily by Internet email and file transfer), rather than
  1414. working on discrete compenents in isolation from one another.  Most of the
  1415. work after the design stage will proceed in parallel, with developments and
  1416. discoveries constantly feeding back into the design and implementation plan
  1417. as real-life experience is gained with issues that have, so far, been
  1418. completely abstract.  Thus a highly detailed and specific "critical path"
  1419. analysis would not apply to this project.  However, the overall structure
  1420. of the workflow can be depicted as follows:
  1421.  
  1422. +---------+         +-------------+         +---------+      +------------+
  1423. | Initial | ------> | Development | ------> | Public  | ---> | Acceptance |
  1424. | Design  | --+     | and testing |         | Beta    |      | testing    |
  1425. +---------+   |     +-------------+    +--> | testing |      +------------+
  1426.               |                        |    +---------+
  1427.               |    +---------------+   |
  1428.               +--> | User & tech   | --+
  1429.                    | Documentation |
  1430.                    +---------------+
  1431.  
  1432. Omitted from this diagram (for simplicity) is the obvious fact that each stage
  1433. can feed back to earlier stages.  For example, development and testing might
  1434. require changes in the design; Beta or acceptance testing might reveal bugs
  1435. that need fixing or even previously undiscovered design problems, and so on.
  1436.  
  1437. Here is a preliminary outline of the work to be done.  This outline gives a
  1438. suggested order in which tasks are to be accomplished, proceeding from the
  1439. general (items not strictly related to checkpoint/restart capability, but
  1440. needed as underpinnings to it) to the specific, with prototyping done at 
  1441. appropriate points.
  1442.  
  1443. In most cases, later items depend on earlier items.  This outline is not,
  1444. however, a rigid prescription.  In particular, developers should feel free to
  1445. proceed to a later item if they are temporarily blocked (perhaps for reasons
  1446. beyond their control) by an earlier item.  For example, if a particular
  1447. feature is to be tested among all combinations of MS-DOS Kermit, C-Kermit, and
  1448. IBM Mainframe Kermit, but that feature is not yet ready in, say, C-Kermit, the
  1449. MS-DOS and IBM Mainframe Kermit developers should not feel compelled to do
  1450. nothing until C-Kermit is ready, but rather, they may proceed with other items
  1451. that do not depend on that feature.
  1452.  
  1453. A. LAYING THE FOUNDATION
  1454.  
  1455.  1. Implementation, testing, and documentation of requisite capabilities that
  1456.     are lacking from specific Kermit software programs:
  1457.  
  1458.     - SET FILE COLLISION APPEND capability in MS-DOS and VMS C-Kermit.
  1459.     - SET FILE COLLISION UPDATE capability in MS-DOS Kermit.
  1460.     - SET { TAKE, MACRO } { ERROR, ECHO } { ON, OFF } in MS-DOS Kermit.
  1461.     - Carrier-loss detection in MS-DOS Kermit: SET CARRIER { ON, OFF, AUTO }.
  1462.     - Possible addition of an intrinsic DIAL command to MS-DOS Kermit, with
  1463.       associated SET MODEM and SET DIAL commands as in C-Kermit.
  1464.  
  1465.  2. Redesign of C-Kermit's file input module specification to deliver
  1466.     consistently marked records, and recoding of system-dependent file i/o
  1467.     modules according to the new specification.
  1468.  
  1469.  3. Implementation, testing, and documentation of PSEND and PRECEIVE commands
  1470.     to establish the ability to seek within a file.
  1471.  
  1472.  4. Definition of standardized Kermit protocol error codes and their meanings.
  1473.  
  1474.  5. Addition of standardized error codes to E packets in the three major
  1475.     Kermit versions.
  1476.  
  1477.  6. Classification of error codes into recoverable and nonrecoverable
  1478.     categories and addition of a new variable or status code that can be
  1479.     queried to see whether a failed transfer is recoverable.
  1480.  
  1481.  7. Coding and testing of file allocation unit to Attribute-packet reply.
  1482.  
  1483. B. CHECKPOINT/RESTART FRAMEWORK CODE DEVELOPMENT
  1484.  
  1485.  1. Definition of file and variable names for checkpoint/restart, and
  1486.     specification of the associated semantics.
  1487.  
  1488.  2. Coding, testing, and documentation of the commands to set and display
  1489.     checkpoint-related variables and capabilities: SET CHECKPOINT { ON,
  1490.     DISABLED, ENABLED , INTERVAL, RECOVERY-FILE, ERROR-ACTION }, SHOW
  1491.     CHECKPOINT.  At this stage, these commands simply set and display internal
  1492.     variables.
  1493.  
  1494.  3. Coding, testing, and documentation of the ASSERT TRANSFER FILE command.
  1495.  
  1496.  4. Coding, testing, and documentation of the following prototype
  1497.     (nonoperational) commands:
  1498.  
  1499.     - SET TRANSFER ID <xfer-id>
  1500.     - SET TRANSFER FILE <filename>
  1501.     - SET TRANSFER ACTION { SEND, RECEIVE }
  1502.     - CHECKPOINT <number-list>
  1503.     - STATUS <number>
  1504.  
  1505.     The Kermit program will parse these commands, but will not associate any
  1506.     actions with them.  Check for syntactic problems or conflicts with other
  1507.     commands as well as conceptual problems or difficulties with documentation.
  1508.  
  1509.  5. Create and test a new module used by the file sender to generate a transfer
  1510.     ID and write the initial part of the recovery file.  At this stage of
  1511.     development, this module would be called by the file sender at the time it
  1512.     opens the input (source) file.
  1513.  
  1514.  6. Ensure that the same Kermit program can read the prototype recovery files
  1515.     back without syntax errors, and set the corresponding variables correctly.
  1516.  
  1517.  7. Ensure that the file sender creates a new Transfer ID and recovery file for
  1518.     each file in a file group, and that each recovery file is destroyed after
  1519.     the file is successfully transferred, and that the proper recovery file
  1520.     remains on disk when a transfer is interrupted.  Test with file groups
  1521.     consisting of zero files, one file, and more than one file.
  1522.  
  1523.  8. Coding and testing of a module (in some cases, perhaps a preexisting 
  1524.     system call) to create a temporary output file without destroying any
  1525.     existing file.
  1526.  
  1527.  9. Coding of a module that appends one file to another.  Install a new
  1528.     file-management command, APPEND <source> <dest>, to test this code.
  1529.    
  1530. 10. Enable use of temporary files by the file receiver without checkpointing.
  1531.     Receive into a temporary file, and when the transfer is complete, rename
  1532.     the temporary file to the desired name.
  1533.  
  1534. C. CODE DEVELOPMENT FOR CHECKPOINTED FILE TRANSFER
  1535.  
  1536.  1. Coding and testing of checkpoint/restart protocol negotiation: WILL, WONT,
  1537.     DO; communication of checkpoint interval.  Add display and/or debugging
  1538.     tools to monitor the progress and/or results of the negotiation.  Test all
  1539.     combinations of SET CHECKPOINT { ON, OFF, ENABLED } among MS-DOS Kermit,
  1540.     C-Kermit, and Kermit-370, as well as against a non-checkpoint-capable
  1541.     Kermit version.
  1542.  
  1543.  2. Add the new CHECKPOINT SYNC (H) packet and the appropriate protocol state
  1544.     transitions and actions.  Sender generates a new Transfer ID, and uses a
  1545.     null Checkpoint ID.  Create and initialize the recovery file in both file
  1546.     sender and receiver.  To test, collect packet logs and ensure that the new
  1547.     packets are exchanged, have the correct format, and that file transfers
  1548.     still work.  Also, ensure that the H-packet is NOT exchanged when
  1549.     checkpointing has not been negotiated.  Also, ensure that failure of the
  1550.     CHECKPOINT SYNC packet to appear at the proper time when checkpointing has
  1551.     been negotiated is handled according to CHECKPOINT ERROR-RECOVERY.
  1552.     Inspect the recovery files and ensure they are correct.
  1553.  
  1554.  3. Implementation of the checkpointing process in the file sender:
  1555.  
  1556.     - Determination of when to initiate a checkpoint request, based on
  1557.       negotiated checkpoint interval and file record/line boundaries.
  1558.  
  1559.     - Addition of capability to terminate a file-transfer data packet on a
  1560.       record (e.g. text line) boundary, rather than filling the packet.
  1561.  
  1562.     - Creation of the checkpoint window structure and recording of checkpoints.
  1563.  
  1564.     - Writing of CHECKPOINT and STATUS records to the recovery file.
  1565.  
  1566.     - Transmission of CHECKPOINT REQUEST packets.
  1567.  
  1568.     - Ability of receiver to accept CHECKPOINT REQUEST packets without error,
  1569.       but without actually processing them, so the sender's code can be tested.
  1570.  
  1571.  4. Testing of checkpointing process in the file sender:
  1572.  
  1573.     - Collect packet logs.
  1574.  
  1575.     - Test both text and binary mode transfers.
  1576.  
  1577.     - Binary transfers should be tested for stream and record-oriented systems.
  1578.  
  1579.     - Ensure that checkpoints were taken at the right places.
  1580.  
  1581.     - Ensure that CHECKPOINT records were written correctly.
  1582.  
  1583.     - Dump the checkpoint window periodically to ensure it is correct.
  1584.  
  1585.     - Ensure that appropriate STATUS records are written for both successful
  1586.       and failed transfers.
  1587.  
  1588.  5. Implementation of the checkpointing process in the file receiver.  Upon
  1589.     receipt of CHECKPOINT REQUEST packet:
  1590.  
  1591.     - Flush, close temp file.
  1592.  
  1593.     - Append temp file to destination file and delete temp file.
  1594.  
  1595.     - Create new temp file for subsequent incoming data.
  1596.  
  1597.     - If all OK, write CHECKPOINT record to recovery file.
  1598.  
  1599.     - If OK, send CHECKPOINT CONFIRMATION packet, otherwise cancel transfer
  1600.       or checkpointing according to CHECKPOINT ERROR-RECOVERY setting.
  1601.  
  1602.  6. Testing of the checkpointing process in the file receiver:
  1603.  
  1604.     - Ensure destination files (both text and binary) are created correctly.
  1605.  
  1606.     - Ensure that CHECKPOINT CONFIRMATION packets are correct.
  1607.  
  1608.     - Ensure recovery file updated correctly with CHECKPOINT and STATUS
  1609.       records. 
  1610.  
  1611.     - Ensure recovery file is retained when transfer fails, destroyed when
  1612.       transfer succeeds.
  1613.  
  1614.  7. Further Testing of checkpointed transfers.  Verify that all mechamisms
  1615.     coded so far work on or for:
  1616.  
  1617.     - Text and binary files
  1618.  
  1619.     - For binary files: stream and record oriented.
  1620.  
  1621.     - For record-oriented binary files: records of different sizes / formats
  1622.  
  1623.     - All window sizes (test on long-delay connections with large windows
  1624.       sizes) 
  1625.  
  1626.     - Long and short packets
  1627.  
  1628.     - Single-file transfers and file-group transfers
  1629.  
  1630.     - 7-bit and 8-bit connections
  1631.  
  1632.     - With and without text character-set conversion.
  1633.  
  1634.     - Serial and network connections
  1635.  
  1636.     - Noisy and clean connections
  1637.  
  1638.     - Between all combinations of MS-DOS Kermit, C-Kermit, and Kermit-370
  1639.  
  1640.  8. Performance Evaluation.  Compare file transfer efficiency with and without
  1641.     checkpointing:
  1642.  
  1643.     - For various checkpoint intervals
  1644.  
  1645.     - For text and binary files
  1646.  
  1647.     - For various window-size / packet-length combinations
  1648.  
  1649. D. CODE DEVELOPMENT FOR RECOVERY FROM POINT OF FAILURE
  1650.  
  1651.  1. Implementation of the CHECKPOINT command.  This command simply loads the
  1652.     given information into the indicated slot in the checkpoint window.
  1653.  
  1654.  2. Implementation of the STATUS command.  This simply sets an internal
  1655.     variable to the given number.
  1656.  
  1657.  3. Implementation of SET TRANSFER { FILE, ID, ACTION } commands.   
  1658.  
  1659.  4. Implementation of the RECOVER command:
  1660.  
  1661.     - Locate and read recovery file, validate info, determine TRANSFER ACTION.
  1662.  
  1663.     - Open the transfer file in the given mode (read or write)
  1664.  
  1665.     - Load checkpoint window.
  1666.  
  1667.     - Determine final transfer status, don't recover if 0.
  1668.  
  1669.     - Close recovery file.
  1670.  
  1671.     - Enable checkpointing.
  1672.  
  1673.     - Enter protocol mode according to TRANSFER ACTION.
  1674.  
  1675.     - Process and synchronize CHECKPOINT SYNC from recovery file info.
  1676.  
  1677.     - Sender positions source-file pointer to indicated position.
  1678.  
  1679.     - Receiver opens destination file in append mode.
  1680.  
  1681.     - File transfer resumes where it left off when interrupted.
  1682.  
  1683.     - Recovery files are updated and disposed of in the normal way.
  1684.  
  1685.  5. Testing the RECOVER command:
  1686.  
  1687.     - Collect packet logs on both ends, inspect to ensure correctness.
  1688.  
  1689.     - Using all combinations of connections, protocol settings, file settings,
  1690.       systems, etc, ensure that files of all types are recovered correctly.
  1691.  
  1692.     - Ensure that a recovery operation can itself be interrupted and recovered.
  1693.    
  1694. E. SAMPLE SCRIPTS FOR AUTOMATIC RECOVERY
  1695.  
  1696.  1. Write and refine sample scripts for automated connection establishment,
  1697.     file transfer, detection of recoverable failures, connection
  1698.     reestablishment, and file transfer recovery.
  1699.  
  1700.  2. Test with single- and multiple-file transfers.
  1701.  
  1702.  3. Test on direct serial, dialed, and network connections.
  1703.  
  1704.  4. Test for recovery by caller and callee.
  1705.  
  1706.  5. Test recovery when receiver's recovery file is one checkpoint behind
  1707.     the destination file.
  1708.  
  1709. .c2. DOCUMENTATION
  1710.  
  1711. Throughout the development / implementation stage, technical documentation
  1712. will be updated and refined, and trial copies of user documentation of each
  1713. user-visible feature will be produced as that feature is added.
  1714.  
  1715. The technical documentation will include extensions to the Kermit protocol
  1716. specification [1] as well as additions to the relevent program logic manuals
  1717. (PLMs).  Eventually the extensions to the Kermit protocol will be published in
  1718. a new edition of [1].  PLMs are generally maintained as online
  1719. English-language plain-text files.
  1720.  
  1721. Trial user documentation will be compiled from the documentation written
  1722. during the development period, in the form of online English-language plain
  1723. text, to be issued in the update or release notes with beta-test or newly
  1724. released versions of the updated Kermit software programs.  Eventually, the
  1725. user interface to the checkpoint/restart features will be described in new
  1726. editions of the relevent published or online user manuals.
  1727.  
  1728. .c2.TESTING
  1729.  
  1730. Testing is performed by the developers at each step of the development
  1731. process.  When the initial implementation is complete, further testing will
  1732. be done by project members who were not personally involved in the coding.
  1733.  
  1734. Once the internal tests are complete, the updated software and documentation
  1735. will be turned over to the contractor for evaluation and testing, and, upon
  1736. the contractor's go-ahead, will also be released to the general Internet user
  1737. community for Beta testing.  We feel that the wider Internet community will
  1738. give the updated software a much more thorough workout on a much wider variety
  1739. of platforms and communication methods than the developers or contractors
  1740. could ever hope to accomplish by themselves.
  1741.  
  1742. After the public Beta test period is complete, the resulting software and
  1743. documentation will be turned over to the contractor for acceptance testings.
  1744. A detailed formal test plan will accompany the software.  The contractor may,
  1745. of course, devise its own tests.  Once the contractor has accepted the
  1746. software, all test notices will be removed from its banners and documentation,
  1747. and it will be released.
  1748.  
  1749. .c2.TIMELINE
  1750.  
  1751. Requirements Definition and Initial Design:  One month.  Done.
  1752.  
  1753. The development and testing phase is expected to take four months.  Thus, if
  1754. work commences September 1, it will be complete by December 31.
  1755.  
  1756. Development (keyed to section labels used above), 3 calendar months, 3-5
  1757. people working in parallel on each phase:
  1758.  
  1759.   A: One calendar month
  1760.   B: One half calendar month
  1761.   C: One half calendar month
  1762.   D: One half calendar month
  1763.   E: One half calendar month
  1764.  
  1765. Testing: One month
  1766.  
  1767. .c.REFERENCES
  1768.  
  1769. [1] da Cruz, Frank, "Kermit, A File Transfer Protocol", Digital Press (1987).
  1770.  
  1771. [2] Gianone, Christine, "Using MS-DOS Kermit", 2nd Ed., Digital Press (1992).
  1772.  
  1773. [3] da Cruz, F., and C. Gianone, "Using C-Kermit", Digital Press (1993).
  1774.  
  1775. [4] Chandler, John, "IBM System/370 Kermit User's Guide", unpublished (1993).
  1776.  
  1777. (End of Document)
  1778.