-
Notifications
You must be signed in to change notification settings - Fork 0
/
ymodem.txt
1650 lines (895 loc) · 48.3 KB
/
ymodem.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
- 1 -
XMODEM/YMODEM PROTOCOL REFERENCE
A compendium of documents describing the
XMODEM and YMODEM
File Transfer Protocols
Edited by Chuck Forsberg
Please distribute as widely as possible.
Questions to Chuck Forsberg
Omen Technology Inc
17505-V Sauvie Island Road
Portland Oregon 97231
Voice: 503-621-3406
Modem (Telegodzilla): 503-621-3746 Speed 1200,300
Compuserve: 70715,131
UUCP: ...!tektronix!reed!omen!caf
- 2 -
1. ROSETTA STONE
Here are some definitions which reflect the current vernacular in the
computer media. The attempt here is identify the file transfer protocol
rather than specific programs.
XMODEM refers to the original 1979 file transfer etiquette introduced by
Ward Christensen's 1979 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 every serious communications program because of its
universality, simplicity, and reasonable performance.
XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
Redunancy Check (CRC-16), giving modern error detection
protection.
YMODEM refers to the XMODEM/CRC protocol with the throughput and/or batch
transmission enhancements described below.
2. YET ANOTHER PROTOCOL?
Since its development half a decade ago, the Ward Christensen modem
protocol has enabled a wide variety of computer systems to interchange
data. There is hardly a communications program that doesn't at least
claim to support this protocol.
Recent advances in computing, modems and networking have revealed a number
of weaknesses in the original protocol:
+ The short block length caused throughput to suffer when used with
timesharing systems, packet switched networks, satellite circuits,
and buffered (error correcting) modems.
+ The 8 bit arithemetic checksum and other aspects allowed line
impairments to interfere with dependable, accurate transfers.
+ Only one file could be sent per command. The file name had to be
given twice, first to the sending program and then again to the
receiving program.
+ The transmitted file could accumulate as many as 127 extraneous
bytes.
+ The modification date of the file was lost.
A number of other protocols have been developed over the years, but none
have displaced XMODEM to date:
Chapter 2
X/YMODEM Protocol Reference 10-10-85 3
+ Lack of public domain documentation and example programs have kept
proprietary protocols such as MNP, Blast, and others tightly bound to
the fortunes of their suppliers.
+ Complexity discourages the widespread application of BISYNC, SDLC,
HDLC, X.25, and X.PC protocols.
+ Performance compromises and moderate complexity have limited the
popularity of the Kermit protocol, which was developed to allow file
transfers in environments hostile to XMODEM.
The YMODEM Protocol extensions were developed as a means of addressing the
weaknesses described above while maintaining XMODEM's simplicity as much
as possible.
YMODEM is supported by the public domain programs YAM (CP/M),
YAM(CP/M-86), YAM(CCPM-86), IMP (CP/M), KMD (CP/M), MODEM76.ASM (CP/M),
rb/sb (Unix, VMS, Berkeley Unix, Venix, Xenix, Coherent, IDRIS, Regulus)
as well as Professional-YAM.1 These programs have been in use since 1981.
The 1k packet length capability described below may be used in conjunction
with the Batch Protocol, or with single file transfers identical to the
XMODEM/CRC protocol except for the minimal changes to support 1k packets.
Another extension is simply called the g option. It provides maximum
throughput when used with end to end error correcting media, such as X.PC
and error correcting modems, including the emerging 9600 bps units by
Electronic Vaults and others.
To complete this tome, Ward Christensen's original protocol document and
John Byrns's CRC-16 document are included for reference.
References to the MODEM or MODEM7 protocol have been changed to XMODEM to
accommodate the vernacular. In Australia, it is properly called the
Christensen Portocol.
Watch for an article describing the YMODEM protocol in a more coherent
fashion later this year. The article will include some interesting
history on the development of microcomputer file transfers.
__________
1. Available for IBM PC,XT,AT, Unix and Xenix
Chapter 2
X/YMODEM Protocol Reference 10-10-85 4
2.1 Some Messages from the Pioneer
#: 130940 S0/Communications 25-Apr-85 18:38:47
Sb: my protocol
Fm: Ward Christensen 76703,302 (EDITED)
To: all
Be aware the article2 DID quote me correctly in terms of the phrases like
"not robust", etc.
It was a quick hack I threw together, very unplanned (like everything I
do), to satisfy a personal need to communicate with "some other" people.
ONLY the fact that it was done in 8/77, and that I put it in the public
domain immediately, made it become the standard that it is.
I think its time for me to
(1) document it; (people call me and say "my product is going to include
it - what can I 'reference'", or "I'm writing a paper on it, what do I put
in the bibliography") and
(2) propose an "incremental extension" to it, which might take "exactly"
the form of Chuck Forsberg's YAM protocol. He wrote YAM in C for CP/M and
put it in the public domain, and wrote a batch protocol for Unix3 called
rb and sb (receive batch, send batch), which was basically XMODEM with
(a) a record 0 containing filename date time and size
(b) a 1K block size option
(c) CRC-16.
He did some clever programming to detect false ACK or EOT, but basically
left them the same.
People who suggest I make SIGNIFICANT changes to the protocol, such as
"full duplex", "multiple outstanding blocks", "multiple destinations", etc
etc don't understand that the incredible simplicity of the protocol is one
of the reasons it survived to this day in as many machines and programs as
it may be found in!
Consider the PC-NET group back in '77 or so - documenting to beat the band
- THEY had a protocol, but it was "extremely complex", because it tried to
be "all things to all people" - i.e. send binary files on a 7-bit system,
etc. I was not that "benevolent". I (emphasize > I < ) had an 8-bit UART,
__________
2. Infoworld April 29 p. 16
3. VAX/VMS versions of these programs are also available.
Chapter 2
X/YMODEM Protocol Reference 10-10-85 5
so "my protocol was an 8-bit protocol", and I would just say "sorry" to
people who were held back by 7-bit limitations. ...
Block size: Chuck Forsberg created an extension of my protocol, called
YAM, which is also supported via his public domain programs for UNIX
called rb and sb - receive batch and send batch. They cleverly send a
"block 0" which contains the filename, date, time, and size.
Unfortunately, its UNIX style, and is a bit weird4 - octal numbers, etc.
BUT, it is a nice way to overcome the kludgy "echo the chars of the name"
introduced with MODEM7. Further, chuck uses CRC-16 and optional 1K
blocks. Thus the record 0, 1K, and CRC, make it a "pretty slick new
protocol" which is not significantly different from my own.
Also, there is a catchy name - YMODEM. That means to some that it is the
"next thing after XMODEM", and to others that it is the Y(am)MODEM
protocol. I don't want to emphasize that too much - out of fear that
other mfgrs might think it is a "competitive" protocol, rather than an
"unaffiliated" protocol. Chuck is currently selling a much-enhanced
version of his CP/M-80 C program YAM, calling it Professional Yam, and its
for the PC - I'm using it right now. VERY slick! 32K capture buffer,
script, scrolling, previously captured text search, plus built-in commands
for just about everything - directory (sorted every which way), XMODEM,
YMODEM, KERMIT, and ASCII file upload/download, etc. You can program it
to "behave" with most any system - for example when trying a number for
CIS it detects the "busy" string back from the modem and substitutes a
diff phone # into the dialing string and branches back to try it.
3. XMODEM PROTOCOL ENHANCEMENTS
This chapter discusses the protocol extensions to Ward Christensen's 1982
XMODEM protocol description document.
The original document recommends the user be asked wether to continue
trying or abort after 10 retries. Most programs no longer ask the
operator whether he wishes to keep retrying. Virtually all correctable
errors are corrected within the first few retransmissions. If the line is
so bad that ten attempts are insufficient, there is a significant danger
of undetected errors. If the connection is that bad, it's better to
redial for a better connection, or mail a floppy disk.
__________
4. The file length, time, and file mode are optional. The pathname and
file length may be sent alone if desired.
Chapter 3 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 6
3.1 Graceful Abort
YAM and Professional-YAM recognize a sequence of two consecutive CAN (Hex
18) characters without modem errors (overrun, framing, etc.) as a transfer
abort command.1 The check for two consecutive CAN characters virtually
eliminates the possibility of a line hit aborting the transfer. YAM sends
five CAN characters when it aborts an XMODEM or YMODEM protocol file
transfer, followed by five backspaces to delete the CAN characters from
the remote's keyboard input buffer (in case the remote had already aborted
the transfer).
3.2 CRC-16 Option
The XMODEM protocol uses an optional two character CRC-16 instead of the
one character arithmetic checksum used by the original protocol and by
most commercial implementations. CRC-16 guarantees detection of all
single and double bit errors, all errors with an odd number of error
bits, all burst errors of length 16 or less, 99.9969% of all 17-bit error
bursts, and 99.9984 per cent of all possible longer error bursts. By
contrast, a double bit error, or a burst error of 9 bits or more can sneak
past the XMODEM protocol arithmetic checksum.
The XMODEM/CRC protocol is similar to the XMODEM protocol, except that the
receiver specifies CRC-16 by sending C (Hex 43) instead of NAK when
requesting the FIRST packet. A two byte CRC is sent in place of the one
byte arithmetic checksum.
YAM's c option to the r command enables CRC-16 in single file reception,
corresponding to the original implementation in the MODEM7 series
programs. This remains the default because many commercial communications
programs and bulletin board systems still do not support CRC-16,
especially those written in Basic or Pascal.
XMODEM protocol with CRC is accurate provided both sender and receiver
both report a successful transmission. The protocol is robust in the
presence of characters lost by buffer overloading on timesharing systems.
The single character ACK/NAK responses generated by the receiving program
adapt well to split speed modems, where the reverse channel is limited to
ten per cent or less of the main channel's speed.
XMODEM and YMODEM are half duplex protocols which do not attempt to
transmit information and control signals in both directions at the same
__________
1. This is recognized when YAM is waiting for the beginning of a packet
or for an acknowledge to one that has been sent.
Chapter 3 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 7
time. This avoids buffer overrun problems that have been reported by
users attempting to exploit full duplex aynchronous file transfer
protocols such as Blast.
Professional-YAM adds several proprietary logic enhancements to XMODEM's
error detection and recovery. These compatible enhancements eliminate
most of the bad file transfers other programs make when using the XMODEM
protocol under less than ideal conditions.
3.3 1024 Byte Packet Option
The choice to use 1024 byte packets is expressed to the sending program on
its command line or selection menu.
Programs using the Hoff protocol use a two character sequence emitted by
the receiver (CK) to automatically trigger the use of 1024 byte packets as
an alternative to specifying this option on this command line. Although
this two character sequence works well on single process micros in direct
communication, timesharing systems and packet switched networks can
separate the successive characters by several seconds, rendering this
method unreliable.
An STX (02) replaces the SOH (01) at the beginning of the transmitted
block to notify the receiver of the longer packet length. The transmitted
packet contains 1024 bytes of data. The receiver should be able to accept
any mixture of 128 and 1024 byte packets. The packet number is
incremented by one for each packet regardless of the packet length.
The sender must not change between 128 and 1024 byte packet lengths if it
has not received a valid ACK for the current packet. Failure to observe
this restriction allows certain transmission errors to pass undetected.
If 1024 byte packets are being used, it is possible for a file to "grow"
up to the next multiple of 1024 bytes. This does not waste disk space if
the allocation granularity is 1k or greater. When 1024 byte packets are
used with YMODEM batch transmission, the file length transmitted in the
file name packet allows the receiver to discard the padding, preserving
the exact file length and contents.
CRC-16 should be used with the k option to preserve data integrity over
phone lines.2 1024 byte packets may be used with batch file transmission
or with single file transmission.
__________
2. Some programs enforce this recommendation.
Chapter 3 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 8
Figure 1. 1024 byte Packets
SENDER RECEIVER
"s -k foo.bar"
"foo.bar open x.x minutes"
C
STX 01 FE Data[1024] CRC CRC
ACK
STX 02 FD Data[1024] CRC CRC
ACK
STX 03 FC Data[1000] CPMEOF[24] CRC CRC
ACK
EOT
ACK
Figure 2. Mixed 1024 and 128 byte Packets
SENDER RECEIVER
"s -k foo.bar"
"foo.bar open x.x minutes"
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
4. 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 packets 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
__________
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.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 9
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 packet 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 packet 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 never sent.
Filename Considerations:
+ File names should be translated 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.
+ The rb(1) program on Unix systems normally translates the
filename to lower case unless one or more letters in the
filename are already in lower case.
+ When transmitting files between different operating systems,
file names must be acceptable to both the sender and receiving
operating systems.
__________
2. Only the data part of the packet is described here.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 10
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 packet as a decimal string counting
the number of data bytes in the file. The file length does not
include any CPMEOF (^Z) characters used to pad the last packet.
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 packet.
Modification Date A single space separates the modification date from the
file length.
The mod date is optional, and the filename and length may be sent
without requiring the mod date to be sent.
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.
Two Microsoft blunders complicate the use of modification dates in
file transfers with MSDOS(TM) systems. The first is the lack of
timezone standardization in MS-DOS. A file's creation time can not
be known unless the timezone of the system that wrote the file4 is
known. Unix solved this problem (for planet Earth, anyway) by
stamping files with Universal Time (GMT). Microsoft would have to
include the timezone of origin in the directory entries, but does
not. Professional-YAM gets around this problem by using the z
parameter which is set to the number of minutes local time lags GMT.
For files known to originate from a different timezone, the -zT
option may be used to specify T as the timezone for an individual
file transfer.
__________
3. Fields may not be skipped.
4. Not necessarily that of the transmitting system!
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 11
The second problem is the lack of a separate file creation date in
DOS. Since some backup schemes used with DOS rely on the file
creation date to select files to be copied to the archive, back-
dating the file modification date could interfere with the safety of
the transferred files. For this reason, Professional-YAM does not
modify the date of received files with the header information unless
the d parameter is non zero.
Mode 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 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.
The rest of the packet is set to nulls. This is essential to preserve
upward compatibility.5 After the filename packet has been received, it is
ACK'ed if the write open is successful. The receiver then initiates
transfer of the file contents according to the standard XMODEM/CRC
protocol. If the file cannot be opened for writing, the receiver cancels
the transfer with CAN characters as described above.
After the file contents have been transmitted, 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.
In batch transmission, the receiver automatically requests CRC-16.
The Unix programs sb(1) and rb(1) included in the source code file
RBSB.SHQ (rbsb.sh) should answer other questions about YMODEM batch
protocol.
__________
5. If, perchance, this information extends beyond 128 bytes (possible
with Unix 4.2 BSD extended file names), the packet should be sent as a
1k packet as described above.
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 12
Figure 3. Batch Transmission Session
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 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
NAK
EOT
ACK
C
SOH 00 FF NUL[128] CRC CRC
ACK
Figure 4. Filename packet transmitted by sb
-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
80 000000CA 56
Chapter 4 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 13
Figure 5. Header Information used by YMODEM Implementations
_____________________________________________________________________
| Program | Batch | Length | Date | Mode | S/N | 1k-Blk | g-Option |
|___________|_______|________|______|______|_____|________|__________|
|Unix rb/sb | yes | yes | yes | yes | no | yes | sb only |
|___________|_______|________|______|______|_____|________|__________|
|VMS rb/sb | yes | yes | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
|Pro-YAM | yes | yes | yes | no | yes | yes | yes |
|___________|_______|________|______|______|_____|________|__________|
|CP/M YAM | yes | no | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
|KMD/IMP | yes | no | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
|MEX | no | no | no | no | no | yes | no |
|___________|_______|________|______|______|_____|________|__________|
4.1 IMP/KMD Record Count
Due to programming constraints, these programs do not send the file length
as described above. Instead, they send (and look for) the CP/M record
count stored in the last two bytes of the header packet. The least
significant bits are stored in the penultimate byte.
KMD and IMP use the record count to allow the receiving program to display
the file size and estimated transmission time; the file length is
determined by the actual number of records sent.
5. g Option File Transmission
Developing technology is providing phone line data transmission at ever
higher speeds using very specialized techniques. These high speed modems,
as well as session protocols such as X.PC, provide high speed, error free
communications at the expense of considerably increased delay time.
This delay time is moderate compared to human interactions, but it
cripples the throughput of most error correcting protocols.
The g option to YMODEM has proven effective under these circumstances.
The g option is driven by the receiver, which initiates the batch transfer
by transmitting a G instead of C. When the sender recognizes the G, it
bypasses the usual wait for an ACK to each transmitted packet, sending
succeeding packets at full speed, subject to XOFF/XON or other flow
control exerted by the medium.
The sender expects an inital G to initiate the transmission of a
particular file, and also expects an ACK on the EOT sent at the end of
each file. This synchronization allows the receiver time to open and
Chapter 5 XMODEM Protocol Enhancements
X/YMODEM Protocol Reference 10-10-85 14
close files as necessary.
Figure 6. g Option Transmission Session
SENDER RECEIVER
"sb foo.*<CR>"
"sending in batch mode etc..."
G (command:rb -g)
SOH 00 FF foo.c NUL[123] CRC CRC
G
SOH 01 FE Data[128] CRC CRC
SOH 02 FD Data[1024] CRC CRC
SOH 03 FC Data[128] CRC CRC
SOH 04 FB Data[100] CPMEOF[28] CRC CRC
EOT
ACK
G
SOH 00 FF NUL[128] CRC CRC
6. XMODEM PROTOCOL OVERVIEW
8/9/82 by Ward Christensen.
I will maintain a master copy of this. Please pass on changes or
suggestions via CBBS/Chicago at (312) 545-8086, CBBS/CPMUG (312) 849-1132
or by voice at (312) 849-6279.
6.1 Definitions
<soh> 01H
<eot> 04H
<ack> 06H
<nak> 15H
<can> 18H
<C> 43H
6.2 Transmission Medium Level Protocol
Asynchronous, 8 data bits, no parity, one stop bit.
The protocol imposes no restrictions on the contents of the data being
transmitted. No control characters are looked for in the 128-byte data
messages. Absolutely any kind of data may be sent - binary, ASCII, etc.
The protocol has not formally been adopted to a 7-bit environment for the
transmission of ASCII-only (or unpacked-hex) data , although it could be
simply by having both ends agree to AND the protocol-dependent data with
7F hex before validating it. I specifically am referring to the checksum,
and the block numbers and their ones- complement.
Chapter 6 Xmodem Protocol Overview
X/YMODEM Protocol Reference 10-10-85 15
Those wishing to maintain compatibility of the CP/M file structure, i.e.
to allow modemming ASCII files to or from CP/M systems should follow this
data format:
+ ASCII tabs used (09H); tabs set every 8.
+ Lines terminated by CR/LF (0DH 0AH)
+ End-of-file indicated by ^Z, 1AH. (one or more)
+ Data is variable length, i.e. should be considered a continuous
stream of data bytes, broken into 128-byte chunks purely for the
purpose of transmission.
+ A CP/M "peculiarity": If the data ends exactly on a 128-byte
boundary, i.e. CR in 127, and LF in 128, a subsequent sector
containing the ^Z EOF character(s) is optional, but is preferred.
Some utilities or user programs still do not handle EOF without ^Zs.
+ The last block sent is no different from others, i.e. there is no
"short block".
Figure 7. XMODEM Message Block Level Protocol
Each block of the transfer looks like:
<SOH><blk #><255-blk #><--128 data bytes--><cksum>
in which:
<SOH> = 01 hex
<blk #> = binary number, starts at 01 increments by 1, and
wraps 0FFH to 00H (not to 01)
<255-blk #> = blk # after going thru 8080 "CMA" instr, i.e.
each bit complemented in the 8-bit block number.
Formally, this is the "ones complement".
<cksum> = the sum of the data bytes only. Toss any carry.
6.3 File Level Protocol
6.3.1 Common_to_Both_Sender_and_Receiver
All errors are retried 10 times. For versions running with an operator
(i.e. NOT with XMODEM), a message is typed after 10 errors asking the
operator whether to "retry or quit".
Some versions of the protocol use <can>, ASCII ^X, to cancel transmission.
This was never adopted as a standard, as having a single "abort" character
makes the transmission susceptible to false termination due to an <ack>
<nak> or <soh> being corrupted into a <can> and cancelling transmission.
The protocol may be considered "receiver driven", that is, the sender need
not automatically re-transmit, although it does in the current
implementations.
Chapter 6 Xmodem Protocol Overview
X/YMODEM Protocol Reference 10-10-85 16
6.3.2 Receive_Program_Considerations
The receiver has a 10-second timeout. It sends a <nak> every time it
times out. The receiver's first timeout, which sends a <nak>, signals the