home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / protocol / streaming.txt < prev    next >
Text File  |  2020-01-01  |  33KB  |  759 lines

  1. KERMIT PROTOCOL STREAMING ON RELIABLE CONNECTIONS
  2.  
  3.   D R A F T   #   7
  4.  
  5.   Wed Dec 16 15:06:28 1998
  6.   Updated Fri Dec 24 16:50:25 1999 (chars that must be prefixed)
  7.  (First Draft: November 1997)
  8.  
  9.  
  10. THE PROBLEM
  11.  
  12. Kermit file transfer protocol has often been compared unfavorably with
  13. streaming protocols such as FTP, Zmodem (when configured to stream), and
  14. Ymodem-G.  Unlike Kermit, these protocols are designed to take full advantage
  15. of a reliable connection, so they can take liberties and therefore
  16. tend to go faster.  (Yes, that's the problem :-)
  17.  
  18. In recent years, Kermit protocol has proven itself as fast as, yet more robust
  19. than, other protocols on most serial communications connections.  Yet on
  20. TCP/IP connections, Kermit is often dramatically slower thant FTP, which can
  21. be attributed to underlying heuristics in the TCP/IP stack such as the Nagle
  22. and Delayed ACK algorithms.
  23.  
  24. First, some definitions:
  25.  
  26.  Transport:
  27.    The underlying connection on which the Kermit program writes and reads
  28.    Kermit packets.
  29.  
  30.  Primary Channel:
  31.    The portion of the connection used for sending packets from the file
  32.    sender to the file receiver.
  33.  
  34.  Reverse Channel:
  35.    The portion of the connection used for sending packets from the file
  36.    receiver to the file sender.
  37.  
  38. Unlike FTP, Ymodem-G, and (non-windowed) Zmodem, Kermit is a sliding-window
  39. protocol with selective retransmission, meaning every packet must be ACK'd,
  40. and selected packets can be retansmitted to fill in holes (in contrast to a
  41. go-back-to-n protocol in which any error rewinds the transfer to the point of
  42. error and starts over from there).  Thus, Kermit can become blocked waiting
  43. for application-level acknowledgements to arrive on the reverse channel.
  44.  
  45. Even when a window and packet size is used that is large enough to keep the
  46. primary channel fully occupied, the underlying transport might delay
  47. transmission of ACKs on the reverse channel because they are short, or because
  48. the reverse channel is congested, or for any other conceivable reason.
  49.  
  50. Kermit protocol is designed for unreliable transports where packets can be
  51. lost, damaged, duplicated, echoed, or delivered out of order.  Thus ACKs are
  52. required for every packet.
  53.  
  54.  
  55. A SOLUTION
  56.  
  57. But what if we have a reliable transport, such as the one that FTP always has?
  58.  
  59.  Reliable Transport:
  60.    A transport that delivers a data stream without loss or corruption and
  61.    with all bytes in the same order in which they were sent.  If it can't 
  62.    do that, it delivers a fatal i/o error.
  63.  
  64. Therefore, on a reliable transport, packets are never damaged, lost,
  65. duplicated, or delivered out of order as long as the connection remains open.
  66. Therefore, per-packet ACKs are not required, NAKs will never be sent, and
  67. retransmission is never necessary.
  68.  
  69. On such a connection, Kermit can be modified to not send or expect ACKs during
  70. the data phase of a file transfer.  This is called streaming; it is equivalent
  71. to using an infinite window size.
  72.  
  73. The object of streaming is to eliminate any ACK-related bottlenecks that would
  74. needlessly impede Kermit's performance on reliable connections, allowing it to
  75. perform comparably to other protocols that are specifically designed for
  76. reliable connections, but in a way that does not depend on specific knowledge
  77. about the underlying platform or transport.
  78.  
  79. Streaming is intended primarily for use on TCP/IP client/server connections,
  80. which will become more common once we have TCP-based Kermit servers similar to
  81. FTP servers, but can also be used in other settings.
  82.  
  83. HOW DO WE KNOW WHEN WE HAVE A RELIABLE TRANSPORT?
  84.  
  85. The Kermit program that makes the connection usually knows what the underlying
  86. transport is, and therefore whether it is reliable.  When it is a TCP
  87. connection, in most cases it can be considered reliable, since error
  88. detection, error correction, pacing, and sequencing are done by TCP, IP, and
  89. the layers below.  Similarly for X.25 and other reliable end-to-end protocols.
  90. A serial connection, on the other hand, should not be considered reliable,
  91. even when error-correcting modems are involved, for all the well-known reasons
  92. (lack of effective flow control, interrupt conflicts, loose wires, etc).
  93.  
  94. The remote Kermit can not usually tell what kind of connection it has, and so
  95. some means is required to tell it that it has a reliable one.  This can be
  96. done by command, or the information can be conveyed from the local Kermit via
  97. protocol.
  98.  
  99. In some cases, a reliable transport is not truly reliable.  Examples:
  100.  
  101.  . A Telnet connection might not be 8-bit clean.
  102.  . A TCP connection might be to a terminal server that makes a dialout call.
  103.  . A Telnet or Rlogin connection might be through an intermediate Telnet or
  104.    Rlogin client, which filters out the 8th bit or has an escape character. 
  105.  . Telnet to VMS can lose characters if the remote session has certain
  106.    parameters set, such as TERMINAL /NOTTSYNC and/or /NOHOSTSYNC.
  107.  
  108. Note: some of these are transparency problems, which are independent of
  109. whether the transport is reliable.
  110.  
  111. COMMANDS
  112.  
  113. Commands are necessary to let the user have the final say about whether a
  114. connection is reliable:
  115.  
  116.   SET RELIABLE { AUTOMATIC, ON, OFF }
  117.  
  118. And on the C-Kermit / K95 command line:
  119.  
  120.   kermit -I
  121.  
  122. (uppercase I, like Internet) specifies a reliable connection (used in
  123. remote mode).
  124.  
  125. SET RELIABLE ON (and -I) can have all sorts of effects, and so in themselves
  126. do not control the streaming feature.  If not given, then the Kermit program's
  127. internal "reliable" variable is set automatically according to the connection
  128. type.  Use this command to override Kermit's decision.
  129.  
  130. SET RELIABLE AUTO should be the default.  It allows the local Kermit to
  131. automatically SET RELIABLE ON or OFF according to the kind of connection it
  132. has made (normally, TCP and X.25 connections are reliable, others are not).
  133. It lets the remote Kermit learn whether the connection is reliable from the
  134. local one.
  135.  
  136. Streaming is controlled by a separate command:
  137.  
  138.   SET STREAMING { ON, OFF, AUTO }
  139.  
  140. AUTO should be the default setting for Kermit programs that support streaming.
  141.      It means that if the local Kermit program has SET RELIABLE ON, or if
  142.      is has SET RELIABLE AUTO and believes it has a reliable connection,
  143.      then it offers to stream.  With SET STREAMING AUTO and SET RELIABLE AUTO
  144.      (or ON), the remote Kermit always offers to stream.
  145.  
  146. ON   means that the Kermit program offers to stream no matter what kind of
  147.      connection it thinks it has.
  148.  
  149. OFF  means that the Kermit program refuses to stream.
  150.  
  151. Thus, in cases where both Kermit programs *know* they have a reliable
  152. connection, or when one Kermit knows and tells the other, streaming occurs
  153. automatically, in all others, it does not occur unless the user takes special
  154. action to enable it.
  155.  
  156. For example, if Kermit on A telnets to B and starts Kermit there, and 
  157. both RELIABLE and STREAMING have their default settings of AUTO, then Kermit A
  158. tells Kermit B the connection is reliable, and so they agree to stream.
  159.  
  160. If Kermit A telnets directly to a TCP socket on which Kermit B is listening
  161. for incoming connections, then both know they have a reliable connection, and
  162. streaming occurs automatically.
  163.  
  164. Both these scenarios can fail, of course, in the hopefully rare situation in
  165. which the caller has a TCP connection to a dialout terminal server, which is
  166. used to call another terminal server, from which a TCP connection is made
  167. directly to a Kermit socket.
  168.  
  169. The command, SHOW STREAMING, displays the current settings of the STREAMING
  170. and RELIABLE variables, and explains under what conditions streaming will be
  171. done, and whether it was done in the most recent file transfer, if any.
  172.  
  173.  
  174. NEGOTIATION
  175.  
  176. When STREAMING is ON, or when STREAMING is AUTO and the Kermit program
  177. believes it has a reliable connection, it offers to stream by setting Bit 3
  178. (reserved until now) in the WHATAMI byte of the Initialization String.  
  179.  
  180.   IMPORTANT:
  181.   The WHATAMI spec did not define this bit, and it specified that the 
  182.   FLAG3 bit was to be set when Bit 3 was defined.  This requirement has 
  183.   been  dropped; see next section.
  184.  
  185. If both Kermit programs set Bit 3, they will stream; if not, they will not
  186. stream.
  187.  
  188. Such agreement is not sticky; it does not persist beyond the transaction in
  189. which it was negotiated.
  190.  
  191. For best results, if possible, although it violates all principles of layered
  192. networking protocols, each Kermit program should ensure that the maximum
  193. packet length it allows the other to send is optimized for the underlying
  194. transport.  For example, if the TCP Maximum Segment Size is 1450, then 1450
  195. (or slightly less), or any multiple thereof up to 8700 (or the TCP SENDBUF
  196. size, whichever is less), would be a good choice, forcing Kermit packets to
  197. fit nicely withing TCP packets, whereas 1451 would be a terrible choice,
  198. causing a full-size TCP packet to be sent, and then a "runt" constructed that
  199. is likely to languish in an output buffer for some time due to TCP congestion
  200. avoidance heuristics.
  201.  
  202.  
  203. CLEARCHANNEL PROTOCOL
  204.  
  205. (Unrelated to streaming, but documented here anyway.)
  206.  
  207. The WHATAMI spec has never been published.  Therefore it is safe to change the
  208. definition of the FLAG3 bit in the WHATAMI byte.  Consider:
  209.  
  210.   . If Bit 3 is 0, there will be no streaming.
  211.  
  212.   . If Bit 3 is 1, there will be no streaming unless the other Kermit
  213.     knows about streaming and sets this bit also.  If it doesn't know about
  214.     streaming, it won't set this bit.
  215.  
  216. Since no streaming versions of Kermit have yet been released to the public,
  217. not even as alpha tests, there is no need for the FLAG3 bit and we can
  218. redefine it as follows:
  219.  
  220.   Bit 4: WMI_CLEAR
  221.  
  222. Each Kermit program sets this bit if it KNOWS it has an 8-bit connection that
  223. transparent to all 256 bit patterns, or a 7-bit connection transparent to all
  224. 128 bit patterns, EXCEPT allowing for the possibility that Telnet NVT rules
  225. might or might not apply.
  226.  
  227. The clear-channel property is independent of the 8-bit cleanliness (parity)
  228. and the reliability of the channel.  Thus, it is possible to have a clear
  229. channel on a 7-bit connection, or over an unreliable transport; the only
  230. criterion is that the channel be transparent to all 7-bit or 8-bit bytes, with
  231. the exceptions noted below.
  232.  
  233. A clear channel can be clearly identified when the program has opened a TCP
  234. socket, since most other communication paths are through devices that have
  235. escape characters or sequences (such as terminal servers or modems), or
  236. through an intermediate Telnet, Rlogin, or other connection program, etc.
  237.  
  238. Since remote-mode Kermit programs usually have no clue about the connection
  239. method, they normally will not believe they have a clear channel.
  240.  
  241. When a Kermit program receives a parameter string in which the clear-channel
  242. bit is set, this is permission to send any or all control characters without
  243. prefixing, except on Telnet connections, where the following must be prefixed:
  244.  
  245.  1. CR (decimal 13) because of NVT rules, and:
  246.  2. DEL (decimal 127) and IAC (decimal 255), and:
  247.  3. XOFF and XON (decimal 17 and 19), often used for flow control, and:
  248.  3. (optionally, but recommended for safety) the Kermit packet start and end
  249.     characters.
  250.  
  251. These exceptions allow for the possibility that the connection goes through 
  252. a Telnet server without knowing it.  If the Kermit program knows it has a
  253. connection that does not use Telnet NVT rules (such as, e.g., an Rlogin
  254. connection), it can omit (1) and (2).
  255.  
  256. Any Kermit program that sets the clear-channel bit must be capable of
  257. receiving ANY bit pattern within a packet, including NUL (0), CR (13),
  258. and IAC (255).
  259.  
  260. In the event of a misjudgment about the transparency of the channel, of course
  261. the transfer is likely to fail, but that has always been the case.
  262.  
  263. The user can override the automatic clear-channel determination with SET
  264. CLEARCHANNEL { ON, OFF, AUTO }.
  265.  
  266. The WHATAMI spec is hereby amended to redefine Bit 4; its old FLAG3 value 
  267. is retired and it is now the CLEARCHANNEL indicator.
  268.  
  269.  
  270. STREAMING PROTOCOL
  271.  
  272. Once the two Kermit partners have agreed to use streaming protocol, the
  273. transfer takes place in the normal manner, except:
  274.  
  275.  . Streaming is activated in the file receiver after the first F or X packet
  276.    is received, i.e. after it knows that streaming is negotiated and that
  277.    any retransmissions of the S/Y exchange have already occurred and so will
  278.    not be fatal.  From this point streaming remains in effect until the end
  279.    of the transaction, i.e. after the B/Y exchange or an E packet.
  280.  
  281.  . The sender does not wait for ACKs to D packets, but keeps sending the file
  282.    without pause until the end (unless interrupted), at which point it sends a
  283.    Z packet and waits for its ACK in the normal manner.
  284.    
  285.  . During the data phase, the file sender must sample the reverse channel in
  286.    case Error or cancellation packets arrive.  This can be done using a
  287.    nondestructive communications input-buffer peeking technique, and should
  288.    not affect performance
  289.  
  290.  . The receiver does not send ACKs for D packets, but simply decodes incoming
  291.    data and disposes of it in the normal manner (e.g. writes it to disk),
  292.    except when the user interrupts the transfer.
  293.  
  294.  . The receiver does not time out during streaming.  Once streaming is
  295.    negotiated, the timer it turned off until the end of the transaction.
  296.  
  297.  . The receiver does not send NAKs, since there is no longer any window
  298.    management -- the sender might be many window cycles ahead of the receiver
  299.    by the time a NAK arrives.  In any case, by the definition of "reliable
  300.    transport", there is no need for NAKs.  The underlying transport handles
  301.    timeouts, pacing, and flow control automatically.  When the Z packet
  302.    arrives, the file is closed and the Z packet is acknowledged.
  303.  
  304.  . If a damaged or out-of-sequence data packet arrives at the receiver during
  305.    streaming, this is fatal.  The receiver of such a packet must respond with
  306.    an Error packet and the transfer must cease.  Similarly, if a NAK packet
  307.    arrives at the sender during streaming, this too is fatal.
  308.  
  309.  . The Kermit partner that is in local mode must still sample the keyboard
  310.    for interruptions (cancel file, cancel batch, send Error packet & quit).
  311.    The "retransmit previous packet" interruption, however, should be ignored.
  312.  
  313.  . If a file (X) or group (Z) interruption is signaled from the keyboard to
  314.    the file receiver, only one ACK(X) or ACK(Z) should be sent.
  315.  
  316.  . The heuristic of clearing the communications input buffer when the window
  317.    size is 1 and the desired packet has just been received must not be used
  318.    when streaming.
  319.  
  320. It is essential that both sides either (a) engage in streaming protocol, or
  321. else (b) not engage in it.  No mixing and matching.  If the sender waits for
  322. ACKs that never come, the transfer will hang as soon as the first window
  323. fills.  If the sender gets ACKs or NAKs, it won't know which packet they are
  324. for and will not be able to handle them.
  325.  
  326. Additional notes:
  327.  
  328.  . Streaming is independent of other negotiated parameters like packet length,
  329.    and window size, 8th-bit prefixing, locking shifts, etc, and can be used in
  330.    either text- or binary-mode transfers.  It is also independent of
  331.    unilateral (non-negotiated) settings like control-character prefixing.
  332.  
  333.  . On TCP connections, it is helpful at the low level to issue read requests
  334.    for at least 1/2 the TCP Receive Window size; in many TCP/IP
  335.    implementations, this can have the effect of opening the TCP Receive Window
  336.    and therefore minimize blockage at the TCP level.
  337.  
  338.  
  339. STREAMING ON HALF-DUPLEX CONNECTIONS
  340.  
  341. Sliding windows requires a full-duplex connection to allow the file sender to
  342. sample the reverse channel.  But a half-duplex connection, such as we normally
  343. have to IBM mainframes, does not have a reverse channel; conceptually there is
  344. only one channel that switches direction back and forth.  In this case, once
  345. the sender begins streaming, the receiver will not be able to signal an
  346. interruption, and thus the transfer must proceed to completion.  If we are
  347. willing to accept this restriction, we can implement streaming in IBM
  348. Mainframe Kermit.
  349.  
  350. When a line-turnaround handshake character is used, as on an IBM mainframe
  351. linemode connection, the non-mainframe file sender should append it to each
  352. packet that requires an ACK (I, S, F, A, Z, B), but not to Data packets.
  353.  
  354.    
  355. STREAMING ON NOT-REALLY-RELIABLE CONNECTIONS
  356.  
  357. Certain connections might be reliable in all respects except transparency.
  358. For example, you might have Telnet connection that strips the 8th bit, or that
  359. is sensitive to certain control characters.  Streaming can still be used on
  360. such connections in conjunction with the appropriate Kermit adjustments,
  361. such as SET PARITY SPACE, SET CONTROL PREFIX <xxx>, etc.
  362.  
  363. Certain dialup connections using error-correcting modems and hardware flow
  364. control, in which the connection between each modem and its computer is also
  365. error-free by virtue of a lack of interrupt conflicts, noise, interference,
  366. loose connectors, buffer overruns, etc, might lend themselves streaming.
  367. Kermit allows you to try it if you want, at your own risk; just tell each
  368. Kermit partner to SET RELIABLE ON, and then make sure to also set up hardware
  369. flow control.
  370.  
  371. If a block check or sequencing error is detected during streaming, it is
  372. fatal; the message is "Transmission error detected on reliable link".  Kermit
  373. can detect errors and fail more promptly (and gracefully) than most other
  374. streaming protocols.
  375.  
  376.  
  377. PRELIMINARY RESULTS
  378.  
  379. All trials are conducted transferring real files over real network and serial
  380. connections (not internal "localhost" connections), disk-to-disk (no RAM
  381. disks, etc).  The conditions are real, not controlled; the hosts are shared,
  382. not dedicated, and when a network connection is involved, it too is a shared,
  383. production network.  Thus the numbers are not precise and repeatable.
  384. However, large numbers of samples over long periods of time tend to smooth
  385. over the effects of localized host or network effects.
  386.  
  387.  
  388. TRIAL 0:  TCP/IP, Local Ethernet
  389.  
  390. The first trial is only to give a feel for the effect of streaming over the
  391. widest possible range of Kermit packet and window sizes, rather than making
  392. assumptions.
  393.  
  394. Transferring a 4MB Sparc executable (the SunOS version of C-Kermit 6.1,
  395. concatenated with itself 4 times) from a Sparc-20 to an UltraSparc-xxx over
  396. 10BaseT (10Mbps), under moderate network and host load, using C-Kermit 6.1
  397. Alpha.10 on each end.  The two Kermit programs are connected via TCP directly
  398. socket-to-socket, rather than through a Telnet server.  Round-trip-time for
  399. ICMP echo is 2msec.
  400.  
  401. Kermit packet sizes of 480 to 8640 in increments of 480 (18 different sizes)
  402. were used in conjunction with window sizes 1-31 to transfer the file, once
  403. with streaming off, again with it on, for a total of 1116 samples.  For each
  404. sample, the speed in characters per second (CPS), plus the packet length,
  405. window size, and streaming status were recorded in a table, and the table was
  406. analyzed by SAS.  Univariate analysis of CPS figures showed:
  407.  
  408.                 Streaming    Nonstreaming
  409.   Max CPS         699050 (11)   699050 (2)
  410.   Min CPS          99864 (1)     47127 (1)
  411.   Mean CPS        441275        380094
  412.   Median CPS      455033        381300
  413.   Std Dev         123663        135782
  414.  
  415. By way of comparison, FTP transfer of the same file between the same two
  416. computers on the same network under the same conditions proceeded at between
  417. 150 and 180Kcps in 20 trials (before and after the Kermit trials).
  418.  
  419. Correlations of throughput with window size, packet length, and the product
  420. of packet length and window size (i.e. total packet buffer size) were:
  421.  
  422.                 Streaming    Nonstreaming
  423. Window Size (W):   -0.05          0.24
  424. Packet Length (P):  0.34          0.51
  425. W x P:              0.18          0.46
  426.  
  427. The insignificant figure for window size in the streaming case is not
  428. surprising, since streaming effectively ignores the window size setting.
  429.  
  430. The correlation between CPS and Streaming (0 or 1) was 0.23, a positive number
  431. indicating that there is a significant, if not strong, relationship between
  432. streaming and throughput; when streaming is used, throughput tends to be
  433. higher than when streaming is not used.
  434.  
  435. Out of 558 trials, streaming beat nonstreaming 346 times and equaled it
  436. 74 times.  Nonstreaming beat streaming 138 times.  Thus streaming was as good
  437. as or better than streaming in 75.3% of the cases.
  438.  
  439. An identical run performed late at night when the network and hosts were
  440. minimally loaded gave similar results, except with less variability due to
  441. load spikes:
  442.  
  443.                 Streaming    Nonstreaming
  444.   Std Dev          99265        147947
  445.  
  446. This shows that thoughput tends to be more consistent with streaming.
  447. Correlations in the late-night run were stronger too:
  448.  
  449.                 Streaming    Nonstreaming
  450. Window Size (W):    0.02          0.39
  451. Packet Length (P):  0.55          0.54
  452. W x P:              0.36          0.60
  453.  
  454. This run showed a 0.30 correlation between streaming and throughput.
  455.  
  456. A glance at the raw data shows that the maximum throughput (699Kcps) can 
  457. occur for almost any window size, including 1, but occurs most frequently when
  458. the window size is between 10 and 19:
  459.  
  460.   1-9:   6
  461.  10-19: 14  (The median window size for fastest transfers is 14)
  462.  20-31:  5
  463.  
  464. Maximum throughput never occurs unless the packet length is 4K or greater:
  465.  
  466.  0-3K:   0
  467.  4-5K:   3
  468.  5-6K:   5
  469.  6-7K:   2
  470.  7-8K:   6
  471.  8-9K:   7
  472.  
  473.  
  474. TRIAL 1.  TCP/IP, Local Ethernet
  475.  
  476. In this trial we transfer an 8MB file over the same connection as in Trial 0
  477. and vary the window size from 10-20 and the packet length from 4350 to 8700 by
  478. steps of 1450.  The idea is to rule out the cases where streaming wins
  479. automatically simply because it is equivalent to an infinite window size.
  480.  
  481.                 Streaming    Nonstreaming
  482.   Max CPS         682666        682666
  483.   Min CPS         341333        256000
  484.   Mean CPS        595009        563725
  485.   Median CPS      630153        630153
  486.   Std Dev          81941        109767
  487.  
  488.                 Streaming    Nonstreaming
  489. Window Size (W):    0.00          0.05
  490. Packet Length (P):  0.25          0.27
  491. W x P:              0.17          0.12
  492.  
  493. Correlation of CPS to Streaming (0 or 1): 0.16
  494.  
  495. Of the 44 pairs of transfers, streaming beat nonstreaming in 22, equaled it
  496. in 9, and lost in 13.  Thus it was better or equal to nonstreaming in 70.5%
  497. of the cases, but not by a huge amount.
  498.  
  499.  
  500. TRIAL 2.  Long-Distance TCP/IP, Moderate Latency
  501.  
  502. Same Sparc-20 host in NYC via Internet to Netlab1, a PC running Unixware
  503. 2.1.1, at Utah State University, socket-to-socket.  On this connection there
  504. is an average round-trip time of 69msec, and the available bandwidth is lower
  505. too.  Here we use a 1MB Sparc executable (the SunOS C-Kermit 6.1 executable)
  506. as the test file rather than the 4MB file, since 1MB takes enough seconds to
  507. transfer over this link to give good variation in throughput numbers.
  508.  
  509.                 Streaming    Nonstreaming       FTP
  510.   Max CPS         262144 (25)   262144 (15)    130000 (1)
  511.   Min CPS          52428 (1)      6026 (1)      50000 (1)
  512.   Mean CPS        164585        124784          74200
  513.   Median CPS      149796        123790          56000
  514.   Std Dev          56181         70618          29200
  515.  
  516. The FTP column is shown for comparison; 20 transfers of the same file in the
  517. same direction between the same two hosts were performed shortly before,
  518. during, and shortly after the Kermit transfers.
  519.  
  520. Correlations:
  521.                 Streaming    Nonstreaming
  522. Window Size (W):    0.34          0.57
  523. Packet Length (P): -0.05          0.44
  524. W x P:              0.16          0.69
  525.  
  526. CPS to Streaming:   0.30
  527.  
  528.  
  529. TRIAL 3.  Longer-Distance TCP/IP, Low Bandwidth, Greater Latency
  530.  
  531. From SunOS in NYC to a DECstation 5000 (MIPS) running Ultrix 4.3 at the Japan
  532. National Laboratory for High Energy Physics, about 18 hops and 13,000 miles
  533. away.  IP packet round-trip time is about 240 msec.  FTP consistently
  534. transferred files of various sizes at 3600 CPS.
  535.  
  536. In these trials, a 100,000-byte binary file was used (the first 100000 bytes
  537. of the Sparc C-Kermit executable).  Window sizes were in the 20-30 range,
  538. on the supposition that it's a long pipe and needs more to fill it.  Packet
  539. lengths are varied from 4350 to 8700.
  540.  
  541.                 Streaming    Nonstreaming
  542.   Max CPS           5000          5882
  543.   Min CPS            425 (1)       436
  544.   Mean CPS          2180          2978
  545.   Median CPS        1963          2941
  546.   Std Dev           1061          1198
  547.  
  548. Correlations:
  549.                 Streaming    Nonstreaming
  550. Window Size (W):   -0.28         -0.20
  551. Packet Length (P): -0.09         -0.24
  552. W x P:             -0.13         -0.29
  553.  
  554. CPS to Streaming:  -0.34
  555.  
  556. Now this is a curious result!  Increasing any of our performance options --
  557. window size, packet length, streaming -- tends to reduce performance.  No
  558. doubt there is an explanation, perhaps having to do with the extreme jerkiness
  559. of the connection.  But in any case, both streaming and nonstreaming Kermit
  560. transfers can outdo FTP on this connection, and streaming transfers do work as
  561. advertised; even though the connection is slow and has long delays, it is
  562. reliable.  Furthermore, the difference between streaming and nonstreaming is
  563. not large in absolute terms.
  564.  
  565.  
  566. TRIAL 4.  Simulated IBM Mainframe Connection
  567.  
  568. Here we are limited to 1 window slot, and the maximum packet length is 1920.
  569. We vary the packet length from 192 to 1920 in increments of 192, keeping the
  570. window size at 1, and transfer the 8M file with and without streaming.  The
  571. host is not actually an IBM mainframe, since streaming code has not been
  572. written for it, but rather a Solaris system with C-Kermit 6.1 using IBM
  573. Mainframe-like settings.
  574.  
  575.                 Streaming    Nonstreaming
  576.   Max CPS         524288 (2)    147168 (1)
  577.   Min CPS         335544 (1)     13378 (1)
  578.   Mean CPS        466280         84969
  579.   Median CPS      493447        144637
  580.   Std Dev          58844         54826
  581.  
  582. Correlation of CPS to Packet Length, Streaming:     0.83
  583. Correlation of CPS to Packet Length, Nonstreaming: -0.43  (???)
  584. Correlation of CPS to Streaming (0 or 1):           0.96
  585.  
  586. The effect of streaming in this case is dramatic.
  587.  
  588. (Granted, an IBM Mainframe Kermit program written specifically for TCP
  589. socket-to-socket connections would not have these limitations, but there's not
  590. much chance of that happening; however, the streaming modifications would be
  591. fairly simple to add to the existing mainframe version.)
  592.  
  593.  
  594. TRIAL 5.  TCP/IP, Local Network, Microsoft Winsock
  595.  
  596. IBM P90 Win95 to IBM PowerServer 850 with AIX 4.1.  
  597.  
  598. FTP goes at about 700Kcps.
  599.  
  600. First I tested today's K95 build by downloading an 8M file from watsun to the
  601. PC on the local Ethernet:
  602.  
  603.  . No streaming:     818Kcps 
  604.  . Streaming:        819Kcps
  605.  . Streaming/nodisk: 909Kcps (I know, it's cheating not to write to disk)
  606.  
  607. Consistently faster than ftp, and probably the fastest Kermit times for
  608. nontrivial files (i.e. at least 4 times bigger than the channel capacity in
  609. cps) ever seen.  And this was through the SunOS Telnet server, too.  But I
  610. could never reproduce these results again -- after that, the best transfers I
  611. could get were in the 340Kcps range, even after rebooting, no matter which
  612. host I used on the other end.  The mysteries of Windows, always the problem
  613. child, fooey...
  614.  
  615. Anyway, benchmarking from Windows 95 to AIX, window sizes 10 to 30, packet
  616. lengths 1450 to 9000, transferring the 8MB binary file from Windows to AIX
  617. over the local Ethernet.  It ran fine until trying to send an 86K TCP buffer
  618. (10 8600-byte Kermit packets), at which point it slowed to a crawl, like
  619. 45Kcps.  This is not good.  Manually changing the TCP SENDBUF to 200K gets
  620. around this problem (but why do I have to do that?).  Results:
  621.  
  622.                 Streaming    Nonstreaming
  623.   Max CPS         341333        303407
  624.   Min CPS         234057        141241
  625.   Mean CPS        306502        259081
  626.   Median CPS      321378        277774
  627.   Std Dev          33257         51867
  628.  
  629. Correlations:
  630.                 Streaming    Nonstreaming
  631. Window Size (W):   -0.05          0.14
  632. Packet Length (P):  0.89          0.90
  633. W x P:              0.85          0.90
  634.  
  635. CPS to Streaming:   0.50  (and in a later trial, this was 0.73).
  636.  
  637.  
  638. TRIAL 6.  Serial Connection, V.32bis, 14400bps
  639.  
  640. Preliminary serial trials were done using fixed large window and packet sizes.
  641. They compare uploading and downloading of two common types of files, with and
  642. without streaming.  Configuration:
  643.  
  644.   HP-9000/715/33 -- 57600bps, RTS/CTS -- Telebit T3000 -- V.32bis+V.42
  645.   14400bps -- USR V.34+ Rackmount -- 57600bps, RTS/CTS -- Cisco TS -- Solaris
  646.   2.5.1.  Packet size = 8000, Window Size = 30, Control Character Unprefixing
  647.   Minimal (but including ^^, the Cisco escape character).
  648.  
  649. This is not a truly reliable connection, and some trials failed when a bad
  650. packet was received (the failure was graceful and immediate, and the message
  651. was informative).  The results of ten successful trials uploading and
  652. downloading two files with and without streaming are:
  653.  
  654. Streaming    Up     Down
  655.        on   3387    3246   txt (= C source code, 78K)
  656.             1576    1548   gz  (= compressed gzip file, 85K)
  657.       off   3246    3246   txt
  658.             1576    1548   gz
  659.  
  660. Here we see little difference between streaming and nonstreaming.
  661.  
  662.  
  663. TRIAL 7.  Serial Connection, V.34+, 31200bps
  664.  
  665. Exactly like Trial 5, but dialing up with a USR Courier V.34+ rather than the
  666. Telebit T3000:
  667.  
  668. Streaming    Up     Down
  669.        on   5565    5565   txt (= C source code, 78K)
  670.             3406    3406   gz  (= compressed gzip file, 85K)
  671.       off   5194    5194   txt
  672.             3135    3041   gz
  673.  
  674. Here we see fairly noticable improvements with streaming.
  675.  
  676.  
  677. CONCLUSIONS
  678.  
  679. Further study needed.  First of all, rule out the "straw man" cases, in which
  680. packet and/or window sizes are held lower than the connection will allow,
  681. since this automatically (and artificially) makes streaming look better --
  682. sometimes ten, twenty, thirty, or forty times better.
  683.  
  684. After casting out these unhelpful cases, it appears on the whole that
  685. streaming usually helps.  But there are certain ones where it does not (such
  686. as the very slow connection to Japan), for reasons unknown.
  687.  
  688. The Windows 95 version of Kermit will need to set its TCP SENDBUF and RECVBUF
  689. to about 200K or else streaming will knock it dead in its tracks.  No other
  690. system exhibited this peculiarity.  (I did try this on the UNIX end once or
  691. twice and found that it made little difference.)
  692.  
  693. Although numerous lower-level tricks can be used to improve performance on
  694. specific platforms or connection methods, streaming occurs at a high,
  695. system-independent level of the Kermit protocol and therefore can apply to all
  696. types of platforms and (reliable) connections transparently.
  697.  
  698. Meanwhile, further tuning is also needed.  Even without streaming, the
  699. C-Kermit figures are pretty high due to recent internal tuning, and no doubt
  700. can be improved still more.
  701.  
  702.  
  703. APPENDIX I: Benchmark Script
  704.  
  705. local \&s[] \%w \%p \%i \%m
  706. local \%a \%c \%o \%d \%x \%e \%n
  707. declare \&s[2] off on
  708. def \%n 7
  709. declare \&p[\%n] 1450 2900 4350 5800 7250 8630 9010 ; Packet lengths
  710. def _file x ; Name of file to transfer
  711. def \%m 0
  712. def \%c 0
  713. def \%d 0
  714. def \%e 0
  715. set file display brief
  716. set control unprefix all
  717. set control prefix 0 1 255
  718. set transfer bell off
  719. set file patterns off
  720. set file type binary
  721. remote set file collision overwrite
  722. if fail stop 1 {REMOTE SET FILE COLLISION FAILED: \&s[\%i] \%w \%p}
  723. if open write close write
  724. if exist bench.log rename bench.log bench.log.\v(ndate).\v(ntime)
  725. open write bench.log
  726. if fail stop 1 BENCH.LOG: can't open
  727. write file {; BEGIN: \v(date) \v(time). }
  728. ask \%a { Log comment: }
  729. writeln file \%a
  730. writeln file {; FILE=\fpathname(\m(_file)), SIZE=\fsize(\m(_file))}
  731. for \%w 10 32 2 {
  732.     set window \%w
  733.     for \%p 1 \%n 1 {
  734.         for \%i 1 2 1 {
  735.         set streaming \&s[\%i]
  736.             remote set rec pack \&p[\%p]
  737.             if fail stop 1 {REMOTE SET PACKET LENGTH FAILED: \&s[\%i] \%w \%p}
  738.             echo S=\&s[\%i] W=\%w P=\&p[\%p]
  739.         send \m(_file)
  740.             if fail stop 1 {TRANSFER FAILED: \&s[\%i] \%w \&p[\%p]}
  741.             incr \%c
  742.             xif = \%i 1 {
  743.                 asg \%o \v(cps)
  744.             } else {
  745.                 if > \v(cps) \%o incr \%d
  746.                 if = \v(cps) \%o incr \%e
  747.             }
  748.             .\%x ::= \%w * \&p[\%p]
  749.             xif > \v(cps) \%m { echo NEW RECORD: \v(cps), asg \%m \v(cps) }
  750.         writeln file \flpad(\v(cps),8) \frpad(\&s[\%i],3) \flpad(\%w,2) \flpad(\&p[\%p],4) \flpad(\%x,6)
  751.         }
  752.     }
  753. }
  754. writeln file {; FINISH: \v(date) \v(time) - transfers: \%c, max cps: \%m.}
  755. writeln file {; STREAMING win ratio: \feval(\%d+\%d)/\feval(\%c/2).}
  756. close write
  757.  
  758. ; End
  759.