Synchronet v3.19b-Win32 (install) has been released (Jan-2022).

You can donate to the Synchronet project using PayPal.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ref:zmodem [2010/02/25 14:12] – created, imported Jacques Mattheij's ZMODEM.DOC digitalmanref:zmodem [2021/06/29 15:34] (current) – [ZFILE FRAME FILE INFORMATION SUBPACKET] footnote about path/file names with spaces (they are in fact supported in most ZMODEM implemenations) digital man
Line 1: Line 1:
-====== Zmodem ======+====== ZMODEM ======
  
 zmodem.doc !copyrighted by MCS 1994 use it anyway you like but don't complain zmodem.doc !copyrighted by MCS 1994 use it anyway you like but don't complain
Line 35: Line 35:
 a typical (simple) zmodem file transfer looks like this : a typical (simple) zmodem file transfer looks like this :
  
-<file> +^sender                 ^receiver^ 
-sender                  receiver +|ZRQINIT(0)             |        | 
- +|         |ZRINIT  | 
-ZRQINIT(0) +|ZFILE                         | 
-         ZRINIT +| |ZRPOS   | 
-ZFILE +|ZDATA data ...         |        | 
- ZRPOS +|ZEOF                   |        | 
-ZDATA data ... +|         |ZRINIT  | 
-ZEOF +|ZFIN                   |        |  
-         ZRINIT +|         |ZFIN    | 
-ZFIN +|OO                     |        |
-         ZFIN +
-OO +
-</file> +
  
 zmodem continuously transmits data unless the receiver interrupts zmodem continuously transmits data unless the receiver interrupts
