idnits 2.17.1 draft-ietf-tcpm-1323bis-02.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack a both a reference to RFC 2119 and the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. RFC 2119 keyword, line 545: '...1) The receiver MUST honor, as in-win...' RFC 2119 keyword, line 548: '... effect, the receiver SHOULD track the...' RFC 2119 keyword, line 556: '...ial transmission MUST honor window on ...' -- The abstract seems to indicate that this document obsoletes RFC1323, but the header doesn't have an 'Obsoletes:' line to match this. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1399 has weird spacing: '... TSval times...' == Line 1401 has weird spacing: '... TSecr times...' -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (May 18, 2012) is 4354 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '1' on line 299 ** Obsolete normative reference: RFC 793 (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 896 (Obsoleted by RFC 7805) -- Obsolete informational reference (is this intentional?): RFC 1072 (Obsoleted by RFC 1323, RFC 2018, RFC 6247) -- Obsolete informational reference (is this intentional?): RFC 1110 (Obsoleted by RFC 6247) -- Obsolete informational reference (is this intentional?): RFC 1185 (Obsoleted by RFC 1323) -- Obsolete informational reference (is this intentional?): RFC 1323 (Obsoleted by RFC 7323) -- Obsolete informational reference (is this intentional?): RFC 2581 (Obsoleted by RFC 5681) -- Obsolete informational reference (is this intentional?): RFC 3517 (Obsoleted by RFC 6675) Summary: 2 errors (**), 0 flaws (~~), 3 warnings (==), 12 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 TCP Maintenance (TCPM) D. Borman 3 Internet-Draft Quantum Corporation 4 Intended status: Standards Track B. Braden 5 Expires: November 19, 2012 University of Southern 6 California 7 V. Jacobson 8 Packet Design 9 R. Scheffenegger, Ed. 10 NetApp, Inc. 11 May 18, 2012 13 TCP Extensions for High Performance 14 draft-ietf-tcpm-1323bis-02 16 Abstract 18 This memo presents a set of TCP extensions to improve performance 19 over large bandwidth*delay product paths and to provide reliable 20 operation over very high-speed paths. It defines TCP options for 21 scaled windows and timestamps, which are designed to provide 22 compatible interworking with TCP's that do not implement the 23 extensions. The timestamps are used for two distinct mechanisms: 24 RTTM (Round Trip Time Measurement) and PAWS (Protection Against 25 Wrapped Sequences). Selective acknowledgments are not included in 26 this memo. 28 This memo updates and obsoletes RFC 1323. 30 Status of this Memo 32 This Internet-Draft is submitted in full conformance with the 33 provisions of BCP 78 and BCP 79. 35 Internet-Drafts are working documents of the Internet Engineering 36 Task Force (IETF). Note that other groups may also distribute 37 working documents as Internet-Drafts. The list of current Internet- 38 Drafts is at http://datatracker.ietf.org/drafts/current/. 40 Internet-Drafts are draft documents valid for a maximum of six months 41 and may be updated, replaced, or obsoleted by other documents at any 42 time. It is inappropriate to use Internet-Drafts as reference 43 material or to cite them other than as "work in progress." 45 This Internet-Draft will expire on November 19, 2012. 47 Copyright Notice 48 Copyright (c) 2012 IETF Trust and the persons identified as the 49 document authors. All rights reserved. 51 This document is subject to BCP 78 and the IETF Trust's Legal 52 Provisions Relating to IETF Documents 53 (http://trustee.ietf.org/license-info) in effect on the date of 54 publication of this document. Please review these documents 55 carefully, as they describe your rights and restrictions with respect 56 to this document. Code Components extracted from this document must 57 include Simplified BSD License text as described in Section 4.e of 58 the Trust Legal Provisions and are provided without warranty as 59 described in the Simplified BSD License. 61 Table of Contents 63 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 64 1.1. TCP Performance . . . . . . . . . . . . . . . . . . . . . 4 65 1.2. TCP Reliability . . . . . . . . . . . . . . . . . . . . . 6 66 1.3. Using TCP options . . . . . . . . . . . . . . . . . . . . 9 67 2. TCP Window Scale Option . . . . . . . . . . . . . . . . . . . 10 68 2.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . 10 69 2.2. Window Scale Option . . . . . . . . . . . . . . . . . . . 10 70 2.3. Using the Window Scale Option . . . . . . . . . . . . . . 11 71 2.4. Addressing Window Retraction . . . . . . . . . . . . . . . 13 72 3. RTTM -- Round-Trip Time Measurement . . . . . . . . . . . . . 13 73 3.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . 13 74 3.2. TCP Timestamps Option . . . . . . . . . . . . . . . . . . 14 75 3.3. The RTTM Mechanism . . . . . . . . . . . . . . . . . . . . 15 76 3.4. Which Timestamp to Echo . . . . . . . . . . . . . . . . . 17 77 4. PAWS -- Protection Against Wrapped Sequence Numbers . . . . . 19 78 4.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . 19 79 4.2. The PAWS Mechanism . . . . . . . . . . . . . . . . . . . . 20 80 4.2.1. Basic PAWS Algorithm . . . . . . . . . . . . . . . . . 21 81 4.2.2. Timestamp Clock . . . . . . . . . . . . . . . . . . . 23 82 4.2.3. Outdated Timestamps . . . . . . . . . . . . . . . . . 24 83 4.2.4. Header Prediction . . . . . . . . . . . . . . . . . . 25 84 4.2.5. IP Fragmentation . . . . . . . . . . . . . . . . . . . 26 85 4.3. Duplicates from Earlier Incarnations of Connection . . . . 27 86 5. Conclusions and Acknowledgements . . . . . . . . . . . . . . . 27 87 6. Security Considerations . . . . . . . . . . . . . . . . . . . 28 88 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 28 89 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 28 90 8.1. Normative References . . . . . . . . . . . . . . . . . . . 28 91 8.2. Informative References . . . . . . . . . . . . . . . . . . 29 92 Appendix A. Implementation Suggestions . . . . . . . . . . . . . 31 93 Appendix B. Duplicates from Earlier Connection Incarnations . . . 32 94 B.1. System Crash with Loss of State . . . . . . . . . . . . . 32 95 B.2. Closing and Reopening a Connection . . . . . . . . . . . . 32 96 Appendix C. Changes from RFC 1072, RFC 1185, and RFC 1323 . . . . 34 97 Appendix D. Summary of Notation . . . . . . . . . . . . . . . . . 36 98 Appendix E. Pseudo-code Summary . . . . . . . . . . . . . . . . . 37 99 Appendix F. Event Processing Summary . . . . . . . . . . . . . . 39 100 Appendix G. Timestamps Edge Cases . . . . . . . . . . . . . . . . 44 101 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 45 103 1. Introduction 105 The TCP protocol [RFC0793] was designed to operate reliably over 106 almost any transmission medium regardless of transmission rate, 107 delay, corruption, duplication, or reordering of segments. 108 Production TCP implementations currently adapt to transfer rates in 109 the range of 100 bps to 10^10 bps and round-trip delays in the range 110 1 ms to 100 seconds. Work on TCP performance has shown that TCP 111 without the extensions described in this memo can work well over a 112 variety of Internet paths, ranging from 800 Mbit/sec I/O channels to 113 300 bit/sec dial-up modems . 115 Over the years, advances in networking technology has resulted in 116 ever-higher transmission speeds, and the fastest paths are well 117 beyond the domain for which TCP was originally engineered. This memo 118 defines a set of modest extensions to TCP to extend the domain of its 119 application to match this increasing network capability. It is an 120 update to and obsoletes [RFC1323], which in turn is based upon and 121 obsoletes [RFC1072] and [RFC1185]. 123 There is no one-line answer to the question: "How fast can TCP go?". 124 There are two separate kinds of issues, performance and reliability, 125 and each depends upon different parameters. We discuss each in turn. 127 1.1. TCP Performance 129 TCP performance depends not upon the transfer rate itself, but rather 130 upon the product of the transfer rate and the round-trip delay. This 131 "bandwidth*delay product" measures the amount of data that would 132 "fill the pipe"; it is the buffer space required at sender and 133 receiver to obtain maximum throughput on the TCP connection over the 134 path, i.e., the amount of unacknowledged data that TCP must handle in 135 order to keep the pipeline full. TCP performance problems arise when 136 the bandwidth*delay product is large. We refer to an Internet path 137 operating in this region as a "long, fat pipe", and a network 138 containing this path as an "LFN" (pronounced "elephan(t)"). 140 High-capacity packet satellite channels are LFN's. For example, a 141 DS1-speed satellite channel has a bandwidth*delay product of 10^6 142 bits or more; this corresponds to 100 outstanding TCP segments of 143 1200 bytes each. Terrestrial fiber-optical paths will also fall into 144 the LFN class; for example, a cross-country delay of 30 ms at a DS3 145 bandwidth (45Mbps) also exceeds 10^6 bits. 147 There are three fundamental performance problems with the current TCP 148 over LFN paths: 150 (1) Window Size Limit 152 The TCP header uses a 16 bit field to report the receive window 153 size to the sender. Therefore, the largest window that can be 154 used is 2^16 = 65K bytes. 156 To circumvent this problem, Section 2 of this memo defines a new 157 TCP option, "Window Scale", to allow windows larger than 2^16. 158 This option defines an implicit scale factor, which is used to 159 multiply the window size value found in a TCP header to obtain 160 the true window size. 162 (2) Recovery from Losses 164 Packet losses in an LFN can have a catastrophic effect on 165 throughput. In the past, properly-operating TCP implementations 166 would cause the data pipeline to drain with every packet loss, 167 and require a slow-start action to recover. The Fast Retransmit 168 and Fast Recovery algorithms [Jacobson90c], [RFC2581] and 169 [RFC5681] were introduced, and their combined effect was to 170 recover from one packet loss per window, without draining the 171 pipeline. However, more than one packet loss per window 172 typically resulted in a retransmission timeout and the resulting 173 pipeline drain and slow start. 175 Expanding the window size to match the capacity of an LFN 176 results in a corresponding increase of the probability of more 177 than one packet per window being dropped. This could have a 178 devastating effect upon the throughput of TCP over an LFN. In 179 addition, since the publication of RFC 1323, congestion control 180 mechanism based upon some form of random dropping have been 181 introduced into gateways, and randomly spaced packet drops have 182 become common; this increases the probability of dropping more 183 than one packet per window. 185 To generalize the Fast Retransmit/Fast Recovery mechanism to 186 handle multiple packets dropped per window, selective 187 acknowledgments are required. Unlike the normal cumulative 188 acknowledgments of TCP, selective acknowledgments give the 189 sender a complete picture of which segments are queued at the 190 receiver and which have not yet arrived. 192 Since the publication of [RFC1323], selective acknowledgments 193 (SACK) have become important in the LFN regime. SACK has been 194 published as a [RFC2018], "TCP Selective Acknowledgment 195 Options".. Additional information about SACK can be found in 196 [RFC2883], "An Extension to the Selective Acknowledgement (SACK) 197 option for TCP" and [RFC3517], "A Conservative Selective 198 Acknowledgment (SACK)-based Loss Recovery Algorithm for TCP". 200 (3) Round-Trip Measurement 202 TCP implements reliable data delivery by retransmitting segments 203 that are not acknowledged within some retransmission timeout 204 (RTO) interval. Accurate dynamic determination of an 205 appropriate RTO is essential to TCP performance. RTO is 206 determined by estimating the mean and variance of the measured 207 round-trip time (RTT), i.e., the time interval between sending a 208 segment and receiving an acknowledgment for it [Jacobson88a]. 210 Section 3.2 introduces a new TCP option, "Timestamps", and then 211 defines a mechanism using this option that allows nearly every 212 segment, including retransmissions, to be timed at negligible 213 computational cost. We use the mnemonic RTTM (Round Trip Time 214 Measurement) for this mechanism, to distinguish it from other 215 uses of the Timestamps option. 217 1.2. TCP Reliability 219 Now we turn from performance to reliability. High transfer rate 220 enters TCP performance through the bandwidth*delay product. However, 221 high transfer rate alone can threaten TCP reliability by violating 222 the assumptions behind the TCP mechanism for duplicate detection and 223 sequencing. 225 An especially serious kind of error may result from an accidental 226 reuse of TCP sequence numbers in data segments. Suppose that an "old 227 duplicate segment", e.g., a duplicate data segment that was delayed 228 in Internet queues, is delivered to the receiver at the wrong moment, 229 so that its sequence numbers falls somewhere within the current 230 window. There would be no checksum failure to warn of the error, and 231 the result could be an undetected corruption of the data. Reception 232 of an old duplicate ACK segment at the transmitter could be only 233 slightly less serious: it is likely to lock up the connection so that 234 no further progress can be made, forcing an RST on the connection. 236 TCP reliability depends upon the existence of a bound on the lifetime 237 of a segment: the "Maximum Segment Lifetime" or MSL. An MSL is 238 generally required by any reliable transport protocol, since every 239 sequence number field must be finite, and therefore any sequence 240 number may eventually be reused. In the Internet protocol suite, the 241 MSL bound is enforced by an IP-layer mechanism, the "Time-to-Live" or 242 TTL field. 244 Duplication of sequence numbers might happen in either of two ways: 246 (1) Sequence number wrap-around on the current connection 248 A TCP sequence number contains 32 bits. At a high enough 249 transfer rate, the 32-bit sequence space may be "wrapped" 250 (cycled) within the time that a segment is delayed in queues. 252 (2) Earlier incarnation of the connection 254 Suppose that a connection terminates, either by a proper close 255 sequence or due to a host crash, and the same connection (i.e., 256 using the same pair of sockets) is immediately reopened. A 257 delayed segment from the terminated connection could fall within 258 the current window for the new incarnation and be accepted as 259 valid. 261 Duplicates from earlier incarnations, Case (2), are avoided by 262 enforcing the current fixed MSL of the TCP spec, as explained in 263 Section 4.3 and Appendix B. However, case (1), avoiding the reuse of 264 sequence numbers within the same connection, requires an MSL bound 265 that depends upon the transfer rate, and at high enough rates, a new 266 mechanism is required. 268 More specifically, if the maximum effective bandwidth at which TCP is 269 able to transmit over a particular path is B bytes per second, then 270 the following constraint must be satisfied for error-free operation: 272 2^31 / B > MSL (secs) [1] 274 The following table shows the value for Twrap = 2^31/B in seconds, 275 for some important values of the bandwidth B: 277 +------------------+----------+-------------+--------------------+ 278 | Network | bits/sec | B bytes/sec | Twrap secs | 279 +------------------+----------+-------------+--------------------+ 280 | Dialup | 56kbps | 7kBps | 3*10^5 (~3.6 days) | 281 | DS1 | 1.5Mbps | 190kBps | 10^4 (~3 hours) | 282 | 10MBit Ethernet | 10Mbps | 1.25MBps | 1700 (~0.5 hours) | 283 | DS3 | 45Mbps | 5.6MBps | 380 | 284 | 100MBit Ethernet | 100Mbps | 12.5MBps | 170 | 285 | Gigabit Ethernet | 1Gbps | 125MBps | 17 | 286 | 10Gig Ethernet | 10Gbps | 1.25GBps | 1.7 | 287 +------------------+----------+-------------+--------------------+ 289 It is clear that wrap-around of the sequence space is not a problem 290 for 56kbps packet switching or even 10Mbps Ethernets. On the other 291 hand, at DS3 and 100mbit speeds, Twrap is comparable to the 2 minute 292 MSL assumed by the TCP specification [RFC0793]. Moving towards and 293 beyond gigabit speeds, Twrap becomes too small for reliable 294 enforcement by the Internet TTL mechanism. 296 The 16-bit window field of TCP limits the effective bandwidth B to 297 2^16/RTT, where RTT is the round-trip time in seconds [RFC1110]. If 298 the RTT is large enough, this limits B to a value that meets the 299 constraint [1] for a large MSL value. For example, consider a 300 transcontinental backbone with an RTT of 60ms (set by the laws of 301 physics). With the bandwidth*delay product limited to 64KB by the 302 TCP window size, B is then limited to 1.1MBps, no matter how high the 303 theoretical transfer rate of the path. This corresponds to cycling 304 the sequence number space in Twrap = 2000 secs, which is safe in 305 today's Internet. 307 It is important to understand that the culprit is not the larger 308 window but rather the high bandwidth. For example, consider a (very 309 large) FDDI LAN with a diameter of 10km. Using the speed of light, 310 we can compute the RTT across the ring as (2*10^4)/(3*10^8) = 67 311 microseconds, and the delay*bandwidth product is then 833 bytes. A 312 TCP connection across this LAN using a window of only 833 bytes will 313 run at the full 100mbps and can wrap the sequence space in about 3 314 minutes, very close to the MSL of TCP. Thus, high speed alone can 315 cause a reliability problem with sequence number wrap-around, even 316 without extended windows. 318 Watson's Delta-T protocol [Watson81] includes network-layer 319 mechanisms for precise enforcement of an MSL. In contrast, the IP 320 mechanism for MSL enforcement is loosely defined and even more 321 loosely implemented in the Internet. Therefore, it is unwise to 322 depend upon active enforcement of MSL for TCP connections, and it is 323 unrealistic to imagine setting MSL's smaller than the current values 324 (e.g., 120 seconds specified for TCP). 326 A possible fix for the problem of cycling the sequence space would be 327 to increase the size of the TCP sequence number field. For example, 328 the sequence number field (and also the acknowledgment field) could 329 be expanded to 64 bits. This could be done either by changing the 330 TCP header or by means of an additional option. 332 Section 4 presents a different mechanism, which we call PAWS (Protect 333 Against Wrapped Sequence numbers), to extend TCP reliability to 334 transfer rates well beyond the foreseeable upper limit of network 335 bandwidths. PAWS uses the TCP Timestamps option defined in 336 Section 3.2 to protect against old duplicates from the same 337 connection. 339 1.3. Using TCP options 341 The extensions defined in this memo all use new TCP options. We must 342 address two possible issues concerning the use of TCP options: (1) 343 compatibility and (2) overhead. 345 We must pay careful attention to compatibility, i.e., to 346 interoperation with existing implementations. The only TCP option 347 defined previously, MSS, may appear only on a SYN segment. Every 348 implementation should (and we expect that most will) ignore unknown 349 options on SYN segments. When RFC 1323 was published, there was 350 concern that some buggy TCP implementation might be crashed by the 351 first appearance of an option on a non-SYN segment. However, bugs 352 like that can lead to DOS attacks against a TCP, so it is now 353 expected that most TCP implementations will properly handle unknown 354 options on non-SYN segments. But it is still prudent to be 355 conservative in what you send, and avoiding buggy TCP implementation 356 is not the only reason for negotiating TCP options on SYN segments. 357 Therefore, for each of the extensions defined below, TCP options will 358 be sent on non-SYN segments only after an exchange of options on the 359 the SYN segments has indicated that both sides understand the 360 extension. Furthermore, an extension option will be sent in a 361 segment only if the corresponding option was received in 362 the initial segment. 364 A question may be raised about the bandwidth and processing overhead 365 for TCP options. Those options that occur on SYN segments are not 366 likely to cause a performance concern. Opening a TCP connection 367 requires execution of significant special-case code, and the 368 processing of options is unlikely to increase that cost 369 significantly. 371 On the other hand, a Timestamps option may appear in any data or ACK 372 segment, adding 12 bytes to the 20-byte TCP header. We believe that 373 the bandwidth saved by reducing unnecessary retransmissions will more 374 than pay for the extra header bandwidth. 376 There is also an issue about the processing overhead for parsing the 377 variable byte-aligned format of options, particularly with a RISC- 378 architecture CPU. Appendix A contains a recommended layout of the 379 options in TCP headers to achieve reasonable data field alignment. 380 In the spirit of Header Prediction, a TCP can quickly test for this 381 layout and if it is verified then use a fast path. Hosts that use 382 this canonical layout will effectively use the options as a set of 383 fixed-format fields appended to the TCP header. However, to retain 384 the philosophical and protocol framework of TCP options, a TCP must 385 be prepared to parse an arbitrary options field, albeit with less 386 efficiency. 388 Finally, we observe that most of the mechanisms defined in this memo 389 are important for LFN's and/or very high-speed networks. For low- 390 speed networks, it might be a performance optimization to NOT use 391 these mechanisms. A TCP vendor concerned about optimal performance 392 over low-speed paths might consider turning these extensions off for 393 low-speed paths, or allow a user or installation manager to disable 394 them. 396 2. TCP Window Scale Option 398 2.1. Introduction 400 The window scale extension expands the definition of the TCP window 401 to 32 bits and then uses a scale factor to carry this 32-bit value in 402 the 16-bit Window field of the TCP header (SEG.WND in RFC 793). The 403 scale factor is carried in a new TCP option, Window Scale. This 404 option is sent only in a SYN segment (a segment with the SYN bit on), 405 hence the window scale is fixed in each direction when a connection 406 is opened. (Another design choice would be to specify the window 407 scale in every TCP segment. It would be incorrect to send a window 408 scale option only when the scale factor changed, since a TCP option 409 in an acknowledgement segment will not be delivered reliably (unless 410 the ACK happens to be piggy-backed on data in the other direction). 411 Fixing the scale when the connection is opened has the advantage of 412 lower overhead but the disadvantage that the scale factor cannot be 413 changed during the connection.) 415 The maximum receive window, and therefore the scale factor, is 416 determined by the maximum receive buffer space. In a typical modern 417 implementation, this maximum buffer space is set by default but can 418 be overridden by a user program before a TCP connection is opened. 419 This determines the scale factor, and therefore no new user interface 420 is needed for window scaling. 422 2.2. Window Scale Option 424 The three-byte Window Scale option may be sent in a SYN segment by a 425 TCP. It has two purposes: (1) indicate that the TCP is prepared to 426 do both send and receive window scaling, and (2) communicate a scale 427 factor to be applied to its receive window. Thus, a TCP that is 428 prepared to scale windows should send the option, even if its own 429 scale factor is 1. The scale factor is limited to a power of two and 430 encoded logarithmically, so it may be implemented by binary shift 431 operations. 433 TCP Window Scale Option (WSopt): 435 Kind: 3 437 Length: 3 bytes 439 +---------+---------+---------+ 440 | Kind=3 |Length=3 |shift.cnt| 441 +---------+---------+---------+ 443 This option is an offer, not a promise; both sides must send Window 444 Scale options in their SYN segments to enable window scaling in 445 either direction. If window scaling is enabled, then the TCP that 446 sent this option will right-shift its true receive-window values by 447 'shift.cnt' bits for transmission in SEG.WND. The value 'shift.cnt' 448 may be zero (offering to scale, while applying a scale factor of 1 to 449 the receive window). 451 This option may be sent in an initial segment (i.e., a segment 452 with the SYN bit on and the ACK bit off). It may also be sent in a 453 segment, but only if a Window Scale option was received in 454 the initial segment. A Window Scale option in a segment 455 without a SYN bit should be ignored. 457 The Window field in a SYN (i.e., a or ) segment itself 458 is never scaled. 460 2.3. Using the Window Scale Option 462 A model implementation of window scaling is as follows, using the 463 notation of [RFC0793]: 465 o All windows are treated as 32-bit quantities for storage in the 466 connection control block and for local calculations. This 467 includes the send-window (SND.WND) and the receive- window 468 (RCV.WND) values, as well as the congestion window. 470 o The connection state is augmented by two window shift counts, 471 Snd.Wind.Scale and Rcv.Wind.Scale, to be applied to the incoming 472 and outgoing window fields, respectively. 474 o If a TCP receives a segment containing a Window Scale 475 option, it sends its own Window Scale option in the 476 segment. 478 o The Window Scale option is sent with shift.cnt = R, where R is the 479 value that the TCP would like to use for its receive window. 481 o Upon receiving a SYN segment with a Window Scale option containing 482 shift.cnt = S, a TCP sets Snd.Wind.Scale to S and sets 483 Rcv.Wind.Scale to R; otherwise, it sets both Snd.Wind.Scale and 484 Rcv.Wind.Scale to zero. 486 o The window field (SEG.WND) in the header of every incoming 487 segment, with the exception of SYN segments, is left-shifted by 488 Snd.Wind.Scale bits before updating SND.WND: 490 SND.WND = SEG.WND << Snd.Wind.Scale 492 (assuming the other conditions of RFC 793 are met, and using the 493 "C" notation "<<" for left-shift). 495 o The window field (SEG.WND) of every outgoing segment, with the 496 exception of SYN segments, is right-shifted by Rcv.Wind.Scale 497 bits: 499 SND.WND = RCV.WND >> Rcv.Wind.Scale 501 TCP determines if a data segment is "old" or "new" by testing whether 502 its sequence number is within 2^31 bytes of the left edge of the 503 window, and if it is not, discarding the data as "old". To insure 504 that new data is never mistakenly considered old and vice- versa, the 505 left edge of the sender's window has to be at most 2^31 away from the 506 right edge of the receiver's window. Similarly with the sender's 507 right edge and receiver's left edge. Since the right and left edges 508 of either the sender's or receiver's window differ by the window 509 size, and since the sender and receiver windows can be out of phase 510 by at most the window size, the above constraints imply that 2 * the 511 max window size must be less than 2^31, or 513 max window < 2^30 515 Since the max window is 2^S (where S is the scaling shift count) 516 times at most 2^16 - 1 (the maximum unscaled window), the maximum 517 window is guaranteed to be < 2*30 if S <= 14. Thus, the shift count 518 must be limited to 14 (which allows windows of 2^30 = 1 Gbyte). If a 519 Window Scale option is received with a shift.cnt value exceeding 14, 520 the TCP should log the error but use 14 instead of the specified 521 value. 523 The scale factor applies only to the Window field as transmitted in 524 the TCP header; each TCP using extended windows will maintain the 525 window values locally as 32-bit numbers. For example, the 526 "congestion window" computed by Slow Start and Congestion Avoidance 527 is not affected by the scale factor, so window scaling will not 528 introduce quantization into the congestion window. 530 2.4. Addressing Window Retraction 532 When a non-zero scale factor is in use, there are instances when a 533 retracted window can be offered [Mathis08]. The end of the window 534 will be on a boundary based on the granularity of the scale factor 535 being used. If the sequence number is then updated by a number of 536 bytes smaller than that granularity, the TCP will have to either 537 advertise a new window that is beyond what it previously advertised 538 (and perhaps beyond the buffer), or will have to advertise a smaller 539 window, which will cause the TCP window to shrink. Implementations 540 should ensure that they handle a shrinking window, as specified in 541 section 4.2.2.16 of [RFC1122]. 543 For the receiver, this implies that: 545 1) The receiver MUST honor, as in-window, any segment that would 546 have been in-window for any ACK sent by the receiver. 548 2) When window scaling is in effect, the receiver SHOULD track the 549 actual maximum window sequence number (which is likely to be 550 greater than the window announced by the most recent ACK, if more 551 than one segment has arrived since the application consumed any 552 data in the receive buffer). 554 On the sender side: 556 3) The initial transmission MUST honor window on most recent ACK. 558 4) On first retransmission, or if it is out-of-window by less than 559 (2^Rcv.Wind.Scale) then do normal retransmission(s) without 560 regard to receiver window as long as the original segment was in 561 window when it was sent. 563 5) On subsequent retransmissions, treat it as zero window probes. 565 3. RTTM -- Round-Trip Time Measurement 567 3.1. Introduction 569 Accurate and current RTT estimates are necessary to adapt to changing 570 traffic conditions and to avoid an instability known as "congestion 571 collapse" [RFC0896] in a busy network. However, accurate measurement 572 of RTT may be difficult both in theory and in implementation. 574 Many TCP implementations base their RTT measurements upon a sample of 575 one packet per window or less. While this yields an adequate 576 approximation to the RTT for small windows, it results in an 577 unacceptably poor RTT estimate for an LFN. If we look at RTT 578 estimation as a signal processing problem (which it is), a data 579 signal at some frequency, the packet rate, is being sampled at a 580 lower frequency, the window rate. This lower sampling frequency 581 violates Nyquist's criteria and may therefore introduce "aliasing" 582 artifacts into the estimated RTT [Hamming77]. 584 A good RTT estimator with a conservative retransmission timeout 585 calculation can tolerate aliasing when the sampling frequency is 586 "close" to the data frequency. For example, with a window of 8 587 packets, the sample rate is 1/8 the data frequency -- less than an 588 order of magnitude different. However, when the window is tens or 589 hundreds of packets, the RTT estimator may be seriously in error, 590 resulting in spurious retransmissions. 592 If there are dropped packets, the problem becomes worse. Zhang 593 [Zhang86], Jain [Jain86] and Karn [Karn87] have shown that it is not 594 possible to accumulate reliable RTT estimates if retransmitted 595 segments are included in the estimate. Since a full window of data 596 will have been transmitted prior to a retransmission, all of the 597 segments in that window will have to be ACKed before the next RTT 598 sample can be taken. This means at least an additional window's 599 worth of time between RTT measurements and, as the error rate 600 approaches one per window of data (e.g., 10^-6 errors per bit for the 601 Wideband satellite network), it becomes effectively impossible to 602 obtain a valid RTT measurement. 604 A solution to these problems, which actually simplifies the sender 605 substantially, is as follows: using TCP options, the sender places a 606 timestamp in each data segment, and the receiver reflects these 607 timestamps back in ACK segments. Then a single subtract gives the 608 sender an accurate RTT measurement for every ACK segment (which will 609 correspond to every other data segment, with a sensible receiver). 610 We call this the RTTM (Round-Trip Time Measurement) mechanism. 612 It is vitally important to use the RTTM mechanism with big windows; 613 otherwise, the door is opened to some dangerous instabilities due to 614 aliasing. Furthermore, the option is probably useful for all TCP's, 615 since it simplifies the sender. 617 3.2. TCP Timestamps Option 619 TCP is a symmetric protocol, allowing data to be sent at any time in 620 either direction, and therefore timestamp echoing may occur in either 621 direction. For simplicity and symmetry, we specify that timestamps 622 always be sent and echoed in both directions. For efficiency, we 623 combine the timestamp and timestamp reply fields into a single TCP 624 Timestamps Option. 626 TCP Timestamps Option (TSopt): 628 Kind: 8 630 Length: 10 bytes 632 +-------+-------+---------------------+---------------------+ 633 |Kind=8 | 10 | TS Value (TSval) |TS Echo Reply (TSecr)| 634 +-------+-------+---------------------+---------------------+ 635 1 1 4 4 637 The Timestamps option carries two four-byte timestamp fields. The 638 Timestamp Value field (TSval) contains the current value of the 639 timestamp clock of the TCP sending the option. 641 The Timestamp Echo Reply field (TSecr) is valid if the ACK bit is set 642 in the TCP header; if it is valid, it echos a timestamp value that 643 was sent by the remote TCP in the TSval field of a Timestamps option. 644 When TSecr is not valid, its value must be zero. However, a value of 645 zero does not imply TSecr being invalid. The TSecr value will 646 generally be from the most recent Timestamp option that was received; 647 however, there are exceptions that are explained below. 649 A TCP may send the Timestamps option (TSopt) in an initial 650 segment (i.e., a segment containing a SYN bit and no ACK bit). Once 651 a TSopt has been sent or received in a non segment, it must be 652 sent in all segments. Once a TSopt has been received in a non 653 segment, then any successive segment that is received without the RST 654 bit and without a TSopt may be dropped without further processing, 655 and an ACK of the current SND.UNA generated. 657 In the case of crossing SYN packets where one SYN contains a TSopt 658 and the other doesn't, both sides should put a TSopt in the 659 segment. 661 3.3. The RTTM Mechanism 663 RTTM places a Timestamps option in every segment, with a TSval that 664 is obtained from a (virtual) "timestamp clock". Values of this clock 665 values must be at least approximately proportional to real time, in 666 order to measure actual RTT. 668 These TSval values are echoed in TSecr values in the reverse 669 direction. The difference between a received TSecr value and the 670 current timestamp clock value provides an RTT measurement. 672 When timestamps are used, every segment that is received will contain 673 a TSecr value; however, these values cannot all be used to update the 674 measured RTT. The following example illustrates why. It shows a 675 one-way data flow with segments arriving in sequence without loss. 676 Here A, B, C... represent data blocks occupying successive blocks of 677 sequence numbers, and ACK(A),... represent the corresponding 678 cumulative acknowledgments. The two timestamp fields of the 679 Timestamps option are shown symbolically as . Each 680 TSecr field contains the value most recently received in a TSval 681 field. 683 TCP A TCP B 685 ------> 687 <---- 689 ------> 691 <---- 693 . . . . . . . . . . . . . . . . . . . . . . 695 ------> 697 <---- 699 (etc) 701 The dotted line marks a pause (60 time units long) in which A had 702 nothing to send. Note that this pause inflates the RTT which B could 703 infer from receiving TSecr=131 in data segment C. Thus, in one-way 704 data flows, RTTM in the reverse direction measures a value that is 705 inflated by gaps in sending data. However, the following rule 706 prevents a resulting inflation of the measured RTT: 708 RTTM Rule: A TSecr value received in a segment is used to update 709 the averaged RTT measurement only if 711 a) the segment acknowledges some new data, i.e., only if it 712 advances the left edge of the send window, and 714 b) the segment does not indicate any loss or reordering, i.e. 715 contains SACK options 717 Since TCP B is not sending data, the data segment C does not 718 acknowledge any new data when it arrives at B. Thus, the inflated 719 RTTM measurement is not used to update B's RTTM measurement. 721 Implementors should note that with Timestamps multiple RTTMs can be 722 taken per RTT. Many RTO estimators have a weighting factor based on 723 an implicit assumption that at most one RTTM will be gotten per RTT. 724 When using multiple RTTMs per RTT to update the RTO estimator, the 725 weighting factor needs to be decreased to take into account the more 726 frequent RTTMs. For example, an implementation could choose to just 727 use one sample per RTT to update the RTO estimator, or or vary the 728 gain based on the congestion window, or take an average of all the 729 RTTM measurements received over one RTT, and then use that value to 730 update the RTO estimator. This document does not prescribe any 731 particular method for modifying the RTO estimator, the important 732 point is that the implementation should do something more than just 733 feeding additional RTTM samples from one RTT into the RTO estimator. 735 3.4. Which Timestamp to Echo 737 If more than one Timestamps option is received before a reply segment 738 is sent, the TCP must choose only one of the TSvals to echo, ignoring 739 the others. To minimize the state kept in the receiver (i.e., the 740 number of unprocessed TSvals), the receiver should be required to 741 retain at most one timestamp in the connection control block. 743 There are three situations to consider: 745 (A) Delayed ACKs. 747 Many TCP's acknowledge only every Kth segment out of a group of 748 segments arriving within a short time interval; this policy is 749 known generally as "delayed ACKs". The data-sender TCP must 750 measure the effective RTT, including the additional time due to 751 delayed ACKs, or else it will retransmit unnecessarily. Thus, 752 when delayed ACKs are in use, the receiver should reply with the 753 TSval field from the earliest unacknowledged segment. 755 (B) A hole in the sequence space (segment(s) have been lost). 757 The sender will continue sending until the window is filled, and 758 the receiver may be generating ACKs as these out-of-order 759 segments arrive (e.g., to aid "fast retransmit"). 761 The lost segment is probably a sign of congestion, and in that 762 situation the sender should be conservative about 763 retransmission. Furthermore, it is better to overestimate than 764 underestimate the RTT. An ACK for an out-of-order segment 765 should therefore contain the timestamp from the most recent 766 segment that advanced the window. 768 The same situation occurs if segments are re-ordered by the 769 network. 771 (C) A filled hole in the sequence space. 773 The segment that fills the hole represents the most recent 774 measurement of the network characteristics. On the other hand, 775 an RTT computed from an earlier segment would probably include 776 the sender's retransmit time-out, badly biasing the sender's 777 average RTT estimate. Thus, the timestamp from the latest 778 segment (which filled the hole) must be echoed. 780 An algorithm that covers all three cases is described in the 781 following rules for Timestamps option processing on a synchronized 782 connection: 784 (1) The connection state is augmented with two 32-bit slots: 786 TS.Recent holds a timestamp to be echoed in TSecr whenever a 787 segment is sent, and Last.ACK.sent holds the ACK field from the 788 last segment sent. Last.ACK.sent will equal RCV.NXT except when 789 ACKs have been delayed. 791 (2) If: 793 SEG.TSval >= TSrecent and SEG.SEQ <= Last.ACK.sent 795 then SEG.TSval is copied to TS.Recent; otherwise, it is ignored. 797 (3) When a TSopt is sent, its TSecr field is set to the current 798 TS.Recent value. 800 The following examples illustrate these rules. Here A, B, C... 801 represent data segments occupying successive blocks of sequence 802 numbers, and ACK(A),... represent the corresponding acknowledgment 803 segments. Note that ACK(A) has the same sequence number as B. We 804 show only one direction of timestamp echoing, for clarity. 806 o Packets arrive in sequence, and some of the ACKs are delayed. 808 By Case (A), the timestamp from the oldest unacknowledged segment 809 is echoed. 811 TS.Recent 812 -------------------> 813 1 814 -------------------> 815 1 816 -------------------> 817 1 819 <---- 820 (etc) 822 o Packets arrive out of order, and every packet is acknowledged. 824 By Case (B), the timestamp from the last segment that advanced the 825 left window edge is echoed, until the missing segment arrives; it 826 is echoed according to Case (C). The same sequence would occur if 827 segments B and D were lost and retransmitted.. 829 TS.Recent 830 -------------------> 831 1 832 <---- 833 1 834 -------------------> 835 1 836 <---- 837 1 838 -------------------> 839 2 840 <---- 841 2 842 -------------------> 843 2 844 <---- 845 2 846 -------------------> 847 4 848 <---- 849 (etc) 851 4. PAWS -- Protection Against Wrapped Sequence Numbers 853 4.1. Introduction 855 Section 4.2describes a simple mechanism to reject old duplicate 856 segments that might corrupt an open TCP connection; we call this 857 mechanism PAWS (Protection Against Wrapped Sequence numbers). PAWS 858 operates within a single TCP connection, using state that is saved in 859 the connection control block. Section 4.3 and Appendix C discuss the 860 implications of the PAWS mechanism for avoiding old duplicates from 861 previous incarnations of the same connection. 863 4.2. The PAWS Mechanism 865 PAWS uses the same TCP Timestamps option as the RTTM mechanism 866 described earlier, and assumes that every received TCP segment 867 (including data and ACK segments) contains a timestamp SEG.TSval 868 whose values are monotonically non-decreasing in time. The basic 869 idea is that a segment can be discarded as an old duplicate if it is 870 received with a timestamp SEG.TSval less than some timestamp recently 871 received on this connection. 873 In both the PAWS and the RTTM mechanism, the "timestamps" are 32-bit 874 unsigned integers in a modular 32-bit space. Thus, "less than" is 875 defined the same way it is for TCP sequence numbers, and the same 876 implementation techniques apply. If s and t are timestamp values, 878 s < t if 0 < (t - s) < 2^31, 880 computed in unsigned 32-bit arithmetic. 882 The choice of incoming timestamps to be saved for this comparison 883 must guarantee a value that is monotonically increasing. For 884 example, we might save the timestamp from the segment that last 885 advanced the left edge of the receive window, i.e., the most recent 886 in-sequence segment. Instead, we choose the value TS.Recent 887 introduced in Section 3.4 for the RTTM mechanism, since using a 888 common value for both PAWS and RTTM simplifies the implementation of 889 both. As Section 3.4 explained, TS.Recent differs from the timestamp 890 from the last in-sequence segment only in the case of delayed ACKs, 891 and therefore by less than one window. Either choice will therefore 892 protect against sequence number wrap-around. 894 RTTM was specified in a symmetrical manner, so that TSval timestamps 895 are carried in both data and ACK segments and are echoed in TSecr 896 fields carried in returning ACK or data segments. PAWS submits all 897 incoming segments to the same test, and therefore protects against 898 duplicate ACK segments as well as data segments. (An alternative 899 non-symmetric algorithm would protect against old duplicate ACKs: the 900 sender of data would reject incoming ACK segments whose TSecr values 901 were less than the TSecr saved from the last segment whose ACK field 902 advanced the left edge of the send window. This algorithm was deemed 903 to lack economy of mechanism and symmetry.) 905 TSval timestamps sent on >SYN< and >SYN,ACK< segments are used to 906 initialize PAWS. PAWS protects against old duplicate non-SYN 907 segments, and duplicate SYN segments received while there is a 908 synchronized connection. Duplicate >SYN< and >SYN,ACK< segments 909 received when there is no connection will be discarded by the normal 910 3-way handshake and sequence number checks of TCP. 912 RFC 1323 recommended that RST segments NOT carry timestamps, and that 913 they be acceptable regardless of their timestamp. At that time, the 914 thinking was that old duplicate RST segments should be exceedingly 915 unlikely, and their cleanup function should take precedence over 916 timestamps. More recently, discussion about various blind attacks on 917 TCP connections have raised the suggestion that if the Timestamps 918 option is present, SEG.TSecr could be used to provide stricter 919 acceptance tests for RST packets. While still under discussion, to 920 enable research into this area it is now recommended that when 921 generating a RST, that if the packet causing the RST to be generated 922 contained a Timestamps option that the RST also contain a Timestamps 923 option. In the RST segment, SEG.TSecr should be set to SEG.TSval 924 from the incoming packet and SEG.TSval should be set to zero. If a 925 RST is being generated because of a user abort, and Snd.TS.OK is set, 926 then a Timestamps option should be included in the RST. When a RST 927 packet is received, it must not be subjected to PAWS checks, and 928 information from the Timestamps option must not be use to update 929 connection state information. SEG.TSecr may be used to provide 930 stricter RST acceptance checks. 932 4.2.1. Basic PAWS Algorithm 934 The PAWS algorithm requires the following processing to be performed 935 on all incoming segments for a synchronized connection: 937 R1) If there is a Timestamps option in the arriving segment, 938 SEG.TSval < TS.Recent, TS.Recent is valid (see later discussion) 939 and the RST bit is not set, then treat the arriving segment as 940 not acceptable: 942 Send an acknowledgement in reply as specified in RFC 793 page 943 69 and drop the segment. 945 Note: it is necessary to send an ACK segment in order to 946 retain TCP's mechanisms for detecting and recovering from 947 half-open connections. For example, see Figure 10 of RFC 948 793. 950 R2) If the segment is outside the window, reject it (normal TCP 951 processing) 953 R3) If an arriving segment satisfies: SEG.SEQ <= Last.ACK.sent (see 954 Section 3.4), then record its timestamp in TS.Recent. 956 R4) If an arriving segment is in-sequence (i.e., at the left window 957 edge), then accept it normally. 959 R5) Otherwise, treat the segment as a normal in-window, out- of- 960 sequence TCP segment (e.g., queue it for later delivery to the 961 user). 963 Steps R2, R4, and R5 are the normal TCP processing steps specified by 964 RFC 793. 966 It is important to note that the timestamp is checked only when a 967 segment first arrives at the receiver, regardless of whether it is 968 in-sequence or it must be queued for later delivery. 970 Consider the following example. 972 Suppose the segment sequence: A.1, B.1, C.1, ..., Z.1 has been 973 sent, where the letter indicates the sequence number and the digit 974 represents the timestamp. Suppose also that segment B.1 has been 975 lost. The timestamp in TS.TStamp is 1 (from A.1), so C.1, ..., 976 Z.1 are considered acceptable and are queued. When B is 977 retransmitted as segment B.2 (using the latest timestamp), it 978 fills the hole and causes all the segments through Z to be 979 acknowledged and passed to the user. The timestamps of the queued 980 segments are *not* inspected again at this time, since they have 981 already been accepted. When B.2 is accepted, TS.Stamp is set to 982 2. 984 This rule allows reasonable performance under loss. A full window of 985 data is in transit at all times, and after a loss a full window less 986 one packet will show up out-of-sequence to be queued at the receiver 987 (e.g., up to ~2^30 bytes of data); the timestamp option must not 988 result in discarding this data. 990 In certain unlikely circumstances, the algorithm of rules R1-R5 could 991 lead to discarding some segments unnecessarily, as shown in the 992 following example: 994 Suppose again that segments: A.1, B.1, C.1, ..., Z.1 have been 995 sent in sequence and that segment B.1 has been lost. Furthermore, 996 suppose delivery of some of C.1, ... Z.1 is delayed until AFTER 997 the retransmission B.2 arrives at the receiver. These delayed 998 segments will be discarded unnecessarily when they do arrive, 999 since their timestamps are now out of date. 1001 This case is very unlikely to occur. If the retransmission was 1002 triggered by a timeout, some of the segments C.1, ... Z.1 must have 1003 been delayed longer than the RTO time. This is presumably an 1004 unlikely event, or there would be many spurious timeouts and 1005 retransmissions. If B's retransmission was triggered by the "fast 1006 retransmit" algorithm, i.e., by duplicate ACKs, then the queued 1007 segments that caused these ACKs must have been received already. 1009 Even if a segment were delayed past the RTO, the Fast Retransmit 1010 mechanism [Jacobson90c] will cause the delayed packets to be 1011 retransmitted at the same time as B.2, avoiding an extra RTT and 1012 therefore causing a very small performance penalty. 1014 We know of no case with a significant probability of occurrence in 1015 which timestamps will cause performance degradation by unnecessarily 1016 discarding segments. 1018 4.2.2. Timestamp Clock 1020 It is important to understand that the PAWS algorithm does not 1021 require clock synchronization between sender and receiver. The 1022 sender's timestamp clock is used to stamp the segments, and the 1023 sender uses the echoed timestamp to measure RTT's. However, the 1024 receiver treats the timestamp as simply a monotonically increasing 1025 serial number, without any necessary connection to its clock. From 1026 the receiver's viewpoint, the timestamp is acting as a logical 1027 extension of the high-order bits of the sequence number. 1029 The receiver algorithm does place some requirements on the frequency 1030 of the timestamp clock. 1032 (a) The timestamp clock must not be "too slow". 1034 It must tick at least once for each 2^31 bytes sent. In fact, 1035 in order to be useful to the sender for round trip timing, the 1036 clock should tick at least once per window's worth of data, and 1037 even with the window extension defined in Section 2.2, 2^31 1038 bytes must be at least two windows. 1040 To make this more quantitative, any clock faster than 1 tick/sec 1041 will reject old duplicate segments for link speeds of ~8 Gbps. 1042 A 1ms timestamp clock will work at link speeds up to 8 Tbps 1043 (8*10^12) bps! 1045 (b) The timestamp clock must not be "too fast". 1047 Its recycling time must be greater than MSL seconds. Since the 1048 clock (timestamp) is 32 bits and the worst-case MSL is 255 1049 seconds, the maximum acceptable clock frequency is one tick 1050 every 59 ns. 1052 However, it is desirable to establish a much longer recycle 1053 period, in order to handle outdated timestamps on idle 1054 connections (see Section 4.2.3), and to relax the MSL 1055 requirement for preventing sequence number wrap-around. With a 1056 1 ms timestamp clock, the 32-bit timestamp will wrap its sign 1057 bit in 24.8 days. Thus, it will reject old duplicates on the 1058 same connection if MSL is 24.8 days or less. This appears to be 1059 a very safe figure; an MSL of 24.8 days or longer can probably 1060 be assumed by the gateway system without requiring precise MSL 1061 enforcement by the TTL value in the IP layer. 1063 Based upon these considerations, we choose a timestamp clock 1064 frequency in the range 1 ms to 1 sec per tick. This range also 1065 matches the requirements of the RTTM mechanism, which does not need 1066 much more resolution than the granularity of the retransmit timer, 1067 e.g., tens or hundreds of milliseconds. 1069 The PAWS mechanism also puts a strong monotonicity requirement on the 1070 sender's timestamp clock. The method of implementation of the 1071 timestamp clock to meet this requirement depends upon the system 1072 hardware and software. 1074 o Some hosts have a hardware clock that is guaranteed to be 1075 monotonic between hardware resets. 1077 o A clock interrupt may be used to simply increment a binary integer 1078 by 1 periodically. 1080 o The timestamp clock may be derived from a system clock that is 1081 subject to being abruptly changed, by adding a variable offset 1082 value. This offset is initialized to zero. When a new timestamp 1083 clock value is needed, the offset can be adjusted as necessary to 1084 make the new value equal to or larger than the previous value 1085 (which was saved for this purpose). 1087 4.2.3. Outdated Timestamps 1089 If a connection remains idle long enough for the timestamp clock of 1090 the other TCP to wrap its sign bit, then the value saved in TS.Recent 1091 will become too old; as a result, the PAWS mechanism will cause all 1092 subsequent segments to be rejected, freezing the connection (until 1093 the timestamp clock wraps its sign bit again). 1095 With the chosen range of timestamp clock frequencies (1 sec to 1 ms), 1096 the time to wrap the sign bit will be between 24.8 days and 24800 1097 days. A TCP connection that is idle for more than 24 days and then 1098 comes to life is exceedingly unusual. However, it is undesirable in 1099 principle to place any limitation on TCP connection lifetimes. 1101 We therefore require that an implementation of PAWS include a 1102 mechanism to "invalidate" the TS.Recent value when a connection is 1103 idle for more than 24 days. (An alternative solution to the problem 1104 of outdated timestamps would be to send keep-alive segments at a very 1105 low rate, but still more often than the wrap-around time for 1106 timestamps, e.g., once a day. This would impose negligible overhead. 1107 However, the TCP specification has never included keep-alives, so the 1108 solution based upon invalidation was chosen.) 1110 Note that a TCP does not know the frequency, and therefore, the 1111 wraparound time, of the other TCP, so it must assume the worst. The 1112 validity of TS.Recent needs to be checked only if the basic PAWS 1113 timestamp check fails, i.e., only if SEG.TSval < TS.Recent. If 1114 TS.Recent is found to be invalid, then the segment is accepted, 1115 regardless of the failure of the timestamp check, and rule R3 updates 1116 TS.Recent with the TSval from the new segment. 1118 To detect how long the connection has been idle, the TCP may update a 1119 clock or timestamp value associated with the connection whenever 1120 TS.Recent is updated, for example. The details will be 1121 implementation-dependent. 1123 4.2.4. Header Prediction 1125 "Header prediction" [Jacobson90a] is a high-performance transport 1126 protocol implementation technique that is most important for high- 1127 speed links. This technique optimizes the code for the most common 1128 case, receiving a segment correctly and in order. Using header 1129 prediction, the receiver asks the question, "Is this segment the next 1130 in sequence?" This question can be answered in fewer machine 1131 instructions than the question, "Is this segment within the window?" 1133 Adding header prediction to our timestamp procedure leads to the 1134 following recommended sequence for processing an arriving TCP 1135 segment: 1137 H1) Check timestamp (same as step R1 above) 1139 H2) Do header prediction: if segment is next in sequence and if 1140 there are no special conditions requiring additional processing, 1141 accept the segment, record its timestamp, and skip H3. 1143 H3) Process the segment normally, as specified in RFC 793. This 1144 includes dropping segments that are outside the window and 1145 possibly sending acknowledgments, and queueing in-window, out- 1146 of-sequence segments. 1148 Another possibility would be to interchange steps H1 and H2, i.e., to 1149 perform the header prediction step H2 FIRST, and perform H1 and H3 1150 only when header prediction fails. This could be a performance 1151 improvement, since the timestamp check in step H1 is very unlikely to 1152 fail, and it requires unsigned modulo arithmetic, a relatively 1153 expensive operation. To perform this check on every single segment 1154 is contrary to the philosophy of header prediction. We believe that 1155 this change might produce a measurable reduction in CPU time for TCP 1156 protocol processing on high-speed networks. 1158 However, putting H2 first would create a hazard: a segment from 2^32 1159 bytes in the past might arrive at exactly the wrong time and be 1160 accepted mistakenly by the header-prediction step. The following 1161 reasoning has been introduced in [RFC1185] to show that the 1162 probability of this failure is negligible. 1164 If all segments are equally likely to show up as old duplicates, 1165 then the probability of an old duplicate exactly matching the left 1166 window edge is the maximum segment size (MSS) divided by the size 1167 of the sequence space. This ratio must be less than 2^-16, since 1168 MSS must be < 2^16; for example, it will be (2^12)/(2^32) = 2^-20 1169 for a FDDI link. However, the older a segment is, the less likely 1170 it is to be retained in the Internet, and under any reasonable 1171 model of segment lifetime the probability of an old duplicate 1172 exactly at the left window edge must be much smaller than 2^-16. 1174 The 16 bit TCP checksum also allows a basic unreliability of one 1175 part in 2^16. A protocol mechanism whose reliability exceeds the 1176 reliability of the TCP checksum should be considered "good 1177 enough", i.e., it won't contribute significantly to the overall 1178 error rate. We therefore believe we can ignore the problem of an 1179 old duplicate being accepted by doing header prediction before 1180 checking the timestamp. 1182 However, this probabilistic argument is not universally accepted, and 1183 the consensus at present is that the performance gain does not 1184 justify the hazard in the general case. It is therefore recommended 1185 that H2 follow H1. 1187 4.2.5. IP Fragmentation 1189 At high data rates, the protection against old packets provided by 1190 PAWS can be circumvented by errors in IP fragment reassembly (see 1191 [RFC4963]). The only way to protect against incorrect IP fragment 1192 reassembly is to not allow the packets to be fragmented. This is 1193 done by setting the Don't Fragment (DF) bit in the IP header. 1194 Setting the DF bit implies the use of Path MTU Discovery as described 1195 in [RFC1191], thus any TCP implementation that implements PAWS must 1196 also implement Path MTU Discovery. 1198 4.3. Duplicates from Earlier Incarnations of Connection 1200 The PAWS mechanism protects against errors due to sequence number 1201 wrap-around on high-speed connection. Segments from an earlier 1202 incarnation of the same connection are also a potential cause of old 1203 duplicate errors. In both cases, the TCP mechanisms to prevent such 1204 errors depend upon the enforcement of a maximum segment lifetime 1205 (MSL) by the Internet (IP) layer (see Appendix of RFC 1185 for a 1206 detailed discussion). Unlike the case of sequence space wrap-around, 1207 the MSL required to prevent old duplicate errors from earlier 1208 incarnations does not depend upon the transfer rate. If the IP layer 1209 enforces the recommended 2 minute MSL of TCP, and if the TCP rules 1210 are followed, TCP connections will be safe from earlier incarnations, 1211 no matter how high the network speed. Thus, the PAWS mechanism is 1212 not required for this case. 1214 We may still ask whether the PAWS mechanism can provide additional 1215 security against old duplicates from earlier connections, allowing us 1216 to relax the enforcement of MSL by the IP layer. Appendix B explores 1217 this question, showing that further assumptions and/or mechanisms are 1218 required, beyond those of PAWS. This is not part of the current 1219 extension. 1221 5. Conclusions and Acknowledgements 1223 This memo presented a set of extensions to TCP to provide efficient 1224 operation over large-bandwidth*delay-product paths and reliable 1225 operation over very high-speed paths. These extensions are designed 1226 to provide compatible interworking with TCP's that do not implement 1227 the extensions. 1229 These mechanisms are implemented using new TCP options for scaled 1230 windows and timestamps. The timestamps are used for two distinct 1231 mechanisms: RTTM (Round Trip Time Measurement) and PAWS (Protect 1232 Against Wrapped Sequences). 1234 The Window Scale option was originally suggested by Mike St. Johns of 1235 USAF/DCA. The present form of the option was suggested by Mike 1236 Karels of UC Berkeley in response to a more cumbersome scheme defined 1237 by Van Jacobson. Lixia Zhang helped formulate the PAWS mechanism 1238 description in RFC 1185. 1240 Finally, much of this work originated as the result of discussions 1241 within the End-to-End Task Force on the theoretical limitations of 1242 transport protocols in general and TCP in particular. Task force 1243 members and other on the end2end-interest list have made valuable 1244 contributions by pointing out flaws in the algorithms and the 1245 documentation. Continued discussion and development since the 1246 publication of RFC 1323 originally occurred in the IETF TCP Large 1247 Windows Working Group, later on in the End-to-End Task Force, and 1248 most recently in the IETF TCP Maintenance Working Group. The authors 1249 are grateful for all these contributions. 1251 6. Security Considerations 1253 The TCP sequence space is a fixed size, and as the window becomes 1254 larger it becomes easier for an attacker to generate forged packets 1255 that can fall within the TCP window, and be accepted as valid 1256 packets. While use of Timestamps and PAWS can help to mitigate this, 1257 when using PAWS, if an attacker is able to forge a packet that is 1258 acceptable to the TCP connection, a timestamp that is in the future 1259 would cause valid packets to be dropped due to PAWS checks. Hence, 1260 implementors should take care to not open the TCP window drastically 1261 beyond the requirements of the connection. 1263 Middle boxes and options If a middle box removes TCP options from the 1264 SYN, such as TSopt, a high speed connection that needs PAWS would not 1265 have that protection. In this situation, an implementor could 1266 provide a mechanism for the application to determine whether or not 1267 PAWS is in use on the connection, and chose to terminate the 1268 connection if that protection doesn't exist. 1270 Mechanisms to protect the TCP header from modification should also 1271 protect the TCP options. 1273 Expanding the TCP window beyond 64K for IPv6 allows Jumbograms 1274 [RFC2675] to be used when the local network supports packets larger 1275 than 64K. When larger TCP packets are used, the TCP checksum becomes 1276 weaker. 1278 7. IANA Considerations 1280 This document has no actions for IANA. 1282 8. References 1284 8.1. Normative References 1286 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7, 1287 RFC 793, September 1981. 1289 [RFC1191] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 1290 November 1990. 1292 8.2. Informative References 1294 [Garlick77] 1295 Garlick, L., Rom, R., and J. Postel, "Issues in Reliable 1296 Host-to-Host Protocols", Proc. Second Berkeley Workshop on 1297 Distributed Data Management and Computer Networks , 1298 May 1977, . 1300 [Hamming77] 1301 Hamming, R., "Digital Filters", Prentice Hall, Englewood 1302 Cliffs, N.J. ISBN 0-13-212571-4, 1977. 1304 [Jacobson88a] 1305 Jacobson, V., "Congestion Avoidance and Control", SIGCOMM 1306 '88, Stanford, CA. , August 1988, 1307 . 1309 [Jacobson90a] 1310 Jacobson, V., "4BSD Header Prediction", ACM Computer 1311 Communication Review , April 1990. 1313 [Jacobson90c] 1314 Jacobson, V., "Modified TCP congestion avoidance 1315 algorithm", Message to end2end-interest mailing list , 1316 April 1990, 1317 . 1319 [Jain86] Jain, R., "Divergence of Timeout Algorithms for Packet 1320 Retransmissions", Proc. Fifth Phoenix Conf. on Comp. and 1321 Comm., Scottsdale, Arizona , March 1986, 1322 . 1324 [Karn87] Karn, P. and C. Partridge, "Estimating Round-Trip Times in 1325 Reliable Transport Protocols", Proc. SIGCOMM '87 , 1326 August 1987. 1328 [Martin03] 1329 Martin, D., "[Tsvwg] RFC 1323.bis", Message to the tsvwg 1330 mailing list , September 2003, . 1333 [Mathis08] 1334 Mathis, M., "[tcpm] Example of 1323 window retraction 1335 problemPer my comments at the microphone at TCPM...", 1336 Message to the tcpm mailing list , March 2008, . 1339 [RFC0896] Nagle, J., "Congestion control in IP/TCP internetworks", 1340 RFC 896, January 1984. 1342 [RFC1072] Jacobson, V. and R. Braden, "TCP extensions for long-delay 1343 paths", RFC 1072, October 1988. 1345 [RFC1110] McKenzie, A., "Problem with the TCP big window option", 1346 RFC 1110, August 1989. 1348 [RFC1122] Braden, R., "Requirements for Internet Hosts - 1349 Communication Layers", STD 3, RFC 1122, October 1989. 1351 [RFC1185] Jacobson, V., Braden, B., and L. Zhang, "TCP Extension for 1352 High-Speed Paths", RFC 1185, October 1990. 1354 [RFC1323] Jacobson, V., Braden, B., and D. Borman, "TCP Extensions 1355 for High Performance", RFC 1323, May 1992. 1357 [RFC2018] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 1358 Selective Acknowledgment Options", RFC 2018, October 1996. 1360 [RFC2581] Allman, M., Paxson, V., and W. Stevens, "TCP Congestion 1361 Control", RFC 2581, April 1999. 1363 [RFC2675] Borman, D., Deering, S., and R. Hinden, "IPv6 Jumbograms", 1364 RFC 2675, August 1999. 1366 [RFC2883] Floyd, S., Mahdavi, J., Mathis, M., and M. Podolsky, "An 1367 Extension to the Selective Acknowledgement (SACK) Option 1368 for TCP", RFC 2883, July 2000. 1370 [RFC3517] Blanton, E., Allman, M., Fall, K., and L. Wang, "A 1371 Conservative Selective Acknowledgment (SACK)-based Loss 1372 Recovery Algorithm for TCP", RFC 3517, April 2003. 1374 [RFC4963] Heffner, J., Mathis, M., and B. Chandler, "IPv4 Reassembly 1375 Errors at High Data Rates", RFC 4963, July 2007. 1377 [RFC5681] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 1378 Control", RFC 5681, September 2009. 1380 [Watson81] 1381 Watson, R., "Timer-based Mechanisms in Reliable Transport 1382 Protocol Connection Management", Computer Networks, Vol. 1383 5 , 1981. 1385 [Zhang86] Zhang, L., "Why TCP Timers Don't Work Well", Proc. SIGCOMM 1386 '86, Stowe, VT , August 1986. 1388 Appendix A. Implementation Suggestions 1390 TCP Option Layout 1392 The following layouts are recommended for sending options on non- 1393 SYN segments, to achieve maximum feasible alignment of 32-bit and 1394 64-bit machines. 1396 +--------+--------+--------+--------+ 1397 | NOP | NOP | TSopt | 10 | 1398 +--------+--------+--------+--------+ 1399 | TSval timestamp | 1400 +--------+--------+--------+--------+ 1401 | TSecr timestamp | 1402 +--------+--------+--------+--------+ 1404 Interaction with the TCP Urgent Pointer 1406 The TCP Urgent pointer, like the TCP window, is a 16 bit value. 1407 Some of the original discussion for the TCP Window Scale option 1408 included proposals to increase the Urgent pointer to 32 bits. As 1409 it turns out, this is unnecessary. There are two observations 1410 that should be made: 1412 (1) With IP Version 4, the largest amount of TCP data that can be 1413 sent in a single packet is 65495 bytes (64K - 1 - size of 1414 fixed IP and TCP headers). 1416 (2) Updates to the urgent pointer while the user is in "urgent 1417 mode" are invisible to the user. 1419 This means that if the Urgent Pointer points beyond the end of the 1420 TCP data in the current packet, then the user will remain in 1421 urgent mode until the next TCP packet arrives. That packet will 1422 update the urgent pointer to a new offset, and the user will never 1423 have left urgent mode. 1425 Thus, to properly implement the Urgent Pointer, the sending TCP 1426 only has to check for overflow of the 16 bit Urgent Pointer field 1427 before filling it in. If it does overflow, than a value of 65535 1428 should be inserted into the Urgent Pointer. 1430 The same technique applies to IP Version 6, except in the case of 1431 IPv6 Jumbograms. When IPv6 Jumbograms are supported, [RFC2675] 1432 requires additional steps for dealing with the Urgent Pointer, 1433 these are described in section 5.2 of [RFC2675]. 1435 Appendix B. Duplicates from Earlier Connection Incarnations 1437 There are two cases to be considered: (1) a system crashing (and 1438 losing connection state) and restarting, and (2) the same connection 1439 being closed and reopened without a loss of host state. These will 1440 be described in the following two sections. 1442 B.1. System Crash with Loss of State 1444 TCP's quiet time of one MSL upon system startup handles the loss of 1445 connection state in a system crash/restart. For an explanation, see 1446 for example "When to Keep Quiet" in the TCP protocol specification 1447 [RFC0793]. The MSL that is required here does not depend upon the 1448 transfer speed. The current TCP MSL of 2 minutes seems acceptable as 1449 an operational compromise, as many host systems take this long to 1450 boot after a crash. 1452 However, the timestamp option may be used to ease the MSL 1453 requirements (or to provide additional security against data 1454 corruption). If timestamps are being used and if the timestamp clock 1455 can be guaranteed to be monotonic over a system crash/restart, i.e., 1456 if the first value of the sender's timestamp clock after a crash/ 1457 restart can be guaranteed to be greater than the last value before 1458 the restart, then a quiet time will be unnecessary. 1460 To dispense totally with the quiet time would require that the host 1461 clock be synchronized to a time source that is stable over the crash/ 1462 restart period, with an accuracy of one timestamp clock tick or 1463 better. We can back off from this strict requirement to take 1464 advantage of approximate clock synchronization. Suppose that the 1465 clock is always re-synchronized to within N timestamp clock ticks and 1466 that booting (extended with a quiet time, if necessary) takes more 1467 than N ticks. This will guarantee monotonicity of the timestamps, 1468 which can then be used to reject old duplicates even without an 1469 enforced MSL. 1471 B.2. Closing and Reopening a Connection 1473 When a TCP connection is closed, a delay of 2*MSL in TIME-WAIT state 1474 ties up the socket pair for 4 minutes (see Section 3.5 of [RFC0793]. 1475 Applications built upon TCP that close one connection and open a new 1476 one (e.g., an FTP data transfer connection using Stream mode) must 1477 choose a new socket pair each time. The TIME- WAIT delay serves two 1478 different purposes: 1480 (a) Implement the full-duplex reliable close handshake of TCP. 1482 The proper time to delay the final close step is not really 1483 related to the MSL; it depends instead upon the RTO for the FIN 1484 segments and therefore upon the RTT of the path. (It could be 1485 argued that the side that is sending a FIN knows what degree of 1486 reliability it needs, and therefore it should be able to 1487 determine the length of the TIME-WAIT delay for the FIN's 1488 recipient. This could be accomplished with an appropriate TCP 1489 option in FIN segments.) 1491 Although there is no formal upper-bound on RTT, common network 1492 engineering practice makes an RTT greater than 1 minute very 1493 unlikely. Thus, the 4 minute delay in TIME-WAIT state works 1494 satisfactorily to provide a reliable full-duplex TCP close. 1495 Note again that this is independent of MSL enforcement and 1496 network speed. 1498 The TIME-WAIT state could cause an indirect performance problem 1499 if an application needed to repeatedly close one connection and 1500 open another at a very high frequency, since the number of 1501 available TCP ports on a host is less than 2^16. However, high 1502 network speeds are not the major contributor to this problem; 1503 the RTT is the limiting factor in how quickly connections can be 1504 opened and closed. Therefore, this problem will be no worse at 1505 high transfer speeds. 1507 (b) Allow old duplicate segments to expire. 1509 To replace this function of TIME-WAIT state, a mechanism would 1510 have to operate across connections. PAWS is defined strictly 1511 within a single connection; the last timestamp (TS.Recent) is 1512 kept in the connection control block, and discarded when a 1513 connection is closed. 1515 An additional mechanism could be added to the TCP, a per-host 1516 cache of the last timestamp received from any connection. This 1517 value could then be used in the PAWS mechanism to reject old 1518 duplicate segments from earlier incarnations of the connection, 1519 if the timestamp clock can be guaranteed to have ticked at least 1520 once since the old connection was open. This would require that 1521 the TIME-WAIT delay plus the RTT together must be at least one 1522 tick of the sender's timestamp clock. Such an extension is not 1523 part of the proposal of this RFC. 1525 Note that this is a variant on the mechanism proposed by 1526 Garlick, Rom, and Postel [Garlick77], which required each host 1527 to maintain connection records containing the highest sequence 1528 numbers on every connection. Using timestamps instead, it is 1529 only necessary to keep one quantity per remote host, regardless 1530 of the number of simultaneous connections to that host. 1532 Appendix C. Changes from RFC 1072, RFC 1185, and RFC 1323 1534 The protocol extensions defined in RFC 1323 document differ in 1535 several important ways from those defined in RFC 1072 and RFC 1185. 1537 (a) SACK has been split off into a separate document, [RFC2018]. 1539 (b) The detailed rules for sending timestamp replies (see 1540 Section 3.4) differ in important ways. The earlier rules could 1541 result in an under-estimate of the RTT in certain cases (packets 1542 dropped or out of order). 1544 (c) The same value TS.Recent is now shared by the two distinct 1545 mechanisms RTTM and PAWS. This simplification became possible 1546 because of change (b). 1548 (d) An ambiguity in RFC 1185 was resolved in favor of putting 1549 timestamps on ACK as well as data segments. This supports the 1550 symmetry of the underlying TCP protocol. 1552 (e) The echo and echo reply options of RFC 1072 were combined into a 1553 single Timestamps option, to reflect the symmetry and to 1554 simplify processing. 1556 (f) The problem of outdated timestamps on long-idle connections, 1557 discussed in Section 4.2.2, was realized and resolved. 1559 (g) RFC 1185 recommended that header prediction take precedence over 1560 the timestamp check. Based upon some skepticism about the 1561 probabilistic arguments given in Section 4.2.4, it was decided 1562 to recommend that the timestamp check be performed first. 1564 (h) The spec was modified so that the extended options will be sent 1565 on segments only when they are received in the 1566 corresponding segments. This provides the most 1567 conservative possible conditions for interoperation with 1568 implementations without the extensions. 1570 In addition to these substantive changes, the present RFC attempts to 1571 specify the algorithms unambiguously by presenting modifications to 1572 the Event Processing rules of RFC 793; see Appendix F. 1574 There are additional changes in this document from RFC 1323. These 1575 changes are: 1577 (a) The description of which TSecr values can be used to update the 1578 measured RTT has been clarified. Specifically, with Timestamps, 1579 the Karn algorithm [Karn87] is disabled. The Karn algorithm 1580 disables all RTT measurements during retransmission, since it is 1581 ambiguous whether the ACK is is for the original packet, or the 1582 retransmitted packet. With Timestamps, that ambiguity is 1583 removed since the TSecr in the ACK will contain the TSval from 1584 whichever data packet made it to the destination. 1586 (b) In RFC1323, section 3.4, step (2) of the algorithm to control 1587 which timestamp is echoed was incorrect in two regards: 1589 (1) It failed to update TSrecent for a retransmitted segment 1590 that resulted from a lost ACK. 1592 (2) It failed if SEG.LEN = 0. 1594 In the new algorithm, the case of SEG.TSval = TSrecent is 1595 included for consistency with the PAWS test. 1597 (c) One correction was made to the Event Processing Summary in 1598 Appendix F. In SEND CALL/ESTABLISHED STATE, RCV.WND is used to 1599 fill in the SEG.WND value, not SND.WND. 1601 (d) New pseudo-code summary has been added in Appendix E. 1603 (e) Appendix A has been expanded with information about the TCP MSS 1604 option and the TCP Urgent Pointer. 1606 (f) It is now recommended that Timestamps options be included in RST 1607 packets if the incoming packet contained a Timestamps option. 1609 (g) RST packets are explicitly excluded from PAWS processing. 1611 (h) Snd.TSoffset and Snd.TSclock variables have been added. 1612 Snd.TSclock is the sum of my.TSclock and Snd.TSoffset. This 1613 allows the starting points for timestamps to be randomized on a 1614 per-connection basis. Setting Snd.TSoffset to zero yields the 1615 same results as [RFC1323]. 1617 (i) RTTM update processing explicitly excludes packets containing 1618 SACK options. This addresses inflation of the RTT during 1619 episodes of packet loss in both directions. 1621 (j) In Section 3.2 the if-clause allowing sending of timestamps only 1622 when received in a or was removed, to allow for 1623 late timestamp negotiation. 1625 (k) Section 2.4 was added describing the unavoidable window 1626 retraction issue, and explicitly describing the mitigation steps 1627 necessary. 1629 Appendix D. Summary of Notation 1631 The following notation has been used in this document. 1633 Options 1635 WSopt: TCP Window Scale Option 1636 TSopt: TCP Timestamps Option 1638 Option Fields 1640 shift.cnt: Window scale byte in WSopt 1641 TSval: 32-bit Timestamp Value field in TSopt 1642 TSecr: 32-bit Timestamp Reply field in TSopt 1644 Option Fields in Current Segment 1646 SEG.TSval: TSval field from TSopt in current segment 1647 SEG.TSecr: TSecr field from TSopt in current segment 1648 SEG.WSopt: 8-bit value in WSopt 1650 Clock Values 1652 my.TSclock: System wide source of 32-bit timestamp values 1653 my.TSclock.rate: Period of my.TSclock (1 ms to 1 sec) 1654 Snd.TSoffset: A offset for randomizing Snd.TSclock 1655 Snd.TSclock: my.TSclock + Snd.TSoffset 1657 Per-Connection State Variables 1659 TS.Recent: Latest received Timestamp 1660 Last.ACK.sent: Last ACK field sent 1661 Snd.TS.OK: 1-bit flag 1662 Snd.WS.OK: 1-bit flag 1663 Rcv.Wind.Scale: Receive window scale power 1664 Snd.Wind.Scale: Send window scale power 1665 Start.Time: Snd.TSclock value when segment being timed was 1666 sent (used by pre-1323 code). 1668 Procedure 1670 Update_SRTT(m) Procedure to update the smoothed RTT and RTT 1671 variance estimates, using the rules of 1672 [Jacobson88a], given m, a new RTT measurement 1674 Appendix E. Pseudo-code Summary 1676 Create new TCB => { 1677 Rcv.wind.scale = 1678 MIN( 14, MAX(0, floor(log2(receive buffer space)) - 15) ); 1679 Snd.wind.scale = 0; 1680 Last.ACK.sent = 0; 1681 Snd.TS.OK = Snd.WS.OK = FALSE; 1682 Snd.TSoffset = random 32 bit value 1683 } 1685 Send initial segment => { 1686 SEG.WND = MIN( RCV.WND, 65535 ); 1687 Include in segment: TSopt(TSval=Snd.TSclock, TCecr=0); 1688 Include in segment: WSopt = Rcv.wind.scale; 1689 } 1691 Send segment => { 1692 SEG.ACK = Last.ACK.sent = RCV.NXT; 1693 SEG.WND = MIN( RCV.WND, 65535 ); 1694 if (Snd.TS.OK) then 1695 Include in segment: 1696 TSopt(TSval=Snd.TSclock, TSecr=TS.Recent); 1697 if (Snd.WS.OK) then 1698 Include in segment: WSopt = Rcv.wind.scale; 1699 } 1701 Receive or segment => { 1702 if (Segment contains TSopt) then { 1703 TS.Recent = SEG.TSval; 1704 Snd.TS.OK = TRUE; 1705 if (is segment) then 1706 Update_SRTT( 1707 (Snd.TSclock - SEG.TSecr)/my.TSclock.rate); 1708 } 1709 if (Segment contains WSopt) then { 1710 Snd.wind.scale = SEG.WSopt; 1711 Snd.WS.OK = TRUE; 1712 if (the ACK bit is not set, and Rcv.wind.scale has not been 1713 initialized by the user) then 1714 Rcv.wind.scale = Snd.wind.scale; 1715 } 1716 else 1717 Rcv.wind.scale = Snd.wind.scale = 0; 1718 } 1720 Send non-SYN segment => { 1721 SEG.ACK = Last.ACK.sent = RCV.NXT; 1722 SEG.WND = MIN( RCV.WND >> Rcv.wind.scale, 65535 ); 1723 if (Snd.TS.OK) then 1724 Include in segment: 1725 TSopt(TSval=Snd.TSclock, TSecr=TS.Recent); 1726 } 1728 Receive non-SYN segment in (state >= ESTABLISHED) => { 1729 Window = (SEG.WND << Snd.wind.scale); 1730 /* Use 32-bit 'Window' instead of 16-bit 'SEG.WND' 1731 * in rest of processing. 1732 */ 1733 if (Segment contains TSopt) then { 1734 if (SEG.TSval < TS.Recent && Idle less than 24 days) then { 1735 if (Send.TS.OK AND (NOT RST) ) then { 1736 /* Timestamp too old => 1737 * segment is unacceptable. 1738 */ 1739 Send ACK segment; 1740 Discard segment and return; 1741 } 1742 } 1743 else { 1744 if (SEG.SEQ =< Last.ACK.sent) then 1745 TS.Recent = SEG.TSval; 1746 } 1747 } 1748 if (SEG.ACK > SND.UNA) then { 1749 /* (At least part of) first segment in 1750 * retransmission queue has been ACKd 1751 */ 1752 if (Segment contains TSopt) then 1753 Update_SRTT( 1754 (Snd.TSclock - SEG.TSecr)/my.TSclock.rate); 1755 else 1756 Update_SRTT( /* for compatibility */ 1757 (Snd.TSclock - Start.Time)/my.TSclock.rate); 1759 } 1760 } 1762 Appendix F. Event Processing Summary 1764 OPEN Call 1766 ... 1768 An initial send sequence number (ISS) is selected. Send a SYN 1769 segment of the form: 1771 1773 ... 1775 SEND Call 1777 CLOSED STATE (i.e., TCB does not exist) 1779 ... 1781 LISTEN STATE 1783 If the foreign socket is specified, then change the connection 1784 from passive to active, select an ISS. Send a SYN segment 1785 containing the options: and 1786 . Set SND.UNA to ISS, SND.NXT to ISS+1. 1787 Enter SYN-SENT state. ... 1789 SYN-SENT STATE 1790 SYN-RECEIVED STATE 1792 ... 1794 ESTABLISHED STATE 1795 CLOSE-WAIT STATE 1797 Segmentize the buffer and send it with a piggybacked 1798 acknowledgment (acknowledgment value = RCV.NXT). ... 1800 If the urgent flag is set ... 1802 If the Snd.TS.OK flag is set, then include the TCP Timestamps 1803 option in each data 1804 segment. 1806 Scale the receive window for transmission in the segment 1807 header: 1809 SEG.WND = (RCV.WND >> Rcv.Wind.Scale). 1811 SEGMENT ARRIVES 1813 ... 1815 If the state is LISTEN then 1817 first check for an RST 1819 ... 1821 second check for an ACK 1823 ... 1825 third check for a SYN 1827 if the SYN bit is set, check the security. If the ... 1829 ... 1831 if the SEG.PRC is less than the TCB.PRC then continue. 1833 Check for a Window Scale option (WSopt); if one is found, 1834 save SEG.WSopt in Snd.Wind.Scale and set Snd.WS.OK flag on. 1835 Otherwise, set both Snd.Wind.Scale and Rcv.Wind.Scale to 1836 zero and clear Snd.WS.OK flag. 1838 Check for a TSopt option; if one is found, save SEG.TSval in 1839 the variable TS.Recent and turn on the Snd.TS.OK bit. 1841 Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any 1842 other control or text should be queued for processing later. 1843 ISS should be selected and a SYN segment sent of the form: 1845 1847 If the Snd.WS.OK bit is on, include a WSopt option 1848 in this segment. If the Snd.TS.OK 1849 bit is on, include a TSopt 1850 in this segment. 1851 Last.ACK.sent is set to RCV.NXT. 1853 SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 1854 state should be changed to SYN-RECEIVED. Note that any 1855 other incoming control or data (combined with SYN) will be 1856 processed in the SYN-RECEIVED state, but processing of SYN 1857 and ACK should not be repeated. If the listen was not fully 1858 specified (i.e., the foreign socket was not fully 1859 specified), then the unspecified fields should be filled in 1860 now. 1862 fourth other text or control 1864 ... 1866 If the state is SYN-SENT then 1868 first check the ACK bit 1870 ... 1872 ... 1874 fourth check the SYN bit 1876 ... 1878 If the SYN bit is on and the security/compartment and 1879 precedence are acceptable then, RCV.NXT is set to SEG.SEQ+1, 1880 IRS is set to SEG.SEQ, and any acknowledgements on the 1881 retransmission queue which are thereby acknowledged should 1882 be removed. 1884 Check for a Window Scale option (WSopt); if it is found, 1885 save SEG.WSopt in Snd.Wind.Scale; otherwise, set both 1886 Snd.Wind.Scale and Rcv.Wind.Scale to zero. 1888 Check for a TSopt option; if one is found, save SEG.TSval in 1889 variable TS.Recent and turn on the Snd.TS.OK bit in the 1890 connection control block. If the ACK bit is set, use 1891 Snd.TSclock - SEG.TSecr as the initial RTT estimate. 1893 If SND.UNA > ISS (our SYN has been ACKed), change the 1894 connection state to ESTABLISHED, form an ACK segment: 1896 1898 and send it. If the Snd.Echo.OK bit is on, include a TSopt 1899 option in this ACK 1900 segment. Last.ACK.sent is set to RCV.NXT. 1902 Data or controls which were queued for transmission may be 1903 included. If there are other controls or text in the 1904 segment then continue processing at the sixth step below 1905 where the URG bit is checked, otherwise return. 1907 Otherwise enter SYN-RECEIVED, form a SYN,ACK segment: 1909 1911 and send it. If the Snd.Echo.OK bit is on, include a TSopt 1912 option in this segment. 1913 If the Snd.WS.OK bit is on, include a WSopt option 1914 in this segment. Last.ACK.sent is 1915 set to RCV.NXT. 1917 If there are other controls or text in the segment, queue 1918 them for processing after the ESTABLISHED state has been 1919 reached, return. 1921 fifth, if neither of the SYN or RST bits is set then drop the 1922 segment and return. 1924 Otherwise, 1926 First, check sequence number 1928 SYN-RECEIVED STATE 1929 ESTABLISHED STATE 1930 FIN-WAIT-1 STATE 1931 FIN-WAIT-2 STATE 1932 CLOSE-WAIT STATE 1933 CLOSING STATE 1934 LAST-ACK STATE 1935 TIME-WAIT STATE 1937 Segments are processed in sequence. Initial tests on 1938 arrival are used to discard old duplicates, but further 1939 processing is done in SEG.SEQ order. If a segment's 1940 contents straddle the boundary between old and new, only the 1941 new parts should be processed. 1943 Rescale the received window field: 1945 TrueWindow = SEG.WND << Snd.Wind.Scale, 1947 and use "TrueWindow" in place of SEG.WND in the following 1948 steps. 1950 Check whether the segment contains a Timestamps option and 1951 bit Snd.TS.OK is on. If so: 1953 If SEG.TSval < TS.Recent and the RST bit is off, then 1954 test whether connection has been idle less than 24 days; 1955 if all are true, then the segment is not acceptable; 1956 follow steps below for an unacceptable segment. 1958 If SEG.SEQ is equal to Last.ACK.sent, then save SEG.TSval 1959 in variable TS.Recent. 1961 There are four cases for the acceptability test for an 1962 incoming segment: 1964 ... 1966 If an incoming segment is not acceptable, an acknowledgment 1967 should be sent in reply (unless the RST bit is set, if so 1968 drop the segment and return): 1970 1972 Last.ACK.sent is set to SEG.ACK of the acknowledgment. If 1973 the Snd.Echo.OK bit is on, include the Timestamps option 1974 in this ACK segment. 1975 Set Last.ACK.sent to SEG.ACK and send the ACK segment. 1976 After sending the acknowledgment, drop the unacceptable 1977 segment and return. 1979 ... 1981 fifth check the ACK field. 1983 if the ACK bit is off drop the segment and return. 1985 if the ACK bit is on 1987 ... 1989 ESTABLISHED STATE 1991 If SND.UNA < SEG.ACK <= SND.NXT then, set SND.UNA <- 1992 SEG.ACK. Also compute a new estimate of round-trip time. 1993 If Snd.TS.OK bit is on, use Snd.TSclock - SEG.TSecr; 1994 otherwise use the elapsed time since the first segment in 1995 the retransmission queue was sent. Any segments on the 1996 retransmission queue which are thereby entirely 1997 acknowledged... 1999 ... 2001 Seventh, process the segment text. 2003 ESTABLISHED STATE 2004 FIN-WAIT-1 STATE 2005 FIN-WAIT-2 STATE 2007 ... 2009 Send an acknowledgment of the form: 2011 2013 If the Snd.TS.OK bit is on, include Timestamps option 2014 in this ACK segment. 2015 Set Last.ACK.sent to SEG.ACK of the acknowledgment, and send 2016 it. This acknowledgment should be piggy-backed on a segment 2017 being transmitted if possible without incurring undue delay. 2019 ... 2021 Appendix G. Timestamps Edge Cases 2023 While the rules laid out for when to calculate RTTM produce the 2024 correct results most of the time, there are some edge cases where an 2025 incorrect RTTM can be calculated. All of these situations involve 2026 the loss of packets. It is felt that these scenarios are rare, and 2027 that if they should happen, they will cause a single RTTM measurement 2028 to be inflated, which mitigates its effects on RTO calculations. 2030 [Martin03] cites two similar cases when the returning ACK is lost, 2031 and before the retransmission timer fires, another returning packet 2032 arrives, which ACKs the data. In this case, the RTTM calculated will 2033 be inflated: 2035 clock 2036 tc=1 -------------------> 2038 tc=2 (lost) <---- 2039 (RTTM would have been 1) 2041 (receive window opens, window update is sent) 2042 tc=5 <---- 2043 (RTTM is calculated at 4) 2045 One thing to note about this situation is that it is somewhat bounded 2046 by RTO + RTT, limiting how far off the RTTM calculation will be. 2047 While more complex scenarios can be constructed that produce larger 2048 inflations (e.g., retransmissions are lost), those scenarios involve 2049 multiple packet losses, and the connection will have other more 2050 serious operational problems than using an inflated RTTM in the RTO 2051 calculation. 2053 Authors' Addresses 2055 David Borman 2056 Quantum Corporation 2057 Mendota Heights MN 55120 2058 USA 2060 Email: david.borman@quantum.com 2062 Bob Braden 2063 University of Southern California 2064 4676 Admiralty Way 2065 Marina del Rey CA 90292 2066 USA 2068 Email: braden@isi.edu 2070 Van Jacobson 2071 Packet Design 2072 2465 Latham Street 2073 Mountain View CA 94040 2074 USA 2076 Email: van@packetdesign.com 2078 Richard Scheffenegger (editor) 2079 NetApp, Inc. 2080 Am Euro Platz 2 2081 Vienna, 1120 2082 Austria 2084 Email: rs@netapp.com