Introduction X-MODEM protocol (reproduced)

xiaoxiao2021-03-06  77

XMODEM protocol

XModem protocol was developed and first implemented by Ward Christensen in 1977 and placed in the public domain becoming one of the earliest and most popular protocols for file transfers between various hardware platforms.

XModem is the simplest and one of the slowest of the file transfer protocols. It uses data blocks of only 128 bytes, requires an acknowledgement of every single block transmitted and uses only a simple checksum for data validation.

XModem Blocks Have The Following Format:

1 Byte 1 byte <~ blockno> 1 byte 128 bytes 1 byte

SOH marks start of the block. BlockNo is a one byte block number. The block numbers have range [1, 255]. After 255, the block number cycle starts again. ~ BlockNo is a complement of the block number. Data are a text LONG 128 Characters. If The Text Is Shorter Than 128 Characters, The Data Block Is Filled with Padding Characters (Ctrlz by Default). Checksum is an Arithmetic Sum (MODULO-256) of All Data Bytes.

A Typical XModem Protocol Transfer Looks Like this:

TransmitterReceiver <1> <254> -> Response Acknowledgment <2> <253> -> -> End of Transmission <-

Handshake: the receiver always begins communication in start-up phase by sending a handshake character (in this case a NAK character) It waits for 10 seconds for the response If it does not receive a block within 10 seconds it sends another NAK... Receiver tries up to 10 times to establish the handshake when it gives up Response:.. transmitter sends requested data Data are divided in blocks 128 characters long Timeout for each character to be received is 1 second Transmitter waits after first block up to 1.. minute for the receiver's acknowledgement This gives the receiver time for disk storage preparation Acknowledgement:... receiver calculates the checksum and compares it to the checksum received If checksums are the same, it sends positive acknowledgement ACK If they differ, the receiver sends a. NAK AND The Transmitter Resends The Current Block. This Continues Until The All Data IS Transmitted. End of Transmission: After The All Data Are Transmitted, The Transmitter Notifies That B y sending a EOT character. Either side can cancel transmission at any time by sending 3 CAN (CtrlX) characters.Protocol does not support any additional information about the file being transmitted, like file name or file size. Hence, the received file size is always a multiple of the block size Since XModem does not escape any binary data (like XON and XOFF), a software flow control is not possible For binary data transfer hardware flow control (called also RTS / CTS Control -.. Ready to Send / Clear to send) Should Be SELECTED.

XMODEM EXTENSIONS

XModem CRC improves error checking by substituting 1 byte checksum with 2 bytes cyclic redundancy check (CRC16). This offers much higher level of data integrity. The receiver indicates this protocol by sending the 'C' character as a handshake. Receiver tries up to 3 Times to Start Data Transmiter IS Not Capable. 2 Bytescrc Hibytecrc Lobytexmodem Uses A Non-Reverse CRC Algorithm with Divisor PolyNomial X16 X12 X5 X0.

TransmitterRecEiver <-C

1 Byte 1 byte <~ blockno> 1 byte 128 bytes 2 bytes -> ->

XModem 1k improves data transfer speed by increasing block size up to 1024 bytes. Each block starts with an STX character rather than an SOH. A CRC16 is used for the checksum. Because of the larger block size, number of times the transmitter must wait for an acknowledgement is reduced and transmission speed is increased. With noisy lines throughput is reduced significantly, because the block must be retransmitted is bigger. If transmitter receives 5 NAK characters in a row, it should decrease block size to 128 bytes. Once the block size Is Reduced, IT IS Never Stepped Back Up to 1024 Bytes.

TransmitterRecEiver <-C

1 byte 1 byte <~ blockno> 1 byte 1024 bytes 2 bytes -> ->

XModem 1kG supports data streaming. The receiver request data by sending the 'G' character as a handshake. The transmiter continuously transmits blocks without waiting for acknowledgment. If the receiver does encounter a bad block, it aborts entire session by sending a NAK. To Obtain this Very High Throughput, Modems on Both Sides of the Line Must Have Enabled Error Correcting Features.TransmitterRecEiver <-g

1 byte 1 byte <~ blockno> 1 byte 1024 bytes 2 bytes->

1 byte 1 byte <~ blockno> 1 byte 1024 bytes 2 bytes -> ->

REFERENCE:

Xmodem / YMODEM Protocol Reference By Chuck Forsberg [10-14-88]

转载请注明原文地址:https://www.9cbs.com/read-121354.html

New Post(0)