idnits 2.17.1 draft-ietf-tcpm-rfc793bis-25.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 Security Considerations section. ** There are 3 instances of too long lines in the document, the longest one being 54 characters in excess of 72. == There are 3 instances of lines with non-RFC2606-compliant FQDNs in the document. -- The draft header indicates that this document obsoletes RFC6093, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC2873, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC6429, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC7, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC879, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document obsoletes RFC6528, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords -- however, there's a paragraph with a matching beginning. Boilerplate error? (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). (Using the creation date from RFC1122, updated by this document, for RFC5378 checks: 1989-10-01) -- The document seems to contain a disclaimer for pre-RFC5378 work, and may have content which was first submitted before 10 November 2008. The disclaimer is necessary when there are original authors that you have been unable to contact, or if some do not wish to grant the BCP78 rights to the IETF Trust. If you are able to get all authors (current and original) to grant those rights, you can and should remove the disclaimer; otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (7 September 2021) is 961 days in the past. Is this intentional? 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: 'Options' on line 301 -- Looks like a reference, but probably isn't: 'RFC8311' on line 4432 -- Looks like a reference, but probably isn't: 'RFC3540' on line 4432 -- Looks like a reference, but probably isn't: 'RFC3168' on line 4434 -- Obsolete informational reference (is this intentional?): RFC 793 (ref. '16') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 896 (ref. '17') (Obsoleted by RFC 7805) -- Obsolete informational reference (is this intentional?): RFC 1349 (ref. '19') (Obsoleted by RFC 2474) -- Obsolete informational reference (is this intentional?): RFC 1644 (ref. '20') (Obsoleted by RFC 6247) -- Obsolete informational reference (is this intentional?): RFC 2873 (ref. '23') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6093 (ref. '38') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6429 (ref. '40') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6528 (ref. '41') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6691 (ref. '42') (Obsoleted by RFC 9293) == Outdated reference: A later version (-13) exists of draft-ietf-tcpm-tcp-edo-10 == Outdated reference: A later version (-13) exists of draft-mcquistin-augmented-ascii-diagrams-08 == Outdated reference: A later version (-04) exists of draft-iab-use-it-or-lose-it-02 Summary: 2 errors (**), 0 flaws (~~), 6 warnings (==), 21 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Internet Engineering Task Force W. Eddy, Ed. 3 Internet-Draft MTI Systems 4 Obsoletes: 793, 879, 2873, 6093, 6429, 6528, 7 September 2021 5 6691 (if approved) 6 Updates: 5961, 1122 (if approved) 7 Intended status: Standards Track 8 Expires: 11 March 2022 10 Transmission Control Protocol (TCP) Specification 11 draft-ietf-tcpm-rfc793bis-25 13 Abstract 15 This document specifies the Transmission Control Protocol (TCP). TCP 16 is an important transport layer protocol in the Internet protocol 17 stack, and has continuously evolved over decades of use and growth of 18 the Internet. Over this time, a number of changes have been made to 19 TCP as it was specified in RFC 793, though these have only been 20 documented in a piecemeal fashion. This document collects and brings 21 those changes together with the protocol specification from RFC 793. 22 This document obsoletes RFC 793, as well as RFCs 879, 2873, 6093, 23 6429, 6528, and 6691 that updated parts of RFC 793. It updates RFC 24 1122, and should be considered as a replacement for the portions of 25 that document dealing with TCP requirements. It also updates RFC 26 5961 by adding a small clarification in reset handling while in the 27 SYN-RECEIVED state. The TCP header control bits from RFC 793 have 28 also been updated based on RFC 3168. 30 RFC EDITOR NOTE: If approved for publication as an RFC, this should 31 be marked additionally as "STD: 7" and replace RFC 793 in that role. 33 Status of This Memo 35 This Internet-Draft is submitted in full conformance with the 36 provisions of BCP 78 and BCP 79. 38 Internet-Drafts are working documents of the Internet Engineering 39 Task Force (IETF). Note that other groups may also distribute 40 working documents as Internet-Drafts. The list of current Internet- 41 Drafts is at https://datatracker.ietf.org/drafts/current/. 43 Internet-Drafts are draft documents valid for a maximum of six months 44 and may be updated, replaced, or obsoleted by other documents at any 45 time. It is inappropriate to use Internet-Drafts as reference 46 material or to cite them other than as "work in progress." 48 This Internet-Draft will expire on 11 March 2022. 50 Copyright Notice 52 Copyright (c) 2021 IETF Trust and the persons identified as the 53 document authors. All rights reserved. 55 This document is subject to BCP 78 and the IETF Trust's Legal 56 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 57 license-info) in effect on the date of publication of this document. 58 Please review these documents carefully, as they describe your rights 59 and restrictions with respect to this document. Code Components 60 extracted from this document must include Simplified BSD License text 61 as described in Section 4.e of the Trust Legal Provisions and are 62 provided without warranty as described in the Simplified BSD License. 64 This document may contain material from IETF Documents or IETF 65 Contributions published or made publicly available before November 66 10, 2008. The person(s) controlling the copyright in some of this 67 material may not have granted the IETF Trust the right to allow 68 modifications of such material outside the IETF Standards Process. 69 Without obtaining an adequate license from the person(s) controlling 70 the copyright in such materials, this document may not be modified 71 outside the IETF Standards Process, and derivative works of it may 72 not be created outside the IETF Standards Process, except to format 73 it for publication as an RFC or to translate it into languages other 74 than English. 76 Table of Contents 78 1. Purpose and Scope . . . . . . . . . . . . . . . . . . . . . . 3 79 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 80 2.1. Requirements Language . . . . . . . . . . . . . . . . . . 5 81 2.2. Key TCP Concepts . . . . . . . . . . . . . . . . . . . . 5 82 3. Functional Specification . . . . . . . . . . . . . . . . . . 6 83 3.1. Header Format . . . . . . . . . . . . . . . . . . . . . . 6 84 3.2. Specific Option Definitions . . . . . . . . . . . . . . . 11 85 3.2.1. Other Common Options . . . . . . . . . . . . . . . . 13 86 3.2.2. Experimental TCP Options . . . . . . . . . . . . . . 13 87 3.3. TCP Terminology Overview . . . . . . . . . . . . . . . . 13 88 3.3.1. Key Connection State Variables . . . . . . . . . . . 13 89 3.3.2. State Machine Overview . . . . . . . . . . . . . . . 15 90 3.4. Sequence Numbers . . . . . . . . . . . . . . . . . . . . 18 91 3.5. Establishing a connection . . . . . . . . . . . . . . . . 26 92 3.6. Closing a Connection . . . . . . . . . . . . . . . . . . 32 93 3.6.1. Half-Closed Connections . . . . . . . . . . . . . . . 35 94 3.7. Segmentation . . . . . . . . . . . . . . . . . . . . . . 35 95 3.7.1. Maximum Segment Size Option . . . . . . . . . . . . . 37 96 3.7.2. Path MTU Discovery . . . . . . . . . . . . . . . . . 38 97 3.7.3. Interfaces with Variable MTU Values . . . . . . . . . 39 98 3.7.4. Nagle Algorithm . . . . . . . . . . . . . . . . . . . 39 99 3.7.5. IPv6 Jumbograms . . . . . . . . . . . . . . . . . . . 40 100 3.8. Data Communication . . . . . . . . . . . . . . . . . . . 40 101 3.8.1. Retransmission Timeout . . . . . . . . . . . . . . . 41 102 3.8.2. TCP Congestion Control . . . . . . . . . . . . . . . 41 103 3.8.3. TCP Connection Failures . . . . . . . . . . . . . . . 42 104 3.8.4. TCP Keep-Alives . . . . . . . . . . . . . . . . . . . 43 105 3.8.5. The Communication of Urgent Information . . . . . . . 44 106 3.8.6. Managing the Window . . . . . . . . . . . . . . . . . 45 107 3.9. Interfaces . . . . . . . . . . . . . . . . . . . . . . . 50 108 3.9.1. User/TCP Interface . . . . . . . . . . . . . . . . . 50 109 3.9.2. TCP/Lower-Level Interface . . . . . . . . . . . . . . 59 110 3.10. Event Processing . . . . . . . . . . . . . . . . . . . . 62 111 3.10.1. OPEN Call . . . . . . . . . . . . . . . . . . . . . 63 112 3.10.2. SEND Call . . . . . . . . . . . . . . . . . . . . . 64 113 3.10.3. RECEIVE Call . . . . . . . . . . . . . . . . . . . . 66 114 3.10.4. CLOSE Call . . . . . . . . . . . . . . . . . . . . . 67 115 3.10.5. ABORT Call . . . . . . . . . . . . . . . . . . . . . 68 116 3.10.6. STATUS Call . . . . . . . . . . . . . . . . . . . . 69 117 3.10.7. SEGMENT ARRIVES . . . . . . . . . . . . . . . . . . 70 118 3.10.8. Timeouts . . . . . . . . . . . . . . . . . . . . . . 84 119 4. Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . 84 120 5. Changes from RFC 793 . . . . . . . . . . . . . . . . . . . . 89 121 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 95 122 7. Security and Privacy Considerations . . . . . . . . . . . . . 96 123 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 98 124 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 99 125 9.1. Normative References . . . . . . . . . . . . . . . . . . 99 126 9.2. Informative References . . . . . . . . . . . . . . . . . 100 127 Appendix A. Other Implementation Notes . . . . . . . . . . . . . 106 128 A.1. IP Security Compartment and Precedence . . . . . . . . . 106 129 A.1.1. Precedence . . . . . . . . . . . . . . . . . . . . . 106 130 A.1.2. MLS Systems . . . . . . . . . . . . . . . . . . . . . 107 131 A.2. Sequence Number Validation . . . . . . . . . . . . . . . 107 132 A.3. Nagle Modification . . . . . . . . . . . . . . . . . . . 108 133 A.4. Low Water Mark Settings . . . . . . . . . . . . . . . . . 108 134 Appendix B. TCP Requirement Summary . . . . . . . . . . . . . . 108 135 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 112 137 1. Purpose and Scope 139 In 1981, RFC 793 [16] was released, documenting the Transmission 140 Control Protocol (TCP), and replacing earlier specifications for TCP 141 that had been published in the past. 143 Since then, TCP has been widely implemented, and has been used as a 144 transport protocol for numerous applications on the Internet. 146 For several decades, RFC 793 plus a number of other documents have 147 combined to serve as the core specification for TCP [48]. Over time, 148 a number of errata have been filed against RFC 793, as well as 149 deficiencies in security, performance, and many other aspects. The 150 number of enhancements has grown over time across many separate 151 documents. These were never accumulated together into a 152 comprehensive update to the base specification. 154 The purpose of this document is to bring together all of the IETF 155 Standards Track changes that have been made to the base TCP 156 functional specification and unify them into an update of RFC 793. 158 Some companion documents are referenced for important algorithms that 159 are used by TCP (e.g. for congestion control), but have not been 160 completely included in this document. This is a conscious choice, as 161 this base specification can be used with multiple additional 162 algorithms that are developed and incorporated separately. This 163 document focuses on the common basis all TCP implementations must 164 support in order to interoperate. Since some additional TCP features 165 have become quite complicated themselves (e.g. advanced loss recovery 166 and congestion control), future companion documents may attempt to 167 similarly bring these together. 169 In addition to the protocol specification that describes the TCP 170 segment format, generation, and processing rules that are to be 171 implemented in code, RFC 793 and other updates also contain 172 informative and descriptive text for readers to understand aspects of 173 the protocol design and operation. This document does not attempt to 174 alter or update this informative text, and is focused only on 175 updating the normative protocol specification. This document 176 preserves references to the documentation containing the important 177 explanations and rationale, where appropriate. 179 This document is intended to be useful both in checking existing TCP 180 implementations for conformance purposes, as well as in writing new 181 implementations. 183 2. Introduction 185 RFC 793 contains a discussion of the TCP design goals and provides 186 examples of its operation, including examples of connection 187 establishment, connection termination, packet retransmission to 188 repair losses. 190 This document describes the basic functionality expected in modern 191 TCP implementations, and replaces the protocol specification in RFC 192 793. It does not replicate or attempt to update the introduction and 193 philosophy content in Sections 1 and 2 of RFC 793. Other documents 194 are referenced to provide explanation of the theory of operation, 195 rationale, and detailed discussion of design decisions. This 196 document only focuses on the normative behavior of the protocol. 198 The "TCP Roadmap" [48] provides a more extensive guide to the RFCs 199 that define TCP and describe various important algorithms. The TCP 200 Roadmap contains sections on strongly encouraged enhancements that 201 improve performance and other aspects of TCP beyond the basic 202 operation specified in this document. As one example, implementing 203 congestion control (e.g. [9]) is a TCP requirement, but is a complex 204 topic on its own, and not described in detail in this document, as 205 there are many options and possibilities that do not impact basic 206 interoperability. Similarly, most TCP implementations today include 207 the high-performance extensions in [46], but these are not strictly 208 required or discussed in this document. Multipath considerations for 209 TCP are also specified separately in [57]. 211 A list of changes from RFC 793 is contained in Section 5. 213 2.1. Requirements Language 215 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 216 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 217 "OPTIONAL" in this document are to be interpreted as described in BCP 218 14 [3][12] when, and only when, they appear in all capitals, as shown 219 here. 221 Each use of RFC 2119 keywords in the document is individually labeled 222 and referenced in Appendix B that summarizes implementation 223 requirements. 225 Sentences using "MUST" are labeled as "MUST-X" with X being a numeric 226 identifier enabling the requirement to be located easily when 227 referenced from Appendix B. 229 Similarly, sentences using "SHOULD" are labeled with "SHLD-X", "MAY" 230 with "MAY-X", and "RECOMMENDED" with "REC-X". 232 For the purposes of this labeling, "SHOULD NOT" and "MUST NOT" are 233 labeled the same as "SHOULD" and "MUST" instances. 235 2.2. Key TCP Concepts 237 TCP provides a reliable, in-order, byte-stream service to 238 applications. 240 The application byte-stream is conveyed over the network via TCP 241 segments, with each TCP segment sent as an Internet Protocol (IP) 242 datagram. 244 TCP reliability consists of detecting packet losses (via sequence 245 numbers) and errors (via per-segment checksums), as well as 246 correction via retransmission. 248 TCP supports unicast delivery of data. Anycast applications exist 249 that successfully use TCP without modifications, though there is some 250 risk of instability due to changes of lower-layer forwarding behavior 251 [45]. 253 TCP is connection-oriented, though does not inherently include a 254 liveness detection capability. 256 Data flow is supported bidirectionally over TCP connections, though 257 applications are free to send data only unidirectionally, if they so 258 choose. 260 TCP uses port numbers to identify application services and to 261 multiplex distinct flows between hosts. 263 A more detailed description of TCP features compared to other 264 transport protocols can be found in Section 3.1 of [51]. Further 265 description of the motivations for developing TCP and its role in the 266 Internet protocol stack can be found in Section 2 of [16] and earlier 267 versions of the TCP specification. 269 3. Functional Specification 271 3.1. Header Format 273 TCP segments are sent as internet datagrams. The Internet Protocol 274 (IP) header carries several information fields, including the source 275 and destination host addresses [1] [13]. A TCP header follows the IP 276 headers, supplying information specific to the TCP protocol. This 277 division allows for the existence of host level protocols other than 278 TCP. In early development of the Internet suite of protocols, the IP 279 header fields had been a part of TCP. 281 This document describes the TCP protocol. The TCP protocol uses TCP 282 Headers. 284 A TCP Header is formatted as follows, using the style from [65]: 286 0 1 2 3 287 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 288 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 289 | Source Port | Destination Port | 290 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 291 | Sequence Number | 292 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 293 | Acknowledgment Number | 294 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 295 | Data | |C|E|U|A|P|R|S|F| | 296 | Offset| Rsrvd |W|C|R|C|S|S|Y|I| Window | 297 | | |R|E|G|K|H|T|N|N| | 298 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 299 | Checksum | Urgent Pointer | 300 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 301 | [Options] | 302 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 303 | : 304 : Data : 305 : | 306 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 308 Note that one tick mark represents one bit position. 310 Figure 1: TCP Header Format 312 where: 314 Source Port: 16 bits. 315 The source port number. 317 Destination Port: 16 bits. 318 The destination port number. 320 Sequence Number: 32 bits. 321 The sequence number of the first data octet in this segment (except 322 when the SYN flag is set). If SYN is set the sequence number is 323 the initial sequence number (ISN) and the first data octet is 324 ISN+1. 326 Acknowledgment Number: 32 bits. 327 If the ACK control bit is set, this field contains the value of the 328 next sequence number the sender of the segment is expecting to 329 receive. Once a connection is established, this is always sent. 331 Data Offset (DOffset): 4 bits. 333 The number of 32 bit words in the TCP Header. This indicates where 334 the data begins. The TCP header (even one including options) is an 335 integer multiple of 32 bits long. 337 Reserved (Rsrvd): 4 bits. 338 A set of control bits reserved for future use. Must be zero in 339 generated segments and must be ignored in received segments, if 340 corresponding future features are unimplemented by the sending or 341 receiving host. 343 The control bits are also know as "flags". Assignment is managed 344 by IANA from the "TCP Header Flags" registry [61]. The currently 345 assigned control bits are CWR, ECE, URG, ACK, PSH, RST, SYN, and 346 FIN. 348 CWR: 1 bit. 349 Congestion Window Reduced (see [7]). 351 ECE: 1 bit. 352 ECN-Echo (see [7]). 354 URG: 1 bit. 355 Urgent Pointer field is significant. 357 ACK: 1 bit. 358 Acknowledgment field is significant. 360 PSH: 1 bit. 361 Push Function (see the Send Call description in Section 3.9.1). 363 RST: 1 bit. 364 Reset the connection. 366 SYN: 1 bit. 367 Synchronize sequence numbers. 369 FIN: 1 bit. 370 No more data from sender. 372 Window: 16 bits. 373 The number of data octets beginning with the one indicated in the 374 acknowledgment field that the sender of this segment is willing to 375 accept. The value is shifted when the Window Scaling extension is 376 used [46]. 378 The window size MUST be treated as an unsigned number, or else 379 large window sizes will appear like negative windows and TCP will 380 not work (MUST-1). It is RECOMMENDED that implementations will 381 reserve 32-bit fields for the send and receive window sizes in the 382 connection record and do all window computations with 32 bits (REC- 383 1). 385 Checksum: 16 bits. 386 The checksum field is the 16 bit one's complement of the one's 387 complement sum of all 16 bit words in the header and text. The 388 checksum computation needs to ensure the 16-bit alignment of the 389 data being summed. If a segment contains an odd number of header 390 and text octets, alignment can be achieved by padding the last 391 octet with zeros on its right to form a 16 bit word for checksum 392 purposes. The pad is not transmitted as part of the segment. 393 While computing the checksum, the checksum field itself is replaced 394 with zeros. 396 The checksum also covers a pseudo header (Figure 2) conceptually 397 prefixed to the TCP header. The pseudo header is 96 bits for IPv4 398 and 320 bits for IPv6. Including the pseudo header in the checksum 399 gives the TCP connection protection against misrouted segments. 400 This information is carried in IP headers and is transferred across 401 the TCP/Network interface in the arguments or results of calls by 402 the TCP implementation on the IP layer. 404 +--------+--------+--------+--------+ 405 | Source Address | 406 +--------+--------+--------+--------+ 407 | Destination Address | 408 +--------+--------+--------+--------+ 409 | zero | PTCL | TCP Length | 410 +--------+--------+--------+--------+ 412 Figure 2: IPv4 Pseudo Header 414 Pseudo header components for IPv4: 415 Source Address: the IPv4 source address in network byte order 417 Destination Address: the IPv4 destination address in network 418 byte order 420 zero: bits set to zero 422 PTCL: the protocol number from the IP header 424 TCP Length: the TCP header length plus the data length in 425 octets (this is not an explicitly transmitted quantity, but is 426 computed), and it does not count the 12 octets of the pseudo 427 header. 429 For IPv6, the pseudo header is defined in Section 8.1 of RFC 8200 430 [13], and contains the IPv6 Source Address and Destination 431 Address, an Upper Layer Packet Length (a 32-bit value otherwise 432 equivalent to TCP Length in the IPv4 pseudo header), three bytes 433 of zero-padding, and a Next Header value (differing from the IPv6 434 header value in the case of extension headers present in between 435 IPv6 and TCP). 437 The TCP checksum is never optional. The sender MUST generate it 438 (MUST-2) and the receiver MUST check it (MUST-3). 440 Urgent Pointer: 16 bits. 441 This field communicates the current value of the urgent pointer as 442 a positive offset from the sequence number in this segment. The 443 urgent pointer points to the sequence number of the octet following 444 the urgent data. This field is only be interpreted in segments 445 with the URG control bit set. 447 Options: [TCP Option]; Options#Size == (DOffset-5)*32; present 448 only when DOffset > 5. 449 Options may occupy space at the end of the TCP header and are a 450 multiple of 8 bits in length. All options are included in the 451 checksum. An option may begin on any octet boundary. There are 452 two cases for the format of an option: 454 Case 1: A single octet of option-kind. 456 Case 2: An octet of option-kind (Kind), an octet of option- 457 length, and the actual option-data octets. 459 The option-length counts the two octets of option-kind and option- 460 length as well as the option-data octets. 462 Note that the list of options may be shorter than the data offset 463 field might imply. The content of the header beyond the End-of- 464 Option option must be header padding (i.e., zero). 466 The list of all currently defined options is managed by IANA [60], 467 and each option is defined in other RFCs, as indicated there. That 468 set includes experimental options that can be extended to support 469 multiple concurrent usages [44]. 471 A given TCP implementation can support any currently defined 472 options, but the following options MUST be supported (MUST-4 - note 473 Maximum Segment Size option support is also part of MUST-19 in 474 Section 3.7.2): 476 Kind Length Meaning 477 ---- ------ ------- 478 0 - End of option list. 479 1 - No-Operation. 480 2 4 Maximum Segment Size. 482 These options are specified in detail in Section 3.2. 484 A TCP implementation MUST be able to receive a TCP option in any 485 segment (MUST-5). 487 A TCP implementation MUST (MUST-6) ignore without error any TCP 488 option it does not implement, assuming that the option has a length 489 field. All TCP options except End of option list and No-Operation 490 MUST have length fields, including all future options (MUST-68). 491 TCP implementations MUST be prepared to handle an illegal option 492 length (e.g., zero); a suggested procedure is to reset the 493 connection and log the error cause (MUST-7). 495 Note: There is ongoing work to extend the space available for TCP 496 options, such as [64]. 498 Data: variable length. 499 User data carried by the TCP segment. 501 3.2. Specific Option Definitions 503 A TCP Option is one of: an End of Option List Option, a No-Operation 504 Option, or a Maximum Segment Size Option. 506 An End of Option List Option is formatted as follows: 508 0 509 0 1 2 3 4 5 6 7 510 +-+-+-+-+-+-+-+-+ 511 | 0 | 512 +-+-+-+-+-+-+-+-+ 514 where: 516 Kind: 1 byte; Kind == 0. 517 This option code indicates the end of the option list. This might 518 not coincide with the end of the TCP header according to the Data 519 Offset field. This is used at the end of all options, not the end 520 of each option, and need only be used if the end of the options 521 would not otherwise coincide with the end of the TCP header. 523 A No-Operation Option is formatted as follows: 525 0 526 0 1 2 3 4 5 6 7 527 +-+-+-+-+-+-+-+-+ 528 | 1 | 529 +-+-+-+-+-+-+-+-+ 531 where: 533 Kind: 1 byte; Kind == 1. 534 This option code can be used between options, for example, to align 535 the beginning of a subsequent option on a word boundary. There is 536 no guarantee that senders will use this option, so receivers MUST 537 be prepared to process options even if they do not begin on a word 538 boundary (MUST-64). 540 A Maximum Segment Size Option is formatted as follows: 542 0 1 2 3 543 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 544 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 545 | 2 | Length | Maximum Segment Size (MSS) | 546 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 548 where: 550 Kind: 1 byte; Kind == 2. 551 If this option is present, then it communicates the maximum receive 552 segment size at the TCP endpoint that sends this segment. This 553 value is limited by the IP reassembly limit. This field may be 554 sent in the initial connection request (i.e., in segments with the 555 SYN control bit set) and MUST NOT be sent in other segments (MUST- 556 65). If this option is not used, any segment size is allowed. A 557 more complete description of this option is provided in 558 Section 3.7.1. 560 Length: 1 byte; Length == 4. 561 Length of the option in bytes. 563 Maximum Segment Size (MSS): 2 bytes. 564 The maximum receive segment size at the TCP endpoint that sends 565 this segment. 567 3.2.1. Other Common Options 569 Additional RFCs define some other commonly used options that are 570 recommended to implement for high performance, but not necessary for 571 basic TCP interoperability. These are the TCP Selective 572 Acknowledgement (SACK) option [21][24], TCP Timestamp (TS) option 573 [46], and TCP Window Scaling (WS) option [46]. 575 3.2.2. Experimental TCP Options 577 Experimental TCP option values are defined in [28], and [44] 578 describes the current recommended usage for these experimental 579 values. 581 3.3. TCP Terminology Overview 583 This section includes an overview of key terms needed to understand 584 the detailed protocol operation in the rest of the document. There 585 is a traditional glossary of terms in Section 4. 587 3.3.1. Key Connection State Variables 589 Before we can discuss very much about the operation of the TCP 590 implementation we need to introduce some detailed terminology. The 591 maintenance of a TCP connection requires the remembering of several 592 variables. We conceive of these variables being stored in a 593 connection record called a Transmission Control Block or TCB. Among 594 the variables stored in the TCB are the local and remote IP addresses 595 and port numbers, the IP security level and compartment of the 596 connection (see Appendix A.1), pointers to the user's send and 597 receive buffers, pointers to the retransmit queue and to the current 598 segment. In addition several variables relating to the send and 599 receive sequence numbers are stored in the TCB. 601 Send Sequence Variables: 603 SND.UNA - send unacknowledged 604 SND.NXT - send next 605 SND.WND - send window 606 SND.UP - send urgent pointer 607 SND.WL1 - segment sequence number used for last window update 608 SND.WL2 - segment acknowledgment number used for last window 609 update 610 ISS - initial send sequence number 612 Receive Sequence Variables: 614 RCV.NXT - receive next 615 RCV.WND - receive window 616 RCV.UP - receive urgent pointer 617 IRS - initial receive sequence number 619 The following diagrams may help to relate some of these variables to 620 the sequence space. 622 1 2 3 4 623 ----------|----------|----------|---------- 624 SND.UNA SND.NXT SND.UNA 625 +SND.WND 627 1 - old sequence numbers that have been acknowledged 628 2 - sequence numbers of unacknowledged data 629 3 - sequence numbers allowed for new data transmission 630 4 - future sequence numbers that are not yet allowed 632 Figure 3: Send Sequence Space 634 The send window is the portion of the sequence space labeled 3 in 635 Figure 3. 637 1 2 3 638 ----------|----------|---------- 639 RCV.NXT RCV.NXT 640 +RCV.WND 642 1 - old sequence numbers that have been acknowledged 643 2 - sequence numbers allowed for new reception 644 3 - future sequence numbers that are not yet allowed 646 Figure 4: Receive Sequence Space 648 The receive window is the portion of the sequence space labeled 2 in 649 Figure 4. 651 There are also some variables used frequently in the discussion that 652 take their values from the fields of the current segment. 654 Current Segment Variables: 656 SEG.SEQ - segment sequence number 657 SEG.ACK - segment acknowledgment number 658 SEG.LEN - segment length 659 SEG.WND - segment window 660 SEG.UP - segment urgent pointer 662 3.3.2. State Machine Overview 664 A connection progresses through a series of states during its 665 lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, 666 ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, 667 TIME-WAIT, and the fictional state CLOSED. CLOSED is fictional 668 because it represents the state when there is no TCB, and therefore, 669 no connection. Briefly the meanings of the states are: 671 LISTEN - represents waiting for a connection request from any 672 remote TCP peer and port. 674 SYN-SENT - represents waiting for a matching connection request 675 after having sent a connection request. 677 SYN-RECEIVED - represents waiting for a confirming connection 678 request acknowledgment after having both received and sent a 679 connection request. 681 ESTABLISHED - represents an open connection, data received can be 682 delivered to the user. The normal state for the data transfer 683 phase of the connection. 685 FIN-WAIT-1 - represents waiting for a connection termination 686 request from the remote TCP peer, or an acknowledgment of the 687 connection termination request previously sent. 689 FIN-WAIT-2 - represents waiting for a connection termination 690 request from the remote TCP peer. 692 CLOSE-WAIT - represents waiting for a connection termination 693 request from the local user. 695 CLOSING - represents waiting for a connection termination request 696 acknowledgment from the remote TCP peer. 698 LAST-ACK - represents waiting for an acknowledgment of the 699 connection termination request previously sent to the remote TCP 700 peer (this termination request sent to the remote TCP peer already 701 included an acknowledgment of the termination request sent from 702 the remote TCP peer). 704 TIME-WAIT - represents waiting for enough time to pass to be sure 705 the remote TCP peer received the acknowledgment of its connection 706 termination request, and to avoid new connections being impacted 707 by delayed segments from previous connections. 709 CLOSED - represents no connection state at all. 711 A TCP connection progresses from one state to another in response to 712 events. The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, 713 ABORT, and STATUS; the incoming segments, particularly those 714 containing the SYN, ACK, RST and FIN flags; and timeouts. 716 The state diagram in Figure 5 illustrates only state changes, 717 together with the causing events and resulting actions, but addresses 718 neither error conditions nor actions that are not connected with 719 state changes. In a later section, more detail is offered with 720 respect to the reaction of the TCP implementation to events. Some 721 state names are abbreviated or hyphenated differently in the diagram 722 from how they appear elsewhere in the document. 724 NOTA BENE: This diagram is only a summary and must not be taken as 725 the total specification. Many details are not included. 727 +---------+ ---------\ active OPEN 728 | CLOSED | \ ----------- 729 +---------+<---------\ \ create TCB 730 | ^ \ \ snd SYN 731 passive OPEN | | CLOSE \ \ 732 ------------ | | ---------- \ \ 733 create TCB | | delete TCB \ \ 734 V | \ \ 735 rcv RST (note 1) +---------+ CLOSE | \ 736 -------------------->| LISTEN | ---------- | | 737 / +---------+ delete TCB | | 738 / rcv SYN | | SEND | | 739 / ----------- | | ------- | V 740 +--------+ snd SYN,ACK / \ snd SYN +--------+ 741 | |<----------------- ------------------>| | 742 | SYN | rcv SYN | SYN | 743 | RCVD |<-----------------------------------------------| SENT | 744 | | snd SYN,ACK | | 745 | |------------------ -------------------| | 746 +--------+ rcv ACK of SYN \ / rcv SYN,ACK +--------+ 747 | -------------- | | ----------- 748 | x | | snd ACK 749 | V V 750 | CLOSE +---------+ 751 | ------- | ESTAB | 752 | snd FIN +---------+ 753 | CLOSE | | rcv FIN 754 V ------- | | ------- 755 +---------+ snd FIN / \ snd ACK +---------+ 756 | FIN |<---------------- ------------------>| CLOSE | 757 | WAIT-1 |------------------ | WAIT | 758 +---------+ rcv FIN \ +---------+ 759 | rcv ACK of FIN ------- | CLOSE | 760 | -------------- snd ACK | ------- | 761 V x V snd FIN V 762 +---------+ +---------+ +---------+ 763 |FINWAIT-2| | CLOSING | | LAST-ACK| 764 +---------+ +---------+ +---------+ 765 | rcv ACK of FIN | rcv ACK of FIN | 766 | rcv FIN -------------- | Timeout=2MSL -------------- | 767 | ------- x V ------------ x V 768 \ snd ACK +---------+delete TCB +---------+ 769 -------------------->|TIME-WAIT|------------------->| CLOSED | 770 +---------+ +---------+ 772 Figure 5: TCP Connection State Diagram 774 The following notes apply to Figure 5: 776 Note 1: The transition from SYN-RECEIVED to LISTEN on receiving a 777 RST is conditional on having reached SYN-RECEIVED after a passive 778 open. 780 Note 2: An unshown transition exists from FIN-WAIT-1 to TIME-WAIT 781 if a FIN is received and the local FIN is also acknowledged. 783 Note 3: A RST can be sent from any state with a corresponding 784 transition to TIME-WAIT (see [69] for rationale). These 785 transitions are not not explicitly shown, otherwise the diagram 786 would become very difficult to read. Similarly, receipt of a RST 787 from any state results in a transition to LISTEN or CLOSED, though 788 this is also omitted from the diagram for legibility. 790 3.4. Sequence Numbers 792 A fundamental notion in the design is that every octet of data sent 793 over a TCP connection has a sequence number. Since every octet is 794 sequenced, each of them can be acknowledged. The acknowledgment 795 mechanism employed is cumulative so that an acknowledgment of 796 sequence number X indicates that all octets up to but not including X 797 have been received. This mechanism allows for straight-forward 798 duplicate detection in the presence of retransmission. Numbering of 799 octets within a segment is that the first data octet immediately 800 following the header is the lowest numbered, and the following octets 801 are numbered consecutively. 803 It is essential to remember that the actual sequence number space is 804 finite, though very large. This space ranges from 0 to 2**32 - 1. 805 Since the space is finite, all arithmetic dealing with sequence 806 numbers must be performed modulo 2**32. This unsigned arithmetic 807 preserves the relationship of sequence numbers as they cycle from 808 2**32 - 1 to 0 again. There are some subtleties to computer modulo 809 arithmetic, so great care should be taken in programming the 810 comparison of such values. The symbol "=<" means "less than or 811 equal" (modulo 2**32). 813 The typical kinds of sequence number comparisons that the TCP 814 implementation must perform include: 816 (a) Determining that an acknowledgment refers to some sequence 817 number sent but not yet acknowledged. 819 (b) Determining that all sequence numbers occupied by a segment 820 have been acknowledged (e.g., to remove the segment from a 821 retransmission queue). 823 (c) Determining that an incoming segment contains sequence numbers 824 that are expected (i.e., that the segment "overlaps" the receive 825 window). 827 In response to sending data the TCP endpoint will receive 828 acknowledgments. The following comparisons are needed to process the 829 acknowledgments. 831 SND.UNA = oldest unacknowledged sequence number 833 SND.NXT = next sequence number to be sent 835 SEG.ACK = acknowledgment from the receiving TCP peer (next 836 sequence number expected by the receiving TCP peer) 838 SEG.SEQ = first sequence number of a segment 840 SEG.LEN = the number of octets occupied by the data in the segment 841 (counting SYN and FIN) 843 SEG.SEQ+SEG.LEN-1 = last sequence number of a segment 845 A new acknowledgment (called an "acceptable ack"), is one for which 846 the inequality below holds: 848 SND.UNA < SEG.ACK =< SND.NXT 850 A segment on the retransmission queue is fully acknowledged if the 851 sum of its sequence number and length is less or equal than the 852 acknowledgment value in the incoming segment. 854 When data is received the following comparisons are needed: 856 RCV.NXT = next sequence number expected on an incoming segments, 857 and is the left or lower edge of the receive window 859 RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming 860 segment, and is the right or upper edge of the receive window 862 SEG.SEQ = first sequence number occupied by the incoming segment 864 SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming 865 segment 867 A segment is judged to occupy a portion of valid receive sequence 868 space if 870 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 872 or 874 RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 876 The first part of this test checks to see if the beginning of the 877 segment falls in the window, the second part of the test checks to 878 see if the end of the segment falls in the window; if the segment 879 passes either part of the test it contains data in the window. 881 Actually, it is a little more complicated than this. Due to zero 882 windows and zero length segments, we have four cases for the 883 acceptability of an incoming segment: 885 Segment Receive Test 886 Length Window 887 ------- ------- ------------------------------------------- 889 0 0 SEG.SEQ = RCV.NXT 891 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 893 >0 0 not acceptable 895 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 896 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 898 Note that when the receive window is zero no segments should be 899 acceptable except ACK segments. Thus, it is possible for a TCP 900 implementation to maintain a zero receive window while transmitting 901 data and receiving ACKs. A TCP receiver MUST process the RST and URG 902 fields of all incoming segments, even when the receive window is zero 903 (MUST-66). 905 We have taken advantage of the numbering scheme to protect certain 906 control information as well. This is achieved by implicitly 907 including some control flags in the sequence space so they can be 908 retransmitted and acknowledged without confusion (i.e., one and only 909 one copy of the control will be acted upon). Control information is 910 not physically carried in the segment data space. Consequently, we 911 must adopt rules for implicitly assigning sequence numbers to 912 control. The SYN and FIN are the only controls requiring this 913 protection, and these controls are used only at connection opening 914 and closing. For sequence number purposes, the SYN is considered to 915 occur before the first actual data octet of the segment in which it 916 occurs, while the FIN is considered to occur after the last actual 917 data octet in a segment in which it occurs. The segment length 918 (SEG.LEN) includes both data and sequence space occupying controls. 919 When a SYN is present then SEG.SEQ is the sequence number of the SYN. 921 Initial Sequence Number Selection 923 A connection is defined by a pair of sockets. Connections can be 924 reused. New instances of a connection will be referred to as 925 incarnations of the connection. The problem that arises from this is 926 -- "how does the TCP implementation identify duplicate segments from 927 previous incarnations of the connection?" This problem becomes 928 apparent if the connection is being opened and closed in quick 929 succession, or if the connection breaks with loss of memory and is 930 then reestablished. To support this, the TIME-WAIT state limits the 931 rate of connection reuse, while the initial sequence number selection 932 described below further protects against ambiguity about what 933 incarnation of a connection an incoming packet corresponds to. 935 To avoid confusion we must prevent segments from one incarnation of a 936 connection from being used while the same sequence numbers may still 937 be present in the network from an earlier incarnation. We want to 938 assure this, even if a TCP endpoint loses all knowledge of the 939 sequence numbers it has been using. When new connections are 940 created, an initial sequence number (ISN) generator is employed that 941 selects a new 32 bit ISN. There are security issues that result if 942 an off-path attacker is able to predict or guess ISN values. 944 TCP Initial Sequence Numbers are generated from a number sequence 945 that monotonically increases until it wraps, known loosely as a 946 "clock". This clock is a 32-bit counter that typically increments at 947 least once every roughly 4 microseconds, although it is neither 948 assumed to be realtime nor precise, and need not persist across 949 reboots. The clock component is intended to insure that with a 950 Maximum Segment Lifetime (MSL), generated ISNs will be unique, since 951 it cycles approximately every 4.55 hours, which is much longer than 952 the MSL. 954 A TCP implementation MUST use the above type of "clock" for clock- 955 driven selection of initial sequence numbers (MUST-8), and SHOULD 956 generate its Initial Sequence Numbers with the expression: 958 ISN = M + F(localip, localport, remoteip, remoteport, secretkey) 959 where M is the 4 microsecond timer, and F() is a pseudorandom 960 function (PRF) of the connection's identifying parameters ("localip, 961 localport, remoteip, remoteport") and a secret key ("secretkey") 962 (SHLD-1). F() MUST NOT be computable from the outside (MUST-9), or 963 an attacker could still guess at sequence numbers from the ISN used 964 for some other connection. The PRF could be implemented as a 965 cryptographic hash of the concatenation of the TCP connection 966 parameters and some secret data. For discussion of the selection of 967 a specific hash algorithm and management of the secret key data, 968 please see Section 3 of [41]. 970 For each connection there is a send sequence number and a receive 971 sequence number. The initial send sequence number (ISS) is chosen by 972 the data sending TCP peer, and the initial receive sequence number 973 (IRS) is learned during the connection establishing procedure. 975 For a connection to be established or initialized, the two TCP peers 976 must synchronize on each other's initial sequence numbers. This is 977 done in an exchange of connection establishing segments carrying a 978 control bit called "SYN" (for synchronize) and the initial sequence 979 numbers. As a shorthand, segments carrying the SYN bit are also 980 called "SYNs". Hence, the solution requires a suitable mechanism for 981 picking an initial sequence number and a slightly involved handshake 982 to exchange the ISNs. 984 The synchronization requires each side to send its own initial 985 sequence number and to receive a confirmation of it in acknowledgment 986 from the remote TCP peer. Each side must also receive the remote 987 peer's initial sequence number and send a confirming acknowledgment. 989 1) A --> B SYN my sequence number is X 990 2) A <-- B ACK your sequence number is X 991 3) A <-- B SYN my sequence number is Y 992 4) A --> B ACK your sequence number is Y 994 Because steps 2 and 3 can be combined in a single message this is 995 called the three-way (or three message) handshake (3WHS). 997 A 3WHS is necessary because sequence numbers are not tied to a global 998 clock in the network, and TCP implementations may have different 999 mechanisms for picking the ISNs. The receiver of the first SYN has 1000 no way of knowing whether the segment was an old delayed one or not, 1001 unless it remembers the last sequence number used on the connection 1002 (which is not always possible), and so it must ask the sender to 1003 verify this SYN. The three way handshake and the advantages of a 1004 clock-driven scheme are discussed in [68]. 1006 Knowing When to Keep Quiet 1007 A theoretical problem exists where data could be corrupted due to 1008 confusion between old segments in the network and new ones after a 1009 host reboots, if the same port numbers and sequence space are reused. 1010 The "Quiet Time" concept discussed below addresses this and the 1011 discussion of it is included for situations where it might be 1012 relevant, although it is not felt to be necessary in most current 1013 implementations. The problem was more relevant earlier in the 1014 history of TCP. In practical use on the Internet today, the error- 1015 prone conditions are sufficiently unlikely that it is felt safe to 1016 ignore. Reasons why it is now negligible include: (a) ISS and 1017 ephemeral port randomization have reduced likelihood of reuse of port 1018 numbers and sequence numbers after reboots, (b) the effective MSL of 1019 the Internet has declined as links have become faster, and (c) 1020 reboots often taking longer than an MSL anyways. 1022 To be sure that a TCP implementation does not create a segment 1023 carrying a sequence number that may be duplicated by an old segment 1024 remaining in the network, the TCP endpoint must keep quiet for an MSL 1025 before assigning any sequence numbers upon starting up or recovering 1026 from a situation where memory of sequence numbers in use was lost. 1027 For this specification the MSL is taken to be 2 minutes. This is an 1028 engineering choice, and may be changed if experience indicates it is 1029 desirable to do so. Note that if a TCP endpoint is reinitialized in 1030 some sense, yet retains its memory of sequence numbers in use, then 1031 it need not wait at all; it must only be sure to use sequence numbers 1032 larger than those recently used. 1034 The TCP Quiet Time Concept 1036 Hosts that for any reason lose knowledge of the last sequence numbers 1037 transmitted on each active (i.e., not closed) connection shall delay 1038 emitting any TCP segments for at least the agreed MSL in the internet 1039 system that the host is a part of. In the paragraphs below, an 1040 explanation for this specification is given. TCP implementors may 1041 violate the "quiet time" restriction, but only at the risk of causing 1042 some old data to be accepted as new or new data rejected as old 1043 duplicated by some receivers in the internet system. 1045 TCP endpoints consume sequence number space each time a segment is 1046 formed and entered into the network output queue at a source host. 1047 The duplicate detection and sequencing algorithm in the TCP protocol 1048 relies on the unique binding of segment data to sequence space to the 1049 extent that sequence numbers will not cycle through all 2**32 values 1050 before the segment data bound to those sequence numbers has been 1051 delivered and acknowledged by the receiver and all duplicate copies 1052 of the segments have "drained" from the internet. Without such an 1053 assumption, two distinct TCP segments could conceivably be assigned 1054 the same or overlapping sequence numbers, causing confusion at the 1055 receiver as to which data is new and which is old. Remember that 1056 each segment is bound to as many consecutive sequence numbers as 1057 there are octets of data and SYN or FIN flags in the segment. 1059 Under normal conditions, TCP implementations keep track of the next 1060 sequence number to emit and the oldest awaiting acknowledgment so as 1061 to avoid mistakenly using a sequence number over before its first use 1062 has been acknowledged. This alone does not guarantee that old 1063 duplicate data is drained from the net, so the sequence space has 1064 been made very large to reduce the probability that a wandering 1065 duplicate will cause trouble upon arrival. At 2 megabits/sec. it 1066 takes 4.5 hours to use up 2**32 octets of sequence space. Since the 1067 maximum segment lifetime in the net is not likely to exceed a few 1068 tens of seconds, this is deemed ample protection for foreseeable 1069 nets, even if data rates escalate to 10's of megabits/sec. At 100 1070 megabits/sec, the cycle time is 5.4 minutes, which may be a little 1071 short, but still within reason. 1073 The basic duplicate detection and sequencing algorithm in TCP can be 1074 defeated, however, if a source TCP endpoint does not have any memory 1075 of the sequence numbers it last used on a given connection. For 1076 example, if the TCP implementation were to start all connections with 1077 sequence number 0, then upon the host rebooting, a TCP peer might re- 1078 form an earlier connection (possibly after half-open connection 1079 resolution) and emit packets with sequence numbers identical to or 1080 overlapping with packets still in the network, which were emitted on 1081 an earlier incarnation of the same connection. In the absence of 1082 knowledge about the sequence numbers used on a particular connection, 1083 the TCP specification recommends that the source delay for MSL 1084 seconds before emitting segments on the connection, to allow time for 1085 segments from the earlier connection incarnation to drain from the 1086 system. 1088 Even hosts that can remember the time of day and used it to select 1089 initial sequence number values are not immune from this problem 1090 (i.e., even if time of day is used to select an initial sequence 1091 number for each new connection incarnation). 1093 Suppose, for example, that a connection is opened starting with 1094 sequence number S. Suppose that this connection is not used much and 1095 that eventually the initial sequence number function (ISN(t)) takes 1096 on a value equal to the sequence number, say S1, of the last segment 1097 sent by this TCP endpoint on a particular connection. Now suppose, 1098 at this instant, the host reboots and establishes a new incarnation 1099 of the connection. The initial sequence number chosen is S1 = ISN(t) 1100 -- last used sequence number on old incarnation of connection! If 1101 the recovery occurs quickly enough, any old duplicates in the net 1102 bearing sequence numbers in the neighborhood of S1 may arrive and be 1103 treated as new packets by the receiver of the new incarnation of the 1104 connection. 1106 The problem is that the recovering host may not know for how long it 1107 was down between rebooting nor does it know whether there are still 1108 old duplicates in the system from earlier connection incarnations. 1110 One way to deal with this problem is to deliberately delay emitting 1111 segments for one MSL after recovery from a reboot - this is the 1112 "quiet time" specification. Hosts that prefer to avoid waiting are 1113 willing to risk possible confusion of old and new packets at a given 1114 destination may choose not to wait for the "quiet time". 1115 Implementors may provide TCP users with the ability to select on a 1116 connection by connection basis whether to wait after a reboot, or may 1117 informally implement the "quiet time" for all connections. 1118 Obviously, even where a user selects to "wait," this is not necessary 1119 after the host has been "up" for at least MSL seconds. 1121 To summarize: every segment emitted occupies one or more sequence 1122 numbers in the sequence space, the numbers occupied by a segment are 1123 "busy" or "in use" until MSL seconds have passed, upon rebooting a 1124 block of space-time is occupied by the octets and SYN or FIN flags of 1125 the last emitted segment, if a new connection is started too soon and 1126 uses any of the sequence numbers in the space-time footprint of the 1127 last segment of the previous connection incarnation, there is a 1128 potential sequence number overlap area that could cause confusion at 1129 the receiver. 1131 3.5. Establishing a connection 1133 The "three-way handshake" is the procedure used to establish a 1134 connection. This procedure normally is initiated by one TCP peer and 1135 responded to by another TCP peer. The procedure also works if two 1136 TCP peers simultaneously initiate the procedure. When simultaneous 1137 open occurs, each TCP peer receives a "SYN" segment that carries no 1138 acknowledgment after it has sent a "SYN". Of course, the arrival of 1139 an old duplicate "SYN" segment can potentially make it appear, to the 1140 recipient, that a simultaneous connection initiation is in progress. 1141 Proper use of "reset" segments can disambiguate these cases. 1143 Several examples of connection initiation follow. Although these 1144 examples do not show connection synchronization using data-carrying 1145 segments, this is perfectly legitimate, so long as the receiving TCP 1146 endpoint doesn't deliver the data to the user until it is clear the 1147 data is valid (e.g., the data is buffered at the receiver until the 1148 connection reaches the ESTABLISHED state, given that the three-way 1149 handshake reduces the possibility of false connections). It is the 1150 implementation of a trade-off between memory and messages to provide 1151 information for this checking. 1153 The simplest 3WHS is shown in Figure 6. The figures should be 1154 interpreted in the following way. Each line is numbered for 1155 reference purposes. Right arrows (-->) indicate departure of a TCP 1156 segment from TCP peer A to TCP peer B, or arrival of a segment at B 1157 from A. Left arrows (<--), indicate the reverse. Ellipsis (...) 1158 indicates a segment that is still in the network (delayed). Comments 1159 appear in parentheses. TCP connection states represent the state 1160 AFTER the departure or arrival of the segment (whose contents are 1161 shown in the center of each line). Segment contents are shown in 1162 abbreviated form, with sequence number, control flags, and ACK field. 1163 Other fields such as window, addresses, lengths, and text have been 1164 left out in the interest of clarity. 1166 TCP Peer A TCP Peer B 1168 1. CLOSED LISTEN 1170 2. SYN-SENT --> --> SYN-RECEIVED 1172 3. ESTABLISHED <-- <-- SYN-RECEIVED 1174 4. ESTABLISHED --> --> ESTABLISHED 1176 5. ESTABLISHED --> --> ESTABLISHED 1178 Figure 6: Basic 3-Way Handshake for Connection Synchronization 1180 In line 2 of Figure 6, TCP Peer A begins by sending a SYN segment 1181 indicating that it will use sequence numbers starting with sequence 1182 number 100. In line 3, TCP Peer B sends a SYN and acknowledges the 1183 SYN it received from TCP Peer A. Note that the acknowledgment field 1184 indicates TCP Peer B is now expecting to hear sequence 101, 1185 acknowledging the SYN that occupied sequence 100. 1187 At line 4, TCP Peer A responds with an empty segment containing an 1188 ACK for TCP Peer B's SYN; and in line 5, TCP Peer A sends some data. 1189 Note that the sequence number of the segment in line 5 is the same as 1190 in line 4 because the ACK does not occupy sequence number space (if 1191 it did, we would wind up ACKing ACKs!). 1193 Simultaneous initiation is only slightly more complex, as is shown in 1194 Figure 7. Each TCP peer's connection state cycles from CLOSED to 1195 SYN-SENT to SYN-RECEIVED to ESTABLISHED. 1197 TCP Peer A TCP Peer B 1199 1. CLOSED CLOSED 1201 2. SYN-SENT --> ... 1203 3. SYN-RECEIVED <-- <-- SYN-SENT 1205 4. ... --> SYN-RECEIVED 1207 5. SYN-RECEIVED --> ... 1209 6. ESTABLISHED <-- <-- SYN-RECEIVED 1211 7. ... --> ESTABLISHED 1213 Figure 7: Simultaneous Connection Synchronization 1215 A TCP implementation MUST support simultaneous open attempts (MUST- 1216 10). 1218 Note that a TCP implementation MUST keep track of whether a 1219 connection has reached SYN-RECEIVED state as the result of a passive 1220 OPEN or an active OPEN (MUST-11). 1222 The principal reason for the three-way handshake is to prevent old 1223 duplicate connection initiations from causing confusion. To deal 1224 with this, a special control message, reset, is specified. If the 1225 receiving TCP peer is in a non-synchronized state (i.e., SYN-SENT, 1226 SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset. 1227 If the TCP peer is in one of the synchronized states (ESTABLISHED, 1228 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it 1229 aborts the connection and informs its user. We discuss this latter 1230 case under "half-open" connections below. 1232 TCP Peer A TCP Peer B 1234 1. CLOSED LISTEN 1236 2. SYN-SENT --> ... 1238 3. (duplicate) ... --> SYN-RECEIVED 1240 4. SYN-SENT <-- <-- SYN-RECEIVED 1242 5. SYN-SENT --> --> LISTEN 1244 6. ... --> SYN-RECEIVED 1246 7. ESTABLISHED <-- <-- SYN-RECEIVED 1248 8. ESTABLISHED --> --> ESTABLISHED 1250 Figure 8: Recovery from Old Duplicate SYN 1252 As a simple example of recovery from old duplicates, consider 1253 Figure 8. At line 3, an old duplicate SYN arrives at TCP Peer B. 1254 TCP Peer B cannot tell that this is an old duplicate, so it responds 1255 normally (line 4). TCP Peer A detects that the ACK field is 1256 incorrect and returns a RST (reset) with its SEQ field selected to 1257 make the segment believable. TCP Peer B, on receiving the RST, 1258 returns to the LISTEN state. When the original SYN finally arrives 1259 at line 6, the synchronization proceeds normally. If the SYN at line 1260 6 had arrived before the RST, a more complex exchange might have 1261 occurred with RST's sent in both directions. 1263 Half-Open Connections and Other Anomalies 1265 An established connection is said to be "half-open" if one of the TCP 1266 peers has closed or aborted the connection at its end without the 1267 knowledge of the other, or if the two ends of the connection have 1268 become desynchronized owing to a failure or reboot that resulted in 1269 loss of memory. Such connections will automatically become reset if 1270 an attempt is made to send data in either direction. However, half- 1271 open connections are expected to be unusual. 1273 If at site A the connection no longer exists, then an attempt by the 1274 user at site B to send any data on it will result in the site B TCP 1275 endpoint receiving a reset control message. Such a message indicates 1276 to the site B TCP endpoint that something is wrong, and it is 1277 expected to abort the connection. 1279 Assume that two user processes A and B are communicating with one 1280 another when a failure or reboot occurs causing loss of memory to A's 1281 TCP implementation. Depending on the operating system supporting A's 1282 TCP implementation, it is likely that some error recovery mechanism 1283 exists. When the TCP endpoint is up again, A is likely to start 1284 again from the beginning or from a recovery point. As a result, A 1285 will probably try to OPEN the connection again or try to SEND on the 1286 connection it believes open. In the latter case, it receives the 1287 error message "connection not open" from the local (A's) TCP 1288 implementation. In an attempt to establish the connection, A's TCP 1289 implementation will send a segment containing SYN. This scenario 1290 leads to the example shown in Figure 9. After TCP Peer A reboots, 1291 the user attempts to re-open the connection. TCP Peer B, in the 1292 meantime, thinks the connection is open. 1294 TCP Peer A TCP Peer B 1296 1. (REBOOT) (send 300,receive 100) 1298 2. CLOSED ESTABLISHED 1300 3. SYN-SENT --> --> (??) 1302 4. (!!) <-- <-- ESTABLISHED 1304 5. SYN-SENT --> --> (Abort!!) 1306 6. SYN-SENT CLOSED 1308 7. SYN-SENT --> --> 1310 Figure 9: Half-Open Connection Discovery 1312 When the SYN arrives at line 3, TCP Peer B, being in a synchronized 1313 state, and the incoming segment outside the window, responds with an 1314 acknowledgment indicating what sequence it next expects to hear (ACK 1315 100). TCP Peer A sees that this segment does not acknowledge 1316 anything it sent and, being unsynchronized, sends a reset (RST) 1317 because it has detected a half-open connection. TCP Peer B aborts at 1318 line 5. TCP Peer A will continue to try to establish the connection; 1319 the problem is now reduced to the basic 3-way handshake of Figure 6. 1321 An interesting alternative case occurs when TCP Peer A reboots and 1322 TCP Peer B tries to send data on what it thinks is a synchronized 1323 connection. This is illustrated in Figure 10. In this case, the 1324 data arriving at TCP Peer A from TCP Peer B (line 2) is unacceptable 1325 because no such connection exists, so TCP Peer A sends a RST. The 1326 RST is acceptable so TCP Peer B processes it and aborts the 1327 connection. 1329 TCP Peer A TCP Peer B 1331 1. (REBOOT) (send 300,receive 100) 1333 2. (??) <-- <-- ESTABLISHED 1335 3. --> --> (ABORT!!) 1337 Figure 10: Active Side Causes Half-Open Connection Discovery 1339 In Figure 11, two TCP Peers A and B with passive connections waiting 1340 for SYN are depicted. An old duplicate arriving at TCP Peer B (line 1341 2) stirs B into action. A SYN-ACK is returned (line 3) and causes 1342 TCP A to generate a RST (the ACK in line 3 is not acceptable). TCP 1343 Peer B accepts the reset and returns to its passive LISTEN state. 1345 TCP Peer A TCP Peer B 1347 1. LISTEN LISTEN 1349 2. ... --> SYN-RECEIVED 1351 3. (??) <-- <-- SYN-RECEIVED 1353 4. --> --> (return to LISTEN!) 1355 5. LISTEN LISTEN 1357 Figure 11: Old Duplicate SYN Initiates a Reset on two Passive Sockets 1359 A variety of other cases are possible, all of which are accounted for 1360 by the following rules for RST generation and processing. 1362 Reset Generation 1363 A TCP user or application can issue a reset on a connection at any 1364 time, though reset events are also generated by the protocol itself 1365 when various error conditions occur, as described below. The side of 1366 a connection issuing a reset should enter the TIME-WAIT state, as 1367 this generally helps to reduce the load on busy servers for reasons 1368 described in [69]. 1370 As a general rule, reset (RST) is sent whenever a segment arrives 1371 that apparently is not intended for the current connection. A reset 1372 must not be sent if it is not clear that this is the case. 1374 There are three groups of states: 1376 1. If the connection does not exist (CLOSED) then a reset is sent 1377 in response to any incoming segment except another reset. A SYN 1378 segment that does not match an existing connection is rejected by 1379 this means. 1381 If the incoming segment has the ACK bit set, the reset takes its 1382 sequence number from the ACK field of the segment, otherwise the 1383 reset has sequence number zero and the ACK field is set to the sum 1384 of the sequence number and segment length of the incoming segment. 1385 The connection remains in the CLOSED state. 1387 2. If the connection is in any non-synchronized state (LISTEN, 1388 SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges 1389 something not yet sent (the segment carries an unacceptable ACK), 1390 or if an incoming segment has a security level or compartment that 1391 does not exactly match the level and compartment requested for the 1392 connection, a reset is sent. 1394 If the incoming segment has an ACK field, the reset takes its 1395 sequence number from the ACK field of the segment, otherwise the 1396 reset has sequence number zero and the ACK field is set to the sum 1397 of the sequence number and segment length of the incoming segment. 1398 The connection remains in the same state. 1400 3. If the connection is in a synchronized state (ESTABLISHED, 1401 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), 1402 any unacceptable segment (out of window sequence number or 1403 unacceptable acknowledgment number) must be responded to with an 1404 empty acknowledgment segment (without any user data) containing 1405 the current send-sequence number and an acknowledgment indicating 1406 the next sequence number expected to be received, and the 1407 connection remains in the same state. 1409 If an incoming segment has a security level, or compartment that 1410 does not exactly match the level and compartment requested for the 1411 connection, a reset is sent and the connection goes to the CLOSED 1412 state. The reset takes its sequence number from the ACK field of 1413 the incoming segment. 1415 Reset Processing 1417 In all states except SYN-SENT, all reset (RST) segments are validated 1418 by checking their SEQ-fields. A reset is valid if its sequence 1419 number is in the window. In the SYN-SENT state (a RST received in 1420 response to an initial SYN), the RST is acceptable if the ACK field 1421 acknowledges the SYN. 1423 The receiver of a RST first validates it, then changes state. If the 1424 receiver was in the LISTEN state, it ignores it. If the receiver was 1425 in SYN-RECEIVED state and had previously been in the LISTEN state, 1426 then the receiver returns to the LISTEN state, otherwise the receiver 1427 aborts the connection and goes to the CLOSED state. If the receiver 1428 was in any other state, it aborts the connection and advises the user 1429 and goes to the CLOSED state. 1431 TCP implementations SHOULD allow a received RST segment to include 1432 data (SHLD-2). 1434 3.6. Closing a Connection 1436 CLOSE is an operation meaning "I have no more data to send." The 1437 notion of closing a full-duplex connection is subject to ambiguous 1438 interpretation, of course, since it may not be obvious how to treat 1439 the receiving side of the connection. We have chosen to treat CLOSE 1440 in a simplex fashion. The user who CLOSEs may continue to RECEIVE 1441 until the TCP receiver is told that the remote peer has CLOSED also. 1442 Thus, a program could initiate several SENDs followed by a CLOSE, and 1443 then continue to RECEIVE until signaled that a RECEIVE failed because 1444 the remote peer has CLOSED. The TCP implementation will signal a 1445 user, even if no RECEIVEs are outstanding, that the remote peer has 1446 closed, so the user can terminate his side gracefully. A TCP 1447 implementation will reliably deliver all buffers SENT before the 1448 connection was CLOSED so a user who expects no data in return need 1449 only wait to hear the connection was CLOSED successfully to know that 1450 all their data was received at the destination TCP endpoint. Users 1451 must keep reading connections they close for sending until the TCP 1452 implementation indicates there is no more data. 1454 There are essentially three cases: 1456 1) The user initiates by telling the TCP implementation to CLOSE 1457 the connection (TCP Peer A in Figure 12). 1459 2) The remote TCP endpoint initiates by sending a FIN control 1460 signal (TCP Peer B in Figure 12). 1462 3) Both users CLOSE simultaneously (Figure 13). 1464 Case 1: Local user initiates the close 1465 In this case, a FIN segment can be constructed and placed on the 1466 outgoing segment queue. No further SENDs from the user will be 1467 accepted by the TCP implementation, and it enters the FIN-WAIT-1 1468 state. RECEIVEs are allowed in this state. All segments 1469 preceding and including FIN will be retransmitted until 1470 acknowledged. When the other TCP peer has both acknowledged the 1471 FIN and sent a FIN of its own, the first TCP peer can ACK this 1472 FIN. Note that a TCP endpoint receiving a FIN will ACK but not 1473 send its own FIN until its user has CLOSED the connection also. 1475 Case 2: TCP endpoint receives a FIN from the network 1476 If an unsolicited FIN arrives from the network, the receiving TCP 1477 endpoint can ACK it and tell the user that the connection is 1478 closing. The user will respond with a CLOSE, upon which the TCP 1479 endpoint can send a FIN to the other TCP peer after sending any 1480 remaining data. The TCP endpoint then waits until its own FIN is 1481 acknowledged whereupon it deletes the connection. If an ACK is 1482 not forthcoming, after the user timeout the connection is aborted 1483 and the user is told. 1485 Case 3: Both users close simultaneously 1486 A simultaneous CLOSE by users at both ends of a connection causes 1487 FIN segments to be exchanged (Figure 13). When all segments 1488 preceding the FINs have been processed and acknowledged, each TCP 1489 peer can ACK the FIN it has received. Both will, upon receiving 1490 these ACKs, delete the connection. 1492 TCP Peer A TCP Peer B 1494 1. ESTABLISHED ESTABLISHED 1496 2. (Close) 1497 FIN-WAIT-1 --> --> CLOSE-WAIT 1499 3. FIN-WAIT-2 <-- <-- CLOSE-WAIT 1501 4. (Close) 1502 TIME-WAIT <-- <-- LAST-ACK 1504 5. TIME-WAIT --> --> CLOSED 1506 6. (2 MSL) 1507 CLOSED 1509 Figure 12: Normal Close Sequence 1511 TCP Peer A TCP Peer B 1513 1. ESTABLISHED ESTABLISHED 1515 2. (Close) (Close) 1516 FIN-WAIT-1 --> ... FIN-WAIT-1 1517 <-- <-- 1518 ... --> 1520 3. CLOSING --> ... CLOSING 1521 <-- <-- 1522 ... --> 1524 4. TIME-WAIT TIME-WAIT 1525 (2 MSL) (2 MSL) 1526 CLOSED CLOSED 1528 Figure 13: Simultaneous Close Sequence 1530 A TCP connection may terminate in two ways: (1) the normal TCP close 1531 sequence using a FIN handshake (Figure 12), and (2) an "abort" in 1532 which one or more RST segments are sent and the connection state is 1533 immediately discarded. If the local TCP connection is closed by the 1534 remote side due to a FIN or RST received from the remote side, then 1535 the local application MUST be informed whether it closed normally or 1536 was aborted (MUST-12). 1538 3.6.1. Half-Closed Connections 1540 The normal TCP close sequence delivers buffered data reliably in both 1541 directions. Since the two directions of a TCP connection are closed 1542 independently, it is possible for a connection to be "half closed," 1543 i.e., closed in only one direction, and a host is permitted to 1544 continue sending data in the open direction on a half-closed 1545 connection. 1547 A host MAY implement a "half-duplex" TCP close sequence, so that an 1548 application that has called CLOSE cannot continue to read data from 1549 the connection (MAY-1). If such a host issues a CLOSE call while 1550 received data is still pending in the TCP connection, or if new data 1551 is received after CLOSE is called, its TCP implementation SHOULD send 1552 a RST to show that data was lost (SHLD-3). See [22] section 2.17 for 1553 discussion. 1555 When a connection is closed actively, it MUST linger in the TIME-WAIT 1556 state for a time 2xMSL (Maximum Segment Lifetime) (MUST-13). 1557 However, it MAY accept a new SYN from the remote TCP endpoint to 1558 reopen the connection directly from TIME-WAIT state (MAY-2), if it: 1560 (1) assigns its initial sequence number for the new connection to 1561 be larger than the largest sequence number it used on the previous 1562 connection incarnation, and 1564 (2) returns to TIME-WAIT state if the SYN turns out to be an old 1565 duplicate. 1567 When the TCP Timestamp options are available, an improved algorithm 1568 is described in [39] in order to support higher connection 1569 establishment rates. This algorithm for reducing TIME-WAIT is a Best 1570 Current Practice that SHOULD be implemented, since timestamp options 1571 are commonly used, and using them to reduce TIME-WAIT provides 1572 benefits for busy Internet servers (SHLD-4). 1574 3.7. Segmentation 1576 The term "segmentation" refers to the activity TCP performs when 1577 ingesting a stream of bytes from a sending application and 1578 packetizing that stream of bytes into TCP segments. Individual TCP 1579 segments often do not correspond one-for-one to individual send (or 1580 socket write) calls from the application. Applications may perform 1581 writes at the granularity of messages in the upper layer protocol, 1582 but TCP guarantees no boundary coherence between the TCP segments 1583 sent and received versus user application data read or write buffer 1584 boundaries. In some specific protocols, such as Remote Direct Memory 1585 Access (RDMA) using Direct Data Placement (DDP) and Marker PDU 1586 Aligned Framing (MPA) [32], there are performance optimizations 1587 possible when the relation between TCP segments and application data 1588 units can be controlled, and MPA includes a specific mechanism for 1589 detecting and verifying this relationship between TCP segments and 1590 application message data structures, but this is specific to 1591 applications like RDMA. In general, multiple goals influence the 1592 sizing of TCP segments created by a TCP implementation. 1594 Goals driving the sending of larger segments include: 1596 * Reducing the number of packets in flight within the network. 1598 * Increasing processing efficiency and potential performance by 1599 enabling a smaller number of interrupts and inter-layer 1600 interactions. 1602 * Limiting the overhead of TCP headers. 1604 Note that the performance benefits of sending larger segments may 1605 decrease as the size increases, and there may be boundaries where 1606 advantages are reversed. For instance, on some implementation 1607 architectures, 1025 bytes within a segment could lead to worse 1608 performance than 1024 bytes, due purely to data alignment on copy 1609 operations. 1611 Goals driving the sending of smaller segments include: 1613 * Avoiding sending a TCP segment that would result in an IP datagram 1614 larger than the smallest MTU along an IP network path, because 1615 this results in either packet loss or packet fragmentation. 1616 Making matters worse, some firewalls or middleboxes may drop 1617 fragmented packets or ICMP messages related to fragmentation. 1619 * Preventing delays to the application data stream, especially when 1620 TCP is waiting on the application to generate more data, or when 1621 the application is waiting on an event or input from its peer in 1622 order to generate more data. 1624 * Enabling "fate sharing" between TCP segments and lower-layer data 1625 units (e.g. below IP, for links with cell or frame sizes smaller 1626 than the IP MTU). 1628 Towards meeting these competing sets of goals, TCP includes several 1629 mechanisms, including the Maximum Segment Size option, Path MTU 1630 Discovery, the Nagle algorithm, and support for IPv6 Jumbograms, as 1631 discussed in the following subsections. 1633 3.7.1. Maximum Segment Size Option 1635 TCP endpoints MUST implement both sending and receiving the MSS 1636 option (MUST-14). 1638 TCP implementations SHOULD send an MSS option in every SYN segment 1639 when its receive MSS differs from the default 536 for IPv4 or 1220 1640 for IPv6 (SHLD-5), and MAY send it always (MAY-3). 1642 If an MSS option is not received at connection setup, TCP 1643 implementations MUST assume a default send MSS of 536 (576-40) for 1644 IPv4 or 1220 (1280 - 60) for IPv6 (MUST-15). 1646 The maximum size of a segment that TCP endpoint really sends, the 1647 "effective send MSS," MUST be the smaller (MUST-16) of the send MSS 1648 (that reflects the available reassembly buffer size at the remote 1649 host, the EMTU_R [18]) and the largest transmission size permitted by 1650 the IP layer (EMTU_S [18]): 1652 Eff.snd.MSS = 1654 min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize 1656 where: 1658 * SendMSS is the MSS value received from the remote host, or the 1659 default 536 for IPv4 or 1220 for IPv6, if no MSS option is 1660 received. 1662 * MMS_S is the maximum size for a transport-layer message that TCP 1663 may send. 1665 * TCPhdrsize is the size of the fixed TCP header and any options. 1666 This is 20 in the (rare) case that no options are present, but may 1667 be larger if TCP options are to be sent. Note that some options 1668 might not be included on all segments, but that for each segment 1669 sent, the sender should adjust the data length accordingly, within 1670 the Eff.snd.MSS. 1672 * IPoptionsize is the size of any IPv4 options or IPv6 extension 1673 headers associated with a TCP connection. Note that some options 1674 or extension headers might not be included on all packets, but 1675 that for each segment sent, the sender should adjust the data 1676 length accordingly, within the Eff.snd.MSS. 1678 The MSS value to be sent in an MSS option should be equal to the 1679 effective MTU minus the fixed IP and TCP headers. By ignoring both 1680 IP and TCP options when calculating the value for the MSS option, if 1681 there are any IP or TCP options to be sent in a packet, then the 1682 sender must decrease the size of the TCP data accordingly. RFC 6691 1683 [42] discusses this in greater detail. 1685 The MSS value to be sent in an MSS option must be less than or equal 1686 to: 1688 MMS_R - 20 1690 where MMS_R is the maximum size for a transport-layer message that 1691 can be received (and reassembled at the IP layer) (MUST-67). TCP 1692 obtains MMS_R and MMS_S from the IP layer; see the generic call 1693 GET_MAXSIZES in Section 3.4 of RFC 1122. These are defined in terms 1694 of their IP MTU equivalents, EMTU_R and EMTU_S [18]. 1696 When TCP is used in a situation where either the IP or TCP headers 1697 are not fixed, the sender must reduce the amount of TCP data in any 1698 given packet by the number of octets used by the IP and TCP options. 1699 This has been a point of confusion historically, as explained in RFC 1700 6691, Section 3.1. 1702 3.7.2. Path MTU Discovery 1704 A TCP implementation may be aware of the MTU on directly connected 1705 links, but will rarely have insight about MTUs across an entire 1706 network path. For IPv4, RFC 1122 recommends an IP-layer default 1707 effective MTU of less than or equal to 576 for destinations not 1708 directly connected, and for IPv6 this would be 1280. Using these 1709 fixed values limits TCP connection performance and efficiency. 1710 Instead, implementation of Path MTU Discovery (PMTUD) and 1711 Packetization Layer Path MTU Discovery (PLPMTUD) is strongly 1712 recommended in order for TCP to improve segmentation decisions. Both 1713 PMTUD and PLPMTUD help TCP choose segment sizes that avoid both on- 1714 path (for IPv4) and source fragmentation (IPv4 and IPv6). 1716 PMTUD for IPv4 [2] or IPv6 [14] is implemented in conjunction between 1717 TCP, IP, and ICMP protocols. It relies both on avoiding source 1718 fragmentation and setting the IPv4 DF (don't fragment) flag, the 1719 latter to inhibit on-path fragmentation. It relies on ICMP errors 1720 from routers along the path, whenever a segment is too large to 1721 traverse a link. Several adjustments to a TCP implementation with 1722 PMTUD are described in RFC 2923 in order to deal with problems 1723 experienced in practice [25]. PLPMTUD [29] is a Standards Track 1724 improvement to PMTUD that relaxes the requirement for ICMP support 1725 across a path, and improves performance in cases where ICMP is not 1726 consistently conveyed, but still tries to avoid source fragmentation. 1727 The mechanisms in all four of these RFCs are recommended to be 1728 included in TCP implementations. 1730 The TCP MSS option specifies an upper bound for the size of packets 1731 that can be received (see [42]). Hence, setting the value in the MSS 1732 option too small can impact the ability for PMTUD or PLPMTUD to find 1733 a larger path MTU. RFC 1191 discusses this implication of many older 1734 TCP implementations setting the TCP MSS to 536 (corresponding to the 1735 IPv4 576 byte default MTU) for non-local destinations, rather than 1736 deriving it from the MTUs of connected interfaces as recommended. 1738 3.7.3. Interfaces with Variable MTU Values 1740 The effective MTU can sometimes vary, as when used with variable 1741 compression, e.g., RObust Header Compression (ROHC) [35]. It is 1742 tempting for a TCP implementation to advertise the largest possible 1743 MSS, to support the most efficient use of compressed payloads. 1744 Unfortunately, some compression schemes occasionally need to transmit 1745 full headers (and thus smaller payloads) to resynchronize state at 1746 their endpoint compressors/decompressors. If the largest MTU is used 1747 to calculate the value to advertise in the MSS option, TCP 1748 retransmission may interfere with compressor resynchronization. 1750 As a result, when the effective MTU of an interface varies packet-to- 1751 packet, TCP implementations SHOULD use the smallest effective MTU of 1752 the interface to calculate the value to advertise in the MSS option 1753 (SHLD-6). 1755 3.7.4. Nagle Algorithm 1757 The "Nagle algorithm" was described in RFC 896 [17] and was 1758 recommended in RFC 1122 [18] for mitigation of an early problem of 1759 too many small packets being generated. It has been implemented in 1760 most current TCP code bases, sometimes with minor variations (see 1761 Appendix A.3). 1763 If there is unacknowledged data (i.e., SND.NXT > SND.UNA), then the 1764 sending TCP endpoint buffers all user data (regardless of the PSH 1765 bit), until the outstanding data has been acknowledged or until the 1766 TCP endpoint can send a full-sized segment (Eff.snd.MSS bytes). 1768 A TCP implementation SHOULD implement the Nagle Algorithm to coalesce 1769 short segments (SHLD-7). However, there MUST be a way for an 1770 application to disable the Nagle algorithm on an individual 1771 connection (MUST-17). In all cases, sending data is also subject to 1772 the limitation imposed by the Slow Start algorithm [9]. 1774 Since there can be problematic interactions between the Nagle 1775 Algorithm and delayed acknowledgements, some implementations use 1776 minor variations of the Nagle algorithm, such as the one described in 1777 Appendix A.3. 1779 3.7.5. IPv6 Jumbograms 1781 In order to support TCP over IPv6 Jumbograms, implementations need to 1782 be able to send TCP segments larger than the 64KB limit that the MSS 1783 option can convey. RFC 2675 [5] defines that an MSS value of 65,535 1784 bytes is to be treated as infinity, and Path MTU Discovery [14] is 1785 used to determine the actual MSS. 1787 The Jumbo Payload option need not be implemented or understood by 1788 IPv6 nodes that do not support attachment to links with a MTU greater 1789 than 65,575 [5], and the present IPv6 Node Requirements does not 1790 include support for Jumbograms [53]. 1792 3.8. Data Communication 1794 Once the connection is established data is communicated by the 1795 exchange of segments. Because segments may be lost due to errors 1796 (checksum test failure), or network congestion, TCP uses 1797 retransmission to ensure delivery of every segment. Duplicate 1798 segments may arrive due to network or TCP retransmission. As 1799 discussed in the section on sequence numbers the TCP implementation 1800 performs certain tests on the sequence and acknowledgment numbers in 1801 the segments to verify their acceptability. 1803 The sender of data keeps track of the next sequence number to use in 1804 the variable SND.NXT. The receiver of data keeps track of the next 1805 sequence number to expect in the variable RCV.NXT. The sender of 1806 data keeps track of the oldest unacknowledged sequence number in the 1807 variable SND.UNA. If the data flow is momentarily idle and all data 1808 sent has been acknowledged then the three variables will be equal. 1810 When the sender creates a segment and transmits it the sender 1811 advances SND.NXT. When the receiver accepts a segment it advances 1812 RCV.NXT and sends an acknowledgment. When the data sender receives 1813 an acknowledgment it advances SND.UNA. The extent to which the 1814 values of these variables differ is a measure of the delay in the 1815 communication. The amount by which the variables are advanced is the 1816 length of the data and SYN or FIN flags in the segment. Note that 1817 once in the ESTABLISHED state all segments must carry current 1818 acknowledgment information. 1820 The CLOSE user call implies a push function (see Section 3.9.1), as 1821 does the FIN control flag in an incoming segment. 1823 3.8.1. Retransmission Timeout 1825 Because of the variability of the networks that compose an 1826 internetwork system and the wide range of uses of TCP connections the 1827 retransmission timeout (RTO) must be dynamically determined. 1829 The RTO MUST be computed according to the algorithm in [10], 1830 including Karn's algorithm for taking RTT samples (MUST-18). 1832 RFC 793 contains an early example procedure for computing the RTO. 1833 This was then replaced by the algorithm described in RFC 1122, and 1834 subsequently updated in RFC 2988, and then again in RFC 6298. 1836 RFC 1122 allows that if a retransmitted packet is identical to the 1837 original packet (which implies not only that the data boundaries have 1838 not changed, but also that none of the headers have changed), then 1839 the same IPv4 Identification field MAY be used (see Section 3.2.1.5 1840 of RFC 1122) (MAY-4). The same IP identification field may be reused 1841 anyways, since it is only meaningful when a datagram is fragmented 1842 [43]. TCP implementations should not rely on or typically interact 1843 with this IPv4 header field in any way. It is not a reasonable way 1844 to either indicate duplicate sent segments, nor to identify duplicate 1845 received segments. 1847 3.8.2. TCP Congestion Control 1849 RFC 2914 [6] explains the importance of congestion control for the 1850 Internet. 1852 RFC 1122 required implementation of Van Jacobson's congestion control 1853 algorithms slow start and congestion avoidance together with 1854 exponential back-off for successive RTO values for the same segment. 1855 RFC 2581 provided IETF Standards Track description of slow start and 1856 congestion avoidance, along with fast retransmit and fast recovery. 1857 RFC 5681 is the current description of these algorithms and is the 1858 current Standards Track specification providing guidelines for TCP 1859 congestion control. RFC 6298 describes exponential back-off of RTO 1860 values, including keeping the backed-off value until a subsequent 1861 segment with new data has been sent and acknowledged without 1862 retransmission. 1864 A TCP endpoint MUST implement the basic congestion control algorithms 1865 slow start, congestion avoidance, and exponential back-off of RTO to 1866 avoid creating congestion collapse conditions (MUST-19). RFC 5681 1867 and RFC 6298 describe the basic algorithms on the IETF Standards 1868 Track that are broadly applicable. Multiple other suitable 1869 algorithms exist and have been widely used. Many TCP implementations 1870 support a set of alternative algorithms that can be configured for 1871 use on the endpoint. An endpoint MAY implement such alternative 1872 algorithms provided that the algorithms are conformant with the TCP 1873 specifications from the IETF Standards Track as described in RFC 1874 2914, RFC 5033 [8], and RFC 8961 [15] (MAY-18). 1876 Explicit Congestion Notification (ECN) was defined in RFC 3168 and is 1877 an IETF Standards Track enhancement that has many benefits [50]. 1879 A TCP endpoint SHOULD implement ECN as described in RFC 3168 (SHLD- 1880 8). 1882 3.8.3. TCP Connection Failures 1884 Excessive retransmission of the same segment by a TCP endpoint 1885 indicates some failure of the remote host or the Internet path. This 1886 failure may be of short or long duration. The following procedure 1887 MUST be used to handle excessive retransmissions of data segments 1888 (MUST-20): 1890 (a) There are two thresholds R1 and R2 measuring the amount of 1891 retransmission that has occurred for the same segment. R1 and R2 1892 might be measured in time units or as a count of retransmissions 1893 (with the current RTO and corresponding backoffs as a conversion 1894 factor, if needed). 1896 (b) When the number of transmissions of the same segment reaches 1897 or exceeds threshold R1, pass negative advice (see Section 3.3.1.4 1898 of [18]) to the IP layer, to trigger dead-gateway diagnosis. 1900 (c) When the number of transmissions of the same segment reaches a 1901 threshold R2 greater than R1, close the connection. 1903 (d) An application MUST (MUST-21) be able to set the value for R2 1904 for a particular connection. For example, an interactive 1905 application might set R2 to "infinity," giving the user control 1906 over when to disconnect. 1908 (e) TCP implementations SHOULD inform the application of the 1909 delivery problem (unless such information has been disabled by the 1910 application; see Asynchronous Reports section), when R1 is reached 1911 and before R2 (SHLD-9). This will allow a remote login (User 1912 Telnet) application program to inform the user, for example. 1914 The value of R1 SHOULD correspond to at least 3 retransmissions, at 1915 the current RTO (SHLD-10). The value of R2 SHOULD correspond to at 1916 least 100 seconds (SHLD-11). 1918 An attempt to open a TCP connection could fail with excessive 1919 retransmissions of the SYN segment or by receipt of a RST segment or 1920 an ICMP Port Unreachable. SYN retransmissions MUST be handled in the 1921 general way just described for data retransmissions, including 1922 notification of the application layer. 1924 However, the values of R1 and R2 may be different for SYN and data 1925 segments. In particular, R2 for a SYN segment MUST be set large 1926 enough to provide retransmission of the segment for at least 3 1927 minutes (MUST-23). The application can close the connection (i.e., 1928 give up on the open attempt) sooner, of course. 1930 3.8.4. TCP Keep-Alives 1932 A TCP connection is said to be "idle" if for some long amount of time 1933 there have been no incoming segments received and there is no new or 1934 unacknowledged data to be sent. 1936 Implementors MAY include "keep-alives" in their TCP implementations 1937 (MAY-5), although this practice is not universally accepted. Some 1938 TCP implementations, however, have included a keep-alive mechanism. 1939 To confirm that an idle connection is still active, these 1940 implementations send a probe segment designed to elicit a response 1941 from the TCP peer. Such a segment generally contains SEG.SEQ = 1942 SND.NXT-1 and may or may not contain one garbage octet of data. If 1943 keep-alives are included, the application MUST be able to turn them 1944 on or off for each TCP connection (MUST-24), and they MUST default to 1945 off (MUST-25). 1947 Keep-alive packets MUST only be sent when no sent data is 1948 outstanding, and no data or acknowledgement packets have been 1949 received for the connection within an interval (MUST-26). This 1950 interval MUST be configurable (MUST-27) and MUST default to no less 1951 than two hours (MUST-28). 1953 It is extremely important to remember that ACK segments that contain 1954 no data are not reliably transmitted by TCP. Consequently, if a 1955 keep-alive mechanism is implemented it MUST NOT interpret failure to 1956 respond to any specific probe as a dead connection (MUST-29). 1958 An implementation SHOULD send a keep-alive segment with no data 1959 (SHLD-12); however, it MAY be configurable to send a keep-alive 1960 segment containing one garbage octet (MAY-6), for compatibility with 1961 erroneous TCP implementations. 1963 3.8.5. The Communication of Urgent Information 1965 As a result of implementation differences and middlebox interactions, 1966 new applications SHOULD NOT employ the TCP urgent mechanism (SHLD- 1967 13). However, TCP implementations MUST still include support for the 1968 urgent mechanism (MUST-30). Details can be found in RFC 6093 [38]. 1970 The objective of the TCP urgent mechanism is to allow the sending 1971 user to stimulate the receiving user to accept some urgent data and 1972 to permit the receiving TCP endpoint to indicate to the receiving 1973 user when all the currently known urgent data has been received by 1974 the user. 1976 This mechanism permits a point in the data stream to be designated as 1977 the end of urgent information. Whenever this point is in advance of 1978 the receive sequence number (RCV.NXT) at the receiving TCP endpoint, 1979 that TCP must tell the user to go into "urgent mode"; when the 1980 receive sequence number catches up to the urgent pointer, the TCP 1981 implementation must tell user to go into "normal mode". If the 1982 urgent pointer is updated while the user is in "urgent mode", the 1983 update will be invisible to the user. 1985 The method employs an urgent field that is carried in all segments 1986 transmitted. The URG control flag indicates that the urgent field is 1987 meaningful and must be added to the segment sequence number to yield 1988 the urgent pointer. The absence of this flag indicates that there is 1989 no urgent data outstanding. 1991 To send an urgent indication the user must also send at least one 1992 data octet. If the sending user also indicates a push, timely 1993 delivery of the urgent information to the destination process is 1994 enhanced. Note that because changes in the urgent pointer correspond 1995 to data being written by a sending application, the urgent pointer 1996 can not "recede" in the sequence space, but a TCP receiver should be 1997 robust to invalid urgent pointer values. 1999 A TCP implementation MUST support a sequence of urgent data of any 2000 length (MUST-31). [18] 2002 The urgent pointer MUST point to the sequence number of the octet 2003 following the urgent data (MUST-62). 2005 A TCP implementation MUST (MUST-32) inform the application layer 2006 asynchronously whenever it receives an Urgent pointer and there was 2007 previously no pending urgent data, or whenever the Urgent pointer 2008 advances in the data stream. The TCP implementation MUST (MUST-33) 2009 provide a way for the application to learn how much urgent data 2010 remains to be read from the connection, or at least to determine 2011 whether or not more urgent data remains to be read [18]. 2013 3.8.6. Managing the Window 2015 The window sent in each segment indicates the range of sequence 2016 numbers the sender of the window (the data receiver) is currently 2017 prepared to accept. There is an assumption that this is related to 2018 the currently available data buffer space available for this 2019 connection. 2021 The sending TCP endpoint packages the data to be transmitted into 2022 segments that fit the current window, and may repackage segments on 2023 the retransmission queue. Such repackaging is not required, but may 2024 be helpful. 2026 In a connection with a one-way data flow, the window information will 2027 be carried in acknowledgment segments that all have the same sequence 2028 number so there will be no way to reorder them if they arrive out of 2029 order. This is not a serious problem, but it will allow the window 2030 information to be on occasion temporarily based on old reports from 2031 the data receiver. A refinement to avoid this problem is to act on 2032 the window information from segments that carry the highest 2033 acknowledgment number (that is segments with acknowledgment number 2034 equal or greater than the highest previously received). 2036 Indicating a large window encourages transmissions. If more data 2037 arrives than can be accepted, it will be discarded. This will result 2038 in excessive retransmissions, adding unnecessarily to the load on the 2039 network and the TCP endpoints. Indicating a small window may 2040 restrict the transmission of data to the point of introducing a round 2041 trip delay between each new segment transmitted. 2043 The mechanisms provided allow a TCP endpoint to advertise a large 2044 window and to subsequently advertise a much smaller window without 2045 having accepted that much data. This, so called "shrinking the 2046 window," is strongly discouraged. The robustness principle [18] 2047 dictates that TCP peers will not shrink the window themselves, but 2048 will be prepared for such behavior on the part of other TCP peers. 2050 A TCP receiver SHOULD NOT shrink the window, i.e., move the right 2051 window edge to the left (SHLD-14). However, a sending TCP peer MUST 2052 be robust against window shrinking, which may cause the "usable 2053 window" (see Section 3.8.6.2.1) to become negative (MUST-34). 2055 If this happens, the sender SHOULD NOT send new data (SHLD-15), but 2056 SHOULD retransmit normally the old unacknowledged data between 2057 SND.UNA and SND.UNA+SND.WND (SHLD-16). The sender MAY also 2058 retransmit old data beyond SND.UNA+SND.WND (MAY-7), but SHOULD NOT 2059 time out the connection if data beyond the right window edge is not 2060 acknowledged (SHLD-17). If the window shrinks to zero, the TCP 2061 implementation MUST probe it in the standard way (described below) 2062 (MUST-35). 2064 3.8.6.1. Zero Window Probing 2066 The sending TCP peer must regularly transmit at least one octet of 2067 new data (if available) or retransmit to the receiving TCP peer even 2068 if the send window is zero, in order to "probe" the window. This 2069 retransmission is essential to guarantee that when either TCP peer 2070 has a zero window the re-opening of the window will be reliably 2071 reported to the other. This is referred to as Zero-Window Probing 2072 (ZWP) in other documents. 2074 Probing of zero (offered) windows MUST be supported (MUST-36). 2076 A TCP implementation MAY keep its offered receive window closed 2077 indefinitely (MAY-8). As long as the receiving TCP peer continues to 2078 send acknowledgments in response to the probe segments, the sending 2079 TCP peer MUST allow the connection to stay open (MUST-37). This 2080 enables TCP to function in scenarios such as the "printer ran out of 2081 paper" situation described in Section 4.2.2.17 of RFC1122. The 2082 behavior is subject to the implementation's resource management 2083 concerns, as noted in [40]. 2085 When the receiving TCP peer has a zero window and a segment arrives 2086 it must still send an acknowledgment showing its next expected 2087 sequence number and current window (zero). 2089 The transmitting host SHOULD send the first zero-window probe when a 2090 zero window has existed for the retransmission timeout period (SHLD- 2091 29) (Section 3.8.1), and SHOULD increase exponentially the interval 2092 between successive probes (SHLD-30). 2094 3.8.6.2. Silly Window Syndrome Avoidance 2096 The "Silly Window Syndrome" (SWS) is a stable pattern of small 2097 incremental window movements resulting in extremely poor TCP 2098 performance. Algorithms to avoid SWS are described below for both 2099 the sending side and the receiving side. RFC 1122 contains more 2100 detailed discussion of the SWS problem. Note that the Nagle 2101 algorithm and the sender SWS avoidance algorithm play complementary 2102 roles in improving performance. The Nagle algorithm discourages 2103 sending tiny segments when the data to be sent increases in small 2104 increments, while the SWS avoidance algorithm discourages small 2105 segments resulting from the right window edge advancing in small 2106 increments. 2108 3.8.6.2.1. Sender's Algorithm - When to Send Data 2110 A TCP implementation MUST include a SWS avoidance algorithm in the 2111 sender (MUST-38). 2113 The Nagle algorithm from Section 3.7.4 additionally describes how to 2114 coalesce short segments. 2116 The sender's SWS avoidance algorithm is more difficult than the 2117 receivers's, because the sender does not know (directly) the 2118 receiver's total buffer space RCV.BUFF. An approach that has been 2119 found to work well is for the sender to calculate Max(SND.WND), the 2120 maximum send window it has seen so far on the connection, and to use 2121 this value as an estimate of RCV.BUFF. Unfortunately, this can only 2122 be an estimate; the receiver may at any time reduce the size of 2123 RCV.BUFF. To avoid a resulting deadlock, it is necessary to have a 2124 timeout to force transmission of data, overriding the SWS avoidance 2125 algorithm. In practice, this timeout should seldom occur. 2127 The "usable window" is: 2129 U = SND.UNA + SND.WND - SND.NXT 2131 i.e., the offered window less the amount of data sent but not 2132 acknowledged. If D is the amount of data queued in the sending TCP 2133 endpoint but not yet sent, then the following set of rules is 2134 recommended. 2136 Send data: 2138 (1) if a maximum-sized segment can be sent, i.e., if: 2140 min(D,U) >= Eff.snd.MSS; 2142 (2) or if the data is pushed and all queued data can be sent now, 2143 i.e., if: 2145 [SND.NXT = SND.UNA and] PUSHED and D <= U 2147 (the bracketed condition is imposed by the Nagle algorithm); 2149 (3) or if at least a fraction Fs of the maximum window can be sent, 2150 i.e., if: 2152 [SND.NXT = SND.UNA and] 2154 min(D,U) >= Fs * Max(SND.WND); 2156 (4) or if the override timeout occurs. 2158 Here Fs is a fraction whose recommended value is 1/2. The override 2159 timeout should be in the range 0.1 - 1.0 seconds. It may be 2160 convenient to combine this timer with the timer used to probe zero 2161 windows (Section 3.8.6.1). 2163 3.8.6.2.2. Receiver's Algorithm - When to Send a Window Update 2165 A TCP implementation MUST include a SWS avoidance algorithm in the 2166 receiver (MUST-39). 2168 The receiver's SWS avoidance algorithm determines when the right 2169 window edge may be advanced; this is customarily known as "updating 2170 the window". This algorithm combines with the delayed ACK algorithm 2171 (Section 3.8.6.3) to determine when an ACK segment containing the 2172 current window will really be sent to the receiver. 2174 The solution to receiver SWS is to avoid advancing the right window 2175 edge RCV.NXT+RCV.WND in small increments, even if data is received 2176 from the network in small segments. 2178 Suppose the total receive buffer space is RCV.BUFF. At any given 2179 moment, RCV.USER octets of this total may be tied up with data that 2180 has been received and acknowledged but that the user process has not 2181 yet consumed. When the connection is quiescent, RCV.WND = RCV.BUFF 2182 and RCV.USER = 0. 2184 Keeping the right window edge fixed as data arrives and is 2185 acknowledged requires that the receiver offer less than its full 2186 buffer space, i.e., the receiver must specify a RCV.WND that keeps 2187 RCV.NXT+RCV.WND constant as RCV.NXT increases. Thus, the total 2188 buffer space RCV.BUFF is generally divided into three parts: 2190 |<------- RCV.BUFF ---------------->| 2191 1 2 3 2192 ----|---------|------------------|------|---- 2193 RCV.NXT ^ 2194 (Fixed) 2196 1 - RCV.USER = data received but not yet consumed; 2197 2 - RCV.WND = space advertised to sender; 2198 3 - Reduction = space available but not yet 2199 advertised. 2201 The suggested SWS avoidance algorithm for the receiver is to keep 2202 RCV.NXT+RCV.WND fixed until the reduction satisfies: 2204 RCV.BUFF - RCV.USER - RCV.WND >= 2206 min( Fr * RCV.BUFF, Eff.snd.MSS ) 2208 where Fr is a fraction whose recommended value is 1/2, and 2209 Eff.snd.MSS is the effective send MSS for the connection (see 2210 Section 3.7.1). When the inequality is satisfied, RCV.WND is set to 2211 RCV.BUFF-RCV.USER. 2213 Note that the general effect of this algorithm is to advance RCV.WND 2214 in increments of Eff.snd.MSS (for realistic receive buffers: 2215 Eff.snd.MSS < RCV.BUFF/2). Note also that the receiver must use its 2216 own Eff.snd.MSS, assuming it is the same as the sender's. 2218 3.8.6.3. Delayed Acknowledgements - When to Send an ACK Segment 2220 A host that is receiving a stream of TCP data segments can increase 2221 efficiency in both the Internet and the hosts by sending fewer than 2222 one ACK (acknowledgment) segment per data segment received; this is 2223 known as a "delayed ACK". 2225 A TCP endpoint SHOULD implement a delayed ACK (SHLD-18), but an ACK 2226 should not be excessively delayed; in particular, the delay MUST be 2227 less than 0.5 seconds (MUST-40). An ACK SHOULD be generated for at 2228 least every second full-sized segment or 2*RMSS bytes of new data 2229 (where RMSS is the MSS specified by the TCP endpoint receiving the 2230 segments to be acknowledged, or the default value if not specified) 2231 (SHLD-19). Excessive delays on ACKs can disturb the round-trip 2232 timing and packet "clocking" algorithms. More complete discussion of 2233 delayed ACK behavior is in Section 4.2 of RFC 5681 [9], including 2234 recomendations to immediately acknowledge out-of-order segments, 2235 segments above a gap in sequence space, or segments that fill all or 2236 part of a gap, in order to accelerate loss recovery. 2238 Note that there are several current practices that further lead to a 2239 reduced number of ACKs, including generic receive offload (GRO), ACK 2240 compression, and ACK decimation [26]. 2242 3.9. Interfaces 2244 There are of course two interfaces of concern: the user/TCP interface 2245 and the TCP/lower-level interface. We have a fairly elaborate model 2246 of the user/TCP interface, but the interface to the lower level 2247 protocol module is left unspecified here, since it will be specified 2248 in detail by the specification of the lower level protocol. For the 2249 case that the lower level is IP we note some of the parameter values 2250 that TCP implementations might use. 2252 3.9.1. User/TCP Interface 2254 The following functional description of user commands to the TCP 2255 implementation is, at best, fictional, since every operating system 2256 will have different facilities. Consequently, we must warn readers 2257 that different TCP implementations may have different user 2258 interfaces. However, all TCP implementations must provide a certain 2259 minimum set of services to guarantee that all TCP implementations can 2260 support the same protocol hierarchy. This section specifies the 2261 functional interfaces required of all TCP implementations. 2263 Section 3.1 of [52] also identifies primitives provided by TCP, and 2264 could be used as an additional reference for implementers. 2266 TCP User Commands 2268 The following sections functionally characterize a USER/TCP 2269 interface. The notation used is similar to most procedure or 2270 function calls in high level languages, but this usage is not 2271 meant to rule out trap type service calls. 2273 The user commands described below specify the basic functions the 2274 TCP implementation must perform to support interprocess 2275 communication. Individual implementations must define their own 2276 exact format, and may provide combinations or subsets of the basic 2277 functions in single calls. In particular, some implementations 2278 may wish to automatically OPEN a connection on the first SEND or 2279 RECEIVE issued by the user for a given connection. 2281 In providing interprocess communication facilities, the TCP 2282 implementation must not only accept commands, but must also return 2283 information to the processes it serves. The latter consists of: 2285 (a) general information about a connection (e.g., interrupts, 2286 remote close, binding of unspecified remote socket). 2288 (b) replies to specific user commands indicating success or 2289 various types of failure. 2291 Open 2293 Format: OPEN (local port, remote socket, active/passive [, 2294 timeout] [, DiffServ field] [, security/compartment] [local IP 2295 address,] [, options]) -> local connection name 2297 If the active/passive flag is set to passive, then this is a 2298 call to LISTEN for an incoming connection. A passive open may 2299 have either a fully specified remote socket to wait for a 2300 particular connection or an unspecified remote socket to wait 2301 for any call. A fully specified passive call can be made 2302 active by the subsequent execution of a SEND. 2304 A transmission control block (TCB) is created and partially 2305 filled in with data from the OPEN command parameters. 2307 Every passive OPEN call either creates a new connection record 2308 in LISTEN state, or it returns an error; it MUST NOT affect any 2309 previously created connection record (MUST-41). 2311 A TCP implementation that supports multiple concurrent 2312 connections MUST provide an OPEN call that will functionally 2313 allow an application to LISTEN on a port while a connection 2314 block with the same local port is in SYN-SENT or SYN-RECEIVED 2315 state (MUST-42). 2317 On an active OPEN command, the TCP endpoint will begin the 2318 procedure to synchronize (i.e., establish) the connection at 2319 once. 2321 The timeout, if present, permits the caller to set up a timeout 2322 for all data submitted to TCP. If data is not successfully 2323 delivered to the destination within the timeout period, the TCP 2324 endpoint will abort the connection. The present global default 2325 is five minutes. 2327 The TCP implementation or some component of the operating 2328 system will verify the users authority to open a connection 2329 with the specified DiffServ field value or security/ 2330 compartment. The absence of a DiffServ field value or 2331 security/compartment specification in the OPEN call indicates 2332 the default values must be used. 2334 TCP will accept incoming requests as matching only if the 2335 security/compartment information is exactly the same as that 2336 requested in the OPEN call. 2338 The DiffServ field value indicated by the user only impacts 2339 outgoing packets, may be altered en route through the network, 2340 and has no direct bearing or relation to received packets. 2342 A local connection name will be returned to the user by the TCP 2343 implementation. The local connection name can then be used as 2344 a short hand term for the connection defined by the pair. 2347 The optional "local IP address" parameter MUST be supported to 2348 allow the specification of the local IP address (MUST-43). 2349 This enables applications that need to select the local IP 2350 address used when multihoming is present. 2352 A passive OPEN call with a specified "local IP address" 2353 parameter will await an incoming connection request to that 2354 address. If the parameter is unspecified, a passive OPEN will 2355 await an incoming connection request to any local IP address, 2356 and then bind the local IP address of the connection to the 2357 particular address that is used. 2359 For an active OPEN call, a specified "local IP address" 2360 parameter will be used for opening the connection. If the 2361 parameter is unspecified, the host will choose an appropriate 2362 local IP address (see RFC 1122 section 3.3.4.2). 2364 If an application on a multihomed host does not specify the 2365 local IP address when actively opening a TCP connection, then 2366 the TCP implementation MUST ask the IP layer to select a local 2367 IP address before sending the (first) SYN (MUST-44). See the 2368 function GET_SRCADDR() in Section 3.4 of RFC 1122. 2370 At all other times, a previous segment has either been sent or 2371 received on this connection, and TCP implementations MUST use 2372 the same local address is used that was used in those previous 2373 segments (MUST-45). 2375 A TCP implementation MUST reject as an error a local OPEN call 2376 for an invalid remote IP address (e.g., a broadcast or 2377 multicast address) (MUST-46). 2379 Send 2381 Format: SEND (local connection name, buffer address, byte 2382 count, PUSH flag (optional), URGENT flag [,timeout]) 2384 This call causes the data contained in the indicated user 2385 buffer to be sent on the indicated connection. If the 2386 connection has not been opened, the SEND is considered an 2387 error. Some implementations may allow users to SEND first; in 2388 which case, an automatic OPEN would be done. For example, this 2389 might be one way for application data to be included in SYN 2390 segments. If the calling process is not authorized to use this 2391 connection, an error is returned. 2393 A TCP endpoint MAY implement PUSH flags on SEND calls (MAY-15). 2394 If PUSH flags are not implemented, then the sending TCP peer: 2395 (1) MUST NOT buffer data indefinitely (MUST-60), and (2) MUST 2396 set the PSH bit in the last buffered segment (i.e., when there 2397 is no more queued data to be sent) (MUST-61). The remaining 2398 description below assumes the PUSH flag is supported on SEND 2399 calls. 2401 If the PUSH flag is set, the application intends the data to be 2402 transmitted promptly to the receiver, and the PUSH bit will be 2403 set in the last TCP segment created from the buffer. When an 2404 application issues a series of SEND calls without setting the 2405 PUSH flag, the TCP implementation MAY aggregate the data 2406 internally without sending it (MAY-16). 2408 The PSH bit is not a record marker and is independent of 2409 segment boundaries. The transmitter SHOULD collapse successive 2410 bits when it packetizes data, to send the largest possible 2411 segment (SHLD-27). 2413 If the PUSH flag is not set, the data may be combined with data 2414 from subsequent SENDs for transmission efficiency. Note that 2415 when the Nagle algorithm is in use, TCP implementations may 2416 buffer the data before sending, without regard to the PUSH flag 2417 (see Section 3.7.4). 2419 An application program is logically required to set the PUSH 2420 flag in a SEND call whenever it needs to force delivery of the 2421 data to avoid a communication deadlock. However, a TCP 2422 implementation SHOULD send a maximum-sized segment whenever 2423 possible (SHLD-28), to improve performance (see 2424 Section 3.8.6.2.1). 2426 New applications SHOULD NOT set the URGENT flag [38] due to 2427 implementation differences and middlebox issues (SHLD-13). 2429 If the URGENT flag is set, segments sent to the destination TCP 2430 peer will have the urgent pointer set. The receiving TCP peer 2431 will signal the urgent condition to the receiving process if 2432 the urgent pointer indicates that data preceding the urgent 2433 pointer has not been consumed by the receiving process. The 2434 purpose of urgent is to stimulate the receiver to process the 2435 urgent data and to indicate to the receiver when all the 2436 currently known urgent data has been received. The number of 2437 times the sending user's TCP implementation signals urgent will 2438 not necessarily be equal to the number of times the receiving 2439 user will be notified of the presence of urgent data. 2441 If no remote socket was specified in the OPEN, but the 2442 connection is established (e.g., because a LISTENing connection 2443 has become specific due to a remote segment arriving for the 2444 local socket), then the designated buffer is sent to the 2445 implied remote socket. Users who make use of OPEN with an 2446 unspecified remote socket can make use of SEND without ever 2447 explicitly knowing the remote socket address. 2449 However, if a SEND is attempted before the remote socket 2450 becomes specified, an error will be returned. Users can use 2451 the STATUS call to determine the status of the connection. 2452 Some TCP implementations may notify the user when an 2453 unspecified socket is bound. 2455 If a timeout is specified, the current user timeout for this 2456 connection is changed to the new one. 2458 In the simplest implementation, SEND would not return control 2459 to the sending process until either the transmission was 2460 complete or the timeout had been exceeded. However, this 2461 simple method is both subject to deadlocks (for example, both 2462 sides of the connection might try to do SENDs before doing any 2463 RECEIVEs) and offers poor performance, so it is not 2464 recommended. A more sophisticated implementation would return 2465 immediately to allow the process to run concurrently with 2466 network I/O, and, furthermore, to allow multiple SENDs to be in 2467 progress. Multiple SENDs are served in first come, first 2468 served order, so the TCP endpoint will queue those it cannot 2469 service immediately. 2471 We have implicitly assumed an asynchronous user interface in 2472 which a SEND later elicits some kind of SIGNAL or pseudo- 2473 interrupt from the serving TCP endpoint. An alternative is to 2474 return a response immediately. For instance, SENDs might 2475 return immediate local acknowledgment, even if the segment sent 2476 had not been acknowledged by the distant TCP endpoint. We 2477 could optimistically assume eventual success. If we are wrong, 2478 the connection will close anyway due to the timeout. In 2479 implementations of this kind (synchronous), there will still be 2480 some asynchronous signals, but these will deal with the 2481 connection itself, and not with specific segments or buffers. 2483 In order for the process to distinguish among error or success 2484 indications for different SENDs, it might be appropriate for 2485 the buffer address to be returned along with the coded response 2486 to the SEND request. TCP-to-user signals are discussed below, 2487 indicating the information that should be returned to the 2488 calling process. 2490 Receive 2492 Format: RECEIVE (local connection name, buffer address, byte 2493 count) -> byte count, urgent flag, push flag (optional) 2495 This command allocates a receiving buffer associated with the 2496 specified connection. If no OPEN precedes this command or the 2497 calling process is not authorized to use this connection, an 2498 error is returned. 2500 In the simplest implementation, control would not return to the 2501 calling program until either the buffer was filled, or some 2502 error occurred, but this scheme is highly subject to deadlocks. 2503 A more sophisticated implementation would permit several 2504 RECEIVEs to be outstanding at once. These would be filled as 2505 segments arrive. This strategy permits increased throughput at 2506 the cost of a more elaborate scheme (possibly asynchronous) to 2507 notify the calling program that a PUSH has been seen or a 2508 buffer filled. 2510 A TCP receiver MAY pass a received PSH flag to the application 2511 layer via the PUSH flag in the interface (MAY-17), but it is 2512 not required (this was clarified in RFC 1122 section 4.2.2.2). 2513 The remainder of text describing the RECEIVE call below assumes 2514 that passing the PUSH indication is supported. 2516 If enough data arrive to fill the buffer before a PUSH is seen, 2517 the PUSH flag will not be set in the response to the RECEIVE. 2518 The buffer will be filled with as much data as it can hold. If 2519 a PUSH is seen before the buffer is filled the buffer will be 2520 returned partially filled and PUSH indicated. 2522 If there is urgent data the user will have been informed as 2523 soon as it arrived via a TCP-to-user signal. The receiving 2524 user should thus be in "urgent mode". If the URGENT flag is 2525 on, additional urgent data remains. If the URGENT flag is off, 2526 this call to RECEIVE has returned all the urgent data, and the 2527 user may now leave "urgent mode". Note that data following the 2528 urgent pointer (non-urgent data) cannot be delivered to the 2529 user in the same buffer with preceding urgent data unless the 2530 boundary is clearly marked for the user. 2532 To distinguish among several outstanding RECEIVEs and to take 2533 care of the case that a buffer is not completely filled, the 2534 return code is accompanied by both a buffer pointer and a byte 2535 count indicating the actual length of the data received. 2537 Alternative implementations of RECEIVE might have the TCP 2538 endpoint allocate buffer storage, or the TCP endpoint might 2539 share a ring buffer with the user. 2541 Close 2543 Format: CLOSE (local connection name) 2545 This command causes the connection specified to be closed. If 2546 the connection is not open or the calling process is not 2547 authorized to use this connection, an error is returned. 2548 Closing connections is intended to be a graceful operation in 2549 the sense that outstanding SENDs will be transmitted (and 2550 retransmitted), as flow control permits, until all have been 2551 serviced. Thus, it should be acceptable to make several SEND 2552 calls, followed by a CLOSE, and expect all the data to be sent 2553 to the destination. It should also be clear that users should 2554 continue to RECEIVE on CLOSING connections, since the remote 2555 peer may be trying to transmit the last of its data. Thus, 2556 CLOSE means "I have no more to send" but does not mean "I will 2557 not receive any more." It may happen (if the user level 2558 protocol is not well thought out) that the closing side is 2559 unable to get rid of all its data before timing out. In this 2560 event, CLOSE turns into ABORT, and the closing TCP peer gives 2561 up. 2563 The user may CLOSE the connection at any time on their own 2564 initiative, or in response to various prompts from the TCP 2565 implementation (e.g., remote close executed, transmission 2566 timeout exceeded, destination inaccessible). 2568 Because closing a connection requires communication with the 2569 remote TCP peer, connections may remain in the closing state 2570 for a short time. Attempts to reopen the connection before the 2571 TCP peer replies to the CLOSE command will result in error 2572 responses. 2574 Close also implies push function. 2576 Status 2578 Format: STATUS (local connection name) -> status data 2580 This is an implementation dependent user command and could be 2581 excluded without adverse effect. Information returned would 2582 typically come from the TCB associated with the connection. 2584 This command returns a data block containing the following 2585 information: 2587 local socket, 2589 remote socket, 2591 local connection name, 2593 receive window, 2595 send window, 2597 connection state, 2599 number of buffers awaiting acknowledgment, 2601 number of buffers pending receipt, 2603 urgent state, 2605 DiffServ field value, 2607 security/compartment, 2609 and transmission timeout. 2611 Depending on the state of the connection, or on the 2612 implementation itself, some of this information may not be 2613 available or meaningful. If the calling process is not 2614 authorized to use this connection, an error is returned. This 2615 prevents unauthorized processes from gaining information about 2616 a connection. 2618 Abort 2620 Format: ABORT (local connection name) 2621 This command causes all pending SENDs and RECEIVES to be 2622 aborted, the TCB to be removed, and a special RESET message to 2623 be sent to the remote TCP peer of the connection. Depending on 2624 the implementation, users may receive abort indications for 2625 each outstanding SEND or RECEIVE, or may simply receive an 2626 ABORT-acknowledgment. 2628 Flush 2630 Some TCP implementations have included a FLUSH call, which will 2631 empty the TCP send queue of any data that the user has issued 2632 SEND calls but is still to the right of the current send 2633 window. That is, it flushes as much queued send data as 2634 possible without losing sequence number synchronization. The 2635 FLUSH call MAY be implemented (MAY-14). 2637 Asynchronous Reports 2639 There MUST be a mechanism for reporting soft TCP error 2640 conditions to the application (MUST-47). Generically, we 2641 assume this takes the form of an application-supplied 2642 ERROR_REPORT routine that may be upcalled asynchronously from 2643 the transport layer: 2645 ERROR_REPORT(local connection name, reason, subreason) 2647 The precise encoding of the reason and subreason parameters is 2648 not specified here. However, the conditions that are reported 2649 asynchronously to the application MUST include: 2651 * ICMP error message arrived (see Section 3.9.2.2 for 2652 description of handling each ICMP message type, since some 2653 message types need to be suppressed from generating reports 2654 to the application) 2656 * Excessive retransmissions (see Section 3.8.3) 2658 * Urgent pointer advance (see Section 3.8.5) 2660 However, an application program that does not want to receive 2661 such ERROR_REPORT calls SHOULD be able to effectively disable 2662 these calls (SHLD-20). 2664 Set Differentiated Services Field (IPv4 TOS or IPv6 Traffic Class) 2666 The application layer MUST be able to specify the 2667 Differentiated Services field for segments that are sent on a 2668 connection (MUST-48). The Differentiated Services field 2669 includes the 6-bit Differentiated Services Code Point (DSCP) 2670 value. It is not required, but the application SHOULD be able 2671 to change the Differentiated Services field during the 2672 connection lifetime (SHLD-21). TCP implementations SHOULD pass 2673 the current Differentiated Services field value without change 2674 to the IP layer, when it sends segments on the connection 2675 (SHLD-22). 2677 The Differentiated Services field will be specified 2678 independently in each direction on the connection, so that the 2679 receiver application will specify the Differentiated Services 2680 field used for ACK segments. 2682 TCP implementations MAY pass the most recently received 2683 Differentiated Services field up to the application (MAY-9). 2685 3.9.2. TCP/Lower-Level Interface 2687 The TCP endpoint calls on a lower level protocol module to actually 2688 send and receive information over a network. The two current 2689 standard Internet Protocol (IP) versions layered below TCP are IPv4 2690 [1] and IPv6 [13]. 2692 If the lower level protocol is IPv4 it provides arguments for a type 2693 of service (used within the Differentiated Services field) and for a 2694 time to live. TCP uses the following settings for these parameters: 2696 DiffServ field: The IP header value for the DiffServ field is 2697 given by the user. This includes the bits of the DiffServ Code 2698 Point (DSCP). 2700 Time to Live (TTL): The TTL value used to send TCP segments MUST 2701 be configurable (MUST-49). 2703 - Note that RFC 793 specified one minute (60 seconds) as a 2704 constant for the TTL, because the assumed maximum segment 2705 lifetime was two minutes. This was intended to explicitly ask 2706 that a segment be destroyed if it cannot be delivered by the 2707 internet system within one minute. RFC 1122 changed this 2708 specification to require that the TTL be configurable. 2710 - Note that the DiffServ field is permitted to change during a 2711 connection (Section 4.2.4.2 of RFC 1122). However, the 2712 application interface might not support this ability, and the 2713 application does not have knowledge about individual TCP 2714 segments, so this can only be done on a coarse granularity, at 2715 best. This limitation is further discussed in RFC 7657 (sec 2716 5.1, 5.3, and 6) [49]. Generally, an application SHOULD NOT 2717 change the DiffServ field value during the course of a 2718 connection (SHLD-23). 2720 Any lower level protocol will have to provide the source address, 2721 destination address, and protocol fields, and some way to determine 2722 the "TCP length", both to provide the functional equivalent service 2723 of IP and to be used in the TCP checksum. 2725 When received options are passed up to TCP from the IP layer, TCP 2726 implementations MUST ignore options that it does not understand 2727 (MUST-50). 2729 A TCP implementation MAY support the Time Stamp (MAY-10) and Record 2730 Route (MAY-11) options. 2732 3.9.2.1. Source Routing 2734 If the lower level is IP (or other protocol that provides this 2735 feature) and source routing is used, the interface must allow the 2736 route information to be communicated. This is especially important 2737 so that the source and destination addresses used in the TCP checksum 2738 be the originating source and ultimate destination. It is also 2739 important to preserve the return route to answer connection requests. 2741 An application MUST be able to specify a source route when it 2742 actively opens a TCP connection (MUST-51), and this MUST take 2743 precedence over a source route received in a datagram (MUST-52). 2745 When a TCP connection is OPENed passively and a packet arrives with a 2746 completed IP Source Route option (containing a return route), TCP 2747 implementations MUST save the return route and use it for all 2748 segments sent on this connection (MUST-53). If a different source 2749 route arrives in a later segment, the later definition SHOULD 2750 override the earlier one (SHLD-24). 2752 3.9.2.2. ICMP Messages 2754 TCP implementations MUST act on an ICMP error message passed up from 2755 the IP layer, directing it to the connection that created the error 2756 (MUST-54). The necessary demultiplexing information can be found in 2757 the IP header contained within the ICMP message. 2759 This applies to ICMPv6 in addition to IPv4 ICMP. 2761 [33] contains discussion of specific ICMP and ICMPv6 messages 2762 classified as either "soft" or "hard" errors that may bear different 2763 responses. Treatment for classes of ICMP messages is described 2764 below: 2766 Source Quench 2767 TCP implementations MUST silently discard any received ICMP Source 2768 Quench messages (MUST-55). See [11] for discussion. 2770 Soft Errors 2771 For ICMP these include: Destination Unreachable -- codes 0, 1, 5, 2772 Time Exceeded -- codes 0, 1, and Parameter Problem. 2774 For ICMPv6 these include: Destination Unreachable -- codes 0 and 3, 2775 Time Exceeded -- codes 0, 1, and Parameter Problem -- codes 0, 1, 2776 2. 2778 Since these Unreachable messages indicate soft error conditions, 2779 TCP implementations MUST NOT abort the connection (MUST-56), and it 2780 SHOULD make the information available to the application (SHLD-25). 2782 Hard Errors 2783 For ICMP these include Destination Unreachable -- codes 2-4. 2785 These are hard error conditions, so TCP implementations SHOULD 2786 abort the connection (SHLD-26). [33] notes that some 2787 implementations do not abort connections when an ICMP hard error is 2788 received for a connection that is in any of the synchronized 2789 states. 2791 Note that [33] section 4 describes widespread implementation behavior 2792 that treats soft errors as hard errors during connection 2793 establishment. 2795 3.9.2.3. Source Address Validation 2797 RFC 1122 requires addresses to be validated in incoming SYN packets: 2799 An incoming SYN with an invalid source address MUST be ignored 2800 either by TCP or by the IP layer (MUST-63) (Section 3.2.1.3 of 2801 [18]). 2803 A TCP implementation MUST silently discard an incoming SYN segment 2804 that is addressed to a broadcast or multicast address (MUST-57). 2806 This prevents connection state and replies from being erroneously 2807 generated, and implementers should note that this guidance is 2808 applicable to all incoming segments, not just SYNs, as specifically 2809 indicated in RFC 1122. 2811 3.10. Event Processing 2813 The processing depicted in this section is an example of one possible 2814 implementation. Other implementations may have slightly different 2815 processing sequences, but they should differ from those in this 2816 section only in detail, not in substance. 2818 The activity of the TCP endpoint can be characterized as responding 2819 to events. The events that occur can be cast into three categories: 2820 user calls, arriving segments, and timeouts. This section describes 2821 the processing the TCP endpoint does in response to each of the 2822 events. In many cases the processing required depends on the state 2823 of the connection. 2825 Events that occur: 2827 User Calls 2829 - OPEN 2831 SEND 2833 RECEIVE 2835 CLOSE 2837 ABORT 2839 STATUS 2841 Arriving Segments 2843 - SEGMENT ARRIVES 2845 Timeouts 2847 - USER TIMEOUT 2849 RETRANSMISSION TIMEOUT 2851 TIME-WAIT TIMEOUT 2853 The model of the TCP/user interface is that user commands receive an 2854 immediate return and possibly a delayed response via an event or 2855 pseudo interrupt. In the following descriptions, the term "signal" 2856 means cause a delayed response. 2858 Error responses in this document are identified by character strings. 2859 For example, user commands referencing connections that do not exist 2860 receive "error: connection not open". 2862 Please note in the following that all arithmetic on sequence numbers, 2863 acknowledgment numbers, windows, et cetera, is modulo 2**32 the size 2864 of the sequence number space. Also note that "=<" means less than or 2865 equal to (modulo 2**32). 2867 A natural way to think about processing incoming segments is to 2868 imagine that they are first tested for proper sequence number (i.e., 2869 that their contents lie in the range of the expected "receive window" 2870 in the sequence number space) and then that they are generally queued 2871 and processed in sequence number order. 2873 When a segment overlaps other already received segments we 2874 reconstruct the segment to contain just the new data, and adjust the 2875 header fields to be consistent. 2877 Note that if no state change is mentioned the TCP connection stays in 2878 the same state. 2880 3.10.1. OPEN Call 2882 CLOSED STATE (i.e., TCB does not exist) 2884 - Create a new transmission control block (TCB) to hold 2885 connection state information. Fill in local socket identifier, 2886 remote socket, DiffServ field, security/compartment, and user 2887 timeout information. Note that some parts of the remote socket 2888 may be unspecified in a passive OPEN and are to be filled in by 2889 the parameters of the incoming SYN segment. Verify the 2890 security and DiffServ value requested are allowed for this 2891 user, if not return "error: precedence not allowed" or "error: 2892 security/compartment not allowed." If passive enter the LISTEN 2893 state and return. If active and the remote socket is 2894 unspecified, return "error: remote socket unspecified"; if 2895 active and the remote socket is specified, issue a SYN segment. 2896 An initial send sequence number (ISS) is selected. A SYN 2897 segment of the form is sent. Set SND.UNA to 2898 ISS, SND.NXT to ISS+1, enter SYN-SENT state, and return. 2900 - If the caller does not have access to the local socket 2901 specified, return "error: connection illegal for this process". 2902 If there is no room to create a new connection, return "error: 2903 insufficient resources". 2905 LISTEN STATE 2907 - If the OPEN call is active and the remote socket is specified, 2908 then change the connection from passive to active, select an 2909 ISS. Send a SYN segment, set SND.UNA to ISS, SND.NXT to ISS+1. 2910 Enter SYN-SENT state. Data associated with SEND may be sent 2911 with SYN segment or queued for transmission after entering 2912 ESTABLISHED state. The urgent bit if requested in the command 2913 must be sent with the data segments sent as a result of this 2914 command. If there is no room to queue the request, respond 2915 with "error: insufficient resources". If Foreign socket was 2916 not specified, then return "error: remote socket unspecified". 2918 SYN-SENT STATE 2920 SYN-RECEIVED STATE 2922 ESTABLISHED STATE 2924 FIN-WAIT-1 STATE 2926 FIN-WAIT-2 STATE 2928 CLOSE-WAIT STATE 2930 CLOSING STATE 2932 LAST-ACK STATE 2934 TIME-WAIT STATE 2936 - Return "error: connection already exists". 2938 3.10.2. SEND Call 2940 CLOSED STATE (i.e., TCB does not exist) 2942 - If the user does not have access to such a connection, then 2943 return "error: connection illegal for this process". 2945 - Otherwise, return "error: connection does not exist". 2947 LISTEN STATE 2949 - If the remote socket is specified, then change the connection 2950 from passive to active, select an ISS. Send a SYN segment, set 2951 SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT state. Data 2952 associated with SEND may be sent with SYN segment or queued for 2953 transmission after entering ESTABLISHED state. The urgent bit 2954 if requested in the command must be sent with the data segments 2955 sent as a result of this command. If there is no room to queue 2956 the request, respond with "error: insufficient resources". If 2957 Foreign socket was not specified, then return "error: remote 2958 socket unspecified". 2960 SYN-SENT STATE 2962 SYN-RECEIVED STATE 2964 - Queue the data for transmission after entering ESTABLISHED 2965 state. If no space to queue, respond with "error: insufficient 2966 resources". 2968 ESTABLISHED STATE 2970 CLOSE-WAIT STATE 2972 - Segmentize the buffer and send it with a piggybacked 2973 acknowledgment (acknowledgment value = RCV.NXT). If there is 2974 insufficient space to remember this buffer, simply return 2975 "error: insufficient resources". 2977 - If the urgent flag is set, then SND.UP <- SND.NXT and set the 2978 urgent pointer in the outgoing segments. 2980 FIN-WAIT-1 STATE 2982 FIN-WAIT-2 STATE 2984 CLOSING STATE 2986 LAST-ACK STATE 2988 TIME-WAIT STATE 2990 - Return "error: connection closing" and do not service request. 2992 3.10.3. RECEIVE Call 2994 CLOSED STATE (i.e., TCB does not exist) 2996 - If the user does not have access to such a connection, return 2997 "error: connection illegal for this process". 2999 - Otherwise return "error: connection does not exist". 3001 LISTEN STATE 3003 SYN-SENT STATE 3005 SYN-RECEIVED STATE 3007 - Queue for processing after entering ESTABLISHED state. If 3008 there is no room to queue this request, respond with "error: 3009 insufficient resources". 3011 ESTABLISHED STATE 3013 FIN-WAIT-1 STATE 3015 FIN-WAIT-2 STATE 3017 - If insufficient incoming segments are queued to satisfy the 3018 request, queue the request. If there is no queue space to 3019 remember the RECEIVE, respond with "error: insufficient 3020 resources". 3022 - Reassemble queued incoming segments into receive buffer and 3023 return to user. Mark "push seen" (PUSH) if this is the case. 3025 - If RCV.UP is in advance of the data currently being passed to 3026 the user notify the user of the presence of urgent data. 3028 - When the TCP endpoint takes responsibility for delivering data 3029 to the user that fact must be communicated to the sender via an 3030 acknowledgment. The formation of such an acknowledgment is 3031 described below in the discussion of processing an incoming 3032 segment. 3034 CLOSE-WAIT STATE 3035 - Since the remote side has already sent FIN, RECEIVEs must be 3036 satisfied by data already on hand, but not yet delivered to the 3037 user. If no text is awaiting delivery, the RECEIVE will get a 3038 "error: connection closing" response. Otherwise, any remaining 3039 text can be used to satisfy the RECEIVE. 3041 CLOSING STATE 3043 LAST-ACK STATE 3045 TIME-WAIT STATE 3047 - Return "error: connection closing". 3049 3.10.4. CLOSE Call 3051 CLOSED STATE (i.e., TCB does not exist) 3053 - If the user does not have access to such a connection, return 3054 "error: connection illegal for this process". 3056 - Otherwise, return "error: connection does not exist". 3058 LISTEN STATE 3060 - Any outstanding RECEIVEs are returned with "error: closing" 3061 responses. Delete TCB, enter CLOSED state, and return. 3063 SYN-SENT STATE 3065 - Delete the TCB and return "error: closing" responses to any 3066 queued SENDs, or RECEIVEs. 3068 SYN-RECEIVED STATE 3070 - If no SENDs have been issued and there is no pending data to 3071 send, then form a FIN segment and send it, and enter FIN-WAIT-1 3072 state; otherwise queue for processing after entering 3073 ESTABLISHED state. 3075 ESTABLISHED STATE 3077 - Queue this until all preceding SENDs have been segmentized, 3078 then form a FIN segment and send it. In any case, enter FIN- 3079 WAIT-1 state. 3081 FIN-WAIT-1 STATE 3082 FIN-WAIT-2 STATE 3084 - Strictly speaking, this is an error and should receive a 3085 "error: connection closing" response. An "ok" response would 3086 be acceptable, too, as long as a second FIN is not emitted (the 3087 first FIN may be retransmitted though). 3089 CLOSE-WAIT STATE 3091 - Queue this request until all preceding SENDs have been 3092 segmentized; then send a FIN segment, enter LAST-ACK state. 3094 CLOSING STATE 3096 LAST-ACK STATE 3098 TIME-WAIT STATE 3100 - Respond with "error: connection closing". 3102 3.10.5. ABORT Call 3104 CLOSED STATE (i.e., TCB does not exist) 3106 - If the user should not have access to such a connection, return 3107 "error: connection illegal for this process". 3109 - Otherwise return "error: connection does not exist". 3111 LISTEN STATE 3113 - Any outstanding RECEIVEs should be returned with "error: 3114 connection reset" responses. Delete TCB, enter CLOSED state, 3115 and return. 3117 SYN-SENT STATE 3119 - All queued SENDs and RECEIVEs should be given "connection 3120 reset" notification, delete the TCB, enter CLOSED state, and 3121 return. 3123 SYN-RECEIVED STATE 3125 ESTABLISHED STATE 3127 FIN-WAIT-1 STATE 3129 FIN-WAIT-2 STATE 3130 CLOSE-WAIT STATE 3132 - Send a reset segment: 3134 o 3136 - All queued SENDs and RECEIVEs should be given "connection 3137 reset" notification; all segments queued for transmission 3138 (except for the RST formed above) or retransmission should be 3139 flushed, delete the TCB, enter CLOSED state, and return. 3141 CLOSING STATE LAST-ACK STATE TIME-WAIT STATE 3143 - Respond with "ok" and delete the TCB, enter CLOSED state, and 3144 return. 3146 3.10.6. STATUS Call 3148 CLOSED STATE (i.e., TCB does not exist) 3150 - If the user should not have access to such a connection, return 3151 "error: connection illegal for this process". 3153 - Otherwise return "error: connection does not exist". 3155 LISTEN STATE 3157 - Return "state = LISTEN", and the TCB pointer. 3159 SYN-SENT STATE 3161 - Return "state = SYN-SENT", and the TCB pointer. 3163 SYN-RECEIVED STATE 3165 - Return "state = SYN-RECEIVED", and the TCB pointer. 3167 ESTABLISHED STATE 3169 - Return "state = ESTABLISHED", and the TCB pointer. 3171 FIN-WAIT-1 STATE 3173 - Return "state = FIN-WAIT-1", and the TCB pointer. 3175 FIN-WAIT-2 STATE 3177 - Return "state = FIN-WAIT-2", and the TCB pointer. 3179 CLOSE-WAIT STATE 3181 - Return "state = CLOSE-WAIT", and the TCB pointer. 3183 CLOSING STATE 3185 - Return "state = CLOSING", and the TCB pointer. 3187 LAST-ACK STATE 3189 - Return "state = LAST-ACK", and the TCB pointer. 3191 TIME-WAIT STATE 3193 - Return "state = TIME-WAIT", and the TCB pointer. 3195 3.10.7. SEGMENT ARRIVES 3197 3.10.7.1. CLOSED State 3199 If the state is CLOSED (i.e., TCB does not exist) then 3201 all data in the incoming segment is discarded. An incoming 3202 segment containing a RST is discarded. An incoming segment not 3203 containing a RST causes a RST to be sent in response. The 3204 acknowledgment and sequence field values are selected to make the 3205 reset sequence acceptable to the TCP endpoint that sent the 3206 offending segment. 3208 If the ACK bit is off, sequence number zero is used, 3210 - 3212 If the ACK bit is on, 3214 - 3216 Return. 3218 3.10.7.2. LISTEN State 3220 If the state is LISTEN then 3222 first check for an RST 3224 - An incoming RST segment could not be valid, since it could not 3225 have been sent in response to anything sent by this incarnation 3226 of the connection. An incoming RST should be ignored. Return. 3228 second check for an ACK 3230 - Any acknowledgment is bad if it arrives on a connection still 3231 in the LISTEN state. An acceptable reset segment should be 3232 formed for any arriving ACK-bearing segment. The RST should be 3233 formatted as follows: 3235 o 3237 - Return. 3239 third check for a SYN 3241 - If the SYN bit is set, check the security. If the security/ 3242 compartment on the incoming segment does not exactly match the 3243 security/compartment in the TCB then send a reset and return. 3245 o 3247 - Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any other 3248 control or text should be queued for processing later. ISS 3249 should be selected and a SYN segment sent of the form: 3251 o 3253 - SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 3254 state should be changed to SYN-RECEIVED. Note that any other 3255 incoming control or data (combined with SYN) will be processed 3256 in the SYN-RECEIVED state, but processing of SYN and ACK should 3257 not be repeated. If the listen was not fully specified (i.e., 3258 the remote socket was not fully specified), then the 3259 unspecified fields should be filled in now. 3261 fourth other data or control 3263 - This should not be reached. Drop the segment and return. Any 3264 other control or data-bearing segment (not containing SYN) must 3265 have an ACK and thus would have been discarded by the ACK 3266 processing in the second step, unless it was first discarded by 3267 RST checking in the first step. 3269 3.10.7.3. SYN-SENT State 3271 If the state is SYN-SENT then 3273 first check the ACK bit 3275 - If the ACK bit is set 3276 o If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset 3277 (unless the RST bit is set, if so drop the segment and 3278 return) 3280 + 3282 o and discard the segment. Return. 3284 o If SND.UNA < SEG.ACK =< SND.NXT then the ACK is acceptable. 3285 Some deployed TCP code has used the check SEG.ACK == SND.NXT 3286 (using "==" rather than "=<", but this is not appropriate 3287 when the stack is capable of sending data on the SYN, 3288 because the TCP peer may not accept and acknowledge all of 3289 the data on the SYN. 3291 second check the RST bit 3293 - If the RST bit is set 3295 o A potential blind reset attack is described in RFC 5961 3296 [37]. The mitigation described in that document has 3297 specific applicability explained therein, and is not a 3298 substitute for cryptographic protection (e.g. IPsec or TCP- 3299 AO). A TCP implementation that supports the RFC 5961 3300 mitigation SHOULD first check that the sequence number 3301 exactly matches RCV.NXT prior to executing the action in the 3302 next paragraph. 3304 o If the ACK was acceptable then signal the user "error: 3305 connection reset", drop the segment, enter CLOSED state, 3306 delete TCB, and return. Otherwise (no ACK) drop the segment 3307 and return. 3309 third check the security 3311 - If the security/compartment in the segment does not exactly 3312 match the security/compartment in the TCB, send a reset 3314 o If there is an ACK 3316 + 3318 o Otherwise 3320 + 3322 - If a reset was sent, discard the segment and return. 3324 fourth check the SYN bit 3326 - This step should be reached only if the ACK is ok, or there is 3327 no ACK, and the segment did not contain a RST. 3329 - If the SYN bit is on and the security/compartment is acceptable 3330 then, RCV.NXT is set to SEG.SEQ+1, IRS is set to SEG.SEQ. 3331 SND.UNA should be advanced to equal SEG.ACK (if there is an 3332 ACK), and any segments on the retransmission queue that are 3333 thereby acknowledged should be removed. 3335 - If SND.UNA > ISS (our SYN has been ACKed), change the 3336 connection state to ESTABLISHED, form an ACK segment 3338 o 3340 - and send it. Data or controls that were queued for 3341 transmission MAY be included. Some TCP implementations 3342 suppress sending this segment when the received segment 3343 contains data that will anyways generate an acknowledgement in 3344 the later processing steps, saving this extra acknowledgement 3345 of the SYN from being sent. If there are other controls or 3346 text in the segment then continue processing at the sixth step 3347 under Section 3.10.7.4 where the URG bit is checked, otherwise 3348 return. 3350 - Otherwise enter SYN-RECEIVED, form a SYN,ACK segment 3352 o 3354 - and send it. Set the variables: 3356 o SND.WND <- SEG.WND 3358 SND.WL1 <- SEG.SEQ 3360 SND.WL2 <- SEG.ACK 3362 If there are other controls or text in the segment, queue them 3363 for processing after the ESTABLISHED state has been reached, 3364 return. 3366 - Note that it is legal to send and receive application data on 3367 SYN segments (this is the "text in the segment" mentioned 3368 above. There has been significant misinformation and 3369 misunderstanding of this topic historically. Some firewalls 3370 and security devices consider this suspicious. However, the 3371 capability was used in T/TCP [20] and is used in TCP Fast Open 3372 (TFO) [47], so is important for implementations and network 3373 devices to permit. 3375 fifth, if neither of the SYN or RST bits is set then drop the 3376 segment and return. 3378 3.10.7.4. Other States 3380 Otherwise, 3382 first check sequence number 3384 - SYN-RECEIVED STATE 3386 ESTABLISHED STATE 3388 FIN-WAIT-1 STATE 3390 FIN-WAIT-2 STATE 3392 CLOSE-WAIT STATE 3394 CLOSING STATE 3396 LAST-ACK STATE 3398 TIME-WAIT STATE 3400 o Segments are processed in sequence. Initial tests on 3401 arrival are used to discard old duplicates, but further 3402 processing is done in SEG.SEQ order. If a segment's 3403 contents straddle the boundary between old and new, only the 3404 new parts should be processed. 3406 o In general, the processing of received segments MUST be 3407 implemented to aggregate ACK segments whenever possible 3408 (MUST-58). For example, if the TCP endpoint is processing a 3409 series of queued segments, it MUST process them all before 3410 sending any ACK segments (MUST-59). 3412 o There are four cases for the acceptability test for an 3413 incoming segment: 3415 Segment Receive Test 3416 Length Window 3417 ------- ------- ------------------------------------------- 3419 0 0 SEG.SEQ = RCV.NXT 3421 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3423 >0 0 not acceptable 3425 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3426 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 3428 o In implementing sequence number validation as described 3429 here, please note Appendix A.2. 3431 o If the RCV.WND is zero, no segments will be acceptable, but 3432 special allowance should be made to accept valid ACKs, URGs 3433 and RSTs. 3435 o If an incoming segment is not acceptable, an acknowledgment 3436 should be sent in reply (unless the RST bit is set, if so 3437 drop the segment and return): 3439 + 3441 o After sending the acknowledgment, drop the unacceptable 3442 segment and return. 3444 o Note that for the TIME-WAIT state, there is an improved 3445 algorithm described in [39] for handling incoming SYN 3446 segments, that utilizes timestamps rather than relying on 3447 the sequence number check described here. When the improved 3448 algorithm is implemented, the logic above is not applicable 3449 for incoming SYN segments with timestamp options, received 3450 on a connection in the TIME-WAIT state. 3452 o In the following it is assumed that the segment is the 3453 idealized segment that begins at RCV.NXT and does not exceed 3454 the window. One could tailor actual segments to fit this 3455 assumption by trimming off any portions that lie outside the 3456 window (including SYN and FIN), and only processing further 3457 if the segment then begins at RCV.NXT. Segments with higher 3458 beginning sequence numbers SHOULD be held for later 3459 processing (SHLD-31). 3461 - second check the RST bit, 3462 o RFC 5961 [37] section 3 describes a potential blind reset 3463 attack and optional mitigation approach. This does not 3464 provide a cryptographic protection (e.g. as in IPsec or TCP- 3465 AO), but can be applicable in situations described in RFC 3466 5961. For stacks implementing the RFC 5961 protection, the 3467 three checks below apply, otherwise processing for these 3468 states is indicated further below. 3470 + 1) If the RST bit is set and the sequence number is 3471 outside the current receive window, silently drop the 3472 segment. 3474 + 2) If the RST bit is set and the sequence number exactly 3475 matches the next expected sequence number (RCV.NXT), then 3476 TCP endpoints MUST reset the connection in the manner 3477 prescribed below according to the connection state. 3479 + 3) If the RST bit is set and the sequence number does not 3480 exactly match the next expected sequence value, yet is 3481 within the current receive window, TCP endpoints MUST 3482 send an acknowledgement (challenge ACK): 3484 3486 After sending the challenge ACK, TCP endpoints MUST drop 3487 the unacceptable segment and stop processing the incoming 3488 packet further. Note that RFC 5961 and Errata ID 4772 3489 contain additional considerations for ACK throttling in 3490 an implementation. 3492 o SYN-RECEIVED STATE 3494 + If the RST bit is set 3496 * If this connection was initiated with a passive OPEN 3497 (i.e., came from the LISTEN state), then return this 3498 connection to LISTEN state and return. The user need 3499 not be informed. If this connection was initiated 3500 with an active OPEN (i.e., came from SYN-SENT state) 3501 then the connection was refused, signal the user 3502 "connection refused". In either case, all segments on 3503 the retransmission queue should be removed. And in 3504 the active OPEN case, enter the CLOSED state and 3505 delete the TCB, and return. 3507 o ESTABLISHED 3509 FIN-WAIT-1 3510 FIN-WAIT-2 3512 CLOSE-WAIT 3514 + If the RST bit is set then, any outstanding RECEIVEs and 3515 SEND should receive "reset" responses. All segment 3516 queues should be flushed. Users should also receive an 3517 unsolicited general "connection reset" signal. Enter the 3518 CLOSED state, delete the TCB, and return. 3520 o CLOSING STATE 3522 LAST-ACK STATE 3524 TIME-WAIT 3526 + If the RST bit is set then, enter the CLOSED state, 3527 delete the TCB, and return. 3529 - third check security 3531 o SYN-RECEIVED 3533 + If the security/compartment in the segment does not 3534 exactly match the security/compartment in the TCB then 3535 send a reset, and return. 3537 o ESTABLISHED 3539 FIN-WAIT-1 3541 FIN-WAIT-2 3543 CLOSE-WAIT 3545 CLOSING 3547 LAST-ACK 3549 TIME-WAIT 3551 + If the security/compartment in the segment does not 3552 exactly match the security/compartment in the TCB then 3553 send a reset, any outstanding RECEIVEs and SEND should 3554 receive "reset" responses. All segment queues should be 3555 flushed. Users should also receive an unsolicited 3556 general "connection reset" signal. Enter the CLOSED 3557 state, delete the TCB, and return. 3559 o Note this check is placed following the sequence check to 3560 prevent a segment from an old connection between these port 3561 numbers with a different security from causing an abort of 3562 the current connection. 3564 - fourth, check the SYN bit, 3566 o SYN-RECEIVED 3568 + If the connection was initiated with a passive OPEN, then 3569 return this connection to the LISTEN state and return. 3570 Otherwise, handle per the directions for synchronized 3571 states below. 3573 ESTABLISHED STATE 3575 FIN-WAIT STATE-1 3577 FIN-WAIT STATE-2 3579 CLOSE-WAIT STATE 3581 CLOSING STATE 3583 LAST-ACK STATE 3585 TIME-WAIT STATE 3587 + If the SYN bit is set in these synchronized states, it 3588 may be either a legitimate new connection attempt (e.g. 3589 in the case of TIME-WAIT), an error where the connection 3590 should be reset, or the result of an attack attempt, as 3591 described in RFC 5961 [37]. For the TIME-WAIT state, new 3592 connections can be accepted if the timestamp option is 3593 used and meets expectations (per [39]). For all other 3594 cases, RFC 5961 provides a mitigation with applicability 3595 to some situations, though there are also alternatives 3596 that offer cryptographic protection (see Section 7). RFC 3597 5961 recommends that in these synchronized states, if the 3598 SYN bit is set, irrespective of the sequence number, TCP 3599 endpoints MUST send a "challenge ACK" to the remote peer: 3601 + 3603 + After sending the acknowledgement, TCP implementations 3604 MUST drop the unacceptable segment and stop processing 3605 further. Note that RFC 5961 and Errata ID 4772 contain 3606 additional ACK throttling notes for an implementation. 3608 + For implementations that do not follow RFC 5961, the 3609 original RFC 793 behavior follows in this paragraph. If 3610 the SYN is in the window it is an error, send a reset, 3611 any outstanding RECEIVEs and SEND should receive "reset" 3612 responses, all segment queues should be flushed, the user 3613 should also receive an unsolicited general "connection 3614 reset" signal, enter the CLOSED state, delete the TCB, 3615 and return. 3617 + If the SYN is not in the window this step would not be 3618 reached and an ACK would have been sent in the first step 3619 (sequence number check). 3621 - fifth check the ACK field, 3623 o if the ACK bit is off drop the segment and return 3625 o if the ACK bit is on 3627 + RFC 5961 [37] section 5 describes a potential blind data 3628 injection attack, and mitigation that implementations MAY 3629 choose to include (MAY-12). TCP stacks that implement 3630 RFC 5961 MUST add an input check that the ACK value is 3631 acceptable only if it is in the range of ((SND.UNA - 3632 MAX.SND.WND) =< SEG.ACK =< SND.NXT). All incoming 3633 segments whose ACK value doesn't satisfy the above 3634 condition MUST be discarded and an ACK sent back. The 3635 new state variable MAX.SND.WND is defined as the largest 3636 window that the local sender has ever received from its 3637 peer (subject to window scaling) or may be hard-coded to 3638 a maximum permissible window value. When the ACK value 3639 is acceptable, the processing per-state below applies: 3641 + SYN-RECEIVED STATE 3643 * If SND.UNA < SEG.ACK =< SND.NXT then enter ESTABLISHED 3644 state and continue processing with variables below set 3645 to: 3647 - SND.WND <- SEG.WND 3649 SND.WL1 <- SEG.SEQ 3651 SND.WL2 <- SEG.ACK 3653 * If the segment acknowledgment is not acceptable, form 3654 a reset segment, 3655 - 3657 * and send it. 3659 + ESTABLISHED STATE 3661 * If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- 3662 SEG.ACK. Any segments on the retransmission queue 3663 that are thereby entirely acknowledged are removed. 3664 Users should receive positive acknowledgments for 3665 buffers that have been SENT and fully acknowledged 3666 (i.e., SEND buffer should be returned with "ok" 3667 response). If the ACK is a duplicate (SEG.ACK =< 3668 SND.UNA), it can be ignored. If the ACK acks 3669 something not yet sent (SEG.ACK > SND.NXT) then send 3670 an ACK, drop the segment, and return. 3672 * If SND.UNA =< SEG.ACK =< SND.NXT, the send window 3673 should be updated. If (SND.WL1 < SEG.SEQ or (SND.WL1 3674 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- 3675 SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- 3676 SEG.ACK. 3678 * Note that SND.WND is an offset from SND.UNA, that 3679 SND.WL1 records the sequence number of the last 3680 segment used to update SND.WND, and that SND.WL2 3681 records the acknowledgment number of the last segment 3682 used to update SND.WND. The check here prevents using 3683 old segments to update the window. 3685 + FIN-WAIT-1 STATE 3687 * In addition to the processing for the ESTABLISHED 3688 state, if the FIN segment is now acknowledged then 3689 enter FIN-WAIT-2 and continue processing in that 3690 state. 3692 + FIN-WAIT-2 STATE 3694 * In addition to the processing for the ESTABLISHED 3695 state, if the retransmission queue is empty, the 3696 user's CLOSE can be acknowledged ("ok") but do not 3697 delete the TCB. 3699 + CLOSE-WAIT STATE 3701 * Do the same processing as for the ESTABLISHED state. 3703 + CLOSING STATE 3705 * In addition to the processing for the ESTABLISHED 3706 state, if the ACK acknowledges our FIN then enter the 3707 TIME-WAIT state, otherwise ignore the segment. 3709 + LAST-ACK STATE 3711 * The only thing that can arrive in this state is an 3712 acknowledgment of our FIN. If our FIN is now 3713 acknowledged, delete the TCB, enter the CLOSED state, 3714 and return. 3716 + TIME-WAIT STATE 3718 * The only thing that can arrive in this state is a 3719 retransmission of the remote FIN. Acknowledge it, and 3720 restart the 2 MSL timeout. 3722 - sixth, check the URG bit, 3724 o ESTABLISHED STATE 3726 FIN-WAIT-1 STATE 3728 FIN-WAIT-2 STATE 3730 + If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and 3731 signal the user that the remote side has urgent data if 3732 the urgent pointer (RCV.UP) is in advance of the data 3733 consumed. If the user has already been signaled (or is 3734 still in the "urgent mode") for this continuous sequence 3735 of urgent data, do not signal the user again. 3737 o CLOSE-WAIT STATE 3739 CLOSING STATE 3741 LAST-ACK STATE 3743 TIME-WAIT 3745 + This should not occur, since a FIN has been received from 3746 the remote side. Ignore the URG. 3748 - seventh, process the segment text, 3750 o ESTABLISHED STATE 3751 FIN-WAIT-1 STATE 3753 FIN-WAIT-2 STATE 3755 + Once in the ESTABLISHED state, it is possible to deliver 3756 segment text to user RECEIVE buffers. Text from segments 3757 can be moved into buffers until either the buffer is full 3758 or the segment is empty. If the segment empties and 3759 carries a PUSH flag, then the user is informed, when the 3760 buffer is returned, that a PUSH has been received. 3762 + When the TCP endpoint takes responsibility for delivering 3763 the data to the user it must also acknowledge the receipt 3764 of the data. 3766 + Once the TCP endpoint takes responsibility for the data 3767 it advances RCV.NXT over the data accepted, and adjusts 3768 RCV.WND as appropriate to the current buffer 3769 availability. The total of RCV.NXT and RCV.WND should 3770 not be reduced. 3772 + A TCP implementation MAY send an ACK segment 3773 acknowledging RCV.NXT when a valid segment arrives that 3774 is in the window but not at the left window edge (MAY- 3775 13). 3777 + Please note the window management suggestions in 3778 Section 3.8. 3780 + Send an acknowledgment of the form: 3782 * 3784 + This acknowledgment should be piggybacked on a segment 3785 being transmitted if possible without incurring undue 3786 delay. 3788 o CLOSE-WAIT STATE 3790 CLOSING STATE 3792 LAST-ACK STATE 3794 TIME-WAIT STATE 3796 + This should not occur, since a FIN has been received from 3797 the remote side. Ignore the segment text. 3799 - eighth, check the FIN bit, 3801 o Do not process the FIN if the state is CLOSED, LISTEN or 3802 SYN-SENT since the SEG.SEQ cannot be validated; drop the 3803 segment and return. 3805 o If the FIN bit is set, signal the user "connection closing" 3806 and return any pending RECEIVEs with same message, advance 3807 RCV.NXT over the FIN, and send an acknowledgment for the 3808 FIN. Note that FIN implies PUSH for any segment text not 3809 yet delivered to the user. 3811 + SYN-RECEIVED STATE 3813 ESTABLISHED STATE 3815 * Enter the CLOSE-WAIT state. 3817 + FIN-WAIT-1 STATE 3819 * If our FIN has been ACKed (perhaps in this segment), 3820 then enter TIME-WAIT, start the time-wait timer, turn 3821 off the other timers; otherwise enter the CLOSING 3822 state. 3824 + FIN-WAIT-2 STATE 3826 * Enter the TIME-WAIT state. Start the time-wait timer, 3827 turn off the other timers. 3829 + CLOSE-WAIT STATE 3831 * Remain in the CLOSE-WAIT state. 3833 + CLOSING STATE 3835 * Remain in the CLOSING state. 3837 + LAST-ACK STATE 3839 * Remain in the LAST-ACK state. 3841 + TIME-WAIT STATE 3843 * Remain in the TIME-WAIT state. Restart the 2 MSL 3844 time-wait timeout. 3846 - and return. 3848 3.10.8. Timeouts 3850 USER TIMEOUT 3852 - For any state if the user timeout expires, flush all queues, 3853 signal the user "error: connection aborted due to user timeout" 3854 in general and for any outstanding calls, delete the TCB, enter 3855 the CLOSED state and return. 3857 RETRANSMISSION TIMEOUT 3859 - For any state if the retransmission timeout expires on a 3860 segment in the retransmission queue, send the segment at the 3861 front of the retransmission queue again, reinitialize the 3862 retransmission timer, and return. 3864 TIME-WAIT TIMEOUT 3866 - If the time-wait timeout expires on a connection delete the 3867 TCB, enter the CLOSED state and return. 3869 4. Glossary 3871 ACK 3872 A control bit (acknowledge) occupying no sequence space, 3873 which indicates that the acknowledgment field of this segment 3874 specifies the next sequence number the sender of this segment 3875 is expecting to receive, hence acknowledging receipt of all 3876 previous sequence numbers. 3878 connection 3879 A logical communication path identified by a pair of sockets. 3881 datagram 3882 A message sent in a packet switched computer communications 3883 network. 3885 Destination Address 3886 The network layer address of the remote endpoint. 3888 FIN 3889 A control bit (finis) occupying one sequence number, which 3890 indicates that the sender will send no more data or control 3891 occupying sequence space. 3893 fragment 3894 A portion of a logical unit of data, in particular an 3895 internet fragment is a portion of an internet datagram. 3897 header 3898 Control information at the beginning of a message, segment, 3899 fragment, packet or block of data. 3901 host 3902 A computer. In particular a source or destination of 3903 messages from the point of view of the communication network. 3905 Identification 3906 An Internet Protocol field. This identifying value assigned 3907 by the sender aids in assembling the fragments of a datagram. 3909 internet address 3910 A network layer address. 3912 internet datagram 3913 The unit of data exchanged between an internet module and the 3914 higher level protocol together with the internet header. 3916 internet fragment 3917 A portion of the data of an internet datagram with an 3918 internet header. 3920 IP 3921 Internet Protocol. See [1] and [13]. 3923 IRS 3924 The Initial Receive Sequence number. The first sequence 3925 number used by the sender on a connection. 3927 ISN 3928 The Initial Sequence Number. The first sequence number used 3929 on a connection, (either ISS or IRS). Selected in a way that 3930 is unique within a given period of time and is unpredictable 3931 to attackers. 3933 ISS 3934 The Initial Send Sequence number. The first sequence number 3935 used by the sender on a connection. 3937 left sequence 3938 This is the next sequence number to be acknowledged by the 3939 data receiving TCP endpoint (or the lowest currently 3940 unacknowledged sequence number) and is sometimes referred to 3941 as the left edge of the send window. 3943 module 3944 An implementation, usually in software, of a protocol or 3945 other procedure. 3947 MSL 3948 Maximum Segment Lifetime, the time a TCP segment can exist in 3949 the internetwork system. Arbitrarily defined to be 2 3950 minutes. 3952 octet 3953 An eight bit byte. 3955 Options 3956 An Option field may contain several options, and each option 3957 may be several octets in length. 3959 packet 3960 A package of data with a header that may or may not be 3961 logically complete. More often a physical packaging than a 3962 logical packaging of data. 3964 port 3965 The portion of a connection identifier used for 3966 demultiplexing connections at an endpoint. 3968 process 3969 A program in execution. A source or destination of data from 3970 the point of view of the TCP endpoint or other host-to-host 3971 protocol. 3973 PUSH 3974 A control bit occupying no sequence space, indicating that 3975 this segment contains data that must be pushed through to the 3976 receiving user. 3978 RCV.NXT 3979 receive next sequence number 3981 RCV.UP 3982 receive urgent pointer 3984 RCV.WND 3985 receive window 3987 receive next sequence number 3988 This is the next sequence number the local TCP endpoint is 3989 expecting to receive. 3991 receive window 3992 This represents the sequence numbers the local (receiving) 3993 TCP endpoint is willing to receive. Thus, the local TCP 3994 endpoint considers that segments overlapping the range 3995 RCV.NXT to RCV.NXT + RCV.WND - 1 carry acceptable data or 3996 control. Segments containing sequence numbers entirely 3997 outside of this range are considered duplicates and 3998 discarded. 4000 RST 4001 A control bit (reset), occupying no sequence space, 4002 indicating that the receiver should delete the connection 4003 without further interaction. The receiver can determine, 4004 based on the sequence number and acknowledgment fields of the 4005 incoming segment, whether it should honor the reset command 4006 or ignore it. In no case does receipt of a segment 4007 containing RST give rise to a RST in response. 4009 SEG.ACK 4010 segment acknowledgment 4012 SEG.LEN 4013 segment length 4015 SEG.SEQ 4016 segment sequence 4018 SEG.UP 4019 segment urgent pointer field 4021 SEG.WND 4022 segment window field 4024 segment 4025 A logical unit of data, in particular a TCP segment is the 4026 unit of data transferred between a pair of TCP modules. 4028 segment acknowledgment 4029 The sequence number in the acknowledgment field of the 4030 arriving segment. 4032 segment length 4033 The amount of sequence number space occupied by a segment, 4034 including any controls that occupy sequence space. 4036 segment sequence 4037 The number in the sequence field of the arriving segment. 4039 send sequence 4040 This is the next sequence number the local (sending) TCP 4041 endpoint will use on the connection. It is initially 4042 selected from an initial sequence number curve (ISN) and is 4043 incremented for each octet of data or sequenced control 4044 transmitted. 4046 send window 4047 This represents the sequence numbers that the remote 4048 (receiving) TCP endpoint is willing to receive. It is the 4049 value of the window field specified in segments from the 4050 remote (data receiving) TCP endpoint. The range of new 4051 sequence numbers that may be emitted by a TCP implementation 4052 lies between SND.NXT and SND.UNA + SND.WND - 1. 4053 (Retransmissions of sequence numbers between SND.UNA and 4054 SND.NXT are expected, of course.) 4056 SND.NXT 4057 send sequence 4059 SND.UNA 4060 left sequence 4062 SND.UP 4063 send urgent pointer 4065 SND.WL1 4066 segment sequence number at last window update 4068 SND.WL2 4069 segment acknowledgment number at last window update 4071 SND.WND 4072 send window 4074 socket (or socket number, or socket address, or socket identifier) 4075 An address that specifically includes a port identifier, that 4076 is, the concatenation of an Internet Address with a TCP port. 4078 Source Address 4079 The network layer address of the sending endpoint. 4081 SYN 4082 A control bit in the incoming segment, occupying one sequence 4083 number, used at the initiation of a connection, to indicate 4084 where the sequence numbering will start. 4086 TCB 4087 Transmission control block, the data structure that records 4088 the state of a connection. 4090 TCP 4091 Transmission Control Protocol: A host-to-host protocol for 4092 reliable communication in internetwork environments. 4094 TOS 4095 Type of Service, an obsoleted IPv4 field. The same header 4096 bits currently are used for the Differentiated Services field 4097 [4] containing the Differentiated Services Code Point (DSCP) 4098 value and the 2-bit ECN codepoint [7]. 4100 Type of Service 4101 See "TOS". 4103 URG 4104 A control bit (urgent), occupying no sequence space, used to 4105 indicate that the receiving user should be notified to do 4106 urgent processing as long as there is data to be consumed 4107 with sequence numbers less than the value indicated in the 4108 urgent pointer. 4110 urgent pointer 4111 A control field meaningful only when the URG bit is on. This 4112 field communicates the value of the urgent pointer that 4113 indicates the data octet associated with the sending user's 4114 urgent call. 4116 5. Changes from RFC 793 4118 This document obsoletes RFC 793 as well as RFC 6093 and 6528, which 4119 updated 793. In all cases, only the normative protocol specification 4120 and requirements have been incorporated into this document, and some 4121 informational text with background and rationale may not have been 4122 carried in. The informational content of those documents is still 4123 valuable in learning about and understanding TCP, and they are valid 4124 Informational references, even though their normative content has 4125 been incorporated into this document. 4127 The main body of this document was adapted from RFC 793's Section 3, 4128 titled "FUNCTIONAL SPECIFICATION", with an attempt to keep formatting 4129 and layout as close as possible. 4131 The collection of applicable RFC Errata that have been reported and 4132 either accepted or held for an update to RFC 793 were incorporated 4133 (Errata IDs: 573, 574, 700, 701, 1283, 1561, 1562, 1564, 1565, 1571, 4134 1572, 2296, 2297, 2298, 2748, 2749, 2934, 3213, 3300, 3301, 6222). 4135 Some errata were not applicable due to other changes (Errata IDs: 4136 572, 575, 1569, 3305, 3602). 4138 Changes to the specification of the Urgent Pointer described in RFC 4139 1122 and 6093 were incorporated. See RFC 6093 for detailed 4140 discussion of why these changes were necessary. 4142 The discussion of the RTO from RFC 793 was updated to refer to RFC 4143 6298. The RFC 1122 text on the RTO originally replaced the 793 text, 4144 however, RFC 2988 should have updated 1122, and has subsequently been 4145 obsoleted by 6298. 4147 RFC 1122 contains a collection of other changes and clarifications to 4148 RFC 793. The normative items impacting the protocol have been 4149 incorporated here, though some historically useful implementation 4150 advice and informative discussion from RFC 1122 is not included here. 4152 RFC 1122 contains more than just TCP requirements, so this document 4153 can't obsolete RFC 1122 entirely. It is only marked as "updating" 4154 1122, however, it should be understood to effectively obsolete all of 4155 the RFC 1122 material on TCP. 4157 The more secure Initial Sequence Number generation algorithm from RFC 4158 6528 was incorporated. See RFC 6528 for discussion of the attacks 4159 that this mitigates, as well as advice on selecting PRF algorithms 4160 and managing secret key data. 4162 A note based on RFC 6429 was added to explicitly clarify that system 4163 resource management concerns allow connection resources to be 4164 reclaimed. RFC 6429 is obsoleted in the sense that this 4165 clarification has been reflected in this update to the base TCP 4166 specification now. 4168 The description of congestion control implementation was added, based 4169 on the set of documents that are IETF BCP or Standards Track on the 4170 topic, and the current state of common implementations. 4172 RFC EDITOR'S NOTE: the content below is for detailed change tracking 4173 and planning, and not to be included with the final revision of the 4174 document. 4176 This document started as draft-eddy-rfc793bis-00, that was merely a 4177 proposal and rough plan for updating RFC 793. 4179 The -01 revision of this draft-eddy-rfc793bis incorporates the 4180 content of RFC 793 Section 3 titled "FUNCTIONAL SPECIFICATION". 4181 Other content from RFC 793 has not been incorporated. The -01 4182 revision of this document makes some minor formatting changes to the 4183 RFC 793 content in order to convert the content into XML2RFC format 4184 and account for left-out parts of RFC 793. For instance, figure 4185 numbering differs and some indentation is not exactly the same. 4187 The -02 revision of draft-eddy-rfc793bis incorporates errata that 4188 have been verified: 4190 Errata ID 573: Reported by Bob Braden (note: This errata basically 4191 is just a reminder that RFC 1122 updates 793. Some of the 4192 associated changes are left pending to a separate revision that 4193 incorporates 1122. Bob's mention of PUSH in 793 section 2.8 was 4194 not applicable here because that section was not part of the 4195 "functional specification". Also the 1122 text on the 4196 retransmission timeout also has been updated by subsequent RFCs, 4197 so the change here deviates from Bob's suggestion to apply the 4198 1122 text.) 4199 Errata ID 574: Reported by Yin Shuming 4200 Errata ID 700: Reported by Yin Shuming 4201 Errata ID 701: Reported by Yin Shuming 4202 Errata ID 1283: Reported by Pei-chun Cheng 4203 Errata ID 1561: Reported by Constantin Hagemeier 4204 Errata ID 1562: Reported by Constantin Hagemeier 4205 Errata ID 1564: Reported by Constantin Hagemeier 4206 Errata ID 1565: Reported by Constantin Hagemeier 4207 Errata ID 1571: Reported by Constantin Hagemeier 4208 Errata ID 1572: Reported by Constantin Hagemeier 4209 Errata ID 2296: Reported by Vishwas Manral 4210 Errata ID 2297: Reported by Vishwas Manral 4211 Errata ID 2298: Reported by Vishwas Manral 4212 Errata ID 2748: Reported by Mykyta Yevstifeyev 4213 Errata ID 2749: Reported by Mykyta Yevstifeyev 4214 Errata ID 2934: Reported by Constantin Hagemeier 4215 Errata ID 3213: Reported by EugnJun Yi 4216 Errata ID 3300: Reported by Botong Huang 4217 Errata ID 3301: Reported by Botong Huang 4218 Errata ID 3305: Reported by Botong Huang 4219 Note: Some verified errata were not used in this update, as they 4220 relate to sections of RFC 793 elided from this document. These 4221 include Errata ID 572, 575, and 1569. 4222 Note: Errata ID 3602 was not applied in this revision as it is 4223 duplicative of the 1122 corrections. 4225 Not related to RFC 793 content, this revision also makes small tweaks 4226 to the introductory text, fixes indentation of the pseudo header 4227 diagram, and notes that the Security Considerations should also 4228 include privacy, when this section is written. 4230 The -03 revision of draft-eddy-rfc793bis revises all discussion of 4231 the urgent pointer in order to comply with RFC 6093, 1122, and 1011. 4232 Since 1122 held requirements on the urgent pointer, the full list of 4233 requirements was brought into an appendix of this document, so that 4234 it can be updated as-needed. 4236 The -04 revision of draft-eddy-rfc793bis includes the ISN generation 4237 changes from RFC 6528. 4239 The -05 revision of draft-eddy-rfc793bis incorporates MSS 4240 requirements and definitions from RFC 879, 1122, and 6691, as well as 4241 option-handling requirements from RFC 1122. 4243 The -00 revision of draft-ietf-tcpm-rfc793bis incorporates several 4244 additional clarifications and updates to the section on segmentation, 4245 many of which are based on feedback from Joe Touch improving from the 4246 initial text on this in the previous revision. 4248 The -01 revision incorporates the change to Reserved bits due to ECN, 4249 as well as many other changes that come from RFC 1122. 4251 The -02 revision has small formatting modifications in order to 4252 address xml2rfc warnings about long lines. It was a quick update to 4253 avoid document expiration. TCPM working group discussion in 2015 4254 also indicated that that we should not try to add sections on 4255 implementation advice or similar non-normative information. 4257 The -03 revision incorporates more content from RFC 1122: Passive 4258 OPEN Calls, Time-To-Live, Multihoming, IP Options, ICMP messages, 4259 Data Communications, When to Send Data, When to Send a Window Update, 4260 Managing the Window, Probing Zero Windows, When to Send an ACK 4261 Segment. The section on data communications was re-organized into 4262 clearer subsections (previously headings were embedded in the 793 4263 text), and windows management advice from 793 was removed (as 4264 reviewed by TCPM working group) in favor of the 1122 additions on 4265 SWS, ZWP, and related topics. 4267 The -04 revision includes reference to RFC 6429 on the ZWP condition, 4268 RFC1122 material on TCP Connection Failures, TCP Keep-Alives, 4269 Acknowledging Queued Segments, and Remote Address Validation. RTO 4270 computation is referenced from RFC 6298 rather than RFC 1122. 4272 The -05 revision includes the requirement to implement TCP congestion 4273 control with recommendation to implement ECN, the RFC 6633 update to 4274 1122, which changed the requirement on responding to source quench 4275 ICMP messages, and discussion of ICMP (and ICMPv6) soft and hard 4276 errors per RFC 5461 (ICMPv6 handling for TCP doesn't seem to be 4277 mentioned elsewhere in standards track). 4279 The -06 revision includes an appendix on "Other Implementation Notes" 4280 to capture widely-deployed fundamental features that are not 4281 contained in the RFC series yet. It also added mention of RFC 6994 4282 and the IANA TCP parameters registry as a reference. It includes 4283 references to RFC 5961 in appropriate places. The references to TOS 4284 were changed to DiffServ field, based on reflecting RFC 2474 as well 4285 as the IPv6 presence of traffic class (carrying DiffServ field) 4286 rather than TOS. 4288 The -07 revision includes reference to RFC 6191, updated security 4289 considerations, discussion of additional implementation 4290 considerations, and clarification of data on the SYN. 4292 The -08 revision includes changes based on: 4294 describing treatment of reserved bits (following TCPM mailing list 4295 thread from July 2014 on "793bis item - reserved bit behavior" 4296 addition a brief TCP key concepts section to make up for not 4297 including the outdated section 2 of RFC 793 4298 changed "TCP" to "host" to resolve conflict between 1122 wording 4299 on whether TCP or the network layer chooses an address when 4300 multihomed 4301 fixed/updated definition of options in glossary 4302 moved note on aggregating ACKs from 1122 to a more appropriate 4303 location 4304 resolved notes on IP precedence and security/compartment 4305 added implementation note on sequence number validation 4306 added note that PUSH does not apply when Nagle is active 4307 added 1122 content on asynchronous reports to replace 793 section 4308 on TCP to user messages 4310 The -09 revision fixes section numbering problems. 4312 The -10 revision includes additions to the security considerations 4313 based on comments from Joe Touch, and suggested edits on RST/FIN 4314 notification, RFC 2525 reference, and other edits suggested by 4315 Yuchung Cheng, as well as modifications to DiffServ text from Yuchung 4316 Cheng and Gorry Fairhurst. 4318 The -11 revision includes a start at identifying all of the 4319 requirements text and referencing each instance in the common table 4320 at the end of the document. 4322 The -12 revision completes the requirement language indexing started 4323 in -11 and adds necessary description of the PUSH functionality that 4324 was missing. 4326 The -13 revision contains only changes in the inline editor notes. 4328 The -14 revision includes updates with regard to several comments 4329 from the mailing list, including editorial fixes, adding IANA 4330 considerations for the header flags, improving figure title 4331 placement, and breaking up the "Terminology" section into more 4332 appropriately titled subsections. 4334 The -15 revision has many technical and editorial corrections from 4335 Gorry Fairhurst's review, and subsequent discussion on the TCPM list, 4336 as well as some other collected clarifications and improvements from 4337 mailing list discussion. 4339 The -16 revision addresses several discussions that rose from 4340 additional reviews and follow-up on some of Gorry Fairhurst's 4341 comments from revision 14. 4343 The -17 revision includes errata 6222 from Charles Deng, update to 4344 the key words boilerplate, updated description of the header flags 4345 registry changes, and clarification about connections rather than 4346 users in the discussion of OPEN calls. 4348 The -18 revision includes editorial changes to the IANA 4349 considerations, based on comments from Richard Scheffenegger at the 4350 IETF 108 TCPM virtual meeting. 4352 The -19 revision includes editorial changes from Errata 6281 and 6282 4353 reported by Merlin Buge. It also includes WGLC changes noted by 4354 Mohamed Boucadair, Rahul Jadhav, Praveen Balasubramanian, Matt Olson, 4355 Yi Huang, Joe Touch, and Juhamatti Kuusisaari. 4357 The -20 revision includes text on congestion control based on mailing 4358 list and meeting discussion, put together in its final form by Markku 4359 Kojo. It also clarifies that SACK, WS, and TS options are 4360 recommended for high performance, but not needed for basic 4361 interoperability. It also clarifies that the length field is 4362 required for new TCP options. 4364 The -21 revision includes slight changes to the header diagram for 4365 compatibility with tooling, from Stephen McQuistin, clarification on 4366 the meaning of idle connections from Yuchung Cheng, Neal Cardwell, 4367 Michael Scharf, and Richard Scheffenegger, editorial improvements 4368 from Markku Kojo, notes that some stacks suppress extra 4369 acknowledgments of the SYN when SYN-ACK carries data from Richard 4370 Scheffenegger, and adds MAY-18 numbering based on note from Jonathan 4371 Morton. 4373 The -22 revision includes small clarifications on terminology (might 4374 versus may) and IPv6 extension headers versus IPv4 options, based on 4375 comments from Gorry Fairhurst. 4377 The -23 revision has a fix to indentation from Michael Tuexen and 4378 idnits issues addressed from Michael Scharf. 4380 The -24 revision incorporates changes after Martin Duke's AD review, 4381 including further feedback on those comments from Yuchung Cheng and 4382 Joe Touch. Important changes for review include (1) removal of the 4383 need to check for the PUSH flag when evaluating the SWS override 4384 timer expiration, (2) clarification about receding urgent pointer, 4385 and (3) de-duplicating handling of the RST checking between step 4 4386 and step 1. 4388 The -25 revision incorporates changes based on the GENART review from 4389 Francis Dupont, SECDIR review from Kyle Rose, and OPSDIR review from 4390 Sarah Banks. 4392 Some other suggested changes that will not be incorporated in this 4393 793 update unless TCPM consensus changes with regard to scope are: 4395 1. Tony Sabatini's suggestion for describing DO field 4396 2. Per discussion with Joe Touch (TAPS list, 6/20/2015), the 4397 description of the API could be revisited 4398 3. Reducing the R2 value for SYNs has been suggested as a possible 4399 topic for future consideration. 4401 Early in the process of updating RFC 793, Scott Brim mentioned that 4402 this should include a PERPASS/privacy review. This may be something 4403 for the chairs or AD to request during WGLC or IETF LC. 4405 6. IANA Considerations 4407 In the "Transmission Control Protocol (TCP) Header Flags" registry, 4408 IANA is asked to make several changes described in this section. 4410 RFC 3168 originally created this registry, but only populated it with 4411 the new bits defined in RFC 3168, neglecting the other bits that had 4412 previously been described in RFC 793 and other documents. Bit 7 has 4413 since also been updated by RFC 8311. 4415 The "Bit" column is renamed below as the "Bit Offset" column, since 4416 it references each header flag's offset within the 16-bit aligned 4417 view of the TCP header in Figure 1. The bits in offsets 0 through 4 4418 are the TCP segment Data Offset field, and not header flags. 4420 IANA should add a column for "Assignment Notes". 4422 IANA should assign values indicated below. 4424 TCP Header Flags 4426 Bit Name Reference Assignment Notes 4427 Offset 4428 --- ---- --------- ---------------- 4429 4 Reserved for future use (this document) 4430 5 Reserved for future use (this document) 4431 6 Reserved for future use (this document) 4432 7 Reserved for future use [RFC8311] Previously used by Historic [RFC3540] as NS (Nonce Sum) 4433 8 CWR (Congestion Window Reduced) [RFC3168] 4434 9 ECE (ECN-Echo) [RFC3168] 4435 10 Urgent Pointer field is significant (URG) (this document) 4436 11 Acknowledgment field is significant (ACK) (this document) 4437 12 Push Function (PSH) (this document) 4438 13 Reset the connection (RST) (this document) 4439 14 Synchronize sequence numbers (SYN) (this document) 4440 15 No more data from sender (FIN) (this document) 4442 This TCP Header Flags registry should also be moved to a sub-registry 4443 under the global "Transmission Control Protocol (TCP) Parameters 4444 registry (https://www.iana.org/assignments/tcp-parameters/tcp- 4445 parameters.xhtml). 4447 The registry's Registration Procedure should remain Standards Action, 4448 but the Reference can be updated to this document, and the Note 4449 removed. 4451 7. Security and Privacy Considerations 4453 The TCP design includes only rudimentary security features that 4454 improve the robustness and reliability of connections and application 4455 data transfer, but there are no built-in cryptographic capabilities 4456 to support any form of privacy, authentication, or other typical 4457 security functions. Non-cryptographic enhancements (e.g. [37]) have 4458 been developed to improve robustness of TCP connections to particular 4459 types of attacks, but the applicability and protections of non- 4460 cryptographic enhancements are limited (e.g. see section 1.1 of 4461 [37]). Applications typically utilize lower-layer (e.g. IPsec) and 4462 upper-layer (e.g. TLS) protocols to provide security and privacy for 4463 TCP connections and application data carried in TCP. Methods based 4464 on TCP options have been developed as well, to support some security 4465 capabilities. 4467 In order to fully protect TCP connections (including their control 4468 flags) IPsec or the TCP Authentication Option (TCP-AO) [36] are the 4469 only current effective methods. Other methods discussed in this 4470 section may protect the payload, but either only a subset of the 4471 fields (e.g. tcpcrypt [55]) or none at all (e.g. TLS). Other 4472 security features that have been added to TCP (e.g. ISN generation, 4473 sequence number checks, and others) are only capable of partially 4474 hindering attacks. 4476 Applications using long-lived TCP flows have been vulnerable to 4477 attacks that exploit the processing of control flags described in 4478 earlier TCP specifications [31]. TCP-MD5 was a commonly implemented 4479 TCP option to support authentication for some of these connections, 4480 but had flaws and is now deprecated. TCP-AO provides a capability to 4481 protect long-lived TCP connections from attacks, and has superior 4482 properties to TCP-MD5. It does not provide any privacy for 4483 application data, nor for the TCP headers. 4485 The "tcpcrypt" [55] Experimental extension to TCP provides the 4486 ability to cryptographically protect connection data. Metadata 4487 aspects of the TCP flow are still visible, but the application stream 4488 is well-protected. Within the TCP header, only the urgent pointer 4489 and FIN flag are protected through tcpcrypt. 4491 The TCP Roadmap [48] includes notes about several RFCs related to TCP 4492 security. Many of the enhancements provided by these RFCs have been 4493 integrated into the present document, including ISN generation, 4494 mitigating blind in-window attacks, and improving handling of soft 4495 errors and ICMP packets. These are all discussed in greater detail 4496 in the referenced RFCs that originally described the changes needed 4497 to earlier TCP specifications. Additionally, see RFC 6093 [38] for 4498 discussion of security considerations related to the urgent pointer 4499 field, that has been deprecated. 4501 Since TCP is often used for bulk transfer flows, some attacks are 4502 possible that abuse the TCP congestion control logic. An example is 4503 "ACK-division" attacks. Updates that have been made to the TCP 4504 congestion control specifications include mechanisms like Appropriate 4505 Byte Counting (ABC) [27] that act as mitigations to these attacks. 4507 Other attacks are focused on exhausting the resources of a TCP 4508 server. Examples include SYN flooding [30] or wasting resources on 4509 non-progressing connections [40]. Operating systems commonly 4510 implement mitigations for these attacks. Some common defenses also 4511 utilize proxies, stateful firewalls, and other technologies outside 4512 of the end-host TCP implementation. 4514 The concept of a protocol's "wire image" is described in RFC 8546 4515 [54], which describes how TCP's cleartext headers expose more 4516 metadata to nodes on the path than is strictly required to route the 4517 packets to their destination. On-path adversaries may be able to 4518 leverage this metadata. Lessons learned in this respect from TCP 4519 have been applied in the design of newer transports like QUIC [58]. 4521 Additionally, based partly on experiences with TCP and its 4522 extensions, there are considerations that might be applicable for 4523 future TCP extensions and other transports that the IETF has 4524 documented in RFC 9065 [59], along with IAB recommendations in RFC 4525 8558 [56] and [66]. 4527 8. Acknowledgements 4529 This document is largely a revision of RFC 793, which Jon Postel was 4530 the editor of. Due to his excellent work, it was able to last for 4531 three decades before we felt the need to revise it. 4533 Andre Oppermann was a contributor and helped to edit the first 4534 revision of this document. 4536 We are thankful for the assistance of the IETF TCPM working group 4537 chairs, over the course of work on this document: 4539 Michael Scharf 4541 Yoshifumi Nishida 4543 Pasi Sarolahti 4545 Michael Tuexen 4547 During the discussions of this work on the TCPM mailing list, in 4548 working group meetings, and via area reviews, helpful comments, 4549 critiques, and reviews were received from (listed alphabetically by 4550 last name): Praveen Balasubramanian, David Borman, Mohamed Boucadair, 4551 Bob Briscoe, Neal Cardwell, Yuchung Cheng, Martin Duke, Francis 4552 Dupont, Ted Faber, Gorry Fairhurst, Fernando Gont, Rodney Grimes, Yi 4553 Huang, Rahul Jadhav, Markku Kojo, Mike Kosek, Juhamatti Kuusisaari, 4554 Kevin Lahey, Kevin Mason, Matt Mathis, Stephen McQuistin, Jonathan 4555 Morton, Matt Olson, Tommy Pauly, Tom Petch, Hagen Paul Pfeifer, Kyle 4556 Rose, Anthony Sabatini, Michael Scharf, Greg Skinner, Joe Touch, 4557 Michael Tuexen, Reji Varghese, Tim Wicinski, Lloyd Wood, and Alex 4558 Zimmermann. 4560 Joe Touch provided additional help in clarifying the description of 4561 segment size parameters and PMTUD/PLPMTUD recommendations. Markku 4562 Kojo helped put together the text in the section on TCP Congestion 4563 Control. 4565 This document includes content from errata that were reported by 4566 (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, 4567 Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta 4568 Yevstifeyev, EungJun Yi, Botong Huang, Charles Deng, Merlin Buge. 4570 9. References 4572 9.1. Normative References 4574 [1] Postel, J., "Internet Protocol", STD 5, RFC 791, 4575 DOI 10.17487/RFC0791, September 1981, 4576 . 4578 [2] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 4579 DOI 10.17487/RFC1191, November 1990, 4580 . 4582 [3] Bradner, S., "Key words for use in RFCs to Indicate 4583 Requirement Levels", BCP 14, RFC 2119, 4584 DOI 10.17487/RFC2119, March 1997, 4585 . 4587 [4] Nichols, K., Blake, S., Baker, F., and D. Black, 4588 "Definition of the Differentiated Services Field (DS 4589 Field) in the IPv4 and IPv6 Headers", RFC 2474, 4590 DOI 10.17487/RFC2474, December 1998, 4591 . 4593 [5] Borman, D., Deering, S., and R. Hinden, "IPv6 Jumbograms", 4594 RFC 2675, DOI 10.17487/RFC2675, August 1999, 4595 . 4597 [6] Floyd, S., "Congestion Control Principles", BCP 41, 4598 RFC 2914, DOI 10.17487/RFC2914, September 2000, 4599 . 4601 [7] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 4602 of Explicit Congestion Notification (ECN) to IP", 4603 RFC 3168, DOI 10.17487/RFC3168, September 2001, 4604 . 4606 [8] Floyd, S. and M. Allman, "Specifying New Congestion 4607 Control Algorithms", BCP 133, RFC 5033, 4608 DOI 10.17487/RFC5033, August 2007, 4609 . 4611 [9] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 4612 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 4613 . 4615 [10] Paxson, V., Allman, M., Chu, J., and M. Sargent, 4616 "Computing TCP's Retransmission Timer", RFC 6298, 4617 DOI 10.17487/RFC6298, June 2011, 4618 . 4620 [11] Gont, F., "Deprecation of ICMP Source Quench Messages", 4621 RFC 6633, DOI 10.17487/RFC6633, May 2012, 4622 . 4624 [12] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 4625 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 4626 May 2017, . 4628 [13] Deering, S. and R. Hinden, "Internet Protocol, Version 6 4629 (IPv6) Specification", STD 86, RFC 8200, 4630 DOI 10.17487/RFC8200, July 2017, 4631 . 4633 [14] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 4634 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 4635 DOI 10.17487/RFC8201, July 2017, 4636 . 4638 [15] Allman, M., "Requirements for Time-Based Loss Detection", 4639 BCP 233, RFC 8961, DOI 10.17487/RFC8961, November 2020, 4640 . 4642 9.2. Informative References 4644 [16] Postel, J., "Transmission Control Protocol", STD 7, 4645 RFC 793, DOI 10.17487/RFC0793, September 1981, 4646 . 4648 [17] Nagle, J., "Congestion Control in IP/TCP Internetworks", 4649 RFC 896, DOI 10.17487/RFC0896, January 1984, 4650 . 4652 [18] Braden, R., Ed., "Requirements for Internet Hosts - 4653 Communication Layers", STD 3, RFC 1122, 4654 DOI 10.17487/RFC1122, October 1989, 4655 . 4657 [19] Almquist, P., "Type of Service in the Internet Protocol 4658 Suite", RFC 1349, DOI 10.17487/RFC1349, July 1992, 4659 . 4661 [20] Braden, R., "T/TCP -- TCP Extensions for Transactions 4662 Functional Specification", RFC 1644, DOI 10.17487/RFC1644, 4663 July 1994, . 4665 [21] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 4666 Selective Acknowledgment Options", RFC 2018, 4667 DOI 10.17487/RFC2018, October 1996, 4668 . 4670 [22] Paxson, V., Allman, M., Dawson, S., Fenner, W., Griner, 4671 J., Heavens, I., Lahey, K., Semke, J., and B. Volz, "Known 4672 TCP Implementation Problems", RFC 2525, 4673 DOI 10.17487/RFC2525, March 1999, 4674 . 4676 [23] Xiao, X., Hannan, A., Paxson, V., and E. Crabbe, "TCP 4677 Processing of the IPv4 Precedence Field", RFC 2873, 4678 DOI 10.17487/RFC2873, June 2000, 4679 . 4681 [24] Floyd, S., Mahdavi, J., Mathis, M., and M. Podolsky, "An 4682 Extension to the Selective Acknowledgement (SACK) Option 4683 for TCP", RFC 2883, DOI 10.17487/RFC2883, July 2000, 4684 . 4686 [25] Lahey, K., "TCP Problems with Path MTU Discovery", 4687 RFC 2923, DOI 10.17487/RFC2923, September 2000, 4688 . 4690 [26] Balakrishnan, H., Padmanabhan, V., Fairhurst, G., and M. 4691 Sooriyabandara, "TCP Performance Implications of Network 4692 Path Asymmetry", BCP 69, RFC 3449, DOI 10.17487/RFC3449, 4693 December 2002, . 4695 [27] Allman, M., "TCP Congestion Control with Appropriate Byte 4696 Counting (ABC)", RFC 3465, DOI 10.17487/RFC3465, February 4697 2003, . 4699 [28] Fenner, B., "Experimental Values In IPv4, IPv6, ICMPv4, 4700 ICMPv6, UDP, and TCP Headers", RFC 4727, 4701 DOI 10.17487/RFC4727, November 2006, 4702 . 4704 [29] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 4705 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 4706 . 4708 [30] Eddy, W., "TCP SYN Flooding Attacks and Common 4709 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 4710 . 4712 [31] Touch, J., "Defending TCP Against Spoofing Attacks", 4713 RFC 4953, DOI 10.17487/RFC4953, July 2007, 4714 . 4716 [32] Culley, P., Elzur, U., Recio, R., Bailey, S., and J. 4717 Carrier, "Marker PDU Aligned Framing for TCP 4718 Specification", RFC 5044, DOI 10.17487/RFC5044, October 4719 2007, . 4721 [33] Gont, F., "TCP's Reaction to Soft Errors", RFC 5461, 4722 DOI 10.17487/RFC5461, February 2009, 4723 . 4725 [34] StJohns, M., Atkinson, R., and G. Thomas, "Common 4726 Architecture Label IPv6 Security Option (CALIPSO)", 4727 RFC 5570, DOI 10.17487/RFC5570, July 2009, 4728 . 4730 [35] Sandlund, K., Pelletier, G., and L-E. Jonsson, "The RObust 4731 Header Compression (ROHC) Framework", RFC 5795, 4732 DOI 10.17487/RFC5795, March 2010, 4733 . 4735 [36] Touch, J., Mankin, A., and R. Bonica, "The TCP 4736 Authentication Option", RFC 5925, DOI 10.17487/RFC5925, 4737 June 2010, . 4739 [37] Ramaiah, A., Stewart, R., and M. Dalal, "Improving TCP's 4740 Robustness to Blind In-Window Attacks", RFC 5961, 4741 DOI 10.17487/RFC5961, August 2010, 4742 . 4744 [38] Gont, F. and A. Yourtchenko, "On the Implementation of the 4745 TCP Urgent Mechanism", RFC 6093, DOI 10.17487/RFC6093, 4746 January 2011, . 4748 [39] Gont, F., "Reducing the TIME-WAIT State Using TCP 4749 Timestamps", BCP 159, RFC 6191, DOI 10.17487/RFC6191, 4750 April 2011, . 4752 [40] Bashyam, M., Jethanandani, M., and A. Ramaiah, "TCP Sender 4753 Clarification for Persist Condition", RFC 6429, 4754 DOI 10.17487/RFC6429, December 2011, 4755 . 4757 [41] Gont, F. and S. Bellovin, "Defending against Sequence 4758 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 4759 2012, . 4761 [42] Borman, D., "TCP Options and Maximum Segment Size (MSS)", 4762 RFC 6691, DOI 10.17487/RFC6691, July 2012, 4763 . 4765 [43] Touch, J., "Updated Specification of the IPv4 ID Field", 4766 RFC 6864, DOI 10.17487/RFC6864, February 2013, 4767 . 4769 [44] Touch, J., "Shared Use of Experimental TCP Options", 4770 RFC 6994, DOI 10.17487/RFC6994, August 2013, 4771 . 4773 [45] McPherson, D., Oran, D., Thaler, D., and E. Osterweil, 4774 "Architectural Considerations of IP Anycast", RFC 7094, 4775 DOI 10.17487/RFC7094, January 2014, 4776 . 4778 [46] Borman, D., Braden, B., Jacobson, V., and R. 4779 Scheffenegger, Ed., "TCP Extensions for High Performance", 4780 RFC 7323, DOI 10.17487/RFC7323, September 2014, 4781 . 4783 [47] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 4784 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 4785 . 4787 [48] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. 4788 Zimmermann, "A Roadmap for Transmission Control Protocol 4789 (TCP) Specification Documents", RFC 7414, 4790 DOI 10.17487/RFC7414, February 2015, 4791 . 4793 [49] Black, D., Ed. and P. Jones, "Differentiated Services 4794 (Diffserv) and Real-Time Communication", RFC 7657, 4795 DOI 10.17487/RFC7657, November 2015, 4796 . 4798 [50] Fairhurst, G. and M. Welzl, "The Benefits of Using 4799 Explicit Congestion Notification (ECN)", RFC 8087, 4800 DOI 10.17487/RFC8087, March 2017, 4801 . 4803 [51] Fairhurst, G., Ed., Trammell, B., Ed., and M. Kuehlewind, 4804 Ed., "Services Provided by IETF Transport Protocols and 4805 Congestion Control Mechanisms", RFC 8095, 4806 DOI 10.17487/RFC8095, March 2017, 4807 . 4809 [52] Welzl, M., Tuexen, M., and N. Khademi, "On the Usage of 4810 Transport Features Provided by IETF Transport Protocols", 4811 RFC 8303, DOI 10.17487/RFC8303, February 2018, 4812 . 4814 [53] Chown, T., Loughney, J., and T. Winters, "IPv6 Node 4815 Requirements", BCP 220, RFC 8504, DOI 10.17487/RFC8504, 4816 January 2019, . 4818 [54] Trammell, B. and M. Kuehlewind, "The Wire Image of a 4819 Network Protocol", RFC 8546, DOI 10.17487/RFC8546, April 4820 2019, . 4822 [55] Bittau, A., Giffin, D., Handley, M., Mazieres, D., Slack, 4823 Q., and E. Smith, "Cryptographic Protection of TCP Streams 4824 (tcpcrypt)", RFC 8548, DOI 10.17487/RFC8548, May 2019, 4825 . 4827 [56] Hardie, T., Ed., "Transport Protocol Path Signals", 4828 RFC 8558, DOI 10.17487/RFC8558, April 2019, 4829 . 4831 [57] Ford, A., Raiciu, C., Handley, M., Bonaventure, O., and C. 4832 Paasch, "TCP Extensions for Multipath Operation with 4833 Multiple Addresses", RFC 8684, DOI 10.17487/RFC8684, March 4834 2020, . 4836 [58] Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 4837 Multiplexed and Secure Transport", RFC 9000, 4838 DOI 10.17487/RFC9000, May 2021, 4839 . 4841 [59] Fairhurst, G. and C. Perkins, "Considerations around 4842 Transport Header Confidentiality, Network Operations, and 4843 the Evolution of Internet Transport Protocols", RFC 9065, 4844 DOI 10.17487/RFC9065, July 2021, 4845 . 4847 [60] IANA, "Transmission Control Protocol (TCP) Parameters, 4848 https://www.iana.org/assignments/tcp-parameters/tcp- 4849 parameters.xhtml", 2019. 4851 [61] IANA, "Transmission Control Protocol (TCP) Header Flags, 4852 https://www.iana.org/assignments/tcp-header-flags/tcp- 4853 header-flags.xhtml", 2019. 4855 [62] Gont, F., "Processing of IP Security/Compartment and 4856 Precedence Information by TCP", Work in Progress, 4857 Internet-Draft, draft-gont-tcpm-tcp-seccomp-prec-00, 29 4858 March 2012, . 4861 [63] Gont, F. and D. Borman, "On the Validation of TCP Sequence 4862 Numbers", Work in Progress, Internet-Draft, draft-gont- 4863 tcpm-tcp-seq-validation-04, 11 March 2019, 4864 . 4867 [64] Touch, J. and W. Eddy, "TCP Extended Data Offset Option", 4868 Work in Progress, Internet-Draft, draft-ietf-tcpm-tcp-edo- 4869 10, 19 July 2018, . 4872 [65] McQuistin, S., Band, V., Jacob, D., and C. Perkins, 4873 "Describing Protocol Data Units with Augmented Packet 4874 Header Diagrams", Work in Progress, Internet-Draft, draft- 4875 mcquistin-augmented-ascii-diagrams-08, 5 May 2021, 4876 . 4879 [66] Thomson, M. and T. Pauly, "Long-term Viability of Protocol 4880 Extension Mechanisms", Work in Progress, Internet-Draft, 4881 draft-iab-use-it-or-lose-it-02, 23 August 2021, 4882 . 4885 [67] Minshall, G., "A Proposed Modification to Nagle's 4886 Algorithm", Work in Progress, Internet-Draft, draft- 4887 minshall-nagle-01, June 1999, 4888 . 4891 [68] Dalal, Y. and C. Sunshine, "Connection Management in 4892 Transport Protocols", Computer Networks Vol. 2, No. 6, pp. 4893 454-473, December 1978. 4895 [69] Faber, T., Touch, J., and W. Yui, "The TIME-WAIT state in 4896 TCP and Its Effect on Busy Servers", Proceedings of IEEE 4897 INFOCOM pp. 1573-1583, March 1999. 4899 Appendix A. Other Implementation Notes 4901 This section includes additional notes and references on TCP 4902 implementation decisions that are currently not a part of the RFC 4903 series or included within the TCP standard. These items can be 4904 considered by implementers, but there was not yet a consensus to 4905 include them in the standard. 4907 A.1. IP Security Compartment and Precedence 4909 The IPv4 specification [1] includes a precedence value in the (now 4910 obsoleted) Type of Service field (TOS) field. It was modified in 4911 [19], and then obsoleted by the definition of Differentiated Services 4912 (DiffServ) [4]. Setting and conveying TOS between the network layer, 4913 TCP implementation, and applications is obsolete, and replaced by 4914 DiffServ in the current TCP specification. 4916 RFC 793 requires checking the IP security compartment and precedence 4917 on incoming TCP segments for consistency within a connection, and 4918 with application requests. Each of these aspects of IP have become 4919 outdated, without specific updates to RFC 793. The issues with 4920 precedence were fixed by [23], which is Standards Track, and so this 4921 present TCP specification includes those changes. However, the state 4922 of IP security options that may be used by MLS systems is not as 4923 clean. 4925 Resetting connections when incoming packets do not meet expected 4926 security compartment or precedence expectations has been recognized 4927 as a possible attack vector [62], and there has been discussion about 4928 amending the TCP specification to prevent connections from being 4929 aborted due to non-matching IP security compartment and DiffServ 4930 codepoint values. 4932 A.1.1. Precedence 4934 In DiffServ the former precedence values are treated as Class 4935 Selector codepoints, and methods for compatible treatment are 4936 described in the DiffServ architecture. The RFC 793/1122 TCP 4937 specification includes logic intending to have connections use the 4938 highest precedence requested by either endpoint application, and to 4939 keep the precedence consistent throughout a connection. This logic 4940 from the obsolete TOS is not applicable for DiffServ, and should not 4941 be included in TCP implementations, though changes to DiffServ values 4942 within a connection are discouraged. For discussion of this, see RFC 4943 7657 (sec 5.1, 5.3, and 6) [49]. 4945 The obsoleted TOS processing rules in TCP assumed bidirectional (or 4946 symmetric) precedence values used on a connection, but the DiffServ 4947 architecture is asymmetric. Problems with the old TCP logic in this 4948 regard were described in [23] and the solution described is to ignore 4949 IP precedence in TCP. Since RFC 2873 is a Standards Track document 4950 (although not marked as updating RFC 793), current implementations 4951 are expected to be robust to these conditions. Note that the 4952 DiffServ field value used in each direction is a part of the 4953 interface between TCP and the network layer, and values in use can be 4954 indicated both ways between TCP and the application. 4956 A.1.2. MLS Systems 4958 The IP security option (IPSO) and compartment defined in [1] was 4959 refined in RFC 1038 that was later obsoleted by RFC 1108. The 4960 Commercial IP Security Option (CIPSO) is defined in FIPS-188, and is 4961 supported by some vendors and operating systems. RFC 1108 is now 4962 Historic, though RFC 791 itself has not been updated to remove the IP 4963 security option. For IPv6, a similar option (CALIPSO) has been 4964 defined [34]. RFC 793 includes logic that includes the IP security/ 4965 compartment information in treatment of TCP segments. References to 4966 the IP "security/compartment" in this document may be relevant for 4967 Multi-Level Secure (MLS) system implementers, but can be ignored for 4968 non-MLS implementations, consistent with running code on the 4969 Internet. See Appendix A.1 for further discussion. Note that RFC 4970 5570 describes some MLS networking scenarios where IPSO, CIPSO, or 4971 CALIPSO may be used. In these special cases, TCP implementers should 4972 see section 7.3.1 of RFC 5570, and follow the guidance in that 4973 document. 4975 A.2. Sequence Number Validation 4977 There are cases where the TCP sequence number validation rules can 4978 prevent ACK fields from being processed. This can result in 4979 connection issues, as described in [63], which includes descriptions 4980 of potential problems in conditions of simultaneous open, self- 4981 connects, simultaneous close, and simultaneous window probes. The 4982 document also describes potential changes to the TCP specification to 4983 mitigate the issue by expanding the acceptable sequence numbers. 4985 In Internet usage of TCP, these conditions are rarely occurring. 4986 Common operating systems include different alternative mitigations, 4987 and the standard has not been updated yet to codify one of them, but 4988 implementers should consider the problems described in [63]. 4990 A.3. Nagle Modification 4992 In common operating systems, both the Nagle algorithm and delayed 4993 acknowledgements are implemented and enabled by default. TCP is used 4994 by many applications that have a request-response style of 4995 communication, where the combination of the Nagle algorithm and 4996 delayed acknowledgements can result in poor application performance. 4997 A modification to the Nagle algorithm is described in [67] that 4998 improves the situation for these applications. 5000 This modification is implemented in some common operating systems, 5001 and does not impact TCP interoperability. Additionally, many 5002 applications simply disable Nagle, since this is generally supported 5003 by a socket option. The TCP standard has not been updated to include 5004 this Nagle modification, but implementers may find it beneficial to 5005 consider. 5007 A.4. Low Water Mark Settings 5009 Some operating system kernel TCP implementations include socket 5010 options that allow specifying the number of bytes in the buffer until 5011 the socket layer will pass sent data to TCP (SO_SNDLOWAT) or to the 5012 application on receiving (SO_RCVLOWAT). 5014 In addition, another socket option (TCP_NOTSENT_LOWAT) can be used to 5015 control the amount of unsent bytes in the write queue. This can help 5016 a sending TCP application to avoid creating large amounts of buffered 5017 data (and corresponding latency). As an example, this may be useful 5018 for applications that are multiplexing data from multiple upper level 5019 streams onto a connection, especially when streams may be a mix of 5020 interactive / real-time and bulk data transfer. 5022 Appendix B. TCP Requirement Summary 5024 This section is adapted from RFC 1122. 5026 Note that there is no requirement related to PLPMTUD in this list, 5027 but that PLPMTUD is recommended. 5029 | | | | |S| | 5030 | | | | |H| |F 5031 | | | | |O|M|o 5032 | | |S| |U|U|o 5033 | | |H| |L|S|t 5034 | |M|O| |D|T|n 5035 | |U|U|M| | |o 5036 | |S|L|A|N|N|t 5037 | |T|D|Y|O|O|t 5039 FEATURE | ReqID | | | |T|T|e 5040 -------------------------------------------------|--------|-|-|-|-|-|-- 5041 | | | | | | | 5042 Push flag | | | | | | | 5043 Aggregate or queue un-pushed data | MAY-16 | | |x| | | 5044 Sender collapse successive PSH flags | SHLD-27| |x| | | | 5045 SEND call can specify PUSH | MAY-15 | | |x| | | 5046 If cannot: sender buffer indefinitely | MUST-60| | | | |x| 5047 If cannot: PSH last segment | MUST-61|x| | | | | 5048 Notify receiving ALP of PSH | MAY-17 | | |x| | |1 5049 Send max size segment when possible | SHLD-28| |x| | | | 5050 | | | | | | | 5051 Window | | | | | | | 5052 Treat as unsigned number | MUST-1 |x| | | | | 5053 Handle as 32-bit number | REC-1 | |x| | | | 5054 Shrink window from right | SHLD-14| | | |x| | 5055 - Send new data when window shrinks | SHLD-15| | | |x| | 5056 - Retransmit old unacked data within window | SHLD-16| |x| | | | 5057 - Time out conn for data past right edge | SHLD-17| | | |x| | 5058 Robust against shrinking window | MUST-34|x| | | | | 5059 Receiver's window closed indefinitely | MAY-8 | | |x| | | 5060 Use standard probing logic | MUST-35|x| | | | | 5061 Sender probe zero window | MUST-36|x| | | | | 5062 First probe after RTO | SHLD-29| |x| | | | 5063 Exponential backoff | SHLD-30| |x| | | | 5064 Allow window stay zero indefinitely | MUST-37|x| | | | | 5065 Retransmit old data beyond SND.UNA+SND.WND | MAY-7 | | |x| | | 5066 Process RST and URG even with zero window | MUST-66|x| | | | | 5067 | | | | | | | 5068 Urgent Data | | | | | | | 5069 Include support for urgent pointer | MUST-30|x| | | | | 5070 Pointer indicates first non-urgent octet | MUST-62|x| | | | | 5071 Arbitrary length urgent data sequence | MUST-31|x| | | | | 5072 Inform ALP asynchronously of urgent data | MUST-32|x| | | | |1 5073 ALP can learn if/how much urgent data Q'd | MUST-33|x| | | | |1 5074 ALP employ the urgent mechanism | SHLD-13| | | |x| | 5075 | | | | | | | 5076 TCP Options | | | | | | | 5077 Support the mandatory option set | MUST-4 |x| | | | | 5078 Receive TCP option in any segment | MUST-5 |x| | | | | 5079 Ignore unsupported options | MUST-6 |x| | | | | 5080 Include length for all options except EOL+NOP | MUST-68|x| | | | | 5081 Cope with illegal option length | MUST-7 |x| | | | | 5082 Process options regardless of word alignment | MUST-64|x| | | | | 5083 Implement sending & receiving MSS option | MUST-14|x| | | | | 5084 IPv4 Send MSS option unless 536 | SHLD-5 | |x| | | | 5085 IPv6 Send MSS option unless 1220 | SHLD-5 | |x| | | | 5086 Send MSS option always | MAY-3 | | |x| | | 5087 IPv4 Send-MSS default is 536 | MUST-15|x| | | | | 5088 IPv6 Send-MSS default is 1220 | MUST-15|x| | | | | 5089 Calculate effective send seg size | MUST-16|x| | | | | 5090 MSS accounts for varying MTU | SHLD-6 | |x| | | | 5091 MSS not sent on non-SYN segments | MUST-65| | | | |x| 5092 MSS value based on MMS_R | MUST-67|x| | | | | 5093 | | | | | | | 5094 TCP Checksums | | | | | | | 5095 Sender compute checksum | MUST-2 |x| | | | | 5096 Receiver check checksum | MUST-3 |x| | | | | 5097 | | | | | | | 5098 ISN Selection | | | | | | | 5099 Include a clock-driven ISN generator component | MUST-8 |x| | | | | 5100 Secure ISN generator with a PRF component | SHLD-1 | |x| | | | 5101 PRF computable from outside the host | MUST-9 | | | | |x| 5102 | | | | | | | 5103 Opening Connections | | | | | | | 5104 Support simultaneous open attempts | MUST-10|x| | | | | 5105 SYN-RECEIVED remembers last state | MUST-11|x| | | | | 5106 Passive Open call interfere with others | MUST-41| | | | |x| 5107 Function: simultan. LISTENs for same port | MUST-42|x| | | | | 5108 Ask IP for src address for SYN if necc. | MUST-44|x| | | | | 5109 Otherwise, use local addr of conn. | MUST-45|x| | | | | 5110 OPEN to broadcast/multicast IP Address | MUST-46| | | | |x| 5111 Silently discard seg to bcast/mcast addr | MUST-57|x| | | | | 5112 | | | | | | | 5113 Closing Connections | | | | | | | 5114 RST can contain data | SHLD-2 | |x| | | | 5115 Inform application of aborted conn | MUST-12|x| | | | | 5116 Half-duplex close connections | MAY-1 | | |x| | | 5117 Send RST to indicate data lost | SHLD-3 | |x| | | | 5118 In TIME-WAIT state for 2MSL seconds | MUST-13|x| | | | | 5119 Accept SYN from TIME-WAIT state | MAY-2 | | |x| | | 5120 Use Timestamps to reduce TIME-WAIT | SHLD-4 | |x| | | | 5121 | | | | | | | 5122 Retransmissions | | | | | | | 5123 Implement exponential backoff, slow start, and | MUST-19|x| | | | | 5124 congestion avoidance | | | | | | | 5125 Retransmit with same IP ident | MAY-4 | | |x| | | 5126 Karn's algorithm | MUST-18|x| | | | | 5127 | | | | | | | 5128 Generating ACKs: | | | | | | | 5129 Aggregate whenever possible | MUST-58|x| | | | | 5130 Queue out-of-order segments | SHLD-31| |x| | | | 5131 Process all Q'd before send ACK | MUST-59|x| | | | | 5132 Send ACK for out-of-order segment | MAY-13 | | |x| | | 5133 Delayed ACKs | SHLD-18| |x| | | | 5134 Delay < 0.5 seconds | MUST-40|x| | | | | 5135 Every 2nd full-sized segment or 2*RMSS ACK'd | SHLD-19|x| | | | | 5136 Receiver SWS-Avoidance Algorithm | MUST-39|x| | | | | 5137 | | | | | | | 5138 Sending data | | | | | | | 5139 Configurable TTL | MUST-49|x| | | | | 5140 Sender SWS-Avoidance Algorithm | MUST-38|x| | | | | 5141 Nagle algorithm | SHLD-7 | |x| | | | 5142 Application can disable Nagle algorithm | MUST-17|x| | | | | 5143 | | | | | | | 5144 Connection Failures: | | | | | | | 5145 Negative advice to IP on R1 retxs | MUST-20|x| | | | | 5146 Close connection on R2 retxs | MUST-20|x| | | | | 5147 ALP can set R2 | MUST-21|x| | | | |1 5148 Inform ALP of R1<=retxs inform ALP | SHLD-25| |x| | | | 5176 Dest. Unreach (0,1,5) => abort conn | MUST-56| | | | |x| 5177 Dest. Unreach (2-4) => abort conn | SHLD-26| |x| | | | 5178 Source Quench => silent discard | MUST-55|x| | | | | 5179 Time Exceeded => tell ALP, don't abort | MUST-56| | | | |x| 5180 Param Problem => tell ALP, don't abort | MUST-56| | | | |x| 5181 | | | | | | | 5182 Address Validation | | | | | | | 5183 Reject OPEN call to invalid IP address | MUST-46|x| | | | | 5184 Reject SYN from invalid IP address | MUST-63|x| | | | | 5185 Silently discard SYN to bcast/mcast addr | MUST-57|x| | | | | 5186 | | | | | | | 5187 TCP/ALP Interface Services | | | | | | | 5188 Error Report mechanism | MUST-47|x| | | | | 5189 ALP can disable Error Report Routine | SHLD-20| |x| | | | 5190 ALP can specify DiffServ field for sending | MUST-48|x| | | | | 5191 Passed unchanged to IP | SHLD-22| |x| | | | 5192 ALP can change DiffServ field during connection| SHLD-21| |x| | | | 5193 ALP generally changing DiffServ during conn. | SHLD-23| | | |x| | 5194 Pass received DiffServ field up to ALP | MAY-9 | | |x| | | 5195 FLUSH call | MAY-14 | | |x| | | 5196 Optional local IP addr parm. in OPEN | MUST-43|x| | | | | 5197 | | | | | | | 5198 RFC 5961 Support: | | | | | | | 5199 Implement data injection protection | MAY-12 | | |x| | | 5200 | | | | | | | 5201 Explicit Congestion Notification: | | | | | | | 5202 Support ECN | SHLD-8 | |x| | | | 5203 | | | | | | | 5204 Alternative Congestion Control: | | | | | | | 5205 Implement alternative conformant algorithm(s) | MAY-18 | | |x| | | 5206 -------------------------------------------------|--------|-|-|-|-|-|- 5208 FOOTNOTES: (1) "ALP" means Application-Layer Program. 5210 Author's Address 5212 Wesley M. Eddy (editor) 5213 MTI Systems 5214 United States of America 5216 Email: wes@mti-systems.com