ZMODEM.DOC 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056
  1. The ZMODEM Asynchronous Inter Application File Transfer Protocol
  2. Chuck Forsberg
  3. Omen Technology Inc
  4. Chuck Forsberg
  5. Omen Technology Inc
  6. 17505-V Northwest Sauvie Island Road
  7. Portland Oregon 97231
  8. Voice: 503-621-3406
  9. Modem (Telegodzilla): 503-621-3746 Speed 1200,300
  10. Compuserve: 70715,131
  11. UUCP: ...!tektronix!reed!omen!caf
  12. Chapter 0 rev051486 Printed 5-16-86 1
  13. Chapter 0 rev051486 Printed 5-16-86 2
  14. 1. INTENDED AUDIENCE
  15. This document is intended for systems programmers and other technically
  16. qualified people who choose and implement asynchronous file transfer
  17. protocols over dial-up networks and related environments.
  18. 2. ACKNOWLEDGMENTS
  19. Encouragement and suggestions by Stuart Mathison, Thomas Buck, John Wales,
  20. Ward Christensen, and Irv Hoff are gratefully acknowledged.
  21. 3. RELATED DOCUMENTS
  22. The following files should be available for reference while studying this
  23. document:
  24. YMODEM.DOC Describes the XMODEM and YMODEM file transfer protocols
  25. ZMODEM.H Provides definitions for the manifest constants referenced
  26. herein.
  27. rz.c, sz.c, rbsb.c Unix source code for operating ZMODEM programs.
  28. rz.1, sz.1 Manual pages for rz and sz.
  29. zm.c, zmodem.h Operating system independent ZMODEM subroutines, header
  30. file.
  31. 4. ROSETTA STONE
  32. Here are some definitions which reflect the current vernacular in the
  33. computer media. The attempt here is identify the file transfer protocol
  34. rather than specific programs.
  35. Frame A ZMODEM frame consists of a header packet and 0 or more data
  36. packets.
  37. XMODEM refers to the original 1979 file transfer etiquette introduced by
  38. Ward Christensen's 1979 MODEM2 program. It's also called the
  39. MODEM or MODEM2 protocol. Some who are unaware of MODEM7's
  40. unusual batch file mode call it MODEM7. Other aliases include
  41. "CP/M Users's Group" and "TERM II FTP 3". This protocol is
  42. supported by every serious communications program because of its
  43. universality, simplicity, and reasonable performance.
  44. XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
  45. Redundancy Check (CRC-16), giving modern error detection
  46. protection.
  47. Chapter 4 rev051486 Printed 5-16-86 2
  48. Chapter 4 rev051486 Printed 5-16-86 3
  49. YMODEM refers to the XMODEM/CRC protocol with the throughput and/or batch
  50. transmission enhancements described in YMODEM.DOC.
  51. ZMODEM Zmodem is a second generation streaming protocol for text and
  52. binary file transmission between applications running on
  53. microcomputers and mainframes.
  54. 5. WHY DEVELOP ZMODEM?
  55. Since its development half a decade ago, the Ward Christensen MODEM
  56. protocol has enabled a wide variety of computer systems to interchange
  57. data. There is hardly a communications program that doesn't at least
  58. claim to support this protocol, now called XMODEM.
  59. Advances in computing, modems and networking have spread the XMODEM
  60. protocol far beyond the micro to micro environment for which it was
  61. designed. These application have exposed some weaknesses:
  62. + The user interface is suitable for computer hobbyists. Three or four
  63. commands must be keyboarded to transfer each file.
  64. + The short block length causes throughput to suffer when used with
  65. timesharing systems, packet switched networks, satellite circuits,
  66. and buffered (error correcting) modems.
  67. + The 8 bit checksum and unprotected transactions allow undetected
  68. errors and disrupted file transfers.
  69. + Only one file can be sent per command. The file name has to be given
  70. twice, first to the sending program and then again to the receiving
  71. program.
  72. + The transmitted file accumulates as many as 127 extraneous bytes.
  73. + The modification date and other file attributes are lost.
  74. + XMODEM requires complete 8 bit transparency, all 256 codes. XMODEM
  75. will not operate over some networks that need flow control.
  76. A number of other protocols have been developed over the years, but none
  77. have displaced XMODEM to date.
  78. + Lack of public domain documentation and example programs have kept
  79. proprietary protocols such as MNP, Blast, and others tightly bound to
  80. the fortunes of their suppliers.
  81. + Hardware and/or software complexity discourages the widespread
  82. application of BISYNC, SDLC, HDLC, X.25, and X.PC protocols.
  83. Chapter 5 rev051486 Printed 5-16-86 3
  84. Chapter 5 rev051486 Printed 5-16-86 4
  85. + Link level protocols such as X.25, X.PC, and MNP do not manage
  86. application to application file transfers.
  87. + The Kermit protocol was developed to allow file transfers in
  88. environments hostile to XMODEM. The performance compromises
  89. necessary to accomodate non transparent environments limit Kermit's
  90. efficiency. Even with completely transparent channels, Kermit
  91. control character quoting limits the efficiency of binary file
  92. transfers to about 75 per cent.[1]
  93. Kermit Sliding Windows ("SuperKermit") improves throughput over
  94. networks at the cost of increased complexity. SuperKermit state
  95. transitions are encoded in a special language "wart" which requires a
  96. C compiler. The SuperKermit C code requires full duplex
  97. communications and the ability to check for the presence of
  98. characters in the input queue, precluding its implementation on some
  99. operating systems.
  100. A number of submodes are used in various Kermit programs, including
  101. different methods of transferring binary files. Two Kermit programs
  102. will mysteriously fail to operate with each other if these submodes
  103. are not matched.
  104. A number of extensions to the XMODEM protocol have been made under the
  105. collective name YMODEM.
  106. + YMODEM-k uses 1024 byte blocks to reduce the overhead from transmission
  107. delays by 87 per cent compared to XMODEM, but network delays can still
  108. degrade performance. Some networks may not be transmit the 1024 byte
  109. packets unmodified.
  110. + The handling of files that are not a multiple of 1024 or 128 bytes is
  111. awkward, especially if the file length is not known, or changes during
  112. transmission.
  113. + YMODEM-g provides efficient batch file transfers, preserving the exact
  114. file length and file modification date. YMODEM-g is essentially
  115. insensitive to network delays. Because it does not support error
  116. recovery, YMODEM-g is usually used hardwired or with a reliable link
  117. level protocol. IF YMODEM-g detects a CRC error, data transfers are
  118. aborted. YMODEM-g is easy to implement because it closely resembles
  119. XMODEM-CRC.
  120. Another XMODEM "extension" is protocol cheating, referred to as "Turbo
  121. Download" and OverThruster. [2] These sometimes improve XMODEM throughput
  122. __________
  123. 1. Some Kermit programs support run length encoding.
  124. Chapter 5 rev051486 Printed 5-16-86 4
  125. Chapter 5 rev051486 Printed 5-16-86 5
  126. at the expense of error recovery.
  127. The ZMODEM Protocol is proposed as a means of addressing the weaknesses
  128. described above while maintaining as much of XMODEM's simplicity and prior
  129. art as possible.
  130. 6. ZMODEM Protocol Design Criteria
  131. The design of a file transfer protocol is an engineering compromise
  132. between conflicting requirements:
  133. 6.1 Ease of Use
  134. + ZMODEM allows either program to initiate file transfers, passing
  135. commands and/or modifiers to the other program.
  136. + File names need be entered only once, menu selections are possible.
  137. + Wild Card names may be used with batch transfers.
  138. + Minimum keystrokes required to initiate transfers.
  139. + ZRQINIT packet sent by sending program can trigger automatic downloads.
  140. + ZMODEM can step down to YMODEM if the other end does not support
  141. ZMODEM.[1]
  142. 6.2 Throughput
  143. ZMODEM is designed for optimum performance with minimum degradation caused
  144. by delays introduced by packet switched networks and timesharing systems.
  145. ZMODEM is optimized for best throughput when line hits occur infrequently.
  146. This assumption markedly reduces code complexity and memory requirements.
  147. ZMODEM protocol features enhance rapid error recovery compared to network
  148. compatible XMODEM implementations.
  149. It is assumed that many transfers will originate from a timesharing system
  150. connected to a packet switched network. ZMODEM provides features to allow
  151. for simple, efficient implementation on timesharing hosts.
  152. __________________________________________________________________________
  153. 2. Omen Technology Trademark
  154. 1. Provided the transmission medium accomodates YMODEM.
  155. Chapter 6 rev051486 Printed 5-16-86 5
  156. Chapter 6 rev051486 Printed 5-16-86 6
  157. File transfers begin immediately regardless of which program is started
  158. first, without the 10 second delay associated with XMODEM.
  159. 6.3 Integrity and Robustness
  160. All packets are protected with 16 bit CRC. Proprietary alogrithyms[2] are
  161. not needed for reliable transfers.
  162. A security challenge guards againgst Trojan Horse messages.
  163. 6.4 Ease of Implementation
  164. ZMODEM accomodates a wide variety of systems:
  165. + Microcomputers that cannot overlap disk and serial i/o
  166. + Microcomputers that cannot overlap serial send and receive
  167. + Computers and/or networks requiring XON/XOFF flow control
  168. + Computers that cannot check the serial input queue for the presence of
  169. data without having to wait for the data to arrive.
  170. Although ZMODEM provides "hooks" for multiple "threads", ZMODEM is not
  171. intended to replace link level protocols such as X.25.
  172. ZMODEM accomodates network and timesharing system delays by continuously
  173. transmitting data unless the receiver interrupts the sender to request
  174. retransmission of garbled data. ZMODEM in effect uses the entire file as
  175. a window.[3]
  176. ZMODEM provides a general purpose application to application file transfer
  177. protocol which may be used directly or with with reliable link level
  178. protocols such as X.25, MNP, Fastlink, etc.
  179. 7. ZMODEM BASICS
  180. __________
  181. 2. Unique to Professional-YAM, PowerCom, etc.
  182. 3. Streaming strategey is discussed in a coming chapter.
  183. Chapter 7 rev051486 Printed 5-16-86 6
  184. Chapter 7 rev051486 Printed 5-16-86 7
  185. 7.1 Packetization
  186. ZMODEM frames somewhat different from X/YMODEM blocks. X/YMODEM blocks
  187. are not used for the following reasons:
  188. + Block numbers are limited to 256
  189. + No provision for variable length blocks
  190. + Line hits corrupt protocol signals, causing failed file transfers. In
  191. particular, modem errors sometimes generate false block numbers, false
  192. EOTs and false ACKs. False ACKs are the most troublesome as they cause
  193. the sender to lose synchronization with the receiver.
  194. State of the art X/YMODEM programs such as Professional-YAM and
  195. PowerCom overcome some of these weaknesses with clever proprietary
  196. code, but a stronger protocol is desired.
  197. + It is difficult to determine the beginning and ends of X/YMODEM blocks
  198. when line hits cause a loss of synchronization. This precludes rapid
  199. error recovery.
  200. 7.2 Link Escape Encoding
  201. ZMODEM acheives data transparency by extending the 8 bit character set
  202. (256 codes) with escape sequences based on the ZMODEM data link escape
  203. character ZDLE.[1]
  204. Link Escape coding permits variable length data packets without the
  205. overhead of a separate byte count. It allows the beginning of frames to
  206. be detected without special timing techniques, facilitating rapid error
  207. recovery.
  208. Link Escape coding does add some overhead. The worst case, a file
  209. consisting entirely of ZDLE characters, would incur a 50% overhead.
  210. The ZDLE character is special. ZDLE represents a control sequence of some
  211. sort. If a ZDLE character appears in the data sent within a binary
  212. packet, it is prefixed with ZDLE, then sent as ZDLEE.
  213. The value for ZDLE is octal 030 (ASCII CAN). This particular value was
  214. chosen to allow a string of CAN characters to abort a ZMODEM session,
  215. compatible with X/YMODEM session abort.
  216. __________
  217. 1. This and other constants are defined in the zmodem.h include file.
  218. Please note that constants with a leading 0 are octal constants in C.
  219. Chapter 7 rev051486 Printed 5-16-86 7
  220. Chapter 7 rev051486 Printed 5-16-86 8
  221. Since CAN is not used for normal terminal operations, communications
  222. programs can monitor the data flow for ZDLE. The following characters can
  223. be scanned to detect the ZRQINIT packet, the invitation to automatically
  224. download commands or files.
  225. Two successive CAN characters will abort a ZMODEM session. Experience
  226. with YMODEM file transfers suggests that this does not impair the
  227. robustness of the protocol. A minimum of 8 CAN are sent, so the ZMODEM
  228. subroutines can be modified to require more successive CAN characters to
  229. signal an abort.
  230. The receiving program will decode any sequence of ZDLE followed by a byte
  231. with bit 6 set and bit 5 reset (upper case letter, either parity) to the
  232. equivalent control character by inverting bit 6. This allows the
  233. transmitter to escape any control character that cannot be sent by the
  234. communications medium. The ZMODEM software currently escapes ZDLE, 021,
  235. 0221, 023, and 0223. In addition, the receiver recognizes escapes for
  236. 0177 and 0377 should these characters need to be escaped.
  237. 7.3 Header Packet Information
  238. All ZMODEM frames begin with a header packet which may be sent in binary
  239. or HEX form. ZMODEM uses a single routine to recognize binary and hex
  240. header packets. Either form of the header packet contains the same raw
  241. information:
  242. + A type byte[2] Future extensions to ZMODEM may use the high order bits
  243. of the type byte to indicate thread selection.
  244. + Four bytes of data indicating flags and/or numeric quantities depending
  245. on the packet type
  246. Figure 1. Order of Bytes in Header Packet
  247. TYPE: packet Type
  248. F0: Flags least significant byte
  249. P0: file Position least significant
  250. P3: file Position most significant
  251. TYPE F3 F2 F1 F0
  252. --------------
  253. TYPE P0 P1 P2 P3
  254. __________
  255. 2. The packet types are cardinal numbers beginning with 0 to minimize
  256. state transition table memory requirements.
  257. Chapter 7 rev051486 Printed 5-16-86 8
  258. Chapter 7 rev051486 Printed 5-16-86 9
  259. 7.4 Binary Header Packet
  260. A binary header packet is only sent by the sending program to the
  261. receiving program.
  262. A binary header packet begins with the sequence ZPAD, ZDLE, ZBIN.
  263. The frame type byte is ZDLE encoded.
  264. The four position/flags bytes are ZDLE encoded.
  265. A two byte CRC of the frame type and position/flag bytes is ZDLE encoded.
  266. 0 or more binary data packets will follow depending on the frame type.
  267. The function zsbhdr transmits a binary header packet. The function
  268. zgethdr receives a binary or hex header packet.
  269. Figure 2. Binary Header Packet
  270. * * ZDLE TYPE F3/P0 F2/P1 F1/P2 F0/P3 CRC-1 CRC-2
  271. 7.5 HEX Header Packet
  272. The receiver sends responses in hex header packets. The sender also uses
  273. hex header packets when they are not followed by binary data packets.
  274. Hex encoding is required to support XON/XOFF flow control. The hex header
  275. receiving routine ignores flow control characters.
  276. Use of Kermit style encoding for control and paritied characters was
  277. considered and rejected because of increased possibility of interacting
  278. with some timesharing systems's line edit functions. Use of HEX packets
  279. from the receiving program allows control characters to be used to
  280. interrupt the sender when errors are detected. Except for header packet
  281. types that imply data packets to follow, a HEX header packet may be used
  282. in place of a binary header packet.
  283. A hex header packet begins with the sequence ZPAD, ZPAD, ZDLE, ZHEX. The
  284. zgethdr routine synchronizes in the ZPAD-ZDELE sequence. The extra ZPAD
  285. allows other parts of the program to detect a ZMODEM packet and then call
  286. zgethdr to receive the packet.
  287. The type byte, the four position/flag bytes, and the CRC thereof are sent
  288. in hex using the character set 01234567890abcdef. Upper case hex digits
  289. are not allowed; they false trigger X/YMODEM programs.
  290. A carriage return, line feed, and XON are appended to the HEX header
  291. packet but are not considered to be part of it. The CR/LF aids debugging
  292. from printouts. The XON releases the sender from spurious XOFF flow
  293. control characters generated by line noise, a common occurrence.
  294. Chapter 7 rev051486 Printed 5-16-86 9
  295. Chapter 7 rev051486 Printed 5-16-86 10
  296. 0 or more ASCII Encoded data packets will follow depending on the frame
  297. type.
  298. The function zshhdr sends a hex header packet.
  299. Figure 3. HEX Header Packet
  300. * * ZDLE TYPE F3/P0 F2/P1 F1/P2 F0/P3 CRC-1 CRC-2 CR LF XON
  301. (TYPE, F3...F0, CRC-1, and CRC-2 are each sent as two hex digits.)
  302. 7.6 Binary Data Packets
  303. Binary data packets immediately follow the associated binary header
  304. packet. A binary data packet contains 0 to 1024 bytes of data.
  305. Recommended length values are 256 bytes below 4800 bps, 1024 above 4800
  306. bps or when the data link is known to be relatively error free.
  307. No padding is used with binary data packets. The data bytes are ZDLE
  308. encoded and transmitted. A ZDLE and frameend are then sent, followed by
  309. two ZDLE encoded CRC bytes. The CRC accumulates the data bytes and
  310. frameend.
  311. The function zsbdata sends a binary data packet. The function zrbdata
  312. receives a binary data packet.
  313. 7.7 ASCII Encoded Data Packet
  314. The format of ASCII Encoded data packets is not currently specified.
  315. These would be used for server commands, etc.
  316. 8. PROTOCOL TRANSACTION OVERVIEW
  317. As with the XMODEM recommendation, ZMODEM timing is receiver driven. The
  318. transmitter should not time out at all, except to abort the program if no
  319. packets are received for an extended period of time, say one minute.[1]
  320. To start a ZMODEM file transfer session, the sending program is called
  321. with the names of the desired file(s) and option(s).
  322. The sending program sends the string "rz\r" to invoke the receiving
  323. program from a possible command mode. The "rz" followed by carriage
  324. return activates a ZMODEM receive program or command if it were not
  325. already active.
  326. __________
  327. 1. Special considerations apply when sending commands.
  328. Chapter 8 rev051486 Printed 5-16-86 10
  329. Chapter 8 rev051486 Printed 5-16-86 11
  330. The sender may then display a message intended for human consumption, such
  331. as a list of the files requested, etc.
  332. Then the sender sends a ZRQINIT packet. The ZRQINIT packet causes a
  333. previously started receive program to send its ZRINIT packet without
  334. delay.
  335. In an interactive or conversational mode, the receiving application may
  336. monitor the data stream for ZDLE. The following characters may be scanned
  337. for B000000 indicating a ZRQINIT packet, a command to download a command
  338. or data.
  339. The sending program awaits a command from the receiving program to start
  340. file transfers. If a "C", "G", or NAK is received, an XMODEM or YMODEM
  341. file transfer is indicated, and file transfer(s) use the X/YMODEM
  342. protocol. Note: With ZMODEM and YMODEM Batch, the sending program
  343. provides the file name, but not with XMODEM.
  344. When the ZMODEM receive program starts, it immediately sends a ZRINIT
  345. packet to initiate ZMODEM file transfers, or a ZCHALLENGE packet to verify
  346. the sending program. The receive program resends its packet at repsonse
  347. time intervals for a suitable period of time (40 seconds typical) before
  348. falling back to X/YMODEM protocol. If the receiving program receives a
  349. ZRQINIT packet, it resends the ZRINIT packet. If the sending program
  350. receives the ZCHALLENGE packet, it places the data in ZP0...ZP3 in an
  351. answering ZACK packet.
  352. If the receiving program receives a ZRINIT packet, it is an echo
  353. indicating that the sending program is not operational.
  354. Eventually the sending program correctly receives the ZRINIT packet.
  355. The sender may then respond with an optional ZSINIT frame to set the
  356. receiving program's Attention string. The receiver sends a ZACK packet in
  357. response, containing the serial number of the receiving program, or 0.
  358. The sender then sends a ZFILE header with ZMODEM Conversion, Management,
  359. and Transport options[2] followed by a ZCRCW data packet containing the
  360. file name, file length, modification date, and other information identical
  361. to that used by YMODEM Batch.
  362. The receiving program should insure the pathname and options are
  363. compatible with its operating environment and local security requirements.
  364. __________
  365. 2. See below, under ZFILE packet type.
  366. Chapter 8 rev051486 Printed 5-16-86 11
  367. Chapter 8 rev051486 Printed 5-16-86 12
  368. If the receiver has a file with the same name and length,
  369. it may respond with a ZCRC packet, which requires the
  370. sender to permorm a 16 bit CRC on the file and transmit the
  371. CRC in ZP0...ZP1 of a ZCRC packet. The receiver uses this
  372. information to determine whether to accept the file or skip
  373. it. This sequence is triggered by the ZMCRC Management
  374. Option.
  375. The receiver may then respond with a ZSKIP packet, which causes the
  376. sender to process the next file (if any) in the batch.
  377. A ZRPOS packet from the receiver initiates transmission of the file data
  378. starting at the offset in the file specified in the ZRPOS packet.
  379. Normally the receiver specifies the data transfer begin begin at offset 0
  380. in the file.
  381. The receiver may start the transfer further down in the
  382. file. This allows a file transfer interrupted by a loss
  383. or carrier or system crash to be completed on the next
  384. connection without requiring the entire file to be
  385. retransmitted.[3] If downloading a file from a timesharing
  386. system that becomes sluggish, the transfer can be
  387. interrupted and resumed later with no loss of data.
  388. The sender sends a ZDATA binary header packet (with file position)
  389. followed by one or more data packets.
  390. The receiver compares the file position in the ZDATA header with the
  391. number of characters successfully received to the file. If they do not
  392. agree, a ZRPOS error response is generated to force the sender to the
  393. right position within the file.[4]
  394. A data packet terminated by ZCRCGO and CRC does not elicit a response
  395. unless an error is detected; more data packet(s) follow immediately.
  396. ZCRCQ data packets expect a ZACK response (with the file
  397. offset) if no error, otherwise a ZRPOS response (with the
  398. last good file offset). Another data packet continues
  399. immediately. ZCRCQ packets are not used if the receiver
  400. does not indicate FDX ability with the CANFDX bit.
  401. ZCRCW data packets expect a response before the next frame is sent. If
  402. the receiver does not indicate overlapped I/O capability with the
  403. __________
  404. 3. This does not apply to files that have been translated.
  405. 4. If the ZMSPARS option is used, the receiver instead seeks to position
  406. in the ZDATA packet.
  407. Chapter 8 rev051486 Printed 5-16-86 12
  408. Chapter 8 rev051486 Printed 5-16-86 13
  409. CANOVIO bit, or by setting a buffer size, the sender uses the ZCRCW to
  410. allow the receiver to write its buffer before sending more data.
  411. A zero length data frame may be used as a sending idle
  412. packet to prevent the receiver from timing out in case
  413. data is not immediately available to the sender.
  414. In the absence of fatal error, the sender eventually encounters end of
  415. file. If the end of file is encountered within a frame, the frame is
  416. closed with a ZCRCE data packet which does not elicit a response
  417. except in case of error.
  418. The sender sends a ZEOF packet with the file ending offset equal to
  419. the number of characters in the file. The receiver compares this
  420. number with the number of characters received. If the receiver has
  421. received all of the file, it closes the file. If the file close was
  422. satisfactory, the receiver responds with ZRINIT. If the receiver has
  423. not received all the bytes of the file, the receiver sends ZRPOS with
  424. the current file offset, forcing the sender to resend the missing
  425. data. (If the receiver cannot properly close the file, a ZFERR packet
  426. is sent.)
  427. After all files are processed, any further protocol
  428. errors should not prevent the sending program from
  429. returning with a success status.
  430. The sender closes the session with a ZEXIT header packet. The
  431. receiver acknowledges this with its own ZEXIT packet.
  432. When the sender receives the acknowledging packet, it sends two
  433. characters, "OO" (Over and Out) and exits to the operating system or
  434. application that invoked it. The receiver waits briefly for the "O"
  435. characters, then exits whether they were received or not.
  436. 8.1 Session Cancel Packet
  437. The Cancel packet consists of two ZPAD characters, eight CAN
  438. characters, and an optional ten backspace characters. First, the
  439. Attn sequence is executed if the receiving program has been receiving
  440. data in streaming mode. The ZPAD characters allow sending programs
  441. that sample the reverse data stream to check for a single character
  442. code indicating a packet from the receiver. The trailing backspace
  443. characters attempt to erase the effects of the other characters if
  444. they are received by a command interpreter.
  445. static char canistr[] = {
  446. ZPAD,ZPAD,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8,0 };
  447. Chapter 9 rev051486 Printed 5-16-86 13
  448. Chapter 9 rev051486 Printed 5-16-86 14
  449. 9. ZMODEM STREAMING TECHNIQUES
  450. ZMODEM allows choices of several data streaming methods selected
  451. according to the limitations of the sending environment, receiving
  452. environment, and transmission channel(s).
  453. 9.1 Full Streaming with Sampling
  454. If the computers can overlap serial I/O with disk I/O, and if the
  455. sender can sample the reverse channel for the presence of data
  456. without having to wait, full streaming can be used with no Attn
  457. sequence required. The sender begins data transmission with a ZDATA
  458. header and continuous ZCRCG data packets. When the receiver detects
  459. an error, it executes the Attn sequence and then sends a ZRPOS packet
  460. to force the sender back to the correct position within the file. At
  461. the end of each transmitted packet, the sender checks for the
  462. presence of an error packet from the receiver. To do this, the
  463. sender may sample the reverse data stream for the presence of a ZPAD
  464. character.
  465. Such a program would sample the reverse channel for ZPAD. If seen,
  466. an empty ZCRCW data packet is sent (in case the receiver was still
  467. reading packets) and then the receiver's response packet is read and
  468. acted upon. The code fragment in sz.c beginning at NOTDEF_DOS would
  469. perform this function.
  470. 9.2 Full Streaming with Interrupt
  471. The method above cannot be used if if the reverse data stream cannot
  472. be sampled without entering an I/O wait. An alternate method is to
  473. instruct the receiver to interrupt the sending program when an error
  474. is detected.
  475. The receiver can interrupt the sender with a control character, break
  476. signal, or combination thereof, as specified in the ZSINIT frame sent
  477. by the sending program.
  478. When the sending program "catches" this interrupt, it reads a HEX
  479. packet (normally ZRPOS) from the receiver and takes appropriate
  480. action. The Unix sb.c program uses a setjmp/longjmp call and the
  481. getinsync() function to read the receiver's error packet and take
  482. appropriate action.
  483. Chapter 9 rev051486 Printed 5-16-86 14
  484. Chapter 9 rev051486 Printed 5-16-86 15
  485. 9.3 Full Streaming with a Sliding Window
  486. If none of the above methods is applicable, hope is not yet lost. If
  487. the sender can buffer responses from the receiver, the sender can use
  488. ZCRCQ packets to get ACKs from the receiver without interrupting the
  489. transmission of data. After a sufficient number of ZCRCQ packets
  490. have been sent, the sender can read one of the one or more packets
  491. that should have arrived in it's receive interrupt buffer.
  492. A problem with this method is the probability of wasting an excessive
  493. amount of time responding to the receiver's error packet.
  494. 9.4 No Streaming
  495. If the receiver cannot overlap serial and disk I/O, it uses the
  496. ZRINIT frame to specify a buffer length which the sender will not
  497. overflow. The sending program sends a ZCRCW packet and waits for an
  498. ZACK packet before sending the next segment of the file.
  499. If the sending program supports reverse data stream sampling or
  500. interrupt, error recovery will be faster (on average) than a protocol
  501. (such as YMODEM) that sends "monolithic" blocks.
  502. 10. ATTENTION SEQUENCE
  503. The receiving program sends the Attn sequence whenever it detects an
  504. error and needs to interrupt the sending program.
  505. The default Attn string value is empty (no Attn sequence). The
  506. receiving program resets Attn to the empty default before each
  507. transfer session.
  508. The sender speficies the Attn sequence in its optional ZSINIT frame.
  509. The Attn string is terminated with a null.
  510. Two meta-characters perform special functions:
  511. + \335 (octal) Sends a break signal
  512. + \336 (octal) Pauses one second
  513. 11. PACKET/FRAME TYPES
  514. The numeric values for the values shown in boldface are given in
  515. zmodem.h.
  516. Chapter 11 rev051486 Printed 5-16-86 15
  517. Chapter 11 rev051486 Printed 5-16-86 16
  518. 11.1 ZRQINIT
  519. Sent once by the sending program, to trigger the receiving program to
  520. send its ZRINIT packet. This aviods the aggravatimg startup delay
  521. associated with XMODEM and Kermit transfers.
  522. ZF0 contains ZCOMMAND if the program is attempting to send a command,
  523. 0 otherwise.
  524. 11.2 ZRINIT
  525. Sent by the receiving program. ZF0 and ZF1 contain the bitwise or
  526. of the receiver capability flags:
  527. #define CANFDX 1 /* Rx can send and receive FDX */
  528. #define CANOVIO 2 /* Rx can receive during disk I/O */
  529. #define CANBRK 4 /* Rx can send a break signal */
  530. #define CANCRY 8 /* Receiver can decrypt */
  531. ZP0 and ZP1 contain the size of the receiver's buffer in bytes, or 0
  532. if nonstop I/O is allowed.
  533. 11.3 ZSINIT
  534. Sender sends capability flags (currently all 0) (none currently
  535. defined) followed by a binary data packet terminated with ZCRCW. The
  536. data packet contains the null terminated Attn sequence, maximum
  537. length 32 bytes including the terminating null.
  538. 11.4 ZACK
  539. Acknowedgement to ZSINIT header packet, ZCHALLENGE header packet, or
  540. ZCRCW data packet. ZP0 to ZP3 contain file offset. Response to
  541. ZCHALLENGE contains the same 32 bits as received.
  542. 11.5 ZFILE
  543. This packet denotes the beginning of a file transmission attempt.
  544. ZF0, ZF1, and ZF2 may contain options. A value of 0 in each of these
  545. bytes implies no special treatment. If options are specified to the
  546. reciever, they override options specified to the sender with the
  547. exception of the ZCBIN option, which overrides any other Conversion
  548. Option.
  549. 11.5.1 ZF0: Conversion Option
  550. If the receiver does not recognize the Conversion Option, an
  551. application dependent default conversion may apply.
  552. ZCBIN "Binary" transfer - inhibit conversion unconditionally
  553. Chapter 11 rev051486 Printed 5-16-86 16
  554. Chapter 11 rev051486 Printed 5-16-86 17
  555. ZCNL Convert received end of line to local end of line convention.
  556. The suported end line conventions are CR/LF (most ASCII based
  557. operating systems except Unix and Macintosh), and NL (Unix).
  558. Neither of these two end of line conventions violate the
  559. permissible ASCII definitions for Carriage Return and Line
  560. Feed/New Line.
  561. ZCRECOV Recover interrupted file transfer; start transfer at location
  562. corresponding to the receiver's end of file. This option does
  563. not apply if the source file is shorter. Files that have been
  564. converted (e.g., ZCNL) or subject to a single ended Transport
  565. Option cannot have their transfers recovered.
  566. 11.5.2 ZF1: Management Option
  567. If the receiver does not recognize the Management Option, the file
  568. should be transferred normally.
  569. ZMNEW Compare the source and destination files. Transfer file if
  570. source newer or different length
  571. ZMCRC Compare the source and destination files. Transfer if
  572. different file length or CRC
  573. ZMAPND Append source file contents to existing destination file (if
  574. any)
  575. ZMCLOB Replace existing destination file (if any)
  576. ZTSPARS Special processing for sparse file; each file segment is
  577. transmitted as a separate frame, where the frames are not
  578. necessarily contiguous.
  579. 11.5.3 ZF2: Transport Option
  580. If the receiver does not implement the particular transport option,
  581. the file is copied without conversion for later processing.
  582. ZTLZW Lempel-Ziv compression. Transmitted data will be identical to
  583. that produced by compress 4.0 operating on a computer with VAX
  584. byte ordering, using 12 bit encoding.
  585. ZTCRYPT Encryption. An initial null terminated string identifies the
  586. key. Details to be determined.
  587. ZTRLE Run Length encoding Details to be determined.
  588. A ZCRCW data packet follows with file name, file length, modification
  589. date, and other information described in a later chapter.
  590. Chapter 11 rev051486 Printed 5-16-86 17
  591. Chapter 11 rev051486 Printed 5-16-86 18
  592. 11.6 ZSKIP
  593. Sent by the receiver in response to ZFILE, makes the sender skip to
  594. the next file.
  595. 11.7 ZNAK
  596. Indicates last packet header was garbled. (See also ZRPOS).
  597. 11.8 ZABORT
  598. Sent by receiver to terminate batch file transfers when requested by
  599. the user. Sender initiates a ZFIN sequence.[1]
  600. 11.9 ZFIN
  601. Sent by sending program to terminate a ZMODEM session. Receiver
  602. responds with ZFIN.
  603. 11.10 ZRPOS
  604. Sent by receiver to force file transfer to resume at file offset
  605. given in ZP0...ZP3.
  606. 11.11 ZDATA
  607. ZP0...ZP3 contain file offset. One or more data packets follow.
  608. 11.12 ZEOF
  609. Sender reports End of File. ZP0...ZP3 contain the ending file
  610. offset.
  611. 11.13 ZFERR
  612. Error in reading or writing file, protocol equivalent to ZABORT.
  613. 11.14 ZCRC
  614. Request (receiver) and response (sender) for file CRC. ZP0 and ZP1
  615. contain 16 bit file CRC.
  616. __________
  617. 1. Or ZCOMPL in case of server mode.
  618. Chapter 11 rev051486 Printed 5-16-86 18
  619. Chapter 11 rev051486 Printed 5-16-86 19
  620. 11.15 ZCHALLENGE
  621. Request to echo a random number in ZP0...ZP3 in a ZACK frame. Sent
  622. by the receiving program to the sending program to verify that it is
  623. connected to an operating program, and was not activated by spurious
  624. data or a Trojan Horse message.
  625. 11.16 ZCOMPL
  626. Request now completed.
  627. 11.17 ZCAN
  628. This is a pseudo frame type returned by gethdr() in response to a
  629. Cancel sequence.
  630. 11.18 ZFREECNT
  631. Sending program requests a ZACK frame with ZP0...ZP3 containing the
  632. number of free bytes on the current file system. A value of 0
  633. represents an indefinite amount of free space.
  634. 11.19 ZCOMMAND
  635. ZCOMMAND is only sent as a binary header packet. ZP0...ZP2 contain a
  636. unique cardinal number to differentiate this command from other
  637. commands[2]. ZF0 contains 0 or ZCACK1.
  638. A ZCRCW data packet follows, with the ASCII text command string
  639. terminated with a NULL character. If the command is intended to be
  640. executed by the operating system hosting the receiving program (e.g.,
  641. "shell escape"), it must have "!" as the first character. Otherwise
  642. the command is meant to be executed by the application program which
  643. received the command.
  644. If ZF0 contained ZCACK1, the receiver immediately responds with a
  645. ZCOMPL header. Otherwise, the receiver responds with a ZCOMPL header
  646. when the operation is completed.
  647. The exit status of the completed command is stored in ZP0...ZP3 (0 if
  648. ZCACK1). A 0 exit status implies nominal completion of the command.
  649. If the command caused a file to be transmitted, the command sender
  650. will see a ZRQINIT frame from the other computer attempting to send
  651. __________
  652. 2. Currently unused.
  653. Chapter 11 rev051486 Printed 5-16-86 19
  654. Chapter 11 rev051486 Printed 5-16-86 20
  655. data.
  656. The sender examines ZF0 of the received ZRQINIT packet to determine
  657. it is not an echo of its own ZRQINIT packet. It is illegal for the
  658. sending program to command the receiving program to send a command.
  659. 12. TRANSACTION EXAMPLE
  660. 12.1 A simple file transfer
  661. A simple transaction, one file, no errors, no CHALLENGE, overlapped
  662. I/O:
  663. Sender Receiver
  664. "rz\r"
  665. ZRQINIT(0)
  666. ZRINIT
  667. ZFILE
  668. ZRPOS
  669. ZDATA data ...
  670. ZEOF
  671. ZRINIT
  672. ZFIN
  673. ZFIN
  674. OO
  675. 12.2 Challenge and Command Download
  676. Sender Receiver
  677. "rz\r"
  678. ZRQINIT(ZCOMMAND)
  679. ZCHALLENGE(rnd)
  680. ZACK(same-rnd)
  681. ZRINIT
  682. ZCOMMAND
  683. (Perform Command)
  684. ZCOMPL
  685. ZFIN
  686. ZFIN
  687. OO
  688. Chapter 13 rev051486 Printed 5-16-86 20
  689. Chapter 13 rev051486 Printed 5-16-86 21
  690. 13. ZFILE FRAME FILE INFORMATION
  691. ZMODEM sends the same file information with the ZFILE frame data that
  692. YMODEM Batch sends in its block 0.
  693. N.B.: Only the pathname (file name) part is s required for batch
  694. transfers.
  695. Pathname The pathname (conventionally, the file name) is sent as a
  696. null terminated ASCII string. This is the filename format used
  697. by the handle oriented MSDOS(TM) functions and C library fopen
  698. functions. An assembly language example follows:
  699. DB 'foo.bar',0
  700. No spaces are included in the pathname. Normally only the file
  701. name stem (no directory prefix) is transmitted unless the sender
  702. has selected YAM's f option to send the full relative pathname.
  703. The source drive designator (A:, B:, etc.) is not sent.
  704. Filename Considerations:
  705. + File names should be translated to lower case unless the
  706. sending system supports upper/lower case file names. This
  707. is a convenience for users of systems (such as Unix) which
  708. store filenames in upper and lower case.
  709. + The receiver should accommodate file names in lower and
  710. upper case.
  711. + The rb(1) program on Unix systems normally translates the
  712. filename to lower case unless one or more letters in the
  713. filename are already in lower case.
  714. + When transmitting files between different operating
  715. systems, file names must be acceptable to both the sender
  716. and receiving operating systems.
  717. If directories are included, they are delimited by /; i.e.,
  718. "subdir/foo" is acceptable, "subdir\foo" is not.
  719. Length The file length and each of the succeeding fields are
  720. optional.[1] The length field is stored as a decimal string
  721. counting the number of data bytes in the file.
  722. With ZMODEM, the receiver uses the file length only for display
  723. (progress reporting) purposes; the actual length is determined
  724. __________
  725. 1. Fields may not be skipped.
  726. Chapter 13 rev051486 Printed 5-16-86 21
  727. Chapter 13 rev051486 Printed 5-16-86 22
  728. by the data transfer.
  729. Modification Date A single space separates the modification date from
  730. the file length.
  731. The mod date is optional, and the filename and length may be
  732. sent without requiring the mod date to be sent.
  733. The mod date is sent as an octal number giving the time the
  734. contents of the file were last changed measured in seconds from
  735. Jan 1 1970 Universal Coordinated Time (GMT). A date of 0
  736. implies the modification date is unknown and should be left as
  737. the date the file is received.
  738. This standard format was chosen to eliminate ambiguities arising
  739. from transfers between different time zones.
  740. Two Microsoft blunders complicate the use of modification dates
  741. in file transfers with MSDOS(TM) systems. The first is the lack
  742. of timezone standardization in MS-DOS. A file's creation time
  743. can not be known unless the timezone of the system that wrote
  744. the file[2] is known. Unix solved this problem (for planet
  745. Earth, anyway) by stamping files with Universal Time (GMT).
  746. Microsoft would have to include the timezone of origin in the
  747. directory entries, but does not. Professional-YAM gets around
  748. this problem by using the z parameter which is set to the number
  749. of minutes local time lags GMT. For files known to originate
  750. from a different timezone, the -zT option may be used to specify
  751. T as the timezone for an individual file transfer.
  752. The second problem is the lack of a separate file creation date
  753. in DOS. Since some backup schemes used with DOS rely on the
  754. file creation date to select files to be copied to the archive,
  755. back-dating the file modification date could interfere with the
  756. safety of the transferred files. For this reason,
  757. Professional-YAM does not modify the date of received files with
  758. the header information unless the d parameter is non zero.
  759. Mode A single space separates the file mode from the modification
  760. date. The file mode is stored as an octal string. Unless the
  761. file originated from a Unix system, the file mode is set to 0.
  762. rb(1) checks the file mode for the 0x8000 bit which indicates a
  763. Unix type regular file. Files with the 0x8000 bit set are
  764. assumed to have been sent from another Unix (or similar) system
  765. __________
  766. 2. Not necessarily that of the transmitting system!
  767. Chapter 13 rev051486 Printed 5-16-86 22
  768. Chapter 13 rev051486 Printed 5-16-86 23
  769. which uses the same file conventions. Such files are not
  770. translated in any way.
  771. Serial Number A single space separates the serial number from the
  772. file mode. The serial number of the transmitting program is
  773. stored as an octal string. Programs which do not have a serial
  774. number should omit this field, or set it to 0. The receiver's
  775. use of this field is optional.
  776. The file information is terminated by a null. If only the pathname
  777. is sent, the pathname will be terminated by two nulls. The length of
  778. the file information packet, including the trailing null, must not
  779. exceed 1024 bytes; a typical length is less than 64 bytes.
  780. 14. PERFORMANCE RESULTS
  781. 14.1 Throughput
  782. Between two single task PC-XT computrers, on a Telenet link through
  783. the local Telenet, SuperKermit gave 72 ch/sec throughput at 1200
  784. baud. YMODEM-k yielded 85 chars/sec, and ZMODEM provided 113 chat
  785. sec. ZMODEM was not measured, but would have given much less.
  786. 14.2 Error Recovery
  787. Some tests of ZMODEM protocol performance have been made. A PC-AT
  788. with SCO SYS V Xenix or DOS 3.1 was connected to a PC with DOS 2.1
  789. either directly at 9600 bps or with unbuffered dial-up 1200 bps
  790. modems. The ZMODEM software was configured to use 1024 byte packet
  791. lengths above 2400 bps, 256 otherwise.
  792. Because no time delays are necessary in normal file transfers, per
  793. file negotiations are much faster than with YMODEM, the only observed
  794. impidiment being the time required by the program(s) to update
  795. logging files.
  796. During a file transfer, a short line hit seen by the receiver usually
  797. induces a CRC error. The interrupt packet is usually seen by the
  798. sender before the next packet is sent, and the resultant loss of data
  799. throughput averages about half a packet. At 1200 bps this is would
  800. be about .75 second lost per hit. At 10-5 error rate, this would
  801. degrade throughput by about 9 per cent. The throughput degradation
  802. increases with the channel delay, as the packets in transit through
  803. the channel are discarded on error.
  804. A longer noise burst that affects both the receiver and the sender's
  805. reception of the interrupt packet usually causes the sender to remain
  806. silent until the receiver times out in 10 seconds. If the round trip
  807. channel delay exceeds the receiver's 10 second timeout, recovery from
  808. Chapter 14 rev051486 Printed 5-16-86 23
  809. Chapter 14 rev051486 Printed 5-16-86 24
  810. this type of error may become difficult.
  811. Noise affecting only the sender is usually ignored, with one common
  812. exception. Spurious XOFF characters generated by noise stop the
  813. sender until the receiver times out and sends an interrupt packet
  814. which concludes with an XON.
  815. In summation, ZMODEM performance in the presence of errors resembles
  816. that of X.PC and SuperKermit. Short bursts cause minimuml data loss.
  817. Long bursts (such as pulse dialing noises) often require a timeout
  818. error to restore the flow of data.
  819. 15. PACKET SWITCHED NETWORK CONSIDERATIONS
  820. Flow control is necessary for printing messages and directories, and
  821. for streaming file transfer protocols including Kermit Sliding
  822. Windows and ZMODEM. A non transparent flow control is incompatible
  823. with XMODEM and YMODEM transfers. XMODEM and YMODEM protocols
  824. require complete transparency of all 256 8 bit codes to operate
  825. properly.
  826. The most desireable flow control (when X.25 or hardware CTS is
  827. unavailable) does not "eat" any characters at all. When the PAD's
  828. buffer almost fills up, an XOFF should be emitted. When the buffer
  829. is no longer nearly full, send an XON. Otherwise, the network should
  830. neither generate nor eat XON or XOFF control characters.
  831. On Telenet, this can be met by setting CCIT X3 5:1 and 12:0 at both
  832. ends of the network. For best throughput, parameter 64 (advance ACK)
  833. should be set to something like 4. Packets should be sent when the
  834. packet is a full 128 bytes, or after a moderate delay (3:0,4:10,6:0).
  835. For YMODEM, PAD buffering should guarantee that a minimum of 1040
  836. characters can be sent in a burst without loss of data or generation
  837. of flow control characters. Failure to provide this buffering will
  838. generate excessive retries with YMODEM.
  839. Figure 4. Flow Control Compatibility
  840. Connectivity Interactive XMODEM KERMIT ZMODEM
  841. Direct Connection YES YES YES YES
  842. Network, no flow control NO YES (1) (1)
  843. Network, transparent f.c. YES YES YES YES
  844. Network, semi-transparent f.c. YES NO YES YES
  845. Network, 7 bit YES NO YES(2) NO(3)
  846. (1) Cannot operate in streaming mode. Kermit is very slow because of
  847. 96 byte max packet size. ZMODEM can adjust burst length to maximum
  848. for faster transfers.
  849. Chapter 15 rev051486 Printed 5-16-86 24
  850. Chapter 15 rev051486 Printed 5-16-86 25
  851. (2) Parity bits must be encoded, slowing binary transfers.
  852. (3) Extension possible for encoding data to 7 bits.
  853. 16. PERFORMANCE COMPARISION TABLES
  854. "Round Trip Delay Time" includes the time for the last byte in a
  855. packet to propagate through the operating systems and network to the
  856. receiver, plus the time for the receiver's response to that packet to
  857. propogate back to the sender.
  858. The figures shown below are calculated for round trip delay times of
  859. 40 milliseconds and 5 seconds. Shift registers in the two computers
  860. and a pair of 212 modems generate a round trip delay time on the
  861. order of 40 milliseconds. Operation with busy timesharing computers
  862. and networks can easily generate round trip delays of five seconds.
  863. Because the round trip delays cause visible interruptions of data
  864. transfer when using XMODEM protocol, the subjective effect of these
  865. delays is greatly exaggerated, especially when the user is paying for
  866. connect time.
  867. A 102400 byte binary file with randomly distributed codes is sent at
  868. 1200 bps 8 data bits, 1 stop bit. The calculations assume no
  869. transmission errors. For each of the protocols, only the per file
  870. functions are considered. Processor and I/O overhead are not
  871. included. YM-k refers to YMODEM with 1024 byte packets. YM-g refers
  872. to the YMODEM "g" option. ZMODEM uses 256 byte packets for this
  873. example. SuperKermit uses maximum packet size, 8 bit transparent
  874. transmission, no run length compression.
  875. For comparison, a straight "dump" of the file contents with no file
  876. management or error checking takes 853 seconds.
  877. Figure 5. Protocol Overhead Information
  878. Protocol XMODEM YM-k YM-g ZMODEM S-Kermit
  879. Protocol Round Trips 803 103 5 5 5
  880. Trip Time at 40ms 32s 4s 0 0 0
  881. Trip Time at 5s 4015s 515s 25s 25s 25
  882. Overhead Characters 4803 603 503 3600 38280
  883. Transfer Time at 0s 893s 858s 857s 883s 1172s
  884. Transfer Time at 40ms 925s 862s 857s 883s 1172s
  885. Transfer Time at 5s 5761s 1373s 882s 918s 1197s
  886. Chapter 16 rev051486 Printed 5-16-86 25
  887. Chapter 16 rev051486 Printed 5-16-86 26
  888. Figure 6. Transmission Time Comparision
  889. (5 Second Round Trip)
  890. ************************************************** XMODEM
  891. ************ YMODEM-K
  892. ********** SuperKermit (Sliding Windows)
  893. ******* YMODEM-G
  894. ******* ZMODEM
  895. Figure 7. Y/ZMODEM Header Information usage
  896. Program Batch Length Date Mode S/N YMODEM-g ZMODEM
  897. Unix rb/sb yes yes yes yes no sb only no
  898. Unix rz/sz yes yes yes yes no sz only yes
  899. VMS rb/sb yes yes no no no no no
  900. Pro-YAM yes yes yes no yes yes yes
  901. CP/M YAM yes no no no no no no
  902. KMD/IMP yes yes- no no no no no
  903. MEX no no no no no no no
  904. 17. MORE INFORMATION
  905. More information may be obtained by calling Telegodzilla at
  906. 503-621-3746.
  907. UUCP sites can obtain the nroff/troff source to this file with
  908. uucp omen!/usr/caf/public/zmodem.mm /tmp
  909. A continually updated list of available files is stored in
  910. /usr/spool/uucppublic/FILES.
  911. The following L.sys line calls site "omen" yia UUCP. Telegodzilla
  912. uses Pro-YAM in host operation.
  913. In response to "Name Please:" uucico gives the Pro-YAM "link" command
  914. as a user name. The password (Giznoid) controls access to the Xenix
  915. system connected to the IBM PC's other serial port. Communications
  916. between Pro-YAM and Xenix use 9600 bps; YAM converts this to the
  917. caller's speed.
  918. Finally, the calling uucico logs in as uucp.
  919. omen Any ACU 1200 1-503-621-3746 e:--e: link d: Giznoid n:--n: uucp
  920. Chapter 18 rev051486 Printed 5-16-86 26
  921. Chapter 18 rev051486 Printed 5-16-86 27
  922. 18. ZMODEM PROGRAMS
  923. A demonstration version of Professional-YAM is available as
  924. YAMDEMO.ARC on TeleGodzilla.. This file must be unpacked with the
  925. "ARC" program, version 5 or later. A copy of ARC is available as
  926. "ARC.EXE" or "ARC510.COM" on TeleGodzilla.
  927. This may be used to test ZMODEM and YMODEM implementations. A
  928. flash-up tree structured help file and processor are provided in
  929. YAMHELP.LQR.
  930. 19. YMODEM PROGRAMS
  931. Unix programs supporting the YMODEM protocol are available on
  932. Telegodzilla in the "upgrade" subdirectory as RBSB.SHQ (a SQueezed
  933. shell archive). Most Unix like systems are supported, including V7,
  934. Sys III, 4.2 BSD, SYS V, Idris, Coherent, and Regulus.
  935. A version for VAX-VMS is available in VRBSB.SHQ, in the same
  936. directory.
  937. Irv Hoff has added YMODEM 1k packets and YMODEM batch transfers to
  938. the KMD and IMP series programs, which replace the XMODEM and
  939. MODEM7/MDM7xx series respectively. Overlays are available for a wide
  940. variety of CP/M systems.
  941. Many other programs, including MEX and MEX-PC also support some of
  942. the YMODEM extensions.
  943. Questions about YMODEM, the Professional-YAM communications program,
  944. and requests for evaluation copies may be directed to:
  945. Chuck Forsberg
  946. Omen Technology Inc
  947. 17505-V Sauvie Island Road
  948. Portland Oregon 97231
  949. Voice: 503-621-3406
  950. Modem (Telegodzilla): 503-621-3746
  951. Usenet: ...!tektronix!reed!omen!caf
  952. Compuserve: 70715,131
  953. Source: TCE022
  954. Yours very truly,
  955. Chapter 19 rev051486 Printed 5-16-86 27
  956. CONTENTS
  957. 1. INTENDED AUDIENCE................................................ 2
  958. 2. ACKNOWLEDGMENTS.................................................. 2
  959. 3. RELATED DOCUMENTS................................................ 2
  960. 4. ROSETTA STONE.................................................... 2
  961. 5. WHY DEVELOP ZMODEM?.............................................. 3
  962. 6. ZMODEM Protocol Design Criteria.................................. 5
  963. 6.1 Ease of Use............................................... 5
  964. 6.2 Throughput................................................ 5
  965. 6.3 Integrity and Robustness.................................. 6
  966. 6.4 Ease of Implementation.................................... 6
  967. 7. ZMODEM BASICS.................................................... 6
  968. 7.1 Packetization............................................. 7
  969. 7.2 Link Escape Encoding...................................... 7
  970. 7.3 Header Packet Information................................. 8
  971. 7.4 Binary Header Packet...................................... 9
  972. 7.5 HEX Header Packet......................................... 9
  973. 7.6 Binary Data Packets....................................... 10
  974. 7.7 ASCII Encoded Data Packet................................. 10
  975. 8. PROTOCOL TRANSACTION OVERVIEW.................................... 10
  976. 8.1 Session Cancel Packet..................................... 13
  977. 9. ZMODEM STREAMING TECHNIQUES...................................... 14
  978. 9.1 Full Streaming with Sampling.............................. 14
  979. 9.2 Full Streaming with Interrupt............................. 14
  980. 9.3 Full Streaming with a Sliding Window...................... 15
  981. 9.4 No Streaming.............................................. 15
  982. 10. ATTENTION SEQUENCE............................................... 15
  983. 11. PACKET/FRAME TYPES............................................... 15
  984. 11.1 ZRQINIT................................................... 16
  985. 11.2 ZRINIT.................................................... 16
  986. 11.3 ZSINIT.................................................... 16
  987. 11.4 ZACK...................................................... 16
  988. 11.5 ZFILE..................................................... 16
  989. 11.6 ZSKIP..................................................... 18
  990. 11.7 ZNAK...................................................... 18
  991. 11.8 ZABORT.................................................... 18
  992. 11.9 ZFIN...................................................... 18
  993. 11.10 ZRPOS..................................................... 18
  994. 11.11 ZDATA..................................................... 18
  995. - i -
  996. 11.12 ZEOF...................................................... 18
  997. 11.13 ZFERR..................................................... 18
  998. 11.14 ZCRC...................................................... 18
  999. 11.15 ZCHALLENGE................................................ 19
  1000. 11.16 ZCOMPL.................................................... 19
  1001. 11.17 ZCAN...................................................... 19
  1002. 11.18 ZFREECNT.................................................. 19
  1003. 11.19 ZCOMMAND.................................................. 19
  1004. 12. TRANSACTION EXAMPLE.............................................. 20
  1005. 12.1 A simple file transfer.................................... 20
  1006. 12.2 Challenge and Command Download............................ 20
  1007. 13. ZFILE FRAME FILE INFORMATION..................................... 21
  1008. 14. PERFORMANCE RESULTS.............................................. 23
  1009. 14.1 Throughput................................................ 23
  1010. 14.2 Error Recovery............................................ 23
  1011. 15. PACKET SWITCHED NETWORK CONSIDERATIONS........................... 24
  1012. 16. PERFORMANCE COMPARISION TABLES................................... 25
  1013. 17. MORE INFORMATION................................................. 26
  1014. 18. ZMODEM PROGRAMS.................................................. 27
  1015. 19. YMODEM PROGRAMS.................................................. 27
  1016. - ii -
  1017. LIST OF FIGURES
  1018. Figure 1. Order of Bytes in Header Packet............................ 8
  1019. Figure 2. Binary Header Packet....................................... 9
  1020. Figure 3. HEX Header Packet.......................................... 10
  1021. Figure 4. Flow Control Compatibility................................. 24
  1022. Figure 5. Protocol Overhead Information.............................. 25
  1023. Figure 6. Transmission Time Comparision.............................. 26
  1024. Figure 7. Y/ZMODEM Header Information usage.......................... 26
  1025. - iii -
  1026. The ZMODEM Asynchronous Inter Application File Transfer Protocol
  1027. Chuck Forsberg
  1028. Omen Technology Inc
  1029. ABSTRACT
  1030. The ZMODEM file transfer protocol greatly simplifies file transfers
  1031. compared to XMODEM. In addition to supporting a transparent user
  1032. interface, ZMODEM provides Personal Computer and other users an efficient,
  1033. accurate, robust file transfer method.
  1034. ZMODEM provides especially efficient file transfers with timesharing
  1035. systems, satellite relays, and wide area packet switched networks. A
  1036. choice of buffering and windowing modes allow ZMODEM to operate
  1037. efficiently on systems that cannot support some other streaming protocols.
  1038. ZMODEM provides advanced file management features including AutoDownload,
  1039. remote file compare, aborted transfer recovery, selective file transfers,
  1040. and security verified command downloading.
  1041. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Ös×�[ÀéÐ Eš�� ¸Ö0b€su@�;�w÷`R0—0í°õ
  1042. Xv{u‹ P
  1043. –��e÷Qç�Bm
  1044. ˜ ‡“†�÷Їè0Ò��h¸+0 à [°ÝЀ• ‘0 s0O0�€€ày8ˆ`Y8í0 O°¡è¤è§ÈPŠ€ŠõcXë� °0sÿPPhþ€ Oµû�;>·ÕÀ†ë�ÙP‡„]�İ÷p �0Œ€j— à Ç û >Š�Šà ºt šF â(ÀP ÛH%upNàj°&k` Ç�€@ï°T°�Õ°�Ê �Ÿ¶AEP]Â è  ‘rð�6E%wÐrpöp A$ë@X�Ð@r ëÀ�I’&‰’ÏÃ�€�’ƒp �o¿@%FÀ†ÎèsŠ� éÐ
  1045. ��
  1046. f‘^ ‘s
  1047. ‘F
  1048. Š`èÄæ€•pgt� �Y‘‰‘ý3),`Æ H'0’%y’rð+i‘�–0¹À†€P–Ð Ð Ð8©“l(Ò€?i•B�•[i‘^©‘9–ÂDgé’jÉ–,9‘où’rð<sكИw™—{Ù—€`¡ÐE—��M �‰@d‰P`�èˆP
  1049. þÀX}€¶Y~€�‰pcÆÀZ�0 ÓˆX ³Ù\Õå4D©•è ‘é�9éuP9€œ´9;¹�YiÄ�up¾�€ €�ʹXÂæ�˜é`b†ð©3 $�Ѐ †@ eiÂIè€î £DE€  €�L<ðt(H3€d �,ð˜�Á…�Tp�‰À† ˆàƒªš0 ª�4¶ �€ àÉ 0ŒØ�Î�ë0 )ú¢à‰„È� 6Š£¿P]±R¡˜�H ç� Ò �Ò�÷°ª�Iup�„ é� rDuÐA\P�Š@ Z[´ð˜‚��fª�é€
  1050. XöX¦ ´4K£§�ŠÀ  �ÉPÁ°§¾\=Ð}ð =ÿàÝ@�`¦`¯õZ0ˆ ‹@ @ �¿d‹¦™:�t€Y©P”é� ©šb©ªr � T"p`ÃD@Ÿƒ�«ïÔ)Ð��3ƒâ�÷A0 «°ð
  1051. ³Ãªö �ä€ݰð ­xÀë°z‹…nzªZ¹ª®Š®.°àìA€ �üà¡À°¬Íºèê·ú