home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / protocol / compress.txt < prev    next >
Text File  |  2020-01-01  |  152KB  |  3,525 lines

  1. 25-Oct-91 14:45:19-GMT,4410;000000000401
  2. Return-Path: <fdc>
  3. Received: by watsun.cc.columbia.edu (5.59/FCB)
  4.     id AA03372; Fri, 25 Oct 91 10:45:06 EDT
  5. Date: Fri, 25 Oct 91 10:45:06 EDT
  6. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  7. To: "Glenn E. Thobe" <thobe@getunx.info.com>
  8. Subject: Re: Recent Kermit Protocol Extensions
  9. In-Reply-To: Your message of Thu, 24 Oct 91 23:31:06 PDT
  10. Message-Id: <CMM.0.90.0.688401906.fdc@watsun.cc.columbia.edu>
  11.  
  12. > Frank-
  13. > In comp.protocols.kermit you write:
  14. > >The next major effort in Kermit protocol expansion (no commitment expressed
  15. > >or implied!) is the addition of an effective and portable compression
  16. > >method. ... For maximum transportability, the
  17. > >result of compression should be a sequence of 7-bit ASCII printable
  18. > >characters (32-126 or a subset of these).  
  19. > No, it should be flexible enough to efficiently use whatever character
  20. > space is available: 32-126 or 32-126,160-255 or ...
  21. > Development of a compression scheme should be combined with the
  22. > development of an efficient means of transporting binary data
  23. > uniformly distributed over the codes 0-255.
  24. We have already done this, to an extent.  But because Kermit will always have
  25. to work on 7-bit connections, and connections where any number of C0 or C1
  26. control characters could interfere with transmission, it would save us a lot
  27. of complexity if the compression method always encodes into ASCII -- that
  28. relieves us of the overhead of prefixing, quoting, and shifting
  29. already-compressed text (to get an idea of what I mean, see the lshift.txt
  30. paper that was mentioned in the same message).
  31.  
  32. > The current method, control-code prefixing, increases the size of such
  33. > a binary file by a good 25% on an 8-bit channel, dissipating about half 
  34. > the gains achieved by precompressing the file.  On a 7-bit channel, the
  35. > combination of 8-th bit and control-code prefixing increases the
  36. > effective file size by some 75%.  Compare these losses the theoretical
  37. > minimums of 6.5% and 21.5%, respectively.
  38. That's why we need a good compression scheme that automatically gives 8-bit
  39. and C0/C1 transparency.
  40.  
  41. > For 7-bit channels, a 4-to-5 byte scheme such as used in the tarmail 
  42. > utility solves this problem (the basis of this algorithm is to treat 
  43. > each four bytes as a 32-bit unsigned integer and express it as 5 digits 
  44. > in base 95).  For 8-bit channels, a similar scheme could be worked out 
  45. > to utilize both the lower and upper ascii printables efficiently.  
  46. Right, but better still to design an algorithm that optimally compresses
  47. into ASCII graphics from the start -- then there is no need to expand the
  48. compressed data for transmission.
  49.  
  50. > Such an alternative to control-code (and even 8th-bit) prefixing
  51. > should be added along with compression, but should be selectable
  52. > (negotiable) even without compression.
  53. There has actually been a lot of talk about this, and this is a possibility.
  54. But the gain in efficiency over current methods is minimal compared (I hope)
  55. to what an effective compression algorithm will yield, so I'd much rather
  56. concentrate on compression than on yet-another-way-of-achieving-transparency-
  57. without-compression.
  58.  
  59. > (Since a protocol extension is envisioned anyway, you might consider 
  60. > extending the character space to optionally include at least the 
  61. > upper ASCII control characters.)
  62. That'll never work.  C1 controls can be misinterpreted as C0 controls
  63. by communication devices or hosts that ignore the 8th bit, and even when they
  64. are correctly seen as C1 controls can trigger unwanted actions like shifting.
  65.  
  66. > Sorry, I don't have any good alternative compression algorithms.
  67. > It is just possible that the LZW *program* might be incorporated into
  68. > Kermit or left as a separate module without legal problems on the
  69. > grounds of prior art, publication, etc.  Or the patent holders
  70. > might write an exemption for Kermit use only.
  71. It's a possibility.
  72.  
  73. > Best wishes.
  74. > -Glenn Thobe <getunx!thobe@uunet.uu.net>
  75. > (A long-time Kermit enthusiast.)
  76. > ---
  77. > P.S. Bravo for your pioneering internationalization efforts!
  78. >
  79. Thanks!  (Do you use this stuff yourself?)
  80.  
  81. > P.P.S. What can be done to get the most popular BBS's to support Kermit?
  82. Beats me.  Maybe as BBS's become popular outside the USA -- where
  83. (inter)national character set conversion is important and 8-bit transparency
  84. cannot be assumed (because of the PTTs) -- we'll see more Kermit support in
  85. BBS software.
  86.  
  87. 26-Oct-91  6:20:53-GMT,1200;000000000011
  88. Return-Path: <@mail.swip.net:pkmab!ske@kullmar>
  89. Received: from mail.swip.net by watsun.cc.columbia.edu (5.59/FCB)
  90.     id AA15980; Sat, 26 Oct 91 02:20:44 EDT
  91. Received: by mail.swip.net (5.61+IDA/KTH/LTH/1.2)
  92.     id AAmail11771; Sat, 26 Oct 91 07:20:39 +0100
  93. Received: by kullmar.se (smail2.5)
  94.     id AA04013; 26 Oct 91 06:15:01 SWT (Sat)
  95. Received: by pkmab.se (smail2.5)
  96.     id AA13833; 26 Oct 91 02:33:04 MET (Sat)
  97. Subject: Compression Protocol
  98. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  99. Date: Sat, 26 Oct 91 2:33:03 MET
  100. From: Kristoffer Eriksson <ske@pkmab.se>
  101. X-Mailer: ELM (ver 2.2 PL16)
  102. Message-Id: <9110260233.AA13833@pkmab.se>
  103.  
  104. >The next major effort in Kermit protocol expansion (no commitment expressed
  105. >or implied!) is the addition of an effective and portable compression
  106. >method.
  107.  
  108. Isn't this a bit over-ambitious? Why not just provide a portable but
  109. separate compression program that you can run before and after transfer?
  110. That way you would avoid bloating the kermit program itself.
  111.  
  112. ----
  113. Kristoffer Eriksson, Peridot Konsult AB, Hagagatan 6, S-703 40 Oerebro, Sweden
  114. Phone: +46 19-13 03 60 !  e-mail: ske@pkmab.se
  115. Fax:   +46 19-11 51 03 !  or ...!{uunet,mcsun}!mail.swip.net!kullmar!pkmab!ske
  116.  
  117. 28-Oct-91 15:18:19-GMT,1076;000000000001
  118. Return-Path: <fdc>
  119. Received: by watsun.cc.columbia.edu (5.59/FCB)
  120.     id AA12440; Mon, 28 Oct 91 10:18:10 EST
  121. Date: Mon, 28 Oct 91 10:18:09 EST
  122. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  123. To: Kristoffer Eriksson <ske@pkmab.se>
  124. Subject: Re: Compression Protocol
  125. In-Reply-To: Your message of Sat, 26 Oct 91 2:33:03 MET
  126. Message-Id: <CMM.0.90.0.688663089.fdc@watsun.cc.columbia.edu>
  127.  
  128. > >The next major effort in Kermit protocol expansion (no commitment expressed
  129. > >or implied!) is the addition of an effective and portable compression
  130. > >method.
  131. > Isn't this a bit over-ambitious? Why not just provide a portable but
  132. > separate compression program that you can run before and after transfer?
  133. > That way you would avoid bloating the kermit program itself.
  134. Because the sending Kermit has to do the record format and character-set
  135. conversions before compressing, and the receiving Kermit has to do them after
  136. decompressing.  Thus we would need not only "n" portable compression programs,
  137. but also "n x (n - 1)" character-set and record-format conversion programs.
  138.  
  139. - Frank
  140.  
  141. 28-Oct-91 18:25:13-GMT,3632;000000000011
  142. Return-Path: <afbf05!afbf02!afbf14!les@uunet.UU.NET>
  143. Received: from relay2.UU.NET by watsun.cc.columbia.edu (5.59/FCB)
  144.     id AA16062; Mon, 28 Oct 91 13:25:11 EST
  145. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  146.     (5.61/UUNET-internet-primary) id AA24113; Mon, 28 Oct 91 13:25:04 -0500
  147. Received: from afbf05.UUCP by uunet.uu.net with UUCP/RMAIL
  148.     (queueing-rmail) id 132450.6045; Mon, 28 Oct 1991 13:24:50 EST
  149. Received: id <m0kbbcJ-0000meC@afbf05.fb.com> Mon, 28 Oct 91 13:23 EST
  150. Received: id <m0kbbXk-00026bC@afbf02.fb.com> Mon, 28 Oct 91 12:18 CST
  151. Received: id <m0kbcTI-0002Y3C@afbf14.fb.com> Mon, 28 Oct 91 13:18 CST
  152. Message-Id:  <m0kbcTI-0002Y3C@afbf14.fb.com>
  153. From: les@fb.com (Les Mikesell)
  154. Subject: Re: Info-Kermit Digest V14
  155. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  156. Date: Mon, 28 Oct 91 13:17:55 CST
  157. In-Reply-To: <CMM.0.90.0.688662617.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Oct 28, 91 10:10 am
  158.  
  159. [Compression to printable chars...]
  160. > Right, but better still to design an algorithm that optimally compresses
  161. > into ASCII graphics from the start -- then there is no need to expand the
  162. > compressed data for transmission.
  163.  
  164. I'm not sure I agree here.  I suppose it might depend on the algorithm,
  165. but I don't see how a 1-pass compress can do any optimization into
  166. a specified character set to make it come out any better than compressing
  167. into 256 characters, then expanding through something like btoa.  That
  168. is, the compress pass is always going to generate an essentially random
  169. output and thus can't do any optimization for the output character set.
  170. The extra processing would be irrelevant compared to the compress pass anyway.
  171.  
  172. > > Such an alternative to control-code (and even 8th-bit) prefixing
  173. > > should be added along with compression, but should be selectable
  174. > > (negotiable) even without compression.
  175.  
  176. > There has actually been a lot of talk about this, and this is a possibility.
  177. > But the gain in efficiency over current methods is minimal compared (I hope)
  178. > to what an effective compression algorithm will yield, so I'd much rather
  179. > concentrate on compression than on yet-another-way-of-achieving-transparency-
  180. > without-compression.
  181.  
  182. But any way you look at it, control-code prefixing is going to cost about
  183. 25% of your possible bandwidth, and on many (probably most) connections
  184. it isn't necessary.  I think you need both options and they need to
  185. be coordinated so the compression can use the full character set if
  186. the transfer link allows it.  Likewise, if the material is pre-compressed
  187. with unix compress, zip, zoo, arc or the like, the kermit compression
  188. is unlikely to help and quite likely to expand the data unless you are
  189. careful to allow compression to be disabled when it isn't working
  190. (per-packet would be nice here). In this case if the transfer link
  191. needs control/hi-bit escaping you would still be ahead to pass the
  192. data stream through a btoa style encoder instead of using traditional
  193. kermit escaping, so that should be a separate choice with or without
  194. the compression.   Also, this stuff needs to be processed
  195. so that the CRC checking sees the same thing on both ends.  The current
  196. 8-bit quoting is done such that it can be set on one end and not on
  197. the other and the error checking still passes.
  198.  
  199. > > Sorry, I don't have any good alternative compression algorithms.
  200.  
  201. You might want to check with: brnstnd@KRAMDEN.ACF.NYU.EDU (Dan Bernstein).
  202. He has posted some original code to usenet and made references to some
  203. work in progress.  I think the intent was to have something available
  204. to use without patent restrictions.
  205.  
  206. Les Mikesell
  207.   les@fb.com
  208.  
  209. 28-Oct-91 18:56:12-GMT,4752;000000000001
  210. Return-Path: <fdc>
  211. Received: by watsun.cc.columbia.edu (5.59/FCB)
  212.     id AA16439; Mon, 28 Oct 91 13:56:04 EST
  213. Date: Mon, 28 Oct 91 13:56:03 EST
  214. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  215. To: les@fb.com (Les Mikesell)
  216. Subject: Re: Info-Kermit Digest V14
  217. In-Reply-To: Your message of Mon, 28 Oct 91 13:17:55 CST
  218. Message-Id: <CMM.0.90.0.688676163.fdc@watsun.cc.columbia.edu>
  219.  
  220. > I'm not sure I agree here.  I suppose it might depend on the algorithm,
  221. > but I don't see how a 1-pass compress can do any optimization into
  222. > a specified character set to make it come out any better than compressing
  223. > into 256 characters, then expanding through something like btoa.  That
  224. > is, the compress pass is always going to generate an essentially random
  225. > output and thus can't do any optimization for the output character set.
  226. > The extra processing would be irrelevant compared to the compress pass
  227. > anyway. 
  228. You might be right, but I think it's worth trying to come up with an algorithm
  229. that compresses into printable ASCII before deciding it can't be done.  You
  230. should be able to use codewords of any bit length you like, so (for example)
  231. we could compress into 6-bit codewords and add some offset (like 33) to get
  232. printable ASCII.  Wasteful but simple.  Needs analysis.
  233.  
  234. > But any way you look at it, control-code prefixing is going to cost about
  235. > 25% of your possible bandwidth, and on many (probably most) connections
  236. > it isn't necessary.
  237. >
  238. But you never know which control characters are going to cause problems.  The
  239. Kermit programs themselves can't know, because they don't know what kinds of
  240. things are sitting between them.  They can't even send a "test pattern"
  241. because that might put some intermediate box out of commission (e.g. Ctrl-P
  242. might put an X.3 PAD into local mode; Series/1-style 3270 protocol converters
  243. normally will not pass *any* control characters through to the host; etc etc).
  244. I don't think we can ever assume that any particular control characters are
  245. safe, even though some subset of them usually are on any particular connection.
  246.  
  247. > I think you need both options and they need to be coordinated so the
  248. > compression can use the full character set if the transfer link allows it.
  249. >
  250. But then you put an awful burden on the user.  I'd prefer to see compression
  251. work automatically if both Kermit programs support it, without having to make
  252. the user figure whether and to what degree the link is transparent to control
  253. and 8-bit characters.
  254.  
  255. > Likewise, if the material is pre-compressed with unix compress, zip, zoo,
  256. > arc or the like, the kermit compression is unlikely to help and quite likely
  257. > to expand the data unless you are careful to allow compression to be
  258. > disabled when it isn't working (per-packet would be nice here).
  259. >
  260. Like all Kermit options (except control-character escaping), compression
  261. will be disablable by the user.  If a file (precompressed or not) has a
  262. random distribution of characters, there will indeed be about 25% expansion
  263. for control prefixing.  On a 7-bit connection, there would also be an
  264. additional 50% for 8th-bit escaping, except that now we have a locking shift
  265. mechanism that reduces that to practically nil.
  266.  
  267. In the interest of minimizing the internal complexity of the Kermit program
  268. and its user interface, I think it might be better, when compressing, to strip 
  269. away the already-complicated control- and 8th-bit escaping methods and
  270. compress directly into a form that is guaranteed to be transparent to even the
  271. most hostile connections.  It's a tradeoff -- everybody pays a price in some
  272. additional overhead, but everybody gets a compression method that works
  273. without requiring just the right combination of manual tweaking.
  274.  
  275. > In this case if the transfer link needs control/hi-bit escaping you would
  276. > still be ahead to pass the data stream through a btoa style encoder instead
  277. > of using traditional kermit escaping, so that should be a separate choice
  278. > with or without the compression.
  279. >
  280. btoa is a 4-for-3 scheme, right?  For most types of data (all text, many
  281. kinds of binaries), Kermit is already better than that.
  282.  
  283. > Also, this stuff needs to be processed
  284. > so that the CRC checking sees the same thing on both ends.  The current
  285. > 8-bit quoting is done such that it can be set on one end and not on
  286. > the other and the error checking still passes.
  287. That only happens if there is a bug in one of the Kermit programs.  The
  288. 8th-bit prefixing negotiation is supposed to work.
  289.  
  290. > You might want to check with: brnstnd@KRAMDEN.ACF.NYU.EDU (Dan Bernstein).
  291. > He has posted some original code to usenet and made references to some
  292. > work in progress.  I think the intent was to have something available
  293. > to use without patent restrictions.
  294. Thanks for the pointer!
  295.  
  296. - Frank
  297.  
  298. 28-Oct-91 20:36:19-GMT,4650;000000000011
  299. Return-Path: <afbf05!afbf02!afbf14!les@uunet.UU.NET>
  300. Received: from relay2.UU.NET by watsun.cc.columbia.edu (5.59/FCB)
  301.     id AA17697; Mon, 28 Oct 91 15:36:15 EST
  302. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  303.     (5.61/UUNET-internet-primary) id AA27497; Mon, 28 Oct 91 15:36:17 -0500
  304. Received: from afbf05.UUCP by uunet.uu.net with UUCP/RMAIL
  305.     (queueing-rmail) id 153546.21143; Mon, 28 Oct 1991 15:35:46 EST
  306. Received: id <m0kbden-00015qC@afbf05.fb.com> Mon, 28 Oct 91 15:33 EST
  307. Received: id <m0kbdbA-00028IC@afbf02.fb.com> Mon, 28 Oct 91 14:30 CST
  308. Received: id <m0kbeWY-0002WRC@afbf14.fb.com> Mon, 28 Oct 91 15:29 CST
  309. Message-Id:  <m0kbeWY-0002WRC@afbf14.fb.com>
  310. From: les@fb.com (Les Mikesell)
  311. Subject: Re: Info-Kermit Digest V14
  312. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  313. Date: Mon, 28 Oct 91 15:29:26 CST
  314. In-Reply-To: <CMM.0.90.0.688676163.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Oct 28, 91 1:56 pm
  315.  
  316. > You might be right, but I think it's worth trying to come up with an algorithm
  317. > that compresses into printable ASCII before deciding it can't be done.
  318.  
  319. No question that it can be done - I just don't think it can be done much
  320. more efficiently than compression without regard to the output character
  321. set followed by remapping.
  322.  
  323. > >
  324. > But you never know which control characters are going to cause problems.
  325.  
  326. Right - in my original message I suggested explicit commands for
  327. SET CONTROL-ESCAPING ON/OFF/MINIMAL/LIST  so you could tell it how
  328. to handle a particular link optimally.  Minimal would be
  329. xon/xoff/ctl-p/and the kermit start-of-packet.  Off would probably
  330. still have to include the start-of-packet.  This would need to be
  331. negotiated with the remote, although I suspect that most kermits would
  332. receive correctly anyway if the sender unilaterally only escaped the
  333. minimal set.
  334.  
  335. > > I think you need both options and they need to be coordinated so the
  336. > > compression can use the full character set if the transfer link allows it.
  337. > >
  338. > But then you put an awful burden on the user.  I'd prefer to see compression
  339. > work automatically if both Kermit programs support it, without having to make
  340. > the user figure whether and to what degree the link is transparent to control
  341. > and 8-bit characters.
  342.  
  343. It's not a burden if the default is for the worst-case.  Then the user
  344. doesn't need to know, but if he does know about a particular link he can
  345. easily set the option to take advantage of it. 
  346.  
  347. > In the interest of minimizing the internal complexity of the Kermit program
  348. > and its user interface, I think it might be better, when compressing, to strip 
  349. > away the already-complicated control- and 8th-bit escaping methods and
  350. > compress directly into a form that is guaranteed to be transparent to even the
  351. > most hostile connections.  It's a tradeoff -- everybody pays a price in some
  352. > additional overhead, but everybody gets a compression method that works
  353. > without requiring just the right combination of manual tweaking.
  354.  
  355. Yes, that is the right thing to do for the default case, but I still think
  356. you should accomodate the people who are using expensive but transparent
  357. links and want the optimum speed.  In this case, the data is very likely
  358. going to be pre-compressed anyway.
  359.  
  360. > > In this case if the transfer link needs control/hi-bit escaping you would
  361. > > still be ahead to pass the data stream through a btoa style encoder instead
  362. > > of using traditional kermit escaping, so that should be a separate choice
  363. > > with or without the compression.
  364. > >
  365. > btoa is a 4-for-3 scheme, right?  For most types of data (all text, many
  366. > kinds of binaries), Kermit is already better than that.
  367.  
  368. But the people who care about transfer time are probably compressing the
  369. files already.  They are probably also using some other transfer
  370. protocol if they have transparent links, but kermit could handle it
  371. with a simple option.  The 4-3 coding just makes things fall out on
  372. byte boundaries.  You could do 8-bit to n-bit coding any way you like
  373. as long as it is internal to kermit. The ideal thing would be to make
  374. the compression and encoding options settable per-packet (at least when
  375. you use long packets).  Then the sender could prepare compressed/encoded,
  376. straight encoded, and traditional kermit escaping packets and send whichever
  377. happens to be shorter.  No matter what compression scheme you pick there
  378. will always be data that won't compress.  If you look at tests of MNP5
  379. vs. V.42bis modem transfer rates you will see that the V.42bis handles
  380. pre-compressed data much better because it knows enough not to expand
  381. the stream accidentally for any length of time.   
  382.  
  383. Les Mikesell
  384.   les@fb.com
  385.  
  386. 28-Oct-91 21:34:03-GMT,5365;000000000001
  387. Return-Path: <fdc>
  388. Received: by watsun.cc.columbia.edu (5.59/FCB)
  389.     id AA18316; Mon, 28 Oct 91 16:33:53 EST
  390. Date: Mon, 28 Oct 91 16:33:52 EST
  391. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  392. To: les@fb.com (Les Mikesell)
  393. Subject: Re: Info-Kermit Digest V14
  394. In-Reply-To: Your message of Mon, 28 Oct 91 15:29:26 CST
  395. Message-Id: <CMM.0.90.0.688685632.fdc@watsun.cc.columbia.edu>
  396.  
  397. > > You might be right, but I think it's worth trying to come up with an
  398. > > algorithm that compresses into printable ASCII before deciding it can't 
  399. > > be done.
  400. > No question that it can be done - I just don't think it can be done much
  401. > more efficiently than compression without regard to the output character
  402. > set followed by remapping.
  403. Right, probably somewhat less efficiently -- but more portably (in the same
  404. way that Kermit protocol is more portable than Xmodem, but at some expense
  405. in efficiency -- however, Xmodem's efficiency is zero on a 7-bit link, so it
  406. kind of averages out).
  407.  
  408. > > But you never know which control characters are going to cause problems.
  409. > Right - in my original message I suggested explicit commands for
  410. > SET CONTROL-ESCAPING ON/OFF/MINIMAL/LIST  so you could tell it how
  411. > to handle a particular link optimally.
  412. >
  413. This is, of course, a possibility and there's nothing in the protocol that
  414. prevents this.  You are correct that most Kermit programs would accept control
  415. characters in data packets "bare" (but there's no good way to take a complete
  416. census).  But it's a cost vs benefit thing -- the cost in complexity and
  417. confusion would be high, few people would actually use it; those that did
  418. would become confused when the "transparency mask" changed from connection to
  419. connection (and it will), etc.  The overall gain for text is minimal, and
  420. even for binary files with uniform distribution of chars, 25% at best.  So
  421. yes, it can be done, but the payoff would not be nearly so dramatic as for a
  422. good compression scheme, so it's lower on the priority list.  Btw, there have
  423. also been some very clever alternate escaping mechanisms proposed for
  424. combinations of control and 8-bit chars, but again, the benefit/cost ratio is
  425. low.
  426.  
  427. > Minimal would be xon/xoff/ctl-p/and the kermit start-of-packet.
  428. >
  429. ...and carriage return, and linefeed, and 0xff (telnet), and Ctrl-C (most
  430. things), and Ctrl-I (often gets expanded to spaces), and Ctrl-N/Ctrl-O
  431. (shift-in/shift-out), and various 8-bit shifts (SS2, SS3, LS2, LS3, LS2R,...),
  432. etc etc.
  433.  
  434. > Off would probably still have to include the start-of-packet.  This would
  435. > need to be negotiated with the remote,
  436. >
  437. But it can't be.  They don't know, and there is no way (unless I'm being
  438. incredibly dense) that they can figure it out for themselves.  "Hey, here's
  439. a Ctrl-S, did you get it?" -- what happens next (now that the link is Xoff'd).
  440. Similar scenarios for each Ctrl character...
  441.  
  442. > It's not a burden if the default is for the worst-case.  Then the user
  443. > doesn't need to know, but if he does know about a particular link he can
  444. > easily set the option to take advantage of it. 
  445. Well, yes, that's an option.  The thing can be designed (for example -- truly
  446. off the top of the head) to use, say, 6-bit codewords on a 7-bit link and
  447. 7-bit codewords on an 8-bit link (etc, into the future).  But we'd have to be
  448. pretty clever about designing an algorithm that generalizes to n-bit codewords
  449. (and we should be!).
  450.  
  451. > But the people who care about transfer time are probably compressing the
  452. > files already.
  453. >
  454. Actually, there are two things going on here.  Precompression for quick
  455. transfers is one thing, and hopefully Kermit will make that relatively
  456. unnecessary.  People also put things into archives for EASE of transport --
  457. many unlike files collected into a single flat file, which floats around from
  458. place to place until it finally reaches its final destination where it is
  459. de-archived.  Unfortunately, these schemes are mostly system-specific -- DOS
  460. ZIP archives, UNIX TAR archives, VMS BACKUP archives, etc -- they depend on
  461. the home system's encoding and record format conventions.
  462.  
  463. > The 4-3 coding just makes things fall out on byte boundaries.  You could do
  464. > 8-bit to n-bit coding any way you like as long as it is internal to kermit.
  465. > The ideal thing would be to make the compression and encoding options
  466. > settable per-packet (at least when you use long packets).  Then the sender
  467. > could prepare compressed/encoded, straight encoded, and traditional kermit
  468. > escaping packets and send whichever happens to be shorter.
  469. >
  470. This is a worthy goal, but phew!  -- Try to picture the programs that
  471. implement it.  My instinct tells me that if we don't keep it pretty simple,
  472. programmers are just not going to tackle it.  Also we have the issue of CPU
  473. speed here -- on your typical 80286 and below, the computation could easily
  474. wind up being the bottleneck.
  475.  
  476. > No matter what compression scheme you pick there will always be data that
  477. > won't compress.  If you look at tests of MNP5 vs. V.42bis modem transfer
  478. > rates you will see that the V.42bis handles pre-compressed data much better
  479. > because it knows enough not to expand the stream accidentally for any length
  480. > of time.
  481. Just the kind of info I'm looking for.  Have you seen any analyses of V.42bis
  482. published anywhere?  I have (at least part of) the V.42bis specification
  483. (text, no pictures), but no analysis at all.
  484.  
  485. Thanks!  - Frank
  486.  
  487. 28-Oct-91 23:51:52-GMT,6495;000000000011
  488. Return-Path: <afbf05!afbf02!afbf14!les@uunet.UU.NET>
  489. Received: from relay2.UU.NET by watsun.cc.columbia.edu (5.59/FCB)
  490.     id AA19986; Mon, 28 Oct 91 18:51:49 EST
  491. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  492.     (5.61/UUNET-internet-primary) id AA09251; Mon, 28 Oct 91 18:51:37 -0500
  493. Received: from afbf05.UUCP by uunet.uu.net with UUCP/RMAIL
  494.     (queueing-rmail) id 185002.12615; Mon, 28 Oct 1991 18:50:02 EST
  495. Received: id <m0kbgfw-0001DyC@afbf05.fb.com> Mon, 28 Oct 91 18:47 EST
  496. Received: id <m0kbgb0-0002MCC@afbf02.fb.com> Mon, 28 Oct 91 17:42 CST
  497. Received: id <m0kbhWd-0001C5C@afbf14.fb.com> Mon, 28 Oct 91 18:41 CST
  498. Message-Id:  <m0kbhWd-0001C5C@afbf14.fb.com>
  499. From: les@fb.com (Les Mikesell)
  500. Subject: Re: Info-Kermit Digest V14
  501. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  502. Date: Mon, 28 Oct 91 18:41:42 CST
  503. In-Reply-To: <CMM.0.90.0.688685632.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Oct 28, 91 4:33 pm
  504.  
  505. > > No question that it can be done - I just don't think it can be done much
  506. > > more efficiently than compression without regard to the output character
  507. > > set followed by remapping.
  508.  
  509. > Right, probably somewhat less efficiently -- but more portably
  510.  
  511. Keeping the phases separate doesn't affect portability - and it lets you
  512. use each for its own purpose.
  513.  
  514. [reduced escaping...]
  515. > This is, of course, a possibility and there's nothing in the protocol that
  516. > prevents this. 
  517.  
  518. > The overall gain for text is minimal, and
  519. > even for binary files with uniform distribution of chars, 25% at best.  So
  520. > yes, it can be done, but the payoff would not be nearly so dramatic as for a
  521. > good compression scheme, so it's lower on the priority list.  Btw, there have
  522. > also been some very clever alternate escaping mechanisms proposed for
  523. > combinations of control and 8-bit chars, but again, the benefit/cost ratio is
  524. > low.
  525.  
  526. What's low?  We spend about $6-10,000/month on phone charges for data
  527. communications and that's probably low for a national organization. 
  528. I'd think 25% of that would be worth thinking about.
  529. Certainly worth figuring out whether you should issue a set command in
  530. your start-up scripts.  Most of it isn't using kermit now, but I'd switch
  531. some things over if it could match the other protocols in speed.
  532.  
  533. > > Off would probably still have to include the start-of-packet.  This would
  534. > > need to be negotiated with the remote,
  535. > >
  536. > But it can't be.  They don't know, and there is no way (unless I'm being
  537. > incredibly dense) that they can figure it out for themselves. 
  538.  
  539. Right - we have to assume that the sender knows what he is doing, or at least
  540. is capable of learning from the transfer failures when he does it wrong.  The
  541. negotiation part would just be to be assured that the remote knows how to
  542. receive the unescaped control characters - it's really up to the sender to
  543. do it all.  Basically you are just asking the user to be aware of the same
  544. things they currently need to know when they chose a protocol, if the
  545. list of choices includes xmodem, etc.
  546.  
  547. > Actually, there are two things going on here.  Precompression for quick
  548. > transfers is one thing, and hopefully Kermit will make that relatively
  549. > unnecessary.  People also put things into archives for EASE of transport --
  550. > many unlike files collected into a single flat file, which floats around from
  551. > place to place until it finally reaches its final destination where it is
  552. > de-archived.  Unfortunately, these schemes are mostly system-specific -- DOS
  553. > ZIP archives, UNIX TAR archives, VMS BACKUP archives, etc -- they depend on
  554. > the home system's encoding and record format conventions.
  555.  
  556. This is becoming much less of an issue with portable versions of zoo, arc
  557. and zip around, as well as tar and cpio.  I happen to prefer zoo at the
  558. moment, but I may change my mind when I get around to pickup up the zip
  559. source.   The real challenge for portable kermit compression has got to
  560. be the contortions you have to go through when ascii<->ebcdic conversions
  561. are done by something else between the sender and receiver, but I'm not
  562. sure it's worth crippling other transfers just to allow this one to be
  563. a little bit faster.  (I do use a unix <-> ibm mainframe kermit link,
  564. but it's local and completely script driven, so the speed doesn't matter
  565. much to me.)
  566.  
  567. > > The 4-3 coding just makes things fall out on byte boundaries.  You could do
  568. > > 8-bit to n-bit coding any way you like as long as it is internal to kermit.
  569. > > The ideal thing would be to make the compression and encoding options
  570. > > settable per-packet (at least when you use long packets).  Then the sender
  571. > > could prepare compressed/encoded, straight encoded, and traditional kermit
  572. > > escaping packets and send whichever happens to be shorter.
  573. > >
  574. > This is a worthy goal, but phew!  -- Try to picture the programs that
  575. > implement it.  My instinct tells me that if we don't keep it pretty simple,
  576. > programmers are just not going to tackle it.  Also we have the issue of CPU
  577. > speed here -- on your typical 80286 and below, the computation could easily
  578. > wind up being the bottleneck.
  579.  
  580. The worst case of this is the one you mostly want to try, though.  That is,
  581. you need to go through the motions of compressing and doing the portable
  582. encoding anyway.  The other 2 choices (encoding only/traditional kermit)
  583. are trivial in computation for the sender, and all you need are 3 bits in
  584. a packet header to allow an on-the-fly choice of which to send (although
  585. you do have to be careful about compression methods that change their
  586. tables dynamically).  If the encoding/decompression steps are separate,
  587. the receiver doesn't have to be much more complicated at all.  You will
  588. already need traditional kermit packet handling, so you just add the 
  589. new alternative routines and process each step according to the header
  590. indication.  I'm not sure it's worth going down to the short packets
  591. with this, though.
  592.  
  593. > Just the kind of info I'm looking for.  Have you seen any analyses of V.42bis
  594. > published anywhere?  I have (at least part of) the V.42bis specification
  595. > (text, no pictures), but no analysis at all.
  596.  
  597. No, I've only seen some commentary on usenet.  Toby Nixon (an engineer
  598. at Hayes) has explained some of the theory (like what happens when you
  599. send a worst-case data stream), but unfortunately I didn't save any of
  600. it.  Basically, after a certain interval of expanding data it will dump
  601. its tables and start retraining, somehow syncing this with the remote
  602. end.
  603.  
  604. Les Mikesell
  605.   les@chinet.chi.il.us
  606.  
  607. 29-Oct-91  0:19:42-GMT,2071;000000000001
  608. Return-Path: <fdc>
  609. Received: by watsun.cc.columbia.edu (5.59/FCB)
  610.     id AA20307; Mon, 28 Oct 91 19:18:02 EST
  611. Date: Mon, 28 Oct 91 19:18:01 EST
  612. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  613. To: les@fb.com (Les Mikesell)
  614. Subject: Re: Info-Kermit Digest V14
  615. In-Reply-To: Your message of Mon, 28 Oct 91 18:41:42 CST
  616. Message-Id: <CMM.0.90.0.688695481.fdc@watsun.cc.columbia.edu>
  617.  
  618. > What's low?  We spend about $6-10,000/month on phone charges for data
  619. > communications and that's probably low for a national organization. 
  620. > I'd think 25% of that would be worth thinking about.
  621. >
  622. Total agreement.  But wouldn't you rather reduce your phone bill by, say,
  623. 50%, 100%, or more, instead of 25%?  With only a couple people willing to put
  624. in whatever spare-time hours they can grab, nights and weekends, we have to
  625. put our efforts where the biggest payoff is.  Changing Kermit protocol and
  626. software to transmit & negotiate bare controls would take a lot longer than
  627. you think -- probably a year for the flame wars alone...
  628.  
  629. > Right - we have to assume that the sender knows what he is doing, or at least
  630. > is capable of learning from the transfer failures when he does it wrong.
  631. >
  632. Yes, but...  Can you suggest a method that a mere mortal can follow?
  633.  
  634. > The real challenge for portable kermit compression has got to
  635. > be the contortions you have to go through when ascii<->ebcdic conversions
  636. > are done by something else between the sender and receiver...
  637. >
  638. Not just ASCII/EBCDIC, but Latin-1, JIS Kanji, etc etc.  We've already figured
  639. this one out -- it's how mainframe Kermit works.  We're adding compression at
  640. a level (sort of "high presentation") where this is not an issue (long story).
  641.  
  642. > The worst case of this is the one you mostly want to try, though.  That is,
  643. > you need to go through the motions of compressing and doing the portable
  644. > encoding anyway.  The other 2 choices (encoding only/traditional kermit)
  645. > are trivial...
  646. >
  647. I must say, this is an interesting idea (mixing compressed and uncompressed
  648. packets) but, no doubt, a lot trickier than it sounds.
  649.  
  650. - Frank
  651.  
  652. 29-Oct-91 16:06:22-GMT,5542;000000000011
  653. Return-Path: <afbf05!afbf02!afbf14!les@uunet.UU.NET>
  654. Received: from relay2.UU.NET by watsun.cc.columbia.edu (5.59/FCB)
  655.     id AA28757; Tue, 29 Oct 91 11:06:20 EST
  656. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  657.     (5.61/UUNET-internet-primary) id AA10445; Tue, 29 Oct 91 11:06:21 -0500
  658. Received: from afbf05.UUCP by uunet.uu.net with UUCP/RMAIL
  659.     (queueing-rmail) id 110506.14627; Tue, 29 Oct 1991 11:05:06 EST
  660. Received: id <m0kbvuR-0001GaC@afbf05.fb.com> Tue, 29 Oct 91 11:03 EST
  661. Received: id <m0kbvkL-0001YRC@afbf02.fb.com> Tue, 29 Oct 91 09:52 CST
  662. Received: id <m0kbwgQ-0002WWC@afbf14.fb.com> Tue, 29 Oct 91 10:52 CST
  663. Message-Id:  <m0kbwgQ-0002WWC@afbf14.fb.com>
  664. From: les@fb.com (Les Mikesell)
  665. Subject: Re: Info-Kermit Digest V14
  666. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  667. Date: Tue, 29 Oct 91 10:52:50 CST
  668. In-Reply-To: <CMM.0.90.0.688695481.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Oct 28, 91 7:18 pm
  669.  
  670. > Total agreement.  But wouldn't you rather reduce your phone bill by, say,
  671. > 50%, 100%, or more, instead of 25%?  With only a couple people willing to put
  672. > in whatever spare-time hours they can grab, nights and weekends, we have to
  673. > put our efforts where the biggest payoff is.  Changing Kermit protocol and
  674. > software to transmit & negotiate bare controls would take a lot longer than
  675. > you think -- probably a year for the flame wars alone...
  676.  
  677. I can't argue about the politics, but from a practical point of view, I'd
  678. rather have the ability to pass the control characters. You are unlikely
  679. to beat V.42bis compression, and that is increasingly available in the
  680. modem hardware, and in the cases where it really matters we can always
  681. pre-compress before transmission.  The thing we currently can't do is
  682. move the bytes with any efficiency after they have been compressed.
  683. I'd be happy with a simple non-negotiated command to turn off escaping
  684. on everything but start-of-packet, ^C, ^P, and if flow control is
  685. enabled, ^S and ^Q (I suppose you'd have to look at how most versions
  686. handle received nulls, too...).  Then just start fixing versions to do
  687. the right thing on the receiving side if they don't already.  I don't
  688. see how anyone can flame about something that is an option and not
  689. enabled unless you want it.  But the important thing is to get this
  690. ability in place so an alternate encoding method can follow the setting.
  691. Typical text compression might be in the 60-70% range using the bandwith
  692. provided by an 8-bit data stream.  The nature of compression is going
  693. to make the character distribution essentially random (otherwise the
  694. compression isn't optimal), so restricting the character set for
  695. transmission is going to take a statistical 1/256th of your efficiency
  696. for every character you disallow, plus the overhead of the mapping. 
  697. There is just no magical way to avoid this.
  698.  
  699. >>Right - we have to assume that the sender knows what he is doing, or at least
  700. >> is capable of learning from the transfer failures when he does it wrong.
  701. >>
  702. > Yes, but...  Can you suggest a method that a mere mortal can follow?
  703.  
  704. Yes - the way you learn everything else: if it hurts, don't do it!
  705.  
  706. It's no more complicated than getting your parity set right or any of
  707. the other things you already have to know.  People are already making
  708. this particular decision, except that instead of telling kermit to
  709. work efficiently they just use a different protocol that is more efficient
  710. by design.  But, programs like C-kermit 5A and the MSDOS 3.11 are so good
  711. that they could handle just about everything else anyone would want to do.
  712. Maybe it would be simpler to just graft a zmodem option into those programs.
  713.  
  714. > Not just ASCII/EBCDIC, but Latin-1, JIS Kanji, etc etc.  We've already figured
  715. > this one out -- it's how mainframe Kermit works.  We're adding compression at
  716. > a level (sort of "high presentation") where this is not an issue (long story).
  717.  
  718. I hope this means that the decompression will be done before the checksum/
  719. CRC is computed so that any screwups will appear as a transmission error
  720. and not go undetected.  I've had this happen with 8-bit quoting with one
  721. end happily gobbling all my "&" characters and converting the next character
  722. and reporting that the transfer went fine.  C source is not a pretty sight
  723. after this happens.  I know you said that this was supposed to be negotiated,
  724. so it was probably an error in the program, but it still should have failed
  725. the transfer instead of reporting success with different file contents at
  726. the other end.
  727.  
  728. > I must say, this is an interesting idea (mixing compressed and uncompressed
  729. > packets) but, no doubt, a lot trickier than it sounds.
  730.  
  731. The only tricky part is that the compressor needs to know about it.  You
  732. couldn't just take the stream from unix compress and do that because
  733. the compression tables are part of the data stream and they adapt to the
  734. data on the fly.  Also, compression code generally builds a bit-stream,
  735. so you might have to fill out to a byte boundary, effectively going through
  736. the motions of ending a file at the compression level and then starting up
  737. from scratch on the next compressable packet.  How complex this is would
  738. depend on the nature of the compression code.  Off the top of my head, though,
  739. I would bet that you could build non-adaptive tables for english text that
  740. would work as well as any adaptive scheme if you simply pass through the
  741. pieces that don't compress.  But, I suppose you need to support other
  742. languages as well so you need some sort of adaptive method.
  743.  
  744. Les Mikesell
  745.   les@fb.com
  746.  
  747. 29-Oct-91 17:06:01-GMT,2579;000000000001
  748. Return-Path: <fdc>
  749. Received: by watsun.cc.columbia.edu (5.59/FCB)
  750.     id AA29982; Tue, 29 Oct 91 12:04:57 EST
  751. Date: Tue, 29 Oct 91 12:04:56 EST
  752. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  753. To: les@fb.com (Les Mikesell)
  754. Subject: Re: Info-Kermit Digest V14
  755. In-Reply-To: Your message of Tue, 29 Oct 91 10:52:50 CST
  756. Message-Id: <CMM.0.90.0.688755896.fdc@watsun.cc.columbia.edu>
  757.  
  758. > I can't argue about the politics, but from a practical point of view, I'd
  759. > rather have the ability to pass the control characters. You are unlikely
  760. > to beat V.42bis compression, and that is increasingly available in the
  761. > modem hardware, and in the cases where it really matters we can always
  762. > pre-compress before transmission.
  763. >
  764. But pre-compression usually only works between like systems, or a small set
  765. of unlike systems (e.g. where "portable zip" runs).  Even then, it doesn't
  766. handle the character set conversions, and often doesn't record format
  767. conversions either, which is why you really want to slip compression into
  768. Kermit's presentation layer after all that has been done.
  769.  
  770. > > Yes, but...  Can you suggest a method that a mere mortal can follow?
  771. > Yes - the way you learn everything else: if it hurts, don't do it!
  772. > It's no more complicated than getting your parity set right or any of
  773. > the other things you already have to know.
  774. >
  775. Well, it's actually much more complicated.  Parity is usually an "on" or
  776. "off" decision; only in rare cases does it actually matter which kind of
  777. (non-none) parity to use.  At most we have 5 choices.  For optimal control
  778. character transparency the user has to test over 60 different characters for
  779. each connection.  That could take hours, since any given test could blow the
  780. connection away.  There goes your efficiency.
  781.  
  782. > I hope this means that the decompression will be done before the checksum/
  783. > CRC is computed so that any screwups will appear as a transmission error
  784. > and not go undetected.
  785. >
  786. Definitely.  The entire packet is not compressed, only the contents of the
  787. data field, and the checksum is computed on the characters that go into the
  788. packet.
  789.  
  790. > I've had this happen with 8-bit quoting with one
  791. > end happily gobbling all my "&" characters and converting the next character
  792. > and reporting that the transfer went fine.
  793. >
  794. Like I said, that's a bug -- it should not happen.  Before C-Kermit 5A is
  795. released, I'll be sure this is working right.
  796.  
  797. > I would bet that you could build non-adaptive tables for english text that...
  798. >
  799. We actually did this once in a pilot project.  But it's a no-no for Kermit.
  800. No anglocentrism allowed.
  801.  
  802. - Frank
  803.  
  804. 29-Oct-91 18:55:14-GMT,4225;000000000005
  805. Return-Path: <afbf05!afbf02!afbf14!les@uunet.UU.NET>
  806. Received: from relay2.UU.NET by watsun.cc.columbia.edu (5.59/FCB)
  807.     id AA02047; Tue, 29 Oct 91 13:55:06 EST
  808. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay2.UU.NET with SMTP 
  809.     (5.61/UUNET-internet-primary) id AA20384; Tue, 29 Oct 91 13:55:09 -0500
  810. Received: from afbf05.UUCP by uunet.uu.net with UUCP/RMAIL
  811.     (queueing-rmail) id 135439.19267; Tue, 29 Oct 1991 13:54:39 EST
  812. Received: id <m0kbyYb-0001I8C@afbf05.fb.com> Tue, 29 Oct 91 13:52 EST
  813. Received: id <m0kbyUM-0001rgC@afbf02.fb.com> Tue, 29 Oct 91 12:48 CST
  814. Received: id <m0kbzQT-0001geC@afbf14.fb.com> Tue, 29 Oct 91 13:48 CST
  815. Message-Id:  <m0kbzQT-0001geC@afbf14.fb.com>
  816. From: les@fb.com (Les Mikesell)
  817. Subject: Re: Info-Kermit Digest V14
  818. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  819. Date: Tue, 29 Oct 91 13:48:32 CST
  820. In-Reply-To: <CMM.0.90.0.688755896.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Oct 29, 91 12:04 pm
  821.  
  822. > But pre-compression usually only works between like systems, or a small set
  823. > of unlike systems (e.g. where "portable zip" runs).
  824.  
  825. Then that's a problem in its own right and should be addressed directly,
  826. perhaps by promoting the use of "zoo" which should be available for
  827. the common ascii machines.
  828.  
  829. > Even then, it doesn't
  830. > handle the character set conversions, and often doesn't record format
  831. > conversions either, which is why you really want to slip compression into
  832. > Kermit's presentation layer after all that has been done.
  833.  
  834. I hesitate to comment on this because I think this belongs elsewhere as
  835. well.  That is, any machine needing file format preservation should have
  836. a way to encapsulate the file into a byte stream and do the reverse. A
  837. file being sent over a communications line may traverse many machines
  838. before it's actually used again.  I'd prefer for the transfer protocol
  839. to transfer the file contents unchanged so that the proper conversions
  840. can be done only at the end point.  For the terminal emulation portion
  841. you need to do it in real time, and you don't have any choice about the
  842. ascii-ebcdic conversions when going through a mainframe front-end, but
  843. files can always be run through a separate conversion.  Isn't that why
  844. we put things in data files in the first place?  Plus there are many
  845. things that you might want to preserve (like the ownership, permissions,
  846. filenames that may not map reversibly on the current machine) that can
  847. only be done by encapsulating the file and attributes for transmission
  848. because intermediate filesystems may not share the same concepts.
  849.  
  850. > Well, it's actually much more complicated.  Parity is usually an "on" or
  851. > "off" decision; only in rare cases does it actually matter which kind of
  852. > (non-none) parity to use.  At most we have 5 choices. 
  853.  
  854. Make that 5 choices at each end, thus 25 possibilities, plus flow control,
  855. plus file type, plus a few other settings that have to be set right just
  856. to get a single file across unchanged.  If you are arguing that kermit
  857. is now simple to use and would be rendered complex by another settable
  858. option, I disagree.  Kermit already has a deserved reputation for being
  859. difficult to use - one settable option more or less isn't going to change
  860. that.
  861.  
  862. > For optimal control
  863. > character transparency the user has to test over 60 different characters for
  864. > each connection.  That could take hours, since any given test could blow the
  865. > connection away.  There goes your efficiency.
  866.  
  867. That's an unlikely worst-case scenario.  In practice, someone will know
  868. if a particular link isn't transparent (and why), and tell the people
  869. using it the proper settings to use.  How long would it take you to
  870. find the right mainframe handshake character?  The same argument would
  871. apply there.  And I still say that people already know this and just
  872. use different protocols without being overwhelmed by complexity.  Ideally,
  873. kermits could be set up to send an attribute packet defining any known
  874. problem characters for the link at start-up (escaped or in hex) but
  875. that would only work for point to point links with computers that have
  876. some concept of which device they are using, so the lack of such an
  877. indication shouldn't automatically mean the link is transparent. 
  878.  
  879. Les Mikesell
  880.   les@fb.com
  881.  
  882. 29-Oct-91 20:21:58-GMT,2050;000000000001
  883. Return-Path: <fdc>
  884. Received: by watsun.cc.columbia.edu (5.59/FCB)
  885.     id AA04080; Tue, 29 Oct 91 15:21:42 EST
  886. Date: Tue, 29 Oct 91 15:21:40 EST
  887. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  888. To: les@fb.com (Les Mikesell)
  889. Subject: Re: Info-Kermit Digest V14
  890. In-Reply-To: Your message of Tue, 29 Oct 91 13:48:32 CST
  891. Message-Id: <CMM.0.90.0.688767700.fdc@watsun.cc.columbia.edu>
  892.  
  893. > > Even then, it doesn't handle the character set conversions, and often
  894. > > doesn't record format conversions either, which is why you really want to
  895. > > slip compression into Kermit's presentation layer after all that has been
  896. > > done.
  897. > I hesitate to comment on this because I think this belongs elsewhere as
  898. > well.
  899. >
  900. Here we're getting into very old arguments.  I'll only say that the notion
  901. of a "common intermediate representation" is essential to all protocols.
  902. Without them, every computer would need knowledge of the formats and codes of
  903. every other kind of computer.
  904.  
  905. > That is, any machine needing file format preservation should have
  906. > a way to encapsulate the file into a byte stream and do the reverse.
  907. > A file being sent over a communications line may traverse many machines
  908. > before it's actually used again.  I'd prefer for the transfer protocol
  909. > to transfer the file contents unchanged so that the proper conversions
  910. > can be done only at the end point.
  911. >
  912. Done, not only by zip/zoo/tar/backup and friends, but also by Kermit's very
  913. own "set file type binary".  You can even have Kermit do record format
  914. conversion but skip the character-set translations: "set file type text", "set
  915. transfer character-set transparent".  The Kermit protocol also has an
  916. "archiving" notion that has never been implemented (basically, saving the
  917. attribute packet along with the data).
  918.  
  919. > ...but files can always be run through a separate conversion.
  920. >
  921. Then if we have n kinds of computers, we need n x (n-1) conversion programs.
  922. Now add a new kind of computer: write a new conversion program for it, and
  923. modify the other n x (n-1) programs to know about it.
  924.  
  925. - Frank
  926.  
  927. 30-Oct-91  3:45:41-GMT,1771;000000000001
  928. Return-Path: <afbf05!afbf02!afbhub!les@uunet.UU.NET>
  929. Received: from relay1.UU.NET by watsun.cc.columbia.edu (5.59/FCB)
  930.     id AA09857; Tue, 29 Oct 91 22:45:35 EST
  931. Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay1.UU.NET with SMTP 
  932.     (5.61/UUNET-internet-primary) id AA03817; Tue, 29 Oct 91 22:45:13 -0500
  933. Received: from afbf05.UUCP by uunet.uu.net with UUCP/RMAIL
  934.     (queueing-rmail) id 224431.10244; Tue, 29 Oct 1991 22:44:31 EST
  935. Received: id <m0kc6pa-0001GUC@afbf05.fb.com> Tue, 29 Oct 91 22:43 EST
  936. Received: id <m0kc6mm-0002M2C@afbf02.fb.com> Tue, 29 Oct 91 21:40 CST
  937. Received: id <m0kc6nD-0005EkC@afbhub.fb.com> Tue, 29 Oct 91 21:40 CST
  938. Message-Id:  <m0kc6nD-0005EkC@afbhub.fb.com>
  939. From: les@fb.com (Les Mikesell)
  940. Subject: Re: Info-Kermit Digest V14
  941. To: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  942. Date: Tue, 29 Oct 91 21:40:32 CST
  943. In-Reply-To: <CMM.0.90.0.688767700.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Oct 29, 91 3:21 pm
  944.  
  945. > > ...but files can always be run through a separate conversion.
  946. > >
  947. > Then if we have n kinds of computers, we need n x (n-1) conversion programs.
  948. > Now add a new kind of computer: write a new conversion program for it, and
  949. > modify the other n x (n-1) programs to know about it.
  950.  
  951. This has nothing to do with the concept of including such conversions
  952. in a file transfer protocol - it could still be done by with a single
  953. program for each machine to handle the local <-> portable conversions.
  954. I don't really want to argue against having those options available
  955. in kermit, but the one thing that can't be done anywhere but in
  956. the communication code is efficiently moving the bytes.  I just think
  957. it is a mistake to let functions that could be done elsewhere interfere
  958. with the thing that can't.
  959.  
  960. Les Mikesell
  961.   les@fb.com
  962.  
  963. 30-Oct-91 10:39:12-GMT,1072;000000000005
  964. Return-Path: <tankus@hsi86.hsi.com>
  965. Received: from hsi86.hsi.com by watsun.cc.columbia.edu (5.59/FCB)
  966.     id AA12825; Wed, 30 Oct 91 05:39:09 EST
  967. Received: by hsi86.hsi.com (5.61+++/1.34)
  968.     id AA28816; Wed, 30 Oct 91 05:34:34 -0500
  969. Message-Id: <9110301034.AA28816@hsi86.hsi.com>
  970. From: tankus@hsi86.hsi.com (Ed Tankus)
  971. Date: Wed, 30 Oct 1991 05:34:33 EST
  972. X-Mailer: Mail User's Shell (7.1.2 7/11/90)
  973. To: fdc@watsun.cc.columbia.edu
  974. Subject: Compresssion for Kermit
  975.  
  976. Frank,
  977.  
  978. You may wish to speak with the author of ARJ, Robert K. Jung.  The ARJ program
  979. is the fastest and best-compression scheme in the DOS world.  Robert has a
  980. C source de-archiver which is very portable and plans to release a C source
  981. simple archiver during 1Q92 when he releases a UNIX flavor of his commercial
  982. product.
  983.  
  984. Robert K. Jung can be reached via email at robjung@world.std.com.  The ARJ
  985. software is available for FTP from simtel20, wuarchive, or me.
  986.  
  987. Hope this helps.
  988.  
  989.  
  990. "For every word, there is a song upon which inspiration lies ...". 
  991. Ed Tankus.   {uunet,yale}!hsi!tankus -- OR -- tankus@hsi.com
  992.  
  993. 30-Oct-91 10:54:57-GMT,1332;000000000005
  994. Return-Path: <rommel@dszenger9.informatik.tu-muenchen.de>
  995. Received: from tuminfo2.informatik.tu-muenchen.de by watsun.cc.columbia.edu (5.59/FCB)
  996.     id AA12906; Wed, 30 Oct 91 05:53:03 EST
  997. Received: from dszenger9.informatik.tu-muenchen.de ([131.159.8.67]) by tuminfo2.informatik.tu-muenchen.de with SMTP id <16914>; Wed, 30 Oct 91 10:57:34 +0100
  998. Received: by dszenger9.informatik.tu-muenchen.de (5.61++/TUMinfo2.5Ni)
  999.     id AA25284; Wed, 30 Oct 91 10:57:30 +0100
  1000. From: Kai Uwe Rommel <rommel@informatik.tu-muenchen.de>
  1001. Reply-To: <rommel@dszenger9.informatik.tu-muenchen.de>
  1002. Message-Id: <9110300957.AA25284@dszenger9.informatik.tu-muenchen.de>
  1003. Subject: Re: [Bo Kullmar <bk@kullmar.se>: C-Kermit for OS/2]
  1004. To: fdc@watsun.cc.columbia.edu
  1005. Date:     Wed, 30 Oct 91 10:57:29 +0100
  1006. In-Reply-To: <CMM.0.90.0.680906442.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Jul 30, 91 4:40 pm
  1007. X-Mailer: ELM [version 2.3 PL11]
  1008.  
  1009. I forgot to mention, I have the compression part of the programs already
  1010. working on 16-bit Microsoft C, only the decompressor fails currently.
  1011. I needed the algorithms for my thesis which I am currently preparing.
  1012.  
  1013. Kai Uwe Rommel
  1014.  
  1015. -- 
  1016. /* Kai Uwe Rommel, Munich ----- rommel@informatik.tu-muenchen.de */
  1017.  
  1018. DOS ... is still a real mode only non-reentrant interrupt
  1019. handler, and always will be.                -Russell Williams
  1020.  
  1021. 30-Oct-91 11:21:29-GMT,1713;000000000005
  1022. Return-Path: <rommel@dszenger9.informatik.tu-muenchen.de>
  1023. Received: from tuminfo2.informatik.tu-muenchen.de by watsun.cc.columbia.edu (5.59/FCB)
  1024.     id AA13067; Wed, 30 Oct 91 06:20:31 EST
  1025. Received: by tuminfo2.informatik.tu-muenchen.de via suspension id <16916>; Wed, 30 Oct 91 10:56:31 +0100
  1026. Received: from dszenger9.informatik.tu-muenchen.de ([131.159.8.67]) by tuminfo2.informatik.tu-muenchen.de with SMTP id <16914>; Wed, 30 Oct 91 10:56:01 +0100
  1027. Received: by dszenger9.informatik.tu-muenchen.de (5.61++/TUMinfo2.5Ni)
  1028.     id AA25262; Wed, 30 Oct 91 10:55:55 +0100
  1029. From: Kai Uwe Rommel <rommel@informatik.tu-muenchen.de>
  1030. Reply-To: <rommel@dszenger9.informatik.tu-muenchen.de>
  1031. Message-Id: <9110300955.AA25262@dszenger9.informatik.tu-muenchen.de>
  1032. Subject: Re: [Bo Kullmar <bk@kullmar.se>: C-Kermit for OS/2]
  1033. To: fdc@watsun.cc.columbia.edu
  1034. Date:     Wed, 30 Oct 91 10:55:54 +0100
  1035. In-Reply-To: <CMM.0.90.0.680906442.fdc@watsun.cc.columbia.edu>; from "Frank da Cruz" at Jul 30, 91 4:40 pm
  1036. X-Mailer: ELM [version 2.3 PL11]
  1037.  
  1038. I don't have news regarding the OS/2 port of C-Kermit. Probably I will
  1039. only have time during christmas.
  1040.  
  1041. On another topic - you are looking for a compression algorithm. You
  1042. could ask Ross Williams for his LZRW-[123][a] programs. They are
  1043. portable C versions, running at 200k/sec to 100k/sec on my 24 MHz 386
  1044. and work blocked, so you can back up in case of transmission errors.
  1045. They currently work on 32-bit machines only, but that can be fixed, I
  1046. think. His address is ross@spam.ua.oz.au.
  1047.  
  1048. Kai Uwe Rommel
  1049.  
  1050. -- 
  1051. /* Kai Uwe Rommel, Munich ----- rommel@informatik.tu-muenchen.de */
  1052.  
  1053. DOS ... is still a real mode only non-reentrant interrupt
  1054. handler, and always will be.                -Russell Williams
  1055.  
  1056. 30-Oct-91 19:38:23-GMT,4639;000000000015
  1057. Return-Path: <jloup@chorus.fr>
  1058. Received: from chorus.chorus.fr by watsun.cc.columbia.edu (5.59/FCB)
  1059.     id AA19569; Wed, 30 Oct 91 14:38:04 EST
  1060. Received: from nocturne.chorus.fr by chorus.chorus.fr, Wed, 30 Oct 91 20:24:44 +0100
  1061. Received: from localhost.chorus.fr by nocturne.chorus.fr, Wed, 30 Oct 91 20:21:58 +0100
  1062. Message-Id: <9110301921.AA11176@nocturne.chorus.fr>
  1063. To: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1064. Cc: INFO-ZIP@CS.UCLA.EDU, Jean-loup Gailly <jloup@chorus.fr>
  1065. Subject: Re: Recent Kermit Protocol Extensions
  1066. Date: Wed, 30 Oct 91 20:21:56 +0100
  1067. From: Jean-loup Gailly <jloup@chorus.fr>
  1068.  
  1069. Frank,
  1070.  
  1071. > The next major effort in Kermit protocol expansion (no commitment
  1072. > expressed or implied!) is the addition of an effective and portable
  1073. > compression method.  We're in the information-gathering phase now.
  1074.  
  1075. I suggest that you use an algorithm in the LZ77 class [Ziv77].
  1076. They are often slower than algorithms of the LZ78 class [Ziv78], but
  1077. generally produce a much better compression ratio. They also require
  1078. less memory, and it is quite easy to set any desired tradeoff
  1079. between speed and compression ratio. In short, the main difference
  1080. between LZ77 and LZ78 is that duplicated strings are designated with
  1081. a (pointer,length) pair in LZ77 and a pointer only in LZ78.
  1082.  
  1083. Algorithms using Markov modeling can get an excellent compression
  1084. ratio but they are slow and eat a lot of memory.
  1085.  
  1086. > The method that is finally chosen must be single-pass,
  1087.  
  1088. zip 1.0 uses two passes, but future versions will have an option
  1089. to use one pass only.
  1090.  
  1091. > in the clear legally (unlike LZW, which is tied up in patent
  1092. > infringement litigation,
  1093.  
  1094. Given the rate at which software patents on data compression are
  1095. currently granted, it will be very soon impossible to write an
  1096. efficient non-patented algorithm. LZ78 has been patented twice and
  1097. several patents on LZ77 have appeared recently. The fastest LZ77
  1098. algorithm, published in particular by Ross Williams in his LZRW
  1099. series, is patented by Gibson and Graybill (U.S. Patent 5,049,881).
  1100. As mentioned by Rich Wales, Phil Katz also obtained a patent on LZ77,
  1101. but surprisingly his algorithm does not seem practical and does
  1102. not cover the simpler technique used in zip, arj and freeze.
  1103.  
  1104. The algorithms used in lha and zoo 2.1 are probably covered by the
  1105. Fiala and Greene patent, but I have not read the patent claims. yabba
  1106. written by Dan Bernstein is free of patents, but requires a lot of
  1107. memory and does not compress as well as the LZ77 compressors.
  1108. whap, also written by Dan Bernstein, is patented by Storer.
  1109. zip, arj, freeze and lharc seem to be free of patents for the moment,
  1110. but Robert Jung (author of arj) has applied for a patent in this area.
  1111.  
  1112. (One correction about LZW: this algorithm is patented by IBM and
  1113. Unisys, but both companies are not actually suing people for using
  1114. Unix 'compress'.)
  1115.  
  1116. > effective for all types of data (7-bit text or 8-bit text
  1117. > in any language, binary executables, numeric data, raster images,
  1118. > etc),
  1119.  
  1120. LZ77 is much better than LZ78 for binary data.
  1121.  
  1122. > For maximum transportability, the result of
  1123. > compression should be a sequence of 7-bit ASCII printable characters
  1124. > (32-126 or a subset of these).
  1125.  
  1126. I think that Kermit should take care of transforming the compressed
  1127. binary data to printable characters. It would be easier to plug in
  1128. existing compression algorithms.
  1129.  
  1130. > Suggestions, pointers to specifications for various methods and
  1131. > analyses of them, etc, would be most appreciated.
  1132.  
  1133. For more details on the compression programs mentioned above, you
  1134. can contact:
  1135.  
  1136. Rahul Dhesi     <dhesi@cirrus.com>            about zoo
  1137. Leonid Broukhis <leo@s514.ipmce.su>           about freeze
  1138. Ross Williams   <ross@spam.ua.oz.au>          about lzrw*
  1139. Dan Bernstein   <brnstnd@kramden.acf.nyu.edu> about yabba
  1140. Y.Tagawa        ???                           about Unix lharc
  1141. myself          <jloup@chorus.fr>             about zip
  1142.  
  1143. zip is currently much faster than its portable LZ77 competitors (zoo,
  1144. freeze, lharc), but zoo compresses slightly better. The non patented
  1145. variants of lzrw should be fast as well, but I have not tested them.
  1146. I don't give references for lha and arj since they only run under
  1147. Msdos and the source code of arj is not available anyway.
  1148. lharc, zip, zoo, and freeze have been posted to comp.sources.misc.
  1149.  
  1150. Jean-loup Gailly
  1151.  
  1152. References:
  1153.  
  1154. [Ziv77] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data
  1155. Compression", IEEE Transactions on Information Theory", Vol. 23, No. 3,
  1156. pp. 337-343.
  1157.  
  1158. [Ziv78] Ziv J., Lempel A., "Compression of Individual Sequences via
  1159. Variable-Rate Coding", IEEE Transactions on Information Theory,
  1160. Vol. 24, No. 5, pp. 530-536.
  1161.  
  1162. 30-Oct-91 20:05:31-GMT,3110;000000000001
  1163. Return-Path: <jloup@chorus.fr>
  1164. Received: from chorus.chorus.fr by watsun.cc.columbia.edu (5.59/FCB)
  1165.     id AA19897; Wed, 30 Oct 91 15:05:17 EST
  1166. Received: from nocturne.chorus.fr by chorus.chorus.fr, Wed, 30 Oct 91 21:03:53 +0100
  1167. Received: from localhost.chorus.fr by nocturne.chorus.fr, Wed, 30 Oct 91 21:01:07 +0100
  1168. Message-Id: <9110302001.AA11323@nocturne.chorus.fr>
  1169. To: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1170. Cc: Jean-loup Gailly <jloup@chorus.fr>
  1171. Subject: Re: Recent Kermit Protocol Extensions 
  1172. In-Reply-To: Your message of Wed, 30 Oct 91 14:42:51 -0500.
  1173.              <CMM.0.90.0.688851771.fdc@watsun.cc.columbia.edu> 
  1174. Date: Wed, 30 Oct 91 21:01:04 +0100
  1175. From: Jean-loup Gailly <jloup@chorus.fr>
  1176.  
  1177. > It is also a little bit discouraging (as to the patents, etc)
  1178.  
  1179. Yes, I am quite upset with these software patents. The US patent
  1180. office is absolutely incompetent to determine obviousness and
  1181. the existence of prior art. Most software patents are invalid
  1182. on both grounds. But the simple threat of a lawsuit is often
  1183. too much for individuals like us, developers of zip. We learned
  1184. about the Phil Katz patent a few days before zip became public and we
  1185. had to study it in detail to convince ourselves that it did not
  1186. cover our implementation.
  1187.  
  1188. > What do you know about V.42bis?  Is it a derivative of one of the
  1189. > patented methods?
  1190.  
  1191. I am afraid so. I think it is LZW. But it is very unlikely that
  1192. Unisys or IBM will do anything about this, because LZW is used
  1193. about everywhere now, and moreover they probably do not want to
  1194. fight each other because both patents apply to the same algorithm.
  1195. Of course the patent office did not see that.
  1196.  
  1197. > Have you seen analyses or benchmarks published anywhere? 
  1198.  
  1199. Benchmarks are regularly published in comp.compression. Ask
  1200. Peter Gutman <pgut1@cs.aukuni.ac.nz> for his latest results,
  1201. because the last posting did not include zip 1.0 which was
  1202. not yet public. I am giving below an extract of a posting I made
  1203. in comp.compression on Oct 7.
  1204.  
  1205. Jean-loup
  1206.  
  1207. -----------------------------------------------------------------------
  1208. Here are some results on the standard text compression corpus
  1209. (the 14 files bib book1 book2 geo news obj1 obj2 paper1 paper2 pic
  1210. progc progl progp trans) available at fsa.cpsc.ucalgary.ca in
  1211. /pub/text.compression.corpus.
  1212.                                            user     system     archive size
  1213.  
  1214. $ time zip    ../corp *                   37.630u  5.750s     1,111,595
  1215.  
  1216. $ time zoo ah ../corp *                   88.070u 12.280s     1,097,258
  1217.  
  1218. $ time lharc a   ../corp *                99.180u  9.720s     1,201,148
  1219.  
  1220. $ tar cf - * | time freeze > ../corp.F   110.590u  9.140s     1,137,586
  1221.  
  1222. So, on large files, zip is more than twice faster than all other unix
  1223. compressors with comparable compression ratio (yabba and compress are
  1224. faster but have much worse compression ratio). zoo has however slightly
  1225. better compression because its archive format is better. (zip cannot
  1226. change its archive format because of the compatibility constraint
  1227. with PKZIP.) The versions used where zip 1.0, zoo 2.1, lharc 1.02
  1228. and freeze 2.2.1, run under SunOS 4.1 on a Sparc.
  1229.  
  1230. 30-Oct-91 20:53:44-GMT,5208;000000000011
  1231. Return-Path: <jloup@chorus.fr>
  1232. Received: from chorus.chorus.fr by watsun.cc.columbia.edu (5.59/FCB)
  1233.     id AA20527; Wed, 30 Oct 91 15:53:27 EST
  1234. Received: from nocturne.chorus.fr by chorus.chorus.fr, Wed, 30 Oct 91 21:51:37 +0100
  1235. Received: from localhost.chorus.fr by nocturne.chorus.fr, Wed, 30 Oct 91 21:48:50 +0100
  1236. Message-Id: <9110302048.AA11583@nocturne.chorus.fr>
  1237. To: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1238. Cc: info-zip@cs.ucla.edu, Jean-loup Gailly <jloup@chorus.fr>
  1239. Subject: zip compression algorithm (was: Info-Zip and compression for Kermit)
  1240. Date: Wed, 30 Oct 91 21:48:48 +0100
  1241. From: Jean-loup Gailly <jloup@chorus.fr>
  1242.  
  1243. Frank da Cruz asks:
  1244.  
  1245. > is there a single document, or at least a small number of files
  1246. > (or books, or papers) where Zip's compression algorithm is
  1247. > presented and analyzed?
  1248.  
  1249. Let me try a short summary. Zip's implosion algorithm finds duplicated
  1250. strings in the input data. The second occurrence of a string is
  1251. replaced by a pointer to the previous string, in the form of a pair
  1252. (distance, length).  Distances are limited to 8K bytes, and lengths
  1253. are limited to 320 bytes. When a string does not occur anywhere in the
  1254. previous 8K bytes, it is emitted as a sequence of literal bytes.
  1255. (In this description, 'string' must be taken as an arbitrary sequence
  1256. of bytes, and is not restricted to printable characters.)
  1257.  
  1258. In the compressed output, literal bytes are distinguished from pointers
  1259. with one leading bit. (This is one of the unfortunate features of the
  1260. zip format, since better formats use less than one bit.)
  1261.  
  1262. Distances and lengths are themselves compressed using Shannon-Fano
  1263. encoding, which is somewhat similar to Huffman coding: frequent values
  1264. are encoded on fewer bits than unlikely values. Literal bytes can
  1265. also be optionally encoded using a Shannon-Fano tree. The Shannon-Fano
  1266. trees are stored in a compacted (but non optimal) form at the head
  1267. of compressed output. zip 1.0 uses a two pass algorithm to determine
  1268. optimal trees, but a single pass algorithm is possible using static
  1269. trees.
  1270.  
  1271. Duplicated strings are found using a hash table. All input strings of
  1272. length 2 (for binary data) or 3 (for ascii data) are inserted
  1273. in the hash table and removed when they fall off the sliding window.
  1274. A hash index is computed for the next 2 or 3 bytes. If the hash
  1275. chain for this index is not empty, all strings in the chain are
  1276. compared with the current input string, and the longest match
  1277. is selected.
  1278.  
  1279. The hash chains are searched starting with the most recent strings,
  1280. to favor small distances and thus take advantage of the Shannon-Fano
  1281. encoding. The hash chains are doubly linked to get fast deletion.
  1282.  
  1283. To avoid a worst case situation, very long hash chains are arbitrarily
  1284. truncated at a certain length, determined by a runtime option (zip -0
  1285. to -9). So zip does not always find the longest possible match but
  1286. generally finds a match which is long enough.
  1287.  
  1288. zip also defers the selection of matches with a lazy evaluation
  1289. mechanism. After a match of length N has been found, zip searches for
  1290. a longer match at the next input byte. If a longer match is found, the
  1291. previous match is truncated to a length of one (thus producing a
  1292. single literal byte) and the longer match is emitted afterwards.
  1293. Otherwise, the original match is kept, and the next match search is
  1294. attempted only N steps later.
  1295.  
  1296. The lazy match evaluation is also subject to a runtime parameter.
  1297. If the current match is long enough, zip does not search for
  1298. a longer match, thus speeding up the whole process. If compression
  1299. ratio is more important than speed, zip attempts a second search
  1300. even the first one is already quite long.
  1301.  
  1302.  
  1303. For small files, zip also tries a completely different algorithm
  1304. called shrink, which is an improvement on the LZW algorithm used in
  1305. the well known 'compress' program. The improvement is to re-use
  1306. leaves of the string tree, instead of erasing the whole tree when
  1307. the compression ratio degrades. As in implosion, the shrinking
  1308. algorithm finds duplicated strings, but it can only finds a subset
  1309. of them, because new strings are inserted in the dictionary only
  1310. at the end of the previous string match. (Implosion inserts a new
  1311. string at every input byte.)
  1312.  
  1313. The decompressor reconstructs the same dictionary as the compressor,
  1314. and is thus able to determine string lengths given a string pointer
  1315. only. So the shrink output is only a sequence of pointers and does not
  1316. include lengths. The pointers are encoded on the minimal number of
  1317. bits required to represent them, but they are not further compressed
  1318. with Huffman or Shannon-Fano encoding.
  1319.  
  1320. Shrinking is not attempted by default on large files because implosion
  1321. is generally better, once the initial cost of storing the Shanon-Fano
  1322. trees is amortized.
  1323.  
  1324. I hope that this little introduction has been helpful. For more
  1325. details about data compression algorithms, I recommend the book
  1326.  
  1327.    Text Compression
  1328.    Timothy C. Bell, John G. Cleary, Ian  H. Witten
  1329.    ISBN 0-13-911991-4
  1330.    Price: approx. US$40, much higher outside the US
  1331.    Publisher: Prentice Hall
  1332.  
  1333. or the review paper
  1334.  
  1335.    Modeling for Text Compression
  1336.    Timothy C. Bell, Ian  H. Witten, John G. Cleary
  1337.    ACM computing surveys, Vol 21, No 4, Dec 1989, p557-591
  1338.  
  1339. Jean-loup
  1340.  
  1341. 31-Oct-91  3:05:17-GMT,3931;000000000411
  1342. Return-Path: <thobe@getunx.info.com>
  1343. Received: from RUTGERS.EDU by watsun.cc.columbia.edu (5.59/FCB)
  1344.     id AA24528; Wed, 30 Oct 91 22:05:13 EST
  1345. Received: from usc.UUCP by rutgers.edu (5.59/SMI4.0/RU1.4/3.08) with UUCP 
  1346.     id AA16340; Wed, 30 Oct 91 20:50:57 EST
  1347. Received: from srhqla.UUCP by usc.edu (5.64+/SMI-3.0DEV3) from user uucp id AA18977; 
  1348.                 Wed, 30 Oct 91 17:16:29 PST
  1349. Received: by srhqla.SR.COM (5.51/smail2.5/12-06-88)
  1350.     id AA01857; Wed, 30 Oct 91 16:50:11 PST
  1351. Received: from somewhere by avatar.com id aa15393; Wed, 30 Oct 91 16:23:11 PST
  1352. Received: by getunx.info.com (5.58/smail2.5/09-28-87)
  1353.     id AA04026; Wed, 30 Oct 91 16:26:32 PST
  1354. Date: Wed, 30 Oct 91 16:26:32 PST
  1355. From: "Glenn E. Thobe" <thobe@getunx.info.com>
  1356. Message-Id: <9110310026.AA04026@getunx.info.com>
  1357. To: fdc@watsun.cc.columbia.edu
  1358. Subject: Re: Recent Kermit Protocol Extensions
  1359.  
  1360. Frank-
  1361.  
  1362. Thank you for your detailed reply of 25 Oct 91 to my letter
  1363. regarding proposed Kermit extensions, namely compression.
  1364.  
  1365. On the issue of whether the compressed data should be able to 
  1366. use the upper ASCII printables when available, a quick calculation 
  1367. reveals that using the extra codes adds about 15% to the channel 
  1368. capacity, i.e. not using them increases the message size by 15%.
  1369. (log 192 / log 96 = 1.15)  That's 15% extra cost no matter how
  1370. good the compression.
  1371.  
  1372. >> P.S. Bravo for your pioneering internationalization efforts!
  1373.  
  1374. >Thanks!  (Do you use this stuff yourself?)
  1375.  
  1376. I do a lot of Cyrillic text processing on my 3b1/UnixPC.  I have even
  1377. built a Russian TeX.  As for Cyrillic data communications, I'm pretty
  1378. much limited to network e-mail just because there is no one to exhange
  1379. texts with via Kermit.  I am hoping that when 8-bit mailers become
  1380. universal, ISO 8895 (-5 for Cyrillic) will become the standard of 
  1381. exchange as you have made it for Kermit.  For now, it seems impossible 
  1382. to get two people to agree on the same Cyrillic transliteration.  I found
  1383. the articles in issue 4 of your Kermit mailout regarding Kermit in Russia 
  1384. and internationalization to be quite informative.  (I haven't gotten #5 
  1385. yet, the announcement said if you got #4, they would send #5 automatically.)
  1386.  
  1387. >> P.P.S. What can be done to get the most popular BBS's to support Kermit?
  1388.  
  1389. >Beats me.  Maybe as BBS's become popular outside the USA -- where
  1390. >(inter)national character set conversion is important and 8-bit transparency
  1391. >cannot be assumed (because of the PTTs) -- we'll see more Kermit support in
  1392. >BBS software.
  1393.  
  1394. Chuck Forsberg has had pretty much success getting BBS's to use his Z-modem.
  1395. And he doesn't have a world-wide army of volunteers like Kermit does.
  1396. He even charges money for his product.  I think part of the reason is that
  1397. Kermit has gotten a rep for being slow partly because of this prefixing
  1398. issue, and for other reasons which have been fixed, but people don't
  1399. know it yet.
  1400.  
  1401. A stripped MS-Kermit for remote use on BBS's, if such doesn't already 
  1402. exist, would help, along with specific information on how to install it 
  1403. on the major BBS systems (FIDO, Waffle, etc.).  By stripped I mean no 
  1404. terminal emulation facilities (e.g. rz/sz), do everything from the command 
  1405. line.  Most BBS's give you a choice of protocols, and it shouldn't be hard 
  1406. to make one of them Kermit.  The designers and purveyors of BBS systems 
  1407. could be approached directly.  I don't see a lot of technical obstacles here.  
  1408. Maybe a note in info-kermit would be sufficient to mobilize the forces.
  1409.  
  1410. When I encounter a BBS that doesn't support Kermit, I first proselytize
  1411. the sysop.  Often they are interested, but I don't know exactly what to
  1412. say to them other than to start explaining about the WATSUN archive,
  1413. the Kermit books, the universality of Kermit implementations, the
  1414. importance of getting a current release, etc.
  1415.  
  1416. Then I escape to my local Kermit and "!rz" to download files.  (It's 
  1417. easier to swim around a rock than through it.)
  1418.  
  1419. -Glenn <getunx!thobe@uunet.uu.net>
  1420.  
  1421. 31-Oct-91 16:19:02-GMT,728;000000000001
  1422. Return-Path: <mtune>
  1423. Received: by watsun.cc.columbia.edu (5.59/FCB)
  1424.     id AA01558; Thu, 31 Oct 91 11:19:01 EST
  1425. Date: Thu, 31 Oct 91 11:19:01 EST
  1426. From: Peter Mauzey <mtune>
  1427. Message-Id: <9110311619.AA01558@watsun.cc.columbia.edu>
  1428. To: fdc
  1429.  
  1430. Frank -  (from Peter Mauzey)   October 31, 1991
  1431.  
  1432. Regarding V.42bis being "in the clear," there is no doubt that Microcom,
  1433. which claims to represent UNISYS, has asserted that the technology
  1434. represented by V.42bis is covered by U.S. Patent 4,558,302.
  1435.  
  1436. The contact at Microcom (VP Technology Planning) is Gregory Pearson,
  1437. 818-986-4212, last I heard (Sherman Oaks, CA).
  1438.  
  1439. My Department's representatives to the CCITT are now overseas but I
  1440. will ask them when they return "what's new" with V42bis.
  1441.  
  1442.  4-Nov-91  6:19:26-GMT,1485;000000000001
  1443. Return-Path: <brnstnd@KRAMDEN.ACF.NYU.EDU>
  1444. Received: from KRAMDEN.ACF.NYU.EDU by watsun.cc.columbia.edu (5.59/FCB)
  1445.     id AA15188; Mon, 4 Nov 91 01:19:25 EST
  1446. Received: from LOCALHOST by KRAMDEN.ACF.NYU.EDU (5.61/1.34)
  1447.     id AA17921; Mon, 4 Nov 91 06:19:23 GMT
  1448. Message-Id: <9111040619.AA17921@KRAMDEN.ACF.NYU.EDU>
  1449. To: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1450. Cc: brnstnd@nyu.edu
  1451. Subject: Re: Compression 
  1452. In-Reply-To: Your message of Mon, 28 Oct 91 14:21:04 EST.
  1453.              <CMM.0.90.0.688677664.fdc@watsun.cc.columbia.edu> 
  1454. Date: Mon, 04 Nov 91 01:19:21 +0000
  1455. From: brnstnd@KRAMDEN.ACF.NYU.EDU
  1456.  
  1457. In message <CMM.0.90.0.688677664.fdc@watsun.cc.columbia.edu> you write:
  1458. > Pointers to specifications, analyses, etc, would be much appreciated.
  1459. > Thanks!
  1460.  
  1461. You should pick up my yabbawhap package, comp.sources.unix volume 24.
  1462. The yabba part uses Y coding, which is described in a paper included
  1463. with the package and which is free of patents. Y is an LZ variant which
  1464. generally outperforms compress by 10-20%; on English text it usually
  1465. beats even zip, lharc, freeze, and other LZ-Huffman hybrids. I'm working
  1466. on dabba, which applies a statistical coder to the output of Y coding
  1467. and which so far appears to be competitive with PPMC, the most effective
  1468. known compression method. (PPMC's problem is that it's awfully complex
  1469. to implement and rather slow.) In the meantime, yabba is public-domain.
  1470. Feel free to use it. Last I heard the GNU project was switching to yabba
  1471. from compress.
  1472.  
  1473. ---Dan
  1474.  
  1475.  4-Nov-91 14:48:12-GMT,897;000000000001
  1476. Return-Path: <jloup@chorus.fr>
  1477. Received: from chorus.chorus.fr by watsun.cc.columbia.edu (5.59/FCB)
  1478.     id AA18341; Mon, 4 Nov 91 09:47:39 EST
  1479. Received: from nocturne.chorus.fr by chorus.chorus.fr, Mon, 4 Nov 91 15:46:13 +0100
  1480. Received: from localhost.chorus.fr by nocturne.chorus.fr, Mon, 4 Nov 91 15:43:13 +0100
  1481. Message-Id: <9111041443.AA21073@nocturne.chorus.fr>
  1482. To: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1483. Cc: Jean-loup Gailly <jloup@chorus.fr>
  1484. Subject: v42bis
  1485. In-Reply-To: Your message of Wed, 30 Oct 91 14:42:51 -0500.
  1486.              <CMM.0.90.0.688851771.fdc@watsun.cc.columbia.edu> 
  1487. Date: Mon, 04 Nov 91 15:43:12 +0100
  1488. From: Jean-loup Gailly <jloup@chorus.fr>
  1489.  
  1490. > What doyou know about V.42bis?
  1491.  
  1492. The specification is available by anonymous ftp at bruno.cs.colorado.edu
  1493. in pub/standards/ccitt/1992/v/v42bis.asc. It is indeed the shrink
  1494. algorithm used in zip, and derived from LZW.
  1495.  
  1496. Jean-loup
  1497.  
  1498. 14-Nov-91 17:57:26-GMT,10517;000000000005
  1499. Return-Path: <PK6811S@ACAD.DRAKE.EDU>
  1500. Received: from DRAKE.EDU by watsun.cc.columbia.edu (5.59/FCB)
  1501.     id AA22990; Thu, 14 Nov 91 12:57:19 EST
  1502. Received: from DRAKE.BITNET by DRAKE.BITNET (PMDF #12569) id
  1503.  <01GCXSH8PZ280012TQ@DRAKE.BITNET>; Thu, 14 Nov 1991 11:58 CST
  1504. Date: Thu, 14 Nov 1991 11:58 CST
  1505. From: PK6811S@ACAD.DRAKE.EDU
  1506. Subject: Kermit Compression Experiments
  1507. To: fdc@watsun.cc.columbia.edu
  1508. Message-Id: <01GCXSH8PZ280012TQ@DRAKE.BITNET>
  1509. X-Envelope-To: fdc@watsun.cc.columbia.edu
  1510. X-Vms-To: IN%"fdc@watsun.cc.columbia.edu"
  1511.  
  1512. One more weekend volunteer reporting in.
  1513. Let's keep it simple, and let's try it out to see what happens.  My experiment
  1514. uses run-length and 'Huffman' coding.  I'm no expert on the differences 
  1515. between Huffman and Shannon-Fano coding, but I understand the principle
  1516. of using short codes for frequently-occuring characters.
  1517.  
  1518. I had a go at writing a program on the Mac which reduce the number
  1519. of transmitted characters significantly.  I used four test files:
  1520.         DuTermSource    - tokenized zbasic source code (terminal emulator)
  1521.                         - has lots of text, with some 8-bit
  1522.         Kingdon200      - 200 dpi 2x2 scan of 8.5 by 14 document
  1523.         Excel.mb        - Microsoft Excel program converted by Macbinary
  1524.                         - program to one data fork
  1525.         Crashbang       - sound file
  1526.  
  1527.     Following are my results, given in 1024 bytes. Transmit sizes include packet
  1528. headers and blockcheck, with packetlength=1000.  Repeat prefixing was allowed in
  1529. all cases.
  1530.  
  1531.                       WITHOUT COMPRESSION         ! WITH COMPRESSION
  1532.                  ! ----------------------------------------------------
  1533.                  !  Original    8bit      7bit    !   8bit      7bit
  1534.                  !    File    Transmit  Transmit  ! Transmit  Transmit
  1535.     File         !    Size      Size      Size    !   Size      Size
  1536.     ----         !  --------  --------  --------  ! --------  --------
  1537.     DuTermSource !     255       273       299    !    210       245
  1538.     Kingdon200   !     262       439       521    !    216       252
  1539.     Excel.mb     !     729      1010      1202    !    777       907
  1540.     Crashbang    !      46        68        90    !     46        53
  1541.  
  1542.  
  1543.     I'll summarize my algorithm, then give the details and reasoning.
  1544. But first, we must understand the concept of a compression window.  This
  1545. is a fixed number of input characters considered together for compression.
  1546. The window size can be smaller, equal to, or greater than the packet length;
  1547. for my tests, the window size was 256 with the packet length 1000
  1548.  
  1549.     Summary of Algorithm:
  1550.         1.  Apply run-length encoding to enough input characters to fill
  1551.             a window.  Somewhat like kermit's repeat-prefixing.
  1552.         2.  Convert window to 'Huffman' codes
  1553.         3.  Update Huffman code tables
  1554.         4.  Convert window to printable characters 
  1555.         5.  Accumulate enough windows to fill a packet.
  1556.  
  1557.  
  1558. RUN-LENGTH ENCODING:
  1559.  
  1560. Any character 'c' repeating from 5 to 255 times is replaced with c:r:n,
  1561. where c is the character, r is the repeat-flag character, and
  1562. n is the number of characters replaced.  When the repeat-flag character is
  1563. encountered, it is replaced with r:0.  When decoding, when the repeat-flag is
  1564. found, first check the next character for count.  If count is zero, then 
  1565. output the repeat-flag character, else output 'count' number of the previously
  1566. decoded character.
  1567.     
  1568. Usually this pass will compress the input data somewhat, and can be very
  1569. effective against certain kinds of files, or portions of files.  It is possible
  1570. in cases where there are few or no repeating characters, and many occurances
  1571. of the repeat-flag character that this will actually add to the input size.
  1572. It might be possible to choose either the encoded or the unencoded version
  1573. of the window, appropriately flagged, and pass that to step 2, to prevent
  1574. undue expansion of the file, but I did not do that in my tests.
  1575.  
  1576. HUFFMAN CODING
  1577.  
  1578. Huffman coding allows the most frequently occuring characters to be replaced
  1579. by short (< 8 bits) codes, and less frequently occuring ones to be
  1580. replaced by long (= or > 8 bits) codes.  For example, if hex 00 might be
  1581. the most frequently occuring character, then every hex 00 should be replaced
  1582. by the shortest possible code.  We first construct a table of codes, from
  1583. shortest to longest, my table is as follows:
  1584.  
  1585.     binary    1xxxx     - the 16 most frequent characters
  1586.     binary   01xxxxx    - the next 32 most frequent characters
  1587.     binary  001xxxxxx   - the next 64 most frequent characters
  1588.     binary  000xxxxxxxx - the rest
  1589.  
  1590. To decode, check the next bit, bit1.
  1591.     If bit1 = 1
  1592.         decode the first group from the next 4 bits
  1593.     else
  1594.         check the next bit, bit2
  1595.         if bit2 = 1
  1596.             decode the second group from the next 5 bits
  1597.         else
  1598.             check the next bit, bit3
  1599.             if bit3 = 1
  1600.                 decode the third group from the next 6 bits
  1601.             else
  1602.                 decode the fourth group from the next 8 bits.
  1603.  
  1604. This produces a stream of bits which should be much shorter than the original
  1605. input data where every character is represented by 8 bits.
  1606.  
  1607.  
  1608.  
  1609. UPDATE HUFFMAN CODE TABLES
  1610.  
  1611. It is important to identify the most frequently occuring characters.  Therefore
  1612. we count the occurances of each character in the window, and sort them from
  1613. highest-count to lowest.  This becomes the table used in encoding the next
  1614. window.  Here is an important concept.  The receiver can't decode a window
  1615. without having the same table that the sender used, therefore the table must
  1616. be based on the previous window.  Hopefully, the distribution of characters
  1617. doesn't change much from one window to the next.  There will be instances
  1618. in the data where changes occur, but there should be long stretches where
  1619. they don't.
  1620.  
  1621. As a side note, I found that the efficiency of the sort algorithm was a
  1622. limiting factor in speed of processing.  A simple bubble sort slowed the
  1623. compression program terribly, and required changing to a shell-sort which
  1624. with some tuning gave satisfactory results.
  1625.  
  1626.  
  1627. CONVERT WINDOW TO PRINTABLE CHARACTERS
  1628.  
  1629. Huffman coding leaves us with a stream of bits stored in 8-bit bytes.  We
  1630. now must make them kermit-legal to avoid eight-bit and control prefixing.
  1631. Alas, now is where we give up much of our hard-won compression.
  1632.  
  1633. If we are using a 7-bit channel, I simply take 6 bits at a time - giving
  1634. values hex 00 to hex 3f, and add hex 20 to them to make an 8-bit character
  1635. whose values lie between hex 20 and hex 5f, inclusively, corresponding to 
  1636. printable characters, space through underscore.
  1637.  
  1638. If we are using an 8-bit channel, I take 7 bits at a time - giving values
  1639. hex 00 to hex 7f.  For values hex 00 to hex 3f, I add hex 20 as above.  
  1640. For values hex 40 to hex 7f, I add hex a0 to place them into the 8-bit 
  1641. versions of the same characters, space through underscore.
  1642.  
  1643. These conversions give characters which require no prefixing for transmission.
  1644.  
  1645.  
  1646. MAKE UP A PACKET
  1647.  
  1648. Now we simply accumulate windows until we have a full packet, append the
  1649. appropriate packet header and block-check, and write the packets to our
  1650. output file.  Now we encounter a problem of granularity.  If our window
  1651. size is not a factor of our packet size, we will not be able to fill each
  1652. packet to the maximum allowable size.  Consider this example:  our packet
  1653. size is 1000 and our window size is 256.  After Huffman coding and printable-
  1654. conversion, we could produce a series of windows sized 200, 190, 210, 220, 230.
  1655. The first four windows add up to 820, adding the fifth gives 1050.  Our
  1656. actual average packet size will then be somewhat smaller than that allowable,
  1657. creating additional overhead.
  1658.  
  1659. I did not follow up on this problem, but some method which allows windows
  1660. to span packets may be applied.
  1661.  
  1662.  
  1663. CONCLUSION AND SUGGESTIONS
  1664.  
  1665. My experiments show that a reduction of transmitted characters is possible,
  1666. up to about 50%.  The coding needed is on the order of that required for
  1667. kermit-windows (which makes me think I need to find another name for these
  1668. compression 'windows').
  1669.  
  1670. There is a way to make a further reduction in characters.  You will notice
  1671. that this program doesn't output printable characters in the range hex 60 to
  1672. hex 7e.  Now whenever we have unused character values we should consider how
  1673. to use them to pass information that aids our compression.  Let's say we
  1674. output a hex 40 (space).  We could just as well output a hex 60 "`" - if
  1675. the receiver understood that it really was a hex 40, cleverly encoded to
  1676. flag some kind of information.  So a space is either hex 40 or hex 60, the
  1677. flag is either up or down, on or off, zero or one.  If we have a series of
  1678. such flags we can construct a stream of bits out of them;  and when we have
  1679. accumulated enough bits to make a character, we insert that character in 
  1680. the decoded stream.  Over a 7-bit channel we are taking our huffman stream
  1681. in 6-bit chunks, so that we need 6 flags to insert a character.  Over an
  1682. 8-bit channel we need 7 flags.  Since half of our input characters,
  1683. hex 40 to hex 5e, can serve as flags we can insert a character for every
  1684. 12 or 14 transmitted characters on the average - reducing our transmittal
  1685. by one-twelfth or one-fourteenth
  1686.  
  1687. There is also another approach to Huffman tables.  Rather than sort characters
  1688. by their frequency in the window, we can take advantage of the natural
  1689. assocation of one character to another.  For example, in English text, the
  1690. letter 'd' may be the most frequent character to follow the letter 'e', and
  1691. the letter 'u' is certainly the most frequent character to follow
  1692. the letter 'q'.  If 'd' follows 'e' in the input, it should be replaced by
  1693. the shortest possible code, regardless of how many 'd's appear in the window.
  1694. And 'u' following 'q' should be replaced by the same shortest possible code.
  1695. To do this, we keep a table of counts of characters occuring after one 
  1696. another, and sort each character's 'follower table' separately.  The receiver,
  1697. having constructed the same tables, knows that the same code following an 'e',
  1698. means 'd', but after a 'q', means 'u'.  Unfortunately this implies a large
  1699. table, at least 256 by 256 bytes, plus lots of sort time.  I did not attempt
  1700. this experiment, but someone may be able to find an efficient implementation.
  1701.  
  1702. Hope this is helpful.  A lot of us would like to see shorter file transmission
  1703. times.  
  1704.  
  1705. Paul D. Kline
  1706. Associate Director of Adminstrative Computing
  1707. Drake University
  1708. Des Moines, IA  50311
  1709. (515)271-2166
  1710. internet pk6811s@acad.drake.edu
  1711.  
  1712. 15-Nov-91 20:46:42-GMT,714;000000000005
  1713. Return-Path: <mtdcc!ptm@mtune.att.com>
  1714. Received: from att.att.com by watsun.cc.columbia.edu (5.59/FCB)
  1715.     id AA10254; Fri, 15 Nov 91 15:46:29 EST
  1716. Message-Id: <9111152046.AA10254@watsun.cc.columbia.edu>
  1717. From: mtdcc!ptm@mtune.att.com
  1718. Date: Fri, 15 Nov 91 15:42 EST
  1719. To: fdc@watsun.cc.columbia.edu
  1720.  
  1721. Frank -  (from Peter Mauzey)   November 15, 1991
  1722.  
  1723. A little more about V.42bis.  In addition to UNISYS claiming a
  1724. relevant patent, British Telecom claims the algorithm was the
  1725. subject of a UK patent application GB 8815978 filed 5th July 1988.
  1726.  
  1727. Our representative to the standards organizations says that
  1728. companies that use V.42bis will have to pay an amount that is
  1729. separately negotiated with each company.
  1730.  
  1731. Bye for now.
  1732.  
  1733. 16-Nov-91 20:56:15-GMT,3212;000000000001
  1734. Return-Path: <fdc>
  1735. Received: by watsun.cc.columbia.edu (5.59/FCB)
  1736.     id AA22451; Sat, 16 Nov 91 15:56:05 EST
  1737. Date: Sat, 16 Nov 91 15:56:05 EST
  1738. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1739. To: PK6811S@ACAD.DRAKE.EDU
  1740. Subject: Re: Kermit Compression Experiments
  1741. In-Reply-To: Your message of Thu, 14 Nov 1991 11:58 CST
  1742. Message-Id: <CMM.0.90.0.690324965.fdc@watsun.cc.columbia.edu>
  1743.  
  1744. Paul, many thanks for your message!  It's a good idea, too.  I had always
  1745. thought of Huffman encoding as a two-pass process if we were to develop an
  1746. ideal key for a particular file, but your idea (let me see if I understand it
  1747. right) is to read the first chunk ("window"), get the byte frequencies and
  1748. compute the key, send the first chunk uncompressed, then use the first chunk's
  1749. key to encode and send with the second chunk, etc.
  1750.  
  1751. A refinement on this might be: read a chunk, get the frequencies, construct
  1752. the key, send the key with its own chunk.  This assumes we can keep a whole
  1753. chunk in memory.  But in most cases we do that anyway -- most Kermit programs
  1754. read data from the input file into a buffer, a fairly long piece at a time --
  1755. so now we just make a pass over the input buffer to compute the frequencies
  1756. before compressing the data putting it in the packet.
  1757.  
  1758. How do you encode and transmit the key?  I assume the key would be 256 bytes
  1759. long, before Kermit encoding.  Later, in an example, you mention a window size
  1760. of 256.  This means the key for a window is as long as the window itself.
  1761. Obviously we need either a compact way of transmitting the key, or a much
  1762. bigger window size, or both.  Tricky business, because we have memory and
  1763. addressing limitations to cope with on small machines -- so we'd need to have
  1764. two compression-capable Kermit programs negotiation the compression chunk
  1765. size.  If it is too small, compression won't pay off.
  1766.  
  1767. I agree there is no reason why compression chunks and packet boundaries need
  1768. to have anything to do with each other.  We just need a way of distinguishing
  1769. the key from the compressed data in the packet -- easy to do, using either
  1770. length fields or flagging via unused characters as you suggested.
  1771.  
  1772. Another refinement would be to make better use of the GL and GR character code
  1773. space by "tighter packing", using, say, base 94 (or 188) rather than 64 (or
  1774. 128).
  1775.  
  1776. I'm not sure that second-or-higher-order analysis of the data (for pairs,
  1777. triplets, etc) would be worthwhile -- as you point out, we'd need at least a
  1778. 64K byte (or word!) table, lots of sorting, etc.  Maybe in 10 years, when CPU
  1779. speed and memory are no longer the bottlenecks.  More detailed analysis and
  1780. testing will tell (higher-order analysis is comparable to the string-matching
  1781. approach used by LZW, V.24bis, and friends -- all of which are patented).
  1782.  
  1783. Anyway, the final results of your tests are definitely better than today's
  1784. Kermit, achieving up to a 100% savings in transmission time -- nothing to
  1785. sneeze at.  Your method is simple, easy to understand and program, relatively
  1786. compact in memory requirements, and best of all it is clear of the kind of
  1787. legal hassles impinging on all the fancier LZW-class (string-based)
  1788. algorithms.  It's very much worth considering, and much appreciated.  Thanks!
  1789.  
  1790. - Frank
  1791.  
  1792. 21-Nov-91 21:48:30-GMT,900;000000000001
  1793. Return-Path: <mtdcc!ptm@mtune.att.com>
  1794. Received: from att.att.com by watsun.cc.columbia.edu (5.59/FCB)
  1795.     id AA06760; Thu, 21 Nov 91 16:48:24 EST
  1796. Message-Id: <9111212148.AA06760@watsun.cc.columbia.edu>
  1797. From: mtdcc!ptm@mtune.att.com
  1798. Date: Thu, 21 Nov 91 16:31 EST
  1799. To: fdc@watsun.cc.columbia.edu
  1800.  
  1801. Frank -  (from Peter Mauzey)   November 21, 1991
  1802.  
  1803. Regarding file compression, here's a quote: "Using the 'implode' public
  1804. domain compression algorithm that is optimized for speed rather than
  1805. compression, we were able to achieve speed-ups ranging from 18% to 85%
  1806. on the transfer of a variety of files, varying from 70 kbytes to 1.1
  1807. Mbytes."
  1808.  
  1809. That's from "Software Technology for Wireless Mobile Computing" by
  1810. Daniel Duchamp, Steven K. Feiner, and Gerald Q. Maguire, Jr., in the
  1811. November 1991 IEEE Network magazine (ISSN 0890-8044).  Page 17.
  1812.  
  1813. All three authors are at Columbia, Computer Science Department.
  1814.  
  1815. 22-Nov-91  1:34:03-GMT,7604;000000000001
  1816. Return-Path: <PK6811S@ACAD.DRAKE.EDU>
  1817. Received: from DRAKE.EDU by watsun.cc.columbia.edu (5.59/FCB)
  1818.     id AA09431; Thu, 21 Nov 91 20:33:52 EST
  1819. Received: from DRAKE.BITNET by DRAKE.BITNET (PMDF #12569) id
  1820.  <01GD7YJJ66N4000625@DRAKE.BITNET>; Thu, 21 Nov 1991 18:40 CST
  1821. Date: Thu, 21 Nov 1991 18:40 CST
  1822. From: PK6811S@ACAD.DRAKE.EDU
  1823. Subject: Re: Kermit Compression Experiments
  1824. To: fdc@watsun.cc.columbia.edu
  1825. Message-Id: <01GD7YJJ66N4000625@DRAKE.BITNET>
  1826. X-Envelope-To: fdc@watsun.cc.columbia.edu
  1827. X-Vms-To: BITNET%"fdc@watsun.cc.columbia.edu"
  1828.  
  1829. Frank, you're welcome.  With regard to transmitting the key - I don't.  I start
  1830. with a default key, then each chunk is encoded using the key calculated from
  1831. the previous chunk.  Here's an attempt at  diagramming:
  1832.  
  1833. For the sender:
  1834.  
  1835.     chunk1  +  key0 -> encode1
  1836.     chunk1  -> key1
  1837.     chunk2  +  key1 -> encode2
  1838.     chunk2  -> key2
  1839.     chunk3  +  key2 -> encode3
  1840.     chunk3  -> key3
  1841.       . . .
  1842.       . . .
  1843.       . . .
  1844.     encode1 thru encodeX are blocked into packets and transmitted.
  1845.  
  1846. For the receiver:
  1847.  
  1848.     encode1  +  key0 -> chunk1
  1849.     chunk1   -> key1
  1850.     encode2  +  key1 -> chunk2
  1851.     chunk2   -> key2
  1852.     encode3  +  key2 -> chunk3
  1853.     chunk3   -> key3
  1854.       . . .
  1855.       . . .
  1856.       . . .
  1857.  
  1858. It's obvious that each key is non-optimal for any given chunk of data,
  1859. because it is derived from the previous chunk, however, my Huffman codes
  1860. are not so tight as to make much difference.  The first 16 characters are
  1861. all coded in 5 bits, the next 32 in 7 bits, etc., so if any character is 
  1862. one or two positions off - there won't be much loss of efficiency.  This
  1863. works well when there are long stretches of homogeneous data.  When there
  1864. is a change in type, like in the resource fork of a Macintosh program with
  1865. pics, sounds, text strings, and executable code - there will be 
  1866. inefficient coding for the first chunk of each different stretch, then
  1867. the key will adapt and be correct for subsequent chunks.
  1868.  
  1869. Now, if you were to compute an optimal key for a chunk, by counting the
  1870. frequencies therein, you would need to send the key.  You wouldn't need
  1871. to send the last group of characters (144 count), so you would only
  1872. be sending the first 112 characters.  Or you might only send the
  1873. changes in the key... Char(i)+Newposition(i).
  1874.  
  1875. -----------------------------------------------------------------------
  1876. After sending you those results, I made two tweaks to the program.
  1877. First, I changed the key calculation routine slightly, to allow it to
  1878. ride over rough parts in the data without disrupting the keys completely
  1879. for the next chunk.  Instead of zeroing out the count for each
  1880. character, I simply divide the previous count by 2 (shift right 1).  This
  1881. allows some 'memory' of previous chunks and prevents a frequently-
  1882. recurring character from going to the end of the table just because it
  1883. was left out for a short stretch.
  1884.  
  1885. Second, I divided the fourth group of 144 characters into two groups, so
  1886. that my Huffman codes now look as follows:
  1887.  
  1888.    binary     1xxxx     -  1st 16 characters
  1889.    binary    01xxxxx    - next 32 characters
  1890.    binary   001xxxxxx   - next 64 characters
  1891.    binary  0001xxxxxx   - next 64 characters
  1892.    binary  0000xxxxxxx  - next 80 characters
  1893.  
  1894. The fourth group is now encoded in 10 bits instead of 11 as before.
  1895.  
  1896. With these two changes, I ran the compression against some of the previous
  1897. files:  (all are 8bit)
  1898.  
  1899.                before          after
  1900. File           tweak           tweak
  1901. ----           ------          ------
  1902. DuTermSource    210             207
  1903. Kingdon200      216             214
  1904. Crashbang        46              45
  1905.  
  1906. I tried the program against the text compression corpus available at
  1907. fsa.cpsc.ucalgary.ca in /pub/text.compression.corpus.  This time I
  1908. monitored the total size of chunks after Huffman encoding as well as
  1909. the total size after kermit-legal expansion:
  1910.  
  1911.         Huffman-    Kermit-    Original
  1912.         Encoded    Transmit      File
  1913. File     Size        Size        Size
  1914. ----    -------     ------     --------
  1915. bib       80375      92806      111261
  1916. book1    517426     601001      768771
  1917. bbok2    416858     483608      610856
  1918. geo       86897     100230      102400
  1919. news     265430     308191      377109
  1920. obj1      15486      16861       21504
  1921. obj2     195992     226658      246814
  1922. paper1    36699      41581       53161
  1923. paper2    55451      63852       82199
  1924. pic       79312      91365      513216
  1925. progc     28243      31960       39611
  1926. progl     46402      53255       71646
  1927. progp     32737      37227       49379
  1928. trans     67333      77783       93695
  1929. -----   -------    -------     -------
  1930. total   1924641    2226378     3141622
  1931.  
  1932. Some comments:
  1933. - First, no file transmit size was larger than it's
  1934. original size, though 'geo' was pretty close.  This bodes well for applying
  1935. the algorithm in practice.
  1936. - Second, the expansion from Huffman to transmit size is right at 16%
  1937. for all files, which is due to the data-independent algorithm.
  1938. - Third, the amazing result for the file 'pic' can be explained by the
  1939. existence of long strings of repeated characters which were reduced through
  1940. run-length encoding.
  1941. - Fourth, these results can be compared with those given by Jean-loup Gailly
  1942. for zip, zoo, lharc, and tar - whose archive totals ranged from 1097258 to
  1943. 1201148.  They are much smaller, but he did not give the transmit sizes for
  1944. those archives, which is the real comparison.
  1945.  
  1946. ----------------------------------------------------------------------
  1947. As to the question of long input buffers and such, I tried chunks as large
  1948. as 4k, but the compression varied from slightly worse to slightly better,
  1949. on the order of 1% difference from the 256-byte chunks.  Reason this way:
  1950. either a character occurs frequently or it doesn't.  If it does, then
  1951. most chunks, whatever size, will show that.  And, as before, my Huffman
  1952. codes are not so tight that a character's frequency can't move around
  1953. some without affecting efficiency.  
  1954.  
  1955. There is also the characteristic of 'locality', which means that different
  1956. stretches within the data will have somewhat different profiles.  A good
  1957. compressor will adapt as it proceeds.  In my case adaptivity is determined
  1958. by chunk size.  The smaller the chunk, the more adaptive.  This is an
  1959. advantage above some 'noise' level, below which, the counts become too
  1960. low to be meaningful - they no longer predict the actual frequency of 
  1961. the characters.  Above that level, increasing the chunk size doesn't
  1962. improve the efficiency, and at some higher level the efficiency decreases
  1963. as we lose adaptivity.
  1964.  
  1965. We also need to conceptually separate our input buffers, compression
  1966. chunks, and packets.  They can be optimized independently.  The input
  1967. routine reads large buffers to reduce i/o delays.  The compression
  1968. routine reads small chunks out of the input buffer for processing, and
  1969. puts them somewhere.  The packetizing routine accumulates enough
  1970. chunks to make an efficient packet.  The windowing routine manages
  1971. packets within it's window space.  The leg bone is connected to the
  1972. thigh bone.
  1973.  
  1974. ------------------------------------------------------------------------
  1975. I like the idea of selecting the unencoded chunk or the encoded one,
  1976. whichever is shorter.  I use a terminator character, hex 7e, to separate
  1977. the chunks within packets.  If we used two terminators, 7e and 7d, they
  1978. could indicate whether the chunk was encoded or not.  This would be 
  1979. useful for data that was extremely 'noisy' across all 256 8bit codes.
  1980.  
  1981. ------------------------------------------------------------------------
  1982. Sorry about this late response, I was attending an IA-FRS User Conference
  1983. in Orlando this week.
  1984.  
  1985.  4-Dec-91 21:15:59-GMT,1516;000000000001
  1986. Return-Path: <fdc>
  1987. Received: by watsun.cc.columbia.edu (5.59/FCB)
  1988.     id AA26097; Wed, 4 Dec 91 16:14:39 EST
  1989. Date: Wed, 4 Dec 91 16:14:38 EST
  1990. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  1991. To: Dick Elnicki <DICKE%NERVM@cuvmb.cc.columbia.edu>
  1992. Cc: Network Mailer <MAILER@cuvmb.cc.columbia.edu>,
  1993.         Joe Doupnik <JRD@cc.usu.edu>
  1994. Subject: Re: File Compression
  1995. In-Reply-To: Your message of Tue, 03 Dec 91 15:59:32 EST
  1996. Message-Id: <CMM.0.90.0.691881278.fdc@watsun.cc.columbia.edu>
  1997.  
  1998. >   The results clearly suggest anyone serious about using compression
  1999. > to save file Xmit times should pre-compress rather than do it on the
  2000. > fly during the Xmit.  The Kermit compression procedures would have
  2001. > to be at least as good as PKZIP's result to make the inclusion worth
  2002. > the trouble.  Or, am I missing something...
  2003. Yup -- Kermit runs on hundreds of different kinds of computers.  You can't
  2004. rely on any two of them to have the same compression methods.  Even when they
  2005. do, they might have different file formats, or use different character
  2006. sets.  So the sending Kermit has to convert data to canonical form first,
  2007. then compress.  So you can't separate compression from Kermit.  I'm beginning
  2008. to think we can't really have a super-effective method built into Kermit,
  2009. however, because of complexity, size, execution overhead, and patent/legal
  2010. issues.  It might well turn out that we'll settle for something less effective
  2011. than PKZIP and friends, but something simpler.  It'll be much better than what
  2012. we have now.
  2013.  
  2014. - Frank
  2015.  
  2016. 10-Feb-92 19:09:26-GMT,7097;000000000015
  2017. Return-Path: <getunx.info.com!thobe@avatar.com>
  2018. Received: from elroy.jpl.nasa.gov by watsun.cc.columbia.edu (5.59/FCB)
  2019.     id AA02183; Mon, 10 Feb 92 14:09:18 EST
  2020. Received: from avatar.com by elroy.Jpl.Nasa.Gov (4.1/SMI-4.1+DXR)
  2021.     id AA20906; Mon, 10 Feb 92 11:09:11 PST
  2022. Received: from getunx.info.com by avatar.com
  2023.     id aa12417; Mon, 10 Feb 92 10:22:00 PST
  2024. Received: by getunx.info.com id AA00280
  2025.   (5.65c/IDA-1.4.4 for fdc@watsun.cc.columbia.edu); Mon, 10 Feb 1992 09:06:13 -0800
  2026. Date: Mon, 10 Feb 1992 09:06:13 -0800
  2027. From: "Glenn E. Thobe" <thobe@getunx.info.com>
  2028. Message-Id: <199202101706.AA00280@getunx.info.com>
  2029. To: fdc@watsun.cc.columbia.edu
  2030. Subject: Encoding speeds transfer of compressed files
  2031.  
  2032.  
  2033. Frank-
  2034.  
  2035. I have some experimental results in support of my theory that Kermit's
  2036. performance in transferring compressed files can be greatly improved
  2037. by pre- and post-processing of the files.  I have designed a special
  2038. encoding scheme and programmed encoders and decoders to implement it.
  2039.  
  2040.  
  2041. ------------------------------------------------------------------
  2042.  
  2043.         Preprocessors Speed Kermit File Transfer
  2044.  
  2045.             by Glenn E. Thobe 
  2046.  
  2047.             February 10, 1992
  2048.  
  2049.  
  2050. INTRODUCTION
  2051.  
  2052.  
  2053. I have written a set of four preprocessors for Kermit which greatly
  2054. improve it's efficiency when transferring compressed files.  Kermit's
  2055. control prefixing algorithm, although efficient for text files, is
  2056. expensive for compressed files.  
  2057.  
  2058. Compressed files are fundamentally different from other binary files 
  2059. in the way in which the data are statistically distributed:  roughly 
  2060. speaking the bytes of a compressed file are uncorrelated and uniformly 
  2061. distributed over the 256 8-bit codes are uniformly distributed over.  
  2062.  
  2063. The new routines eliminate Kermit's control prefixing overhead while 
  2064. utilizing the maximum available code space of 190 or 95 characters.  
  2065. This minimizes the number of characters which get transferred, thereby 
  2066. shortening the time and reducing the cost.  
  2067.  
  2068. They filters are:
  2069.  
  2070.     k7enc - encode for 7-bit channels
  2071.     k7dec - decode for 7-bit channels
  2072.     k8enc - encode for 8-bit channels
  2073.     k8dec - decode for 8-bit channels
  2074.  
  2075. For testing purposes, additional filters were written which emulate Kermit's 
  2076. prefixing algorithms:
  2077.  
  2078.     getpkt7 - Kermit encoding (control + 8th-bit prefixing)
  2079.     getpkt8 - Kermit encoding (control prefixing)
  2080.  
  2081. In practice, one would apply the following processes to transfer
  2082. a compressed file:
  2083.  
  2084.     k8enc (encode file on sending computer)
  2085.     kermit (transfer file)
  2086.     k8dec (decode file on receiving computer)
  2087.  
  2088. Here we simulate the transfer and predict the performance of the above
  2089. process by performing the following steps on a single computer:
  2090.  
  2091.     k8enc (encode file)
  2092.     getpkt8 (apply control prefixing of non-printable charaters)
  2093.     k8dec (decode file)
  2094.  
  2095. We can view k8enc and Kermit's encoding as alternative ways of dealing 
  2096. with the limited 190 (or 95) letter code space, and compare the 
  2097. performance of the two.  We can also compare the performance of k7enc, 
  2098. k8enc, and other popular binary-to-printable filters.
  2099.  
  2100.  
  2101. RESULTS
  2102.  
  2103.  
  2104. Following are simulation results for a typical file using k8enc.
  2105.  
  2106.     file=DNLNK/dnlnk.tar.Z
  2107.     raw file transfer:
  2108.     in = 57725, out = 75436, expansion = 30.68%, efficiency = 76.52%
  2109.     encoding alone:
  2110.     in = 57725, out = 62118, expansion = 7.61%, efficiency = 92.92%
  2111.     encoded file transfer alone:
  2112.     in = 62118, out = 63072, expansion = 1.53%, efficiency = 98.48%
  2113.     combined coding and transfer:
  2114.     in = 57725, out = 63072, expansion = 9.26%, efficiency = 91.52%
  2115.  
  2116. Note that k8enc encoding alone significantly outperforms Kermit's
  2117. getpkt8 encoding.  Also, that k8enc preprocessed files enjoy greatly
  2118. improved transfer performance compared the raw compressed file.
  2119.  
  2120. Here, for the same file, are the results with different preprocessors:
  2121.  
  2122.     ============================================================
  2123.     Combined Efficiencies for Kermit used with various preprocessors
  2124.     ============================================================
  2125.     file name = DNLNK/dnlnk.tar.Z, file size = 57725 bytes
  2126.     7-bit channel (eighth bit prefixing):
  2127.     cat             56.77%
  2128.     uuencode x      69.2%
  2129.     btoa            75.96%
  2130.     k7enc           77.36%
  2131.     8-bit channel:
  2132.     cat             76.52%
  2133.     k8enc           91.52%
  2134.     ============================================================
  2135.  
  2136. Note that k7enc used with a 7-bit channel actually outperforms raw 
  2137. file transfer (cat) over an 8-bit channel.  It also outperforms both
  2138. uuencode (where each three bytes are spread over four) and atob 
  2139. (where each four bytes are spread over five).  K8enc is obviously
  2140. the big winner here.
  2141.  
  2142.  
  2143. PROTOCOL ENHANCEMENT PROPOSAL
  2144.  
  2145.  
  2146. While the improvements are impressive, the user is still left with 
  2147. the clumsiness of manually running the pre- and postprocessors, and
  2148. keeping track of the file names.  It would be much more convenient 
  2149. to incorporate the encoding and decoding processes into the Kermit 
  2150. protocol.  
  2151.  
  2152. A compressed-file mode should be introduced.  The user would select 
  2153. this mode when transferring LZ-compressed, zipped, Gif, and other 
  2154. compressed binary data types.  The implementation would be especially 
  2155. easy, since in this mode most of the intricate prefixing, RLE, and
  2156. locking shift preprocessing involved in packetizing the data can be 
  2157. switched off and built-in k7enc or k8enc processing switched on in
  2158. its place.
  2159.  
  2160. This protocol enhancement should be viewed as separate from the proposed 
  2161. built-in file compression, since the latter is of no great benefit when 
  2162. the file is already compressed.  Built-in compression should be used
  2163. for text files, executables, etc., but not for already compressed files.
  2164.  
  2165. A slightly surprising result of this study, is that the cost of Kermit's
  2166. design decision to use only a 188 character subset (190 extended ascii 
  2167. printables minus two control prefix characters) of the 256 data characters, 
  2168. can have so little adverse impact on efficiency.  Typically the cost of 
  2169. mapping white noise data over a 256 character alphabet into a 190 character 
  2170. subset (8-bit channel) is between 7 and 8 percent as shown experimentally 
  2171. by this study.  That is, the files are expanded by only 7 to 8 percent.  
  2172. This would seem to be a fair trade off for the ability to operate over 
  2173. channels where full 8-bit transparency cannot be guaranteed.
  2174.  
  2175.  
  2176. CONCLUSION
  2177.  
  2178.  
  2179. The traditional Kermit prefixing algorithm for mapping all file characters
  2180. into the ASCII and extended ASCII printable codes is optimized for text
  2181. files but performs poorly for compressed files.  File transfer performance 
  2182. with compressed files can be improved greatly by complementary pre- and
  2183. post processing of the files using the filter programs presented here.
  2184. These filters significantly outperform the traditional uuencode and btoa,
  2185. optimally exploiting the available channel capacity.
  2186.  
  2187. These filters should be introduced into the Kermit protocol in support of 
  2188. a special mode for optimizing the transfer of compressed files.
  2189.  
  2190. -----------------------------------------------------------------------
  2191.  
  2192. -Glenn E. Thobe
  2193. <thobe@getunx.info.com>
  2194.  
  2195. 29-Jan-92  0:24:32-GMT,4031;000000000015
  2196. Return-Path: <sturdeva>
  2197. Received: by watsun.cc.columbia.edu (5.59/FCB)
  2198.     id AA19299; Tue, 28 Jan 92 19:24:29 EST
  2199. Date: Tue, 28 Jan 92 19:24:28 EST
  2200. From: James Sturdevant <sturdeva@watsun.cc.columbia.edu>
  2201. To: fdc
  2202. Cc: jrd
  2203. Subject: Kermit Data Compression
  2204. Message-Id: <CMM.0.90.0.696644668.sturdeva@watsun.cc.columbia.edu>
  2205.  
  2206. Greetings,
  2207.  
  2208. In my home directory, you will find my compression routines in both C
  2209. and 8086 assembler.  Below, you will find my attempt to explain them. 
  2210. (The routines are better than the explaination.)
  2211.  
  2212. The compression code challenge:  I have added my code to
  2213. xx??co.c and added the module ckccmp.c.  Changes in the XX
  2214. code have [jrs] comments to flag it.  I have done my best
  2215. to speed it up.  Any other code jockies are welcome to
  2216. prove themselves better.
  2217.  
  2218. Unliketechniques, the compression does not change the
  2219. bit width of any non-compressed characters.  (Is that
  2220. enough difference to patent it?)  It flags compressed data
  2221. with the grave character (`-0x60).  The compression takes
  2222. place after the conversion of the character (or run of like
  2223. characters) for the packet.  For ease of description, I
  2224. will call these tokens.  The basis of this algorithm came
  2225. from an article in Computer Language (V8#5, May 91) on a
  2226. technique called Sliding Windows.  It's supposed to be a
  2227. variation on LZW.  My variations are the position encoding
  2228. and fixed sizes for window and data.
  2229.  
  2230. The compression works like this:
  2231.  
  2232. Initialize a compression buffer and window dictionary.
  2233.  
  2234. Step:
  2235. Create a token.  Add the token to the end of the existing
  2236. buffer.
  2237.  
  2238. Search for a match on the buffer in a "window" of bytes
  2239. processed previously.  If found, get another token.
  2240.  
  2241. When not found,  check the previous match.  If it is
  2242. greater than 4 characters (the length of a compression
  2243. token), output the string as a compressed token, start with
  2244. the new token in the buffer and search again.
  2245.  
  2246. If the buffer without the current token is less than 5
  2247. characters, output the first token normally and try to find
  2248. a match starting at the next token.
  2249.  
  2250. In both cases, the text of the output (whether token or
  2251. compressed string) is added to the window.  This is done
  2252. only when data is actually output so the search doesn't
  2253. find data which is pending.
  2254.  
  2255. The compressed data consists of the flag character a two
  2256. character (base 94) position, and a one character (base 94
  2257. offset 4) length.
  2258.  
  2259. When the file is complete, flush the remaining characters
  2260. from the compression buffer.
  2261.  
  2262. To speed the search of the "window", I maintain a linked
  2263. list for each character with a pointer to the beginning and
  2264. end.  When a character is removed (to add a new character
  2265. in its place) the starting link is moved forward.  The
  2266. ending link is moved with each character.  Searches are
  2267. done by starting at the first character, comparing the
  2268. string starting in that location with the buffer.  On
  2269. success, the search stops (why continue?).  On failure, the
  2270. search follows the link to the next matching character, and
  2271. compares again.
  2272.  
  2273. On the receiving side, the decompression routine read
  2274. characters and processes them until it sees the ` character
  2275. at the beginning of a token (i.e. it is not quoted by #, or
  2276. a length field for a repeat).  As the characters are
  2277. processed, they are added to the window.  It is not
  2278. necessary for the receiving side to maintain a list of
  2279. characters, but it doesn't hurt.  When the ` character is
  2280. seen, the next three characters are used to compute the
  2281. location and length of the real string.  The current data
  2282. buffer is saved and data is consumed from the calculated
  2283. string.  When the string is exausted, processing continues
  2284. on the original data.
  2285.  
  2286. The initial design criteria included low memory usage
  2287. (24K+slop of data), consistancy with the current Kermit
  2288. packet style, and no increase on data which cannot
  2289. compress.  There is an exception for ` which must be quoted
  2290. if compression is turned on.  I chose ` because it is in
  2291. the allowable range for flags and is not likely to appear
  2292. in much text, c programs or assembler programs (that I am
  2293. aware of).
  2294.  
  2295. 13-Feb-92 12:11:52-GMT,27174;000000000005
  2296. Return-Path: <getunx.info.com!thobe@avatar.com>
  2297. Received: from elroy.jpl.nasa.gov by watsun.cc.columbia.edu (5.59/FCB)
  2298.     id AA14153; Thu, 13 Feb 92 07:11:18 EST
  2299. Received: from avatar.com by elroy.Jpl.Nasa.Gov (4.1/SMI-4.1+DXR)
  2300.     id AA14382; Thu, 13 Feb 92 03:13:52 PST
  2301. Received: from getunx.info.com by avatar.com
  2302.     id aa01247; Thu, 13 Feb 92 1:39:04 PST
  2303. Received: by getunx.info.com id AA01901
  2304.   (5.65c/IDA-1.4.4 for fdc@watsun.cc.columbia.edu); Thu, 13 Feb 1992 01:22:25 -0800
  2305. Date: Thu, 13 Feb 1992 01:22:25 -0800
  2306. From: "Glenn E. Thobe" <thobe@getunx.info.com>
  2307. Message-Id: <199202130922.AA01901@getunx.info.com>
  2308. To: fdc@watsun.cc.columbia.edu
  2309. Subject: Re: Encoding speeds transfer of compressed files
  2310.  
  2311. You wrote:
  2312.  
  2313. >Thanks, Glenn!  It'll take me a while to digest this.  As you probably know,
  2314. >yours is only one entry of many in the Great Compression Contest (you saw
  2315. >kermit/e/compress.txt, right?).  Anyway, we really do want to do something
  2316. >like what you have suggested, but we're all pretty swamped right now and will
  2317. >have to come back to this later.  Meanwhile, do you want to send in your
  2318. >filters?  Thanks again!  - Frank
  2319.  
  2320. Frank-
  2321.  
  2322. Here is the whole k7- and k8-encoding package.  I revised the document 
  2323. I sent you the other day (it should be clearer) and included it.  You 
  2324. should be able to build and test everything in minutes on a Unix system.  
  2325. Please let me know if any problems show up.  
  2326.  
  2327. The technique is not a compression scheme as such, it is more of an 
  2328. anti-expansion scheme for already compressed files.  Such a mode should 
  2329. be incorporated whether or not a built in compression is adopted.  
  2330. Nearly all the files I transfer are compressed already, so I feel the 
  2331. need personally.
  2332.  
  2333. I can send you my filters which do Kermit-style prefixing and the 
  2334. comparison shell scripts if you want to repeat my efficiency tests, 
  2335. but I presume you already have a way of doing such things.
  2336.  
  2337. I just ordered bin/e/compress.txt.  Thanks for pointing it out.
  2338.  
  2339. -Glenn <thobe@getunx.info.com>
  2340.  
  2341. #! /bin/sh
  2342. # This is a shell archive.  Remove anything before this line, then unpack
  2343. # it by saving it into a file and typing "sh file".  To overwrite existing
  2344. # files, type "sh file -c".  You can also feed this as standard input via
  2345. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  2346. # will see the following message at the end:
  2347. #        "End of shell archive."
  2348. # Contents:  READ.ME Makefile filters.doc k7enc.c k7dec.c k8enc.c
  2349. #   k8dec.c k7verify.ksh k8verify.ksh
  2350. # Wrapped by thobe@getunx on Thu Feb 13 00:56:42 1992
  2351. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  2352. if test -f 'READ.ME' -a "${1}" != "-c" ; then 
  2353.   echo shar: Will not clobber existing file \"'READ.ME'\"
  2354. else
  2355. echo shar: Extracting \"'READ.ME'\" \(2058 characters\)
  2356. sed "s/^X//" >'READ.ME' <<'END_OF_FILE'
  2357. X/* READ ME */
  2358. XThis is the first release of two pairs of complementary filters for
  2359. Xfor pre- and post-processing of COMPRESSED FILES in order to speed
  2360. Xup the transfer of those files via Kermit.  One pair is for 7 bit 
  2361. Xdata paths and the other is for 8.
  2362. X
  2363. XThe reason these filters are needed is that Kermit allows only the
  2364. XASCII or 8-bit extended ASCII codes to be to be transferred unchanged.  
  2365. XKermit prefixes control codes and replaces them with printable codes,
  2366. Xwhich increases the amount of data to be transferred.  This is efficient 
  2367. Xfor text files where control codes are infrequent but it is inefficient 
  2368. Xfor compressed files.
  2369. X
  2370. XThe code has been compiled and tested on an AT&T 7300/UnixPC/3b1
  2371. Xcomputer with both gcc and cc.  A make file and a document describing
  2372. Xthe rationale are included.  After you build them, test by running
  2373. Xk7verify.ksh and k8verify.ksh under either the Bourne or Korn shell.
  2374. X
  2375. X    /bin/sh k7verify.ksh *
  2376. X    /bin/sh k8verify.ksh *
  2377. X
  2378. XInstructions on use are found in the
  2379. Xheaders of the four C source files.  Sorry, no man page.
  2380. X
  2381. XIt is hoped that these routines will be found helpful in their own
  2382. Xright, but most of all it is hoped that they will find their way
  2383. Xinto the Kermit protocol as a special mode for efficiently transferring
  2384. Xcompressed files.  They may also be combined with future built-in file
  2385. Xcompression.  This mode should be adopted whether or not built in file 
  2386. Xcompression is added.
  2387. X
  2388. XThe design and coding of these filters is a completely original
  2389. Xcreation of the author.  Note the copyright notice.  It is essentially
  2390. XColumbia University's copyright, which should in no way restrict the
  2391. XKermit project from making full use of the code or algorithm.
  2392. X
  2393. X    Copyright (C) 1992, Glenn E. Thobe, Canoga Park, California, USA.
  2394. X    All rights reserved.  Permission is granted to any individual 
  2395. X    or institution to use, copy, or redistribute this software so 
  2396. X    long as it is not sold for profit, provided this copyright 
  2397. X    notice is retained.
  2398. X
  2399. XEnjoy.
  2400. X
  2401. X-Glenn Thobe
  2402. X<thobe@getunx.info.com>
  2403. XWed Feb 12 23:27:51 PST 1992
  2404. END_OF_FILE
  2405. if test 2058 -ne `wc -c <'READ.ME'`; then
  2406.     echo shar: \"'READ.ME'\" unpacked with wrong size!
  2407. fi
  2408. # end of 'READ.ME'
  2409. fi
  2410. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  2411.   echo shar: Will not clobber existing file \"'Makefile'\"
  2412. else
  2413. echo shar: Extracting \"'Makefile'\" \(721 characters\)
  2414. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  2415. X# Makefile for Kermit pre- and postfilters
  2416. X# Author: Glenn E. Thobe <thobe@getunx.info.com>
  2417. X# Wed Feb 12 00:23:44 PST 1992
  2418. X
  2419. XCC = gcc 
  2420. XCFLAGS = -O
  2421. X#LDFLAGS = -s 
  2422. XLDFLAGS = -s -shlib    #shared library option for gcc on 3b1/UnixPC
  2423. X
  2424. XOBJS= k7enc.o k7dec.o k8enc.o k8dec.o
  2425. XPROGS= k7enc k7dec k8enc k8dec
  2426. XSOURCES= k7enc.c k7dec.c k8enc.c k8dec.c
  2427. X
  2428. Xall: $(PROGS)
  2429. X
  2430. Xk7enc: k7enc.o
  2431. X    $(CC) -o $@ k7enc.o $(LDFLAGS)
  2432. X
  2433. Xk7dec: k7dec.o
  2434. X    $(CC) -o $@ k7dec.o $(LDFLAGS)
  2435. X
  2436. Xk8enc: k8enc.o
  2437. X    $(CC) -o $@ k8enc.o $(LDFLAGS)
  2438. X
  2439. Xk8dec: k8dec.o
  2440. X    $(CC) -o $@ k8dec.o $(LDFLAGS)
  2441. X
  2442. Xclean: 
  2443. X    rm core $(PROGS) $(OBJS)
  2444. X
  2445. Xshar:    READ.ME Makefile filters.doc $(SOURCES) k[78]verify.ksh
  2446. X    shar READ.ME Makefile filters.doc $(SOURCES) k[78]verify.ksh \
  2447. X    >filters.shar
  2448. END_OF_FILE
  2449. if test 721 -ne `wc -c <'Makefile'`; then
  2450.     echo shar: \"'Makefile'\" unpacked with wrong size!
  2451. fi
  2452. # end of 'Makefile'
  2453. fi
  2454. if test -f 'filters.doc' -a "${1}" != "-c" ; then 
  2455.   echo shar: Will not clobber existing file \"'filters.doc'\"
  2456. else
  2457. echo shar: Extracting \"'filters.doc'\" \(6957 characters\)
  2458. sed "s/^X//" >'filters.doc' <<'END_OF_FILE'
  2459. X
  2460. X        Preprocessors Speed Kermit File Transfer
  2461. X
  2462. X            by Glenn E. Thobe 
  2463. X
  2464. X            rev. February 12, 1992
  2465. X
  2466. X
  2467. XINTRODUCTION
  2468. X
  2469. X
  2470. XI have written a set of four pre- and post-processors which greatly 
  2471. Ximprove Kermit's efficiency when transferring compressed files.  
  2472. XKermit's control prefixing algorithm, although efficient for text 
  2473. Xfiles, is expensive for compressed files.  
  2474. X
  2475. XCompressed files are fundamentally different from other binary files 
  2476. Xin the way in which the data are statistically distributed.  Roughly 
  2477. Xspeaking, the bytes of a compressed file are uncorrelated and uniformly 
  2478. Xdistributed over the 256 8-bit codes.  Text files, for which Kermit's
  2479. Xcontrol prefixing was originally designed, have few characters which
  2480. Xare not in the printable range.  For them, control prefixing adds 
  2481. Xlittle extra cost.  By contrast, compressed files contain many
  2482. Xunprintable characters for which prefixing is inefficient.  Refinements, 
  2483. Xsuch as Kermit's run length and shift lock encoding, are ineffective 
  2484. Xfor compressed files.
  2485. X
  2486. XThe preprocessors work by preempting Kermit's control prefixing overhead 
  2487. Xwhich was designed to optimize the transmission of text files.  The entire 
  2488. Xavailable code space of 190 or 95 (7-bits) printable characters is used in a 
  2489. Xstatistically uniform way, and none of the control characters are used at 
  2490. Xall.  All forms of encoding will expand compressed files.  Our 
  2491. Xpreprocessors expand them as little as possible, certainly much less than 
  2492. XKermit's control prefixing strategy.  The test measurements bear out this 
  2493. Xcontention.
  2494. X
  2495. XThe filters are:
  2496. X
  2497. X    k7enc - encode for 7-bit channels
  2498. X    k7dec - decode for 7-bit channels
  2499. X    k8enc - encode for 8-bit channels
  2500. X    k8dec - decode for 8-bit channels
  2501. X
  2502. XIn actual use these filters are employed in the following sequence to 
  2503. Xtransfer a compressed file in the least amount of time:
  2504. X
  2505. X    * Using k8enc, encode the file on sending computer.
  2506. X    * Transfer the encoded file using Kermit.
  2507. X    * Using k8dec, decode file on receiving computer.
  2508. X
  2509. XFor testing purposes, additional filters were written which implement
  2510. XKermit's prefixing algorithms: 
  2511. X
  2512. X    getpkt7 - Kermit encoding (control + 8th-bit prefixing) 
  2513. X    getpkt8 - Kermit encoding (control prefixing) 
  2514. X
  2515. XIn order to experimentally evaluate our strategy, we simulated Kermit 
  2516. Xtransfers using the filters k7enc, k8enc, getpkt7, and getpkt8 in 
  2517. Xvarious combinations.  We compared the efficiencies of transferring 
  2518. Xfiles with or without the pre- and post-processing.  Efficiency is
  2519. Xdefined as the ratio of the number of bytes in the original file to
  2520. Xthe number of bytes transmitted over the line (i.e. fully encoded).  
  2521. XThe wc utility gives the number of bytes emerging from the preceding 
  2522. Xfilters in the pipeline:
  2523. X
  2524. X    getpkt8 <file.Z | wc                #raw file transmitted by kermit
  2525. X    k8enc <file.Z | wc                  #k8encoded file
  2526. X    k8enc <file.Z | getpkt8 | wc        #k8encoded file transmitted by Kermit
  2527. X
  2528. XWe can view k8enc and Kermit's encoding as alternative ways of dealing 
  2529. Xwith the limited 190 (or 95) letter code space, and compare the 
  2530. Xperformance of the two.  We can also compare the performance of k7enc
  2531. Xand k8enc with other popular binary-to-printable filters.
  2532. X
  2533. X
  2534. XRESULTS
  2535. X
  2536. X
  2537. XFollowing are simulation results for a typical file using k8enc.
  2538. X
  2539. X    file=DNLNK/dnlnk.tar.Z
  2540. X    raw file transfer:
  2541. X    in = 57725, out = 75436, expansion = 30.68%, efficiency = 76.52%
  2542. X    encoding alone:
  2543. X    in = 57725, out = 62118, expansion = 7.61%, efficiency = 92.92%
  2544. X    encoded file transfer alone:
  2545. X    in = 62118, out = 63072, expansion = 1.53%, efficiency = 98.48%
  2546. X    combined coding and transfer:
  2547. X    in = 57725, out = 63072, expansion = 9.26%, efficiency = 91.52%
  2548. X
  2549. XNote that k8enc encoding alone significantly outperforms Kermit's
  2550. Xgetpkt8 encoding.  Also, that k8enc preprocessed files enjoy greatly
  2551. Ximproved transfer performance compared to the raw compressed file.
  2552. X
  2553. XHere, for the same file, are the results with different preprocessors:
  2554. X
  2555. X    ============================================================
  2556. X    Combined Efficiencies for Kermit used with various preprocessors
  2557. X    ============================================================
  2558. X    file name = DNLNK/dnlnk.tar.Z, file size = 57725 bytes
  2559. X    7-bit channel (eighth bit prefixing):
  2560. X    no encoding     56.77%
  2561. X    uuencode        69.2%
  2562. X    btoa            75.96%
  2563. X    k7enc           77.36%
  2564. X    8-bit channel:
  2565. X    no encoding     76.52%
  2566. X    k8enc           91.52%
  2567. X    ============================================================
  2568. X
  2569. XNote that k7enc used with a 7-bit channel actually outperforms raw 
  2570. Xfile transfer over an 8-bit channel.  It also outperforms both
  2571. Xuuencode (where each three bytes are spread over four) and atob 
  2572. X(where each four bytes are spread over five).  K8enc is obviously
  2573. Xthe big winner here.
  2574. X
  2575. X
  2576. XPROTOCOL ENHANCEMENT PROPOSAL
  2577. X
  2578. X
  2579. XWhile the improvements are impressive, the user is still left with 
  2580. Xthe clumsiness of manually running the pre- and postprocessors, and
  2581. Xkeeping track of the file names.  It would be much more convenient 
  2582. Xto incorporate the encoding and decoding processes into the Kermit 
  2583. Xprotocol.  
  2584. X
  2585. XA compressed-file mode should be introduced.  The user would select 
  2586. Xthis mode when transferring LZ-compressed, zipped, Gif, and other 
  2587. Xcompressed binary data types.  The implementation would be especially 
  2588. Xeasy, since in this mode most of the intricate prefixing, RLE, and
  2589. Xlocking shift preprocessing involved in packetizing the data can be 
  2590. Xswitched off and built-in k7enc or k8enc processing switched on in
  2591. Xits place.
  2592. X
  2593. XThis protocol enhancement should be viewed as separate from the proposed 
  2594. Xbuilt-in file compression, since the latter is of no great benefit when 
  2595. Xthe file is already compressed.  Built-in compression should be used
  2596. Xfor text files, executables, etc., but not for already compressed files.
  2597. X
  2598. XThe good news here is that restricting the code space to the 190 extended
  2599. Xascii printables can have so little adverse impact on efficiency.  When
  2600. Xthe data are encoded using our k8enc filter, a compressed file is expanded
  2601. Xtypically by only 7 to 8 percent, as shown experimentally by our study.
  2602. X
  2603. X
  2604. XCONCLUSION
  2605. X
  2606. X
  2607. XThe traditional Kermit prefixing algorithm for mapping all file characters
  2608. Xinto the ASCII and extended ASCII printable codes is optimized for text
  2609. Xfiles but performs poorly for compressed files.  File transfer performance 
  2610. Xwith compressed files can be improved greatly by complementary pre- and
  2611. Xpost processing of the files using the filter programs presented here.
  2612. XThese filters significantly outperform not only Kermit's built-in
  2613. Xcontrol prefixing, but also the traditional uuencode and btoa.  This
  2614. Xis accomplished by optimally exploiting the available channel capacity.
  2615. X
  2616. XThese filters should be introduced into the Kermit protocol in support of 
  2617. Xa special mode for optimizing the transfer of compressed files.
  2618. X
  2619. X-----------------------------------------------------------------------
  2620. X
  2621. X-Glenn E. Thobe
  2622. X<thobe@getunx.info.com>
  2623. END_OF_FILE
  2624. if test 6957 -ne `wc -c <'filters.doc'`; then
  2625.     echo shar: \"'filters.doc'\" unpacked with wrong size!
  2626. fi
  2627. # end of 'filters.doc'
  2628. fi
  2629. if test -f 'k7enc.c' -a "${1}" != "-c" ; then 
  2630.   echo shar: Will not clobber existing file \"'k7enc.c'\"
  2631. else
  2632. echo shar: Extracting \"'k7enc.c'\" \(2881 characters\)
  2633. sed "s/^X//" >'k7enc.c' <<'END_OF_FILE'
  2634. X/* k7enc.c - encode for Kermit's 7-bit window (0x20-0x7e).
  2635. XSpeeds Kermit transfer of compressed files for 7-bit channels, use 
  2636. Xwith k7dec.  For 8-bit channels with no parity use k8enc and k8dec.
  2637. X
  2638. XAuthor:    Glenn E. Thobe    <thobe@getunx.info.com>
  2639. X
  2640. XCopyright (C) 1992, Glenn E. Thobe, Canoga Park, California, USA.
  2641. XAll rights reserved.  Permission is granted to any individual 
  2642. Xor institution to use, copy, or redistribute this software so 
  2643. Xlong as it is not sold for profit, provided this copyright 
  2644. Xnotice is retained.
  2645. X
  2646. XK7enc prepares a compressed file to be transferred by Kermit in
  2647. Xbinary mode and decoded by k7dec.  As a filter, its typical
  2648. Xusage with the compressed file.Z might be:
  2649. X
  2650. X    k7enc < file.Z | kermit -is -     (sender)
  2651. X    kermit -ik | k7dec > file.Z       (receiver)
  2652. X
  2653. XWith a text file the following is also useful:
  2654. X
  2655. X    compress < file.txt | k7enc | kermit -is -     (sender)
  2656. X    kermit -ik | k7dec | uncompress > file.txt     (receiver)
  2657. X
  2658. XK7enc and k7dec feature a special non-linear mapping which avoids
  2659. Xall ASCII control characters and makes optimal use of the Kermit's 
  2660. Xentire 7-bit ASCII-printable code space.  Thus Kermit has no need
  2661. Xof control or 8th-bit prefixing (except for the control prefix itself
  2662. Xwhich is doubled).
  2663. X*/
  2664. X
  2665. X/* REVISION HISTORY:
  2666. XSat Feb  8 22:15:47 PST 1992    initial release -g.t.
  2667. X*/
  2668. X
  2669. X/* call coroutine */
  2670. X#define A_CALL_B(x,Ax) do{An=x;goto B;Ax:;}while(0)    /* K&R C version */
  2671. X#define B_CALL_A(x,Bx) do{Bn=x;goto A;Bx:;}while(0)    /* K&R C version */
  2672. X
  2673. X#define min(x,y) ((x)>(y))?(y):(x)
  2674. X#define MAP(x) ((x)+0x20)    /* map to ASCII printables */
  2675. X
  2676. X#include <stdio.h>
  2677. X
  2678. Xvoid
  2679. Xmain()
  2680. X{
  2681. X    int An, Bn;
  2682. X    int c, m, h, w, inbuf, u, eof;
  2683. X    static int rmask[]={0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
  2684. X
  2685. X    /* initialize coroutine linkage */
  2686. X    An = 0;
  2687. X    Bn = 0;
  2688. X    goto A;
  2689. X
  2690. X    /* input 1-8 bits as per request */
  2691. XA0:
  2692. X    h = 0;
  2693. X    eof = 0;
  2694. X    inbuf = 0;
  2695. X    while(1)
  2696. X    {
  2697. X    A_CALL_B(1,A1);
  2698. X    if (h < w)
  2699. X    {
  2700. X        u = getchar();
  2701. X        eof = feof(stdin);
  2702. X        inbuf <<= 8;
  2703. X        if(!eof) inbuf += u;
  2704. X        h += 8;
  2705. X    }
  2706. X    c = (inbuf >> (h - w)) & rmask[w];
  2707. X    h -= w;
  2708. X    }
  2709. X
  2710. X    /* assemble and output encoded bytes */
  2711. XB0:
  2712. X    w = 8;
  2713. X    B_CALL_A(1,B1);
  2714. X    while(1)
  2715. X    {
  2716. X    if (c < 0x88)
  2717. X    {
  2718. X        m = c;
  2719. X        putchar(MAP(m >> 2));
  2720. X        if (eof && h < 6) exit(0);
  2721. X        w = 6;
  2722. X        B_CALL_A(2,B2);
  2723. X        c += (m & 0x03) << 6;
  2724. X    }
  2725. X    else if (c < 0xfe)
  2726. X    {
  2727. X        m = c;
  2728. X        putchar(MAP((m >> 1) - 0x22));
  2729. X        if (eof && h < 7) exit(0);
  2730. X        w = 7;
  2731. X        B_CALL_A(3,B3);
  2732. X        c += (m & 0x01) << 7;
  2733. X    }
  2734. X    else
  2735. X    {
  2736. X        putchar(MAP(c - 0xa1));
  2737. X        if (eof && h < 8) exit(0);
  2738. X        w = 8;
  2739. X        B_CALL_A(4,B4);
  2740. X    }
  2741. X    }
  2742. X    exit(0);
  2743. X
  2744. X/* more coroutine stuff */
  2745. X
  2746. XA: 
  2747. X    switch(An)
  2748. X    {
  2749. X    case 0: goto A0;
  2750. X    case 1: goto A1;
  2751. X    }
  2752. X
  2753. XB: 
  2754. X    switch(Bn)
  2755. X    {
  2756. X    case 0: goto B0;
  2757. X    case 1: goto B1;
  2758. X    case 2: goto B2;
  2759. X    case 3: goto B3;
  2760. X    case 4: goto B4;
  2761. X    }
  2762. X}
  2763. END_OF_FILE
  2764. if test 2881 -ne `wc -c <'k7enc.c'`; then
  2765.     echo shar: \"'k7enc.c'\" unpacked with wrong size!
  2766. fi
  2767. # end of 'k7enc.c'
  2768. fi
  2769. if test -f 'k7dec.c' -a "${1}" != "-c" ; then 
  2770.   echo shar: Will not clobber existing file \"'k7dec.c'\"
  2771. else
  2772. echo shar: Extracting \"'k7dec.c'\" \(2585 characters\)
  2773. sed "s/^X//" >'k7dec.c' <<'END_OF_FILE'
  2774. X/* k7dec.c - decode for Kermit's 7-bit window (0x20-0x7e).
  2775. XSpeeds Kermit transfer of compressed files for 7-bit channels, use 
  2776. Xwith k7enc.  For 8-bit channels with no parity use k8enc and k8dec.
  2777. X
  2778. XAuthor:    Glenn E. Thobe    <thobe@getunx.info.com>
  2779. X
  2780. XCopyright (C) 1992, Glenn E. Thobe, Canoga Park, California, USA.
  2781. XAll rights reserved.  Permission is granted to any individual 
  2782. Xor institution to use, copy, or redistribute this software so 
  2783. Xlong as it is not sold for profit, provided this copyright 
  2784. Xnotice is retained.
  2785. X
  2786. XK7dec recovers a compressed file which has been encoded by k7enc 
  2787. Xand transferred by Kermit in binary mode.  As a filter, its typical
  2788. Xusage with the compressed file.Z might be:
  2789. X
  2790. X    k7enc < file.Z | kermit -is -     (sender)
  2791. X    kermit -ik | k7dec > file.Z       (receiver)
  2792. X
  2793. XWith a text file the following is also useful:
  2794. X
  2795. X    compress < file.txt | k7enc | kermit -is -     (sender)
  2796. X    kermit -ik | k7dec | uncompress > file.txt     (receiver)
  2797. X
  2798. XK7enc and k7dec feature a special non-linear mapping which avoids
  2799. Xall ASCII control characters and makes optimal use of the Kermit's 
  2800. Xentire 7-bit ASCII-printable code space.  Thus Kermit has no need
  2801. Xof control or 8th-bit prefixing (except for the control prefix itself
  2802. Xwhich is doubled).
  2803. X*/
  2804. X
  2805. X/* REVISION HISTORY:
  2806. XSat Feb  8 22:15:47 PST 1992    initial release -g.t.
  2807. X*/
  2808. X
  2809. X/* call coroutine */
  2810. X#define A_CALL_B(x,Ax) do{An=x;goto B;Ax:;}while(0)    /* K&R C version */
  2811. X#define B_CALL_A(x,Bx) do{Bn=x;goto A;Bx:;}while(0)    /* K&R C version */
  2812. X
  2813. X#define UNMAP(x) ((x)-0x20)    /* unmap from ASCII printables */
  2814. X
  2815. X#include <stdio.h>
  2816. X#include <assert.h>
  2817. X
  2818. Xvoid
  2819. Xmain()
  2820. X{
  2821. X    int An, Bn;
  2822. X    int c, m, h, w, t, u, inbuf;
  2823. X    static int rmask[]={0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
  2824. X
  2825. X    /* initialize coroutine linkage */
  2826. X    An = 0;
  2827. X    Bn = 0;
  2828. X    goto A;
  2829. X
  2830. X    /* input 1-8 bits as per request */
  2831. XA0:
  2832. X    h = 0;
  2833. X    inbuf = 0;
  2834. X    while(1)
  2835. X    {
  2836. X    A_CALL_B(1,A1);
  2837. X    while (h < w)
  2838. X    {
  2839. X        t = getchar();
  2840. X        if (feof(stdin)) exit(0);
  2841. X        u = UNMAP(t);
  2842. X        if (u < 0x22)
  2843. X        {
  2844. X        inbuf <<= 6;
  2845. X        inbuf += u;
  2846. X        h += 6;
  2847. X        }
  2848. X        else if (u < 0x5d)
  2849. X        {
  2850. X        u += 0x22;
  2851. X        inbuf <<= 7;
  2852. X        inbuf += u;
  2853. X        h += 7;
  2854. X        }
  2855. X        else
  2856. X        {
  2857. X        u += 0xa1;
  2858. X        inbuf <<= 8;
  2859. X        inbuf += u;
  2860. X        h += 8;
  2861. X        }
  2862. X    }
  2863. X    c = (inbuf >> (h - w)) & rmask[w];
  2864. X    h -= w;
  2865. X    }
  2866. X
  2867. X    /* dissemble encoded bytes and output */
  2868. XB0:
  2869. X    while(1)
  2870. X    {
  2871. X    w = 8;
  2872. X    B_CALL_A(1,B1);
  2873. X    putchar(c);
  2874. X    }
  2875. X
  2876. X/* more coroutine stuff */
  2877. X
  2878. XA: 
  2879. X    switch(An)
  2880. X    {
  2881. X    case 0: goto A0;
  2882. X    case 1: goto A1;
  2883. X    }
  2884. X
  2885. XB: 
  2886. X    switch(Bn)
  2887. X    {
  2888. X    case 0: goto B0;
  2889. X    case 1: goto B1;
  2890. X    }
  2891. X}
  2892. END_OF_FILE
  2893. if test 2585 -ne `wc -c <'k7dec.c'`; then
  2894.     echo shar: \"'k7dec.c'\" unpacked with wrong size!
  2895. fi
  2896. # end of 'k7dec.c'
  2897. fi
  2898. if test -f 'k8enc.c' -a "${1}" != "-c" ; then 
  2899.   echo shar: Will not clobber existing file \"'k8enc.c'\"
  2900. else
  2901. echo shar: Extracting \"'k8enc.c'\" \(2737 characters\)
  2902. sed "s/^X//" >'k8enc.c' <<'END_OF_FILE'
  2903. X/* k8enc.c - encode for Kermit's 8-bit window (0x20-0x7e, 0xa0-0xfe).
  2904. XSpeeds Kermit transfer of compressed files for 8-bit channels, use 
  2905. Xwith k8enc.  For 7-bit channels with parity use k7enc and k7dec.
  2906. X
  2907. XAuthor:    Glenn E. Thobe    <thobe@getunx.info.com>
  2908. X
  2909. XCopyright (C) 1992, Glenn E. Thobe, Canoga Park, California, USA.
  2910. XAll rights reserved.  Permission is granted to any individual 
  2911. Xor institution to use, copy, or redistribute this software so 
  2912. Xlong as it is not sold for profit, provided this copyright 
  2913. Xnotice is retained.
  2914. X
  2915. XK8enc prepares a compressed file to be transferred by Kermit in
  2916. Xbinary mode and decoded by k8dec.  As a filter, its typical
  2917. Xusage with the compressed file.Z might be:
  2918. X
  2919. X    k8enc < file.Z | kermit -is -     (sender)
  2920. X    kermit -ik | k8dec > file.Z       (receiver)
  2921. X
  2922. XWith a text file the following is also useful:
  2923. X
  2924. X    compress < file.txt | k8enc | kermit -is -     (sender)
  2925. X    kermit -ik | k8dec | uncompress > file.txt     (receiver)
  2926. X
  2927. XK8enc and k8dec feature a special non-linear mapping which avoids
  2928. Xall ASCII control characters and makes optimal use of the Kermit's 
  2929. Xentire 8-bit ASCII-printable code space.  Thus Kermit has no need
  2930. Xof control prefixing (except for the control prefix itself which 
  2931. Xis doubled).
  2932. X*/
  2933. X
  2934. X/* REVISION HISTORY:
  2935. XSat Feb  8 22:15:47 PST 1992    initial release -g.t.
  2936. X*/
  2937. X
  2938. X/* call coroutine */
  2939. X#define A_CALL_B(x,Ax) do{An=x;goto B;Ax:;}while(0)    /* K&R C version */
  2940. X#define B_CALL_A(x,Bx) do{Bn=x;goto A;Bx:;}while(0)    /* K&R C version */
  2941. X
  2942. X#define min(x,y) ((x)>(y))?(y):(x)
  2943. X#define MAP(x) ((x)+(((x)<0x5f)?0x20:0x41))    /* map to printables */
  2944. X
  2945. X#include <stdio.h>
  2946. X
  2947. Xvoid
  2948. Xmain()
  2949. X{
  2950. X    int An, Bn;
  2951. X    int c, m, h, w, inbuf, u, eof, old_eof;
  2952. X    static int rmask[]={0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
  2953. X
  2954. X    /* initialize coroutine linkage */
  2955. X    An = 0;
  2956. X    Bn = 0;
  2957. X    goto A;
  2958. X
  2959. X    /* input 1-8 bits as per request */
  2960. XA0:
  2961. X    h = 0;
  2962. X    old_eof = eof = 0;
  2963. X    inbuf = 0;
  2964. X    while(1)
  2965. X    {
  2966. X    A_CALL_B(1,A1);
  2967. X    if (h < w)
  2968. X    {
  2969. X        u = getchar();
  2970. X        eof = feof(stdin);
  2971. X        inbuf <<= 8;
  2972. X        if(!eof) inbuf += u;
  2973. X        h += 8;
  2974. X    }
  2975. X    c = (inbuf >> (h - w)) & rmask[w];
  2976. X    h -= w;
  2977. X    }
  2978. X
  2979. X    /* assemble and output encoded bytes */
  2980. XB0:
  2981. X    w = 8;
  2982. X    B_CALL_A(1,B1);
  2983. X    while(1)
  2984. X    {
  2985. X    if (c < 0x84)
  2986. X    {
  2987. X        m = c;
  2988. X        putchar(MAP(m >> 1));
  2989. X        if (eof && h < 7) exit(0);
  2990. X        w = 7;
  2991. X        B_CALL_A(2,B2);
  2992. X        c += (m & 0x01) << 7;
  2993. X    }
  2994. X    else
  2995. X    {
  2996. X        putchar(MAP(c-0x42));
  2997. X        if (eof && h < 8) exit(0);
  2998. X        w = 8;
  2999. X        B_CALL_A(3,B3);
  3000. X    }
  3001. X    old_eof = eof;
  3002. X    }
  3003. X    exit(0);
  3004. X
  3005. X/* more coroutine stuff */
  3006. X
  3007. XA: 
  3008. X    switch(An)
  3009. X    {
  3010. X    case 0: goto A0;
  3011. X    case 1: goto A1;
  3012. X    }
  3013. X
  3014. XB: 
  3015. X    switch(Bn)
  3016. X    {
  3017. X    case 0: goto B0;
  3018. X    case 1: goto B1;
  3019. X    case 2: goto B2;
  3020. X    case 3: goto B3;
  3021. X    }
  3022. X}
  3023. END_OF_FILE
  3024. if test 2737 -ne `wc -c <'k8enc.c'`; then
  3025.     echo shar: \"'k8enc.c'\" unpacked with wrong size!
  3026. fi
  3027. # end of 'k8enc.c'
  3028. fi
  3029. if test -f 'k8dec.c' -a "${1}" != "-c" ; then 
  3030.   echo shar: Will not clobber existing file \"'k8dec.c'\"
  3031. else
  3032. echo shar: Extracting \"'k8dec.c'\" \(2500 characters\)
  3033. sed "s/^X//" >'k8dec.c' <<'END_OF_FILE'
  3034. X/* k8dec.c - decode for Kermit's 8-bit window (0x20-0x7e, 0xa0-0xfe).
  3035. XSpeeds Kermit transfer of compressed files for 8-bit channels, use 
  3036. Xwith k8enc.  For 7-bit channels with parity use k7enc and k7dec.
  3037. X
  3038. XAuthor:    Glenn E. Thobe    <thobe@getunx.info.com>
  3039. X
  3040. XCopyright (C) 1992, Glenn E. Thobe, Canoga Park, California, USA.
  3041. XAll rights reserved.  Permission is granted to any individual 
  3042. Xor institution to use, copy, or redistribute this software so 
  3043. Xlong as it is not sold for profit, provided this copyright 
  3044. Xnotice is retained.
  3045. X
  3046. XK8dec recovers a compressed file which has been encoded by k8enc 
  3047. Xand transferred by Kermit in binary mode.  As a filter, its typical
  3048. Xusage with the compressed file.Z might be:
  3049. X
  3050. X    k8enc < file.Z | kermit -is -     (sender)
  3051. X    kermit -ik | k8dec > file.Z       (receiver)
  3052. X
  3053. XWith a text file the following is also useful:
  3054. X
  3055. X    compress < file.txt | k8enc | kermit -is -     (sender)
  3056. X    kermit -ik | k8dec | uncompress > file.txt     (receiver)
  3057. X
  3058. XK8enc and k8dec feature a special non-linear mapping which avoids
  3059. Xall ASCII control characters and makes optimal use of the Kermit's 
  3060. Xentire 8-bit ASCII-printable code space.  Thus Kermit has no need
  3061. Xof control prefixing (except for the control prefix itself
  3062. Xwhich is doubled).
  3063. X*/
  3064. X
  3065. X/* REVISION HISTORY:
  3066. XSat Feb  8 22:15:47 PST 1992    initial release -g.t.
  3067. X*/
  3068. X
  3069. X/* call coroutine */
  3070. X#define A_CALL_B(x,Ax) do{An=x;goto B;Ax:;}while(0)    /* K&R C version */
  3071. X#define B_CALL_A(x,Bx) do{Bn=x;goto A;Bx:;}while(0)    /* K&R C version */
  3072. X
  3073. X#define UNMAP(x) ((x)-(((x)<0x80)?0x20:0x41))    /* unmap from printables */
  3074. X
  3075. X#include <stdio.h>
  3076. X#include <assert.h>
  3077. X
  3078. Xvoid
  3079. Xmain()
  3080. X{
  3081. X    int An, Bn;
  3082. X    int c, m, h, w, t, u, inbuf;
  3083. X    static int rmask[]={0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
  3084. X
  3085. X    /* initialize coroutine linkage */
  3086. X    An=0;
  3087. X    Bn=0;
  3088. X    goto A;
  3089. X
  3090. X    /* input 1-8 bits as per request */
  3091. XA0:
  3092. X    h = 0;
  3093. X    inbuf = 0;
  3094. X    while(1)
  3095. X    {
  3096. X    A_CALL_B(1,A1);
  3097. X    while (h < w)
  3098. X    {
  3099. X        t = getchar();
  3100. X        if (feof(stdin)) exit(0);
  3101. X        u = UNMAP(t);
  3102. X        if (u < 0x42)
  3103. X        {
  3104. X        inbuf <<= 7;
  3105. X        inbuf += u;
  3106. X        h += 7;
  3107. X        }
  3108. X        else
  3109. X        {
  3110. X        u += 0x42;
  3111. X        inbuf <<= 8;
  3112. X        inbuf += u;
  3113. X        h += 8;
  3114. X        }
  3115. X    }
  3116. X    c = (inbuf >> (h - w)) & rmask[w];
  3117. X    h -= w;
  3118. X    }
  3119. X
  3120. X    /* dissemble encoded bytes and output */
  3121. XB0:
  3122. X    while(1)
  3123. X    {
  3124. X    w = 8;
  3125. X    B_CALL_A(1,B1);
  3126. X    putchar(c);
  3127. X    }
  3128. X
  3129. X/* more coroutine stuff */
  3130. X
  3131. XA: 
  3132. X    switch(An)
  3133. X    {
  3134. X    case 0: goto A0;
  3135. X    case 1: goto A1;
  3136. X    }
  3137. X
  3138. XB: 
  3139. X    switch(Bn)
  3140. X    {
  3141. X    case 0: goto B0;
  3142. X    case 1: goto B1;
  3143. X    }
  3144. X}
  3145. END_OF_FILE
  3146. if test 2500 -ne `wc -c <'k8dec.c'`; then
  3147.     echo shar: \"'k8dec.c'\" unpacked with wrong size!
  3148. fi
  3149. # end of 'k8dec.c'
  3150. fi
  3151. if test -f 'k7verify.ksh' -a "${1}" != "-c" ; then 
  3152.   echo shar: Will not clobber existing file \"'k7verify.ksh'\"
  3153. else
  3154. echo shar: Extracting \"'k7verify.ksh'\" \(90 characters\)
  3155. sed "s/^X//" >'k7verify.ksh' <<'END_OF_FILE'
  3156. Xfor i
  3157. X{
  3158. X    echo "testing on file $i"
  3159. X    k7enc < $i | k7dec | cmp - $i
  3160. X}
  3161. Xecho "finished"
  3162. END_OF_FILE
  3163. if test 90 -ne `wc -c <'k7verify.ksh'`; then
  3164.     echo shar: \"'k7verify.ksh'\" unpacked with wrong size!
  3165. fi
  3166. chmod +x 'k7verify.ksh'
  3167. # end of 'k7verify.ksh'
  3168. fi
  3169. if test -f 'k8verify.ksh' -a "${1}" != "-c" ; then 
  3170.   echo shar: Will not clobber existing file \"'k8verify.ksh'\"
  3171. else
  3172. echo shar: Extracting \"'k8verify.ksh'\" \(90 characters\)
  3173. sed "s/^X//" >'k8verify.ksh' <<'END_OF_FILE'
  3174. Xfor i
  3175. X{
  3176. X    echo "testing on file $i"
  3177. X    k8enc < $i | k8dec | cmp - $i
  3178. X}
  3179. Xecho "finished"
  3180. END_OF_FILE
  3181. if test 90 -ne `wc -c <'k8verify.ksh'`; then
  3182.     echo shar: \"'k8verify.ksh'\" unpacked with wrong size!
  3183. fi
  3184. chmod +x 'k8verify.ksh'
  3185. # end of 'k8verify.ksh'
  3186. fi
  3187. echo shar: End of shell archive.
  3188. exit 0
  3189.  
  3190. 17-Mar-93 21:42:31-GMT,2861;000000000001
  3191. Return-Path: <mtdcr!ptm@mtune.att.com>
  3192. Received: from att-out.att.com by watsun.cc.columbia.edu (5.59/FCB/jba)
  3193.     id AA07725; Wed, 17 Mar 93 16:42:24 EST
  3194. Message-Id: <9303172142.AA07725@watsun.cc.columbia.edu>
  3195. From: mtdcr!ptm@mtune.att.com
  3196. Date: Wed, 17 Mar 93 16:40 EST
  3197. To: fdc@watsun.cc.columbia.edu
  3198. Subject: Compression FYI
  3199.  
  3200. Frank -  (from Peter Mauzey)   March 17, 1993
  3201.  
  3202. You may recall months ago asking about a compression algorithm that
  3203. is free of patent infringements.  Hence the following quote, FYI.
  3204. I'm not sure Keith is correct in his assertion about "patented algorithms."
  3205.  
  3206. ------ quote start -----
  3207. Date: Sun, 14 Mar 1992 20:41:10 EST [ Really 1993 ]
  3208. From: w8sdz@TACOM-EMH1.Army.Mil (Keith Petersen)
  3209. To: MSDOS-Ann@TACOM-EMH1.Army.Mil
  3210. Subject: GZIP106.ZIP - GNU zip: Unix compress/uncompress replacement
  3211. Message-Id: <9303142041.12979.w8sdz@TACOM-EMH1.Army.Mil>
  3212.  
  3213. I have uploaded to WSMR-SIMTEL20.Army.Mil and OAK.Oakland.Edu:
  3214.  
  3215. pd1:<msdos.compress>
  3216. GZIP106.ZIP     GNU zip: Unix compress/uncompress replacement
  3217.  
  3218. gzip (GNU zip) is a compression utility designed to be a replacement
  3219. for 'compress'.  Its main advantages over compress are much better
  3220. compression and freedom from patented algorithms.  The GNU Project
  3221. uses it as the standard compression program for its system. 
  3222.  
  3223. gzip currently uses by default the LZ77 algorithm used in zip 1.9 (the
  3224. portable pkzip compatible archiver).  The gzip format was however
  3225. designed to accommodate several compression algorithms. 
  3226.  
  3227. gunzip can currently decompress files created by gzip, zip (with
  3228. restrictions), compress or pack.  (The SCO 'compress -H' format will be
  3229. supported in a future version).  The detection of the input format is
  3230. automatic.  When using the first two formats, gunzip checks a 32 bit
  3231. CRC.  For pack, gunzip checks the uncompressed length.  The 'compress'
  3232. format was not designed to allow consistency checks.  However gunzip is
  3233. sometimes able to detect a bad .Z file because there is some redundancy
  3234. in the .Z compression format.  If you get an error when uncompressing
  3235. a .Z file, do not assume that the .Z file is correct simply because the
  3236. standard uncompress does not complain.  This generally means that the
  3237. standard uncompress does not check its input, and happily generates
  3238. garbage output. 
  3239.  
  3240. Those who need the source in order to compile this program on other
  3241. platforms please see files GZIP106.TAR-Z and GZIPREAD.ME in SIMTEL20
  3242. directory PD8:<MISC.UNIX> or OAK directory /pub/misc/unix.
  3243.  
  3244. Keith
  3245. --
  3246. Keith Petersen
  3247. Maintainer of the MS-DOS archive at WSMR-SIMTEL20.Army.Mil [192.88.110.20]
  3248. Internet: w8sdz@TACOM-EMH1.Army.Mil     or      w8sdz@Vela.ACS.Oakland.Edu
  3249. Uucp: uunet!umich!vela!w8sdz                         BITNET: w8sdz@OAKLAND
  3250. ------ quote end -----
  3251.  
  3252. Peter Mauzey   908 957-3887       ptm@mtdcr.att.com
  3253. Bell Labs, 200 Laurel Avenue, Room 1A-301, Middletown, NJ  07748-4801
  3254.  
  3255.  1-Dec-93 21:34:56-GMT,9258;000000000001
  3256. Return-Path: <beebe@math.utah.edu>
  3257. Received: from csc-sun.math.utah.edu by watsun.cc.columbia.edu (5.59/FCB/jba)
  3258.     id AA11988; Wed, 1 Dec 93 16:34:53 EST
  3259. Received: from solitude.math.utah.edu by math.utah.edu (4.1/SMI-4.1-utah-csc-server)
  3260.     id AA06920; Wed, 1 Dec 93 14:34:50 MST
  3261. Date: Wed, 1 Dec 93 14:34:50 MST
  3262. From: "Nelson H. F. Beebe" <beebe@math.utah.edu>
  3263. To: fdc@watsun.cc.columbia.edu
  3264. Cc: beebe@math.utah.edu, bowman@math.utah.edu
  3265. X-Us-Mail: "Center for Scientific Computing, South Physics, University of
  3266.         Utah, Salt Lake City, UT 84112"
  3267. X-Telephone: +1 801 581 5254
  3268. X-Fax: +1 801 581 4148
  3269. Subject: Kermit and dynamic compression
  3270. Message-Id: <CMM.0.90.2.754781688.beebe@solitude.math.utah.edu>
  3271.  
  3272. During the last year, implementations of the UNIX ftpd have become
  3273. available that support dynamic archiving (tar, arc, zip, zoo) and
  3274. compression (compress, gzip) for ftp "get" and "mget" commands.  For
  3275. compression, the data transfer volume is often reduced to 1/3 to 1/4
  3276. of what it would be without that compression; some representative
  3277. figures are given below.
  3278.  
  3279. For compression at least, the code changes are very very small: just
  3280. replace
  3281.  
  3282.         fp = fopen(filename,"r");
  3283.         ...
  3284.         (void)fclose(fp);
  3285.  
  3286. with
  3287.         char buffer[MAXFILENAME + xxx];
  3288.         sprintf(command,"gzip < %s",filename);
  3289.         fp = popen(command,"r");
  3290.         ...
  3291.         (void)pclose(fp);
  3292.  
  3293. popen()/pclose() are defined in POSIX and X/Open, so most UNIX
  3294. implementations already have them.  Otherwise, they can be synthesized
  3295. from fork() and exec(), and I'm confident that freely-distribution
  3296. versions of suitable code could be found on the Internet, or
  3297. straightforwardly written.  [xarchie found these a few seconds ago:
  3298.  
  3299. irisa.irisa.fr:/News/Jukebox/comp.sources.atari.st/volume04/popen
  3300. spud.hyperion.com:/Atari/sources/volume4/popen
  3301.  
  3302. ]
  3303.  
  3304. ftpd is somewhat fancier, since it allows the command lines to be
  3305. specified in an external file, along with matching extensions, making
  3306. it possible to extend the choice of archive and compression techniques
  3307. without code modification.  A typical example is appended to this
  3308. message.
  3309.  
  3310. The current Kermit implementation, 5A(189), for UNIX uses run-length
  3311. encoding, as implemented in function encode() in ckcfns.c.  For
  3312. certain types of files (e.g. those with long strings of blanks or
  3313. NULs, or binary images with constant backgrounds), this works quite
  3314. well.  However, the compression algorithms of gzip at present seem to
  3315. outperform almost everything that I've tried (gzip often beats
  3316. compress by about 25%, and both are much better than the dynamic
  3317. Huffman encoding of UNIX pack/unpack).
  3318.  
  3319. Here is a single comparison of gzip and compress on the UNIX (Sun
  3320. SunOS 4.1.3) executable, /usr/local/bin/reduce, the largest one in
  3321. that directory on our system:
  3322.  
  3323. -rwxrwxr-x  1 bowman    5414912 Jun 10  1991 /usr/local/bin/reduce
  3324. -rw-rw-r--  1 beebe      601721 Dec  1 14:06 /tmp/reduce.Z
  3325. -rw-rw-r--  1 beebe      294912 Dec  1 14:06 /tmp/reduce.gz
  3326.  
  3327. compress decreased the file size by a factor of 601721/5414912 = 0.11,
  3328. while gzip decreased it by a factor of 294912/5414912 = 0.05.
  3329.  
  3330. For a large text file, the Steele/Raymond `New Hacker's Dictionary',
  3331. we have
  3332.  
  3333. -rw-rw-r--  1 beebe     1367403 Jul 27 21:04 jargon.info
  3334. -rw-rw-r--  1 beebe      587751 Dec  1 14:19 /tmp/jargon.info.Z
  3335. -rw-rw-r--  1 beebe      523845 Dec  1 14:20 /tmp/jargon.info.gz
  3336.  
  3337. compress reduces the file by a factor of 0.43, and gzip, by
  3338. 0.35.
  3339.  
  3340. For a much more rigorous test, here are the compression results for
  3341. our last night's file system backup with amanda (Advanced Maryland
  3342. Automatic Network Disk Archiver), which uses the standard UNIX
  3343. compress utility.  The COMP% column shows the degree of compression
  3344. achieved for each file system, a total of 3.4GB of data:
  3345.  
  3346. STATISTICS:
  3347.                           Total       Full      Daily
  3348.                         --------   --------   --------
  3349. Dump Time (hrs:min)        6:57       4:27       0:39   (0:32 start, 1:19 idle)
  3350. Output Size (meg)        1550.2      995.8      554.4
  3351. Original Size (meg)      3430.4     2389.0     1041.5
  3352. Avg Compressed Size (%)    39.9       41.7       34.2
  3353. Tape Used (%)              36.9       23.7       13.2   (level:#disks ...)
  3354. Filesystems Dumped           23          3         20   (1:15 2:4 3:1)
  3355. Avg Dump Rate (k/s)        51.0       61.6       38.9
  3356. Avg Tp Write Rate (k/s)    86.4       63.7      241.6
  3357.  
  3358. DUMP SUMMARY:
  3359.                                    DUMPER STATS                  TAPER STATS
  3360.   HOSTNAME   DISK   LV  ORIG-KB   OUT-KB  COMP%  MMM:SS   KB/s  MMM:SS   KB/s
  3361.   --------------------  --------------------------------------  -------------
  3362.   alfred     rz0a    1      198      100   50.8    0:12    8.2    0:16    8.0
  3363.   alfred     rz0h    1    70152    40085   57.1   13:18   50.2    1:33  433.2
  3364.   alfred     rz2a    1     4967     1020   20.5    1:48    9.5    0:12   85.6
  3365.   alfred     rz3a    0  1649058   630695   38.2  230:27   45.6  230:36   45.6
  3366.   alfred     rz5a    2   154888    58652   37.9   28:05   34.8    2:20  417.9
  3367.   csc-sun    xd0a    1    18412    18412    --     2:05  147.8    0:46  403.9
  3368.   csc-sun    xd0g    1      272      272    --     1:22    3.3    0:08   34.9
  3369.   csc-sun    xd0h    2    57012    57012    --     9:03  105.0    2:05  455.1
  3370.   csc-sun    xd1g    1    67337    50299   74.7   17:09   48.9   17:17   48.5
  3371.   csc-sun    xd1h    1    34372    34372    --    12:25   46.1    1:28  391.7
  3372.   csc-sun    xd3c    2    26432    26432    --     6:28   68.1    1:10  376.9
  3373.   csc-sun    xd4c    1    33992    33992    --     7:14   78.2    1:26  395.4
  3374.   csc-sun    xd5c    3   138462   138462    --    25:30   90.5    5:22  430.6
  3375.   eros       erosb   0   138333    28705   20.8   10:26   45.8    1:18  370.7
  3376.   eros       root    1    25940     8855   34.1    3:54   37.8    0:26  340.0
  3377.   geronimo   geroni  1   355416    59176   16.6   12:17   80.3    2:14  441.4
  3378.   geronimo   root    0   658900   360265   54.7   34:58  171.7   35:06  171.0
  3379.   honeycomb  root    2    14495     1910   13.2    1:07   28.6    0:13  145.0
  3380.   saturna    root    1      412      131   31.9    0:29    4.5    0:07   21.5
  3381.   sparky     sd0a    1     6076     1237   20.4    3:10    6.5    0:19   67.4
  3382.   sparky     sd0g    1      107       48   44.9    0:28    1.7    0:07    9.1
  3383.   sparky     sd1c    1    55902    36969   66.1   96:50    6.4    1:33  399.8
  3384.   todd       root    1     1642      308   18.7    0:30   10.2    0:08   38.9
  3385.  
  3386.  
  3387. So, the question arises, have the Kermit developers considered
  3388. supporting this kind of dynamic compression, at least with a UNIX
  3389. kermit server?
  3390.  
  3391. The general idea would be that the user would type
  3392.  
  3393.         kermit> get foo
  3394.  
  3395. to get the original file foo, and
  3396.  
  3397.         kermit> get foo.gz
  3398. or
  3399.         kermit> get foo.Z
  3400.  
  3401. to get foo.gz or foo.Z if they exist, but OTHERWISE, to dynamically
  3402. invoke gzip or compress via popen(), and send the compressed file to
  3403. the user's machine.  If foo is a directory, a "get foo.tar" or "get
  3404. foo.tar.gz" or "get foo.tar.Z" could dynamically invoke tar and
  3405. optionally, gzip or compress.
  3406.  
  3407. ftpd/ftp provide no facility for dynamic decompression or
  3408. de-archiving, and I see no strong need to do so for kermit either,
  3409. although, clearly, it could be an option, e.g. "get/decompress foo.Z"
  3410. or "get/untar foo.tar".  The latter would make it possible for kermit
  3411. to move entire directory trees with a single user command.
  3412.  
  3413. ------------------------------------------------------------------------
  3414.  
  3415. # This is /usr/local/etc/ftpconversions
  3416. # File format:
  3417. # strip prefix:strip postfix:addon prefix:addon postfix:external command:types:options:description
  3418. #
  3419. # For example,
  3420. # :  :  :.tar.Z:/bin/tar -c --compress -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
  3421. # says that a get of foo.tar.Z should execute the command
  3422. # /bin/tar -c --compress -f - foo
  3423. # return the piped output as foo.tar.Z.
  3424. #
  3425. # The line
  3426. # :.Z:  :  :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  3427. # says that a get of foo for the file foo.Z should run
  3428. # /bin/compress -d -c foo.Z
  3429. # and return the piped output as foo
  3430. #
  3431.  :.Z:  :  :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  3432.  :-z:  :  :/bin/compress -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  3433.  :.z:  :  :/bin/gunzip -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  3434.  :.trz: :.tar:/bin/gunzip -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  3435.  :.tar: :.trz:/bin/gunzip -d -c %s:T_REG|T_ASCII:O_UNCOMPRESS:UNCOMPRESS
  3436.  :  :  :.Z:/bin/compress -c %s:T_REG:O_COMPRESS:COMPRESS
  3437.  :  :  :.z:/bin/gzip -c %s:T_REG:O_COMPRESS:COMPRESS
  3438.  :  :  :.tar:/bin/tar -c -f - %s:T_REG|T_DIR:O_TAR:TAR
  3439.  :  :  :.tar.Z:/bin/tar -c --compress -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
  3440.  :  :  :.tar.z:/bin/tar -c --gzip -f - %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
  3441.  :  :  :.zoo:/bin/ZOO %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
  3442.  :  :  :.zip:/bin/ZIP %s:T_REG|T_DIR:O_COMPRESS|O_TAR:TAR+COMPRESS
  3443.  
  3444.  
  3445. ========================================================================
  3446. Nelson H. F. Beebe                      Tel: +1 801 581 5254
  3447. Center for Scientific Computing         FAX: +1 801 581 4148
  3448. Department of Mathematics, 105 JWB      Internet: beebe@math.utah.edu
  3449. University of Utah
  3450. Salt Lake City, UT 84112, USA
  3451. ========================================================================
  3452.  
  3453.  1-Dec-93 22:02:41-GMT,2148;000000000001
  3454. Return-Path: <fdc>
  3455. Received: by watsun.cc.columbia.edu (5.59/FCB/jba)
  3456.     id AA14144; Wed, 1 Dec 93 17:02:36 EST
  3457. Date: Wed, 1 Dec 93 17:02:35 EST
  3458. From: Frank da Cruz <fdc@watsun.cc.columbia.edu>
  3459. To: "Nelson H. F. Beebe" <beebe@math.utah.edu>
  3460. Cc: bowman@math.utah.edu
  3461. Subject: Re: Kermit and dynamic compression
  3462. In-Reply-To: Your message of Wed, 1 Dec 93 14:34:50 MST
  3463. Message-Id: <CMM.0.90.4.754783355.fdc@watsun.cc.columbia.edu>
  3464.  
  3465. > During the last year, implementations of the UNIX ftpd have become
  3466. > available that support dynamic archiving (tar, arc, zip, zoo) and
  3467. > compression (compress, gzip) for ftp "get" and "mget" commands...
  3468. > ...
  3469. > So, the question arises, have the Kermit developers considered
  3470. > supporting this kind of dynamic compression, at least with a UNIX
  3471. > kermit server?
  3472. Yes indeed.  There is a discussion of it in the file kermit/e/compress.txt on
  3473. kermit.columbia.edu, where you will find your own message as the latest
  3474. entry.  (Well, except for this one.)  And no, nothing as simplistic as running
  3475. things through gzip would do the trick.  Sure it's easy in UNIX, but any
  3476. higher-order compression method we adopt is going to have to meet certain
  3477. important criteria:
  3478.  
  3479.  . It must be portable among all OS's and file systems.
  3480.  
  3481.  . It must be designed to produce a data stream that contains no
  3482.    control or 8-bit characters (depending on Kermit's PARITY and
  3483.    SET CONTROL settings), so that Kermit's transparency encoding
  3484.    does not undo the effects of compression.
  3485.  
  3486. Even if we liked the idea of using popen() to run a file through gzip
  3487. before sending it, it still wouldn't be right.  Before compressing a
  3488. text file, we need to convert its character set and record format, otherwise
  3489. it'll be garbage after decompression on the receiving end.  And vice versa.
  3490.  
  3491. So don't worry, compression is high up on the list of items to add to the
  3492. Kermit protocol, pretty much right behind checkpoint/restart.  But it's not
  3493. simple.
  3494.  
  3495. Meanwhile, of course, when transferring between two UNIX systems, you can
  3496. already pipe stuff through C-Kermit, and that applies to compress, gzip,
  3497. crypt, sort, or anything else that works with stdio.
  3498.  
  3499. - Frank
  3500.  
  3501.