home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-MODEM.ARJ / XYMODEM.DOC < prev    next >
Encoding:
Text File  |  1990-11-04  |  54.9 KB  |  1,559 lines

  1.                                   - 1 -
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                      XMODEM/YMODEM PROTOCOL REFERENCE
  9.                  A compendium of documents describing the
  10.  
  11.                             XMODEM and YMODEM
  12.  
  13.                          File Transfer Protocols
  14.  
  15.  
  16.  
  17.  
  18.                    This document was formatted 9-11-86.
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                          Edited by Chuck Forsberg
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.                  Please distribute as widely as possible.
  42.  
  43.                        Questions to Chuck Forsberg
  44.  
  45.  
  46.  
  47.  
  48.  
  49.                            Omen Technology Inc
  50.                         17505-V Sauvie Island Road
  51.                           Portland Oregon 97231
  52.                            Voice: 503-621-3406
  53.             Modem (Telegodzilla): 503-621-3746 Speed 1200,300
  54.                           Compuserve: 70007,2304
  55.                     UUCP: ...!tektronix!reed!omen!caf
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                                   - 2 -
  68.  
  69.  
  70.  
  71. 1.  ROSETTA STONE
  72.  
  73. Here are some definitions which reflect the current vernacular in the computer
  74. media.  The attempt  here is identify the  file transfer protocol rather  than
  75. specific programs.
  76.  
  77. XMODEM  refers to the original 1979 file transfer etiquette introduced by Ward
  78.     Christensen's  1979  MODEM2  program.  It's  also  called the MODEM or
  79.     MODEM2 protocol. Some who are  unaware of MODEM7's unusual batch  file
  80.     mode call it  MODEM7. Other aliases  include "CP/M Users's  Group" and
  81.     "TERM  II  FTP  3".  This  protocol  is  supported  by  every  serious
  82.     communications program  because of  its universality,  simplicity, and
  83.     reasonable performance.
  84.  
  85. XMODEM/CRC  replaces  XMODEM's  1  byte  checksum  with  a  two  byte Cyclical
  86.         Redundancy Check (CRC-16), giving modern error detection protection.
  87.  
  88. XMODEM-1k Refers to the XMODEM/CRC protocol with 1024 byte data blocks.
  89.  
  90. YMODEM  refers to the XMODEM/CRC (optional 1k blocks) protocol with the  batch
  91.     transmission described below.
  92.  
  93. ZMODEM  uses familiar XMODEM/CRC and YMODEM technology in a new protocol  that
  94.     provides reliability, throughput, file management, and user  amenities
  95.     appropriate to contemporary data communications.
  96.  
  97.  
  98. 2.  YET ANOTHER PROTOCOL?
  99.  
  100. Since its development half a  decade ago, the Ward Christensen  modem protocol
  101. has enabled a wide variety of computer systems to interchange data.  There  is
  102. hardly a communications  program that doesn't  at least claim  to support this
  103. protocol.
  104.  
  105. Recent advances in computing, modems and networking have revealed a number  of
  106. weaknesses in the original protocol:
  107.  
  108.    + The  short  block  length  caused  throughput  to  suffer when used  with
  109.      timesharing systems,  packet switched  networks, satellite  circuits, and
  110.      buffered (error correcting) modems.
  111.  
  112.    + The 8 bit arithmetic checksum and other aspects allowed line  impairments
  113.      to interfere with dependable, accurate transfers.
  114.  
  115.    + Only one file could be sent per  command.  The file name had to be  given
  116.      twice,  first  to  the  sending  program  and then again to the receiving
  117.      program.
  118.  
  119.    + The transmitted file could accumulate as many as 127 extraneous bytes.
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. Chapter 2
  131.  
  132.  
  133. X/YMODEM Protocol Reference      09-11-86                                3
  134.  
  135.  
  136.  
  137.    + The modification date of the file was lost.
  138.  
  139. A number of other protocols have been developed over the years, but none  have
  140. displaced XMODEM to date:
  141.  
  142.    + Lack  of  public  domain  documentation  and  example programs have  kept
  143.      proprietary protocols such as MNP, Blast, and others tightly bound to the
  144.      fortunes of their suppliers.
  145.  
  146.    + Complexity discourages the widespread application of BISYNC, SDLC,  HDLC,
  147.      X.25, and X.PC protocols.
  148.  
  149.    + Performance  compromises  and   moderate  complexity  have  limited   the
  150.      popularity of  the Kermit  protocol, which  was developed  to allow  file
  151.      transfers in environments hostile to XMODEM.
  152.  
  153. The XMODEM protocol extensions and YMODEM Batch address these weaknesses while
  154. maintaining XMODEM's simplicity.
  155.  
  156. YMODEM is supported  by the public  domain programs YAM  (CP/M), YAM(CP/M-86),
  157. YAM(CCPM-86), IMP (CP/M), KMD (CP/M), rz/sz (Unix, Xenix, VMS, Berkeley  Unix,
  158. Venix, Xenix, Coherent, IDRIS,  Regulus).  Commerical implementations  include
  159. MIRROR,  and  Professional-YAM.[1]  Communications  programs  supporting these
  160. extensions have been in use since 1981.
  161.  
  162. The 1k packet  length (XMODEM-1k) described  below may be  used in conjunction
  163. with YMODEM  Batch Protocol,  or with  single file  transfers identical to the
  164. XMODEM/CRC protocol except for minimal changes to support 1k packets.
  165.  
  166. Another  extension  is  simply  called  the  g  option.   It  provides maximum
  167. throughput when used with end to end error correcting media, such as X.PC  and
  168. error correcting modems, including the  emerging 9600 bps units by  Electronic
  169. Vaults and others.
  170.  
  171. To complete this tome, Ward Christensen's original protocol document and  John
  172. Byrns's CRC-16 document are included for reference.
  173.  
  174. References to  the MODEM  or MODEM7  protocol have  been changed  to XMODEM to
  175. accommodate  the  vernacular.   In  Australia,  it  is  properly  called   the
  176. Christensen Protocol.
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. __________
  190.  
  191.  1. Available for IBM PC,XT,AT, Unix and Xenix
  192.  
  193.  
  194.  
  195. Chapter 2
  196.  
  197.  
  198. X/YMODEM Protocol Reference      09-11-86                                4
  199.  
  200.  
  201.  
  202. 2.1  Some Messages from the Pioneer
  203.  
  204. #: 130940 S0/Communications 25-Apr-85  18:38:47
  205. Sb: my protocol
  206. Fm: Ward Christensen 76703,302 (EDITED)
  207. To: all
  208.  
  209. Be aware the article[2]  DID quote me correctly  in terms of the  phrases like
  210. "not robust", etc.
  211.  
  212. It was a quick hack I  threw together, very unplanned (like everything  I do),
  213. to satisfy a personal need to communicate with "some other" people.
  214.  
  215. ONLY the fact that it was done in 8/77, and that I put it in the public domain
  216. immediately, made it become the standard that it is.
  217.  
  218. I think its time for me to
  219.  
  220. (1) document it; (people call me and say "my product is going to include it  -
  221. what can I 'reference'", or "I'm writing a  paper on it, what do I put in  the
  222. bibliography") and
  223.  
  224. (2) propose an "incremental extension"  to it, which might take  "exactly" the
  225. form of Chuck Forsberg's YAM protocol.  He wrote YAM in C for CP/M and put  it
  226. in the public domain, and wrote a batch protocol for Unix[3] called rb and  sb
  227. (receive batch, send batch), which was basically XMODEM with
  228.  
  229.    (a) a record 0 containing filename date time and size
  230.    (b) a 1K block size option
  231.    (c) CRC-16.
  232.  
  233. He did some clever programming to detect false ACK or EOT, but basically  left
  234. them the same.
  235.  
  236. People who suggest I make SIGNIFICANT  changes to the protocol, such as  "full
  237. duplex", "multiple outstanding blocks", "multiple destinations", etc etc don't
  238. understand  that  the  incredible  simplicity  of  the  protocol is one of the
  239. reasons it survived to this day in as many machines and programs as it may  be
  240. found in!
  241.  
  242. Consider the PC-NET group back in '77  or so - documenting to beat the  band -
  243. THEY had a protocol,  but it was "extremely  complex", because it tried  to be
  244. "all things to all people" - i.e. send binary files on a 7-bit system, etc.  I
  245. was not that "benevolent". I (emphasize > I < ) had an 8-bit UART,
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252. __________
  253.  
  254.  2. Infoworld April 29 p. 16
  255.  
  256.  3. VAX/VMS versions of these programs are also available.
  257.  
  258.  
  259.  
  260. Chapter 2
  261.  
  262.  
  263. X/YMODEM Protocol Reference      09-11-86                                5
  264.  
  265.  
  266.  
  267. so "my protocol was an 8-bit protocol", and I would just say "sorry" to people
  268. who were held back by 7-bit limitations.  ...
  269.  
  270. Block size: Chuck  Forsberg created an  extension of my  protocol, called YAM,
  271. which is also supported via his public domain programs for UNIX called rb  and
  272. sb -  receive batch  and send  batch.   They cleverly  send a  "block 0" which
  273. contains the filename, date, time,  and size.  Unfortunately, its  UNIX style,
  274. and is a bit weird[4] - octal numbers, etc.  BUT, it is a nice way to overcome
  275. the kludgy  "echo the  chars of  the name"  introduced with  MODEM7.  Further,
  276. chuck uses CRC-16  and optional 1K  blocks.  Thus  the record 0,  1K, and CRC,
  277. make it  a "pretty  slick new  protocol" which  is not significantly different
  278. from my own.
  279.  
  280. Also, there is  a catchy name  - YMODEM.   That means to  some that it  is the
  281. "next thing after XMODEM", and to  others that it is the Y(am)MODEM  protocol.
  282. I don't want to emphasize that too  much - out of fear that other  mfgrs might
  283. think it is a "competitive" protocol, rather than an "unaffiliated"  protocol.
  284. Chuck is currently  selling a much-enhanced  version of his  CP/M-80 C program
  285. YAM, calling it Professional Yam, and its for the PC - I'm using it right now.
  286. VERY slick!  32K capture  buffer, script, scrolling, previously captured  text
  287. search, plus built-in commands for  just about everything - directory  (sorted
  288. every which way), XMODEM, YMODEM, KERMIT, and ASCII file upload/download, etc.
  289. You can program it to "behave" with most any system - for example when  trying
  290. a  number  for  CIS  it  detects  the  "busy"  string  back from the modem and
  291. substitutes a diff phone  # into the dialing  string and branches back  to try
  292. it.
  293.  
  294.  
  295.  
  296. 3.  XMODEM PROTOCOL ENHANCEMENTS
  297.  
  298. This  chapter  discusses  the  protocol  extensions to Ward Christensen's 1982
  299. XMODEM protocol description document.
  300.  
  301. The original document recommends the user be asked whether to continue  trying
  302. or abort after 10 retries.   Most programs no longer ask the  operator whether
  303. he wishes to  keep retrying.   Virtually all correctable  errors are corrected
  304. within the first few retransmissions.  If the line is so bad that ten attempts
  305. are insufficient, there is a significant danger of undetected errors.  If  the
  306. connection is that bad, it's better to redial for a better connection, or mail
  307. a floppy disk.
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317. __________
  318.  
  319.  4. The file length, time, and file mode are optional.  The pathname and  file
  320.     length may be sent alone if desired.
  321.  
  322.  
  323.  
  324.  
  325. Chapter 3                                     XMODEM Protocol Enhancements
  326.  
  327.  
  328. X/YMODEM Protocol Reference      09-11-86                                6
  329.  
  330.  
  331.  
  332. 3.1  Graceful Abort
  333.  
  334. The YAM  and Professional-YAM  X/YMODEM routines  recognize a  sequence of two
  335. consecutive CAN (Hex  18) characters without  modem errors (overrun,  framing,
  336. etc.) as a transfer  abort command.  This  sequence is recognized when  YAM is
  337. waiting for the beginning  of a packet or  for an acknowledge to  one that has
  338. been sent.  The check for two consecutive CAN characters virtually  eliminates
  339. the possibility  of a  line hit  aborting the  transfer.   YAM sends eight CAN
  340. characters when it aborts an XMODEM, YMODEM, or ZMODEM protocol file transfer.
  341. Pro-YAM then  sends eight  backspaces to  delete the  CAN characters  from the
  342. remote's keyboard  input buffer,  in case  the remote  had already aborted the
  343. transfer and was awaiting a keyboarded command.
  344.  
  345.  
  346. 3.2  CRC-16 Option
  347.  
  348. The XMODEM protocol uses an optional  two character CRC-16 instead of the  one
  349. character  arithmetic  checksum  used  by  the  original  protocol and by most
  350. commercial implementations.   CRC-16 guarantees  detection of  all single  and
  351. double bit errors,   all errors with  an odd number  of error bits,  all burst
  352. errors of length 16 or less, 99.9969% of all 17-bit error bursts, and  99.9984
  353. per cent  of all  possible longer  error bursts.   By contrast,  a double  bit
  354. error, or a burst error of 9  bits or more can sneak past the  XMODEM protocol
  355. arithmetic checksum.
  356.  
  357. The XMODEM/CRC  protocol is  similar to  the XMODEM  protocol, except that the
  358. receiver specifies CRC-16 by sending C (Hex 43) instead of NAK when requesting
  359. the FIRST packet.  A two byte CRC is sent in place of the one byte  arithmetic
  360. checksum.
  361.  
  362. YAM's c  option to  the r  command enables  CRC-16 in  single file  reception,
  363. corresponding to the  original implementation in  the MODEM7 series  programs.
  364. This remains the default  because many commercial communications  programs and
  365. bulletin board systems still do  not support CRC-16, especially those  written
  366. in Basic or Pascal.
  367.  
  368. XMODEM protocol with  CRC is accurate  provided both sender  and receiver both
  369. report a successful transmission.  The  protocol is robust in the presence  of
  370. characters lost by buffer overloading on timesharing systems.
  371.  
  372. The  single  character  ACK/NAK  responses  generated by the receiving program
  373. adapt well to split speed modems, where the reverse channel is limited to  ten
  374. per cent or less of the main channel's speed.
  375.  
  376. XMODEM and YMODEM are half duplex  protocols which do not attempt to  transmit
  377. information and control  signals in both  directions at the  same time.   This
  378. avoids buffer overrun problems that have been reported by users attempting  to
  379. exploit full duplex asynchronous file transfer protocols such as Blast.
  380.  
  381. Professional-YAM adds several proprietary logic enhancements to XMODEM's
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390. Chapter 3                                     XMODEM Protocol Enhancements
  391.  
  392.  
  393. X/YMODEM Protocol Reference      09-11-86                                7
  394.  
  395.  
  396.  
  397. error detection and recovery.  These compatible enhancements eliminate most of
  398. the bad  file transfers  other programs  make when  using the  XMODEM protocol
  399. under less than ideal conditions.
  400.  
  401.  
  402. 3.3  XMODEM-1k 1024 Byte Packet
  403.  
  404. The choice to use 1024 byte packets is expressed to the sending program on its
  405. command line  or selection  menu.[1] 1024  byte packets  improve throughput in
  406. many  applications,  but  some  environments  cannot  accept 1024 byte bursts,
  407. especially minicomuters running 19.2kb ports.
  408.  
  409. An STX (02) replaces the SOH (01) at the beginning of the transmitted block to
  410. notify  the  receiver  of  the  longer  packet length.  The transmitted packet
  411. contains  1024  bytes  of  data.   The  receiver  should be able to accept any
  412. mixture of 128 and 1024 byte packets.  The packet number is incremented by one
  413. for each packet regardless of the packet length.
  414.  
  415. The sender must not change between 128 and 1024 byte packet lengths if it  has
  416. not received  a valid  ACK for  the current  packet.   Failure to observe this
  417. restriction allows certain transmission errors to pass undetected.
  418.  
  419. If 1024 byte packets are being used, it is possible for a file to "grow" up to
  420. the next  multiple of  1024 bytes.   This does  not waste  disk space  if  the
  421. allocation granularity is 1k or greater.  With YMODEM batch transmission,  the
  422. optional file length transmitted in  the file name packet allows  the receiver
  423. to discard the padding, preserving the exact file length and contents.
  424.  
  425. 1024 byte packets may be used with batch file transmission or with single file
  426. transmission.   CRC-16  should  be  used  with  the  k option to preserve data
  427. integrity  over  phone   lines.   If   a  program  wishes   to  enforce   this
  428. recommendation,  it  should  cancel  the  transfer,  then issue an informative
  429. diagnostic message if the receiver requests checksum instead of CRC-16.  Under
  430. no circumstances may a sending program use CRC-16 unless the receiver commands
  431. CRC-16.
  432.  
  433.  
  434. 4.  YMODEM Batch File Transmission
  435.  
  436. The YMODEM  Batch protocol  is an  extension to  the XMODEM/CRC  protocol that
  437. allows 0 or more files to be  transmitted with a single command.  (Zero  files
  438. may be sent if none of the requested files is accessible.) The design approach
  439. of the YMODEM  Batch protocol is  to use the  normal routines for  sending and
  440. receiving XMODEM packets in a layered fashion similar to
  441.  
  442.  
  443.  
  444.  
  445.  
  446. __________
  447.  
  448.  1. See "KMD/IMP Exceptions to YMODEM" below.
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455. Chapter 4                                     XMODEM Protocol Enhancements
  456.  
  457.  
  458. X/YMODEM Protocol Reference      09-11-86                                8
  459.  
  460.  
  461.  
  462.           Figure 1.  1024 byte Packets
  463.  
  464.           SENDER                                  RECEIVER
  465.                                                   "s -k foo.bar"
  466.           "foo.bar open x.x minutes"
  467.                                                   C
  468.           STX 01 FE Data[1024] CRC CRC
  469.                                                   ACK
  470.           STX 02 FD Data[1024] CRC CRC
  471.                                                   ACK
  472.           STX 03 FC Data[1000] CPMEOF[24] CRC CRC
  473.                                                   ACK
  474.           EOT
  475.                                                   ACK
  476.  
  477.           Figure 2.  Mixed 1024 and 128 byte Packets
  478.  
  479.           SENDER                                  RECEIVER
  480.                                                   "s -k foo.bar"
  481.           "foo.bar open x.x minutes"
  482.                                                   C
  483.           STX 01 FE Data[1024] CRC CRC
  484.                                                   ACK
  485.           STX 02 FD Data[1024] CRC CRC
  486.                                                   ACK
  487.           SOH 03 FC Data[128] CRC CRC
  488.                                                   ACK
  489.           SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  490.                                                   ACK
  491.           EOT
  492.                                                   ACK
  493.  
  494. packet switching methods.
  495.  
  496. Why was it necessary to design  a new batch protocol when one  already existed
  497. in MODEM7?[1] The batch file mode used by MODEM7 is unsuitable because it does
  498. not  permit  full  pathnames,  file  length,  file  date,  or  other attribute
  499. information to be transmitted.  Such a restrictive design, hastily implemented
  500. with only CP/M in mind, would  not have permitted extensions to current  areas
  501. of personal  computing such  as Unix,  DOS, and  object oriented  systems.  In
  502. addition, the MODEM7 batch file  mode is somewhat susceptible to  transmission
  503. impairments.
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510. __________
  511.  
  512.  1. The MODEM7 batch protocol  transmitted CP/M FCB bytes f1...f8  and t1...t3
  513.     one character at a time.  The receiver echoed these bytes as received, one
  514.     at a time.
  515.  
  516.  
  517.  
  518.  
  519.  
  520. Chapter 4                                     XMODEM Protocol Enhancements
  521.  
  522.  
  523. X/YMODEM Protocol Reference      09-11-86                                9
  524.  
  525.  
  526.  
  527. As in the case  of single a file  transfer, the receiver initiates  batch file
  528. transmission by sending a "C" character (for CRC-16).
  529.  
  530. The sender opens the first file  and sends packet number 0 with  the following
  531. information.[2]
  532.  
  533. Only the pathname (file name) part is required for batch transfers.
  534.  
  535. To maintain upwards compatibility, all unused bytes in packet 0 must be set to
  536. null.
  537.  
  538. Pathname     The pathname (conventionally,  the file name)  is sent as  a null
  539.      terminated ASCII string.  This is the filename format used by the  handle
  540.      oriented MSDOS(TM) functions and C library fopen functions.  An  assembly
  541.      language example follows:
  542.  
  543.            DB      'foo.bar',0
  544.      No spaces are included in the pathname.  Normally only the file name stem
  545.      (no directory prefix) is transmitted unless the sender has selected YAM's
  546.      f option to send the full pathname.   The source drive (A:, B:, etc.)  is
  547.      never sent.
  548.  
  549.      Filename Considerations:
  550.  
  551.         + File  names should  be translated  to lower  case unless the sending
  552.           system supports upper/lower case file names.  This is a  convenience
  553.       for users of systems (such  as Unix) which store filenames  in upper
  554.       and lower case.
  555.  
  556.         + The receiver should accommodate file names in lower and upper case.
  557.  
  558.         + When  transmitting files  between different  operating systems, file
  559.       names must be acceptable to both the sender and receiving  operating
  560.       systems.
  561.  
  562.      If directories are included, they are delimited by /; i.e.,  "subdir/foo"
  563.      is acceptable, "subdir\foo" is not.
  564.  
  565. Length    The file length  and each of the succeeding fields are  optional.[3]
  566.      The length field is stored in the packet as a decimal string counting the
  567.      number of data bytes in the file.   The file length does not include  any
  568.      CPMEOF (^Z) or other garbage characters used to pad the last packet.
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575. __________
  576.  
  577.  2. Only the data part of the packet is described here.
  578.  
  579.  3. Fields may not be skipped.
  580.  
  581.  
  582.  
  583.  
  584.  
  585. Chapter 4                                     XMODEM Protocol Enhancements
  586.  
  587.  
  588. X/YMODEM Protocol Reference      09-11-86                               10
  589.  
  590.  
  591.  
  592.      If the file being transmitted is growing during transmission, the  length
  593.      field should be set  to at least the  final expected file length,  or not
  594.      sent.
  595.  
  596.      The receiver stores  the specified number  of characters, discarding  any
  597.      padding added by the sender to fill up the last packet.
  598.  
  599. Modification Date    The mod date is optional, and the filename and  length
  600.      may be sent without requiring the mod date to be sent.
  601.  
  602.      Iff  the  modification  date  is  sent,  a  single  space  separates  the
  603.      modification date from the file length.
  604.  
  605.      The mod date is sent as an  octal number giving the time the contents  of
  606.      the file were last changed, measured in seconds from Jan 1 1970 Universal
  607.      Coordinated Time (GMT).   A date of  0 implies the  modification date  is
  608.      unknown and should be left as the date the file is received.
  609.  
  610.      This standard  format was  chosen to  eliminate ambiguities  arising from
  611.      transfers between different time zones.
  612.  
  613.      Two Microsoft blunders complicate the  use of modification dates in  file
  614.      transfers with  MSDOS(TM) systems.   The first  is the  lack of  timezone
  615.      standardization  in  MS-DOS.   A  file's  creation  time can not be known
  616.      unless the timezone of the system that wrote the file[4] is known.   Unix
  617.      solved this  problem (for  planet Earth,  anyway) by  stamping files with
  618.      Universal Time (GMT).   Microsoft would have  to include the  timezone of
  619.      origin in  the directory  entries, but  does not.   Professional-YAM gets
  620.      around this problem by using the  z parameter which is set to  the number
  621.      of minutes  local time  lags GMT.   For files  known to  originate from a
  622.      different  timezone,  the  -zT  option  may  be  used to specify T as the
  623.      timezone for an individual file transfer.
  624.  
  625.      The second problem is the lack  of a separate file creation date  in DOS.
  626.      Since some backup schemes used with DOS rely on the file creation date to
  627.      select  files  to  be  copied  to  the  archive,  back-  dating  the file
  628.      modification  date  could  interfere  with  the safety of the transferred
  629.      files.  For  this reason, Pro-YAM  does not modify  the date of  received
  630.      files with the header information  unless the d numeric parameter  is non
  631.      zero.
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641. __________
  642.  
  643.  4. Not necessarily that of the transmitting system!
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650. Chapter 4                                     XMODEM Protocol Enhancements
  651.  
  652.  
  653. X/YMODEM Protocol Reference      09-11-86                               11
  654.  
  655.  
  656.  
  657. Mode     Iff the file  mode is sent,  a  single space separates the  file  mode
  658.      from the modification   date.   The  file  mode is   stored as  an  octal
  659.      string.  Unless the file originated from a Unix system, the file mode  is
  660.      set to 0.  rb(1) checks the file mode for the 0x8000 bit which  indicates
  661.      a Unix type regular file.   Files  with the  0x8000 bit set  are  assumed
  662.      to  have been sent  from  another  Unix  (or  similar)  system which uses
  663.      the same file conventions.  Such files are not translated in any way.
  664.  
  665.  
  666. Serial Number       Iff the serial number is sent, a single space separates  the
  667.      serial number from the file mode.  The serial number of the  transmitting
  668.      program is  stored as  an octal  string.   Programs which  do not  have a
  669.      serial number should omit this field, or set it to 0.  The receiver's use
  670.      of this field is optional.
  671.  
  672.  
  673. Other Fields     YMODEM  was designed to  allow additional header  fields to be
  674.      added as above without creating compatibility problems with older  YMODEM
  675.      programs.  Please contact Omen Technology if other fields are needed  for
  676.      special application requirements.
  677.  
  678. The rest of the packet is set to nulls.  This is essential to preserve  upward
  679. compatibility.[5]
  680.  
  681. If the filename packet is received with a CRC or other error, a restrnsmission
  682. is requested.  After  the filename packet has  been received, it is  ACK'ed if
  683. the write open is successful.  If  the file cannot be opened for writing,  the
  684. receiver cancels the transfer with CAN characters as described above.
  685.  
  686. The receiver  then initiates  transfer of  the file  contents according to the
  687. standard XMODEM/CRC protocol.
  688.  
  689. After the file contents have been transmitted, the receiver again asks for the
  690. next  pathname.   Transmission  of  a  null  pathname  terminates  batch  file
  691. transmission.  Note that transmission of no files is not necessarily an error.
  692. This is possible if none of the files requested of the sender could be  opened
  693. for reading.
  694.  
  695. In batch transmission, the receiver automatically requests CRC-16.
  696.  
  697. The Unix programs sz(1) and rz(1) included in the source code file
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704. __________
  705.  
  706.  5. If, perchance,  this information extends  beyond 128 bytes  (possible with
  707.     Unix 4.2  BSD extended  file names),  the packet  should be  sent as  a 1k
  708.     packet as described above.
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715. Chapter 4                                     XMODEM Protocol Enhancements
  716.  
  717.  
  718. X/YMODEM Protocol Reference      09-11-86                               12
  719.  
  720.  
  721.  
  722. RZSZ[12].SHQ (rzsz1.sh, rzsz2.sh) should  answer other questions about  YMODEM
  723. batch protocol.
  724.  
  725.           Figure 3.  YMODEM Batch Transmission Session
  726.  
  727.           SENDER                                  RECEIVER
  728.                                                   "sb foo.*<CR>"
  729.           "sending in batch mode etc."
  730.                                                   C (command:rb)
  731.           SOH 00 FF foo.c NUL[123] CRC CRC
  732.                                                   ACK
  733.                                                   C
  734.           SOH 01 FE Data[128] CRC CRC
  735.                                                   ACK
  736.           STX 02 FD Data[1024] CRC CRC
  737.                                                   ACK
  738.           SOH 03 FC Data[128] CRC CRC
  739.                                                   ACK
  740.           SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  741.                                                   ACK
  742.           EOT
  743.                                                   NAK
  744.           EOT
  745.                                                   ACK
  746.                                                   C
  747.           SOH 00 FF NUL[128] CRC CRC
  748.                                                   ACK
  749.  
  750.        Figure 4.  YMODEM Filename packet transmitted by sz
  751.  
  752.        -rw-r--r--  6347 Jun 17 1984 20:34 bbcsched.txt
  753.  
  754.        00 0100FF62 62637363 6865642E 74787400   |...bbcsched.txt.|
  755.        10 36333437 20333331 34373432 35313320   |6347 3314742513 |
  756.        20 31303036 34340000 00000000 00000000   |100644..........|
  757.        30 00000000 00000000 00000000 00000000
  758.        80 000000CA 56
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780. Chapter 4                                     XMODEM Protocol Enhancements
  781.  
  782.  
  783. X/YMODEM Protocol Reference      09-11-86                               13
  784.  
  785.  
  786.  
  787.       Figure 5.  YMODEM Header Information used by various programs
  788.  
  789. _____________________________________________________________________
  790. | Program   | Batch | Length | Date | Mode | S/N | 1k-Blk | g-Option |
  791. |___________|_______|________|______|______|_____|________|__________|
  792. |Unix rz/sz | yes   | yes    | yes  | yes  | no  | yes    | sb only  |
  793. |___________|_______|________|______|______|_____|________|__________|
  794. |VMS rb/sb  | yes   | yes    | no   | no   | no  | yes    | no       |
  795. |___________|_______|________|______|______|_____|________|__________|
  796. |Pro-YAM    | yes   | yes    | yes  | no   | yes | yes    | yes      |
  797. |___________|_______|________|______|______|_____|________|__________|
  798. |CP/M YAM   | yes   | no     | no   | no   | no  | yes    | no       |
  799. |___________|_______|________|______|______|_____|________|__________|
  800. |KMD/IMP    | yes   | ?      | no   | no   | no  | yes    | no       |
  801. |___________|_______|________|______|______|_____|________|__________|
  802.  
  803. 4.1  KMD/IMP Exceptions to YMODEM
  804.  
  805. KMD and IMP character sequence  emitted by the receiver (CK)  to automatically
  806. trigger the  use of  1024 byte  packets as  an alternative  to specifying this
  807. option on this command line.  Although this two character sequence works  well
  808. on  single  process  micros  in  direct communication, timesharing systems and
  809. packet switched  networks can  separate the  successive characters  by several
  810. seconds, rendering this method unreliable.
  811.  
  812. Sending programs may detect the CK sequence if the operating enviornment  does
  813. not preclude reliable implementation.
  814.  
  815. Receiving programs should retain the  option of sending the standard  YMODEM C
  816. (not CK) trigger with the  standard 10 second timeout to  insure compatibility
  817. with newer forms of telecommunications technology.
  818.  
  819.  
  820.  
  821. 5.  YMODEM-g File Transmission
  822.  
  823. Developing technology is providing phone line data transmission at ever higher
  824. speeds using very specialized techniques.  These high speed modems, as well as
  825. session protocols such as X.PC, provide high speed, error free  communications
  826. at the expense of considerably increased delay time.
  827.  
  828. This delay time  is moderate compared  to human interactions,  but it cripples
  829. the throughput of most error correcting protocols.
  830.  
  831. The g option to YMODEM has proven effective under these circumstances.  The  g
  832. option  is  driven  by  the  receiver,  which  initiates the batch transfer by
  833. transmitting a G instead of C.  When the sender recognizes the G, it  bypasses
  834. the  usual  wait  for  an  ACK  to each transmitted packet, sending succeeding
  835. packets at full speed,  subject to XOFF/XON or  other flow control exerted  by
  836. the medium.
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845. Chapter 5                                     XMODEM Protocol Enhancements
  846.  
  847.  
  848. X/YMODEM Protocol Reference      09-11-86                               14
  849.  
  850.  
  851.  
  852. The sender expects an  inital G to initiate  the transmission of a  particular
  853. file, and also expects an ACK on the  EOT sent at the end of each file.   This
  854. synchronization allows the receiver time to open and close files as necessary.
  855.  
  856. If  an  error  is  detected  in  a  YMODEM-g transfer, the receiver aborts the
  857. transfer with the multiple CAN abort sequence.  The ZMODEM protocol should  be
  858. used  in  applications  that  require  both  streaming  throughput  and  error
  859. recovery.
  860.  
  861.        Figure 6.  YMODEM-g Transmission Session
  862.  
  863.        SENDER                                    RECEIVER
  864.                                                  "sb foo.*<CR>"
  865.        "sending in batch mode etc..."
  866.                                                  G (command:rb -g)
  867.        SOH 00 FF foo.c NUL[123] CRC CRC
  868.                                                  G
  869.        SOH 01 FE Data[128] CRC CRC
  870.        STX 02 FD Data[1024] CRC CRC
  871.        SOH 03 FC Data[128] CRC CRC
  872.        SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  873.        EOT
  874.                                                  ACK
  875.                                                  G
  876.        SOH 00 FF NUL[128] CRC CRC
  877.  
  878.  
  879. 6.  XMODEM PROTOCOL OVERVIEW
  880.  
  881. 8/9/82 by Ward Christensen.
  882.  
  883. I will maintain a master copy of this.  Please pass on changes or  suggestions
  884. via CBBS/Chicago at (312) 545-8086,  CBBS/CPMUG (312) 849-1132 or by  voice at
  885. (312) 849-6279.
  886.  
  887. 6.1  Definitions
  888.  
  889.   <soh> 01H
  890.   <eot> 04H
  891.   <ack> 06H
  892.   <nak> 15H
  893.   <can> 18H
  894.   <C>   43H
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910. Chapter 6                                         Xmodem Protocol Overview
  911.  
  912.  
  913. X/YMODEM Protocol Reference      09-11-86                               15
  914.  
  915.  
  916.  
  917. 6.2  Transmission Medium Level Protocol
  918.  
  919. Asynchronous, 8 data bits, no parity, one stop bit.
  920.  
  921. The  protocol  imposes  no  restrictions  on  the  contents  of the data being
  922. transmitted.   No  control  characters  are  looked  for  in the 128-byte data
  923. messages.  Absolutely any kind of data may be sent - binary, ASCII, etc.   The
  924. protocol  has  not  formally  been  adopted  to  a  7-bit  environment for the
  925. transmission  of  ASCII-only  (or  unpacked-hex)  data  , although it could be
  926. simply by having both  ends agree to AND  the protocol-dependent data with  7F
  927. hex before validating it.   I specifically am referring  to the checksum,  and
  928. the block numbers and their ones- complement.
  929.  
  930. Those wishing to maintain compatibility of  the CP/M file structure, i.e.   to
  931. allow modemming ASCII files  to or from CP/M  systems should follow this  data
  932. format:
  933.  
  934.    + ASCII tabs used (09H); tabs set every 8.
  935.  
  936.    + Lines terminated by CR/LF (0DH 0AH)
  937.  
  938.    + End-of-file indicated by ^Z, 1AH.  (one or more)
  939.  
  940.    + Data is variable length, i.e. should be considered a continuous stream of
  941.      data  bytes,  broken  into  128-byte  chunks  purely  for  the purpose of
  942.      transmission.
  943.  
  944.    + A CP/M "peculiarity":  If the data ends  exactly on a 128-byte  boundary,
  945.      i.e. CR in 127, and LF in 128, a subsequent sector containing the ^Z  EOF
  946.      character(s)  is  optional,  but  is  preferred.   Some utilities or user
  947.      programs still do not handle EOF without ^Zs.
  948.  
  949.    + The last block sent is no different from others, i.e.  there is no "short
  950.      block".
  951.  
  952.          Figure 7.  XMODEM Message Block Level Protocol
  953.  
  954. Each block of the transfer looks like:
  955.       <SOH><blk #><255-blk #><--128 data bytes--><cksum>
  956. in which:
  957. <SOH>         = 01 hex
  958. <blk #>       = binary number, starts at 01 increments by 1, and
  959.                 wraps 0FFH to 00H (not to 01)
  960. <255-blk #>   = blk # after going thru 8080 "CMA" instr, i.e.
  961.                 each bit complemented in the 8-bit block number.
  962.                 Formally, this is the "ones complement".
  963. <cksum>       = the sum of the data bytes only.  Toss any carry.
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975. Chapter 6                                         Xmodem Protocol Overview
  976.  
  977.  
  978. X/YMODEM Protocol Reference      09-11-86                               16
  979.  
  980.  
  981.  
  982. 6.3  File Level Protocol
  983.  
  984. 6.3.1  Common_to_Both_Sender_and_Receiver
  985.  
  986. All errors are retried 10 times.  For versions running with an operator  (i.e.
  987. NOT with  XMODEM), a  message is  typed after  10 errors  asking the  operator
  988. whether to "retry or quit".
  989.  
  990. Some versions  of the  protocol use  <can>, ASCII  ^X, to cancel transmission.
  991. This was never  adopted as a  standard, as having  a single "abort"  character
  992. makes the transmission susceptible to false termination due to an <ack>  <nak>
  993. or <soh> being corrupted into a <can> and aborting transmission.
  994.  
  995. The protocol may be considered "receiver driven", that is, the sender need not
  996. automatically re-transmit, although it does in the current implementations.
  997.  
  998.  
  999. 6.3.2  Receive_Program_Considerations
  1000.  
  1001. The receiver has a  10-second timeout.  It  sends a <nak> every  time it times
  1002. out.   The  receiver's  first  timeout,  which  sends  a  <nak>,  signals  the
  1003. transmitter  to  start.    Optionally,  the  receiver   could  send  a   <nak>
  1004. immediately, in case  the sender was  ready.  This  would save the  initial 10
  1005. second  timeout.   However,  the  receiver  MUST  continue to timeout every 10
  1006. seconds in case the sender wasn't ready.
  1007.  
  1008. Once into a receiving a block, the receiver goes into a one-second timeout for
  1009. each character and the checksum.  If the receiver wishes to <nak> a block  for
  1010. any reason (invalid header, timeout receiving data), it must wait for the line
  1011. to clear.  See "programming tips" for ideas.
  1012.  
  1013. Synchronizing:  If a valid block number is received, it will be:
  1014.      1) the expected one, in which case everything is fine;
  1015.       or 2) a repeat of the previously received block. This should be
  1016.         considered OK,  and only  indicates that  the receivers  <ack> got
  1017.         glitched,  and   the  sender   re-transmitted;
  1018.      3) any other block number indicates a fatal loss of  synchronization,
  1019.         such as  the rare  case of  the sender  getting a line-glitch that
  1020.         looked like an <ack>. Abort the transmission, sending a <can>
  1021.  
  1022.  
  1023. 6.3.3  Sending_program_considerations
  1024.  
  1025. While waiting for  transmission to begin,  the sender has  only a single  very
  1026. long timeout, say one  minute.  In the  current protocol, the sender  has a 10
  1027. second timeout before  retrying.  I  suggest NOT doing  this, and letting  the
  1028. protocol be completely receiver-driven.  This will be compatible with existing
  1029. programs.
  1030.  
  1031. When the  sender has  no more  data, it  sends an  <eot>, and awaits an <ack>,
  1032. resending the  <eot> if  it doesn't  get one.   Again, the  protocol could  be
  1033. receiver-driven, with the sender  only having the high-level  1-minute timeout
  1034. to abort.
  1035.  
  1036.  
  1037.  
  1038.  
  1039. Chapter 6                                         Xmodem Protocol Overview
  1040.  
  1041.  
  1042. X/YMODEM Protocol Reference      09-11-86                               17
  1043.  
  1044.  
  1045.  
  1046. Here is a sample of the data flow, sending a 3-block message.  It includes the
  1047. two most  common line  hits -  a garbaged  block, and  an <ack>  reply getting
  1048. garbaged.  <xx> represents the checksum byte.
  1049.  
  1050.               Figure 8.  Data flow including Error Recovery
  1051.  
  1052. SENDER                                  RECEIVER
  1053.                               times out after 10 seconds,
  1054.                               <---              <nak>
  1055. <soh> 01 FE -data- <xx>       --->
  1056.                               <---              <ack>
  1057. <soh> 02 FD -data- xx         --->       (data gets line hit)
  1058.                               <---              <nak>
  1059. <soh> 02 FD -data- xx         --->
  1060.                               <---              <ack>
  1061. <soh> 03 FC -data- xx         --->
  1062. (ack gets garbaged)           <---              <ack>
  1063. <soh> 03 FC -data- xx         --->              <ack>
  1064. <eot>                         --->
  1065.                               <---       <anything except ack>
  1066. <eot>                         --->
  1067.                               <---              <ack>
  1068. (finished)
  1069.  
  1070. 6.4  Programming Tips
  1071.  
  1072.    + The  character-receive  subroutine  should  be  called  with  a parameter
  1073.      specifying the number of seconds to wait.  The receiver should first call
  1074.      it with a time of 10, then <nak> and try again, 10 times.
  1075.  
  1076.      After receiving the <soh>, the receiver should call the character receive
  1077.      subroutine with a 1-second timeout, for the remainder of the message  and
  1078.      the <cksum>.  Since they are  sent as a continuous stream, timing  out of
  1079.      this implies a serious like glitch that caused, say, 127 characters to be
  1080.      seen instead of 128.
  1081.  
  1082.    + When the receiver wishes to  <nak>, it should call a "PURGE"  subroutine,
  1083.      to wait for the line to  clear.  Recall the sender tosses  any characters
  1084.      in its UART buffer immediately upon completing sending a block, to ensure
  1085.      no glitches were mis- interpreted.
  1086.  
  1087.      The most common  technique is for  "PURGE" to call  the character receive
  1088.      subroutine, specifying a 1-second  timeout,[1] and looping back  to PURGE
  1089.      until a timeout occurs.  The  <nak> is then sent, ensuring the  other end
  1090.      will see it.
  1091.  
  1092.  
  1093.  
  1094.  
  1095. __________
  1096.  
  1097.  1. These times should be adjusted for use with timesharing systems.
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104. Chapter 6                                         Xmodem Protocol Overview
  1105.  
  1106.  
  1107. X/YMODEM Protocol Reference      09-11-86                               18
  1108.  
  1109.  
  1110.  
  1111.    + You  may wish  to add  code recommended  by John  Mahr to  your character
  1112.      receive routine - to set an  error flag if the UART shows  framing error,
  1113.      or overrun.  This will help catch  a few more glitches - the most  common
  1114.      of which is a hit in the high bits of the byte in two consecutive  bytes.
  1115.      The  <cksum>  comes  out  OK  since  counting in 1-byte produces the same
  1116.      result of adding 80H + 80H as with adding 00H + 00H.
  1117.  
  1118.  
  1119.  
  1120. 7.  XMODEM/CRC Overview
  1121.  
  1122. 1/13/85 by John Byrns -- CRC option.
  1123.  
  1124. Please pass  on any  reports of  errors in  this document  or suggestions  for
  1125. improvement to  me via  Ward's/CBBS at  (312) 849-1132,  or by  voice at (312)
  1126. 885-1105.
  1127.  
  1128. The CRC used in the Modem Protocol  is an alternate form of block check  which
  1129. provides more robust  error detection than  the original checksum.   Andrew S.
  1130. Tanenbaum says in his book, Computer Networks, that the CRC- CCITT used by the
  1131. Modem Protocol will detect all single  and double bit errors, all errors  with
  1132. an odd  number of  bits, all  burst errors  of length  16 or  less, 99.997% of
  1133. 17-bit error bursts, and 99.998% of 18-bit and longer bursts.
  1134.  
  1135. The changes to  the Modem Protocol  to replace the  checksum with the  CRC are
  1136. straight  forward.  If  that  were  all  that  we  did we would not be able to
  1137. communicate between a  program using the  old checksum protocol  and one using
  1138. the new CRC protocol.  An initial handshake was  added to solve this  problem.
  1139. The handshake  allows a  receiving program  with CRC  capability to  determine
  1140. whether the sending program supports the  CRC option, and to switch it  to CRC
  1141. mode if it does. This handshake is designed so that it will work properly with
  1142. programs which  implement only  the original  protocol. A  description of this
  1143. handshake is presented in section 10.
  1144.  
  1145.             Figure 9.  Message Block Level Protocol, CRC mode
  1146.  
  1147. Each block of the transfer in CRC mode looks like:
  1148.      <SOH><blk #><255-blk #><--128 data bytes--><CRC hi><CRC lo>
  1149. in which:
  1150. <SOH>        = 01 hex
  1151. <blk #>      = binary number, starts at 01 increments by 1, and
  1152.                wraps 0FFH to 00H (not to 01)
  1153. <255-blk #>  = ones complement of blk #.
  1154. <CRC hi>     = byte containing the 8 hi order coefficients of the CRC.
  1155. <CRC lo>     = byte containing the 8 lo order coefficients of the CRC.
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169. Chapter 7                                         Xmodem Protocol Overview
  1170.  
  1171.  
  1172. X/YMODEM Protocol Reference      09-11-86                               19
  1173.  
  1174.  
  1175.  
  1176. 7.1  CRC Calculation
  1177.  
  1178. 7.1.1  Formal_Definition
  1179.  
  1180. To  calculate  the  16  bit  CRC  the  message  bits  are considered to be the
  1181. coefficients of a polynomial. This  message polynomial is first multiplied  by
  1182. X^16 and  then divided  by the  generator polynomial  (X^16 +  X^12 + X^5 + 1)
  1183. using modulo  two arithmetic.  The remainder  left after  the division  is the
  1184. desired CRC. Since a message block in the Modem Protocol is 128 bytes or  1024
  1185. bits, the message polynomial will be of order X^1023. The hi order bit of  the
  1186. first byte of the  message block is the  coefficient of X^1023 in  the message
  1187. polynomial.  The  lo order bit  of the last  byte of the  message block is the
  1188. coefficient of X^0 in the message polynomial.
  1189.  
  1190.            Figure 10.  Example of CRC Calculation written in C
  1191. UPDCRC update  routine from  "rbsb.c".   Refer to  the source  code for  these
  1192. programs  (contained  in  RZSZ1.SHQ  and  RZSZ2.SHQ)  for usage.  A fast table
  1193. driven macro is also included in this file.
  1194.  
  1195. /* update CRC */
  1196. unsigned short
  1197. updcrc(c, crc)
  1198. register c;
  1199. register unsigned crc;
  1200. {
  1201.         register count;
  1202.  
  1203.         for (count=8; --count>=0;) {
  1204.                 if (crc & 0x8000) {
  1205.                         crc <<= 1;
  1206.                         crc += (((c<<=1) & 0400)  !=  0);
  1207.                         crc ^= 0x1021;
  1208.                 }
  1209.                 else {
  1210.                         crc <<= 1;
  1211.                         crc += (((c<<=1) & 0400)  !=  0);
  1212.                 }
  1213.         }
  1214.         return crc;
  1215. }
  1216.  
  1217. 7.2  CRC File Level Protocol Changes
  1218.  
  1219. 7.2.1  Common_to_Both_Sender_and_Receiver
  1220.  
  1221. The only change to the File Level  Protocol for the CRC option is the  initial
  1222. handshake which is  used to determine  if both the  sending and the  receiving
  1223. programs support the CRC mode. All Modem Programs should support the  checksum
  1224. mode for compatibility with older  versions.  A receiving program  that wishes
  1225. to receive in CRC mode implements the mode setting handshake by sending a  <C>
  1226. in place of the  initial <nak>.  If  the sending program supports  CRC mode it
  1227. will recognize  the <C>  and will  set itself  into CRC  mode, and  respond by
  1228. sending  the  first  block  as  if  a  <nak> had been received. If the sending
  1229. program does not support CRC mode it will
  1230.  
  1231.  
  1232.  
  1233.  
  1234. Chapter 7                                         Xmodem Protocol Overview
  1235.  
  1236.  
  1237. X/YMODEM Protocol Reference      09-11-86                               20
  1238.  
  1239.  
  1240.  
  1241. not respond to  the <C> at  all. After the  receiver has sent  the <C> it will
  1242. wait up to 3 seconds for the <soh> that starts the first block. If it receives
  1243. a <soh> within 3 seconds it will assume the sender supports CRC mode and  will
  1244. proceed with the file exchange in CRC  mode. If no <soh> is received within  3
  1245. seconds the receiver will switch to  checksum mode, send a <nak>, and  proceed
  1246. in checksum mode. If the receiver  wishes to use checksum mode it  should send
  1247. an  initial  <nak>  and  the  sending  program  should respond to the <nak> as
  1248. defined in the original  Modem Protocol.  After  the mode has been  set by the
  1249. initial <C> or <nak> the protocol  follows the original Modem Protocol and  is
  1250. identical whether the checksum or CRC is being used.
  1251.  
  1252.  
  1253. 7.2.2  Receive_Program_Considerations
  1254.  
  1255. There are at least 4 things that can go wrong with the mode setting handshake.
  1256.  
  1257.   1.  the initial <C> can be garbled or lost.
  1258.   2.  the initial <soh> can be garbled.
  1259.   3.  the initial <C> can be changed to a <nak>.
  1260.   4.  the initial <nak> from a receiver which wants to receive in checksum can
  1261.       be changed to a <C>.
  1262.  
  1263. The first problem can  be solved if the  receiver sends a second  <C> after it
  1264. times out the first time. This process can be repeated several times.  It must
  1265. not  be  repeated  too  many  times  before  sending  a <nak> and switching to
  1266. checksum mode or a sending program without CRC support may time out and abort.
  1267. Repeating the  <C> will  also fix  the second  problem if  the sending program
  1268. cooperates by responding as if a  <nak> were received instead of ignoring  the
  1269. extra <C>.
  1270.  
  1271. It is  possible to  fix problems  3 and  4 but  probably not worth the trouble
  1272. since they  will occur  very infrequently.  They could  be fixed  by switching
  1273. modes in either the sending or  the receiving program after a large  number of
  1274. successive <nak>s. This solution would risk other problems however.
  1275.  
  1276.  
  1277. 7.2.3  Sending_Program_Considerations
  1278.  
  1279. The  sending  program  should  start  in  the  checksum mode. This will insure
  1280. compatibility with checksum only receiving programs. Anytime a <C> is received
  1281. before the first <nak> or <ack> the sending program should set itself into CRC
  1282. mode and respond  as if a  <nak> were received.  The sender should  respond to
  1283. additional <C>s as if they were <nak>s until the first <ack> is received. This
  1284. will assist  the receiving  program in  determining the  correct mode when the
  1285. <soh>  is  lost  or  garbled.  After  the  first <ack> is received the sending
  1286. program should ignore <C>s.
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299. Chapter 7                                         Xmodem Protocol Overview
  1300.  
  1301.  
  1302. X/YMODEM Protocol Reference      09-11-86                               21
  1303.  
  1304.  
  1305.  
  1306. 7.3  Data Flow Examples with CRC Option
  1307.  
  1308. Here  is  a  data  flow  example  for  the  case  where  the receiver requests
  1309. transmission in the CRC mode but  the sender does not support the  CRC option.
  1310. This example also includes various  transmission errors.  <xx> represents  the
  1311. checksum byte.
  1312.  
  1313.       Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't
  1314.  
  1315. SENDER                                        RECEIVER
  1316.                         <---                <C>
  1317.                                 times out after 3 seconds,
  1318.                         <---                <C>
  1319.                                 times out after 3 seconds,
  1320.                         <---                <C>
  1321.                                 times out after 3 seconds,
  1322.                         <---                <C>
  1323.                                 times out after 3 seconds,
  1324.                         <---                <nak>
  1325. <soh> 01 FE -data- <xx> --->
  1326.                         <---                <ack>
  1327. <soh> 02 FD -data- <xx> --->        (data gets line hit)
  1328.                         <---                <nak>
  1329. <soh> 02 FD -data- <xx> --->
  1330.                         <---                <ack>
  1331. <soh> 03 FC -data- <xx> --->
  1332.    (ack gets garbaged)  <---                <ack>
  1333.                                 times out after 10 seconds,
  1334.                         <---                <nak>
  1335. <soh> 03 FC -data- <xx> --->
  1336.                         <---                <ack>
  1337. <eot>                   --->
  1338.                         <---                <ack>
  1339.  
  1340. Here  is  a  data  flow  example  for  the  case  where  the receiver requests
  1341. transmission in the  CRC mode and  the sender supports  the CRC option.   This
  1342. example also includes  various transmission errors.   <xxxx> represents the  2
  1343. CRC bytes.
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364. Chapter 7                                         Xmodem Protocol Overview
  1365.  
  1366.  
  1367. X/YMODEM Protocol Reference      09-11-86                               22
  1368.  
  1369.  
  1370.  
  1371.            Figure 12.  Receiver and Sender Both have CRC Option
  1372.  
  1373. SENDER                                       RECEIVER
  1374.                           <---                 <C>
  1375. <soh> 01 FE -data- <xxxx> --->
  1376.                           <---                 <ack>
  1377. <soh> 02 FD -data- <xxxx> --->         (data gets line hit)
  1378.                           <---                 <nak>
  1379. <soh> 02 FD -data- <xxxx> --->
  1380.                           <---                 <ack>
  1381. <soh> 03 FC -data- <xxxx> --->
  1382. (ack gets garbaged)       <---                 <ack>
  1383.                                      times out after 10 seconds,
  1384.                           <---                 <nak>
  1385. <soh> 03 FC -data- <xxxx> --->
  1386.                           <---                 <ack>
  1387. <eot>                     --->
  1388.                           <---                 <ack>
  1389.  
  1390.  
  1391. 8.  MORE INFORMATION
  1392.  
  1393. More information may be obtained by calling Telegodzilla at 503-621-3746.  Hit
  1394. RETURNs for baud  rate detection.Speed detection  is automatic for  300, 1200,
  1395. and 2400 bps.
  1396.  
  1397. A version this file with boldface, underlining, and superscripts for  printing
  1398. on Epson or Gemini printers  is available on Telegodzilla as  "YMODEME.DOC" or
  1399. "YMODEME.DQC".
  1400.  
  1401. UUCP sites can obtain this file with
  1402.              uucp omen!/usr/spool/uucppublic/ymodem.doc /tmp
  1403. A continually updated list of available files is stored in
  1404.          /usr/spool/uucppublic/FILES.
  1405.  
  1406. The  following  L.sys  line  calls  Telegodzilla  (Pro-YAM in host operation).
  1407. Telegodzilla waits for carriage returns  to determine the incoming speed.   If
  1408. none is detected, 1200 bps is assumed and a greeting is displayed.
  1409.  
  1410. In response to  "Name Please:" uucico  gives the Pro-YAM  "link" command as  a
  1411. user  name.   The  password  (Giznoid)  controls  access  to  the Xenix system
  1412. connected to the IBM PC's  other serial port.  Communications  between Pro-YAM
  1413. and Xenix use 9600 bps; YAM converts this to the caller's speed.
  1414.  
  1415. Finally, the calling uucico logs in as uucp.
  1416.  
  1417. omen Any ACU 1200 1-503-621-3746 se:--se: link ord: Giznoid in:--in: uucp
  1418.  
  1419. Contact omen!caf if you wish the troff source files.
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429. Chapter 8                                         Xmodem Protocol Overview
  1430.  
  1431.  
  1432. X/YMODEM Protocol Reference      09-11-86                               23
  1433.  
  1434.  
  1435.  
  1436. 9.  Document Revisions
  1437.  
  1438. The September 11  1986 edition clarifies  nomenclature and some  minor points.
  1439. The April 15  1986 edition clarifies  some points concerning  CRC calculations
  1440. and spaces in the header.
  1441.  
  1442.  
  1443. 10.  YMODEM Programs
  1444.  
  1445. A demonstration version  of Professional-YAM is  available as ZMODEM.ARC  This
  1446. may be used to test YMODEM amd ZMODEM implementations.
  1447.  
  1448. Unix programs supporting the YMODEM protocol are available on Telegodzilla  as
  1449. RZSZ1.SHQ and RZSZ2.SHQ (SQueezed shell archives).  Most Unix like systems are
  1450. supported, including V7, Xenix, Sys III, 4.2 BSD, SYS V, Idris, Coherent,  and
  1451. Regulus.
  1452.  
  1453. A version for VAX-VMS is available in VRBSB.SHQ.
  1454.  
  1455. Irv Hoff has added YMODEM 1k  packets and basic YMODEM batch transfers  to the
  1456. KMD and IMP series programs, which replace the XMODEM and MODEM7/MDM7xx series
  1457. respectively.  Overlays are available for a wide variety of CP/M systems.
  1458.  
  1459. Questions about YMODEM, the Professional-YAM communications program, and
  1460. requests for evaluation copies may be directed to:
  1461.      Chuck Forsberg
  1462.      Omen Technology Inc
  1463.      17505-V Sauvie Island Road
  1464.      Portland Oregon 97231
  1465.      Voice: 503-621-3406
  1466.      Modem: 503-621-3746 Speed: 2400,1200,300
  1467.      Usenet: ...!tektronix!reed!omen!caf
  1468.      Compuserve: 70007,2304
  1469.      Source: TCE022
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494. Chapter 10                                        Xmodem Protocol Overview
  1495.  
  1496.  
  1497.                                  CONTENTS
  1498.  
  1499.  
  1500.  1.  ROSETTA STONE....................................................   2
  1501.  
  1502.  2.  YET ANOTHER PROTOCOL?............................................   2
  1503.      2.1  Some Messages from the Pioneer..............................   4
  1504.  
  1505.  3.  XMODEM PROTOCOL ENHANCEMENTS.....................................   5
  1506.      3.1  Graceful Abort..............................................   6
  1507.      3.2  CRC-16 Option...............................................   6
  1508.      3.3  XMODEM-1k 1024 Byte Packet..................................   7
  1509.  
  1510.  4.  YMODEM Batch File Transmission...................................   7
  1511.      4.1  KMD/IMP Exceptions to YMODEM................................  13
  1512.  
  1513.  5.  YMODEM-g File Transmission.......................................  13
  1514.  
  1515.  6.  XMODEM PROTOCOL OVERVIEW.........................................  14
  1516.      6.1  Definitions.................................................  14
  1517.      6.2  Transmission Medium Level Protocol..........................  15
  1518.      6.3  File Level Protocol.........................................  16
  1519.      6.4  Programming Tips............................................  17
  1520.  
  1521.  7.  XMODEM/CRC Overview..............................................  18
  1522.      7.1  CRC Calculation.............................................  19
  1523.      7.2  CRC File Level Protocol Changes.............................  19
  1524.      7.3  Data Flow Examples with CRC Option..........................  21
  1525.  
  1526.  8.  MORE INFORMATION.................................................  22
  1527.  
  1528.  9.  Document Revisions...............................................  23
  1529.  
  1530. 10.  YMODEM Programs..................................................  23
  1531.  
  1532.  
  1533.                              LIST OF FIGURES
  1534.  
  1535.  
  1536.  Figure 1.  1024 byte Packets.........................................   7
  1537.  
  1538.  Figure 2.  Mixed 1024 and 128 byte Packets...........................   7
  1539.  
  1540.  Figure 3.  YMODEM Batch Transmission Session.........................  12
  1541.  
  1542.  Figure 4.  YMODEM Filename packet transmitted by sz..................  12
  1543.  
  1544.  Figure 5.  YMODEM Header Information used by various programs........  13
  1545.  
  1546.  Figure 6.  YMODEM-g Transmission Session.............................  14
  1547.  
  1548.  Figure 7.  XMODEM Message Block Level Protocol.......................  15
  1549.  
  1550.  Figure 8.  Data flow including Error Recovery........................  17
  1551.  
  1552.  Figure 9.  Message Block Level Protocol, CRC mode....................  18
  1553.  
  1554. Figure 10.  Example of CRC Calculation written in C...................  19
  1555.  
  1556. Figure 11.  Data Flow: Receiver has CRC Option, Sender Doesn't........  21
  1557.  
  1558. Figure 12.  Receiver and Sender Both have CRC Option..................  22
  1559.