当前位置:网站首页>What is the lszrz protocol used at ordinary times? Talk about xmodem/ymodem/zmodem
What is the lszrz protocol used at ordinary times? Talk about xmodem/ymodem/zmodem
2022-06-12 05:43:00 【Amos-Chen】
XMODEM, YMODEM, and ZMODEM
Because of the usual use of rz/sz More ,r/s A good understanding , One send One receive. But the reason is not clear z What does that mean? , Therefore, there is this article. .sx/rx, sb/rb (b=batch) and sz/rz Implemented separately xmodem,ymodem and zmodem File transfer protocol .
Xmodem(1977 Ward Christensen )->Ymodem(1985 Chuck Forsberg )->Zmodem(1986 Chuck Forsberg)
To have a first Xmodem, Later, it gradually evolved into Ymodem, however Ymodem It's not fast enough and has many shortcomings , Then it developed into Zmodem, This is one of the many file transfer protocols we use in our daily work .
Xmodem
One of the widely used file transfer protocols . The original Xmodem Agreement to use 128 Byte packets and simple The checksum Method as error detection . Subsequently improved to Xmodem-CRC, Use a more secure cyclic redundancy check (Cyclic Redundancy Check ) Method as error detection .Xmodem Protocols always try to take precedence CRC, If the sender does not receive the use CRC Mode request message , The receiver will switch to The checksum Mode to continue requesting transmission .
Checksum method
Package structure
| byte1 | byte2 | byte3 | bytes 4~131=128bytes | byte132 |
|---|---|---|---|---|
| SOH(Start of Header) | block no | 255-(block no) | data packet | checksum |
For example , It takes points to send a document 5 block (block), that block no It's from 1 To 5, And suppose this 5 The packets of the block are d1~d5, that checksum=sum(d1+d2+d3+d4+d5)/256 , here / It's a mold .
How does the receiver know whether a block is the last one ?
Take the above example , In the 5 After the block is sent , Then a message will be sent EOT(End of Transmission) Mark characters , This character is sent as a single byte .
Transmission process

CRC The way
Package structure
| byte1 | byte2 | byte3 | bytes 4~131=128bytes | bytes132~133 |
|---|---|---|---|---|
| SOH | block no | 255-(block no) | data packet | CRC-16 |
CRC In the original way checksum On the basis of , Updated from one byte to two bytes CRC, be relative to checksum More secure .CRC Cyclic redundancy check also belongs to a kind of checksum , But in the strict sense, it does not belong to and But to except
Xmodem-1K
Package structure
| byte1 | byte2 | byte3 | bytes 4~1027=1024bytes | bytes1028~1029 |
|---|---|---|---|---|
| STX | block no | 255-(block no) | data packet | CRC-16 |
Xmodem-1K Essentially, Xmodem-CRC, It's just data packet Increase the length to 1024bytes(1K), Then the first 1 Bytes by SOH Updated to STX. In other systems and BBS It is also called Ymodem,XMODEM-1K Initially Chuck Forsberg In its YMODEM In the agreement XMODEM One of the many improvements made . Forsberg Suggest , Various improvements are optional , It is hoped that software authors can achieve as many improvements as possible . contrary , They usually only meet the minimum requirements , This leads to a large number of semi compatible implementations , And finally from the name “ YMODEM” Split into “ XMODEM-1K” And all kinds of YMODEM.
Ymodem
Ymodem yes Chuck Forsberg Yes Xmodem Improvement , but Ymodem Is named by Xmodem The original author of Ward Christensen give .Ymodem Essentially, Xmodem-1K, It allows you to work in the same conversation (session) Multiple files are transferred simultaneously in . On some systems , It's listed as Ymodem Batch.
Package structure
Ymodem stay Xmodem Develop on the basis of , Continue to use TeLink The method of adding short blocks to the protocol , That is to say, increase block 0. The block Identifies the of the file to be sent file name , file size and File creation timestamp , as follows :
| byte1 | byte2 | byte3 | bytes 4~131=128bytes | bytes132~133 |
|---|---|---|---|---|
| SOH | 0x00 | 0xFF | file name file size Time stamp | CRC-16 |
Ymodem Of block n structure ( Not the second 0 block ), data packet It can be either 128 It can also be 1024 position , Can be controlled by command
| byte1 | byte2 | byte3 | bytes 4~131=128bytes | bytes132~133 |
|---|---|---|---|---|
| SOH | block no | 255-(block no) | data packet | CRC-16 |
| byte1 | byte2 | byte3 | bytes 4~1027=1024bytes | bytes1028~1029 |
|---|---|---|---|---|
| STX | block no | 255-(block no) | data packet | CRC-16 |
Transmission process
Ymodem Allow in the same session (session) Simultaneous transfer of multiple files within , The following shows the transfer process by taking multiple files as an example , A single file is similar to .
With 128 Bit transfer

With 1K transmission

Ymodem-g
YMODEM-g yes Ymodem A variation of the , It's a streaming protocol , Send and receive as a continuous stream 1K Data packets , Until it indicates the need to stop . Before sending the next packet , It doesn't have to wait to receive ACK. The agreement ratio YMODEM faster , Because no delay is introduced between packets , But there is no ability to correct mistakes . If any block transfer fails , Cancel the transfer of the entire file .
Zmodem
As the network speeds up , Existing x/ymodem The speed of the agreement has not kept pace with the times .Zmodem emerge as the times require , It uses a window sliding mechanism ,Zmodem There are two most important characteristics : Efficient , Provides crash recovery .
Efficient
As long as the receiver does not find any errors, the sender is allowed to send packets continuously , No need The sender receive The receiving party Of ACK Mark ( Because there may be delays or errors ). The number of packets allowed to be sent continuously is called window , In most Zmodem In the implementation protocol of 2~16 Number of packages .
Crash recovery
If Zmodem The transmission is cancelled or interfered with for some reason , The transmission can be resumed later , And there is no need to resend the previous content .
Reference resources
http://web.cecs.pdx.edu/~rootd/catdoc/guide/TheGuide_226.html#SEC237
https://en.wikipedia.org/wiki/XMODEM
https://en.wikipedia.org/wiki/YMODEM
https://en.wikipedia.org/wiki/ZMODEM
边栏推荐
- Halcon 用点来拟合平面
- The relation between virtual function and pure virtual function
- [go] Viper reads the configuration file in the go project
- [gpio] how to modify / display GPIO status through ADB shell
- 16. 最接近的三数之和
- Why should state-owned enterprises go public
- 49. ugly number
- Introduction to redis cluster
- Test work summary - performance test indicators
- Test work summary - performance test related issues
猜你喜欢
随机推荐
Halcon 3D 1 Reading 3D data
RTMP streaming +rtmp playback low delay solution in unity environment
Flex/fixed upper, middle and lower (mobile end)
A solution for PHP to implement image login verification code
38. appearance series
C language - how to define arrays
[speech] how to customize ring back tone according to different countries
China's alternative sports equipment market trend report, technology dynamic innovation and market forecast
Performance & interface test tool - JMeter
Deep understanding of asynchronous programming
【js小知识】轻松了解js防抖与节流
49. ugly number
What is the difference between ArrayList and LinkedList?
How does WiFi 802.11 correspond to 802.3
Heap classical problem
March 22, 2021
Role and understanding of proc/cmdline
Individual application for ov type SSL certificate
深入理解异步编程
Performance test - performance test tool analysis








