📄 xymodem.htm
字号:
C
STX 01 FE Data[1024] CRC CRC
ACK
STX 02 FD Data[1024] CRC CRC
ACK
SOH 03 FC Data[128] CRC CRC
ACK
SOH 04 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
ACK
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference June 18 1988 13
5. YMODEM Batch File Transmission
The YMODEM Batch protocol is an extension to the XMODEM/CRC protocol that
allows 0 or more files to be transmitted with a single command. (Zero
files may be sent if none of the requested files is accessible.) The
design approach of the YMODEM Batch protocol is to use the normal routines
for sending and receiving XMODEM blocks in a layered fashion similar to
packet switching methods.
Why was it necessary to design a new batch protocol when one already
existed in MODEM7?[1] The batch file mode used by MODEM7 is unsuitable
because it does not permit full pathnames, file length, file date, or
other attribute information to be transmitted. Such a restrictive design,
hastily implemented with only CP/M in mind, would not have permitted
extensions to current areas of personal computing such as Unix, DOS, and
object oriented systems. In addition, the MODEM7 batch file mode is
somewhat susceptible to transmission impairments.
As in the case of single a file transfer, the receiver initiates batch
file transmission by sending a "C" character (for CRC-16).
The sender opens the first file and sends block number 0 with the
following information.[2]
Only the pathname (file name) part is required for batch transfers.
To maintain upwards compatibility, all unused bytes in block 0 must be set
to null.
Pathname The pathname (conventionally, the file name) is sent as a null
terminated ASCII string. This is the filename format used by the
handle oriented MSDOS(TM) functions and C library fopen functions.
An assembly language example follows:
DB 'foo.bar',0
No spaces are included in the pathname. Normally only the file name
stem (no directory prefix) is transmitted unless the sender has
selected YAM's f option to send the full pathname. The source drive
(A:, B:, etc.) is not sent.
Filename Considerations:
__________
1. The MODEM7 batch protocol transmitted CP/M FCB bytes f1...f8 and
t1...t3 one character at a time. The receiver echoed these bytes as
received, one at a time.
2. Only the data part of the block is described here.
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference June 18 1988 14
+ File names are forced to lower case unless the sending system
supports upper/lower case file names. This is a convenience for
users of systems (such as Unix) which store filenames in upper
and lower case.
+ The receiver should accommodate file names in lower and upper
case.
+ When transmitting files between different operating systems,
file names must be acceptable to both the sender and receiving
operating systems.
If directories are included, they are delimited by /; i.e.,
"subdir/foo" is acceptable, "subdir\foo" is not.
Length The file length and each of the succeeding fields are optional.[3]
The length field is stored in the block as a decimal string counting
the number of data bytes in the file. The file length does not
include any CPMEOF (^Z) or other garbage characters used to pad the
last block.
If the file being transmitted is growing during transmission, the
length field should be set to at least the final expected file
length, or not sent.
The receiver stores the specified number of characters, discarding
any padding added by the sender to fill up the last block.
Modification Date The mod date is optional, and the filename and length
may be sent without requiring the mod date to be sent.
Iff the modification date is sent, a single space separates the
modification date from the file length.
The mod date is sent as an octal number giving the time the contents
of the file were last changed, measured in seconds from Jan 1 1970
Universal Coordinated Time (GMT). A date of 0 implies the
modification date is unknown and should be left as the date the file
is received.
This standard format was chosen to eliminate ambiguities arising from
transfers between different time zones.
__________
3. Fields may not be skipped.
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference June 18 1988 15
Mode Iff the file mode is sent, a single space separates the file mode
from the modification date. The file mode is stored as an octal
string. Unless the file originated from a Unix system, the file mode
is set to 0. rb(1) checks the file mode for the 0x8000 bit which
indicates a Unix type regular file. Files with the 0x8000 bit set
are assumed to have been sent from another Unix (or similar) system
which uses the same file conventions. Such files are not translated
in any way.
Serial Number Iff the serial number is sent, a single space separates the
serial number from the file mode. The serial number of the
transmitting program is stored as an octal string. Programs which do
not have a serial number should omit this field, or set it to 0. The
receiver's use of this field is optional.
Other Fields YMODEM was designed to allow additional header fields to be
added as above without creating compatibility problems with older
YMODEM programs. Please contact Omen Technology if other fields are
needed for special application requirements.
The rest of the block is set to nulls. This is essential to preserve
upward compatibility.[4]
If the filename block is received with a CRC or other error, a
retransmission is requested. After the filename block has been received,
it is ACK'ed if the write open is successful. If the file cannot be
opened for writing, the receiver cancels the transfer with CAN characters
as described above.
The receiver then initiates transfer of the file contents with a "C"
character, according to the standard XMODEM/CRC protocol.
After the file contents and XMODEM EOT have been transmitted and
acknowledged, the receiver again asks for the next pathname.
Transmission of a null pathname terminates batch file transmission.
Note that transmission of no files is not necessarily an error. This is
possible if none of the files requested of the sender could be opened for
reading.
__________
4. If, perchance, this information extends beyond 128 bytes (possible
with Unix 4.2 BSD extended file names), the block should be sent as a
1k block as described above.
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference June 18 1988 16
Most YMODEM receivers request CRC-16 by default.
The Unix programs sz(1) and rz(1) included in the source code file
RZSZ.ZOO should answer other questions about YMODEM batch protocol.
Figure 3. YMODEM Batch Transmission Session (1 file)
SENDER RECEIVER
"sb foo.*<cr>"
"sending in batch mode etc."
C (command:rb)
SOH 00 FF foo.c NUL[123] CRC CRC
ACK
C
SOH 01 FE Data[128] CRC CRC
ACK
SOH 02 FC Data[128] CRC CRC
ACK
SOH 03 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
NAK
EOT
ACK
C
SOH 00 FF NUL[128] CRC CRC
ACK
Figure 7. YMODEM Header Information and Features
_____________________________________________________________
| Program | Length | Date | Mode | S/N | 1k-Blk | YMODEM-g |
|___________|________|______|______|_____|________|__________|
|Unix rz/sz | yes | yes | yes | no | yes | sb only |
|___________|________|______|______|_____|________|__________|
|VMS rb/sb | yes | no | no | no | yes | no |
|___________|________|______|______|_____|________|__________|
|Pro-YAM | yes | yes | no | yes | yes | yes |
|___________|________|______|______|_____|________|__________|
|CP/M YAM | no | no | no | no | yes | no |
|___________|________|______|______|_____|________|__________|
|KMD/IMP | ? | no | no | no | yes | no |
|___________|________|______|______|_____|________|__________|
5.1 KMD/IMP Exceptions to YMODEM
KMD and IMP use a "CK" character sequence emitted by the receiver to
trigger the use of 1024 byte blocks as an alternative to specifying this
option to the sending program. This two character sequence generally
works well on single process micros in direct communication, provided the
programs rigorously adhere to all the XMODEM recommendations included
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference June 18 1988 17
Figure 4. YMODEM Batch Transmission Session (2 files)
SENDER RECEIVER
"sb foo.c baz.c<cr>"
"sending in batch mode etc."
C (command:rb)
SOH 00 FF foo.c NUL[123] CRC CRC
ACK
C
SOH 01 FE Data[128] CRC CRC
ACK
SOH 02 FC Data[128] CRC CRC
ACK
SOH 03 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
NAK
EOT
ACK
C
SOH 00 FF baz.c NUL[123] CRC CRC
ACK
C
SOH 01 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
NAK
EOT
ACK
C
SOH 00 FF NUL[128] CRC CRC
ACK
Figure 5. YMODEM Batch Transmission Session-1k Blocks
SENDER RECEIVER
"sb -k foo.*<cr>"
"sending in batch mode etc."
C (command:rb)
SOH 00 FF foo.c NUL[123] CRC CRC
ACK
C
STX 01 FD Data[1024] CRC CRC
ACK
SOH 02 FC Data[128] CRC CRC
ACK
SOH 03 FB Data[100] CPMEOF[28] CRC CRC
ACK
EOT
NAK
EOT
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference June 18 1988 18
ACK
C
SOH 00 FF NUL[128] CRC CRC
ACK
Figure 6. YMODEM Filename block transmitted by sz
-rw-r--r-- 6347 Jun 17 1984 20:34 bbcsched.txt
00 0100FF62 62637363 6865642E 74787400 |...bbcsched.txt.|
10 36333437 20333331 34373432 35313320 |6347 3314742513 |
20 31303036 34340000 00000000 00000000 |100644..........|
30 00000000 00000000 00000000 00000000
40 00000000 00000000 00000000 00000000
50 00000000 00000000 00000000 00000000
60 00000000 00000000 00000000 00000000
70 00000000 00000000 00000000 00000000
80 000000CA 56
herein. Programs with marginal XMODEM implementations do not fare so
well. Timesharing systems and packet switched networks can separate the
successive characters, rendering this method unreliable.
Sending programs may detect the CK sequence if the operating enviornment
does not preclude reliable implementation.
Instead of the standard YMODEM file length in decimal, KMD and IMP
transmit the CP/M record count in the last two bytes of the header block.
6. YMODEM-g File Transmission
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -