home *** CD-ROM | disk | FTP | other *** search
- Xmodem Protocol
-
- Larry Jordan
- Capital PC Users Group
-
- When using the telephone system to
- transfer files between computers,
- there is always the chance that
- electrical noise will cause data
- transmission errors. To ensure
- proper transfer of files, it is
- necessary to detect data transmission
- errors and to retransmit data that
- contains errors.
-
- Asynchronous parity error detection
- does not provide that capability.
- Parity error detection tells you when
- data transfer errors occur, and it's
- up to you to retransmit data to
- correct errors. The problem is that
- parity error detection is not
- actually performed by most IBM PC
- communication packages. If a package
- does perform the error detection, it
- may not inform you of errors in a way
- that lets you know immediately to
- retransmit the data. ASCOM, for
- example, places an asterisk in a file
- where parity errors are detected, but
- you may not realize the errors
- occurred until long after the file is
- transferred. To ensure "error-free"
- data transfer, a protocol file
- transfer technique is required.
-
- A protocol is a set of rules and
- conventions that apply to a specific
- area of communications, allowing
- participants to properly communicate,
- regardless of the hardware brand or
- software package being used. The
- protocol file transfer is a set of
- rules for transferring files, which
- specifies a set of ASCII handshaking
- transfer functions. Protocol
- handshaking signals allow
- communications software to transfer
- text, data and machine code files,
- and to perform sophisticated
- error-checking. The handicap in using
- a protocol file transfer technique is
- that the computers on both ends of
- the communications link must use
- compatible software. There is no
- standard that controls these
- protocols and almost all
- communication packages that have a
- protocol file transfer option use a
- protocol unique to that package. This
- means that a group of people must
- standardize microcomputer
- communications software to take
- advantage of protocol transfers.
-
- The Ward Christensen XMODEM protocol
- is one specific file transfer
- protocol that may become a default
- standard in personal communications,
- primarily because of its widespread
- use in bulletin boards and its
- inclusion in low-cost personal
- computer communications packages,
- such as PC-TALK. Users of
- communication software deserve a
- standard protocol allowing them to
- use the technique with any
- microcomputer, regardless of the
- software packages employed.
-
- The XMODEM protocol is illustrated in
- Figure 1. As you can see from that
- figure, XMODEM does not begin to
- transfer data until the receiving
- computer signals the transmitting
- computer that it is ready to receive
- data. The Negative Acknowledge (NAK)
- character is sent to the transmitting
- computer every 10 seconds until the
- file transfer begins. If the file
- transfer does not begin after 9 NAK's
- are sent, the process has to be
- manually restarted.
-
- Figure 1
-
- XMODEM Protocol File Transfer
-
- Receiving Transmitting
- Computer Computer
- Ready to Ready to
- Receive Transmit
- + +
- + +
- + --------------/NAK/-------------- +
- + +
- +-/SOH/Blk#1/Blk#1/Good Data/CkSum/-+
- + +
- + --------------/ACK/-------------- +
- + +
- +-/SOH/Blk#2/Blk#2/Good Data/CkSum/-+
- + +
- + --------------/ACK/-------------- +
- + +
- +/SOH/Blk#3/Blk#3/Garbled Data/Cksum+
- + +
- + --------------/NAK/-------------- +
- + +
- +-/SOH/Blk#3/Blk#3/Good Data/CkSum/ +
- + +
- + --------------/ACK/-------------- +
- + +
- + --------------/EOT/-------------- +
- + +
- + --------------/ACK/-------------- +
- + +
- V V
- File File
- Receipt Transmit
- Ends Ends
-
- Once a NAK is received, the
- transmitting computer uses a Start of
- Header (SOH) character and two block
- numbers (a true block number followed
- by a 1's complement of the number) to
- signal that a 128-byte block of data
- has started to transfer; it then
- sends the block followed by an
- error-checking checksum. The checksum
- is calculated by adding the ASCII
- values of each character in the 128
- character block; the sum is then
- divided by 255 and the remainder is
- retained as the checksum. After each
- block of data is transferred, the
- receiving computer calculates its
- checksum and compares the result to
- the checksum received from the
- transmitting computer. If the two
- values are the same, the receiving
- computer sends an Acknowledge(ACK)
- character to tell the receiver to
- send the next sequential block. If
- the two values are not the same, the
- receiving computer sends the
- transmitter a NAK to request a
- retransmission of the last block.
- This retransmission process is
- repeated until the block of data is
- properly received or until nine
- attempts have been made to transmit
- the block. If the communications link
- is noisy, resulting in improper block
- transmission after nine attempts, the
- file transfer is aborted.
-
- XMODEM uses two block numbers at the
- start of each block to be sure the
- same block is not transmitted twice
- because of a handshake character loss
- during the transfer. The receiving
- computer checks the transmitted block
- to be sure that it is the one
- requested, and blocks that are
- retransmitted by mistake are thrown
- away. When all data has been
- successfully transmitted, the
- transmitting computer sends the
- receiver an End-of-Transmission (EOT)
- character to indicate end-of-file.
-
- The XMODEM protocol offers the IBM PC
- several advantages over other
- protocols and file transfer methods.
- First, the protocol is in the public
- domain, so software designers tend to
- incorporate it into a communications
- package. Second, the protocol is easy
- to implement using high level
- languages such as BASIC or PASCAL.
- Third, the protocol requires only a
- 256-byte communications receive
- buffer, which makes it attractive for
- IBM PC owners who have 64K systems.
- Fourth, the protocol allows a user to
- transfer non-ASCII 8-bit data files
- (i.e., COM, EXE and tokenized BASIC)
- between microcomputers because it
- calculates the end of a file based on
- file size and uses handshake signals
- to indicate the end of a file instead
- of relying on an end of file marker
- character (control-Z) to terminate a
- file transfer. Fifth, XMODEM error
- checking is superior to normal
- asynchronous parity error checking.
- The parity method of error checking
- is 95 percent effective if the
- software on the receiving end checks
- for parity errors. XMODEM error
- checking is 99.6 percent effective,
- and the software on the receiving end
- must check for errors. Parity errors
- detected also do not result in
- automatic retransmission of the bad
- data; XMODEM detected errors result
- in data retransmission until no
- errors are detected or until nine
- retransmissions have been attempted.
- Finally, the protocol is used by most
- bulletin boards and having it in a
- communications package allows IBM PC
- users to receive error checked files
- from their bulletin boards.