home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 800s / rfc813.txt < prev    next >
Text File  |  1992-09-22  |  38KB  |  1,168 lines

  1.  
  2. RFC:  813
  3.  
  4.  
  5.               
  6.                 WINDOW AND ACKNOWLEDGEMENT STRATEGY IN TCP
  7.  
  8.                              David D. Clark
  9.                   MIT Laboratory for Computer Science
  10.                Computer Systems and Communications Group
  11.                                July, 1982
  12.  
  13.  
  14.      1.  Introduction
  15.  
  16.  
  17.      This  document describes implementation strategies to deal with two
  18.  
  19. mechanisms in TCP, the window and the acknowledgement.  These mechanisms
  20.  
  21. are described in the specification document, but it is  possible,  while
  22.  
  23. complying with the specification, to produce implementations which yield
  24.  
  25. very  bad  performance.    Happily,  the pitfalls possible in window and
  26.  
  27. acknowledgement strategies are very easy to avoid.
  28.  
  29.  
  30.      It is a much more difficult exercise to verify the performance of a
  31.  
  32. specification than the correctness.  Certainly, we have less  experience
  33.  
  34. in  this  area,  and  we  certainly  lack  any  useful formal technique.
  35.  
  36. Nonetheless, it is important to attempt a specification  in  this  area,
  37.  
  38. because  different  implementors  might  otherwise  choose superficially
  39.  
  40. reasonable algorithms  which  interact  poorly  with  each  other.  This
  41.  
  42. document  presents  a  particular  set of algorithms which have received
  43.  
  44. testing in the field, and which appear to work properly with each other.
  45.  
  46. With more experience, these algorithms may become  part  of  the  formal
  47.  
  48. specification:  until such time their use is recommended.
  49.  
  50.                                    2
  51.  
  52.  
  53. 2.  The Mechanisms
  54.  
  55.  
  56.      The acknowledgement mechanism is at the heart of TCP.  Very simply,
  57.  
  58. when  data  arrives at the recipient, the protocol requires that it send
  59.  
  60. back an acknowledgement of this data.  The protocol specifies  that  the
  61.  
  62. bytes  of  data  are  sequentially  numbered,  so that the recipient can
  63.  
  64. acknowledge data by naming the highest numbered  byte  of  data  it  has
  65.  
  66. received,  which  also  acknowledges  the  previous  bytes (actually, it
  67.  
  68. identifies the first byte of data which it has  not  yet  received,  but
  69.  
  70. this is a small detail).  The protocol contains only a general assertion
  71.  
  72. that  data  should  be acknowledged promptly, but gives no more specific
  73.  
  74. indication as to how quickly an acknowledgement must  be  sent,  or  how
  75.  
  76. much data should be acknowledged in each separate acknowledgement.
  77.  
  78.  
  79.      The window mechanism is a flow control tool.  Whenever appropriate,
  80.  
  81. the  recipient of data returns to the sender a number, which is (more or
  82.  
  83. less) the size of the buffer which the receiver currently has  available
  84.  
  85. for  additional  data.   This number of bytes, called the window, is the
  86.  
  87. maximum which the sender is permitted to  transmit  until  the  receiver
  88.  
  89. returns  some  additional  window.  Sometimes, the receiver will have no
  90.  
  91. buffer space available, and will return a window value of zero.    Under
  92.  
  93. these  circumstances,the  protocol  requires  the sender to send a small
  94.  
  95. segment to the receiver now and then, to see if more data  is  accepted.
  96.  
  97. If  the  window  remains closed at zero for some substantial period, and
  98.  
  99. the sender can obtain  no  response  from  the  receiver,  the  protocol
  100.  
  101. requires  the  sender  to  conclude that the receiver has failed, and to
  102.  
  103. close  the  connection.    Again,  there  is  very  little   performance
  104.  
  105.                                    3
  106.  
  107.  
  108. information  in  the  specification, describing under what circumstances
  109.  
  110. the window should be increased, and how the  sender  should  respond  to
  111.  
  112. such revised information.
  113.  
  114.  
  115.      A  bad implementation of the window algorithm can lead to extremely
  116.  
  117. poor performance overall.  The degradations which  occur  in  throughput
  118.  
  119. and  CPU  utilizations  can easily be several factors of ten, not just a
  120.  
  121. fractional increase.  This particular phenomenon is specific enough that
  122.  
  123. it has been given the name of Silly Window Syndrome, or  SWS.    Happily
  124.  
  125. SWS  is  easy  to  avoid  if  a few simple rules are observed.  The most
  126.  
  127. important function of this memo is to describe SWS, so that implementors
  128.  
  129. will understand the general nature  of  the  problem,  and  to  describe
  130.  
  131. algorithms  which  will  prevent  its  occurrence.    This document also
  132.  
  133. describes   performance   enhancing   algorithms   which    relate    to
  134.  
  135. acknowledgement,  and  discusses  the  way  acknowledgement  and  window
  136.  
  137. algorithms interact as part of SWS.
  138.  
  139.  
  140.      3.  SILLY WINDOW SYNDROME
  141.  
  142.  
  143.      In order to understand SWS, we must first  define  two  new  terms.
  144.  
  145. Superficially,  the window mechanism is very simple:  there is a number,
  146.  
  147. called "the window", which is returned from the receiver to the  sender.
  148.  
  149. However,  we  must have a more detailed way of talking about the meaning
  150.  
  151. of this number.  The receiver of data computes a  value  which  we  will
  152.  
  153. call  the  "offered  window".    In  a  simple  case, the offered window
  154.  
  155. corresponds to the amount of buffer space  available  in  the  receiver.
  156.  
  157. This  correspondence  is  not necessarily exact, but is a suitable model
  158.  
  159. for the discussion to follow.    It  is  the  offered  window  which  is
  160.  
  161.                                    4
  162.  
  163.  
  164. actually  transmitted  back from the receiver to the sender.  The sender
  165.  
  166. uses the offered window  to  compute  a  different  value,  the  "usable
  167.  
  168. window",  which  is  the  offered window minus the amount of outstanding
  169.  
  170. unacknowledged data.  The usable window is less than  or  equal  to  the
  171.  
  172. offered window, and can be much smaller.
  173.  
  174.  
  175.      Consider  the  following  simple  example.   The receiver initially
  176.  
  177. provides an offered window of 1,000.  The sender uses up this window  by
  178.  
  179. sending  five  segments  of 200 bytes each.  The receiver, on processing
  180.  
  181. the first of these  segments,  returns  an  acknowledgement  which  also
  182.  
  183. contains  an  updated  window value.  Let us assume that the receiver of
  184.  
  185. the data has removed the first 200 bytes from the buffer,  so  that  the
  186.  
  187. receiver once again has 1,000 bytes of available buffer.  Therefore, the
  188.  
  189. receiver would return, as before, an offered window of 1,000 bytes.  The
  190.  
  191. sender,  on  receipt  of  this  first  acknowledgement, now computes the
  192.  
  193. additional number of bytes which may be sent.  In  fact,  of  the  1,000
  194.  
  195. bytes  which  the recipient is prepared to receive at this time, 800 are
  196.  
  197. already in transit, having been sent in response to the previous offered
  198.  
  199. window.  In this case, the usable window is only 200 bytes.
  200.  
  201.  
  202.      Let us now consider how SWS  arises.    To  continue  the  previous
  203.  
  204. example,  assume  that at some point, when the sender computes a useable
  205.  
  206. window of 200 bytes, it has only 50 bytes to send  until  it  reaches  a
  207.  
  208. "push"  point.   It thus sends 50 bytes in one segment, and 150 bytes in
  209.  
  210. the next segment. Sometime later, this 50-byte segment  will  arrive  at
  211.  
  212. the recipient, which will process and remove the 50 bytes and once again
  213.  
  214. return  an  offered window of 1,000 bytes.  However, the sender will now
  215.  
  216.                                    5
  217.  
  218.  
  219. compute  that there are 950 bytes in transit in the network, so that the
  220.  
  221. useable window is now only 50 bytes.  Thus, the sender will  once  again
  222.  
  223. send  a  50  byte  segment,  even  though  there  is no longer a natural
  224.  
  225. boundary to force it.
  226.  
  227.  
  228.      In fact, whenever the acknowledgement  of  a  small  segment  comes
  229.  
  230. back, the useable window associated with that acknowledgement will cause
  231.  
  232. another  segment  of  the  same  small  size  to  be  sent,  until  some
  233.  
  234. abnormality breaks the pattern.  It is easy to see  how  small  segments
  235.  
  236. arise,  because  natural  boundaries  in the data occasionally cause the
  237.  
  238. sender to take a computed useable window and divide it  up  between  two
  239.  
  240. segments.   Once that division has occurred, there is no natural way for
  241.  
  242. those useable window allocations to be recombined; thus the breaking  up
  243.  
  244. of the useable window into small pieces will persist.
  245.  
  246.  
  247.      Thus,  SWS  is a degeneration in the throughput which develops over
  248.  
  249. time, during a long data transfer.  If the sender  ever  stops,  as  for
  250.  
  251. example  when  it runs out of data to send, the receiver will eventually
  252.  
  253. acknowledge all  the  outstanding  data,  so  that  the  useable  window
  254.  
  255. computed  by  the  sender  will  equal  the  full  offered window of the
  256.  
  257. receiver.  At this point the situation will  have  healed,  and  further
  258.  
  259. data  transmission  over  the  link will occur efficiently.  However, in
  260.  
  261. large file transfers, which occur without interruption,  SWS  can  cause
  262.  
  263. appalling  performance.  The network between the sender and the receiver
  264.  
  265. becomes clogged with  many  small  segments,  and  an  equal  number  of
  266.  
  267. acknowledgements,  which  in  turn  causes lost segments, which triggers
  268.  
  269. massive retransmission.  Bad cases of SWS have been seen  in  which  the
  270.  
  271.                                    6
  272.  
  273.  
  274. average  segment  size was one-tenth of the size the sender and receiver
  275.  
  276. were prepared to deal with, and the average number of retransmission per
  277.  
  278. successful segments sent was five.
  279.  
  280.  
  281.      Happily, SWS is trivial to avoid.  The following sections  describe
  282.  
  283. two  algorithms,  one  executed  by the sender, and one by the receiver,
  284.  
  285. which appear to eliminate SWS completely.  Actually, either algorithm by
  286.  
  287. itself is sufficient to prevent SWS, and thus  protect  a  host  from  a
  288.  
  289. foreign  implementation  which  has  failed  to  deal properly with this
  290.  
  291. problem.  The  two  algorithms  taken  together  produce  an  additional
  292.  
  293. reduction  in  CPU  consumption, observed in practice to be as high as a
  294.  
  295. factor of four.
  296.  
  297.  
  298.      4.  Improved Window Algorithms
  299.  
  300.  
  301.      The receiver of data can take a very simple step to eliminate  SWS.
  302.  
  303. When  it  disposes of a small amount of data, it can artificially reduce
  304.  
  305. the offered window in subsequent acknowledgements, so that  the  useable
  306.  
  307. window computed by the sender does not permit the sending of any further
  308.  
  309. data.     At  some  later  time,  when  the  receiver  has  processed  a
  310.  
  311. substantially larger amount of incoming data, the artificial  limitation
  312.  
  313. on  the  offered  window  can be removed all at once, so that the sender
  314.  
  315. computes a sudden large jump rather than a sequence of  small  jumps  in
  316.  
  317. the useable window.
  318.  
  319.  
  320.      At  this  level,  the  algorithm  is  quite simple, but in order to
  321.  
  322. determine exactly when the window should  be  opened  up  again,  it  is
  323.  
  324. necessary  to  look  at some of the other details of the implementation.
  325.  
  326.                                    7
  327.  
  328.  
  329. Depending  on whether the window is held artificially closed for a short
  330.  
  331. or long time, two problems will  develop.    The  one  we  have  already
  332.  
  333. discussed  -- never closing the window artificially -- will lead to SWS.
  334.  
  335. On the other hand, if  the  window  is  only  opened  infrequently,  the
  336.  
  337. pipeline  of data in the network between the sender and the receiver may
  338.  
  339. have emptied out while the sender was being held off, so that a delay is
  340.  
  341. introduced before additional data arrives from the sender.   This  delay
  342.  
  343. does reduce throughput, but it does not consume network resources or CPU
  344.  
  345. resources  in  the  process, as does SWS.  Thus, it is in this direction
  346.  
  347. that one ought to overcompensate.  For a simple implementation,  a  rule
  348.  
  349. of  thumb  that  seems to work in practice is to artificially reduce the
  350.  
  351. offered window until the reduction constitutes one half of the available
  352.  
  353. space, at which point increase the window to advertise the entire  space
  354.  
  355. again.  In any event, one ought to make the chunk by which the window is
  356.  
  357. opened  at  least permit one reasonably large segment.  (If the receiver
  358.  
  359. is so short of buffers that it can never advertise a large enough buffer
  360.  
  361. to permit at least one large segment, it is hopeless to expect any  sort
  362.  
  363. of high throughput.)
  364.  
  365.  
  366.      There  is  an algorithm that the sender can use to achieve the same
  367.  
  368. effect described above:  a very simple and elegant rule first  described
  369.  
  370. by  Michael  Greenwald  at MIT.  The sender of the data uses the offered
  371.  
  372. window to compute a useable window, and then compares the useable window
  373.  
  374. to the offered window, and refrains from sending anything if  the  ratio
  375.  
  376. of  useable to offered is less than a certain fraction.  Clearly, if the
  377.  
  378. computed useable window is small compared to the  offered  window,  this
  379.  
  380. means  that a substantial amount of previously sent information is still
  381.  
  382.                                    8
  383.  
  384.  
  385. in  the  pipeline  from  the sender to the receiver, which in turn means
  386.  
  387. that the sender can count on being granted a larger  useable  window  in
  388.  
  389. the  future.    Until  the  useable window reaches a certain amount, the
  390.  
  391. sender should simply refuse to send anything.
  392.  
  393.  
  394.      Simple experiments suggest that the exact value of the ratio is not
  395.  
  396. very important, but that a value of about 25 percent  is  sufficient  to
  397.  
  398. avoid  SWS  and  achieve reasonable throughput, even for machines with a
  399.  
  400. small offered window.    An  additional  enhancement  which  might  help
  401.  
  402. throughput  would be to attempt to hold off sending until one can send a
  403.  
  404. maximum size segment.  Another enhancement would be to send anyway, even
  405.  
  406. if the ratio is small, if the useable window is sufficient to  hold  the
  407.  
  408. data available up to the next "push point".
  409.  
  410.  
  411.      This algorithm at the sender end is very simple.  Notice that it is
  412.  
  413. not  necessary  to  set  a timer to protect against protocol lockup when
  414.  
  415. postponing the  send  operation.    Further  acknowledgements,  as  they
  416.  
  417. arrive,  will  inevitably change the ratio of offered to useable window.
  418.  
  419. (To see this, note that when all the data in the  catanet  pipeline  has
  420.  
  421. arrived  at  the  receiver,  the resulting acknowledgement must yield an
  422.  
  423. offered window and  useable  window  that  equal  each  other.)  If  the
  424.  
  425. expected  acknowledgements  do  not arrive, the retransmission mechanism
  426.  
  427. will come into play to assure that something finally happens.  Thus,  to
  428.  
  429. add  this  algorithm  to an existing TCP implementation usually requires
  430.  
  431. one line of code.  As part of the send algorithm it is already necessary
  432.  
  433. to compute the useable window from the offered window.  It is  a  simple
  434.  
  435. matter  to add a line of code which, if the ratio is less than a certain
  436.  
  437.                                    9
  438.  
  439.  
  440. percent,  sets  the  useable  window to zero.  The results of SWS are so
  441.  
  442. devastating that no sender  should  be  without  this  simple  piece  of
  443.  
  444. insurance.
  445.  
  446.  
  447.      5.  Improved Acknowledgement Algorithms
  448.  
  449.  
  450.      In the beginning of this paper, an overly simplistic implementation
  451.  
  452. of  TCP  was described, which led to SWS.  One of the characteristics of
  453.  
  454. this implementation was that the  recipient  of  data  sent  a  separate
  455.  
  456. acknowledgement  for  every  segment  that it received.  This compulsive
  457.  
  458. acknowledgement  was  one  of  the   causes   of   SWS,   because   each
  459.  
  460. acknowledgement provided some new useable window, but even if one of the
  461.  
  462. algorithms  described  above  is  used to eliminate SWS, overly frequent
  463.  
  464. acknowledgement still has  a  substantial  problem,  which  is  that  it
  465.  
  466. greatly  increases the processing time at the sender's end.  Measurement
  467.  
  468. of TCP implementations, especially on large operating systems,  indicate
  469.  
  470. that  most  of  the  overhead  of  dealing  with a segment is not in the
  471.  
  472. processing at the TCP or IP level, but simply in the scheduling  of  the
  473.  
  474. handler which is required to deal with the segment.  A steady dribble of
  475.  
  476. acknowledgements  causes a high overhead in scheduling, with very little
  477.  
  478. to show for it.  This waste is to be avoided if possible.
  479.  
  480.  
  481.      There are two reasons  for  prompt  acknowledgement.    One  is  to
  482.  
  483. prevent  retransmission.  We will discuss later how to determine whether
  484.  
  485. unnecessary  retransmission  is  occurring.    The  other   reason   one
  486.  
  487. acknowledges  promptly  is  to permit further data to be sent.  However,
  488.  
  489. the previous section makes quite clear that it is not  always  desirable
  490.  
  491. to send a little bit of data, even though the receiver may have room for
  492.  
  493.                                    10
  494.  
  495.  
  496. it.    Therefore,  one  can  state  a  general  rule  that  under normal
  497.  
  498. operation, the receiver of data need not,  and  for  efficiency  reasons
  499.  
  500. should  not,  acknowledge  the data unless either the acknowledgement is
  501.  
  502. intended to produce an increased useable window, is necessary  in  order
  503.  
  504. to  prevent  retransmission  or  is  being  sent  as  part  of a reverse
  505.  
  506. direction segment being sent for some other reason.  We will consider an
  507.  
  508. algorithm to achieve these goals.
  509.  
  510.  
  511.      Only the recipient of  the  data  can  control  the  generation  of
  512.  
  513. acknowledgements.    Once  an  acknowledgement  has  been  sent from the
  514.  
  515. receiver back to the sender, the sender must process it.   Although  the
  516.  
  517. extra overhead is incurred at the sender's end, it is entirely under the
  518.  
  519. receiver's  control.  Therefore, we must now describe an algorithm which
  520.  
  521. occurs at the receiver's end.  Obviously, the algorithm  must  have  the
  522.  
  523. following  general form; sometimes the receiver of data, upon processing
  524.  
  525. a segment, decides not to send an acknowledgement now, but  to  postpone
  526.  
  527. the  acknowledgement until some time in the future, perhaps by setting a
  528.  
  529. timer.  The peril of this approach  is  that  on  many  large  operating
  530.  
  531. systems  it  is  extremely costly to respond to a timer event, almost as
  532.  
  533. costly as to respond to an incoming segment.  Clearly, if  the  receiver
  534.  
  535. of  the data, in order to avoid extra overhead at the sender end, spends
  536.  
  537. a great deal of time responding to timer interrupts, no overall  benefit
  538.  
  539. has been achieved, for efficiency at the sender end is achieved by great
  540.  
  541. thrashing  at  the  receiver end.  We must find an algorithm that avoids
  542.  
  543. both of these perils.
  544.  
  545.  
  546.      The following scheme seems a good compromise.  The receiver of data
  547.  
  548.                                    11
  549.  
  550.  
  551. will   refrain   from   sending   an   acknowledgement   under   certain
  552.  
  553. circumstances, in which case it must set a timer which  will  cause  the
  554.  
  555. acknowledgement  to be sent later.  However, the receiver should do this
  556.  
  557. only where it is a reasonable guess that some other event will intervene
  558.  
  559. and prevent the necessity of the timer  interrupt.    The  most  obvious
  560.  
  561. event  on  which  to depend is the arrival of another segment.  So, if a
  562.  
  563. segment arrives, postpone sending an  acknowledgement  if  both  of  the
  564.  
  565. following  conditions  hold.    First,  the  push  bit is not set in the
  566.  
  567. segment, since it is a reasonable assumption that  there  is  more  data
  568.  
  569. coming  in  a  subsequent  segment.   Second, there is no revised window
  570.  
  571. information to be sent back.
  572.  
  573.  
  574.      This algorithm will insure that the timer, although set, is  seldom
  575.  
  576. used.    The  interval  of  the  timer is related to the expected inter-
  577.  
  578. segment delay, which is in turn a function  of  the  particular  network
  579.  
  580. through  which  the  data  is  flowing.    For the Arpanet, a reasonable
  581.  
  582. interval seems to be 200 to 300 milliseconds.  Appendix A  describes  an
  583.  
  584. adaptive algorithm for measuring this delay.
  585.  
  586.  
  587.      The section on improved window algorithms described both a receiver
  588.  
  589. algorithm  and  a  sender  algorithm,  and suggested that both should be
  590.  
  591. used.  The reason for this is now clear.  While the sender algorithm  is
  592.  
  593. extremely  simple,  and  useful  as insurance, the receiver algorithm is
  594.  
  595. required in order that this improved acknowledgement strategy work.   If
  596.  
  597. the  receipt  of every segment causes a new window value to be returned,
  598.  
  599. then of necessity  an  acknowledgement  will  be  sent  for  every  data
  600.  
  601. segment.    When, according to the strategy of the previous section, the
  602.  
  603.                                    12
  604.  
  605.  
  606. receiver  determines  to artificially reduce the offered window, that is
  607.  
  608. precisely the circumstance under which an acknowledgement  need  not  be
  609.  
  610. sent.      When   the   receiver   window  algorithm  and  the  receiver
  611.  
  612. acknowledgement algorithm are  used  together,  it  will  be  seen  that
  613.  
  614. sending  an  acknowledgement  will  be triggered by one of the following
  615.  
  616. events.  First, a push bit has been received.  Second, a temporary pause
  617.  
  618. in the data stream is detected.  Third,  the  offered  window  has  been
  619.  
  620. artificially reduced to one-half its actual value.
  621.  
  622.  
  623.      In the beginning of this section, it was pointed out that there are
  624.  
  625. two  reasons  why  one must acknowledge data.  Our consideration at this
  626.  
  627. point has been concerned only with the first,  that  an  acknowledgement
  628.  
  629. must  be  returned as part of triggering the sending of new data.  It is
  630.  
  631. also necessary to acknowledge  whenever  the  failure  to  do  so  would
  632.  
  633. trigger retransmission by the sender.  Since the retransmission interval
  634.  
  635. is  selected  by  the  sender,  the  receiver  of the data cannot make a
  636.  
  637. precise  determination  of  when  the  acknowledgement  must  be   sent.
  638.  
  639. However,   there   is   a  rough  rule  the  sender  can  use  to  avoid
  640.  
  641. retransmission, provided that the receiver is reasonably well behaved.
  642.  
  643.  
  644.      We will assume that sender of the data uses the optional  algorithm
  645.  
  646. described  in  the  TCP  specification,  in which the roundtrip delay is
  647.  
  648. measured using an exponential decay smoothing algorithm.  Retransmission
  649.  
  650. of a segment occurs if the measured delay for that segment  exceeds  the
  651.  
  652. smoothed  average  by  some  factor.  To see how retransmission might be
  653.  
  654. triggered, one must consider the pattern  of  segment  arrivals  at  the
  655.  
  656. receiver.   The goal of our strategy was that the sender should send off
  657.  
  658.                                    13
  659.  
  660.  
  661. a  number of segments in close sequence, and receive one acknowledgement
  662.  
  663. for the whole burst.  The  acknowledgement  will  be  generated  by  the
  664.  
  665. receiver  at  the time that the last segment in the burst arrives at the
  666.  
  667. receiver.  (To ensure the prompt  return  of  the  acknowledgement,  the
  668.  
  669. sender  could  turn on the "push" bit in the last segment of the burst.)
  670.  
  671. The delay observed at the sender between the initial transmission  of  a
  672.  
  673. segment  and  the  receipt  of the acknowledgement will include both the
  674.  
  675. network transit time, plus the  holding  time  at  the  receiver.    The
  676.  
  677. holding  time  will be greatest for the first segments in the burst, and
  678.  
  679. smallest for the last segments  in  the  burst.    Thus,  the  smoothing
  680.  
  681. algorithm  will  measure  a  delay  which is roughly proportional to the
  682.  
  683. average roundtrip delay for all the segments in  the  burst.    Problems
  684.  
  685. will  arise  if  the  average  delay  is  substantially smaller than the
  686.  
  687. maximum delay  and  the  smoothing  algorithm  used  has  a  very  small
  688.  
  689. threshold  for  triggering retransmission.  The widest variation between
  690.  
  691. average and maximum delay  will  occur  when  network  transit  time  is
  692.  
  693. negligible, and all delay is processing time.  In this case, the maximum
  694.  
  695. will  be  twice  the  average  (by simple algebra) so the threshold that
  696.  
  697. controls retransmission should be somewhat more than a factor of two.
  698.  
  699.  
  700.      In practice, retransmission of the first segments of  a  burst  has
  701.  
  702. not  been  a  problem because the delay measured consists of the network
  703.  
  704. roundtrip  delay,  as  well  as  the  delay  due  to   withholding   the
  705.  
  706. acknowledgement,  and the roundtrip tends to dominate except in very low
  707.  
  708. roundtrip time situations (such as when sending to one's self  for  test
  709.  
  710. purposes).    This low roundtrip situation can be covered very simply by
  711.  
  712. including a minimum value below which  the  roundtrip  estimate  is  not
  713.  
  714. permitted to drop.
  715.  
  716.                                    14
  717.  
  718.  
  719.      In  our  experiments  with  this  algorithm,  retransmission due to
  720.  
  721. faulty calculation of the roundtrip delay occurred only once,  when  the
  722.  
  723. parameters  of  the exponential smoothing algorithm had been misadjusted
  724.  
  725. so that they were only  taking  into  account  the  last  two  or  three
  726.  
  727. segments  sent.   Clearly, this will cause trouble since the last two or
  728.  
  729. three segments of any burst are the  ones  whose  holding  time  at  the
  730.  
  731. receiver is minimal, so the resulting total estimate was much lower than
  732.  
  733. appropriate.   Once the parameters of the algorithm had been adjusted so
  734.  
  735. that the number of segments taken into account was  approximately  twice
  736.  
  737. the  number  of  segments  in  a burst of average size, with a threshold
  738.  
  739. factor of 1.5, no further retransmission has ever been identified due to
  740.  
  741. this problem, including when sending to ourself and  when  sending  over
  742.  
  743. high delay nets.
  744.  
  745.  
  746.      6.  Conservative Vs. Optimistic Windows
  747.  
  748.  
  749.      According  to the TCP specification, the offered window is presumed
  750.  
  751. to have some relationship to the amount of data which  the  receiver  is
  752.  
  753. actually  prepared  to receive.  However, it is not necessarily an exact
  754.  
  755. correspondence.  We will use the term "conservative window" to  describe
  756.  
  757. the case where the offered window is precisely no larger than the actual
  758.  
  759. buffering  available.  The drawback to conservative window algorithms is
  760.  
  761. that they can produce very low throughput in long delay situations.   It
  762.  
  763. is easy to see that the maximum input of a conservative window algorithm
  764.  
  765. is  one  bufferfull  every  roundtrip  delay  in the net, since the next
  766.  
  767. bufferfull cannot be launched until the  updated  window/acknowledgement
  768.  
  769. information from the previous transmission has made the roundtrip.
  770.  
  771.                                    15
  772.  
  773.  
  774.      In  certain  cases,  it  may  be  possible  to increase the overall
  775.  
  776. throughput of the transmission by increasing the offered window over the
  777.  
  778. actual buffer available at the receiver.  Such a strategy we  will  call
  779.  
  780. an  "optimistic  window" strategy.  The optimistic strategy works if the
  781.  
  782. network delivers the data to the recipient sufficiently slowly  that  it
  783.  
  784. can  process  the  data fast enough to keep the buffer from overflowing.
  785.  
  786. If the receiver is faster than the sender, one could, with luck,  permit
  787.  
  788. an infinitely optimistic window, in which the sender is simply permitted
  789.  
  790. to send full-speed.  If the sender is faster than the receiver, however,
  791.  
  792. and the window is too optimistic, then some segments will cause a buffer
  793.  
  794. overflow,  and  will  be  discarded.  Therefore, the correct strategy to
  795.  
  796. implement an optimistic window is to  increase  the  window  size  until
  797.  
  798. segments  start to be lost.  This only works if it is possible to detect
  799.  
  800. that the segment has been lost.  In  some  cases,  it  is  easy  to  do,
  801.  
  802. because  the  segment  is  partially processed inside the receiving host
  803.  
  804. before it is thrown away.  In other cases, overflows may actually  cause
  805.  
  806. the network interface to be clogged, which will cause the segments to be
  807.  
  808. lost  elsewhere  in the net.  It is inadvisable to attempt an optimistic
  809.  
  810. window strategy unless one is certain that the algorithm can detect  the
  811.  
  812. resulting  lost  segments.  However, the increase in throughput which is
  813.  
  814. possible from optimistic windows is quite substantial.  Any systems with
  815.  
  816. small buffer space should seriously consider  the  merit  of  optimistic
  817.  
  818. windows.
  819.  
  820.  
  821.      The  selection  of an appropriate window algorithm is actually more
  822.  
  823. complicated than even the above  discussion  suggests.    The  following
  824.  
  825. considerations  are  not  presented  with  the  intention  that  they be
  826.  
  827.                                    16
  828.  
  829.  
  830. incorporated  in  current  implementations of TCP, but as background for
  831.  
  832. the sophisticated designer who is attempting to understand how  his  TCP
  833.  
  834. will  respond  to  a variety of networks, with different speed and delay
  835.  
  836. characteristics.  The particular pattern of windows and acknowledgements
  837.  
  838. sent from receiver to sender influences two characteristics of the  data
  839.  
  840. being  sent.    First, they control the average data rate.  Clearly, the
  841.  
  842. average rate of the  sender  cannot  exceed  the  average  rate  of  the
  843.  
  844. receiver,  or  long-term  buffer  overflow  will  occur.    Second, they
  845.  
  846. influence the burstiness of the data coming from the sender.  Burstiness
  847.  
  848. has both advantages and disadvantages.  The advantage of  burstiness  is
  849.  
  850. that  it  reduces  the  CPU processing necessary to send the data.  This
  851.  
  852. follows from the observed fact, especially on large machines, that  most
  853.  
  854. of  the  cost  of sending a segment is not the TCP or IP processing, but
  855.  
  856. the scheduling overhead of getting started.
  857.  
  858.  
  859.      On the other hand, the disadvantage of burstiness is  that  it  may
  860.  
  861. cause  buffers  to overflow, either in the eventual recipient, which was
  862.  
  863. discussed above, or in an intermediate gateway,  a  problem  ignored  in
  864.  
  865. this paper.  The algorithms described above attempts to strike a balance
  866.  
  867. between  excessive  burstiness,  which  in  the  extreme cases can cause
  868.  
  869. delays because a burst is  not  requested  soon  enough,  and  excessive
  870.  
  871. fragmentation   of  the  data  stream  into  small  segments,  which  we
  872.  
  873. identified as Silly Window Syndrome.
  874.  
  875.  
  876.      Under conditions of extreme delay  in  the  network,  none  of  the
  877.  
  878. algorithms   described   above   will   achieve   adequate   throughput.
  879.  
  880. Conservative window algorithms  have  a  predictable  throughput  limit,
  881.  
  882.                                    17
  883.  
  884.  
  885. which  is one windowfull per roundtrip delay.  Attempts to solve this by
  886.  
  887. optimistic window strategies may  cause  buffer  overflows  due  to  the
  888.  
  889. bursty  nature  of the arriving data.  A very sophisticated way to solve
  890.  
  891. this is for the receiver, having measured by some  means  the  roundtrip
  892.  
  893. delay  and  intersegment  arrival rate of the actual connection, to open
  894.  
  895. his window, not in one optimistic increment of gigantic proportion,  but
  896.  
  897. in  a number of smaller optimistic increments, which have been carefully
  898.  
  899. spaced using a timer so that the resulting smaller bursts  which  arrive
  900.  
  901. are each sufficiently small to fit into the existing buffers.  One could
  902.  
  903. visualize this as a number of requests flowing backwards through the net
  904.  
  905. which trigger in return a number of bursts which flow back spaced evenly
  906.  
  907. from  the  sender  to  the  receiver.    The  overall result is that the
  908.  
  909. receiver uses the window mechanism to  control  the  burstiness  of  the
  910.  
  911. arrivals, and the average rate.
  912.  
  913.  
  914.      To  my knowledge, no such strategy has been implemented in any TCP.
  915.  
  916. First, we do not normally have delays high enough to require  this  kind
  917.  
  918. of  treatment.    Second,  the  strategy described above is probably not
  919.  
  920. stable unless it is very carefully balanced.  Just as buses on a  single
  921.  
  922. bus  route tend to bunch up, bursts which start out equally spaced could
  923.  
  924. well end up piling into each other, and forming the single  large  burst
  925.  
  926. which  the  receiver was hoping to avoid.  It is important to understand
  927.  
  928. this extreme case, however, in order to  understand  the  limits  beyond
  929.  
  930. which  TCP,  as normally implemented, with either conservative or simple
  931.  
  932. optimistic windows can be expected to  deliver  throughput  which  is  a
  933.  
  934. reasonable percentage of the actual network capacity.
  935.  
  936.                                    18
  937.  
  938.  
  939.      7.  Conclusions
  940.  
  941.  
  942.      This  paper  describes  three  simple  algorithms  for  performance
  943.  
  944. enhancement in TCP, one at the sender end and two at the receiver.   The
  945.  
  946. sender  algorithm  is  to  refrain from sending if the useable window is
  947.  
  948. smaller than 25 percent of the offered window.  The receiver  algorithms
  949.  
  950. are first, to artificially reduce the offered window when processing new
  951.  
  952. data  if  the  resulting  reduction  does  not  represent more than some
  953.  
  954. fraction, say 50 percent, of the actual space available, and second,  to
  955.  
  956. refrain  from  sending an acknowledgment at all if two simple conditions
  957.  
  958. hold.
  959.  
  960.  
  961.      Either of these algorithms will prevent the worst aspects of  Silly
  962.  
  963. Window  Syndrome, and when these algorithms are used together, they will
  964.  
  965. produce substantial improvement in CPU utilization, by  eliminating  the
  966.  
  967. process of excess acknowledgements.
  968.  
  969.  
  970.      Preliminary  experiments  with  these  algorithms suggest that they
  971.  
  972. work, and work very well.  Both the sender and receiver algorithms  have
  973.  
  974. been  shown  to  eliminate  SWS,  even  when  talking  to  fairly  silly
  975.  
  976. algorithms at the other end.  The Multics  mailer,  in  particular,  had
  977.  
  978. suffered substantial attacks of SWS while sending large mail to a number
  979.  
  980. of  hosts.   We believe that implementation of the sender side algorithm
  981.  
  982. has  eliminated  every  known  case  of  SWS  detected  in  our  mailer.
  983.  
  984. Implementation  of  the  receiver  side  algorithm  produced substantial
  985.  
  986. improvements of CPU time when Multics was the sending system.    Multics
  987.  
  988. is  a  typical  large  operating system, with scheduling costs which are
  989.  
  990. large compared to the actual  processing  time  for  protocol  handlers.
  991.  
  992.                                    19
  993.  
  994.  
  995. Tests were done sending from Multics to a host which implemented the SWS
  996.  
  997. suppression  algorithm,  and  which  could  either  refrain  or not from
  998.  
  999. sending acknowledgements on each segment.  As predicted, suppressing the
  1000.  
  1001. return acknowledgements did not influence the throughput for large  data
  1002.  
  1003. transfer  at  all,  since the throttling effect was elsewhere.  However,
  1004.  
  1005. the CPU time required to process the data at the Multics end was cut  by
  1006.  
  1007. a  factor  of  four  (In  this experiment, the bursts of data which were
  1008.  
  1009. being sent were approximately eight  segments.    Thus,  the  number  of
  1010.  
  1011. acknowledgements in the two experiments differed by a factor of eight.)
  1012.  
  1013.  
  1014.      An  important  consideration in evaluating these algorithms is that
  1015.  
  1016. they must not cause the protocol implementations to deadlock.    All  of
  1017.  
  1018. the  recommendations  in this document have the characteristic that they
  1019.  
  1020. suggest one refrain  from  doing  something  even  though  the  protocol
  1021.  
  1022. specification  permits one to do it.  The possibility exists that if one
  1023.  
  1024. refrains from doing something now one may never get to do it later,  and
  1025.  
  1026. both  ends will halt, even though it would appear superficially that the
  1027.  
  1028. transaction can continue.
  1029.  
  1030.  
  1031.      Formally, the idea that things continue to work is referred  to  as
  1032.  
  1033. "liveness".    One  of  the  defects  of ad hoc solutions to performance
  1034.  
  1035. problems is the possibility that two different approaches will  interact
  1036.  
  1037. to  prevent  liveness.   It is believed that the algorithms described in
  1038.  
  1039. this paper are always live, and that is one of the reasons why there  is
  1040.  
  1041. a strong advantage in uniform use of this particular proposal, except in
  1042.  
  1043. cases where it is explicitly demonstrated not to work.
  1044.  
  1045.  
  1046.      The  argument  for liveness in these solutions proceeds as follows.
  1047.  
  1048.                                    20
  1049.  
  1050.  
  1051. First,  the sender algorithm can only be stopped by one thing, a refusal
  1052.  
  1053. of the receiver to acknowledge sent data.    As  long  as  the  receiver
  1054.  
  1055. continues  to  acknowledge  data, the ratio of useable window to offered
  1056.  
  1057. window will approach one, and eventually the  sender  must  continue  to
  1058.  
  1059. send.    However,  notice  that the receiver algorithm we have advocated
  1060.  
  1061. involves refraining from acknowledging.  Therefore, we certainly do have
  1062.  
  1063. a situation where improper  operation  of  this  algorithm  can  prevent
  1064.  
  1065. liveness.
  1066.  
  1067.  
  1068.      What  we  must show is that the receiver of the data, if it chooses
  1069.  
  1070. to refrain from acknowledging, will do so only for a short time, and not
  1071.  
  1072. forever.  The design of the algorithm described above  was  intended  to
  1073.  
  1074. achieve  precisely  this  goal:  whenever the receiver of data refrained
  1075.  
  1076. from sending an acknowledgement it was required to set  a  timer.    The
  1077.  
  1078. only  event  that  was  permitted to clear that timer was the receipt of
  1079.  
  1080. another segment, which essentially reset the timer, and started it going
  1081.  
  1082. again.  Thus, an acknowledgement will be sent as soon  as  no  data  has
  1083.  
  1084. been received.  This has precisely the effect desired:  if the data flow
  1085.  
  1086. appears to be disrupted for any reason, the receiver responds by sending
  1087.  
  1088. an  up-to-date  acknowledgement.    In  fact,  the receiver algorithm is
  1089.  
  1090. designed  to  be  more  robust  than  this,  for  transmission   of   an
  1091.  
  1092. acknowledgment is triggered by two events, either a cessation of data or
  1093.  
  1094. a  reduction in the amount of offered window to 50 percent of the actual
  1095.  
  1096. value.    This  is  the  condition  which  will  normally  trigger   the
  1097.  
  1098. transmission of this acknowledgement.
  1099.  
  1100.                                    21
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.                                APPENDIX A
  1107.  
  1108.  
  1109.      Dynamic Calculation of Acknowledgement Delay
  1110.  
  1111.  
  1112.      The  text  suggested  that  when  setting  a  timer to postpone the
  1113.  
  1114. sending  of  an  acknowledgement,  a  fixed  interval  of  200  to   300
  1115.  
  1116. milliseconds  would  work  properly  in  practice.    This  has not been
  1117.  
  1118. verified over a wide variety of network delays, and clearly if there  is
  1119.  
  1120. a  very  slow  net  which stretches out the intersegment arrival time, a
  1121.  
  1122. fixed interval will fail.  In a sophisticated TCP, which is expected  to
  1123.  
  1124. adjust   dynamically   (rather   than   manually)  to  changing  network
  1125.  
  1126. conditions, it would be appropriate to measure this interval and respond
  1127.  
  1128. dynamically.  The following algorithm, which has been  relegated  to  an
  1129.  
  1130. Appendix,  because  it  has not been tested, seems sensible.  Whenever a
  1131.  
  1132. segment arrives which does not have the push  bit  on  in  it,  start  a
  1133.  
  1134. timer,  which  runs  until  the  next  segment  arrives.   Average these
  1135.  
  1136. interarrival intervals, using an exponential  decay  smoothing  function
  1137.  
  1138. tuned  to take into account perhaps the last ten or twenty segments that
  1139.  
  1140. have come in.  Occasionally, there will be a long  interarrival  period,
  1141.  
  1142. even  for  a  segment  which is does not terminate a piece of data being
  1143.  
  1144. pushed, perhaps because a window has gone to zero or some glitch in  the
  1145.  
  1146. sender  or  the  network  has held up the data.  Therefore, examine each
  1147.  
  1148. interarrival interval, and discard it from the smoothing algorithm if it
  1149.  
  1150. exceeds the current estimate by some amount, perhaps a ratio of  two  or
  1151.  
  1152. four times.  By rejecting the larger intersegment arrival intervals, one
  1153.  
  1154. should obtain a smoothed estimate of the interarrival of segments inside
  1155.  
  1156.                                    22
  1157.  
  1158.  
  1159. a  burst.   The number need not be exact, since the timer which triggers
  1160.  
  1161. acknowledgement can add a fairly generous fudge factor to  this  without
  1162.  
  1163. causing  trouble  with  the  sender's  estimate  of  the  retransmission
  1164.  
  1165. interval, so long as the fudge factor is constant.
  1166.  
  1167.  
  1168.