介绍X-MODEM协议(转载)

原创 2004年09月01日 08:34:00

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:

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

 

常见的MODEM通讯协议

常见的MODEM通讯协议体系可以分为传输协议、纠错协议、压缩协议及传真协议、语音协议等几大类。   1、传输协议   Bell 103 贝尔的 300bps 标准,相当于 V.21...
  • KISSMonX
  • KISSMonX
  • 2013年05月29日 14:47
  • 3250

常见的MODEM通讯协议

常见的MODEM通讯协议体系可以分为传输协议、纠错协议、压缩协议及传真协议、语音协议等几大类。   1、传输协议   Bell 103 贝尔的 300bps 标准,相当于 V.21...
  • KISSMonX
  • KISSMonX
  • 2013年05月29日 14:47
  • 3250

介绍X-MODEM协议和Y-MODEM,Z-MODEM的区别

介绍X-MODEM协议和Y-MODEM,Z-MODEM的区别  (2010-02-22 16:18:25) 转载▼ 标签:  it   分类: 网络技术类 ...
  • u010980705
  • u010980705
  • 2016年11月11日 10:08
  • 1122

简单易懂的USB协议理解

通俗易懂的USB协议详解(转载) 转自 Branchesss的博客:http://blog.sina.com.cn/s/blog_8bbf650701013mub.html USB...
  • aba13579
  • aba13579
  • 2014年03月11日 14:39
  • 953

HTTP协议简单介绍

Http协议是超文本传输协议的缩写,是用于从万维网服务器传输超文本到本地浏览器的传送协议。Http协议是一个基于TCP/IP通信协议来传输数据(HTML文件、图片文件、查询结果等) 浏览器作为HTTP...
  • leixiaolan
  • leixiaolan
  • 2016年08月12日 15:05
  • 801

“知识共享”(CC协议)简单介绍

文章转载自: https://zhuanlan.zhihu.com/p/20641764 作者:漠伦 本人截取了其中的一些比较实用的部分。 同样本文采用 CC-BY 协议进行授权。“知识共享”是...
  • ikewyz
  • ikewyz
  • 2016年10月14日 19:19
  • 743

Http协议简介

1)URI和URL URI:统一资源标识符。用于标识某一互联网资源名称的字符串。包括URL和URN URL:统一资源定位符。URI的一种形式。现在基本都是用URL来代表URI。可以将URL和URI等同...
  • u013510838
  • u013510838
  • 2016年09月04日 12:01
  • 814

DHCP协议简介

DHCP协议简介
  • u011325432
  • u011325432
  • 2016年01月05日 16:51
  • 894

网络各层协议简介

网络接口层   网络接口层在发送端将上层的IP数据报封装成帧后发送到网络上;数据帧通过网络到达接收端时,该结点的网络接口层对数据帧拆封,并检查帧中包含的MAC地址。如果该地址就是本机的MAC地址或者...
  • DaLQT
  • DaLQT
  • 2016年04月16日 00:14
  • 718

TCP/IP(一):TCP/IP协议简单介绍

OSI的7层协议体系和TCP/IP 4层协议体系如下图所示,OSI模型完整但是复杂不太实用,如今应用最多的是TCP/IP 4层协议体系:网络接口层,网络层(IP),传输层(TCP、UDP), 应用层。...
  • sweetgum2012
  • sweetgum2012
  • 2016年04月17日 13:33
  • 1905
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:介绍X-MODEM协议(转载)
举报原因:
原因补充:

(最多只允许输入30个字)