⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zmodem.doc

📁 XMODEM传输协议。 通信用代码。 C语言实现
💻 DOC
📖 第 1 页 / 共 5 页
字号:
simple ACK/NAK sequences mentioned above were corrected, XMODEM's simpleACK and	NACK characters	had evolved into a real	packet.	 The Frog wasriveting.Managing the window[2] was another problem.  Experience	gained indebugging The Source's SuperKermit protocol indicated a	window size ofabout 1000 characters was needed at 1200 bps.  High speed modems require a__________ 1. Without stopping for a response 2. The	WINDOW is the data in transit between sender and receiver.Chapter	4		Rev 8-3-87  Typeset 8-4-87			 7Chapter	4		     ZMODEM Protocol				 8window of 20000	or more	characters for full throughput.	 Much of theSuperKermit's inefficiency, complexity and debugging time centered aroundits ring buffering and window management.  There had to	be a better way	toget the	job done.A sore point with XMODEM and its progeny is error recovery.  More to thepoint, how can the receiver determine whether the sender has responded,	oris ready to respond, to	a retransmission request?  XMODEM attacks theproblem	by throwing away characters until a certain period of silence.Too short a time allows	a spurious pause in output (network or timesharingcongestion) to masquerade as error recovery.  Too long a timeoutdevastates throughput, and allows a noisy line to lock up the protocol.SuperKermit solves the problem with a distinct start of	packet character(SOH).	WXMODEM	and ZMODEM use unique character	sequences to delineate thestart of frames.  SEAlink and MEGAlink do not address this problem.A further error	recovery problem arises	in streaming protocols.	 How doesthe receiver know when (or if) the sender has recognized its error signal?Is the next packet the correct response	to the error signal?  Is itsomething left over "in	the queue"?  Or	is this	new subpacket one of manythat will have to be discarded because the sender did not receive theerror signal?  How long	should this continue before sending another errorsignal?	 How can the protocol prevent this from	degenerating into anargument about mixed signals?SuperKermit uses selective retransmission, so it can accept any	goodpacket it receives.  Each time the SuperKermit receiver	gets a datapacket,	it must	decide which outstanding packet	(if any) it "wants most"to receive, and	asks for that one.  In practice, complex software "hacks"are needed to attain acceptable	robustness.[3]For ZMODEM, we decided to forgo	the complexity of SuperKermit's	packetassembly scheme	and its	associated buffer management logic and memoryrequirements.Another	sore point with	XMODEM and WXMODEM is the garbage added	to files.This was acceptable with old CP/M files	which had no exact length, but notwith modern systems such as DOS	and Unix.  YMODEM uses file lengthinformation transmitted	in the header block to trim the	output file, butthis causes data loss when transferring	files that grow	during a transfer.In some	cases, the file	length may be unknown, as when data is obtainedfrom a process.	 Variable length data subpackets solve both of these__________ 3. For	example, when SuperKermit encounters certain errors, the wndesr    function is	called to determine the	next block to request.	A burst	of    errors generates several wasteful requests to retransmit the same    block.Chapter	4		Rev 8-3-87  Typeset 8-4-87			 8Chapter	4		     ZMODEM Protocol				 9problems.Since some characters had to be	escaped	anyway,	there wasn't any pointwasting	bytes to fill out a fixed packet length	or to specify a	variablepacket length.	In ZMODEM, the length of data subpackets is denoted byending each subpacket with an escape sequence similar to BISYNC	and HDLC.The end	result is a ZMOEM header containing a "frame type", four bytes ofsupervisory information, and its own CRC.  Data	frames consist of a headerfollowed by 1 or more data subpackets.	In the absence of transmissionerrors,	an entire file can be sent in one data frame.Since the sending system may be	sensitive to numerous control charactersor strip parity	in the reverse data path, all of the headers sent by thereceiver are sent in hex.  A common lower level	routine	receives allheaders, allowing the main program logic to deal with headers and datasubpackets as objects.With equivalent	binary (efficient) and hex (application	friendly) frames,the sending program can	send an	"invitation to receive"	sequence toactivate the receiver without crashing the remote application withunexpected control characters.Going "back to scratch"	in the protocol	design presents	an opportunity tosteal good ideas from many sources and to add a	few new	ones.From Kermit and	UUCP comes the concept of an initial dialog to exchangesystem parameters.ZMODEM generalizes Compuserve B	Protocol's host	controlled transfers tosingle command AutoDownload and	command	downloading.  A	Security Challengediscourages password hackers and Trojan	Horse authors from abusingZMODEM's power.We were	also keen to the pain and $uffering of legions oftelecommunicators whose	file transfers have been ruined	by communicationsand timesharing	faults.	 ZMODEM's file transfer	recovery and advanced filemanagement are dedicated to these kindred comrades.After ZMODEM had been operational a short time,	Earl Hall pointed out theobvious: ZMODEM's user friendly	AutoDownload was almost	useless	if theuser must assign transfer options to each of the sending and receivingprograms.  Now,	transfer options may be	specified to/by	the sendingprogram, which passes them to the receiving program in the ZFILE header.Chapter	5		Rev 8-3-87  Typeset 8-4-87			 9Chapter	5		     ZMODEM Protocol				105.  ROSETTA STONEHere are some definitions which	reflect	current	vernacular in the computermedia.	The attempt here is identify the file transfer protocol	ratherthan specific programs.FRAME	A ZMODEM frame consists	of a header and	0 or more data subpackets.XMODEM	refers to the original 1977 file transfer etiquette introduced by	Ward Christensen's MODEM2 program.  It's also called the MODEM or	MODEM2 protocol.  Some who are unaware of MODEM7's unusual batch	file mode call it MODEM7.  Other aliases include "CP/M Users's	Group" and "TERM II FTP	3".  This protocol is supported	by most	communications programs	because	it is easy to implement.XMODEM/CRC replaces XMODEM's 1 byte checksum with a two	byte Cyclical	Redundancy Check (CRC-16), improving error detection.XMODEM-1k Refers to XMODEM-CRC with optional 1024 byte blocks.YMODEM	refers to the XMODEM/CRC protocol with batch transmission and	optional 1024 byte blocks as described in YMODEM.DOC.[1]6.  ZMODEM REQUIREMENTSZMODEM requires	an 8 bit transfer medium.[1] ZMODEM escapes networkcontrol	characters to allow operation with packet switched networks.  Ingeneral, ZMODEM	operates over any path that supports XMODEM, and over manythat don't.To support full	streaming,[2] the transmission path should either assertflow control or	pass full speed	transmission without loss of data.Otherwise the ZMODEM sender must manage	the window size.6.1  File Contents6.1.1  Binary FilesZMODEM places no constraints on	the information	content	of binary files,except that the	number of bits in the file must	be a multiple of 8.__________ 1. Available on TeleGodzilla as part of YZMODEM.ZOO 1. The	ZMODEM design allows encoded packets for less transparent media. 2. With XOFF and XON, or out of band flow control such	as X.25	or CTSChapter	6		Rev 8-3-87  Typeset 8-4-87			10Chapter	6		     ZMODEM Protocol				116.1.2  Text FilesSince ZMODEM is	used to	transfer files between different types of computersystems, text files must meet minimum requirements if they are to bereadable on a wide variety of systems and environments.Text lines consist of printing ASCII characters, spaces, tabs, andbackspaces.6.1.2.1	 ASCII End of LineThe ASCII code definition allows text lines terminated by a CR/LF (015,012) sequence, or by a NL (012)	character.  Lines logically terminated bya lone CR (013)	are not	ASCII text.A CR (013) without a linefeed implies overprinting, and	is not acceptableas a logical line separator.  Overprinted lines	should print all importantcharacters in the last pass to allow CRT displays to display meaningfultext.  Overstruck characters may be generated by backspacing or	byoverprinting the line with CR (015) not	followed by LF.Overstruck characters generated	with backspaces	should be sent with themost important character last to accommodate CRT displays that cannotoverstrike.  The sending program may use the ZCNL bit to force thereceiving program to convert the received end of line to its local end ofline convention.[3]__________ 3. Files that have been translated in such a way as to	modify their    length cannot be updated with the ZCRECOV Conversion Option.Chapter	6		Rev 8-3-87  Typeset 8-4-87			11Chapter	6		     ZMODEM Protocol				127.  ZMODEM BASICS7.1  PacketizationZMODEM frames differ somewhat from XMODEM blocks.  XMODEM blocks are notused for the following reasons: + Block numbers are limited to	256 + No provision	for variable length blocks + Line	hits corrupt protocol signals, causing failed file transfers.  In   particular, modem errors sometimes generate false block numbers, false   EOTs	and false ACKs.	 False ACKs are	the most troublesome as	they cause   the sender to lose synchronization with the receiver.   State of the	art programs such as Professional-YAM and ZCOMM	overcome   some	of these weaknesses with clever	proprietary code, but a	stronger   protocol is desired. + It is difficult to determine	the beginning and ends of XMODEM blocks   when	line hits cause	a loss of synchronization.  This precludes rapid   error recovery.7.2  Link Escape EncodingZMODEM achieves	data transparency by extending the 8 bit character set(256 codes) with escape	sequences based	on the ZMODEM data link	escapecharacter ZDLE.[1]Link Escape coding permits variable length data	subpackets without theoverhead of a separate byte count.  It allows the beginning of frames tobe detected without special timing techniques, facilitating rapid errorrecovery.Link Escape coding does	add some overhead.  The	worst case, a fileconsisting entirely of escaped characters, would incur a 50% overhead.The ZDLE character is special.	ZDLE represents	a control sequence of somesort.  If a ZDLE character appears in binary data, it is prefixed withZDLE, then sent	as ZDLEE.The value for ZDLE is octal 030	(ASCII CAN).  This particular value waschosen to allow	a string of 5 consecutive CAN characters to abort a ZMODEM__________ 1. This and other constants are defined in the	zmodem.h include file.    Please note	that constants with a leading 0	are octal constants in C.Chapter	7		Rev 8-3-87  Typeset 8-4-87			12Chapter	7		     ZMODEM Protocol				13session, compatible with YMODEM	session	abort.Since CAN is not used in normal	terminal operations, interactiveapplications and communications	programs can monitor the data flow forZDLE.  The following characters	can be scanned to detect the ZRQINITheader,	the invitation to automatically	download commands or files.Receipt	of five	successive CAN characters will abort a ZMODEM session.Eight CAN characters are sent.The receiving program decodes any sequence of ZDLE followed by a byte withbit 6 set and bit 5 reset (upper case letter, either parity) to	theequivalent control character by	inverting bit 6.  This allows thetransmitter to escape any control character that cannot	be sent	by thecommunications medium.	In addition, the receiver recognizes escapes for0177 and 0377 should these characters need to be escaped.ZMODEM software	escapes	ZDLE, 020, 0220, 021, 0221, 023, and 0223.  Ifpreceded by 0100 or 0300 (@), 015 and 0215 are also escaped to protect theTelenet	command	escape CR-@-CR.	 The receiver ignores 021, 0221, 023, and0223 characters	in the data stream.The ZMODEM routines in zm.c accept an option to	escape all controlcharacters, to allow operation with less transparent networks.	Thisoption can be given to either the sending or receiving program.7.3  HeaderAll ZMODEM frames begin	with a header which may	be sent	in binary or HEXform.  ZMODEM uses a single routine to recognize binary	and hex	headers.Either form of the header contains the same raw	information: + A type byte[2] [3] + Four	bytes of data indicating flags and/or numeric quantities depending   on the frame	type__________ 2. The	frame types are	cardinal numbers beginning with	0 to minimize    state transition table memory requirements. 3. Future extensions to ZMODEM	may use	the high order bits of the type    byte to indicate thread selection.Chapter	7		Rev 8-3-87  Typeset 8-4-87			13Chapter	7		     ZMODEM Protocol				14		   Figure 1.  Order of Bytes in	Header		   TYPE:  frame	type		   F0: Flags least significant byte		   P0: file Position least significant		   P3: file Position most significant			   TYPE	 F3 F2 F1 F0			   -------------------			   TYPE	 P0 P1 P2 P37.3.1  16 Bit CRC Binary HeaderA binary header	is sent	by the sending program to the receiving	program.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -