|
Xmodem communication protocol
Xmodem protocol is an asynchronous file transport protocol widely used in personal computer communication using dial-up modems. This protocol transmits data in 128/1k byte blocks, and each block uses a checksum process for error detection. If the receiver's checksum for a block is the same as the sender's checksum, the receiver sends an approval byte to the sender. In order to facilitate readers to read the program, the main features of the protocol are briefly described below. For the complete protocol of Xmoden, please refer to other related materials.
Xmodem control characters: <soh> 01H, <stx> 02H <eot> 04H, <ack> 06H, <nak> 15H, <can> 18H, <eof> 1AH.
Xmodem transmission data block format: "<soh> <packNO> <255-packNO> <...128-byte data block...> <cksum>". Among them, <soh> is the starting byte; <packNO> is the data block number byte, incremented by one each time; <255-packNO> is the complement of the previous byte; the next is a data block with a length of 128 bytes ; The last <cksum> is the check code of 128 bytes of data, the length is 2 bytes.
The receiving end dominates the entire transmission. Start the transmission by sending <nak> or <stx> or'C'. The control character "C" has a special function. When the sender receives the "C" control character, it restarts to send the data block with CRC check (packNO = 1). The CRC check method uses 16 bits (X^16 + X^12 + X^5 + 1). When the sender receives the first <nak>, it starts sending in checksum mode. When the sender receives the first <stx>, it starts sending in 1k-crc mode. When the receiving end receives a data block and the verification is correct, it sends back <ack>; receiving error sends back <nak>; and sends back <can> to indicate that the sender should stop sending. After receiving <ack>, the sender can continue to send the next data block (packNO+1). Each time a new data block <packNO> is sent, 1 is added, and the <packNO> of the next data block after adding 0xFF is zero. When receiving <nak>, the last data block can be resent again. The sender sends <eot> to indicate that all data has been sent. If the last data to be sent is less than 128 bytes, fill a data block with <eof>. |
|