Line 66: Line 63:
  
 zmodem places no constraints on the content files. zmodem places no constraints on the content files.
 +
 +===== FRAMING =====
 +
 +==== ZMODEM Frame ====
 +There are 2 classes of ZMODEM Frames:
 +  - Hexadecimal (HEX) frames, containing only US-ASCII characters
 +  - Binary (BIN16 or BIN32) frames, containing //almost// all possible octet values
 +
 +=== HEX Frame ===
 +  <frame header> [CR] LF [XON]
 +
 +HEX frames are terminated with an ASCII linefeed character. Some ZMODEM implementations send the HEX frame terminating linefeed character with the high bit set (0x8A, that's ASCII-LF with an even-parity bit set). Also, for some HEX frame types, the frame terminator may be followed by an XON (0x11) character ("transmit on" in so-called "software flow control").
 +
 +=== Binary Frame ===
 +  <frame header> [[<* data subpacket> [...]] <ZCRCW | ZCRCE data subpacket>]
 +  
 +Binary frames may contain zero or more data subpackets (depending on the frame type). The final subpacket of a binary data frame will be of type ZCRCW or ZCRCE.
 +
 +==== Frame Header ====
 +  <frame encoding> <frame type> <frame info> <checksum>
 +
 +**Frame Encoding** (single byte):
 +
 +The //Frame Encoding// is also sometimes called the "Frame Style".
 +
 +^ Style  ^  AKA   ^ Value          ^ Frame Contents                       ^ Checksum   ^
 +| HEX    | ZHEX   | ASCII '''B'''  | Hexadecimal/US-ASCII characters only | 16-bit CRC |
 +| BIN16  | ZBIN   | ASCII '''A'''  | Binary                               | 16-bit CRC |
 +| BIN32  | ZBIN32 | ASCII '''C'''  | Binary                               | 32-bit CRC |
 +
 +Notes:
 +  * All frames sent by the "receiver" must use HEX encoding. 
 +
 +**Frame Type** (single byte):
 +
 +^ Type     ^ Value ^ TX((from sender))^ RX((from receiver)) ^ Info    ^ Data Subpkt    ^ Notes ^
 +| ZRQINIT  | 0x00  |  Y                -                  | caps    | -              | Request ZRINIT from the receiver |
 +| ZRINIT   | 0x01  |  -                Y                  | caps    | -              | Receiver Initialized |
 +| ZSINIT   | 0x02  |  Y                -                  | flags   | Attn sequence  | Sender Initialized |
 +| ZACK     | 0x03  |  Y                Y                  | offset  | -              | Positive Acknowledgment |
 +| ZFILE    | 0x04  |  Y                -                  | options | File metadata  | File information (name/len/date) |
 +| ZSKIP    | 0x05  |  -                Y                  |         | -              | Skip (don't send) this file |
 +| ZNAK     | 0x06  |  Y                Y                  |         | -              | Negative Acknowledgment |
 +| ZABORT   | 0x07  |  -                Y                  |         | -              | Terminate batch file transfer |
 +| ZFIN     | 0x08  |  Y                -                  |         | -              | Terminate transfer session |
 +| ZRPOS    | 0x09  |  -                Y                  | offset  | -              | Reposition the send offset |
 +| ZDATA    | 0x0A  |  Y                -                  | offset  | File contents  | One or more data subpackets follow |
 +| ZEOF     | 0x0B  |  Y                -                  | offset  | -              | End of file reached |
 +| ZFERROR  | 0x0C  |  -                Y                  |         | -              | File I/O error |
 +| ZCRC     | 0x0D  |  Y                Y                  | CRC-32  | -              | File CRC request/response |
 +| ZFREECNT | 0x11  |  Y                -                  | f-space | -              | Request free disk space |
 +
 +**Frame Info**: Up to 15 bytes (but typically 4) of frame type-specific information.\\
 +Note that later claims of //16// bytes of possible frame header data include the //Frame Type// byte.
 +
 +**Frame Header Integrity**: The //Frame Type// and //Frame Info// are integrity-protected with either a 16-bit or 32-bit CRC (determined by the frame encoding).
 +
 +==== Data Subpacket ====
 +  <data> ZDLE <subpacket type> <crc>
 +
 +**ZDLE** is the ZMODEM Data-link-escape character (''^X'', ASCII 24).
 +
 +=== Data Subpacket Length ===
 +
 +  * Data Subpackets may contain up to **1024** bytes of //data// (special octet values are transposed and escaped with //ZDLE//)
 +  * The Data Subpacket Length is also sometimes referred to as the transmit "block size"
 +  * The Data Subpacket Length can be dynamically adjusted by the sender during the transfer of a file, e.g. in response to errors reported by the receiver
 +  * Some ZMODEM implementations (e.g. "ZedZap") support a Data Subpacket Length of up to 8K (8192 bytes)
 +
 +=== Data Subpacket Types ===
 +The Data Subpacket Type is encoded in a single byte.
 +
 +^ Type  ^ ZACK/ZRPOS expected ^ End-of-Frame ^ Meaning    ^ Notes ^
 +| ZCRCW | Yes (synchronous)   | Yes          | Wait or Write | "ZCRCW data subpackets expect a response before the next frame is sent ... to allow the receiver to write its buffer before sending more data"      |
 +| ZCRCE | Only errors         | Yes          | End        | "If the end of file is encountered within a frame, the frame is closed with a ZCRCE data subpacket which does not elicit a response except in case of error"     |
 +| ZCRCQ | Yes (asynchronous)  | No           | Query      | "ZCRCQ subpackets are not used if the receiver does not indicate full duplex ability with the [ZRINIT] CANFDX bit" |
 +| ZCRCG | Only errors         | No           | Go         | "ZCRCG subpackets do not elicit a response unless an error is detected"      |
 +
 +=== Data Subpacket Integrity ===  
 +The Subpacket //data// and //type// bytes are integrity-protected by either a 16-bit or 32-bit CRC.
  
 ===== LINK ESCAPE ENCODING ===== ===== LINK ESCAPE ENCODING =====
Line 604: Line 681:
 The pathname (conventionally, the file name) is sent as a The pathname (conventionally, the file name) is sent as a
 null terminated ASCII string.  null terminated ASCII string. 
-No spaces are included in the pathname. +No spaces are included in the pathname. ((some ZMODEM implementations support path/file names that include spaces))
  
 Filename Considerations Filename Considerations
Line 777: Line 854:
  
 ==== ASCII ==== ==== ASCII ====
- +<code c> 
-  SOH 0x01 +SOH 0x01 
-  STX 0x02 +STX 0x02 
-  EOT 0x04 +EOT 0x04 
-  ENQ 0x05 +ENQ 0x05 
-  ACK 0x06 +ACK 0x06 
-  LF 0x0a +LF 0x0a 
-  CR 0x0d +CR 0x0d 
-  XON 0x11 +XON 0x11 
-  XOFF         0x13 +XOFF 0x13 
-  NAK 0x15 +NAK 0x15 
-  CAN 0x18 +CAN 0x18 
 +</code>
 ==== ZMODEM ==== ==== ZMODEM ====
  
  
-  ZPAD 0x2a /* pad character; begins frames */ +<code c> 
-  ZDLE 0x18 /* ctrl-x zmodem escape */ +ZPAD 0x2a /* pad character; begins frames */ 
-  ZDLEE 0x58 /* escaped ZDLE */ +ZDLE 0x18 /* ctrl-x zmodem escape */ 
 +ZDLEE 0x58 /* escaped ZDLE */
  
-  ZBIN 0x41 /* binary frame indicator (CRC16) */ +ZBIN 0x41 /* binary frame indicator (CRC16) */ 
-  ZHEX 0x42 /* hex frame indicator */ +ZHEX 0x42 /* hex frame indicator */ 
-  ZBIN32 0x43 /* binary frame indicator (CRC32) */ +ZBIN32         0x43 /* binary frame indicator (CRC32) */ 
-  ZBINR32 0x44 /* run length encoded binary frame (CRC32) */+ZBINR32         0x44 /* run length encoded binary frame (CRC32) */
  
-  ZVBIN 0x61 /* binary frame indicator (CRC16) */ +ZVBIN 0x61 /* binary frame indicator (CRC16) */ 
-  ZVHEX 0x62 /* hex frame indicator */ +ZVHEX 0x62 /* hex frame indicator */ 
-  ZVBIN32 0x63 /* binary frame indicator (CRC32) */ +ZVBIN32 0x63 /* binary frame indicator (CRC32) */ 
-  ZVBINR32 0x64 /* run length encoded binary frame (CRC32) */+ZVBINR32 0x64 /* run length encoded binary frame (CRC32) */
  
-  ZRESC 0x7e /* run length encoding flag / escape character */+ZRESC 0x7e /* run length encoding flag / escape character */ 
 +</code>
  
 ==== FRAME TYPES ==== ==== FRAME TYPES ====
  
-  ZRQINIT 0x00 /* request receive init (s->r) */ +<code c> 
-  ZRINIT 0x01 /* receive init (r->s) */ +ZRQINIT         0x00 /* request receive init (s->r) */ 
-  ZSINIT 0x02 /* send init sequence (optional) (s->r) */ +ZRINIT         0x01 /* receive init (r->s) */ 
-  ZACK 0x03 /* ack to ZRQINIT ZRINIT or ZSINIT (s<->r) */ +ZSINIT         0x02 /* send init sequence (optional) (s->r) */ 
-  ZFILE 0x04 /* file name (s->r) */ +ZACK 0x03 /* ack to ZRQINIT ZRINIT or ZSINIT (s<->r) */ 
-  ZSKIP 0x05 /* skip this file (r->s) */ +ZFILE 0x04 /* file name (s->r) */ 
-  ZNAK 0x06 /* last packet was corrupted (?) */ +ZSKIP 0x05 /* skip this file (r->s) */ 
-  ZABORT 0x07 /* abort batch transfers (?) */ +ZNAK 0x06 /* last packet was corrupted (?) */ 
-  ZFIN 0x08 /* finish session (s<->r) */ +ZABORT         0x07 /* abort batch transfers (?) */ 
-  ZRPOS 0x09 /* resume data transmission here (r->s) */ +ZFIN 0x08 /* finish session (s<->r) */ 
-  ZDATA 0x0a /* data packet(s) follow (s->r) */ +ZRPOS 0x09 /* resume data transmission here (r->s) */ 
-  ZEOF 0x0b /* end of file reached (s->r) */ +ZDATA 0x0a /* data packet(s) follow (s->r) */ 
-  ZFERR 0x0c /* fatal read or write error detected (?) */ +ZEOF 0x0b /* end of file reached (s->r) */ 
-  ZCRC 0x0d /* request for file CRC and response (?) */ +ZFERR 0x0c /* fatal read or write error detected (?) */ 
-  ZCHALLENGE 0x0e /* security challenge (r->s) */ +ZCRC 0x0d /* request for file CRC and response (?) */ 
-  ZCOMPL 0x0f /* request is complete (?) */  +ZCHALLENGE 0x0e /* security challenge (r->s) */ 
-  ZCAN 0x10 /* pseudo frame;  +ZCOMPL         0x0f /* request is complete (?) */  
-    other end cancelled session with 5* CAN */ +ZCAN 0x10 /* pseudo frame; other end cancelled session with 5* CAN */ 
-  ZFREECNT 0x11 /* request free bytes on file system (s->r) */ +ZFREECNT 0x11 /* request free bytes on file system (s->r) */ 
-  ZCOMMAND 0x12 /* issue command (s->r) */ +ZCOMMAND 0x12 /* issue command (s->r) */ 
-  ZSTDERR 0x13 /* output data to stderr (??) */+ZSTDERR 0x13 /* output data to stderr (??) */ 
 +</code>
  
 ==== ZDLE SEQUENCES ==== ==== ZDLE SEQUENCES ====
  
-  ZCRCE 0x68 /* CRC next, frame ends, header packet follows */ +<code c> 
-  ZCRCG 0x69 /* CRC next, frame continues nonstop */ +ZCRCE 0x68 /* CRC next, frame ends, header packet follows */ 
-  ZCRCQ 0x6a /* CRC next, frame continuous, ZACK expected */ +ZCRCG 0x69 /* CRC next, frame continues nonstop */ 
-  ZCRCW 0x6b /* CRC next, ZACK expected, end of frame */ +ZCRCQ 0x6a /* CRC next, frame continuous, ZACK expected */ 
-  ZRUB0 0x6c /* translate to rubout 0x7f */ +ZCRCW 0x6b /* CRC next, ZACK expected, end of frame */ 
-  ZRUB1 0x6d /* translate to rubout 0xff */+ZRUB0 0x6c /* translate to rubout 0x7f */ 
 +ZRUB1 0x6d /* translate to rubout 0xff */ 
 +</code>
  
 ==== RECEIVER CAPABILITY FLAGS ==== ==== RECEIVER CAPABILITY FLAGS ====
  
-  CANFDX 0x01 /* Rx can send and receive true full duplex */ +<code c> 
-  CANOVIO 0x02 /* Rx can receive data during disk I/O */ +CANFDX 0x01 /* Rx can send and receive true full duplex */ 
-  CANBRK 0x04 /* Rx can send a break signal */ +CANOVIO 0x02 /* Rx can receive data during disk I/O */ 
-  CANCRY 0x08 /* Receiver can decrypt */ +CANBRK 0x04 /* Rx can send a break signal */ 
-  CANLZW 0x10 /* Receiver can uncompress */ +CANCRY 0x08 /* Receiver can decrypt */ 
-  CANFC32 0x20 /* Receiver can use 32 bit Frame Check */ +CANLZW 0x10 /* Receiver can uncompress */ 
-  ESCCTL 0x40 /* Receiver expects ctl chars to be escaped +CANFC32 0x20 /* Receiver can use 32 bit Frame Check */ 
-  ESC8 0x80 /* Receiver expects 8th bit to be escaped */ +ESCCTL 0x40 /* Receiver expects ctl chars to be escaped */ 
 +ESC8 0x80 /* Receiver expects 8th bit to be escaped */ 
 +</code>
  
 ===== See Also ===== ===== See Also =====
-  * [[:util:sexyz]]+  * [[util:sexyz]]
   * [[:ref:|Reference Library]]   * [[:ref:|Reference Library]]
  
 {{tag>zmodem}} {{tag>zmodem}}