home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / e / id-nag-00.txt < prev    next >
Text File  |  2020-01-01  |  40KB  |  879 lines

  1.  
  2.  
  3.   TCP Implementation Working Group                      Joe R. Doupnik
  4.   Internet Draft                                 Utah State University
  5.   Expiration Date: December 1999                             June 1999
  6.   draft-doupnik-tcpimpl-nagle-mode-00.txt
  7.  
  8.  
  9.             A new TCP transmission policy replacing Nagle mode
  10.  
  11.  
  12.   Status of this Memo
  13.  
  14.   This document is an Internet-Draft and is in full conformance with
  15.   all provisions of Section 10 of RFC2026.
  16.  
  17.   Internet-Drafts are working documents of the Internet Engineering
  18.   Task Force (IETF), its areas, and its working groups.  Note that
  19.   other groups may also distribute working documents as Internet-
  20.   Drafts.
  21.  
  22.   Internet-Drafts are draft documents valid for a maximum of six months
  23.   and may be updated, replaced, or obsoleted by other documents at any
  24.   time.  It is inappropriate to use Internet-Drafts as reference
  25.   material or to cite them other than as "work in progress."
  26.  
  27.   The list of current Internet-Drafts can be accessed at
  28.   http://www.ietf.org/ietf/1id-abstracts.txt
  29.  
  30.   The list of Internet-Draft Shadow Directories can be accessed at
  31.   http://www.ietf.org/shadow.html.
  32.  
  33.   Abstract
  34.  
  35.   Both Nagle mode and delayed ACKs attempt to conserve network and host
  36.   machine resources by delaying transmissions in the expectation that
  37.   the current material can be piggybacked onto a future transmission.
  38.   Unfortunately when both mechanisms are active at the same time on
  39.   either end of a connection a deadlock can exist, which is broken by
  40.   arrival of new data for transmission or firing of the delayed ACK
  41.   timer. This produces classical timer based ACKing, which for the
  42.   common 200ms ACK delay yields five exchanges per second.
  43.  
  44.   A new TCP transmission policy is discussed in this memo which uses
  45.   information known only to the transmitter about when to send
  46.   segments. It groups octets based on filling segments and sending a
  47.   small segment when the application indicates no more data are
  48.   immediately available, not on arrival of ACKs. It works well with and
  49.   avoids deadlocks with delayed ACKs. It is automatic and does not need
  50.   to be turned off. It is a suitable replacement for Nagle mode.
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.   A new TCP transmission policy replacing Nagle mode          [Page 2]
  58.  
  59.   Table of Contents
  60.  
  61.   1.0 Introduction.................................................2
  62.   1.1 Maximum Segment Size, MSS....................................3
  63.   1.2 Nagle mode...................................................3
  64.   1.3 Strict Nagle mode............................................3
  65.   1.4 Strict Nagle example.........................................4
  66.   1.5 Liberal Nagle mode...........................................5
  67.   1.6 Delayed ACKs.................................................5
  68.   2.0 New transmission policy......................................6
  69.   2.1 Formal statement of new policy...............................7
  70.   2.2 Discussion...................................................8
  71.   2.3 Operation between like and unlike TCP stacks.................9
  72.   3.0 Experimental results........................................10
  73.   4.0 Conclusions.................................................13
  74.   5.0 Security Considerations.....................................14
  75.   6.0 Acknowledgments.............................................14
  76.   7.0 References..................................................14
  77.   8.0 Author's address............................................14
  78.  
  79.   1.0 Introduction
  80.  
  81.   Nagle mode [TCP:1] and delayed ACKs are TCP heuristics designed to
  82.   reduce network traffic, and the consequent load on both originating
  83.   and receiving hosts. They perform this by slightly different means,
  84.   but the common factor is to delay a transmission in the expectation
  85.   that another will be required quickly and hence the present and next
  86.   transmissions may be combined into one (piggybacking).
  87.  
  88.   When both modes are active, as they should be to conserve resources,
  89.   then they may interact to hold data at the transmitter while the
  90.   receiver holds/delays the ACKs until a very slow (200ms) timer forces
  91.   out the ACKs. The delay is of major importance when the conversation
  92.   is alternating between hosts, where one side makes requests, the
  93.   other responds, and the pattern repeats. The response is delayed
  94.   until the entire request has arrived at the receiver. Yet the next to
  95.   last packet of the request can result in a delayed ACK which in turn
  96.   delays release of the last packet being held by the Nagle condition.
  97.  
  98.   A delay in sending all octets from one side or the other can slow the
  99.   conversation to about 1/delayed_ack_time exchanges per second
  100.   (typically 5 exchanges per second). Such patterns are common for web
  101.   serving, SMTP mail queues, and other modern applications.
  102.  
  103.   Today many application programmers turn off Nagle mode to overcome
  104.   the interaction. They cannot control delayed ACKs which are often
  105.   turned on or off on a system-wide basis. Unfortunately, turning off
  106.   Nagle mode increases network traffic, host machine workload, and
  107.   router workload. If applications cannot turn off Nagle mode to avoid
  108.   the delayed ACK effect then UDP is the next candidate, and that means
  109.   no regard for the network and little regard (or lots of work in the
  110.   application) for lost packets. Today's growing request/reply work
  111.   would be better served by responsive TCP based communications.
  112.  
  113.  
  114.   Doupnik                                                       Page 2
  115.   A new TCP transmission policy replacing Nagle mode          [Page 3]
  116.  
  117.  
  118.   1.1 Maximum Segment Size, MSS
  119.  
  120.   In the following discussion we will use MSS, Maximum Segment Size, as
  121.   a test criteria for full segments. What is meant is the full capacity
  122.   for TCP data after allowing for IP and TCP headers and options, which
  123.   RFC1122 [TCP:2] represents as Eff.snd.MSS. Also some hosts use a
  124.   power of two buffer sizes as a full segment although the MSS is
  125.   larger. Nevertheless, we will employ the term MSS, Maximum Segment
  126.   Size, to be the host's concept of its largest segment size at one
  127.   moment.
  128.  
  129.   1.2 Nagle mode
  130.  
  131.   The current definition of Nagle mode is found in RFC1122, [TCP:2],
  132.   section 4.2.3.4 When to Send Data:
  133.      (start quote)
  134.       The Nagle algorithm is generally as follows:
  135.           If there is unacknowledged data (i.e., SND.NXT > SND.UNA),
  136.           then the sending TCP buffers all user data (regardless of the
  137.           PSH bit), until the outstanding data has been acknowledged or
  138.           until the TCP can send a full-sized segment (Eff.snd.MSS
  139.           bytes; see Section 4.2.2.6).
  140.      (end quote)
  141.  
  142.   Nagle mode has been implemented in at least two different forms,
  143.   leading to different behaviors. Each is discussed below. The
  144.   different forms result from answering the question: if more than one
  145.   Eff.snd.MSS of data has accumulated, how much beyond full segments
  146.   may be sent at once?
  147.  
  148.   The strict approach answers the question above by sending only full
  149.   segments. A last short segment will be retained for later release. A
  150.   liberal approach answers it by sending all available data including a
  151.   possible (very likely) short ending component. The labels strict
  152.   Nagle and liberal Nagle are used in this paper for purposes of
  153.   discussion. As a matter of interest, TCP/IP stacks derived from BSD
  154.   sources often use the strict Nagle mechanism.
  155.  
  156.   1.3 Strict Nagle form
  157.  
  158.   The strict Nagle form transmits only full sized segments while
  159.   awaiting ACKs for previously sent data. A partial segment of unsent
  160.   data remaining afterward is retained in the transmit buffer as unsent
  161.   data until all preceding data have been ACKed, or until more
  162.   application data arrives to compose full length segments. Window size
  163.   and congestion avoidance criteria of Van Jacobson [TCP:3] may cause
  164.   even these to remain unsent for some time.
  165.  
  166.   Holding back the last partial segment leads to grouping with later
  167.   new application data and hence sending full segments when possible.
  168.   Delayed ACKs assist grouping in the transmitter by allowing time for
  169.   the application to add more octets, assuming there is more data and
  170.   the receiver's window is large enough. But they also introduce the
  171.  
  172.   Doupnik                                                       Page 3
  173.   A new TCP transmission policy replacing Nagle mode          [Page 4]
  174.  
  175.  
  176.   problem of delaying release of the held tail octets. Prior to the
  177.   tail segment, strict Nagle mode is doing a fine job of forming full-
  178.   length segments for transmission. Timely release of held tail octets
  179.   is the essence of the interaction problem discussed in this document.
  180.  
  181.   1.4 Strict Nagle example
  182.  
  183.   As an example, suppose the TCP buffer is empty and the application
  184.   writes 3.5 MSS worth of data to it. Remote host window size and
  185.   congestion avoidance criteria are applied to determine the size of
  186.   the candidate transmission. We may consider two cases, one where all
  187.   data are allowed and a second where less is allowed.
  188.  
  189.   The first case is all octets are allowed. A full MSS of data is
  190.   fetched from the buffer and the Nagle test is applied. It passes
  191.   because the size is a full MSS. The data is sent. The transmitter
  192.   loops back for a second fetch. The Nagle test finds a full segment
  193.   and transmits it although unACKed data exist from the first
  194.   transmission. This repeats until it fetches the last piece, 0.5 MSS.
  195.  
  196.   The Nagle test fails for it because it is smaller than a full segment
  197.   and there is unACKed data in transit. The test will fail again until
  198.   there is no unACKed data (or enough application data arrives). The
  199.   small tail piece is held until all preceding octets have been ACKed,
  200.   not just the first or second segments. Thus up to three ACKs may be
  201.   required to release the tail. This is a "held tail" effect.
  202.  
  203.   The second case is windowing and congestion avoidance allows only a
  204.   few octets to be transmitted, say two MSS worth. The first two
  205.   segments are full length and are sent promptly. Nothing more can be
  206.   sent until either a fresh write from the application or arrival of a
  207.   packet creates another transmission opportunity. 1.5 MSS of data
  208.   remain blocked and invisible to Nagle tests. Suppose the application
  209.   does not write more data. The transmitter awaits a packet from the
  210.   receiver that results in calling the transmission code again. At that
  211.   time as many full segments permitted by windowing and congestion
  212.   avoidance are sent. A partial segment remainder blocks by strict
  213.   Nagle rules because it is smaller than a full segment and unACKed
  214.   data are in transit. Up to three ACKs may be required to release the
  215.   trailer. This is a "held tail" effect.
  216.  
  217.   Unfortunately, the last ACK may be delayed and thus the last piece
  218.   may not go onto the wire for the duration of the receiver's delayed
  219.   ACK timer. The receiver does not know that the transmitter has data
  220.   blocked waiting for the final ACK (rather than say data being forced
  221.   out by new writes from the application). Waiting for the last ACK can
  222.   involve the full delayed ACK interval, often 200ms; and that results
  223.   in timer based ACKing.
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.   Doupnik                                                       Page 4
  231.   A new TCP transmission policy replacing Nagle mode          [Page 5]
  232.  
  233.  
  234.   1.5 Liberal Nagle mode
  235.  
  236.   The second form of Nagle mode applies the full segment rule from
  237.   RFC1122 but interprets it as saying a trailing partial segment may be
  238.   transmitted with full segments during the blocked condition. In
  239.   essence, the size determination is made on all allowed unsent data
  240.   rather than testing each candidate segment individually as in the
  241.   strict Nagle case. The test should be on all unsent data after being
  242.   reduced by remote host window capacity and congestion avoidance
  243.   limits. The test is really on the minimum of "allowed" (by window
  244.   size and congestion avoidance) and "available" (the number of unsent
  245.   octets visible to the TCP transmitter at that moment. Strict Nagle
  246.   mode of course experiences the same size filtering before data reach
  247.   it.
  248.  
  249.   The liberal Nagle form reduces but does not eliminate incidence of
  250.   held tails, as the following example illustrates, whereas strict
  251.   Nagle mode creates such incidences at almost each application write
  252.   event. Liberal Nagle blocks with a partial segment when the window
  253.   size and congestion avoidance combine to hold back data during the
  254.   next to last transmission opportunity and only a fraction of an MSS
  255.   of data remain for the last transmission opportunity. The initial
  256.   hold back is invisible to Nagle mode at that time so the small piece
  257.   is not available to be included with the full segments. UnACKed data
  258.   may exist from the previous send and the small segment remains
  259.   blocked until preceding octets have been ACKed. Large transmitter and
  260.   small receiver TCP window sizes and slow comms contribute markedly to
  261.   this held tail effect with liberal Nagle mode.
  262.  
  263.   One may infer that liberal Nagle mode was created in part to reduce
  264.   incidence of the held tail problem. Alas, it does reduce but not
  265.   eliminate it, and in the process it may send small segments within
  266.   application data.
  267.  
  268.   1.6 Delayed ACKs
  269.  
  270.   Delayed ACKs are a popular mechanism of TCP to avoid sending an ACK
  271.   for each received segment. Typically, every other arrival generates
  272.   an ACK. The mechanism is to create a delayed ACK queue which will be
  273.   flushed to the wire as a single ACK when either a delayed ACK timer
  274.   expires, or the queue length reaches a certain value (such as two
  275.   entries), or the local machine sends data. Although ACKs are tiny-
  276.   grams they do take time and CPU resources to create and to receive,
  277.   and the routing load is the same as full-length segments. Even on a
  278.   local wire without routers sending an ACK for each arriving segment
  279.   creates noticeable additional load on both machines and on network
  280.   capacity. Thus delaying to coalesce two or more ACKs is a good
  281.   concept and is the same philosophy as grouping octets into full
  282.   packets rather than many smaller ones.
  283.  
  284.   Delaying ACKs is guessing, to paraphrase private communications by
  285.   John Nagle, that there will be either more data arriving immediately,
  286.   or there will be a transmission by the receiver in a very short time,
  287.  
  288.   Doupnik                                                       Page 5
  289.   A new TCP transmission policy replacing Nagle mode          [Page 6]
  290.  
  291.  
  292.   or that the receiver doesn't care about immediacy, and thus
  293.   delaying will be a good tactic. Unfortunately, the receiver has
  294.   little basis for making the guess: the sending machine provides no
  295.   hints, the local receiving application provides no notice of data
  296.   about to be delivered. The delay time is fixed, which will be a
  297.   mismatch for either local or long distance communications. And the
  298.   PUSH bit isn't available to act as a hint because the last held
  299.   segment gets the PUSH bit. At best, a receiver may infer tiny
  300.   arrivals might be from human typing where the operating system will
  301.   provide an immediate echo.
  302.  
  303.   Delayed ACKs would be more effective if the receiver were to adjust
  304.   the delay time to match the session, say in a manner similar to
  305.   making round trip timing estimates. One or two round trip times seems
  306.   appropriate, where that information is available. One way transfers
  307.   such as the FTP data channel make this approach impractical. In
  308.   addition, fine scale timers for crisp responses are a burden for the
  309.   operating system and may not be available for the short intervals of
  310.   local area networking. For example, the 200ms delay of the fast timer
  311.   in many BSD systems is very long on even many of today's long
  312.   distance links. Thus the concept of dynamic delay time is difficult
  313.   at this time and becomes more so at increasingly higher network
  314.   speeds.
  315.  
  316.   2.0 New transmission policy
  317.  
  318.   This document proposes a new TCP transmission policy that allows
  319.   delayed ACKs to work as present, thus retaining their advantages. It
  320.   groups octets similar to Nagle algorithms and yet avoids deadlocks.
  321.  
  322.   Two terms need to be defined to simplify discussion. These are
  323.   "available" data and "allowed" capacity. "Available" data are all the
  324.   data from the application which are not yet sent. It is what a single
  325.   write or output statement would provide. The TCP stack may see only a
  326.   portion of this data on each invocation, or it may see it all. This
  327.   implies the TCP stack knows such a length either explicitly or
  328.   through an indicator from its caller. Current TCP stacks already
  329.   perform this test to properly set the PUSH (PSH) bit.
  330.  
  331.   "Allowed" capacity is the number of octets permitted to be sent based
  332.   on calculated receiver window size and congestion avoidance limits.
  333.   It is the minimum of these two constraints. Calculated receiver
  334.   window size is the usual value of the last announced window size
  335.   minus the sent but unACKed data. It does not necessarily yield even
  336.   MSS values. Heuristics in the transmitter may modify the calculation.
  337.   Congestion avoidance is the normal Van Jacobson congestion window
  338.   [TCP:3] and this normally yields full MSS values.
  339.  
  340.   The new policy acts after the window size and congestion avoidance
  341.   size restrictions are applied.
  342.  
  343.   The transmitting side has a transmission policy designed to group
  344.   data into full segments and to not hold the very last segment. This
  345.   may be stated ambiguously as transmit now if a full segment is
  346.  
  347.   Doupnik                                                       Page 6
  348.   A new TCP transmission policy replacing Nagle mode          [Page 7]
  349.  
  350.  
  351.   available (after limitations of receiver window size and congestion
  352.   avoidance are applied). A small segment candidate should be sent
  353.   immediately only if it exhausts all data from the application;
  354.   otherwise it should be held for joining by more application data.
  355.  
  356.   Two parts of the above paragraph are unclear. First, "transmit now"
  357.   does not state how much can be transmitted at one time, a problem
  358.   seen with the Nagle algorithm. The policy can be strict: transmit
  359.   whole segments only and withhold a final small segment until an
  360.   indicator of "no more data will follow" has been obtained. It can be
  361.   liberal: transmit a partially full segment if one or more full
  362.   segments immediately precede it, even though this leads to smaller
  363.   segments on the wire than the strict case. These two policies mimic
  364.   strict and liberal Nagle modes used today, but minus ACKs and
  365.   consideration for unACKed data.
  366.  
  367.   What the policy should not be: hold back a small segment because
  368.   unACKed data is present. That creates the held tail deadlock seen
  369.   with Nagle mode combined with delayed ACKs.
  370.  
  371.   The second ambiguous part is the size of the transmission buffer.
  372.   Some systems expose the entire application buffer to the protocol
  373.   stack. In such systems TCP may easily decide when the current
  374.   candidate for transmission will empty the buffer. Other systems may
  375.   divide the application buffer into many smaller intermediate buffers
  376.   and expose only an intermediate buffer to TCP, one for each call upon
  377.   the transmitter. The latter requires the operating system to provide
  378.   an indicator of end of application data, a flag or variable or
  379.   equivalent, marking the current buffer as the last in a series and
  380.   thus no more data will follow it. In either case, the TCP stack knows
  381.   how much data is "available" and thus it knows when to properly set
  382.   the PUSH (PSH) bit.
  383.  
  384.   2.1 Formal statement of new policy
  385.  
  386.   Stated formally the new transmission policy is as follows:
  387.  
  388.      Rule 1. Transmit all full segments in min(available, allowed).
  389.  
  390.      Rule 2. If a partial segment occurs in min(available, allowed)
  391.      then transmit it now if it includes the end of application data;
  392.      otherwise retain it.
  393.  
  394.      And optionally
  395.  
  396.      Rule 3. If a partial segment occurs in min(available, allowed)
  397.      then transmit it now if min(available, allowed) is larger than a
  398.      full segment. This modifies phrase "otherwise retain it" above.
  399.  
  400.   min(a, b) represents the smaller value of a or b.
  401.   Available is the total amount of unsent application data at the time
  402.   of transmission.
  403.   Allowed is the smaller of receiver apparent window size and
  404.   congestion avoidance constraints.
  405.  
  406.   Doupnik                                                       Page 7
  407.   A new TCP transmission policy replacing Nagle mode          [Page 8]
  408.  
  409.  
  410.   2.2 Discussion
  411.  
  412.   We see that Rule 2 represents a policy of strict grouping until the
  413.   end of application data. Rules 1 and 2 are necessary and sufficient
  414.   for good network behavior and good application response.
  415.  
  416.   Key points of the new policy are the release conditions are generated
  417.   by the transmitter rather than the receiver, and the conditions are a
  418.   full segment or indication of end of application data. For Nagle
  419.   modes, the release is generated by transmitter and receiver, and the
  420.   conditions are a full segment or all previous data have been ACKed.
  421.  
  422.   Optional Rule 3 is a liberal policy to permit sending small segments
  423.   from data immediately available but not at the end of application
  424.   data. Rule 3 is presented only because some existing TCP/IP stacks
  425.   are designed for the liberal Nagle approach.
  426.  
  427.   In practice, the above rules can be overlaid upon current Nagle mode
  428.   code. The full segment test is performed, and the case where a small
  429.   segment is to be delayed is modified to be: transmit a small segment
  430.   if end of application data is reached, else delay it as before.
  431.  
  432.   At this point, we must discuss a useful and important side effect of
  433.   using the new policy: the network will do what the application asks!
  434.  
  435.   When an application does small immediate mode writes, then it largely
  436.   controls the size of segments sent onto the wire. This is because
  437.   each output statement implies its own end of application data (give
  438.   or take whatever the operating system may do between it and the
  439.   protocol stack). In an extreme case the application may perform
  440.   single octet writes in massive succession before reading a response.
  441.   If the network can drain data faster than the application can create
  442.   data (a classical queueing problem) then massive quantities of tiny
  443.   segments will appear on the network. That imposes a very heavy load
  444.   on both hosts and network communications. Slower draining yields
  445.   larger segments, naturally, but erratically from erratic delays.
  446.  
  447.   By way of contrast, Nagle mode will send small segments if ACKs
  448.   arrive promptly. When they don't then Nagle mode strongly groups
  449.   data. A difference between Nagle mode and the new policy is timing
  450.   affects Nagle mode and end of application data affects the new
  451.   policy. The new policy strongly groups bytes that are within the
  452.   application data set, independent of ACKs. One method uses network
  453.   delays to group data and the other uses the application and local
  454.   operating system.
  455.  
  456.   Non-Nagle mode waits for neither ACKs nor indication from the
  457.   application. Liberal Nagle mode will behave like strict or non-Nagle
  458.   modes, depending on whether all unsent data are smaller than a full
  459.   segment, respectively.
  460.  
  461.   In the above case of one octet writing by the application, new policy
  462.   and non-Nagle modes behave alike: send tinygrams. Nagle modes group
  463.   data to the extent that ACKs are delayed.
  464.  
  465.   Doupnik                                                       Page 8
  466.   A new TCP transmission policy replacing Nagle mode          [Page 9]
  467.  
  468.  
  469.   To remove the uncertain element of ACK time of arrival, and its
  470.   consequences for held tails and timer based ACKing, as well as bring
  471.   the small segment problem under control the best strategy is for the
  472.   application to write large components. This is readily accomplished
  473.   by the application programmer. For example, rather than using
  474.   immediate mode writing operations, such as Unix function write(),
  475.   one may use equivalents which are buffered automatically in the
  476.   application, such as Unix functions fwrite() or printf(). Unix
  477.   functions are only illustrative here, as is BSD sockets. With
  478.   buffered functions the protocol stack sees large buffer amounts even
  479.   if data are generated in small increments by the application. Then
  480.   the issue becomes one of using ACK time or application indication.
  481.  
  482.   Buffering is often accompanied by a buffer flush function, such as
  483.   fflush() in Unix, to ensure all data are released at that time rather
  484.   than waiting for the data pathway to be formally closed. A buffer flush
  485.   function also serves as an indirect signal to the protocol stack that
  486.   application data writing is complete, without there being a need to
  487.   invent a special programmer's equivalent to flush TCP transmit data.
  488.   The new policy is closely analogous to this file system buffering.
  489.  
  490.   It seems to the author that data aggregation at the application
  491.   level makes best sense because the natural end of writing is known
  492.   only at that level. Trying to predict the end of writing at the
  493.   protocol stack level by either transmitter or receiver, in
  494.   expectation of avoiding held tails from delayed ACKs and yet
  495.   delaying transmission to form full length segments, is a very
  496.   difficult task. It probably has no solution in the general case
  497.   because a stack does not know when the application is truly finished
  498.   writing. At best the stack is told when a portion of the output has
  499.   been prepared. The new policy uses that information, as does the
  500.   stack to set the PUSH bit.
  501.  
  502.   The new policy provides immediate response by the network when the
  503.   application so indicates, which as noted is a double edged sword;
  504.   otherwise it groups independently of network timing.
  505.  
  506.   The alternatives seem to be we must endure the delayed ACK effect of
  507.   Nagle modes, or risk sending many small segments by poorly designed
  508.   applications, or application writers will turn to UDP and bypass 
  509.   network protection mechanisms.
  510.  
  511.   2.3 Operation between like and unlike TCP stacks
  512.  
  513.   The new transmission policy proposed here resides entirely on the
  514.   transmitting host. Receivers remain unchanged. Clearly, with
  515.   bilateral exchanges both sides should implement the policy for best
  516.   speed. The new policy sends the trailing segment of a series without
  517.   waiting for ACKs to previous data, the same as non-Nagle mode. The
  518.   new policy groups data into full segments (strict Rule 2), or does so
  519.   most of the time (Rule 2 plus optional Rule 3), whereas non-Nagle
  520.   mode and liberal Nagle mode may send short segments as each portion
  521.  
  522.  
  523.   Doupnik                                                       Page 9
  524.  
  525.   A new TCP transmission policy replacing Nagle mode         [Page 10]
  526.  
  527.  
  528.   of application data is delivered to the TCP stack. The PUSH bit
  529.   should be set at end of application data by all policies.
  530.  
  531.   The receiver and network are ready to deal with the data, because
  532.   window size and congestion avoidance criteria are still effective and
  533.   are applied before either Nagle or new policy mechanisms. New policy
  534.   transmitters send the trailing segment when the network and remote
  535.   host is ready, whereas Nagle mode transmitters may wait for one or
  536.   more ACKs to arrive.
  537.  
  538.   The new policy works well with the classical case of write(small),
  539.   write(small), read(). Each write() creates a new application data set
  540.   and each is sent immediately. Both strict and liberal Nagle
  541.   transmitter holds the second write's data; that is the held tail
  542.   effect. The new policy transmitter does not hold the second write's
  543.   data, nor does non-Nagle mode.
  544.  
  545.   The new policy results in more tinygrams when a user is typing by
  546.   hand, because each keystroke constitutes an entire application
  547.   buffer. In practice this is a non-problem because people don't type
  548.   that fast compared to even 200ms delayed ACKs. Thus in practice for
  549.   human typing all three approaches and non-Nagle are about the same on
  550.   the wire. Please see above on data aggregation by applications.
  551.  
  552.   Let us compare the three approaches for longer data transmissions.
  553.   Strict Nagle induces a held-tail for each application buffer longer
  554.   than one segment. Liberal Nagle can also, but only when windowing or
  555.   congestion avoidance hold back octets. New policy and non-Nagle
  556.   transmitters do not hold tails. During sending of the application
  557.   buffer liberal Nagle, liberal new policy, and non-Nagle transmitters
  558.   may send short segments if the data are delivered to the transmitter
  559.   in small pieces. Strict Nagle and strict new policy transmitters join
  560.   interior small pieces into full segments. However, small segments may
  561.   arise naturally if the application buffer is short and/or its filling
  562.   is slower than its draining by the network.
  563.  
  564.   In summary, new policy transmitters should work well with existing
  565.   TCP/IP stacks and should produce no known side effects.
  566.  
  567.   3.0 Experimental results
  568.  
  569.   Four machines were used in a test configuration to examine serving
  570.   web page activity with and without Nagle mode, and with the new
  571.   transmission policy.
  572.  
  573.   Operating System Descriptions:
  574.   UnixWare 7.0.1
  575.           400MHz AMD cpu, 200ms delayed ACK, strict Nagle mode.
  576.           32KB receive window. Source code was not available.
  577.   FreeBSD v3.2
  578.           233MHz AMD cpu, 200ms delayed ACK, strict Nagle mode.
  579.           Source code was modified for new policy. Note indication
  580.           of TCP receive window size, rwnd, in tests.
  581.  
  582.   Doupnik                                                      Page 10
  583.  
  584.   A new TCP transmission policy replacing Nagle mode         [Page 11]
  585.  
  586.  
  587.   Solaris 7/Intel
  588.           350MHz AMD cpu, 50ms delayed ACK, liberal Nagle mode.
  589.           8KB receive window. Source code was modified for new policy.
  590.   Linux 2.2.5-15
  591.           350MHz AMD cpu, 10ms dynamically adjusted delayed ACK,
  592.           liberal Nagle mode. 16KB receive window. Source code was
  593.           modified for new policy.
  594.  
  595.   Interconnections were via a 100Mbps Ethernet hub. This has
  596.   implications for the tests. The fast network is able to drain TCP
  597.   data faster than the application can supply it. Thus protocol
  598.   behavior is exposed that otherwise would be hidden by forced holding
  599.   back from congestion avoidance and window size constraints.
  600.  
  601.   The test procedure employs a web request client to request a web
  602.   page, receive and discard it without reading the content, request it
  603.   again, and so on, and provide timing results. The client sends a
  604.   short one packet GET request, it reads the server's HTTP headers and
  605.   then it counts in the following data file. Once all data file octets
  606.   have been read then the original request is repeated.
  607.  
  608.   Each Unix machine runs a simplified web server that replies to the
  609.   request with two short packets, HTTP web server identification and
  610.   the HTTP document description, followed by the document itself. Thus
  611.   there are two short write()'s followed by a succession of 4KB
  612.   write()'s for the file body. The client counts file octets and when
  613.   done initiates the next request. Keep-alive connections were used to
  614.   create a succession of request and replies on the same TCP
  615.   connection. The serial nature of the request and reply means the
  616.   longer the file the fewer requests occur per second.
  617.  
  618.   The web client produces delayed ACKs to all servers. Its use or not
  619.   of Nagle mode has no influence because each request is only one
  620.   segment and occurs after each long response from the server. Thus the
  621.   server's protocol behavior is being examined in the presence of
  622.   delayed ACKs.
  623.  
  624.   The web server is run as a single process without threads, to
  625.   simplify the experiment and to emphasize serialized request and
  626.   response interaction. Requests were repeated as fast as the systems
  627.   could perform, up to 60 seconds or 50000 requests.
  628.  
  629.   The short file is smaller than window size and congestion avoidance
  630.   limits, as well as fitting into a single Unix write() statement.  The
  631.   longer file may encounter the window size limit, and it will be
  632.   expressed as a sequence of Unix write statements. Both files have
  633.   tails to be held (should we name this the monkey effect?).
  634.  
  635.   The interaction between Nagle mode and 200ms delayed ACKs is evident.
  636.   Also present is a case where liberal Nagle mode is caught by delayed
  637.   ACKs when window size constraints leave a small segment without
  638.   preceding large segments to drag it out.
  639.  
  640.  
  641.   Doupnik                                                      Page 11
  642.  
  643.   A new TCP transmission policy replacing Nagle mode         [Page 12]
  644.  
  645.  
  646.   What the results show is the new policy works. It works better than
  647.   strict Nagle. It works as well as both liberal Nagle (but without the
  648.   held tail effect) and non-Nagle (but without sending small segments
  649.   gratuitously). It does not require control at the application layer.
  650.   However, as discussed previously, applications can abuse the swift
  651.   responsiveness of the network by performing many small writes in
  652.   succession without buffering at the applications layer.
  653.  
  654.  
  655.   Table 1. Web page test results, requests and bytes per second.
  656.  
  657.   Client        Server        2.2KB file      33KB file
  658.   ------       --------       ----------      ----------
  659.  
  660.   UW7          FreeBSD         5 req/sec        5 req/sec
  661.                Nagle on       12 KB/sec       165 KB/sec
  662.  
  663.   UW7          FreeBSD      1249 req/sec      222 req/sec
  664.                Nagle off    2914 KB/sec      7142 KB/sec
  665.  
  666.   UW7          FreeBSD      1247 req/sec      228 req/sec
  667.                new policy   2909 KB/sec      7324 KB/sec
  668.  
  669.   UW7          Solaris7      991 req/sec      221 req/sec
  670.                Nagle on     2311 KB/sec      7112 KB/sec
  671.  
  672.   UW7          Solaris7      935 req/sec      219 req/sec
  673.                Nagle off    2181 KB/sec      7041 KB/sec
  674.  
  675.   UW7          Solaris7      993 req/sec      219 req/sec
  676.                new policy   2317 KB/sec      7041 KB/sec
  677.  
  678.   FreeBSD      UW7             5 req/sec        5 req/sec
  679.   16KB rwnd    Nagle on       12 KB/sec       177 KB/sec
  680.  
  681.   FreeBSD      UW7          1508 req/sec      264 req/sec
  682.   16KB rwnd    Nagle off    3519 KB/sec      8478 KB/sec
  683.  
  684.   FreeBSD      UW7             5 req/sec        5 req/sec
  685.   4KB rwnd     Nagle on       12 KB/sec       166 KB/sec
  686.  
  687.   FreeBSD      UW7          1421 req/sec      235 req/sec
  688.   4KB rwnd     Nagle off    3315 KB/sec      7553 req/sec
  689.  
  690.   FreeBSD      Linux        1665 req/sec      277 req/sec
  691.   16KB rwnd    Nagle on     3912 KB/sec      8876 KB/sec
  692.  
  693.   FreeBSD      Linux        1709 req/sec      279 req/sec
  694.   16KB rwnd    Nagle off    3987 KB/sec      8970 KB/sec
  695.  
  696.   FreeBSD      Linux        1665 req/sec      277 req/sec
  697.   16KB rwnd    new policy   3883 KB/sec      8894 KB/sec
  698.  
  699.  
  700.   Doupnik                                                      Page 12
  701.  
  702.   A new TCP transmission policy replacing Nagle mode         [Page 13]
  703.  
  704.   FreeBSD      Linux        1685 req/sec       55 req/sec
  705.   4KB rwnd     Nagle on     3930 KB/sec      1776 KB/sec
  706.  
  707.   FreeBSD      Linux        1692 req/sec      238 req/sec
  708.   4KB rwnd     Nagle off    3946 KB/sec      7634 KB/sec
  709.  
  710.   FreeBSD      Linux        1699 req/sec      241 req/sec
  711.   4KB rwnd     new policy   3964 KB/sec      7740 KB/sec
  712.  
  713.   FreeBSD      Solaris7     1104 req/sec      180 req/sec
  714.   4KB rwnd     Nagle on     2575 KB/sec      5795 KB/sec
  715.  
  716.   FreeBSD      Solaris7     1090 req/sec      180 req/sec
  717.   4KB rwnd     Nagle off    2544 KB/sec      5772 KB/sec
  718.  
  719.   FreeBSD      Solaris7     1090 req/sec      165 req/sec
  720.   4KB rwnd     new policy   2543 KB/sec      5290 KB/sec
  721.  
  722.   FreeBSD      Solaris7     1151 req/sec      233 req/sec
  723.   16KB rwnd    Nagle on     2685 KB/sec      7474 KB/sec
  724.  
  725.   FreeBSD      Solaris7     1186 req/sec      239 req/sec
  726.   16KB rwnd    Nagle off    2768 KB/sec      7669 KB/sec
  727.  
  728.   FreeBSD      Solaris7     1206 req/sec      237 req/sec
  729.   16KB rwnd    new policy   2813 KB/sec      7634 KB/sec
  730.  
  731.   Solaris7 as a client produced erratic results from long variable
  732.   delays preceding each request. This occurred for stock and modified
  733.   Solaris7. There is suspicion that its server performance may be
  734.   influenced too.
  735.  
  736.   4.0 Conclusions
  737.  
  738.   The new TCP transmission policy solves the problem of Nagle mode
  739.   deadlocking with delayed ACKs. It retains data grouping but
  740.   operates with only transmitter information. It accommodates those
  741.   systems which wish to implement a liberal sending policy regarding
  742.   partial segments not at the end of application data, and those which
  743.   prefer the stronger grouping of a strict sending policy.
  744.  
  745.   The new policy works well with delayed ACKs and sending into small 
  746.   receiver windows. Its performance is essentially the same as non-Nagle
  747.   mode, yet it retains grouping which non-Nagle mode does not. It does
  748.   not need an on/off control visible to applications. The new 
  749.   transmission policy is a suitable replacement for Nagle mode.
  750.  
  751.   The warning is the same as for non-Nagle mode: what is sent by the
  752.   application to the protocol stack is also what the network tries to
  753.   send. Thus grouping of data in applications and/or operating systems
  754.   remains a good idea.
  755.  
  756.  
  757.  
  758.  
  759.   Doupnik                                                      Page 13
  760.  
  761.   A new TCP transmission policy replacing Nagle mode         [Page 14]
  762.  
  763.  
  764.   5.0 Security Considerations
  765.  
  766.   There are no security considerations in this memo.
  767.  
  768.   6.0 Acknowledgements
  769.  
  770.   Special thanks to John Nagle for candid discussions on the problem
  771.   and reviewing the draft document. Thanks to Gehri Grimaud at Utah
  772.   State University for introducing the author to FreeBSD and helping to
  773.   run experiments. And to Miles Johnson at USU, Richard J. Letts at
  774.   Salford University in the UK and Diana Osborn at San Diego State
  775.   University for reading the rough draft of this document.
  776.  
  777.   7.0 References
  778.  
  779.   [TCP:1] "Congestion Control in IP/TCP," J. Nagle, RFC-896, January
  780.   1984.
  781.  
  782.   [TCP:2] "Requirements for Internet Hosts -- Communication Layers", R.
  783.   Brandon RFC-1122, October 1989.
  784.  
  785.   [TCP:3] "Congestion Avoidance and Control," V. Jacobson, ACM SIGCOMM-
  786.   88, August 1988.
  787.  
  788.   8.0 Author's address
  789.  
  790.   Joe R. Doupnik
  791.   Dept of Electrical and Computer Engineering
  792.   Utah State University
  793.   Logan, Utah 84322
  794.   Phone: (801) 797-2982
  795.   Email: jrd@cc.usu.edu
  796.  
  797.  
  798.   Full Copyright Statement
  799.  
  800.   "Copyright (C) The Internet Society (1999). All Rights Reserved. This
  801.   document and translations of it may be copied and furnished to
  802.   others, and derivative works that comment on or otherwise explain it
  803.   or assist in its implementation may be prepared, copied, published
  804.   and distributed, in whole or in part, without restriction of any
  805.   kind, provided that the above copyright notice and this paragraph are
  806.   included on all such copies and derivative works. However, this
  807.   document itself may not be modified in any way, such as by removing
  808.   the copyright notice or references to the Internet Society or other
  809.   Internet organizations, except as needed for the purpose of
  810.   developing Internet standards in which case the procedures for
  811.   copyrights defined in the Internet Standards process must be
  812.   followed, or as required to translate it into languages other than
  813.   English.
  814.  
  815.   The limited permissions granted above are perpetual and will not be
  816.   revoked by the Internet Society or its successors or assigns.
  817.  
  818.   Doupnik                                                      Page 14
  819.  
  820.   A new TCP transmission policy replacing Nagle mode         [Page 15]
  821.  
  822.  
  823.   This document and the information contained herein is provided on an
  824.   "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
  825.   TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
  826.   BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
  827.   HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
  828.   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE."
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.   Doupnik                                                      Page 15
  878.  
  879.