home *** CD-ROM | disk | FTP | other *** search
/ Handbook of Infosec Terms 2.0 / Handbook_of_Infosec_Terms_Version_2.0_ISSO.iso / text / rfcs / rfc0813.txt < prev    next >
Text File  |  1996-05-07  |  40KB  |  1,077 lines

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