分享
 
 
 

介绍X-MODEM协议(转载)

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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:

<SOH> 1 byte

<BlockNo> 1 byte

<~BlockNo> 1 byte

<Data> 128 bytes

<Checksum> 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:

Transmitter

Receiver

<-

<NAK>

handshake

<SOH><1><254><Data 128 bytes><CHK>

->

response

<-

<ACK>

acknowledgment

<SOH><2><253><Data 128 bytes><CHK>

->

<-

<ACK>

<EOT>

->

end of transmission

<-

<ACK>

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 by 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 transfer when it concludes that transmiter is not capable.

<CRC16> 2 bytes

CRC HiByte

CRC LoByte

XModem uses a non-reversed CRC algorithm with divisor polynomial X16+X12+X5+X0.

Transmitter

Receiver

<-

C

<SOH> 1 byte

<BlockNo> 1 byte

<~BlockNo> 1 byte

<Data> 128 bytes

<CRC16> 2 bytes

->

<-

<ACK>

<EOT>

->

<-

<ACK>

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.

Transmitter

Receiver

<-

C

<STX> 1 byte

<BlockNo> 1 byte

<~BlockNo> 1 byte

<Data> 1024 bytes

<CRC16> 2 bytes

->

<-

<ACK>

<EOT>

->

<-

<ACK>

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.

Transmitter

Receiver

<-

G

<STX> 1 byte

<BlockNo> 1 byte

<~BlockNo> 1 byte

<Data> 1024 bytes

<CRC16> 2 bytes

->

<STX> 1 byte

<BlockNo> 1 byte

<~BlockNo> 1 byte

<Data> 1024 bytes

<CRC16> 2 bytes

->

<EOT>

->

Reference:

XModem / YModem Protocol Reference by Chuck Forsberg [10-14-88]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有