[net.micro.apple] XMODEM protocol description

flaps@utcs.uucp (Alan J Rosenthal) (11/12/85)

Posted in response to several requests.
 
I wrote this a couple of years ago from documentation, and edited it just
now.  Note that a dollar sign indicates a hexadecimal number; for example $35
means 35 hex or 41 decimal.  Ward Christensen protocol is a special case of
XMODEM protocol and is what is used by Ascii Express.
 
 
Ward Christensen Protocol Description
=====================================
 
For initial handshake, the receiver sends a $15, then sender sends $01, the
first block number (00), 1s complement of first block number (FF), then the
special filetype block.  It waits for $06 or $15, which mean ok or transmit
again respectively.  The other blocks consist of $01, block number, 1s
complement of block number, 128 bytes of data, then a single byte checksum,
which is the sum mod 256 of all the data bytes.  As the receiver receives, it
computes its own checksum; upon completion of the block it compares.  If they
match, it transmits a $06 for acknowledge.  Otherwise $15 for negative
acknowledgement.  Then the sender sends the next block.  A timeout of 10
seconds counts as a negative acknowledgement.  This occurs during disk saves.
Therefore the receiving computer must check the block #'s and scan for
repeats.  It also verifies the form of the block header by adding the first
three bytes which should sum to 0 mod 256.  At the end the sender sends a $04
and the receiver sends back a $06.  In addition there is an AE pro checksum
called Cyclic Redundancy Check, which is only printed.  At 300 baud a block
takes about 4.5 seconds.
 
If you are not using Ascii Express, simply XMODEM protocol, then the
description of block zero may not apply; this is part of Ward Christensen
protocol but not of the general XMODEM specifications.
 
Also of interest are the following diagnostic messages produced by Ascii
Express while transmitting or receiving files.
 
     S <n>               sending block n
     R <n>               receiving block n
     T <ERR#n-i>         Timeout error, block n, error #i
     NAK <ERR#n-i>       Block sent not acknowledged as ok
     CS <ERR#n-i>        Checksum error
     BS <ERR#n-i>        Bad start - improper data format
     WB <ERR#n-i>        Wrong block number received
     FT <ERR#n-i>        Invalid file type
     SYNC ERROR!         unrecoverable
 
Note that all errors other than SYNC ERROR are recovered from correctly by
Ascii Express.  Verifying the CRC at both ends gives a 99.9% guarantee of
accurate transmission.

If any of the above is unclear then please send a request.  If it is of
general interest I will post to the net as well as responding personally.

Alan J Rosenthal
{ihnp4|allegra|linus|decvax}!utzoo!utcs!flaps, cbosgd!utcs!flaps
ARPA:	@seismo.ARPA:flaps@utcs.uucp