home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / XYMDM.ZIP / XYMDM.DOC
Text File  |  1987-07-14  |  50KB  |  1,651 lines

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