Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| ref:xmodem [2011/07/13 22:28] – Initial import of xmodem.doc digitalman | ref:xmodem [2011/07/13 23:49] (current) – digitalman | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| < | < | ||
| - | Please circulate this document anyway that you see | + | |
| - | | + | fit without alteration except on the page at the |
| - | | + | end titled: "Notes and Comments" |
| - | | + | that anyone using these protocols within a commer- |
| - | | + | cial product not charge for them as an option or |
| - | | + | surcharge, but include XMODEM and its derivations |
| - | | + | as part of the basic product. |
| - | Peter Boswell | + | Peter Boswell |
| - | | + | |
| - | | + | |
| </ | </ | ||
| + | This document was converted to Wiki syntax by [[person: | ||
| ===== Preface ===== | ===== Preface ===== | ||
| Line 35: | Line 35: | ||
| Here are a few people that all of us should thank and I would especially like to recognize: | Here are a few people that all of us should thank and I would especially like to recognize: | ||
| - | === Ward Christensen | + | * Ward Christensen |
| Ward, a true pioneer in the microcomputer | Ward, a true pioneer in the microcomputer | ||
| communications area, is the author of the original Checksum | communications area, is the author of the original Checksum | ||
| Xmodem protocol. | Xmodem protocol. | ||
| stupid" | stupid" | ||
| - | + | ---- | |
| - | === Chuck Forsberg | + | |
| Chuck has edited perhaps the best work on | Chuck has edited perhaps the best work on | ||
| Xmodem and has provided both YMODEM (1K Xmodem) and ZMODEM | Xmodem and has provided both YMODEM (1K Xmodem) and ZMODEM | ||
| Line 47: | Line 47: | ||
| me a protocol which would deal with the X-On/X-Off problem | me a protocol which would deal with the X-On/X-Off problem | ||
| and reminding me that there is such a thing as a DLE character. | and reminding me that there is such a thing as a DLE character. | ||
| - | + | ---- | |
| - | === Richard (Scott) McGinnis | + | |
| Scott is the architect, the moving | Scott is the architect, the moving | ||
| force, for the People/Link software system. | force, for the People/Link software system. | ||
| Line 54: | Line 54: | ||
| you see his visual conference program for the IBM PC! | you see his visual conference program for the IBM PC! | ||
| Thanks for showing me how to use a DLE. | Thanks for showing me how to use a DLE. | ||
| - | + | ---- | |
| - | === Gene Plantz | + | |
| Gene operates a major IBM PC bulletin board in | Gene operates a major IBM PC bulletin board in | ||
| the Chicago area and has been active in the National SYSOP | the Chicago area and has been active in the National SYSOP | ||
| Association. | Association. | ||
| performance. | performance. | ||
| + | |||
| + | ---- | ||
| In a historical perspective, | In a historical perspective, | ||
| Line 128: | Line 130: | ||
| this paper: | this paper: | ||
| < | < | ||
| - | | + | |
| - | | + | |
| - | EOT 04 | + | EOT 04 |
| - | ACK 06 | + | ACK 06 |
| - | DLE 16 | + | DLE 16 |
| - | X-On (DC1) | + | X-On (DC1) |
| - | X-Off(DC3) | + | X-Off(DC3) |
| - | NAK 21 | + | NAK 21 |
| - | SYN 22 | + | SYN 22 |
| - | CAN 24 | + | CAN 24 |
| </ | </ | ||
| Line 148: | Line 150: | ||
| to say: | to say: | ||
| - | | + | |
| - | everything I do), to satisfy a personal need to communicate | + | everything I do), to satisfy a personal need to communicate |
| - | with some other people. | + | with some other people. |
| - | 8/77, and that I put it in the public domain immediately, | + | 8/77, and that I put it in the public domain immediately, |
| - | made it become the standard that it is" | + | made it become the standard that it is" |
| - | suggest I make SIGNIFICANT changes to the protocol, such as | + | suggest I make SIGNIFICANT changes to the protocol, such as |
| - | 'full duplex', | + | 'full duplex', |
| - | destinations', | + | destinations', |
| - | simplicity of the protocol is one of the reasons it survived | + | simplicity of the protocol is one of the reasons it survived |
| - | to this day in as many machines and programs as it may be | + | to this day in as many machines and programs as it may be |
| - | found in!"((Ward Christensen, | + | found in!" |
| + | | ||
| ==== Xmodem Hardware Level Protocol ==== | ==== Xmodem Hardware Level Protocol ==== | ||
| Line 201: | Line 204: | ||
| < | < | ||
| - | | + | |
| - | | + | |
| - | | + | |
| </ | </ | ||
| Line 215: | Line 218: | ||
| The Xmodem Packet looks like this: | The Xmodem Packet looks like this: | ||
| + | < | ||
| + | [SOH] [seq] [cmpl [seq] [128 data bytes] [csum] | ||
| - | [SOH] [seq] [cmpl [seq] [128 data bytes] [csum] | + | SOH Start of header character (decimal 1). |
| - | | + | |
| + | | ||
| + | wraps around to zero. | ||
| - | seq | + | |
| - | increments by one until it reaches | + | calculated as cmpl = 255 - (255 and seq) or using |
| - | wraps around to zero. | + | xor as cmpl = (255 and seq) xor 255. |
| - | cmpl seq one byte 1's complement of seq. This can be | + | data 128, 8 bit bytes of data. Note than when sending |
| - | | + | |
| - | xor as cmpl = (255 and seq) xor 255. | + | |
| - | + | | |
| - | data 128, 8 bit bytes of data. Note than when sending | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| Once Xmodem Initiation has completed, the transmitter sends the | Once Xmodem Initiation has completed, the transmitter sends the | ||
| Line 260: | Line 263: | ||
| Let's look at a three block file transfer: | Let's look at a three block file transfer: | ||
| < | < | ||
| - | Transmitter | + | Transmitter |
| - | <<<<< | + | <<<<< |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| </ | </ | ||
| Seems easy, right? | Seems easy, right? | ||
| Line 347: | Line 350: | ||
| * Once a SOH is found, assume that the next two characters | * Once a SOH is found, assume that the next two characters | ||
| - | * Send a NAK if a timeout occurs while attempting to re-synchronize (e.g. continue to process timeouts as | + | * Send a NAK if a timeout occurs while attempting to re-synchronize (e.g. continue to process timeouts as described above). |
| - | | + | * If no re-synchronization occurs within 135 characters |
| - | | + | |
| - | * If no re-synchronization occurs within 135 characters | + | |
| === False EOT condition === | === False EOT condition === | ||
| Line 364: | Line 365: | ||
| return a NAK for the first EOT received and only assume true | return a NAK for the first EOT received and only assume true | ||
| end of transmission after receiving two EOT's. | end of transmission after receiving two EOT's. | ||
| + | < | ||
| + | Transmitter | ||
| - | Transmitter | + | |
| - | + | <<<<< | |
| - | | + | [EOT] >>>>> |
| - | <<<<< | + | <<<<< |
| - | [EOT] >>>>> | + | [EOT] >>>>> |
| - | <<<<< | + | <<<<< |
| - | [EOT] >>>>> | + | </ |
| - | <<<<< | + | |
| Just in case the transmitter was not prepared to resend the | Just in case the transmitter was not prepared to resend the | ||
| EOT, it might be wise to set the timeout to about 3 seconds | EOT, it might be wise to set the timeout to about 3 seconds | ||
| Line 459: | Line 460: | ||
| - | ===== WINDOWED | + | ===== Windowed |
| This section assumes that the reader is already familiar with Xmodem and CRC Xmodem presented above. | This section assumes that the reader is already familiar with Xmodem and CRC Xmodem presented above. | ||
| Line 472: | Line 473: | ||
| A few people began discussing improvements to Xmodem with me in | A few people began discussing improvements to Xmodem with me in | ||
| late 1985, over time we developed the following criteria: | late 1985, over time we developed the following criteria: | ||
| + | - The protocol must be as similar as possible to the XMODEM originally developed by Ward Christensen. The popularity of XMODEM, I believe, is based on its conceptual simplicity. | ||
| + | - The protocol must overcome the propagation delay that is characteristic of the public data networks. | ||
| + | - The protocol must overcome the flow control problems which are characteristic in many public data network situations. | ||
| + | - The protocol should improve error recovery by simplifying the manner in which a programmer can determine the beginning of an XMODEM block. | ||
| - | - The protocol must be as similar as possible to the | + | ==== Transparency |
| - | XMODEM originally developed by Ward Christensen. | + | |
| - | The popularity of XMODEM, I believe, is based on | + | |
| - | its conceptual simplicity. | + | |
| - | are familiar with this protocol than any other. | + | |
| - | More files are transferred everyday by this | + | |
| - | protocol than any other asynchronous protocol. | + | |
| - | Simplicity here implies a limited number of rules | + | |
| - | for timing, error recovery | + | |
| - | - The protocol must overcome the propagation delay | ||
| - | that is characteristic of the public data networks. | ||
| - | networks than via the public voice networks, the | ||
| - | propagation delays inherent in public data networks | ||
| - | both reduces the cost savings and increases the | ||
| - | aggravation that occurs while watching a computer | ||
| - | slowly perform a file transfer. | ||
| - | - The protocol | + | This protocol |
| - | problems which are characteristic in many public | + | non-X.25 hosts and PC-Pursuit access to bulletin boards. |
| - | data network | + | to accomplish this, the transmitter is not permitted to transmit |
| - | situations, the X-On and X-Off characters | + | the X-On and X-Off characters |
| - | always be used for flow control and only for flow | + | for this restriction is simple: |
| - | control when using public data networks. | + | |
| - | | + | |
| - | simplifying | + | |
| - | determine the beginning | + | |
| - | the Start of Header character (SOH) can appear in | + | |
| - | the data or CRC, the programmer must use a relatively sophisticated method | + | |
| - | actually represents the beginning of a XMODEM | + | |
| - | block. | + | |
| - | ===== Transparency | + | * To avoid data loss public data networks must always assume that any X-Off and X-On character is a flow control character when supporting PC-Pursuit for bulletin boards and when supporting non-X.25 host systems. |
| + | Since many non-X.25 hosts, bulletin boards and communications | ||
| + | programs use X-On and X-Off as flow control characters, public | ||
| + | data networks must support those X-Off and X-On requests at the | ||
| + | point of connection where the X-Off is received by the public data | ||
| + | network. | ||
| + | up in the network would be transmitted by the public data network | ||
| + | before the X-Off used for flow control reached the transmitter. | ||
| + | The public data network has no way to know whether an X-On/X-Off | ||
| + | protocol or Xmodem is operational at any point in time. Therefore | ||
| + | a Xmodem packet which contains an X-Off character and no succeeding X-On character will cause the public data network to stop | ||
| + | forwarding the ACK or NAK. | ||
| - | This protocol provides special public data network support | + | In addition, error recovery requires sophisticated programming |
| - | | + | the receiver |
| - | to accomplish | + | protocol simplifies |
| - | the X-On and X-Off characters in the Xmodem packets. The reason | + | an indicator that an XMODEM packet |
| - | for this restriction | + | SYN (synch, decimal 22) character is used for this purpose. |
| + | The presence of one or more SYN characters in a data stream always | ||
| + | indicates that the next non SYN character | ||
| + | XMODEM packet (e.g. SOH). | ||
| - | | + | The method used here to handle these situations is through |
| - | flow control, buffer overruns and lost data are inevit- | + | insertion |
| - | able from time to time at any baud rate. | + | character) as an indicator that the character following the DLE is |
| + | in fact a modified DLE, SYN, X-On, or X-Off character. | ||
| - | To avoid data loss public data networks must always | + | === Rules === |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | Since many non-X.25 hosts, bulletin boards and communications | + | |
| - | programs use X-On and X-Off as flow control characters, public | + | - The inserted DLE characters are not counted in the 128 byte data length |
| - | data networks must support those X-Off and X-On requests at the | + | - Neither the DLE nor the adjusted characters are used in the CRC calculation, |
| - | point of connection where the X-Off is received by the public data | + | - When the receiver sees a DLE character, it does not count it in the XMODEM block length calculation, |
| - | network. | + | - Prior to transmission of a XMODEM packet, the |
| - | up in the network | + | - Except for the character received after a DLE, the |
| - | before | + | - The transmitter must support flow control characters (X-On, and X-Off) during transmission of |
| - | The public data network has no way to know whether an X-On/X-Off | + | |
| - | | + | |
| - | | + | |
| - | ing X-On character will cause the public data network | + | |
| - | forwarding the ACK or NAK. | + | |
| - | In addition, error recovery requires sophisticated programming for | + | ==== Initial Handshake Rules ==== |
| - | the receiver to determine the start of an XMODEM packet. | + | |
| - | protocol simplifies this task by dedicating a special character as | + | |
| - | an indicator that an XMODEM packet is about to begin. | + | |
| - | SYN (synch, decimal 22) character is used for this purpose. | + | |
| - | The presence of one or more SYN characters in a data stream always | + | |
| - | indicates that the next non SYN character is the beginning of an | + | |
| - | XMODEM packet (e.g. SOH). | + | |
| - | The method used here to handle these situations is through the | ||
| - | insertion of the DLE character (H010, decimal 16, data link escape | ||
| - | character) as an indicator that the character following the DLE is | ||
| - | in fact a modified DLE, SYN, X-On, or X-Off character. | ||
| - | Rules: | + | An initial handshake |
| - | + | indicate | |
| - | | + | Xmodem, CRC Xmodem, or Windowed Xmodem: |
| - | | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | |
| - | June 20, 1986 Page 17 | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | will transmit instead a DLE character followed by | + | |
| - | the original character which has been modified by | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | 128 byte data length of the data portion of the | + | |
| - | | + | |
| - | have a packet which is physically 264 bytes in | + | |
| - | | + | |
| - | (or its complement), all of the 128 data characters | + | |
| - | and two CRC characters are all either X-On, X-Off, | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | used in the CRC calculation, | + | |
| - | | + | |
| + | - WXMODEM - The receiver will send a character W | ||
| + | - CRC XMODEM - The receiver will send a character C | ||
| + | - Checksum XMODEM - The receivers will send a NAK and wait up to 3 seconds for the beginning of a Xmodem packet. | ||
| - | | + | ==== Window Packet Transmission Rules ==== |
| - | count it in the XMODEM block length calculation, | + | |
| - | nor compute it in the CRC calculation but discards | + | |
| - | it and then remembers to exclusive or the next | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | not one of those four characters) and then include | + | |
| - | the character as part of the packet. | + | |
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | + | In order to overcome |
| - | receiver will test each incoming character to see | + | data networks such as Tymnet, Telenet, Datapac, IPSS, Transpac and |
| - | if it is a SYN character. | + | dozens more, the protocol must permit |
| - | | + | than one packet before receiving an acknowledgement from the |
| - | character will be another SYN or SOH. If a SYN | + | receiver. |
| - | | + | before stopping transmission if an acknowledgement has not been |
| - | the receiver | + | received is called |
| - | | + | packets for several reasons. |
| - | beginning of a XMODEM packet by the receiver. | + | set of timing rules which would deal reasonably well with a wide |
| - | an out of synch condition occurs on incoming | + | range of baud rates (that implied keeping |
| - | data, the receiver can just ignore every incoming | + | small). |
| - | character until it sees a SYN. | + | to the Xmodem packet sequence number |
| - | code which already properly deals with this | + | simplify implementation |
| - | situation could just always discard any SYN | + | |
| - | | + | |
| - | | + | |
| + | === Rules === | ||
| + | 1. The window is always 4 Xmodem packets. | ||
| + | |||
| + | 2. The receiver will transmit acknowledgements in the form: | ||
| + | | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | The [sequence] field is an 8 bit number where the |
| - | June 20, 1986 Page 18 | + | high order or most significant 6 bits are always |
| - | ---------------------------------------------------------------------- | + | zero and the low order or least significant 2 bits |
| + | are always the same as the low order 2 bits of the | ||
| + | XMODEM block sequence number of the XMODEM packet | ||
| + | being acknowledged (value in decimal may range | ||
| + | from 0 to 3). | ||
| + | 3. The receiver does not have to acknowledge every | ||
| + | packet, but must acknowledge at minimum every | ||
| + | fourth packet. | ||
| + | ACK[sequence] for multiple XMODEM packets. | ||
| + | example, after an unknown number of packets: | ||
| + | < | ||
| + | | ||
| - | 6.2.7. The transmitter must support flow control char- | + | .... |
| - | acters (X-On, and X-Off) during transmission of | + | .... |
| - | packets. Upon receipt of an X-Off it will wait 10 | + | .... |
| - | seconds for an X-On and will start transmission | + | [Block Sequence Number H0FE] |
| - | again after 10 seconds or an X-On is received, | + | [Block Sequence Number H0FF] ACK[H002] |
| - | whichever occurs first. | + | [Block Sequence Number H000] ACK[H003] |
| - | characters received by the transmitter will be | + | [Block Sequence Number H001] |
| - | ignored and discarded. | + | [Block Sequence Number H002] ACK[H001] |
| - | apply to X.25 host computers which use X.25 L2 and | + | |
| - | L3 windows | + | </ |
| + | Since some transmitters must close the window | ||
| + | cease all communications before doing disk I/O to | ||
| + | read more data, it is suggested that acknowledgements be sent for every packet (except when the | ||
| + | receiver can easily determine that another packet | ||
| + | is already being received at the point in time that | ||
| + | the ACK[sequence] is about to be sent).3 | ||
| - | 6.3. Initial Handshake Rules | ||
| - | |||
| - | An initial handshake is provided to permit the receiver to | ||
| - | indicate to the transmitter whether it can support checksum | ||
| - | | ||
| - | |||
| - | | ||
| - | | ||
| - | of a Xmodem packet. | ||
| - | and then the receiver will drop down to CRC Xmodem. | ||
| - | |||
| - | | ||
| - | | ||
| - | of a Xmodem packet. | ||
| - | and then the receiver will drop down to Checksum | ||
| - | | ||
| - | |||
| - | | ||
| - | and wait up to 3 seconds for the beginning of a | ||
| - | | ||
| - | if no valid SOH is received, the receiver will | ||
| - | abort the file transfer request. | ||
| - | |||
| - | 6.4. Window Packet Transmission Rules | ||
| - | |||
| - | In order to overcome the propagation delays inherent with public | ||
| - | data networks such as Tymnet, Telenet, Datapac, IPSS, Transpac and | ||
| - | dozens more, the protocol must permit the transmitter to send more | ||
| - | than one packet before receiving an acknowledgement from the | ||
| - | receiver. | ||
| - | before stopping transmission if an acknowledgement has not been | ||
| - | received is called the " | ||
| - | packets for several reasons. | ||
| - | set of timing rules which would deal reasonably well with a wide | ||
| - | range of baud rates (that implied keeping the window fairly | ||
| - | small). | ||
| - | to the Xmodem packet sequence number which, hopefully, will | ||
| - | simplify implementation of windowing. | ||
| + | 4. The receiver will reject a packet (request retransmission) by sending: | ||
| + | NAK[sequence] | ||
| + | Where [sequence] is then next window sequence | ||
| + | number (between H000 and H003) after the [sequence] | ||
| + | of the last good block. | ||
| + | up to 3 Xmodem packets received after the NAK is | ||
| + | transmitted until it receives the packet with the | ||
| + | sequence number that had previously been nak'ed by | ||
| + | the receiver. | ||
| + | NAK until another packet with the same sequence | ||
| + | number is received which is also invalid or a | ||
| + | timeout has occurred. | ||
| + | 5. When the transmitter receives a NAK[sequence], | ||
| + | will complete transmission of any XMODEM block | ||
| + | currently being transmitted and then begin re- | ||
| + | transmission starting with the block which was | ||
| + | nak' | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | 6. The receiver will discard duplicate packets but |
| - | June 20, 1986 Page 19 | + | count them in the window for purposes of deter- |
| - | ---------------------------------------------------------------------- | + | mining the maximum receive window without an ACK in |
| + | response. | ||
| + | sequence number 127 four times in a row, it must | ||
| + | send an ACK H003 even if the receiver has previously acked that block. | ||
| + | 7. The timeout intervals at various points in processing are: | ||
| - | Rules: | + | * Waiting for a character on receive, start of packet |
| + | * Waiting for a character on receive, start of packet has been recognized: | ||
| + | * Waiting for an Ack or Nak on transmit side after the window has closed: | ||
| + | * Waiting for an X-On after receipt of an X-Off by the transmitter: | ||
| - | 6.4.1. The window is always 4 Xmodem packets. That is, | + | 8. When the transmitter times out waiting for an ACK or NAK when the window is closed (e.g. four blocks |
| - | the transmitter will send 4 unacknowledged pack- | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | files or at end-of-file. | + | |
| - | 6.4.2. The receiver | + | 9. Where possible, it is recommended that the receiver |
| - | | + | |
| - | ACK[sequence] | + | If the receiver cannot overlap disk I/O and communications |
| + | I/O, the receiver can temporarily stop transmission by either: | ||
| - | | + | - " |
| - | high order or most significant 6 bits are always | + | - Transmitting an X-Off followed by an X-On when the receiver |
| - | | + | - Each approach has its advantages, but the X-Off approach |
| - | are always | + | |
| - | | + | |
| - | being acknowledged (value | + | |
| - | from 0 to 3). | + | |
| - | + | ||
| - | | + | |
| - | packet, but must acknowledge at minimum every | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | cease all communications | + | |
| - | read more data, it is suggested that acknowledge- | + | |
| - | ments be sent for every packet (except when the | + | |
| - | | + | |
| - | is already being received at the point in time that | + | |
| - | the ACK[sequence] is about to be sent).3 | + | |
| + | ==== Notes for X.25 Hosts ==== | ||
| + | Host computer systems which utilize the X.25 protocol | ||
| + | (examples: People/ | ||
| + | interface with the various public data networks may send special | ||
| + | control packets which change the manner in which the network will | ||
| + | communicate with the remote personal computer, bulletin board or | ||
| + | terminal. | ||
| + | X.25 host can already support CRC and/or Checksum Xmodem and | ||
| + | present only the changes for WXMODEM. | ||
| + | - When an X.25 Host is the transmitter, | ||
| + | - When an X.25 Host is the receiver and in WXMODEM | ||
| - | |||
| - | Xmodem, CRC Xmodem, WXmodem | ||
| - | June 20, 1986 Page 20 | ||
| - | | ||
| - | |||
| - | | ||
| - | | ||
| - | |||
| - | NAK[sequence] | ||
| - | |||
| - | Where [sequence] is then next window sequence | ||
| - | | ||
| - | of the last good block. | ||
| - | up to 3 Xmodem packets received after the NAK is | ||
| - | | ||
| - | | ||
| - | the receiver. | ||
| - | NAK until another packet with the same sequence | ||
| - | | ||
| - | | ||
| - | |||
| - | | ||
| - | will complete transmission of any XMODEM block | ||
| - | | ||
| - | | ||
| - | | ||
| - | |||
| - | | ||
| - | count them in the window for purposes of deter- | ||
| - | | ||
| - | | ||
| - | | ||
| - | send an ACK H003 even if the receiver has previous- | ||
| - | ly acked that block. | ||
| - | |||
| - | | ||
| - | ing are: | ||
| - | |||
| - | | ||
| - | not yet recognized: | ||
| - | |||
| - | | ||
| - | has been recognized: | ||
| - | |||
| - | | ||
| - | the window has closed: | ||
| - | |||
| - | | ||
| - | the transmitter: | ||
| - | |||
| - | | ||
| - | or NAK when the window is closed (e.g. four blocks | ||
| - | have been transmitted), | ||
| - | | ||
| - | | ||
| + | ===== Appendix A - CRC Calculation Rules ===== | ||
| + | The purpose of this appendix is to give non-technical and non mathematical software writers a cook book approach to calculating the CRC-16 | ||
| + | used in Xmodem. | ||
| + | in the examples below has been tested on an IBM PC and found to work | ||
| + | effectively even at 9600 with compiled Basic. | ||
| + | not offer an XOR function and others do not have MKI$ and CVI functions | ||
| + | which simplified the movement of data between data types. | ||
| + | hope to provide a Commodore C-64/C-128 implementation which simulates | ||
| + | XOR, but not today! | ||
| + | My thanks go to Chuck Forsberg, Joe Noonan, John Byrns and Stephen | ||
| + | Satchell. | ||
| + | have never been possible. | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | ==== IBM PC - 8088/8086 Data Structure ==== |
| - | June 20, 1986 Page 21 | + | |
| - | | + | |
| - | | ||
| - | | ||
| - | 6.4.9. Where possible, it is recommended that the receiver | + | The Intel 8080 and upward has a feature, convenient only to some |
| - | return an ACK[sequence] | + | electrical engineer somewhere, which places 2 byte (16) bit |
| - | least 50% of the Xmodem packets. | + | integers in BYTE REVERSE order in memory. That is, the least |
| - | must wait for the window | + | significant byte is placed in memory before |
| - | Xmodem packets without an acknowledgement), | + | byte for integer operations. |
| - | some performance benefit will be lost. | + | number 52 and it is assigned |
| + | binary value (52) ends up in the first byte of I% and the second | ||
| + | byte is zero. | ||
| + | < | ||
| + | Result | ||
| - | If the receiver cannot overlap disk I/O and communications | + | |
| - | I/O, the receiver can temporarily stop transmission by either: | + | |
| + | A$=" | ||
| + | I%=ASC(A$) | ||
| + | B$=MKI$(I%) | ||
| + | I%=CVI(CHR$(0)+A$) | ||
| + | A$=CHR$(65) | ||
| + | </code> | ||
| + | Once this is understood, many problems with these algorithms goes away. | ||
| - | " | + | ==== BASIC Implementation of Bit Shift Method ==== |
| - | an ACK[sequence]) performing the disk I/O and then sending an | + | |
| - | | + | |
| - | | ||
| - | is ready to resume accepting data. Note that the receiver | ||
| - | | ||
| - | after the X-Off is sent to cover situations where satellite | ||
| - | | ||
| - | would let the computer user set the "X-Off delay time" so | ||
| - | that in the normal case the X-Off delay could be set to 25 | ||
| - | | ||
| - | | ||
| - | based on experience during the file transfer. | ||
| - | Each approach has its advantages, but the X-Off approach will | + | The bit shift method here was converted from the " |
| - | provide the best performance | + | presented |
| - | using a public data network. | + | and from an old IBM two page reference guide that Joe Noonan |
| - | | + | carries with him in his appointment calendar! |
| - | receive communications data while writing to disk. | + | |
| - | + | === Chucks' "C" | |
| - | + | <code> | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | |
| - | June 20, 1986 Page 22 | + | |
| - | | + | |
| - | + | ||
| - | 6.5. Notes for X.25 Hosts | + | |
| - | + | ||
| - | Host computer systems which utilize the X.25 protocol | + | |
| - | (examples: People/ | + | |
| - | interface with the various public data networks may send special | + | |
| - | control packets which change the manner in which the network will | + | |
| - | communicate with the remote personal computer, bulletin board or | + | |
| - | terminal. | + | |
| - | X.25 host can already support CRC and/or Checksum Xmodem and | + | |
| - | present only the changes for WXMODEM. | + | |
| - | + | ||
| - | | + | |
| - | sure to set the distant X.3 PAD parameters to | + | |
| - | | + | |
| - | flow control. | + | |
| - | Q-Bit command packet to set X.3 parameter 12 to a 1 | + | |
| - | prior to the initial handshake. | + | |
| - | | + | |
| - | send the appropriate Q-Bit packet to reset para- | + | |
| - | meter 12 to a 0 before transmitting the first CRC | + | |
| - | or Checksum Xmodem packet. | + | |
| - | + | ||
| - | | + | |
| - | mode, it must be sure to set the distant X.3 PAD | + | |
| - | | + | |
| - | | + | |
| - | the transmitter to prevent its buffers from | + | |
| - | | + | |
| - | Q-Bit command packet to set X.3 parameter 5 to a 1 | + | |
| - | prior to the initial handshake. | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | |
| - | June 20, 1986 Page 23 | + | |
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | The purpose of this appendix is to give non-technical and non mathema- | + | |
| - | tical software writers a cook book approach to calculating the CRC-16 | + | |
| - | used in Xmodem. | + | |
| - | in the examples below has been tested on an IBM PC and found to work | + | |
| - | | + | |
| - | not offer an XOR function and others do not have MKI$ and CVI functions | + | |
| - | which simplified the movement of data between data types. | + | |
| - | hope to provide a Commodore C-64/C-128 implementation which simulates | + | |
| - | XOR, but not today! | + | |
| - | + | ||
| - | My thanks go to Chuck Forsberg, Joe Noonan, John Byrns and Stephen | + | |
| - | | + | |
| - | have never been possible. | + | |
| - | + | ||
| - | 7.1. IBM PC - 8088/8086 Data Structure | + | |
| - | + | ||
| - | The Intel 8080 and upward has a feature, convenient only to some | + | |
| - | electrical engineer somewhere, which places 2 byte (16) bit | + | |
| - | integers in BYTE REVERSE order in memory. | + | |
| - | significant byte is placed in memory before the most significant | + | |
| - | byte for integer operations. | + | |
| - | number 52 and it is assigned to I% using the ASC function, the | + | |
| - | binary value (52) ends up in the first byte of I% and the second | + | |
| - | byte is zero. | + | |
| - | | + | |
| - | + | ||
| - | I%=0 [x' | + | |
| - | I%=1 [x'0100' | + | |
| - | A$="A" | + | |
| - | I%=ASC(A$) | + | |
| - | B$=MKI$(I%) | + | |
| - | I%=CVI(CHR$(0)+A$) | + | |
| - | A$=CHR$(65) | + | |
| - | + | ||
| - | Once this is understood, many problems with these algorithms goes | + | |
| - | away. | + | |
| - | + | ||
| - | 7.2. BASIC Implementation of Bit Shift Method | + | |
| - | + | ||
| - | The bit shift method here was converted from the " | + | |
| - | presented in Chuck Forsberg' | + | |
| - | and from an old IBM two page reference guide that Joe Noonan | + | |
| - | carries with him in his appointment calendar! | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | Xmodem, CRC Xmodem, WXmodem | + | |
| - | June 20, 1986 Page 24 | + | |
| - | | + | |
| - | + | ||
| - | + | ||
| - | Chucks' | + | |
| /* | /* | ||
| Line 974: | Line 739: | ||
| | | ||
| } | } | ||
| + | </ | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | Xmodem, CRC Xmodem, WXmodem | ||
| - | June 20, 1986 Page 25 | ||
| - | | ||
| - | |||
| - | |||
| - | But in IBM PC BASIC, our implementation looks like: | ||
| + | But in IBM PC BASIC, our implementation looks like: | ||
| + | < | ||
| 100 DEFINT A-Z ' | 100 DEFINT A-Z ' | ||
| 2000 REM * V$ CONTAINS 133 CHARACTER COMPLETE XMODEM PACKET | 2000 REM * V$ CONTAINS 133 CHARACTER COMPLETE XMODEM PACKET | ||
| Line 1014: | Line 770: | ||
| 4130 CRC$=CHR$(CRCH1)+CHR$(CRCL1) | 4130 CRC$=CHR$(CRCH1)+CHR$(CRCL1) | ||
| 4140 RETURN 'WHEW | 4140 RETURN 'WHEW | ||
| + | </ | ||
| + | That routine will execute 128 * 7 + 128 * 9 * 8 BASIC statements | ||
| + | for each Xmodem packet or 10112 statements per Xmodem packet! | ||
| + | will work for low baud rates in compiled BASIC, but just is too | ||
| + | much for interpretive BASIC. | ||
| - | That routine will execute 128 * 7 + 128 * 9 * 8 BASIC statements | + | ==== BASIC Implementation of the Table Method ==== |
| - | for each Xmodem packet or 10112 statements per Xmodem packet! | + | |
| - | will work for low baud rates in compiled BASIC, but just is too | + | |
| - | much for interpretive BASIC. | + | |
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | Xmodem, CRC Xmodem, WXmodem | ||
| - | June 20, 1986 Page 26 | ||
| - | | ||
| - | |||
| - | 7.3. BASIC Implementation of the Table Method | ||
| - | |||
| - | This method is based on routine M4 in Steven Satchell' | ||
| - | "Test of CRC Routines for CRC-CCITT", | ||
| - | cant differences. | ||
| - | with the bit shift method is used to avoid performing the bit | ||
| - | shift during communications. | ||
| - | each byte value from 0 to 255 when the original CRC is zero. The | ||
| - | result of this calculation is included in the DATA statements in | ||
| - | the code. | ||
| - | |||
| - | The comments are intended to show what is logically happening | ||
| - | rather than physically. | ||
| - | integers in the 8088, a logical shift of 8 bits to the left is a | ||
| - | physical shift of eight bits to the right! | ||
| + | This method is based on routine M4 in Steven Satchell' | ||
| + | "Test of CRC Routines for CRC-CCITT", | ||
| + | cant differences. | ||
| + | with the bit shift method is used to avoid performing the bit | ||
| + | shift during communications. | ||
| + | each byte value from 0 to 255 when the original CRC is zero. The | ||
| + | result of this calculation is included in the DATA statements in | ||
| + | the code. | ||
| + | The comments are intended to show what is logically happening | ||
| + | rather than physically. | ||
| + | integers in the 8088, a logical shift of 8 bits to the left is a | ||
| + | physical shift of eight bits to the right! | ||
| + | < | ||
| 200 DEFINT A-Z 'ALL INTEGERS | 200 DEFINT A-Z 'ALL INTEGERS | ||
| 210 DIM CRCTB(256) | 210 DIM CRCTB(256) | ||
| Line 1081: | Line 827: | ||
| 9140 DATA -9219, | 9140 DATA -9219, | ||
| 9150 DATA 27814, 31879, 19684, 23749, 11298, 15363, 3168, 7233 | 9150 DATA 27814, 31879, 19684, 23749, 11298, 15363, 3168, 7233 | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | Xmodem, CRC Xmodem, WXmodem | ||
| - | June 20, 1986 Page 27 | ||
| - | | ||
| - | |||
| 9160 DATA -4690, | 9160 DATA -4690, | ||
| 9170 DATA 32407, 28342, 24277, 20212, 15891, 11826, 7761, 3696 | 9170 DATA 32407, 28342, 24277, 20212, 15891, 11826, 7761, 3696 | ||
| Line 1110: | Line 846: | ||
| 9410 DATA -4321, | 9410 DATA -4321, | ||
| 9420 DATA 28183, 32310, 20053, 24180, 11923, 16050, 3793, 7920 | 9420 DATA 28183, 32310, 20053, 24180, 11923, 16050, 3793, 7920 | ||
| + | </ | ||
| + | This method uses 128 * 6 BASIC statements per Xmodem packet or a | ||
| + | miserly 768 BASIC statements per packet. | ||
| + | code can be tightened still more. Unfortunately, | ||
| + | tightening that we could see would eliminate most of the already | ||
| + | limited readability of the code. | ||
| + | |||
| + | ===== Notes and Comments ===== | ||
| + | Please add your notes and comments here or send them to me and I'll get | ||
| + | them added to the current copy on People/ | ||
| - | | + | - This was originally set up to ADD 32 to the character on transmit |
| - | miserly 768 BASIC statements per packet. | + | - The use of the SYN character was added at the request of several |
| - | code can be tightened still more. | + | - The suggestion that ACK[sequence] be sent for every block received |
| - | | + | - The original value for the ACK/NAK timeout was 10 seconds. |
| - | | + | |
| - | Xmodem, | + | XMODEM and its derivatives have become the primary method for file |
| - | June 20, 1986 Page 28 | + | transfer for personal computers and is a popular error recovery type |
| - | ---------------------------------------------------------------------- | + | protocol. Before learning more about Xmodem, |
| + | what its author has to say: | ||
| - | | + | "It was a quick hack I threw together, very unplanned (like |
| + | everything I do), to satisfy a personal need to communicate | ||
| + | with some other people. | ||
| + | 8/77, and that I put it in the public domain immediately, | ||
| + | made it become the standard that it is"....." | ||
| + | suggest I make SIGNIFICANT changes to the protocol, such as | ||
| + | 'full duplex', | ||
| + | destinations', | ||
| + | simplicity of the protocol is one of the reasons it survived | ||
| + | to this day in as many machines and programs as it may be | ||
| + | found in!" | ||
| - | | + | Ward Christensen, |
| - | them added to the current copy on People/Link. | + | in 1985. Edited by Chuck Forsberg, " |
| + | Reference", | ||
| - | | + | The protocol |
| - | and SUBTRACT 32 on receive. | + | |
| - | logic is the same on transmit and receive. | + | |
| - | | + | |
| - | people who have coded Xmodem routines and have struggled valiantly | + | |
| - | to improve their error recovery routines. | + | |
| - | | + | |
| - | was added. | + | |
| - | | + | |
| - | was changed to 15 seconds the situation where the receiver | + | |
| - | operating at 300 baud and using X-Off to stop receipt of characters | + | |
| - | during disk I/O. Peter Boswell, 6/10/86 | + | |
| - | + | ||
| - | | + | |
| - | | + | |
| - | | + | |
| - | what its author has to say: | + | |
| - | "It was a quick hack I threw together, very unplanned (like | + | ===== See Also ===== |
| - | | + | |
| - | with some other people. | + | |
| - | 8/77, and that I put it in the public domain immediately, | + | |
| - | made it become the standard that it is" | + | |
| - | suggest I make SIGNIFICANT changes to the protocol, such as | + | |
| - | 'full duplex', | + | |
| - | destinations', | + | |
| - | simplicity of the protocol is one of the reasons it survived | + | |
| - | to this day in as many machines and programs as it may be | + | |
| - | found in!" | + | |
| - | Ward Christensen, | + | {{tag> |
| - | in 1985. Edited by Chuck Forsberg, " | + | |
| - | Reference", | + | |
| - | The protocol is Asynchronous, | ||
| - | bit. | ||
| - | ===== See Also ===== | ||
| - | * [[: | ||
| - | {{tag> | ||