idnits 2.17.1 draft-ietf-tcpm-rfc793bis-23.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 51 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 RFC879, 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 (June 6, 2021) is 1053 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 294 -- Looks like a reference, but probably isn't: 'RFC8311' on line 4342 -- Looks like a reference, but probably isn't: 'RFC3540' on line 4342 -- Looks like a reference, but probably isn't: 'RFC3168' on line 4344 -- Obsolete informational reference (is this intentional?): RFC 793 (ref. '15') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 896 (ref. '16') (Obsoleted by RFC 7805) -- Obsolete informational reference (is this intentional?): RFC 1349 (ref. '18') (Obsoleted by RFC 2474) -- Obsolete informational reference (is this intentional?): RFC 1644 (ref. '19') (Obsoleted by RFC 6247) -- Obsolete informational reference (is this intentional?): RFC 2873 (ref. '22') (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 Summary: 2 errors (**), 0 flaws (~~), 5 warnings (==), 19 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, June 6, 2021 5 6528, 6691 (if approved) 6 Updates: 5961, 1122 (if approved) 7 Intended status: Standards Track 8 Expires: December 8, 2021 10 Transmission Control Protocol (TCP) Specification 11 draft-ietf-tcpm-rfc793bis-23 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 December 8, 2021. 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 57 (https://trustee.ietf.org/license-info) in effect on the date of 58 publication of this document. Please review these documents 59 carefully, as they describe your rights and restrictions with respect 60 to this document. Code Components extracted from this document must 61 include Simplified BSD License text as described in Section 4.e of 62 the Trust Legal Provisions and are provided without warranty as 63 described in the Simplified BSD License. 65 This document may contain material from IETF Documents or IETF 66 Contributions published or made publicly available before November 67 10, 2008. The person(s) controlling the copyright in some of this 68 material may not have granted the IETF Trust the right to allow 69 modifications of such material outside the IETF Standards Process. 70 Without obtaining an adequate license from the person(s) controlling 71 the copyright in such materials, this document may not be modified 72 outside the IETF Standards Process, and derivative works of it may 73 not be created outside the IETF Standards Process, except to format 74 it for publication as an RFC or to translate it into languages other 75 than English. 77 Table of Contents 79 1. Purpose and Scope . . . . . . . . . . . . . . . . . . . . . . 3 80 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 81 2.1. Requirements Language . . . . . . . . . . . . . . . . . . 5 82 2.2. Key TCP Concepts . . . . . . . . . . . . . . . . . . . . 5 83 3. Functional Specification . . . . . . . . . . . . . . . . . . 6 84 3.1. Header Format . . . . . . . . . . . . . . . . . . . . . . 6 85 3.2. Specific Option Definitions . . . . . . . . . . . . . . . 11 86 3.2.1. Other Common Options . . . . . . . . . . . . . . . . 13 87 3.2.2. Experimental TCP Options . . . . . . . . . . . . . . 13 88 3.3. TCP Terminology Overview . . . . . . . . . . . . . . . . 13 89 3.3.1. Key Connection State Variables . . . . . . . . . . . 13 90 3.3.2. State Machine Overview . . . . . . . . . . . . . . . 15 91 3.4. Sequence Numbers . . . . . . . . . . . . . . . . . . . . 18 92 3.5. Establishing a connection . . . . . . . . . . . . . . . . 25 93 3.6. Closing a Connection . . . . . . . . . . . . . . . . . . 32 94 3.6.1. Half-Closed Connections . . . . . . . . . . . . . . . 34 95 3.7. Segmentation . . . . . . . . . . . . . . . . . . . . . . 35 96 3.7.1. Maximum Segment Size Option . . . . . . . . . . . . . 36 97 3.7.2. Path MTU Discovery . . . . . . . . . . . . . . . . . 38 98 3.7.3. Interfaces with Variable MTU Values . . . . . . . . . 38 99 3.7.4. Nagle Algorithm . . . . . . . . . . . . . . . . . . . 39 100 3.7.5. IPv6 Jumbograms . . . . . . . . . . . . . . . . . . . 39 101 3.8. Data Communication . . . . . . . . . . . . . . . . . . . 39 102 3.8.1. Retransmission Timeout . . . . . . . . . . . . . . . 40 103 3.8.2. TCP Congestion Control . . . . . . . . . . . . . . . 41 104 3.8.3. TCP Connection Failures . . . . . . . . . . . . . . . 41 105 3.8.4. TCP Keep-Alives . . . . . . . . . . . . . . . . . . . 42 106 3.8.5. The Communication of Urgent Information . . . . . . . 43 107 3.8.6. Managing the Window . . . . . . . . . . . . . . . . . 44 108 3.9. Interfaces . . . . . . . . . . . . . . . . . . . . . . . 49 109 3.9.1. User/TCP Interface . . . . . . . . . . . . . . . . . 49 110 3.9.2. TCP/Lower-Level Interface . . . . . . . . . . . . . . 58 111 3.10. Event Processing . . . . . . . . . . . . . . . . . . . . 60 112 3.11. Glossary . . . . . . . . . . . . . . . . . . . . . . . . 85 113 4. Changes from RFC 793 . . . . . . . . . . . . . . . . . . . . 90 114 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 96 115 6. Security and Privacy Considerations . . . . . . . . . . . . . 97 116 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 98 117 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 99 118 8.1. Normative References . . . . . . . . . . . . . . . . . . 99 119 8.2. Informative References . . . . . . . . . . . . . . . . . 100 120 Appendix A. Other Implementation Notes . . . . . . . . . . . . . 105 121 A.1. IP Security Compartment and Precedence . . . . . . . . . 105 122 A.1.1. Precedence . . . . . . . . . . . . . . . . . . . . . 106 123 A.1.2. MLS Systems . . . . . . . . . . . . . . . . . . . . . 106 124 A.2. Sequence Number Validation . . . . . . . . . . . . . . . 107 125 A.3. Nagle Modification . . . . . . . . . . . . . . . . . . . 107 126 A.4. Low Water Mark Settings . . . . . . . . . . . . . . . . . 107 127 Appendix B. TCP Requirement Summary . . . . . . . . . . . . . . 108 128 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 112 130 1. Purpose and Scope 132 In 1981, RFC 793 [15] was released, documenting the Transmission 133 Control Protocol (TCP), and replacing earlier specifications for TCP 134 that had been published in the past. 136 Since then, TCP has been widely implemented, and has been used as a 137 transport protocol for numerous applications on the Internet. 139 For several decades, RFC 793 plus a number of other documents have 140 combined to serve as the core specification for TCP [48]. Over time, 141 a number of errata have been filed against RFC 793, as well as 142 deficiencies in security, performance, and many other aspects. The 143 number of enhancements has grown over time across many separate 144 documents. These were never accumulated together into a 145 comprehensive update to the base specification. 147 The purpose of this document is to bring together all of the IETF 148 Standards Track changes that have been made to the base TCP 149 functional specification and unify them into an update of RFC 793. 151 Some companion documents are referenced for important algorithms that 152 are used by TCP (e.g. for congestion control), but have not been 153 completely included in this document. This is a conscious choice, as 154 this base specification can be used with multiple additional 155 algorithms that are developed and incorporated separately. This 156 document focuses on the common basis all TCP implementations must 157 support in order to interoperate. Since some additional TCP features 158 have become quite complicated themselves (e.g. advanced loss recovery 159 and congestion control), future companion documents may attempt to 160 similarly bring these together. 162 In addition to the protocol specification that describes the TCP 163 segment format, generation, and processing rules that are to be 164 implemented in code, RFC 793 and other updates also contain 165 informative and descriptive text for readers to understand aspects of 166 the protocol design and operation. This document does not attempt to 167 alter or update this informative text, and is focused only on 168 updating the normative protocol specification. This document 169 preserves references to the documentation containing the important 170 explanations and rationale, where appropriate. 172 This document is intended to be useful both in checking existing TCP 173 implementations for conformance purposes, as well as in writing new 174 implementations. 176 2. Introduction 178 RFC 793 contains a discussion of the TCP design goals and provides 179 examples of its operation, including examples of connection 180 establishment, connection termination, packet retransmission to 181 repair losses. 183 This document describes the basic functionality expected in modern 184 TCP implementations, and replaces the protocol specification in RFC 185 793. It does not replicate or attempt to update the introduction and 186 philosophy content in Sections 1 and 2 of RFC 793. Other documents 187 are referenced to provide explanation of the theory of operation, 188 rationale, and detailed discussion of design decisions. This 189 document only focuses on the normative behavior of the protocol. 191 The "TCP Roadmap" [48] provides a more extensive guide to the RFCs 192 that define TCP and describe various important algorithms. The TCP 193 Roadmap contains sections on strongly encouraged enhancements that 194 improve performance and other aspects of TCP beyond the basic 195 operation specified in this document. As one example, implementing 196 congestion control (e.g. [34]) is a TCP requirement, but is a complex 197 topic on its own, and not described in detail in this document, as 198 there are many options and possibilities that do not impact basic 199 interoperability. Similarly, most TCP implementations today include 200 the high-performance extensions in [46], but these are not strictly 201 required or discussed in this document. Multipath considerations for 202 TCP are also specified separately in [55]. 204 A list of changes from RFC 793 is contained in Section 4. 206 2.1. Requirements Language 208 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 209 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 210 "OPTIONAL" in this document are to be interpreted as described in BCP 211 14 [3][11] when, and only when, they appear in all capitals, as shown 212 here. 214 Each use of RFC 2119 keywords in the document is individually labeled 215 and referenced in Appendix B that summarizes implementation 216 requirements. 218 Sentences using "MUST" are labeled as "MUST-X" with X being a numeric 219 identifier enabling the requirement to be located easily when 220 referenced from Appendix B. 222 Similarly, sentences using "SHOULD" are labeled with "SHLD-X", "MAY" 223 with "MAY-X", and "RECOMMENDED" with "REC-X". 225 For the purposes of this labeling, "SHOULD NOT" and "MUST NOT" are 226 labeled the same as "SHOULD" and "MUST" instances. 228 2.2. Key TCP Concepts 230 TCP provides a reliable, in-order, byte-stream service to 231 applications. 233 The application byte-stream is conveyed over the network via TCP 234 segments, with each TCP segment sent as an Internet Protocol (IP) 235 datagram. 237 TCP reliability consists of detecting packet losses (via sequence 238 numbers) and errors (via per-segment checksums), as well as 239 correction via retransmission. 241 TCP supports unicast delivery of data. Anycast applications exist 242 that successfully use TCP without modifications, though there is some 243 risk of instability due to changes of lower-layer forwarding behavior 244 [45]. 246 TCP is connection-oriented, though does not inherently include a 247 liveness detection capability. 249 Data flow is supported bidirectionally over TCP connections, though 250 applications are free to send data only unidirectionally, if they so 251 choose. 253 TCP uses port numbers to identify application services and to 254 multiplex distinct flows between hosts. 256 A more detailed description of TCP features compared to other 257 transport protocols can be found in Section 3.1 of [51]. Further 258 description of the motivations for developing TCP and its role in the 259 Internet protocol stack can be found in Section 2 of [15] and earlier 260 versions of the TCP specification. 262 3. Functional Specification 264 3.1. Header Format 266 TCP segments are sent as internet datagrams. The Internet Protocol 267 (IP) header carries several information fields, including the source 268 and destination host addresses [1] [12]. A TCP header follows the IP 269 headers, supplying information specific to the TCP protocol. This 270 division allows for the existence of host level protocols other than 271 TCP. In early development of the Internet suite of protocols, the IP 272 header fields had been a part of TCP. 274 This document describes the TCP protocol. The TCP protocol uses TCP 275 Headers. 277 A TCP Header is formatted as follows, using the style from [61]: 279 0 1 2 3 280 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 281 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 282 | Source Port | Destination Port | 283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 284 | Sequence Number | 285 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 286 | Acknowledgment Number | 287 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 288 | Data | |C|E|U|A|P|R|S|F| | 289 | Offset| Rsrvd |W|C|R|C|S|S|Y|I| Window | 290 | | |R|E|G|K|H|T|N|N| | 291 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 292 | Checksum | Urgent Pointer | 293 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 294 | [Options] | 295 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 296 | : 297 : Data : 298 : | 299 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 301 Note that one tick mark represents one bit position. 303 Figure 1: TCP Header Format 305 where: 307 Source Port: 16 bits. 309 The source port number. 311 Destination Port: 16 bits. 313 The destination port number. 315 Sequence Number: 32 bits. 317 The sequence number of the first data octet in this segment (except 318 when the SYN flag is set). If SYN is set the sequence number is 319 the initial sequence number (ISN) and the first data octet is 320 ISN+1. 322 Acknowledgment Number: 32 bits. 324 If the ACK control bit is set, this field contains the value of the 325 next sequence number the sender of the segment is expecting to 326 receive. Once a connection is established, this is always sent. 328 Data Offset (DOffset): 4 bits. 330 The number of 32 bit words in the TCP Header. This indicates where 331 the data begins. The TCP header (even one including options) is an 332 integral number of 32 bits long. 334 Reserved (Rsrvd): 4 bits. 336 A set of control bits reserved for future use. Must be zero in 337 generated segments and must be ignored in received segments, if 338 corresponding future features are unimplemented by the sending or 339 receiving host. 341 The control bits are also know as "flags". Assignment is managed 342 by IANA from the "TCP Header Flags" registry [57]. The currently 343 assigned control bits are CWR, ECE, URG, ACK, PSH, RST, SYN, and 344 FIN. 346 CWR: 1 bit. 348 Congestion Window Reduced (see [7]). 350 ECE: 1 bit. 352 ECN-Echo (see [7]). 354 URG: 1 bit. 356 Urgent Pointer field significant. 358 ACK: 1 bit. 360 Acknowledgment field significant. 362 PSH: 1 bit. 364 Push Function (see the Send Call description in Section 3.9.1). 366 RST: 1 bit. 368 Reset the connection. 370 SYN: 1 bit. 372 Synchronize sequence numbers. 374 FIN: 1 bit. 376 No more data from sender. 378 Window: 16 bits. 380 The number of data octets beginning with the one indicated in the 381 acknowledgment field that the sender of this segment is willing to 382 accept. 384 The window size MUST be treated as an unsigned number, or else 385 large window sizes will appear like negative windows and TCP will 386 not work (MUST-1). It is RECOMMENDED that implementations will 387 reserve 32-bit fields for the send and receive window sizes in the 388 connection record and do all window computations with 32 bits (REC- 389 1). 391 Checksum: 16 bits. 393 The checksum field is the 16 bit one's complement of the one's 394 complement sum of all 16 bit words in the header and text. The 395 checksum computation needs to ensure the 16-bit alignment of the 396 data being summed. If a segment contains an odd number of header 397 and text octets, alignment can be achieved by padding the last 398 octet with zeros on its right to form a 16 bit word for checksum 399 purposes. The pad is not transmitted as part of the segment. 400 While computing the checksum, the checksum field itself is replaced 401 with zeros. 403 The checksum also covers a pseudo header (Figure 2) conceptually 404 prefixed to the TCP header. The pseudo header is 96 bits for IPv4 405 and 320 bits for IPv6. Including the pseudo header in the checksum 406 gives the TCP connection protection against misrouted segments. 407 This information is carried in IP headers and is transferred across 408 the TCP/Network interface in the arguments or results of calls by 409 the TCP implementation on the IP layer. 411 +--------+--------+--------+--------+ 412 | Source Address | 413 +--------+--------+--------+--------+ 414 | Destination Address | 415 +--------+--------+--------+--------+ 416 | zero | PTCL | TCP Length | 417 +--------+--------+--------+--------+ 419 Figure 2: IPv4 Pseudo Header 421 Pseudo header components for IPv4: 423 Source Address: the IPv4 source address in network byte order 425 Destination Address: the IPv4 destination address in network 426 byte order 428 zero: bits set to zero 430 PTCL: the protocol number from the IP header 432 TCP Length: the TCP header length plus the data length in 433 octets (this is not an explicitly transmitted quantity, but is 434 computed), and it does not count the 12 octets of the pseudo 435 header. 437 For IPv6, the pseudo header is defined in Section 8.1 of RFC 8200 438 [12], and contains the IPv6 Source Address and Destination 439 Address, an Upper Layer Packet Length (a 32-bit value otherwise 440 equivalent to TCP Length in the IPv4 pseudo header), three bytes 441 of zero-padding, and a Next Header value (differing from the IPv6 442 header value in the case of extension headers present in between 443 IPv6 and TCP). 445 The TCP checksum is never optional. The sender MUST generate it 446 (MUST-2) and the receiver MUST check it (MUST-3). 448 Urgent Pointer: 16 bits. 450 This field communicates the current value of the urgent pointer as 451 a positive offset from the sequence number in this segment. The 452 urgent pointer points to the sequence number of the octet following 453 the urgent data. This field is only be interpreted in segments 454 with the URG control bit set. 456 Options: [TCP Option]; Options#Size == (DOffset-5)*32; present only 457 when DOffset > 5. 459 Options may occupy space at the end of the TCP header and are a 460 multiple of 8 bits in length. All options are included in the 461 checksum. An option may begin on any octet boundary. There are two 462 cases for the format of an option: 464 Case 1: A single octet of option-kind. 466 Case 2: An octet of option-kind (Kind), an octet of option- 467 length, and the actual option-data octets. 469 The option-length counts the two octets of option-kind and option- 470 length as well as the option-data octets. 472 Note that the list of options may be shorter than the data offset 473 field might imply. The content of the header beyond the End-of- 474 Option option must be header padding (i.e., zero). 476 The list of all currently defined options is managed by IANA [56], 477 and each option is defined in other RFCs, as indicated there. That 478 set includes experimental options that can be extended to support 479 multiple concurrent usages [44]. 481 A given TCP implementation can support any currently defined 482 options, but the following options MUST be supported (MUST-4 - note 483 Maximum Segment Size option support is also part of MUST-19 in 484 Section 3.7.2): 486 Kind Length Meaning 487 ---- ------ ------- 488 0 - End of option list. 489 1 - No-Operation. 490 2 4 Maximum Segment Size. 492 These options are specified in detail in Section 3.2. 494 A TCP implementation MUST be able to receive a TCP option in any 495 segment (MUST-5). 497 A TCP implementation MUST (MUST-6) ignore without error any TCP 498 option it does not implement, assuming that the option has a length 499 field. All TCP options except End of option list and No-Operation 500 MUST have length fields, including all future options (MUST-68). 501 TCP implementations MUST be prepared to handle an illegal option 502 length (e.g., zero); a suggested procedure is to reset the 503 connection and log the error cause (MUST-7). 505 Note: There is ongoing work to extend the space available for TCP 506 options, such as [60]. 508 Data: variable length. 510 User data carried by the TCP segment. 512 3.2. Specific Option Definitions 514 A TCP Option is one of: an End of Option List Option, a No-Operation 515 Option, or a Maximum Segment Size Option. 517 An End of Option List Option is formatted as follows: 519 0 520 0 1 2 3 4 5 6 7 521 +-+-+-+-+-+-+-+-+ 522 | 0 | 523 +-+-+-+-+-+-+-+-+ 525 where: 527 Kind: 1 byte; Kind == 0. 529 This option code indicates the end of the option list. This might 530 not coincide with the end of the TCP header according to the Data 531 Offset field. This is used at the end of all options, not the end 532 of each option, and need only be used if the end of the options 533 would not otherwise coincide with the end of the TCP header. 535 A No-Operation Option is formatted as follows: 537 0 538 0 1 2 3 4 5 6 7 539 +-+-+-+-+-+-+-+-+ 540 | 1 | 541 +-+-+-+-+-+-+-+-+ 543 where: 545 Kind: 1 byte; Kind == 1. 547 This option code can be used between options, for example, to align 548 the beginning of a subsequent option on a word boundary. There is 549 no guarantee that senders will use this option, so receivers MUST 550 be prepared to process options even if they do not begin on a word 551 boundary (MUST-64). 553 A Maximum Segment Size Option is formatted as follows: 555 0 1 2 3 556 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 557 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 558 | 2 | Length | Maximum Segment Size (MSS) | 559 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 561 where: 563 Kind: 1 byte; Kind == 2. 565 If this option is present, then it communicates the maximum receive 566 segment size at the TCP endpoint that sends this segment. This 567 value is limited by the IP reassembly limit. This field may be 568 sent in the initial connection request (i.e., in segments with the 569 SYN control bit set) and MUST NOT be sent in other segments (MUST- 570 65). If this option is not used, any segment size is allowed. A 571 more complete description of this option is provided in 572 Section 3.7.1. 574 Length: 1 byte; Length == 4. 576 Length of the option in bytes. 578 Maximum Segment Size (MSS): 2 bytes. 580 The maximum receive segment size at the TCP endpoint that sends 581 this segment. 583 3.2.1. Other Common Options 585 Additional RFCs define some other commonly used options that are 586 recommended to implement for high performance, but not necessary for 587 basic TCP interoperability. These are the TCP Selective 588 Acknowledgement (SACK) option [20][23], TCP Timestamp (TS) option 589 [46], and TCP Window Scaling (WS) option [46]. 591 3.2.2. Experimental TCP Options 593 Experimental TCP option values are defined in [27], and [44] 594 describes the current recommended usage for these experimental 595 values. 597 3.3. TCP Terminology Overview 599 This section includes an overview of key terms needed to understand 600 the detailed protocol operation in the rest of the document. There 601 is a traditional glossary of terms in Section 3.11. 603 3.3.1. Key Connection State Variables 605 Before we can discuss very much about the operation of the TCP 606 implementation we need to introduce some detailed terminology. The 607 maintenance of a TCP connection requires the remembering of several 608 variables. We conceive of these variables being stored in a 609 connection record called a Transmission Control Block or TCB. Among 610 the variables stored in the TCB are the local and remote IP addresses 611 and port numbers, the IP security level and compartment of the 612 connection (see Appendix A.1), pointers to the user's send and 613 receive buffers, pointers to the retransmit queue and to the current 614 segment. In addition several variables relating to the send and 615 receive sequence numbers are stored in the TCB. 617 Send Sequence Variables: 619 SND.UNA - send unacknowledged 620 SND.NXT - send next 621 SND.WND - send window 622 SND.UP - send urgent pointer 623 SND.WL1 - segment sequence number used for last window update 624 SND.WL2 - segment acknowledgment number used for last window 625 update 626 ISS - initial send sequence number 628 Receive Sequence Variables: 630 RCV.NXT - receive next 631 RCV.WND - receive window 632 RCV.UP - receive urgent pointer 633 IRS - initial receive sequence number 635 The following diagrams may help to relate some of these variables to 636 the sequence space. 638 1 2 3 4 639 ----------|----------|----------|---------- 640 SND.UNA SND.NXT SND.UNA 641 +SND.WND 643 1 - old sequence numbers that have been acknowledged 644 2 - sequence numbers of unacknowledged data 645 3 - sequence numbers allowed for new data transmission 646 4 - future sequence numbers that are not yet allowed 648 Figure 3: Send Sequence Space 650 The send window is the portion of the sequence space labeled 3 in 651 Figure 3. 653 1 2 3 654 ----------|----------|---------- 655 RCV.NXT RCV.NXT 656 +RCV.WND 658 1 - old sequence numbers that have been acknowledged 659 2 - sequence numbers allowed for new reception 660 3 - future sequence numbers that are not yet allowed 662 Figure 4: Receive Sequence Space 664 The receive window is the portion of the sequence space labeled 2 in 665 Figure 4. 667 There are also some variables used frequently in the discussion that 668 take their values from the fields of the current segment. 670 Current Segment Variables: 672 SEG.SEQ - segment sequence number 673 SEG.ACK - segment acknowledgment number 674 SEG.LEN - segment length 675 SEG.WND - segment window 676 SEG.UP - segment urgent pointer 678 3.3.2. State Machine Overview 680 A connection progresses through a series of states during its 681 lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, 682 ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, 683 TIME-WAIT, and the fictional state CLOSED. CLOSED is fictional 684 because it represents the state when there is no TCB, and therefore, 685 no connection. Briefly the meanings of the states are: 687 LISTEN - represents waiting for a connection request from any 688 remote TCP peer and port. 690 SYN-SENT - represents waiting for a matching connection request 691 after having sent a connection request. 693 SYN-RECEIVED - represents waiting for a confirming connection 694 request acknowledgment after having both received and sent a 695 connection request. 697 ESTABLISHED - represents an open connection, data received can be 698 delivered to the user. The normal state for the data transfer 699 phase of the connection. 701 FIN-WAIT-1 - represents waiting for a connection termination 702 request from the remote TCP peer, or an acknowledgment of the 703 connection termination request previously sent. 705 FIN-WAIT-2 - represents waiting for a connection termination 706 request from the remote TCP peer. 708 CLOSE-WAIT - represents waiting for a connection termination 709 request from the local user. 711 CLOSING - represents waiting for a connection termination request 712 acknowledgment from the remote TCP peer. 714 LAST-ACK - represents waiting for an acknowledgment of the 715 connection termination request previously sent to the remote TCP 716 peer (this termination request sent to the remote TCP peer already 717 included an acknowledgment of the termination request sent from 718 the remote TCP peer). 720 TIME-WAIT - represents waiting for enough time to pass to be sure 721 the remote TCP peer received the acknowledgment of its connection 722 termination request, and to avoid new connections being impacted 723 by delayed segments from previous connections. 725 CLOSED - represents no connection state at all. 727 A TCP connection progresses from one state to another in response to 728 events. The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, 729 ABORT, and STATUS; the incoming segments, particularly those 730 containing the SYN, ACK, RST and FIN flags; and timeouts. 732 The state diagram in Figure 5 illustrates only state changes, 733 together with the causing events and resulting actions, but addresses 734 neither error conditions nor actions that are not connected with 735 state changes. In a later section, more detail is offered with 736 respect to the reaction of the TCP implementation to events. Some 737 state names are abbreviated or hyphenated differently in the diagram 738 from how they appear elsewhere in the document. 740 NOTA BENE: This diagram is only a summary and must not be taken as 741 the total specification. Many details are not included. 743 +---------+ ---------\ active OPEN 744 | CLOSED | \ ----------- 745 +---------+<---------\ \ create TCB 746 | ^ \ \ snd SYN 747 passive OPEN | | CLOSE \ \ 748 ------------ | | ---------- \ \ 749 create TCB | | delete TCB \ \ 750 V | \ \ 751 rcv RST (note 1) +---------+ CLOSE | \ 752 -------------------->| LISTEN | ---------- | | 753 / +---------+ delete TCB | | 754 / rcv SYN | | SEND | | 755 / ----------- | | ------- | V 756 +--------+ snd SYN,ACK / \ snd SYN +--------+ 757 | |<----------------- ------------------>| | 758 | SYN | rcv SYN | SYN | 759 | RCVD |<-----------------------------------------------| SENT | 760 | | snd SYN,ACK | | 761 | |------------------ -------------------| | 762 +--------+ rcv ACK of SYN \ / rcv SYN,ACK +--------+ 763 | -------------- | | ----------- 764 | x | | snd ACK 765 | V V 766 | CLOSE +---------+ 767 | ------- | ESTAB | 768 | snd FIN +---------+ 769 | CLOSE | | rcv FIN 770 V ------- | | ------- 771 +---------+ snd FIN / \ snd ACK +---------+ 772 | FIN |<---------------- ------------------>| CLOSE | 773 | WAIT-1 |------------------ | WAIT | 774 +---------+ rcv FIN \ +---------+ 775 | rcv ACK of FIN ------- | CLOSE | 776 | -------------- snd ACK | ------- | 777 V x V snd FIN V 778 +---------+ +---------+ +---------+ 779 |FINWAIT-2| | CLOSING | | LAST-ACK| 780 +---------+ +---------+ +---------+ 781 | rcv ACK of FIN | rcv ACK of FIN | 782 | rcv FIN -------------- | Timeout=2MSL -------------- | 783 | ------- x V ------------ x V 784 \ snd ACK +---------+delete TCB +---------+ 785 -------------------->|TIME-WAIT|------------------->| CLOSED | 786 +---------+ +---------+ 788 Figure 5: TCP Connection State Diagram 790 The following notes apply to Figure 5: 792 Note 1: The transition from SYN-RECEIVED to LISTEN on receiving a 793 RST is conditional on having reached SYN-RECEIVED after a passive 794 open. 796 Note 2: An unshown transition exists from FIN-WAIT-1 to TIME-WAIT 797 if a FIN is received and the local FIN is also acknowledged. 799 Note 3: A RST can be sent from any state with a corresponding 800 transition to TIME-WAIT (see [64] for rationale). These 801 transitions are not not explicitly shown, otherwise the diagram 802 would become very difficult to read. Similarly, receipt of a RST 803 from any state results in a transition to LISTEN or CLOSED, though 804 this is also omitted from the diagram for legibility. 806 3.4. Sequence Numbers 808 A fundamental notion in the design is that every octet of data sent 809 over a TCP connection has a sequence number. Since every octet is 810 sequenced, each of them can be acknowledged. The acknowledgment 811 mechanism employed is cumulative so that an acknowledgment of 812 sequence number X indicates that all octets up to but not including X 813 have been received. This mechanism allows for straight-forward 814 duplicate detection in the presence of retransmission. Numbering of 815 octets within a segment is that the first data octet immediately 816 following the header is the lowest numbered, and the following octets 817 are numbered consecutively. 819 It is essential to remember that the actual sequence number space is 820 finite, though very large. This space ranges from 0 to 2**32 - 1. 821 Since the space is finite, all arithmetic dealing with sequence 822 numbers must be performed modulo 2**32. This unsigned arithmetic 823 preserves the relationship of sequence numbers as they cycle from 824 2**32 - 1 to 0 again. There are some subtleties to computer modulo 825 arithmetic, so great care should be taken in programming the 826 comparison of such values. The symbol "=<" means "less than or 827 equal" (modulo 2**32). 829 The typical kinds of sequence number comparisons that the TCP 830 implementation must perform include: 832 (a) Determining that an acknowledgment refers to some sequence 833 number sent but not yet acknowledged. 835 (b) Determining that all sequence numbers occupied by a segment 836 have been acknowledged (e.g., to remove the segment from a 837 retransmission queue). 839 (c) Determining that an incoming segment contains sequence numbers 840 that are expected (i.e., that the segment "overlaps" the receive 841 window). 843 In response to sending data the TCP endpoint will receive 844 acknowledgments. The following comparisons are needed to process the 845 acknowledgments. 847 SND.UNA = oldest unacknowledged sequence number 849 SND.NXT = next sequence number to be sent 851 SEG.ACK = acknowledgment from the receiving TCP peer (next 852 sequence number expected by the receiving TCP peer) 854 SEG.SEQ = first sequence number of a segment 856 SEG.LEN = the number of octets occupied by the data in the segment 857 (counting SYN and FIN) 859 SEG.SEQ+SEG.LEN-1 = last sequence number of a segment 861 A new acknowledgment (called an "acceptable ack"), is one for which 862 the inequality below holds: 864 SND.UNA < SEG.ACK =< SND.NXT 866 A segment on the retransmission queue is fully acknowledged if the 867 sum of its sequence number and length is less or equal than the 868 acknowledgment value in the incoming segment. 870 When data is received the following comparisons are needed: 872 RCV.NXT = next sequence number expected on an incoming segments, 873 and is the left or lower edge of the receive window 875 RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming 876 segment, and is the right or upper edge of the receive window 878 SEG.SEQ = first sequence number occupied by the incoming segment 880 SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming 881 segment 883 A segment is judged to occupy a portion of valid receive sequence 884 space if 886 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 888 or 890 RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 892 The first part of this test checks to see if the beginning of the 893 segment falls in the window, the second part of the test checks to 894 see if the end of the segment falls in the window; if the segment 895 passes either part of the test it contains data in the window. 897 Actually, it is a little more complicated than this. Due to zero 898 windows and zero length segments, we have four cases for the 899 acceptability of an incoming segment: 901 Segment Receive Test 902 Length Window 903 ------- ------- ------------------------------------------- 905 0 0 SEG.SEQ = RCV.NXT 907 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 909 >0 0 not acceptable 911 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 912 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 914 Note that when the receive window is zero no segments should be 915 acceptable except ACK segments. Thus, it is possible for a TCP 916 implementation to maintain a zero receive window while transmitting 917 data and receiving ACKs. A TCP receiver MUST process the RST and URG 918 fields of all incoming segments, even when the receive window is zero 919 (MUST-66). 921 We have taken advantage of the numbering scheme to protect certain 922 control information as well. This is achieved by implicitly 923 including some control flags in the sequence space so they can be 924 retransmitted and acknowledged without confusion (i.e., one and only 925 one copy of the control will be acted upon). Control information is 926 not physically carried in the segment data space. Consequently, we 927 must adopt rules for implicitly assigning sequence numbers to 928 control. The SYN and FIN are the only controls requiring this 929 protection, and these controls are used only at connection opening 930 and closing. For sequence number purposes, the SYN is considered to 931 occur before the first actual data octet of the segment in which it 932 occurs, while the FIN is considered to occur after the last actual 933 data octet in a segment in which it occurs. The segment length 934 (SEG.LEN) includes both data and sequence space occupying controls. 935 When a SYN is present then SEG.SEQ is the sequence number of the SYN. 937 Initial Sequence Number Selection 939 A connection is defined by a pair of sockets. Connections can be 940 reused. New instances of a connection will be referred to as 941 incarnations of the connection. The problem that arises from this is 942 -- "how does the TCP implementation identify duplicate segments from 943 previous incarnations of the connection?" This problem becomes 944 apparent if the connection is being opened and closed in quick 945 succession, or if the connection breaks with loss of memory and is 946 then reestablished. To support this, the TIME-WAIT state limits the 947 rate of connection reuse, while the initial sequence number selection 948 described below further protects against ambiguity about what 949 incarnation of a connection an incoming packet corresponds to. 951 To avoid confusion we must prevent segments from one incarnation of a 952 connection from being used while the same sequence numbers may still 953 be present in the network from an earlier incarnation. We want to 954 assure this, even if a TCP endpoint loses all knowledge of the 955 sequence numbers it has been using. When new connections are 956 created, an initial sequence number (ISN) generator is employed that 957 selects a new 32 bit ISN. There are security issues that result if 958 an off-path attacker is able to predict or guess ISN values. 960 TCP Initial Sequence Numbers are generated from a number sequence 961 that monotonically increases until it wraps, known loosely as a 962 "clock". This clock is a 32-bit counter that typically increments at 963 least once every roughly 4 microseconds, although it is neither 964 assumed to be realtime nor precise, and need not persist across 965 reboots. The clock component is intended to insure that with a 966 Maximum Segment Lifetime (MSL), generated ISNs will be unique, since 967 it cycles approximately every 4.55 hours, which is much longer than 968 the MSL. 970 A TCP implementation MUST use the above type of "clock" for clock- 971 driven selection of initial sequence numbers (MUST-8), and SHOULD 972 generate its Initial Sequence Numbers with the expression: 974 ISN = M + F(localip, localport, remoteip, remoteport, secretkey) 976 where M is the 4 microsecond timer, and F() is a pseudorandom 977 function (PRF) of the connection's identifying parameters ("localip, 978 localport, remoteip, remoteport") and a secret key ("secretkey") 979 (SHLD-1). F() MUST NOT be computable from the outside (MUST-9), or 980 an attacker could still guess at sequence numbers from the ISN used 981 for some other connection. The PRF could be implemented as a 982 cryptographic hash of the concatenation of the TCP connection 983 parameters and some secret data. For discussion of the selection of 984 a specific hash algorithm and management of the secret key data, 985 please see Section 3 of [41]. 987 For each connection there is a send sequence number and a receive 988 sequence number. The initial send sequence number (ISS) is chosen by 989 the data sending TCP peer, and the initial receive sequence number 990 (IRS) is learned during the connection establishing procedure. 992 For a connection to be established or initialized, the two TCP peers 993 must synchronize on each other's initial sequence numbers. This is 994 done in an exchange of connection establishing segments carrying a 995 control bit called "SYN" (for synchronize) and the initial sequence 996 numbers. As a shorthand, segments carrying the SYN bit are also 997 called "SYNs". Hence, the solution requires a suitable mechanism for 998 picking an initial sequence number and a slightly involved handshake 999 to exchange the ISNs. 1001 The synchronization requires each side to send its own initial 1002 sequence number and to receive a confirmation of it in acknowledgment 1003 from the remote TCP peer. Each side must also receive the remote 1004 peer's initial sequence number and send a confirming acknowledgment. 1006 1) A --> B SYN my sequence number is X 1007 2) A <-- B ACK your sequence number is X 1008 3) A <-- B SYN my sequence number is Y 1009 4) A --> B ACK your sequence number is Y 1011 Because steps 2 and 3 can be combined in a single message this is 1012 called the three-way (or three message) handshake (3WHS). 1014 A 3WHS is necessary because sequence numbers are not tied to a global 1015 clock in the network, and TCP implementations may have different 1016 mechanisms for picking the ISNs. The receiver of the first SYN has 1017 no way of knowing whether the segment was an old delayed one or not, 1018 unless it remembers the last sequence number used on the connection 1019 (which is not always possible), and so it must ask the sender to 1020 verify this SYN. The three way handshake and the advantages of a 1021 clock-driven scheme are discussed in [63]. 1023 Knowing When to Keep Quiet 1025 A theoretical problem exists where data could be corrupted due to 1026 confusion between old segments in the network and new ones after a 1027 host reboots, if the same port numbers and sequence space are reused. 1028 The "Quiet Time" concept discussed below addresses this and the 1029 discussion of it is included for situations where it might be 1030 relevant, although it is not felt to be necessary in most current 1031 implementations. The problem was more relevant earlier in the 1032 history of TCP. In practical use on the Internet today, the error- 1033 prone conditions are sufficiently unlikely that it is felt safe to 1034 ignore. Reasons why it is now negligible include: (a) ISS and 1035 ephemeral port randomization have reduced likelihood of reuse of port 1036 numbers and sequence numbers after reboots, (b) the effective MSL of 1037 the Internet has declined as links have become faster, and (c) 1038 reboots often taking longer than an MSL anyways. 1040 To be sure that a TCP implementation does not create a segment 1041 carrying a sequence number that may be duplicated by an old segment 1042 remaining in the network, the TCP endpoint must keep quiet for an MSL 1043 before assigning any sequence numbers upon starting up or recovering 1044 from a situation where memory of sequence numbers in use was lost. 1045 For this specification the MSL is taken to be 2 minutes. This is an 1046 engineering choice, and may be changed if experience indicates it is 1047 desirable to do so. Note that if a TCP endpoint is reinitialized in 1048 some sense, yet retains its memory of sequence numbers in use, then 1049 it need not wait at all; it must only be sure to use sequence numbers 1050 larger than those recently used. 1052 The TCP Quiet Time Concept 1054 Hosts that for any reason lose knowledge of the last sequence numbers 1055 transmitted on each active (i.e., not closed) connection shall delay 1056 emitting any TCP segments for at least the agreed MSL in the internet 1057 system that the host is a part of. In the paragraphs below, an 1058 explanation for this specification is given. TCP implementors may 1059 violate the "quiet time" restriction, but only at the risk of causing 1060 some old data to be accepted as new or new data rejected as old 1061 duplicated by some receivers in the internet system. 1063 TCP endpoints consume sequence number space each time a segment is 1064 formed and entered into the network output queue at a source host. 1065 The duplicate detection and sequencing algorithm in the TCP protocol 1066 relies on the unique binding of segment data to sequence space to the 1067 extent that sequence numbers will not cycle through all 2**32 values 1068 before the segment data bound to those sequence numbers has been 1069 delivered and acknowledged by the receiver and all duplicate copies 1070 of the segments have "drained" from the internet. Without such an 1071 assumption, two distinct TCP segments could conceivably be assigned 1072 the same or overlapping sequence numbers, causing confusion at the 1073 receiver as to which data is new and which is old. Remember that 1074 each segment is bound to as many consecutive sequence numbers as 1075 there are octets of data and SYN or FIN flags in the segment. 1077 Under normal conditions, TCP implementations keep track of the next 1078 sequence number to emit and the oldest awaiting acknowledgment so as 1079 to avoid mistakenly using a sequence number over before its first use 1080 has been acknowledged. This alone does not guarantee that old 1081 duplicate data is drained from the net, so the sequence space has 1082 been made very large to reduce the probability that a wandering 1083 duplicate will cause trouble upon arrival. At 2 megabits/sec. it 1084 takes 4.5 hours to use up 2**32 octets of sequence space. Since the 1085 maximum segment lifetime in the net is not likely to exceed a few 1086 tens of seconds, this is deemed ample protection for foreseeable 1087 nets, even if data rates escalate to l0's of megabits/sec. At 100 1088 megabits/sec, the cycle time is 5.4 minutes, which may be a little 1089 short, but still within reason. 1091 The basic duplicate detection and sequencing algorithm in TCP can be 1092 defeated, however, if a source TCP endpoint does not have any memory 1093 of the sequence numbers it last used on a given connection. For 1094 example, if the TCP implementation were to start all connections with 1095 sequence number 0, then upon the host rebooting, a TCP peer might re- 1096 form an earlier connection (possibly after half-open connection 1097 resolution) and emit packets with sequence numbers identical to or 1098 overlapping with packets still in the network, which were emitted on 1099 an earlier incarnation of the same connection. In the absence of 1100 knowledge about the sequence numbers used on a particular connection, 1101 the TCP specification recommends that the source delay for MSL 1102 seconds before emitting segments on the connection, to allow time for 1103 segments from the earlier connection incarnation to drain from the 1104 system. 1106 Even hosts that can remember the time of day and used it to select 1107 initial sequence number values are not immune from this problem 1108 (i.e., even if time of day is used to select an initial sequence 1109 number for each new connection incarnation). 1111 Suppose, for example, that a connection is opened starting with 1112 sequence number S. Suppose that this connection is not used much and 1113 that eventually the initial sequence number function (ISN(t)) takes 1114 on a value equal to the sequence number, say S1, of the last segment 1115 sent by this TCP endpoint on a particular connection. Now suppose, 1116 at this instant, the host reboots and establishes a new incarnation 1117 of the connection. The initial sequence number chosen is S1 = ISN(t) 1118 -- last used sequence number on old incarnation of connection! If 1119 the recovery occurs quickly enough, any old duplicates in the net 1120 bearing sequence numbers in the neighborhood of S1 may arrive and be 1121 treated as new packets by the receiver of the new incarnation of the 1122 connection. 1124 The problem is that the recovering host may not know for how long it 1125 was down between rebooting nor does it know whether there are still 1126 old duplicates in the system from earlier connection incarnations. 1128 One way to deal with this problem is to deliberately delay emitting 1129 segments for one MSL after recovery from a reboot - this is the 1130 "quiet time" specification. Hosts that prefer to avoid waiting are 1131 willing to risk possible confusion of old and new packets at a given 1132 destination may choose not to wait for the "quiet time". 1133 Implementors may provide TCP users with the ability to select on a 1134 connection by connection basis whether to wait after a reboot, or may 1135 informally implement the "quiet time" for all connections. 1136 Obviously, even where a user selects to "wait," this is not necessary 1137 after the host has been "up" for at least MSL seconds. 1139 To summarize: every segment emitted occupies one or more sequence 1140 numbers in the sequence space, the numbers occupied by a segment are 1141 "busy" or "in use" until MSL seconds have passed, upon rebooting a 1142 block of space-time is occupied by the octets and SYN or FIN flags of 1143 the last emitted segment, if a new connection is started too soon and 1144 uses any of the sequence numbers in the space-time footprint of the 1145 last segment of the previous connection incarnation, there is a 1146 potential sequence number overlap area that could cause confusion at 1147 the receiver. 1149 3.5. Establishing a connection 1151 The "three-way handshake" is the procedure used to establish a 1152 connection. This procedure normally is initiated by one TCP peer and 1153 responded to by another TCP peer. The procedure also works if two 1154 TCP peers simultaneously initiate the procedure. When simultaneous 1155 open occurs, each TCP peer receives a "SYN" segment that carries no 1156 acknowledgment after it has sent a "SYN". Of course, the arrival of 1157 an old duplicate "SYN" segment can potentially make it appear, to the 1158 recipient, that a simultaneous connection initiation is in progress. 1159 Proper use of "reset" segments can disambiguate these cases. 1161 Several examples of connection initiation follow. Although these 1162 examples do not show connection synchronization using data-carrying 1163 segments, this is perfectly legitimate, so long as the receiving TCP 1164 endpoint doesn't deliver the data to the user until it is clear the 1165 data is valid (e.g., the data is buffered at the receiver until the 1166 connection reaches the ESTABLISHED state, given that the three-way 1167 handshake reduces the possibility of false connections). It is the 1168 implementation of a trade-off between memory and messages to provide 1169 information for this checking. 1171 The simplest 3WHS is shown in Figure 6. The figures should be 1172 interpreted in the following way. Each line is numbered for 1173 reference purposes. Right arrows (-->) indicate departure of a TCP 1174 segment from TCP peer A to TCP peer B, or arrival of a segment at B 1175 from A. Left arrows (<--), indicate the reverse. Ellipsis (...) 1176 indicates a segment that is still in the network (delayed). Comments 1177 appear in parentheses. TCP connection states represent the state 1178 AFTER the departure or arrival of the segment (whose contents are 1179 shown in the center of each line). Segment contents are shown in 1180 abbreviated form, with sequence number, control flags, and ACK field. 1181 Other fields such as window, addresses, lengths, and text have been 1182 left out in the interest of clarity. 1184 TCP Peer A TCP Peer B 1186 1. CLOSED LISTEN 1188 2. SYN-SENT --> --> SYN-RECEIVED 1190 3. ESTABLISHED <-- <-- SYN-RECEIVED 1192 4. ESTABLISHED --> --> ESTABLISHED 1194 5. ESTABLISHED --> --> ESTABLISHED 1196 Figure 6: Basic 3-Way Handshake for Connection Synchronization 1198 In line 2 of Figure 6, TCP Peer A begins by sending a SYN segment 1199 indicating that it will use sequence numbers starting with sequence 1200 number 100. In line 3, TCP Peer B sends a SYN and acknowledges the 1201 SYN it received from TCP Peer A. Note that the acknowledgment field 1202 indicates TCP Peer B is now expecting to hear sequence 101, 1203 acknowledging the SYN that occupied sequence 100. 1205 At line 4, TCP Peer A responds with an empty segment containing an 1206 ACK for TCP Peer B's SYN; and in line 5, TCP Peer A sends some data. 1207 Note that the sequence number of the segment in line 5 is the same as 1208 in line 4 because the ACK does not occupy sequence number space (if 1209 it did, we would wind up ACKing ACKs!). 1211 Simultaneous initiation is only slightly more complex, as is shown in 1212 Figure 7. Each TCP peer's connection state cycles from CLOSED to 1213 SYN-SENT to SYN-RECEIVED to ESTABLISHED. 1215 TCP Peer A TCP Peer B 1217 1. CLOSED CLOSED 1219 2. SYN-SENT --> ... 1221 3. SYN-RECEIVED <-- <-- SYN-SENT 1223 4. ... --> SYN-RECEIVED 1225 5. SYN-RECEIVED --> ... 1227 6. ESTABLISHED <-- <-- SYN-RECEIVED 1229 7. ... --> ESTABLISHED 1231 Figure 7: Simultaneous Connection Synchronization 1233 A TCP implementation MUST support simultaneous open attempts (MUST- 1234 10). 1236 Note that a TCP implementation MUST keep track of whether a 1237 connection has reached SYN-RECEIVED state as the result of a passive 1238 OPEN or an active OPEN (MUST-11). 1240 The principal reason for the three-way handshake is to prevent old 1241 duplicate connection initiations from causing confusion. To deal 1242 with this, a special control message, reset, is specified. If the 1243 receiving TCP peer is in a non-synchronized state (i.e., SYN-SENT, 1244 SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset. 1245 If the TCP peer is in one of the synchronized states (ESTABLISHED, 1246 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it 1247 aborts the connection and informs its user. We discuss this latter 1248 case under "half-open" connections below. 1250 TCP Peer A TCP Peer B 1252 1. CLOSED LISTEN 1254 2. SYN-SENT --> ... 1256 3. (duplicate) ... --> SYN-RECEIVED 1258 4. SYN-SENT <-- <-- SYN-RECEIVED 1260 5. SYN-SENT --> --> LISTEN 1262 6. ... --> SYN-RECEIVED 1264 7. ESTABLISHED <-- <-- SYN-RECEIVED 1266 8. ESTABLISHED --> --> ESTABLISHED 1268 Figure 8: Recovery from Old Duplicate SYN 1270 As a simple example of recovery from old duplicates, consider 1271 Figure 8. At line 3, an old duplicate SYN arrives at TCP Peer B. 1272 TCP Peer B cannot tell that this is an old duplicate, so it responds 1273 normally (line 4). TCP Peer A detects that the ACK field is 1274 incorrect and returns a RST (reset) with its SEQ field selected to 1275 make the segment believable. TCP Peer B, on receiving the RST, 1276 returns to the LISTEN state. When the original SYN finally arrives 1277 at line 6, the synchronization proceeds normally. If the SYN at line 1278 6 had arrived before the RST, a more complex exchange might have 1279 occurred with RST's sent in both directions. 1281 Half-Open Connections and Other Anomalies 1283 An established connection is said to be "half-open" if one of the TCP 1284 peers has closed or aborted the connection at its end without the 1285 knowledge of the other, or if the two ends of the connection have 1286 become desynchronized owing to a failure or reboot that resulted in 1287 loss of memory. Such connections will automatically become reset if 1288 an attempt is made to send data in either direction. However, half- 1289 open connections are expected to be unusual. 1291 If at site A the connection no longer exists, then an attempt by the 1292 user at site B to send any data on it will result in the site B TCP 1293 endpoint receiving a reset control message. Such a message indicates 1294 to the site B TCP endpoint that something is wrong, and it is 1295 expected to abort the connection. 1297 Assume that two user processes A and B are communicating with one 1298 another when a failure or reboot occurs causing loss of memory to A's 1299 TCP implementation. Depending on the operating system supporting A's 1300 TCP implementation, it is likely that some error recovery mechanism 1301 exists. When the TCP endpoint is up again, A is likely to start 1302 again from the beginning or from a recovery point. As a result, A 1303 will probably try to OPEN the connection again or try to SEND on the 1304 connection it believes open. In the latter case, it receives the 1305 error message "connection not open" from the local (A's) TCP 1306 implementation. In an attempt to establish the connection, A's TCP 1307 implementation will send a segment containing SYN. This scenario 1308 leads to the example shown in Figure 9. After TCP Peer A reboots, 1309 the user attempts to re-open the connection. TCP Peer B, in the 1310 meantime, thinks the connection is open. 1312 TCP Peer A TCP Peer B 1314 1. (REBOOT) (send 300,receive 100) 1316 2. CLOSED ESTABLISHED 1318 3. SYN-SENT --> --> (??) 1320 4. (!!) <-- <-- ESTABLISHED 1322 5. SYN-SENT --> --> (Abort!!) 1324 6. SYN-SENT CLOSED 1326 7. SYN-SENT --> --> 1328 Figure 9: Half-Open Connection Discovery 1330 When the SYN arrives at line 3, TCP Peer B, being in a synchronized 1331 state, and the incoming segment outside the window, responds with an 1332 acknowledgment indicating what sequence it next expects to hear (ACK 1333 100). TCP Peer A sees that this segment does not acknowledge 1334 anything it sent and, being unsynchronized, sends a reset (RST) 1335 because it has detected a half-open connection. TCP Peer B aborts at 1336 line 5. TCP Peer A will continue to try to establish the connection; 1337 the problem is now reduced to the basic 3-way handshake of Figure 6. 1339 An interesting alternative case occurs when TCP Peer A reboots and 1340 TCP Peer B tries to send data on what it thinks is a synchronized 1341 connection. This is illustrated in Figure 10. In this case, the 1342 data arriving at TCP Peer A from TCP Peer B (line 2) is unacceptable 1343 because no such connection exists, so TCP Peer A sends a RST. The 1344 RST is acceptable so TCP Peer B processes it and aborts the 1345 connection. 1347 TCP Peer A TCP Peer B 1349 1. (REBOOT) (send 300,receive 100) 1351 2. (??) <-- <-- ESTABLISHED 1353 3. --> --> (ABORT!!) 1355 Figure 10: Active Side Causes Half-Open Connection Discovery 1357 In Figure 11, two TCP Peers A and B with passive connections waiting 1358 for SYN are depicted. An old duplicate arriving at TCP Peer B (line 1359 2) stirs B into action. A SYN-ACK is returned (line 3) and causes 1360 TCP A to generate a RST (the ACK in line 3 is not acceptable). TCP 1361 Peer B accepts the reset and returns to its passive LISTEN state. 1363 TCP Peer A TCP Peer B 1365 1. LISTEN LISTEN 1367 2. ... --> SYN-RECEIVED 1369 3. (??) <-- <-- SYN-RECEIVED 1371 4. --> --> (return to LISTEN!) 1373 5. LISTEN LISTEN 1375 Figure 11: Old Duplicate SYN Initiates a Reset on two Passive Sockets 1377 A variety of other cases are possible, all of which are accounted for 1378 by the following rules for RST generation and processing. 1380 Reset Generation 1382 A TCP user or application can issue a reset on a connection at any 1383 time, though reset events are also generated by the protocol itself 1384 when various error conditions occur, as described below. The side of 1385 a connection issuing a reset should enter the TIME-WAIT state, as 1386 this generally helps to reduce the load on busy servers for reasons 1387 described in [64]. 1389 As a general rule, reset (RST) is sent whenever a segment arrives 1390 that apparently is not intended for the current connection. A reset 1391 must not be sent if it is not clear that this is the case. 1393 There are three groups of states: 1395 1. If the connection does not exist (CLOSED) then a reset is sent 1396 in response to any incoming segment except another reset. A SYN 1397 segment that does not match an existing connection is rejected by 1398 this means. 1400 If the incoming segment has the ACK bit set, the reset takes its 1401 sequence number from the ACK field of the segment, otherwise the 1402 reset has sequence number zero and the ACK field is set to the sum 1403 of the sequence number and segment length of the incoming segment. 1404 The connection remains in the CLOSED state. 1406 2. If the connection is in any non-synchronized state (LISTEN, 1407 SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges 1408 something not yet sent (the segment carries an unacceptable ACK), 1409 or 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. 1413 If the incoming segment has an ACK field, the reset takes its 1414 sequence number from the ACK field of the segment, otherwise the 1415 reset has sequence number zero and the ACK field is set to the sum 1416 of the sequence number and segment length of the incoming segment. 1417 The connection remains in the same state. 1419 3. If the connection is in a synchronized state (ESTABLISHED, 1420 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), 1421 any unacceptable segment (out of window sequence number or 1422 unacceptable acknowledgment number) must be responded to with an 1423 empty acknowledgment segment (without any user data) containing 1424 the current send-sequence number and an acknowledgment indicating 1425 the next sequence number expected to be received, and the 1426 connection remains in the same state. 1428 If an incoming segment has a security level, or compartment that 1429 does not exactly match the level and compartment requested for the 1430 connection, a reset is sent and the connection goes to the CLOSED 1431 state. The reset takes its sequence number from the ACK field of 1432 the incoming segment. 1434 Reset Processing 1435 In all states except SYN-SENT, all reset (RST) segments are validated 1436 by checking their SEQ-fields. A reset is valid if its sequence 1437 number is in the window. In the SYN-SENT state (a RST received in 1438 response to an initial SYN), the RST is acceptable if the ACK field 1439 acknowledges the SYN. 1441 The receiver of a RST first validates it, then changes state. If the 1442 receiver was in the LISTEN state, it ignores it. If the receiver was 1443 in SYN-RECEIVED state and had previously been in the LISTEN state, 1444 then the receiver returns to the LISTEN state, otherwise the receiver 1445 aborts the connection and goes to the CLOSED state. If the receiver 1446 was in any other state, it aborts the connection and advises the user 1447 and goes to the CLOSED state. 1449 TCP implementations SHOULD allow a received RST segment to include 1450 data (SHLD-2). 1452 3.6. Closing a Connection 1454 CLOSE is an operation meaning "I have no more data to send." The 1455 notion of closing a full-duplex connection is subject to ambiguous 1456 interpretation, of course, since it may not be obvious how to treat 1457 the receiving side of the connection. We have chosen to treat CLOSE 1458 in a simplex fashion. The user who CLOSEs may continue to RECEIVE 1459 until the TCP receiver is told that the remote peer has CLOSED also. 1460 Thus, a program could initiate several SENDs followed by a CLOSE, and 1461 then continue to RECEIVE until signaled that a RECEIVE failed because 1462 the remote peer has CLOSED. The TCP implementation will signal a 1463 user, even if no RECEIVEs are outstanding, that the remote peer has 1464 closed, so the user can terminate his side gracefully. A TCP 1465 implementation will reliably deliver all buffers SENT before the 1466 connection was CLOSED so a user who expects no data in return need 1467 only wait to hear the connection was CLOSED successfully to know that 1468 all their data was received at the destination TCP endpoint. Users 1469 must keep reading connections they close for sending until the TCP 1470 implementation indicates there is no more data. 1472 There are essentially three cases: 1474 1) The user initiates by telling the TCP implementation to CLOSE 1475 the connection (TCP Peer A in Figure 12). 1477 2) The remote TCP endpoint initiates by sending a FIN control 1478 signal (TCP Peer B in Figure 12). 1480 3) Both users CLOSE simultaneously (Figure 13). 1482 Case 1: Local user initiates the close 1483 In this case, a FIN segment can be constructed and placed on the 1484 outgoing segment queue. No further SENDs from the user will be 1485 accepted by the TCP implementation, and it enters the FIN-WAIT-1 1486 state. RECEIVEs are allowed in this state. All segments 1487 preceding and including FIN will be retransmitted until 1488 acknowledged. When the other TCP peer has both acknowledged the 1489 FIN and sent a FIN of its own, the first TCP peer can ACK this 1490 FIN. Note that a TCP endpoint receiving a FIN will ACK but not 1491 send its own FIN until its user has CLOSED the connection also. 1493 Case 2: TCP endpoint receives a FIN from the network 1495 If an unsolicited FIN arrives from the network, the receiving TCP 1496 endpoint can ACK it and tell the user that the connection is 1497 closing. The user will respond with a CLOSE, upon which the TCP 1498 endpoint can send a FIN to the other TCP peer after sending any 1499 remaining data. The TCP endpoint then waits until its own FIN is 1500 acknowledged whereupon it deletes the connection. If an ACK is 1501 not forthcoming, after the user timeout the connection is aborted 1502 and the user is told. 1504 Case 3: Both users close simultaneously 1506 A simultaneous CLOSE by users at both ends of a connection causes 1507 FIN segments to be exchanged (Figure 13). When all segments 1508 preceding the FINs have been processed and acknowledged, each TCP 1509 peer can ACK the FIN it has received. Both will, upon receiving 1510 these ACKs, delete the connection. 1512 TCP Peer A TCP Peer B 1514 1. ESTABLISHED ESTABLISHED 1516 2. (Close) 1517 FIN-WAIT-1 --> --> CLOSE-WAIT 1519 3. FIN-WAIT-2 <-- <-- CLOSE-WAIT 1521 4. (Close) 1522 TIME-WAIT <-- <-- LAST-ACK 1524 5. TIME-WAIT --> --> CLOSED 1526 6. (2 MSL) 1527 CLOSED 1529 Figure 12: Normal Close Sequence 1531 TCP Peer A TCP Peer B 1533 1. ESTABLISHED ESTABLISHED 1535 2. (Close) (Close) 1536 FIN-WAIT-1 --> ... FIN-WAIT-1 1537 <-- <-- 1538 ... --> 1540 3. CLOSING --> ... CLOSING 1541 <-- <-- 1542 ... --> 1544 4. TIME-WAIT TIME-WAIT 1545 (2 MSL) (2 MSL) 1546 CLOSED CLOSED 1548 Figure 13: Simultaneous Close Sequence 1550 A TCP connection may terminate in two ways: (1) the normal TCP close 1551 sequence using a FIN handshake (Figure 12), and (2) an "abort" in 1552 which one or more RST segments are sent and the connection state is 1553 immediately discarded. If the local TCP connection is closed by the 1554 remote side due to a FIN or RST received from the remote side, then 1555 the local application MUST be informed whether it closed normally or 1556 was aborted (MUST-12). 1558 3.6.1. Half-Closed Connections 1560 The normal TCP close sequence delivers buffered data reliably in both 1561 directions. Since the two directions of a TCP connection are closed 1562 independently, it is possible for a connection to be "half closed," 1563 i.e., closed in only one direction, and a host is permitted to 1564 continue sending data in the open direction on a half-closed 1565 connection. 1567 A host MAY implement a "half-duplex" TCP close sequence, so that an 1568 application that has called CLOSE cannot continue to read data from 1569 the connection (MAY-1). If such a host issues a CLOSE call while 1570 received data is still pending in the TCP connection, or if new data 1571 is received after CLOSE is called, its TCP implementation SHOULD send 1572 a RST to show that data was lost (SHLD-3). See [21] section 2.17 for 1573 discussion. 1575 When a connection is closed actively, it MUST linger in the TIME-WAIT 1576 state for a time 2xMSL (Maximum Segment Lifetime) (MUST-13). 1577 However, it MAY accept a new SYN from the remote TCP endpoint to 1578 reopen the connection directly from TIME-WAIT state (MAY-2), if it: 1580 (1) assigns its initial sequence number for the new connection to 1581 be larger than the largest sequence number it used on the previous 1582 connection incarnation, and 1584 (2) returns to TIME-WAIT state if the SYN turns out to be an old 1585 duplicate. 1587 When the TCP Timestamp options are available, an improved algorithm 1588 is described in [39] in order to support higher connection 1589 establishment rates. This algorithm for reducing TIME-WAIT is a Best 1590 Current Practice that SHOULD be implemented, since timestamp options 1591 are commonly used, and using them to reduce TIME-WAIT provides 1592 benefits for busy Internet servers (SHLD-4). 1594 3.7. Segmentation 1596 The term "segmentation" refers to the activity TCP performs when 1597 ingesting a stream of bytes from a sending application and 1598 packetizing that stream of bytes into TCP segments. Individual TCP 1599 segments often do not correspond one-for-one to individual send (or 1600 socket write) calls from the application. Applications may perform 1601 writes at the granularity of messages in the upper layer protocol, 1602 but TCP guarantees no boundary coherence between the TCP segments 1603 sent and received versus user application data read or write buffer 1604 boundaries. In some specific protocols, such as Remote Direct Memory 1605 Access (RDMA) using Direct Data Placement (DDP) and Marker PDU 1606 Aligned Framing (MPA) [31], there are performance optimizations 1607 possible when the relation between TCP segments and application data 1608 units can be controlled, and MPA includes a specific mechanism for 1609 detecting and verifying this relationship between TCP segments and 1610 application message data structures, but this is specific to 1611 applications like RDMA. In general, multiple goals influence the 1612 sizing of TCP segments created by a TCP implementation. 1614 Goals driving the sending of larger segments include: 1616 o Reducing the number of packets in flight within the network. 1618 o Increasing processing efficiency and potential performance by 1619 enabling a smaller number of interrupts and inter-layer 1620 interactions. 1622 o Limiting the overhead of TCP headers. 1624 Note that the performance benefits of sending larger segments may 1625 decrease as the size increases, and there may be boundaries where 1626 advantages are reversed. For instance, on some implementation 1627 architectures, 1025 bytes within a segment could lead to worse 1628 performance than 1024 bytes, due purely to data alignment on copy 1629 operations. 1631 Goals driving the sending of smaller segments include: 1633 o Avoiding sending a TCP segment that would result in an IP datagram 1634 larger than the smallest MTU along an IP network path, because 1635 this results in either packet loss or packet fragmentation. 1636 Making matters worse, some firewalls or middleboxes may drop 1637 fragmented packets or ICMP messages related to fragmentation. 1639 o Preventing delays to the application data stream, especially when 1640 TCP is waiting on the application to generate more data, or when 1641 the application is waiting on an event or input from its peer in 1642 order to generate more data. 1644 o Enabling "fate sharing" between TCP segments and lower-layer data 1645 units (e.g. below IP, for links with cell or frame sizes smaller 1646 than the IP MTU). 1648 Towards meeting these competing sets of goals, TCP includes several 1649 mechanisms, including the Maximum Segment Size option, Path MTU 1650 Discovery, the Nagle algorithm, and support for IPv6 Jumbograms, as 1651 discussed in the following subsections. 1653 3.7.1. Maximum Segment Size Option 1655 TCP endpoints MUST implement both sending and receiving the MSS 1656 option (MUST-14). 1658 TCP implementations SHOULD send an MSS option in every SYN segment 1659 when its receive MSS differs from the default 536 for IPv4 or 1220 1660 for IPv6 (SHLD-5), and MAY send it always (MAY-3). 1662 If an MSS option is not received at connection setup, TCP 1663 implementations MUST assume a default send MSS of 536 (576-40) for 1664 IPv4 or 1220 (1280 - 60) for IPv6 (MUST-15). 1666 The maximum size of a segment that TCP endpoint really sends, the 1667 "effective send MSS," MUST be the smaller (MUST-16) of the send MSS 1668 (that reflects the available reassembly buffer size at the remote 1669 host, the EMTU_R [17]) and the largest transmission size permitted by 1670 the IP layer (EMTU_S [17]): 1672 Eff.snd.MSS = 1674 min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize 1676 where: 1678 o SendMSS is the MSS value received from the remote host, or the 1679 default 536 for IPv4 or 1220 for IPv6, if no MSS option is 1680 received. 1682 o MMS_S is the maximum size for a transport-layer message that TCP 1683 may send. 1685 o TCPhdrsize is the size of the fixed TCP header and any options. 1686 This is 20 in the (rare) case that no options are present, but may 1687 be larger if TCP options are to be sent. Note that some options 1688 might not be included on all segments, but that for each segment 1689 sent, the sender should adjust the data length accordingly, within 1690 the Eff.snd.MSS. 1692 o IPoptionsize is the size of any IPv4 options or IPv6 extension 1693 headers associated with a TCP connection. Note that some options 1694 or extension headers might not be included on all packets, but 1695 that for each segment sent, the sender should adjust the data 1696 length accordingly, within the Eff.snd.MSS. 1698 The MSS value to be sent in an MSS option should be equal to the 1699 effective MTU minus the fixed IP and TCP headers. By ignoring both 1700 IP and TCP options when calculating the value for the MSS option, if 1701 there are any IP or TCP options to be sent in a packet, then the 1702 sender must decrease the size of the TCP data accordingly. RFC 6691 1703 [42] discusses this in greater detail. 1705 The MSS value to be sent in an MSS option must be less than or equal 1706 to: 1708 MMS_R - 20 1710 where MMS_R is the maximum size for a transport-layer message that 1711 can be received (and reassembled at the IP layer) (MUST-67). TCP 1712 obtains MMS_R and MMS_S from the IP layer; see the generic call 1713 GET_MAXSIZES in Section 3.4 of RFC 1122. These are defined in terms 1714 of their IP MTU equivalents, EMTU_R and EMTU_S [17]. 1716 When TCP is used in a situation where either the IP or TCP headers 1717 are not fixed, the sender must reduce the amount of TCP data in any 1718 given packet by the number of octets used by the IP and TCP options. 1719 This has been a point of confusion historically, as explained in RFC 1720 6691, Section 3.1. 1722 3.7.2. Path MTU Discovery 1724 A TCP implementation may be aware of the MTU on directly connected 1725 links, but will rarely have insight about MTUs across an entire 1726 network path. For IPv4, RFC 1122 recommends an IP-layer default 1727 effective MTU of less than or equal to 576 for destinations not 1728 directly connected. For IPv6, this would be 1280. In all cases, 1729 however, implementation of Path MTU Discovery (PMTUD) and 1730 Packetization Layer Path MTU Discovery (PLPMTUD) is strongly 1731 recommended in order for TCP to improve segmentation decisions. Both 1732 PMTUD and PLPMTUD help TCP choose segment sizes that avoid both on- 1733 path (for IPv4) and source fragmentation (IPv4 and IPv6). 1735 PMTUD for IPv4 [2] or IPv6 [13] is implemented in conjunction between 1736 TCP, IP, and ICMP protocols. It relies both on avoiding source 1737 fragmentation and setting the IPv4 DF (don't fragment) flag, the 1738 latter to inhibit on-path fragmentation. It relies on ICMP errors 1739 from routers along the path, whenever a segment is too large to 1740 traverse a link. Several adjustments to a TCP implementation with 1741 PMTUD are described in RFC 2923 in order to deal with problems 1742 experienced in practice [24]. PLPMTUD [28] is a Standards Track 1743 improvement to PMTUD that relaxes the requirement for ICMP support 1744 across a path, and improves performance in cases where ICMP is not 1745 consistently conveyed, but still tries to avoid source fragmentation. 1746 The mechanisms in all four of these RFCs are recommended to be 1747 included in TCP implementations. 1749 The TCP MSS option specifies an upper bound for the size of packets 1750 that can be received. Hence, setting the value in the MSS option too 1751 small can impact the ability for PMTUD or PLPMTUD to find a larger 1752 path MTU. RFC 1191 discusses this implication of many older TCP 1753 implementations setting MSS to 536 for non-local destinations, rather 1754 than deriving it from the MTUs of connected interfaces as 1755 recommended. 1757 3.7.3. Interfaces with Variable MTU Values 1759 The effective MTU can sometimes vary, as when used with variable 1760 compression, e.g., RObust Header Compression (ROHC) [35]. It is 1761 tempting for a TCP implementation to advertise the largest possible 1762 MSS, to support the most efficient use of compressed payloads. 1763 Unfortunately, some compression schemes occasionally need to transmit 1764 full headers (and thus smaller payloads) to resynchronize state at 1765 their endpoint compressors/decompressors. If the largest MTU is used 1766 to calculate the value to advertise in the MSS option, TCP 1767 retransmission may interfere with compressor resynchronization. 1769 As a result, when the effective MTU of an interface varies packet-to- 1770 packet, TCP implementations SHOULD use the smallest effective MTU of 1771 the interface to calculate the value to advertise in the MSS option 1772 (SHLD-6). 1774 3.7.4. Nagle Algorithm 1776 The "Nagle algorithm" was described in RFC 896 [16] and was 1777 recommended in RFC 1122 [17] for mitigation of an early problem of 1778 too many small packets being generated. It has been implemented in 1779 most current TCP code bases, sometimes with minor variations (see 1780 Appendix A.3). 1782 If there is unacknowledged data (i.e., SND.NXT > SND.UNA), then the 1783 sending TCP endpoint buffers all user data (regardless of the PSH 1784 bit), until the outstanding data has been acknowledged or until the 1785 TCP endpoint can send a full-sized segment (Eff.snd.MSS bytes). 1787 A TCP implementation SHOULD implement the Nagle Algorithm to coalesce 1788 short segments (SHLD-7). However, there MUST be a way for an 1789 application to disable the Nagle algorithm on an individual 1790 connection (MUST-17). In all cases, sending data is also subject to 1791 the limitation imposed by the Slow Start algorithm [34]. 1793 Since there can be problematic interactions between the Nagle 1794 Algorithm and delayed acknowledgements, some implementations use 1795 minor variations of the Nagle algorithm, such as the one described in 1796 Appendix A.3. 1798 3.7.5. IPv6 Jumbograms 1800 In order to support TCP over IPv6 Jumbograms, implementations need to 1801 be able to send TCP segments larger than the 64KB limit that the MSS 1802 option can convey. RFC 2675 [5] defines that an MSS value of 65,535 1803 bytes is to be treated as infinity, and Path MTU Discovery [13] is 1804 used to determine the actual MSS. 1806 The Jumbo Payload option need not be implemented or understood by 1807 IPv6 nodes that do not support attachment to links with a MTU greater 1808 than 65,575 [5], and the present IPv6 Node Requirements does not 1809 include support for Jumbograms [53]. 1811 3.8. Data Communication 1813 Once the connection is established data is communicated by the 1814 exchange of segments. Because segments may be lost due to errors 1815 (checksum test failure), or network congestion, TCP uses 1816 retransmission to ensure delivery of every segment. Duplicate 1817 segments may arrive due to network or TCP retransmission. As 1818 discussed in the section on sequence numbers the TCP implementation 1819 performs certain tests on the sequence and acknowledgment numbers in 1820 the segments to verify their acceptability. 1822 The sender of data keeps track of the next sequence number to use in 1823 the variable SND.NXT. The receiver of data keeps track of the next 1824 sequence number to expect in the variable RCV.NXT. The sender of 1825 data keeps track of the oldest unacknowledged sequence number in the 1826 variable SND.UNA. If the data flow is momentarily idle and all data 1827 sent has been acknowledged then the three variables will be equal. 1829 When the sender creates a segment and transmits it the sender 1830 advances SND.NXT. When the receiver accepts a segment it advances 1831 RCV.NXT and sends an acknowledgment. When the data sender receives 1832 an acknowledgment it advances SND.UNA. The extent to which the 1833 values of these variables differ is a measure of the delay in the 1834 communication. The amount by which the variables are advanced is the 1835 length of the data and SYN or FIN flags in the segment. Note that 1836 once in the ESTABLISHED state all segments must carry current 1837 acknowledgment information. 1839 The CLOSE user call implies a push function, as does the FIN control 1840 flag in an incoming segment. 1842 3.8.1. Retransmission Timeout 1844 Because of the variability of the networks that compose an 1845 internetwork system and the wide range of uses of TCP connections the 1846 retransmission timeout (RTO) must be dynamically determined. 1848 The RTO MUST be computed according to the algorithm in [9], including 1849 Karn's algorithm for taking RTT samples (MUST-18). 1851 RFC 793 contains an early example procedure for computing the RTO. 1852 This was then replaced by the algorithm described in RFC 1122, and 1853 subsequently updated in RFC 2988, and then again in RFC 6298. 1855 RFC 1122 allows that if a retransmitted packet is identical to the 1856 original packet (which implies not only that the data boundaries have 1857 not changed, but also that none of the headers have changed), then 1858 the same IPv4 Identification field MAY be used (see Section 3.2.1.5 1859 of RFC 1122) (MAY-4). The same IP identification field may be reused 1860 anyways, since it is only meaningful when a datagram is fragmented 1861 [43]. TCP implementations should not rely on or typically interact 1862 with this IPv4 header field in any way. It is not a reasonable way 1863 to either indicate duplicate sent segments, nor to identify duplicate 1864 received segments. 1866 3.8.2. TCP Congestion Control 1868 RFC 2914 [6] explains the importance of congestion control for the 1869 Internet. 1871 RFC 1122 required implementation of Van Jacobson's congestion control 1872 algorithms slow start and congestion avoidance together with 1873 exponential back-off for successive RTO values for the same segment. 1874 RFC 2581 provided IETF Standards Track description of slow start and 1875 congestion avoidance, along with fast retransmit and fast recovery. 1876 RFC 5681 is the current description of these algorithms and is the 1877 current Standards Track specification providing guidelines for TCP 1878 congestion control. RFC 6298 describes exponential back-off of RTO 1879 values, including keeping the backed-off value until a subsequent 1880 segment with new data has been sent and acknowledged without 1881 retransmission. 1883 A TCP endpoint MUST implement the basic congestion control algorithms 1884 slow start, congestion avoidance, and exponential back-off of RTO to 1885 avoid creating congestion collapse conditions (MUST-19). RFC 5681 1886 and RFC 6298 describe the basic algorithms on the IETF Standards 1887 Track that are broadly applicable. Multiple other suitable 1888 algorithms exist and have been widely used. Many TCP implementations 1889 support a set of alternative algorithms that can be configured for 1890 use on the endpoint. An endpoint may implement such alternative 1891 algorithms provided that the algorithms are conformant with the TCP 1892 specifications from the IETF Standards Track as described in RFC 1893 2914, RFC 5033 [8], and RFC 8961 [14] (MAY-18). 1895 Explicit Congestion Notification (ECN) was defined in RFC 3168 and is 1896 an IETF Standards Track enhancement that has many benefits [50]. 1898 A TCP endpoint SHOULD implement ECN as described in RFC 3168 (SHLD- 1899 8). 1901 3.8.3. TCP Connection Failures 1903 Excessive retransmission of the same segment by a TCP endpoint 1904 indicates some failure of the remote host or the Internet path. This 1905 failure may be of short or long duration. The following procedure 1906 MUST be used to handle excessive retransmissions of data segments 1907 (MUST-20): 1909 (a) There are two thresholds R1 and R2 measuring the amount of 1910 retransmission that has occurred for the same segment. R1 and R2 1911 might be measured in time units or as a count of retransmissions. 1913 (b) When the number of transmissions of the same segment reaches 1914 or exceeds threshold R1, pass negative advice (see Section 3.3.1.4 1915 of [17]) to the IP layer, to trigger dead-gateway diagnosis. 1917 (c) When the number of transmissions of the same segment reaches a 1918 threshold R2 greater than R1, close the connection. 1920 (d) An application MUST (MUST-21) be able to set the value for R2 1921 for a particular connection. For example, an interactive 1922 application might set R2 to "infinity," giving the user control 1923 over when to disconnect. 1925 (e) TCP implementations SHOULD inform the application of the 1926 delivery problem (unless such information has been disabled by the 1927 application; see Asynchronous Reports section), when R1 is reached 1928 and before R2 (SHLD-9). This will allow a remote login (User 1929 Telnet) application program to inform the user, for example. 1931 The value of R1 SHOULD correspond to at least 3 retransmissions, at 1932 the current RTO (SHLD-10). The value of R2 SHOULD correspond to at 1933 least 100 seconds (SHLD-11). 1935 An attempt to open a TCP connection could fail with excessive 1936 retransmissions of the SYN segment or by receipt of a RST segment or 1937 an ICMP Port Unreachable. SYN retransmissions MUST be handled in the 1938 general way just described for data retransmissions, including 1939 notification of the application layer. 1941 However, the values of R1 and R2 may be different for SYN and data 1942 segments. In particular, R2 for a SYN segment MUST be set large 1943 enough to provide retransmission of the segment for at least 3 1944 minutes (MUST-23). The application can close the connection (i.e., 1945 give up on the open attempt) sooner, of course. 1947 3.8.4. TCP Keep-Alives 1949 A TCP connection is said to be "idle" if for some long amount of time 1950 there have been no incoming segments received and there is no new or 1951 unacknowledged data to be sent. 1953 Implementors MAY include "keep-alives" in their TCP implementations 1954 (MAY-5), although this practice is not universally accepted. Some 1955 TCP implementations, however, have included a keep-alive mechanism. 1956 To confirm that an idle connection is still active, these 1957 implementations send a probe segment designed to elicit a response 1958 from the TCP peer. Such a segment generally contains SEG.SEQ = 1959 SND.NXT-1 and may or may not contain one garbage octet of data. If 1960 keep-alives are included, the application MUST be able to turn them 1961 on or off for each TCP connection (MUST-24), and they MUST default to 1962 off (MUST-25). 1964 Keep-alive packets MUST only be sent when no sent data is 1965 outstanding, and no data or acknowledgement packets have been 1966 received for the connection within an interval (MUST-26). This 1967 interval MUST be configurable (MUST-27) and MUST default to no less 1968 than two hours (MUST-28). 1970 It is extremely important to remember that ACK segments that contain 1971 no data are not reliably transmitted by TCP. Consequently, if a 1972 keep-alive mechanism is implemented it MUST NOT interpret failure to 1973 respond to any specific probe as a dead connection (MUST-29). 1975 An implementation SHOULD send a keep-alive segment with no data 1976 (SHLD-12); however, it MAY be configurable to send a keep-alive 1977 segment containing one garbage octet (MAY-6), for compatibility with 1978 erroneous TCP implementations. 1980 3.8.5. The Communication of Urgent Information 1982 As a result of implementation differences and middlebox interactions, 1983 new applications SHOULD NOT employ the TCP urgent mechanism (SHLD- 1984 13). However, TCP implementations MUST still include support for the 1985 urgent mechanism (MUST-30). Details can be found in RFC 6093 [38]. 1987 The objective of the TCP urgent mechanism is to allow the sending 1988 user to stimulate the receiving user to accept some urgent data and 1989 to permit the receiving TCP endpoint to indicate to the receiving 1990 user when all the currently known urgent data has been received by 1991 the user. 1993 This mechanism permits a point in the data stream to be designated as 1994 the end of urgent information. Whenever this point is in advance of 1995 the receive sequence number (RCV.NXT) at the receiving TCP endpoint, 1996 that TCP must tell the user to go into "urgent mode"; when the 1997 receive sequence number catches up to the urgent pointer, the TCP 1998 implementation must tell user to go into "normal mode". If the 1999 urgent pointer is updated while the user is in "urgent mode", the 2000 update will be invisible to the user. 2002 The method employs an urgent field that is carried in all segments 2003 transmitted. The URG control flag indicates that the urgent field is 2004 meaningful and must be added to the segment sequence number to yield 2005 the urgent pointer. The absence of this flag indicates that there is 2006 no urgent data outstanding. 2008 To send an urgent indication the user must also send at least one 2009 data octet. If the sending user also indicates a push, timely 2010 delivery of the urgent information to the destination process is 2011 enhanced. 2013 A TCP implementation MUST support a sequence of urgent data of any 2014 length (MUST-31). [17] 2016 The urgent pointer MUST point to the sequence number of the octet 2017 following the urgent data (MUST-62). 2019 A TCP implementation MUST (MUST-32) inform the application layer 2020 asynchronously whenever it receives an Urgent pointer and there was 2021 previously no pending urgent data, or whenever the Urgent pointer 2022 advances in the data stream. The TCP implementation MUST (MUST-33) 2023 provide a way for the application to learn how much urgent data 2024 remains to be read from the connection, or at least to determine 2025 whether or not more urgent data remains to be read [17]. 2027 3.8.6. Managing the Window 2029 The window sent in each segment indicates the range of sequence 2030 numbers the sender of the window (the data receiver) is currently 2031 prepared to accept. There is an assumption that this is related to 2032 the currently available data buffer space available for this 2033 connection. 2035 The sending TCP endpoint packages the data to be transmitted into 2036 segments that fit the current window, and may repackage segments on 2037 the retransmission queue. Such repackaging is not required, but may 2038 be helpful. 2040 In a connection with a one-way data flow, the window information will 2041 be carried in acknowledgment segments that all have the same sequence 2042 number so there will be no way to reorder them if they arrive out of 2043 order. This is not a serious problem, but it will allow the window 2044 information to be on occasion temporarily based on old reports from 2045 the data receiver. A refinement to avoid this problem is to act on 2046 the window information from segments that carry the highest 2047 acknowledgment number (that is segments with acknowledgment number 2048 equal or greater than the highest previously received). 2050 Indicating a large window encourages transmissions. If more data 2051 arrives than can be accepted, it will be discarded. This will result 2052 in excessive retransmissions, adding unnecessarily to the load on the 2053 network and the TCP endpoints. Indicating a small window may 2054 restrict the transmission of data to the point of introducing a round 2055 trip delay between each new segment transmitted. 2057 The mechanisms provided allow a TCP endpoint to advertise a large 2058 window and to subsequently advertise a much smaller window without 2059 having accepted that much data. This, so called "shrinking the 2060 window," is strongly discouraged. The robustness principle [17] 2061 dictates that TCP peers will not shrink the window themselves, but 2062 will be prepared for such behavior on the part of other TCP peers. 2064 A TCP receiver SHOULD NOT shrink the window, i.e., move the right 2065 window edge to the left (SHLD-14). However, a sending TCP peer MUST 2066 be robust against window shrinking, which may cause the "usable 2067 window" (see Section 3.8.6.2.1) to become negative (MUST-34). 2069 If this happens, the sender SHOULD NOT send new data (SHLD-15), but 2070 SHOULD retransmit normally the old unacknowledged data between 2071 SND.UNA and SND.UNA+SND.WND (SHLD-16). The sender MAY also 2072 retransmit old data beyond SND.UNA+SND.WND (MAY-7), but SHOULD NOT 2073 time out the connection if data beyond the right window edge is not 2074 acknowledged (SHLD-17). If the window shrinks to zero, the TCP 2075 implementation MUST probe it in the standard way (described below) 2076 (MUST-35). 2078 3.8.6.1. Zero Window Probing 2080 The sending TCP peer must be prepared to accept from the user and 2081 send at least one octet of new data even if the send window is zero. 2082 The sending TCP peer must regularly retransmit to the receiving TCP 2083 peer even when the window is zero, in order to "probe" the window. 2084 Two minutes is recommended for the retransmission interval when the 2085 window is zero. This retransmission is essential to guarantee that 2086 when either TCP peer has a zero window the re-opening of the window 2087 will be reliably reported to the other. This is referred to as Zero- 2088 Window Probing (ZWP) in other documents. 2090 Probing of zero (offered) windows MUST be supported (MUST-36). 2092 A TCP implementation MAY keep its offered receive window closed 2093 indefinitely (MAY-8). As long as the receiving TCP peer continues to 2094 send acknowledgments in response to the probe segments, the sending 2095 TCP peer MUST allow the connection to stay open (MUST-37). This 2096 enables TCP to function in scenarios such as the "printer ran out of 2097 paper" situation described in Section 4.2.2.17 of RFC1122. The 2098 behavior is subject to the implementation's resource management 2099 concerns, as noted in [40]. 2101 When the receiving TCP peer has a zero window and a segment arrives 2102 it must still send an acknowledgment showing its next expected 2103 sequence number and current window (zero). 2105 The transmitting host SHOULD send the first zero-window probe when a 2106 zero window has existed for the retransmission timeout period (SHLD- 2107 29) (Section 3.8.1), and SHOULD increase exponentially the interval 2108 between successive probes (SHLD-30). 2110 3.8.6.2. Silly Window Syndrome Avoidance 2112 The "Silly Window Syndrome" (SWS) is a stable pattern of small 2113 incremental window movements resulting in extremely poor TCP 2114 performance. Algorithms to avoid SWS are described below for both 2115 the sending side and the receiving side. RFC 1122 contains more 2116 detailed discussion of the SWS problem. Note that the Nagle 2117 algorithm and the sender SWS avoidance algorithm play complementary 2118 roles in improving performance. The Nagle algorithm discourages 2119 sending tiny segments when the data to be sent increases in small 2120 increments, while the SWS avoidance algorithm discourages small 2121 segments resulting from the right window edge advancing in small 2122 increments. 2124 3.8.6.2.1. Sender's Algorithm - When to Send Data 2126 A TCP implementation MUST include a SWS avoidance algorithm in the 2127 sender (MUST-38). 2129 The Nagle algorithm from Section 3.7.4 additionally describes how to 2130 coalesce short segments. 2132 The sender's SWS avoidance algorithm is more difficult than the 2133 receivers's, because the sender does not know (directly) the 2134 receiver's total buffer space RCV.BUFF. An approach that has been 2135 found to work well is for the sender to calculate Max(SND.WND), the 2136 maximum send window it has seen so far on the connection, and to use 2137 this value as an estimate of RCV.BUFF. Unfortunately, this can only 2138 be an estimate; the receiver may at any time reduce the size of 2139 RCV.BUFF. To avoid a resulting deadlock, it is necessary to have a 2140 timeout to force transmission of data, overriding the SWS avoidance 2141 algorithm. In practice, this timeout should seldom occur. 2143 The "usable window" is: 2145 U = SND.UNA + SND.WND - SND.NXT 2147 i.e., the offered window less the amount of data sent but not 2148 acknowledged. If D is the amount of data queued in the sending TCP 2149 endpoint but not yet sent, then the following set of rules is 2150 recommended. 2152 Send data: 2154 (1) if a maximum-sized segment can be sent, i.e, if: 2156 min(D,U) >= Eff.snd.MSS; 2158 (2) or if the data is pushed and all queued data can be sent now, 2159 i.e., if: 2161 [SND.NXT = SND.UNA and] PUSHED and D <= U 2163 (the bracketed condition is imposed by the Nagle algorithm); 2165 (3) or if at least a fraction Fs of the maximum window can be sent, 2166 i.e., if: 2168 [SND.NXT = SND.UNA and] 2170 min(D.U) >= Fs * Max(SND.WND); 2172 (4) or if data is PUSHed and the override timeout occurs. 2174 Here Fs is a fraction whose recommended value is 1/2. The override 2175 timeout should be in the range 0.1 - 1.0 seconds. It may be 2176 convenient to combine this timer with the timer used to probe zero 2177 windows (Section 3.8.6.1). 2179 3.8.6.2.2. Receiver's Algorithm - When to Send a Window Update 2181 A TCP implementation MUST include a SWS avoidance algorithm in the 2182 receiver (MUST-39). 2184 The receiver's SWS avoidance algorithm determines when the right 2185 window edge may be advanced; this is customarily known as "updating 2186 the window". This algorithm combines with the delayed ACK algorithm 2187 (Section 3.8.6.3) to determine when an ACK segment containing the 2188 current window will really be sent to the receiver. 2190 The solution to receiver SWS is to avoid advancing the right window 2191 edge RCV.NXT+RCV.WND in small increments, even if data is received 2192 from the network in small segments. 2194 Suppose the total receive buffer space is RCV.BUFF. At any given 2195 moment, RCV.USER octets of this total may be tied up with data that 2196 has been received and acknowledged but that the user process has not 2197 yet consumed. When the connection is quiescent, RCV.WND = RCV.BUFF 2198 and RCV.USER = 0. 2200 Keeping the right window edge fixed as data arrives and is 2201 acknowledged requires that the receiver offer less than its full 2202 buffer space, i.e., the receiver must specify a RCV.WND that keeps 2203 RCV.NXT+RCV.WND constant as RCV.NXT increases. Thus, the total 2204 buffer space RCV.BUFF is generally divided into three parts: 2206 |<------- RCV.BUFF ---------------->| 2207 1 2 3 2208 ----|---------|------------------|------|---- 2209 RCV.NXT ^ 2210 (Fixed) 2212 1 - RCV.USER = data received but not yet consumed; 2213 2 - RCV.WND = space advertised to sender; 2214 3 - Reduction = space available but not yet 2215 advertised. 2217 The suggested SWS avoidance algorithm for the receiver is to keep 2218 RCV.NXT+RCV.WND fixed until the reduction satisfies: 2220 RCV.BUFF - RCV.USER - RCV.WND >= 2222 min( Fr * RCV.BUFF, Eff.snd.MSS ) 2224 where Fr is a fraction whose recommended value is 1/2, and 2225 Eff.snd.MSS is the effective send MSS for the connection (see 2226 Section 3.7.1). When the inequality is satisfied, RCV.WND is set to 2227 RCV.BUFF-RCV.USER. 2229 Note that the general effect of this algorithm is to advance RCV.WND 2230 in increments of Eff.snd.MSS (for realistic receive buffers: 2231 Eff.snd.MSS < RCV.BUFF/2). Note also that the receiver must use its 2232 own Eff.snd.MSS, assuming it is the same as the sender's. 2234 3.8.6.3. Delayed Acknowledgements - When to Send an ACK Segment 2236 A host that is receiving a stream of TCP data segments can increase 2237 efficiency in both the Internet and the hosts by sending fewer than 2238 one ACK (acknowledgment) segment per data segment received; this is 2239 known as a "delayed ACK". 2241 A TCP endpoint SHOULD implement a delayed ACK (SHLD-18), but an ACK 2242 should not be excessively delayed; in particular, the delay MUST be 2243 less than 0.5 seconds (MUST-40), and in a stream of full-sized 2244 segments there SHOULD be an ACK for at least every second segment 2245 (SHLD-19). Excessive delays on ACKs can disturb the round-trip 2246 timing and packet "clocking" algorithms. More complete discussion of 2247 delayed ACK behavior is in Section 4.2 of RFC 5681 [34], including 2248 rules for streams of segments that are not full-sized. Note that 2249 there are several current practices that further lead to a reduced 2250 number of ACKs, including generic receive offload (GRO), ACK 2251 compression, and ACK decimation [25]. 2253 3.9. Interfaces 2255 There are of course two interfaces of concern: the user/TCP interface 2256 and the TCP/lower-level interface. We have a fairly elaborate model 2257 of the user/TCP interface, but the interface to the lower level 2258 protocol module is left unspecified here, since it will be specified 2259 in detail by the specification of the lower level protocol. For the 2260 case that the lower level is IP we note some of the parameter values 2261 that TCP implementations might use. 2263 3.9.1. User/TCP Interface 2265 The following functional description of user commands to the TCP 2266 implementation is, at best, fictional, since every operating system 2267 will have different facilities. Consequently, we must warn readers 2268 that different TCP implementations may have different user 2269 interfaces. However, all TCP implementations must provide a certain 2270 minimum set of services to guarantee that all TCP implementations can 2271 support the same protocol hierarchy. This section specifies the 2272 functional interfaces required of all TCP implementations. 2274 Section 3.1 of [52] also identifies primitives provided by TCP, and 2275 could be used as an additional reference for implementers. 2277 TCP User Commands 2279 The following sections functionally characterize a USER/TCP 2280 interface. The notation used is similar to most procedure or 2281 function calls in high level languages, but this usage is not 2282 meant to rule out trap type service calls. 2284 The user commands described below specify the basic functions the 2285 TCP implementation must perform to support interprocess 2286 communication. Individual implementations must define their own 2287 exact format, and may provide combinations or subsets of the basic 2288 functions in single calls. In particular, some implementations 2289 may wish to automatically OPEN a connection on the first SEND or 2290 RECEIVE issued by the user for a given connection. 2292 In providing interprocess communication facilities, the TCP 2293 implementation must not only accept commands, but must also return 2294 information to the processes it serves. The latter consists of: 2296 (a) general information about a connection (e.g., interrupts, 2297 remote close, binding of unspecified remote socket). 2299 (b) replies to specific user commands indicating success or 2300 various types of failure. 2302 Open 2304 Format: OPEN (local port, remote socket, active/passive [, 2305 timeout] [, DiffServ field] [, security/compartment] [local IP 2306 address,] [, options]) -> local connection name 2308 If the active/passive flag is set to passive, then this is a 2309 call to LISTEN for an incoming connection. A passive open may 2310 have either a fully specified remote socket to wait for a 2311 particular connection or an unspecified remote socket to wait 2312 for any call. A fully specified passive call can be made 2313 active by the subsequent execution of a SEND. 2315 A transmission control block (TCB) is created and partially 2316 filled in with data from the OPEN command parameters. 2318 Every passive OPEN call either creates a new connection record 2319 in LISTEN state, or it returns an error; it MUST NOT affect any 2320 previously created connection record (MUST-41). 2322 A TCP implementation that supports multiple concurrent 2323 connections MUST provide an OPEN call that will functionally 2324 allow an application to LISTEN on a port while a connection 2325 block with the same local port is in SYN-SENT or SYN-RECEIVED 2326 state (MUST-42). 2328 On an active OPEN command, the TCP endpoint will begin the 2329 procedure to synchronize (i.e., establish) the connection at 2330 once. 2332 The timeout, if present, permits the caller to set up a timeout 2333 for all data submitted to TCP. If data is not successfully 2334 delivered to the destination within the timeout period, the TCP 2335 endpoint will abort the connection. The present global default 2336 is five minutes. 2338 The TCP implementation or some component of the operating 2339 system will verify the users authority to open a connection 2340 with the specified DiffServ field value or security/ 2341 compartment. The absence of a DiffServ field value or 2342 security/compartment specification in the OPEN call indicates 2343 the default values must be used. 2345 TCP will accept incoming requests as matching only if the 2346 security/compartment information is exactly the same as that 2347 requested in the OPEN call. 2349 The DiffServ field value indicated by the user only impacts 2350 outgoing packets, may be altered en route through the network, 2351 and has no direct bearing or relation to received packets. 2353 A local connection name will be returned to the user by the TCP 2354 implementation. The local connection name can then be used as 2355 a short hand term for the connection defined by the pair. 2358 The optional "local IP address" parameter MUST be supported to 2359 allow the specification of the local IP address (MUST-43). 2360 This enables applications that need to select the local IP 2361 address used when multihoming is present. 2363 A passive OPEN call with a specified "local IP address" 2364 parameter will await an incoming connection request to that 2365 address. If the parameter is unspecified, a passive OPEN will 2366 await an incoming connection request to any local IP address, 2367 and then bind the local IP address of the connection to the 2368 particular address that is used. 2370 For an active OPEN call, a specified "local IP address" 2371 parameter will be used for opening the connection. If the 2372 parameter is unspecified, the host will choose an appropriate 2373 local IP address (see RFC 1122 section 3.3.4.2). 2375 If an application on a multihomed host does not specify the 2376 local IP address when actively opening a TCP connection, then 2377 the TCP implementation MUST ask the IP layer to select a local 2378 IP address before sending the (first) SYN (MUST-44). See the 2379 function GET_SRCADDR() in Section 3.4 of RFC 1122. 2381 At all other times, a previous segment has either been sent or 2382 received on this connection, and TCP implementations MUST use 2383 the same local address is used that was used in those previous 2384 segments (MUST-45). 2386 A TCP implementation MUST reject as an error a local OPEN call 2387 for an invalid remote IP address (e.g., a broadcast or 2388 multicast address) (MUST-46). 2390 Send 2391 Format: SEND (local connection name, buffer address, byte 2392 count, PUSH flag (optional), URGENT flag [,timeout]) 2394 This call causes the data contained in the indicated user 2395 buffer to be sent on the indicated connection. If the 2396 connection has not been opened, the SEND is considered an 2397 error. Some implementations may allow users to SEND first; in 2398 which case, an automatic OPEN would be done. For example, this 2399 might be one way for application data to be included in SYN 2400 segments. If the calling process is not authorized to use this 2401 connection, an error is returned. 2403 A TCP endpoint MAY implement PUSH flags on SEND calls (MAY-15). 2404 If PUSH flags are not implemented, then the sending TCP peer: 2405 (1) MUST NOT buffer data indefinitely (MUST-60), and (2) MUST 2406 set the PSH bit in the last buffered segment (i.e., when there 2407 is no more queued data to be sent) (MUST-61). The remaining 2408 description below assumes the PUSH flag is supported on SEND 2409 calls. 2411 If the PUSH flag is set, the application intends the data to be 2412 transmitted promptly to the receiver, and the PUSH bit will be 2413 set in the last TCP segment created from the buffer. When an 2414 application issues a series of SEND calls without setting the 2415 PUSH flag, the TCP implementation MAY aggregate the data 2416 internally without sending it (MAY-16). 2418 The PSH bit is not a record marker and is independent of 2419 segment boundaries. The transmitter SHOULD collapse successive 2420 bits when it packetizes data, to send the largest possible 2421 segment (SHLD-27). 2423 If the PUSH flag is not set, the data may be combined with data 2424 from subsequent SENDs for transmission efficiency. Note that 2425 when the Nagle algorithm is in use, TCP implementations may 2426 buffer the data before sending, without regard to the PUSH flag 2427 (see Section 3.7.4). 2429 An application program is logically required to set the PUSH 2430 flag in a SEND call whenever it needs to force delivery of the 2431 data to avoid a communication deadlock. However, a TCP 2432 implementation SHOULD send a maximum-sized segment whenever 2433 possible (SHLD-28), to improve performance (see 2434 Section 3.8.6.2.1). 2436 New applications SHOULD NOT set the URGENT flag [38] due to 2437 implementation differences and middlebox issues (SHLD-13). 2439 If the URGENT flag is set, segments sent to the destination TCP 2440 peer will have the urgent pointer set. The receiving TCP peer 2441 will signal the urgent condition to the receiving process if 2442 the urgent pointer indicates that data preceding the urgent 2443 pointer has not been consumed by the receiving process. The 2444 purpose of urgent is to stimulate the receiver to process the 2445 urgent data and to indicate to the receiver when all the 2446 currently known urgent data has been received. The number of 2447 times the sending user's TCP implementation signals urgent will 2448 not necessarily be equal to the number of times the receiving 2449 user will be notified of the presence of urgent data. 2451 If no remote socket was specified in the OPEN, but the 2452 connection is established (e.g., because a LISTENing connection 2453 has become specific due to a remote segment arriving for the 2454 local socket), then the designated buffer is sent to the 2455 implied remote socket. Users who make use of OPEN with an 2456 unspecified remote socket can make use of SEND without ever 2457 explicitly knowing the remote socket address. 2459 However, if a SEND is attempted before the remote socket 2460 becomes specified, an error will be returned. Users can use 2461 the STATUS call to determine the status of the connection. 2462 Some TCP implementations may notify the user when an 2463 unspecified socket is bound. 2465 If a timeout is specified, the current user timeout for this 2466 connection is changed to the new one. 2468 In the simplest implementation, SEND would not return control 2469 to the sending process until either the transmission was 2470 complete or the timeout had been exceeded. However, this 2471 simple method is both subject to deadlocks (for example, both 2472 sides of the connection might try to do SENDs before doing any 2473 RECEIVEs) and offers poor performance, so it is not 2474 recommended. A more sophisticated implementation would return 2475 immediately to allow the process to run concurrently with 2476 network I/O, and, furthermore, to allow multiple SENDs to be in 2477 progress. Multiple SENDs are served in first come, first 2478 served order, so the TCP endpoint will queue those it cannot 2479 service immediately. 2481 We have implicitly assumed an asynchronous user interface in 2482 which a SEND later elicits some kind of SIGNAL or pseudo- 2483 interrupt from the serving TCP endpoint. An alternative is to 2484 return a response immediately. For instance, SENDs might 2485 return immediate local acknowledgment, even if the segment sent 2486 had not been acknowledged by the distant TCP endpoint. We 2487 could optimistically assume eventual success. If we are wrong, 2488 the connection will close anyway due to the timeout. In 2489 implementations of this kind (synchronous), there will still be 2490 some asynchronous signals, but these will deal with the 2491 connection itself, and not with specific segments or buffers. 2493 In order for the process to distinguish among error or success 2494 indications for different SENDs, it might be appropriate for 2495 the buffer address to be returned along with the coded response 2496 to the SEND request. TCP-to-user signals are discussed below, 2497 indicating the information that should be returned to the 2498 calling process. 2500 Receive 2502 Format: RECEIVE (local connection name, buffer address, byte 2503 count) -> byte count, urgent flag, push flag (optional) 2505 This command allocates a receiving buffer associated with the 2506 specified connection. If no OPEN precedes this command or the 2507 calling process is not authorized to use this connection, an 2508 error is returned. 2510 In the simplest implementation, control would not return to the 2511 calling program until either the buffer was filled, or some 2512 error occurred, but this scheme is highly subject to deadlocks. 2513 A more sophisticated implementation would permit several 2514 RECEIVEs to be outstanding at once. These would be filled as 2515 segments arrive. This strategy permits increased throughput at 2516 the cost of a more elaborate scheme (possibly asynchronous) to 2517 notify the calling program that a PUSH has been seen or a 2518 buffer filled. 2520 A TCP receiver MAY pass a received PSH flag to the application 2521 layer via the PUSH flag in the interface (MAY-17), but it is 2522 not required (this was clarified in RFC 1122 section 4.2.2.2). 2523 The remainder of text describing the RECEIVE call below assumes 2524 that passing the PUSH indication is supported. 2526 If enough data arrive to fill the buffer before a PUSH is seen, 2527 the PUSH flag will not be set in the response to the RECEIVE. 2528 The buffer will be filled with as much data as it can hold. If 2529 a PUSH is seen before the buffer is filled the buffer will be 2530 returned partially filled and PUSH indicated. 2532 If there is urgent data the user will have been informed as 2533 soon as it arrived via a TCP-to-user signal. The receiving 2534 user should thus be in "urgent mode". If the URGENT flag is 2535 on, additional urgent data remains. If the URGENT flag is off, 2536 this call to RECEIVE has returned all the urgent data, and the 2537 user may now leave "urgent mode". Note that data following the 2538 urgent pointer (non-urgent data) cannot be delivered to the 2539 user in the same buffer with preceding urgent data unless the 2540 boundary is clearly marked for the user. 2542 To distinguish among several outstanding RECEIVEs and to take 2543 care of the case that a buffer is not completely filled, the 2544 return code is accompanied by both a buffer pointer and a byte 2545 count indicating the actual length of the data received. 2547 Alternative implementations of RECEIVE might have the TCP 2548 endpoint allocate buffer storage, or the TCP endpoint might 2549 share a ring buffer with the user. 2551 Close 2553 Format: CLOSE (local connection name) 2555 This command causes the connection specified to be closed. If 2556 the connection is not open or the calling process is not 2557 authorized to use this connection, an error is returned. 2558 Closing connections is intended to be a graceful operation in 2559 the sense that outstanding SENDs will be transmitted (and 2560 retransmitted), as flow control permits, until all have been 2561 serviced. Thus, it should be acceptable to make several SEND 2562 calls, followed by a CLOSE, and expect all the data to be sent 2563 to the destination. It should also be clear that users should 2564 continue to RECEIVE on CLOSING connections, since the remote 2565 peer may be trying to transmit the last of its data. Thus, 2566 CLOSE means "I have no more to send" but does not mean "I will 2567 not receive any more." It may happen (if the user level 2568 protocol is not well thought out) that the closing side is 2569 unable to get rid of all its data before timing out. In this 2570 event, CLOSE turns into ABORT, and the closing TCP peer gives 2571 up. 2573 The user may CLOSE the connection at any time on their own 2574 initiative, or in response to various prompts from the TCP 2575 implementation (e.g., remote close executed, transmission 2576 timeout exceeded, destination inaccessible). 2578 Because closing a connection requires communication with the 2579 remote TCP peer, connections may remain in the closing state 2580 for a short time. Attempts to reopen the connection before the 2581 TCP peer replies to the CLOSE command will result in error 2582 responses. 2584 Close also implies push function. 2586 Status 2588 Format: STATUS (local connection name) -> status data 2590 This is an implementation dependent user command and could be 2591 excluded without adverse effect. Information returned would 2592 typically come from the TCB associated with the connection. 2594 This command returns a data block containing the following 2595 information: 2597 local socket, 2598 remote socket, 2599 local connection name, 2600 receive window, 2601 send window, 2602 connection state, 2603 number of buffers awaiting acknowledgment, 2604 number of buffers pending receipt, 2605 urgent state, 2606 DiffServ field value, 2607 security/compartment, 2608 and transmission timeout. 2610 Depending on the state of the connection, or on the 2611 implementation itself, some of this information may not be 2612 available or meaningful. If the calling process is not 2613 authorized to use this connection, an error is returned. This 2614 prevents unauthorized processes from gaining information about 2615 a connection. 2617 Abort 2619 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 [12]. 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 [32] 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 [10] 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, 2 2776 Since these Unreachable messages indicate soft error conditions, 2777 TCP implementations MUST NOT abort the connection (MUST-56), and it 2778 SHOULD make the information available to the application (SHLD-25). 2780 Hard Errors 2781 For ICMP these include Destination Unreachable -- codes 2-4"> 2782 These are hard error conditions, so TCP implementations SHOULD 2783 abort the connection (SHLD-26). [32] notes that some 2784 implementations do not abort connections when an ICMP hard error is 2785 received for a connection that is in any of the synchronized 2786 states. 2788 Note that [32] section 4 describes widespread implementation behavior 2789 that treats soft errors as hard errors during connection 2790 establishment. 2792 3.9.2.3. Source Address Validation 2794 RFC 1122 requires addresses to be validated in incoming SYN packets: 2796 An incoming SYN with an invalid source address MUST be ignored 2797 either by TCP or by the IP layer (MUST-63) (Section 3.2.1.3 of 2798 [17]). 2800 A TCP implementation MUST silently discard an incoming SYN segment 2801 that is addressed to a broadcast or multicast address (MUST-57). 2803 This prevents connection state and replies from being erroneously 2804 generated, and implementers should note that this guidance is 2805 applicable to all incoming segments, not just SYNs, as specifically 2806 indicated in RFC 1122. 2808 3.10. Event Processing 2810 The processing depicted in this section is an example of one possible 2811 implementation. Other implementations may have slightly different 2812 processing sequences, but they should differ from those in this 2813 section only in detail, not in substance. 2815 The activity of the TCP endpoint can be characterized as responding 2816 to events. The events that occur can be cast into three categories: 2817 user calls, arriving segments, and timeouts. This section describes 2818 the processing the TCP endpoint does in response to each of the 2819 events. In many cases the processing required depends on the state 2820 of the connection. 2822 Events that occur: 2824 User Calls 2826 OPEN 2827 SEND 2828 RECEIVE 2829 CLOSE 2830 ABORT 2831 STATUS 2833 Arriving Segments 2835 SEGMENT ARRIVES 2837 Timeouts 2839 USER TIMEOUT 2840 RETRANSMISSION TIMEOUT 2841 TIME-WAIT TIMEOUT 2843 The model of the TCP/user interface is that user commands receive an 2844 immediate return and possibly a delayed response via an event or 2845 pseudo interrupt. In the following descriptions, the term "signal" 2846 means cause a delayed response. 2848 Error responses in this document are identified by character strings. 2849 For example, user commands referencing connections that do not exist 2850 receive "error: connection not open". 2852 Please note in the following that all arithmetic on sequence numbers, 2853 acknowledgment numbers, windows, et cetera, is modulo 2**32 the size 2854 of the sequence number space. Also note that "=<" means less than or 2855 equal to (modulo 2**32). 2857 A natural way to think about processing incoming segments is to 2858 imagine that they are first tested for proper sequence number (i.e., 2859 that their contents lie in the range of the expected "receive window" 2860 in the sequence number space) and then that they are generally queued 2861 and processed in sequence number order. 2863 When a segment overlaps other already received segments we 2864 reconstruct the segment to contain just the new data, and adjust the 2865 header fields to be consistent. 2867 Note that if no state change is mentioned the TCP connection stays in 2868 the same state. 2870 OPEN Call 2872 CLOSED STATE (i.e., TCB does not exist) 2874 Create a new transmission control block (TCB) to hold 2875 connection state information. Fill in local socket identifier, 2876 remote socket, DiffServ field, security/compartment, and user 2877 timeout information. Note that some parts of the remote socket 2878 may be unspecified in a passive OPEN and are to be filled in by 2879 the parameters of the incoming SYN segment. Verify the 2880 security and DiffServ value requested are allowed for this 2881 user, if not return "error: precedence not allowed" or "error: 2882 security/compartment not allowed." If passive enter the LISTEN 2883 state and return. If active and the remote socket is 2884 unspecified, return "error: remote socket unspecified"; if 2885 active and the remote socket is specified, issue a SYN segment. 2886 An initial send sequence number (ISS) is selected. A SYN 2887 segment of the form is sent. Set SND.UNA to 2888 ISS, SND.NXT to ISS+1, enter SYN-SENT state, and return. 2890 If the caller does not have access to the local socket 2891 specified, return "error: connection illegal for this process". 2892 If there is no room to create a new connection, return "error: 2893 insufficient resources". 2895 LISTEN STATE 2897 If active and the remote socket is specified, then change the 2898 connection from passive to active, select an ISS. Send a SYN 2899 segment, set SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT 2900 state. Data associated with SEND may be sent with SYN segment 2901 or queued for transmission after entering ESTABLISHED state. 2902 The urgent bit if requested in the command must be sent with 2903 the data segments sent as a result of this command. If there 2904 is no room to queue the request, respond with "error: 2905 insufficient resources". If Foreign socket was not specified, 2906 then return "error: remote socket unspecified". 2908 SYN-SENT STATE 2909 SYN-RECEIVED STATE 2910 ESTABLISHED STATE 2911 FIN-WAIT-1 STATE 2912 FIN-WAIT-2 STATE 2913 CLOSE-WAIT STATE 2914 CLOSING STATE 2915 LAST-ACK STATE 2916 TIME-WAIT STATE 2918 Return "error: connection already exists". 2920 SEND Call 2922 CLOSED STATE (i.e., TCB does not exist) 2924 If the user does not have access to such a connection, then 2925 return "error: connection illegal for this process". 2927 Otherwise, return "error: connection does not exist". 2929 LISTEN STATE 2931 If the remote socket is specified, then change the connection 2932 from passive to active, select an ISS. Send a SYN segment, set 2933 SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT state. Data 2934 associated with SEND may be sent with SYN segment or queued for 2935 transmission after entering ESTABLISHED state. The urgent bit 2936 if requested in the command must be sent with the data segments 2937 sent as a result of this command. If there is no room to queue 2938 the request, respond with "error: insufficient resources". If 2939 Foreign socket was not specified, then return "error: remote 2940 socket unspecified". 2942 SYN-SENT STATE 2943 SYN-RECEIVED STATE 2945 Queue the data for transmission after entering ESTABLISHED 2946 state. If no space to queue, respond with "error: insufficient 2947 resources". 2949 ESTABLISHED STATE 2950 CLOSE-WAIT STATE 2952 Segmentize the buffer and send it with a piggybacked 2953 acknowledgment (acknowledgment value = RCV.NXT). If there is 2954 insufficient space to remember this buffer, simply return 2955 "error: insufficient resources". 2957 If the urgent flag is set, then SND.UP <- SND.NXT and set the 2958 urgent pointer in the outgoing segments. 2960 FIN-WAIT-1 STATE 2961 FIN-WAIT-2 STATE 2962 CLOSING STATE 2963 LAST-ACK STATE 2964 TIME-WAIT STATE 2966 Return "error: connection closing" and do not service request. 2968 RECEIVE Call 2970 CLOSED STATE (i.e., TCB does not exist) 2972 If the user does not have access to such a connection, return 2973 "error: connection illegal for this process". 2975 Otherwise return "error: connection does not exist". 2977 LISTEN STATE 2978 SYN-SENT STATE 2979 SYN-RECEIVED STATE 2981 Queue for processing after entering ESTABLISHED state. If 2982 there is no room to queue this request, respond with "error: 2983 insufficient resources". 2985 ESTABLISHED STATE 2986 FIN-WAIT-1 STATE 2987 FIN-WAIT-2 STATE 2989 If insufficient incoming segments are queued to satisfy the 2990 request, queue the request. If there is no queue space to 2991 remember the RECEIVE, respond with "error: insufficient 2992 resources". 2994 Reassemble queued incoming segments into receive buffer and 2995 return to user. Mark "push seen" (PUSH) if this is the case. 2997 If RCV.UP is in advance of the data currently being passed to 2998 the user notify the user of the presence of urgent data. 3000 When the TCP endpoint takes responsibility for delivering data 3001 to the user that fact must be communicated to the sender via an 3002 acknowledgment. The formation of such an acknowledgment is 3003 described below in the discussion of processing an incoming 3004 segment. 3006 CLOSE-WAIT STATE 3008 Since the remote side has already sent FIN, RECEIVEs must be 3009 satisfied by text already on hand, but not yet delivered to the 3010 user. If no text is awaiting delivery, the RECEIVE will get a 3011 "error: connection closing" response. Otherwise, any remaining 3012 text can be used to satisfy the RECEIVE. 3014 CLOSING STATE 3015 LAST-ACK STATE 3016 TIME-WAIT STATE 3018 Return "error: connection closing". 3020 CLOSE Call 3022 CLOSED STATE (i.e., TCB does not exist) 3024 If the user does not have access to such a connection, return 3025 "error: connection illegal for this process". 3027 Otherwise, return "error: connection does not exist". 3029 LISTEN STATE 3031 Any outstanding RECEIVEs are returned with "error: closing" 3032 responses. Delete TCB, enter CLOSED state, and return. 3034 SYN-SENT STATE 3036 Delete the TCB and return "error: closing" responses to any 3037 queued SENDs, or RECEIVEs. 3039 SYN-RECEIVED STATE 3041 If no SENDs have been issued and there is no pending data to 3042 send, then form a FIN segment and send it, and enter FIN-WAIT-1 3043 state; otherwise queue for processing after entering 3044 ESTABLISHED state. 3046 ESTABLISHED STATE 3048 Queue this until all preceding SENDs have been segmentized, 3049 then form a FIN segment and send it. In any case, enter FIN- 3050 WAIT-1 state. 3052 FIN-WAIT-1 STATE 3053 FIN-WAIT-2 STATE 3055 Strictly speaking, this is an error and should receive a 3056 "error: connection closing" response. An "ok" response would 3057 be acceptable, too, as long as a second FIN is not emitted (the 3058 first FIN may be retransmitted though). 3060 CLOSE-WAIT STATE 3062 Queue this request until all preceding SENDs have been 3063 segmentized; then send a FIN segment, enter LAST-ACK state. 3065 CLOSING STATE 3066 LAST-ACK STATE 3067 TIME-WAIT STATE 3068 Respond with "error: connection closing". 3070 ABORT Call 3072 CLOSED STATE (i.e., TCB does not exist) 3074 If the user should not have access to such a connection, return 3075 "error: connection illegal for this process". 3077 Otherwise return "error: connection does not exist". 3079 LISTEN STATE 3081 Any outstanding RECEIVEs should be returned with "error: 3082 connection reset" responses. Delete TCB, enter CLOSED state, 3083 and return. 3085 SYN-SENT STATE 3087 All queued SENDs and RECEIVEs should be given "connection 3088 reset" notification, delete the TCB, enter CLOSED state, and 3089 return. 3091 SYN-RECEIVED STATE 3092 ESTABLISHED STATE 3093 FIN-WAIT-1 STATE 3094 FIN-WAIT-2 STATE 3095 CLOSE-WAIT STATE 3097 Send a reset segment: 3099 3101 All queued SENDs and RECEIVEs should be given "connection 3102 reset" notification; all segments queued for transmission 3103 (except for the RST formed above) or retransmission should be 3104 flushed, delete the TCB, enter CLOSED state, and return. 3106 CLOSING STATE LAST-ACK STATE TIME-WAIT STATE 3108 Respond with "ok" and delete the TCB, enter CLOSED state, and 3109 return. 3111 STATUS Call 3113 CLOSED STATE (i.e., TCB does not exist) 3115 If the user should not have access to such a connection, return 3116 "error: connection illegal for this process". 3118 Otherwise return "error: connection does not exist". 3120 LISTEN STATE 3122 Return "state = LISTEN", and the TCB pointer. 3124 SYN-SENT STATE 3126 Return "state = SYN-SENT", and the TCB pointer. 3128 SYN-RECEIVED STATE 3130 Return "state = SYN-RECEIVED", and the TCB pointer. 3132 ESTABLISHED STATE 3134 Return "state = ESTABLISHED", and the TCB pointer. 3136 FIN-WAIT-1 STATE 3138 Return "state = FIN-WAIT-1", and the TCB pointer. 3140 FIN-WAIT-2 STATE 3142 Return "state = FIN-WAIT-2", and the TCB pointer. 3144 CLOSE-WAIT STATE 3146 Return "state = CLOSE-WAIT", and the TCB pointer. 3148 CLOSING STATE 3150 Return "state = CLOSING", and the TCB pointer. 3152 LAST-ACK STATE 3154 Return "state = LAST-ACK", and the TCB pointer. 3156 TIME-WAIT STATE 3158 Return "state = TIME-WAIT", and the TCB pointer. 3160 SEGMENT ARRIVES 3162 If the state is CLOSED (i.e., TCB does not exist) then 3164 all data in the incoming segment is discarded. An incoming 3165 segment containing a RST is discarded. An incoming segment not 3166 containing a RST causes a RST to be sent in response. The 3167 acknowledgment and sequence field values are selected to make 3168 the reset sequence acceptable to the TCP endpoint that sent the 3169 offending segment. 3171 If the ACK bit is off, sequence number zero is used, 3173 3175 If the ACK bit is on, 3177 3179 Return. 3181 If the state is LISTEN then 3183 first check for an RST 3185 An incoming RST should be ignored. Return. 3187 second check for an ACK 3189 Any acknowledgment is bad if it arrives on a connection 3190 still in the LISTEN state. An acceptable reset segment 3191 should be formed for any arriving ACK-bearing segment. The 3192 RST should be formatted as follows: 3194 3196 Return. 3198 third check for a SYN 3200 If the SYN bit is set, check the security. If the security/ 3201 compartment on the incoming segment does not exactly match 3202 the security/compartment in the TCB then send a reset and 3203 return. 3205 3207 Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any 3208 other control or text should be queued for processing later. 3209 ISS should be selected and a SYN segment sent of the form: 3211 3213 SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 3214 state should be changed to SYN-RECEIVED. Note that any 3215 other incoming control or data (combined with SYN) will be 3216 processed in the SYN-RECEIVED state, but processing of SYN 3217 and ACK should not be repeated. If the listen was not fully 3218 specified (i.e., the remote socket was not fully specified), 3219 then the unspecified fields should be filled in now. 3221 fourth other text or control 3223 Any other control or text-bearing segment (not containing 3224 SYN) must have an ACK and thus would be discarded by the ACK 3225 processing. An incoming RST segment could not be valid, 3226 since it could not have been sent in response to anything 3227 sent by this incarnation of the connection. So, if this 3228 unlikely condition is reached, the correct behavior is to 3229 drop the segment and return. 3231 If the state is SYN-SENT then 3233 first check the ACK bit 3235 If the ACK bit is set 3237 If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset 3238 (unless the RST bit is set, if so drop the segment and 3239 return) 3241 3243 and discard the segment. Return. 3245 If SND.UNA < SEG.ACK =< SND.NXT then the ACK is 3246 acceptable. Some deployed TCP code has used the check 3247 SEG.ACK == SND.NXT (using "==" rather than "=<", but this 3248 is not appropriate when the stack is capable of sending 3249 data on the SYN, because the TCP peer may not accept and 3250 acknowledge all of the data on the SYN. 3252 second check the RST bit 3254 If the RST bit is set 3255 A potential blind reset attack is described in RFC 5961 3256 [37]. The mitigation described in that document has 3257 specific applicability explained therein, and is not a 3258 substitute for cryptographic protection (e.g. IPsec or 3259 TCP-AO). A TCP implementation that supports the RFC 5961 3260 mitigation SHOULD first check that the sequence number 3261 exactly matches RCV.NXT prior to executing the action in 3262 the next paragraph. 3264 If the ACK was acceptable then signal the user "error: 3265 connection reset", drop the segment, enter CLOSED state, 3266 delete TCB, and return. Otherwise (no ACK) drop the 3267 segment and return. 3269 third check the security 3271 If the security/compartment in the segment does not exactly 3272 match the security/compartment in the TCB, send a reset 3274 If there is an ACK 3276 3278 Otherwise 3280 3282 If a reset was sent, discard the segment and return. 3284 fourth check the SYN bit 3286 This step should be reached only if the ACK is ok, or there 3287 is no ACK, and it the segment did not contain a RST. 3289 If the SYN bit is on and the security/compartment is 3290 acceptable then, RCV.NXT is set to SEG.SEQ+1, IRS is set to 3291 SEG.SEQ. SND.UNA should be advanced to equal SEG.ACK (if 3292 there is an ACK), and any segments on the retransmission 3293 queue that are thereby acknowledged should be removed. 3295 If SND.UNA > ISS (our SYN has been ACKed), change the 3296 connection state to ESTABLISHED, form an ACK segment 3298 3300 and send it. Data or controls that were queued for 3301 transmission MAY be included. Some TCP implementations 3302 suppress sending this segment when the received segment 3303 contains data that will anyways generate an acknowledgement 3304 in the later processing steps, saving this extra 3305 acknowledgement of the SYN from being sent. If there are 3306 other controls or text in the segment then continue 3307 processing at the sixth step below where the URG bit is 3308 checked, otherwise return. 3310 Otherwise enter SYN-RECEIVED, form a SYN,ACK segment 3312 3314 and send it. Set the variables: 3316 SND.WND <- SEG.WND 3317 SND.WL1 <- SEG.SEQ 3318 SND.WL2 <- SEG.ACK 3320 If there are other controls or text in the segment, queue 3321 them for processing after the ESTABLISHED state has been 3322 reached, return. 3324 Note that it is legal to send and receive application data 3325 on SYN segments (this is the "text in the segment" mentioned 3326 above. There has been significant misinformation and 3327 misunderstanding of this topic historically. Some firewalls 3328 and security devices consider this suspicious. However, the 3329 capability was used in T/TCP [19] and is used in TCP Fast 3330 Open (TFO) [47], so is important for implementations and 3331 network devices to permit. 3333 fifth, if neither of the SYN or RST bits is set then drop the 3334 segment and return. 3336 Otherwise, 3338 first check sequence number 3340 SYN-RECEIVED STATE 3341 ESTABLISHED STATE 3342 FIN-WAIT-1 STATE 3343 FIN-WAIT-2 STATE 3344 CLOSE-WAIT STATE 3345 CLOSING STATE 3346 LAST-ACK STATE 3347 TIME-WAIT STATE 3349 Segments are processed in sequence. Initial tests on 3350 arrival are used to discard old duplicates, but further 3351 processing is done in SEG.SEQ order. If a segment's 3352 contents straddle the boundary between old and new, only the 3353 new parts should be processed. 3355 In general, the processing of received segments MUST be 3356 implemented to aggregate ACK segments whenever possible 3357 (MUST-58). For example, if the TCP endpoint is processing a 3358 series of queued segments, it MUST process them all before 3359 sending any ACK segments (MUST-59). 3361 There are four cases for the acceptability test for an 3362 incoming segment: 3364 Segment Receive Test 3365 Length Window 3366 ------- ------- ------------------------------------------- 3368 0 0 SEG.SEQ = RCV.NXT 3370 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3372 >0 0 not acceptable 3374 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3375 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 3377 In implementing sequence number validation as described 3378 here, please note Appendix A.2. 3380 If the RCV.WND is zero, no segments will be acceptable, but 3381 special allowance should be made to accept valid ACKs, URGs 3382 and RSTs. 3384 If an incoming segment is not acceptable, an acknowledgment 3385 should be sent in reply (unless the RST bit is set, if so 3386 drop the segment and return): 3388 3390 After sending the acknowledgment, drop the unacceptable 3391 segment and return. 3393 Note that for the TIME-WAIT state, there is an improved 3394 algorithm described in [39] for handling incoming SYN 3395 segments, that utilizes timestamps rather than relying on 3396 the sequence number check described here. When the improved 3397 algorithm is implemented, the logic above is not applicable 3398 for incoming SYN segments with timestamp options, received 3399 on a connection in the TIME-WAIT state. 3401 In the following it is assumed that the segment is the 3402 idealized segment that begins at RCV.NXT and does not exceed 3403 the window. One could tailor actual segments to fit this 3404 assumption by trimming off any portions that lie outside the 3405 window (including SYN and FIN), and only processing further 3406 if the segment then begins at RCV.NXT. Segments with higher 3407 beginning sequence numbers SHOULD be held for later 3408 processing (SHLD-31). 3410 second check the RST bit, 3412 RFC 5961 [37] section 3 describes a potential blind reset 3413 attack and optional mitigation approach. This does not 3414 provide a cryptographic protection (e.g. as in IPsec or TCP- 3415 AO), but can be applicable in situations described in RFC 3416 5961. For stacks implementing the RFC 5961 protection, the 3417 three checks below apply, otherwise processing for these 3418 states is indicated further below. 3420 1) If the RST bit is set and the sequence number is 3421 outside the current receive window, silently drop the 3422 segment. 3424 2) If the RST bit is set and the sequence number exactly 3425 matches the next expected sequence number (RCV.NXT), then 3426 TCP endpoints MUST reset the connection in the manner 3427 prescribed below according to the connection state. 3429 3) If the RST bit is set and the sequence number does not 3430 exactly match the next expected sequence value, yet is 3431 within the current receive window, TCP endpoints MUST 3432 send an acknowledgement (challenge ACK): 3434 3436 After sending the challenge ACK, TCP endpoints MUST drop 3437 the unacceptable segment and stop processing the incoming 3438 packet further. Note that RFC 5961 and Errata ID 4772 3439 contain additional considerations for ACK throttling in 3440 an implementation. 3442 SYN-RECEIVED STATE 3444 If the RST bit is set 3445 If this connection was initiated with a passive OPEN 3446 (i.e., came from the LISTEN state), then return this 3447 connection to LISTEN state and return. The user need 3448 not be informed. If this connection was initiated 3449 with an active OPEN (i.e., came from SYN-SENT state) 3450 then the connection was refused, signal the user 3451 "connection refused". In either case, all segments on 3452 the retransmission queue should be removed. And in 3453 the active OPEN case, enter the CLOSED state and 3454 delete the TCB, and return. 3456 ESTABLISHED 3457 FIN-WAIT-1 3458 FIN-WAIT-2 3459 CLOSE-WAIT 3461 If the RST bit is set then, any outstanding RECEIVEs and 3462 SEND should receive "reset" responses. All segment 3463 queues should be flushed. Users should also receive an 3464 unsolicited general "connection reset" signal. Enter the 3465 CLOSED state, delete the TCB, and return. 3467 CLOSING STATE 3468 LAST-ACK STATE 3469 TIME-WAIT 3471 If the RST bit is set then, enter the CLOSED state, 3472 delete the TCB, and return. 3474 third check security 3476 SYN-RECEIVED 3478 If the security/compartment in the segment does not 3479 exactly match the security/compartment in the TCB then 3480 send a reset, and return. 3482 ESTABLISHED 3483 FIN-WAIT-1 3484 FIN-WAIT-2 3485 CLOSE-WAIT 3486 CLOSING 3487 LAST-ACK 3488 TIME-WAIT 3490 If the security/compartment in the segment does not 3491 exactly match the security/compartment in the TCB then 3492 send a reset, any outstanding RECEIVEs and SEND should 3493 receive "reset" responses. All segment queues should be 3494 flushed. Users should also receive an unsolicited 3495 general "connection reset" signal. Enter the CLOSED 3496 state, delete the TCB, and return. 3498 Note this check is placed following the sequence check to 3499 prevent a segment from an old connection between these port 3500 numbers with a different security from causing an abort of 3501 the current connection. 3503 fourth, check the SYN bit, 3505 SYN-RECEIVED 3507 If the connection was initiated with a passive OPEN, then 3508 return this connection to the LISTEN state and return. 3509 Otherwise, handle per the directions for synchronized 3510 states below. 3512 ESTABLISHED STATE 3513 FIN-WAIT STATE-1 3514 FIN-WAIT STATE-2 3515 CLOSE-WAIT STATE 3516 CLOSING STATE 3517 LAST-ACK STATE 3518 TIME-WAIT STATE 3520 If the SYN bit is set in these synchronized states, it 3521 may be either a legitimate new connection attempt (e.g. 3522 in the case of TIME-WAIT), an error where the connection 3523 should be reset, or the result of an attack attempt, as 3524 described in RFC 5961 [37]. For the TIME-WAIT state, new 3525 connections can be accepted if the timestamp option is 3526 used and meets expectations (per [39]). For all other 3527 cases, RFC 5961 provides a mitigation with applicability 3528 to some situations, though there are also alternatives 3529 that offer cryptographic protection (see Section 6). RFC 3530 5961 recommends that in these synchronized states, if the 3531 SYN bit is set, irrespective of the sequence number, TCP 3532 endpoints MUST send a "challenge ACK" to the remote peer: 3534 3536 After sending the acknowledgement, TCP implementations 3537 MUST drop the unacceptable segment and stop processing 3538 further. Note that RFC 5961 and Errata ID 4772 contain 3539 additional ACK throttling notes for an implementation. 3541 For implementations that do not follow RFC 5961, the 3542 original RFC 793 behavior follows in this paragraph. If 3543 the SYN is in the window it is an error, send a reset, 3544 any outstanding RECEIVEs and SEND should receive "reset" 3545 responses, all segment queues should be flushed, the user 3546 should also receive an unsolicited general "connection 3547 reset" signal, enter the CLOSED state, delete the TCB, 3548 and return. 3550 If the SYN is not in the window this step would not be 3551 reached and an ACK would have been sent in the first step 3552 (sequence number check). 3554 fifth check the ACK field, 3556 if the ACK bit is off drop the segment and return 3558 if the ACK bit is on 3560 RFC 5961 [37] section 5 describes a potential blind data 3561 injection attack, and mitigation that implementations MAY 3562 choose to include (MAY-12). TCP stacks that implement 3563 RFC 5961 MUST add an input check that the ACK value is 3564 acceptable only if it is in the range of ((SND.UNA - 3565 MAX.SND.WND) =< SEG.ACK =< SND.NXT). All incoming 3566 segments whose ACK value doesn't satisfy the above 3567 condition MUST be discarded and an ACK sent back. The 3568 new state variable MAX.SND.WND is defined as the largest 3569 window that the local sender has ever received from its 3570 peer (subject to window scaling) or may be hard-coded to 3571 a maximum permissible window value. When the ACK value 3572 is acceptable, the processing per-state below applies: 3574 SYN-RECEIVED STATE 3576 If SND.UNA < SEG.ACK =< SND.NXT then enter ESTABLISHED 3577 state and continue processing with variables below set 3578 to: 3580 SND.WND <- SEG.WND 3581 SND.WL1 <- SEG.SEQ 3582 SND.WL2 <- SEG.ACK 3584 If the segment acknowledgment is not acceptable, form 3585 a reset segment, 3586 3588 and send it. 3590 ESTABLISHED STATE 3592 If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- 3593 SEG.ACK. Any segments on the retransmission queue 3594 that are thereby entirely acknowledged are removed. 3595 Users should receive positive acknowledgments for 3596 buffers that have been SENT and fully acknowledged 3597 (i.e., SEND buffer should be returned with "ok" 3598 response). If the ACK is a duplicate (SEG.ACK =< 3599 SND.UNA), it can be ignored. If the ACK acks 3600 something not yet sent (SEG.ACK > SND.NXT) then send 3601 an ACK, drop the segment, and return. 3603 If SND.UNA =< SEG.ACK =< SND.NXT, the send window 3604 should be updated. If (SND.WL1 < SEG.SEQ or (SND.WL1 3605 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- 3606 SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- 3607 SEG.ACK. 3609 Note that SND.WND is an offset from SND.UNA, that 3610 SND.WL1 records the sequence number of the last 3611 segment used to update SND.WND, and that SND.WL2 3612 records the acknowledgment number of the last segment 3613 used to update SND.WND. The check here prevents using 3614 old segments to update the window. 3616 FIN-WAIT-1 STATE 3618 In addition to the processing for the ESTABLISHED 3619 state, if the FIN segment is now acknowledged then 3620 enter FIN-WAIT-2 and continue processing in that 3621 state. 3623 FIN-WAIT-2 STATE 3625 In addition to the processing for the ESTABLISHED 3626 state, if the retransmission queue is empty, the 3627 user's CLOSE can be acknowledged ("ok") but do not 3628 delete the TCB. 3630 CLOSE-WAIT STATE 3632 Do the same processing as for the ESTABLISHED state. 3634 CLOSING STATE 3636 In addition to the processing for the ESTABLISHED 3637 state, if the ACK acknowledges our FIN then enter the 3638 TIME-WAIT state, otherwise ignore the segment. 3640 LAST-ACK STATE 3642 The only thing that can arrive in this state is an 3643 acknowledgment of our FIN. If our FIN is now 3644 acknowledged, delete the TCB, enter the CLOSED state, 3645 and return. 3647 TIME-WAIT STATE 3649 The only thing that can arrive in this state is a 3650 retransmission of the remote FIN. Acknowledge it, and 3651 restart the 2 MSL timeout. 3653 sixth, check the URG bit, 3655 ESTABLISHED STATE 3656 FIN-WAIT-1 STATE 3657 FIN-WAIT-2 STATE 3659 If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and 3660 signal the user that the remote side has urgent data if 3661 the urgent pointer (RCV.UP) is in advance of the data 3662 consumed. If the user has already been signaled (or is 3663 still in the "urgent mode") for this continuous sequence 3664 of urgent data, do not signal the user again. 3666 CLOSE-WAIT STATE 3667 CLOSING STATE 3668 LAST-ACK STATE 3669 TIME-WAIT 3671 This should not occur, since a FIN has been received from 3672 the remote side. Ignore the URG. 3674 seventh, process the segment text, 3676 ESTABLISHED STATE 3677 FIN-WAIT-1 STATE 3678 FIN-WAIT-2 STATE 3680 Once in the ESTABLISHED state, it is possible to deliver 3681 segment text to user RECEIVE buffers. Text from segments 3682 can be moved into buffers until either the buffer is full 3683 or the segment is empty. If the segment empties and 3684 carries a PUSH flag, then the user is informed, when the 3685 buffer is returned, that a PUSH has been received. 3687 When the TCP endpoint takes responsibility for delivering 3688 the data to the user it must also acknowledge the receipt 3689 of the data. 3691 Once the TCP endpoint takes responsibility for the data 3692 it advances RCV.NXT over the data accepted, and adjusts 3693 RCV.WND as appropriate to the current buffer 3694 availability. The total of RCV.NXT and RCV.WND should 3695 not be reduced. 3697 A TCP implementation MAY send an ACK segment 3698 acknowledging RCV.NXT when a valid segment arrives that 3699 is in the window but not at the left window edge (MAY- 3700 13). 3702 Please note the window management suggestions in 3703 Section 3.8. 3705 Send an acknowledgment of the form: 3707 3709 This acknowledgment should be piggybacked on a segment 3710 being transmitted if possible without incurring undue 3711 delay. 3713 CLOSE-WAIT STATE 3714 CLOSING STATE 3715 LAST-ACK STATE 3716 TIME-WAIT STATE 3718 This should not occur, since a FIN has been received from 3719 the remote side. Ignore the segment text. 3721 eighth, check the FIN bit, 3723 Do not process the FIN if the state is CLOSED, LISTEN or 3724 SYN-SENT since the SEG.SEQ cannot be validated; drop the 3725 segment and return. 3727 If the FIN bit is set, signal the user "connection closing" 3728 and return any pending RECEIVEs with same message, advance 3729 RCV.NXT over the FIN, and send an acknowledgment for the 3730 FIN. Note that FIN implies PUSH for any segment text not 3731 yet delivered to the user. 3733 SYN-RECEIVED STATE 3734 ESTABLISHED STATE 3736 Enter the CLOSE-WAIT state. 3738 FIN-WAIT-1 STATE 3740 If our FIN has been ACKed (perhaps in this segment), 3741 then enter TIME-WAIT, start the time-wait timer, turn 3742 off the other timers; otherwise enter the CLOSING 3743 state. 3745 FIN-WAIT-2 STATE 3747 Enter the TIME-WAIT state. Start the time-wait timer, 3748 turn off the other timers. 3750 CLOSE-WAIT STATE 3752 Remain in the CLOSE-WAIT state. 3754 CLOSING STATE 3756 Remain in the CLOSING state. 3758 LAST-ACK STATE 3760 Remain in the LAST-ACK state. 3762 TIME-WAIT STATE 3764 Remain in the TIME-WAIT state. Restart the 2 MSL 3765 time-wait timeout. 3767 and return. 3769 USER TIMEOUT 3771 USER TIMEOUT 3773 For any state if the user timeout expires, flush all queues, 3774 signal the user "error: connection aborted due to user timeout" 3775 in general and for any outstanding calls, delete the TCB, enter 3776 the CLOSED state and return. 3778 RETRANSMISSION TIMEOUT 3780 For any state if the retransmission timeout expires on a 3781 segment in the retransmission queue, send the segment at the 3782 front of the retransmission queue again, reinitialize the 3783 retransmission timer, and return. 3785 TIME-WAIT TIMEOUT 3787 If the time-wait timeout expires on a connection delete the 3788 TCB, enter the CLOSED state and return. 3790 3.11. Glossary 3792 ACK 3793 A control bit (acknowledge) occupying no sequence space, 3794 which indicates that the acknowledgment field of this segment 3795 specifies the next sequence number the sender of this segment 3796 is expecting to receive, hence acknowledging receipt of all 3797 previous sequence numbers. 3799 connection 3800 A logical communication path identified by a pair of sockets. 3802 datagram 3803 A message sent in a packet switched computer communications 3804 network. 3806 Destination Address 3807 The network layer address of the remote endpoint. 3809 FIN 3810 A control bit (finis) occupying one sequence number, which 3811 indicates that the sender will send no more data or control 3812 occupying sequence space. 3814 fragment 3815 A portion of a logical unit of data, in particular an 3816 internet fragment is a portion of an internet datagram. 3818 header 3819 Control information at the beginning of a message, segment, 3820 fragment, packet or block of data. 3822 host 3823 A computer. In particular a source or destination of 3824 messages from the point of view of the communication network. 3826 Identification 3827 An Internet Protocol field. This identifying value assigned 3828 by the sender aids in assembling the fragments of a datagram. 3830 internet address 3831 A network layer address. 3833 internet datagram 3834 The unit of data exchanged between an internet module and the 3835 higher level protocol together with the internet header. 3837 internet fragment 3838 A portion of the data of an internet datagram with an 3839 internet header. 3841 IP 3842 Internet Protocol. See [1] and [12]. 3844 IRS 3845 The Initial Receive Sequence number. The first sequence 3846 number used by the sender on a connection. 3848 ISN 3849 The Initial Sequence Number. The first sequence number used 3850 on a connection, (either ISS or IRS). Selected in a way that 3851 is unique within a given period of time and is unpredictable 3852 to attackers. 3854 ISS 3855 The Initial Send Sequence number. The first sequence number 3856 used by the sender on a connection. 3858 left sequence 3859 This is the next sequence number to be acknowledged by the 3860 data receiving TCP endpoint (or the lowest currently 3861 unacknowledged sequence number) and is sometimes referred to 3862 as the left edge of the send window. 3864 module 3865 An implementation, usually in software, of a protocol or 3866 other procedure. 3868 MSL 3869 Maximum Segment Lifetime, the time a TCP segment can exist in 3870 the internetwork system. Arbitrarily defined to be 2 3871 minutes. 3873 octet 3874 An eight bit byte. 3876 Options 3877 An Option field may contain several options, and each option 3878 may be several octets in length. 3880 packet 3881 A package of data with a header that may or may not be 3882 logically complete. More often a physical packaging than a 3883 logical packaging of data. 3885 port 3886 The portion of a connection identifier used for 3887 demultiplexing connections at an endpoint. 3889 process 3890 A program in execution. A source or destination of data from 3891 the point of view of the TCP endpoint or other host-to-host 3892 protocol. 3894 PUSH 3895 A control bit occupying no sequence space, indicating that 3896 this segment contains data that must be pushed through to the 3897 receiving user. 3899 RCV.NXT 3900 receive next sequence number 3902 RCV.UP 3903 receive urgent pointer 3905 RCV.WND 3906 receive window 3908 receive next sequence number 3909 This is the next sequence number the local TCP endpoint is 3910 expecting to receive. 3912 receive window 3913 This represents the sequence numbers the local (receiving) 3914 TCP endpoint is willing to receive. Thus, the local TCP 3915 endpoint considers that segments overlapping the range 3916 RCV.NXT to RCV.NXT + RCV.WND - 1 carry acceptable data or 3917 control. Segments containing sequence numbers entirely 3918 outside of this range are considered duplicates and 3919 discarded. 3921 RST 3922 A control bit (reset), occupying no sequence space, 3923 indicating that the receiver should delete the connection 3924 without further interaction. The receiver can determine, 3925 based on the sequence number and acknowledgment fields of the 3926 incoming segment, whether it should honor the reset command 3927 or ignore it. In no case does receipt of a segment 3928 containing RST give rise to a RST in response. 3930 SEG.ACK 3931 segment acknowledgment 3933 SEG.LEN 3934 segment length 3936 SEG.SEQ 3937 segment sequence 3939 SEG.UP 3940 segment urgent pointer field 3942 SEG.WND 3943 segment window field 3945 segment 3946 A logical unit of data, in particular a TCP segment is the 3947 unit of data transferred between a pair of TCP modules. 3949 segment acknowledgment 3950 The sequence number in the acknowledgment field of the 3951 arriving segment. 3953 segment length 3954 The amount of sequence number space occupied by a segment, 3955 including any controls that occupy sequence space. 3957 segment sequence 3958 The number in the sequence field of the arriving segment. 3960 send sequence 3961 This is the next sequence number the local (sending) TCP 3962 endpoint will use on the connection. It is initially 3963 selected from an initial sequence number curve (ISN) and is 3964 incremented for each octet of data or sequenced control 3965 transmitted. 3967 send window 3968 This represents the sequence numbers that the remote 3969 (receiving) TCP endpoint is willing to receive. It is the 3970 value of the window field specified in segments from the 3971 remote (data receiving) TCP endpoint. The range of new 3972 sequence numbers that may be emitted by a TCP implementation 3973 lies between SND.NXT and SND.UNA + SND.WND - 1. 3974 (Retransmissions of sequence numbers between SND.UNA and 3975 SND.NXT are expected, of course.) 3977 SND.NXT 3978 send sequence 3980 SND.UNA 3981 left sequence 3983 SND.UP 3984 send urgent pointer 3986 SND.WL1 3987 segment sequence number at last window update 3989 SND.WL2 3990 segment acknowledgment number at last window update 3992 SND.WND 3993 send window 3995 socket (or socket number, or socket address, or socket identifier) 3996 An address that specifically includes a port identifier, that 3997 is, the concatenation of an Internet Address with a TCP port. 3999 Source Address 4000 The network layer address of the sending endpoint. 4002 SYN 4003 A control bit in the incoming segment, occupying one sequence 4004 number, used at the initiation of a connection, to indicate 4005 where the sequence numbering will start. 4007 TCB 4008 Transmission control block, the data structure that records 4009 the state of a connection. 4011 TCP 4012 Transmission Control Protocol: A host-to-host protocol for 4013 reliable communication in internetwork environments. 4015 TOS 4016 Type of Service, an obsoleted IPv4 field. The same header 4017 bits currently are used for the Differentiated Services field 4018 [4] containing the Differentiated Services Code Point (DSCP) 4019 value and the 2-bit ECN codepoint [7]. 4021 Type of Service 4022 An Internet Protocol field that indicates the type of service 4023 for this internet fragment. 4025 URG 4026 A control bit (urgent), occupying no sequence space, used to 4027 indicate that the receiving user should be notified to do 4028 urgent processing as long as there is data to be consumed 4029 with sequence numbers less than the value indicated in the 4030 urgent pointer. 4032 urgent pointer 4033 A control field meaningful only when the URG bit is on. This 4034 field communicates the value of the urgent pointer that 4035 indicates the data octet associated with the sending user's 4036 urgent call. 4038 4. Changes from RFC 793 4040 This document obsoletes RFC 793 as well as RFC 6093 and 6528, which 4041 updated 793. In all cases, only the normative protocol specification 4042 and requirements have been incorporated into this document, and some 4043 informational text with background and rationale may not have been 4044 carried in. The informational content of those documents is still 4045 valuable in learning about and understanding TCP, and they are valid 4046 Informational references, even though their normative content has 4047 been incorporated into this document. 4049 The main body of this document was adapted from RFC 793's Section 3, 4050 titled "FUNCTIONAL SPECIFICATION", with an attempt to keep formatting 4051 and layout as close as possible. 4053 The collection of applicable RFC Errata that have been reported and 4054 either accepted or held for an update to RFC 793 were incorporated 4055 (Errata IDs: 573, 574, 700, 701, 1283, 1561, 1562, 1564, 1565, 1571, 4056 1572, 2296, 2297, 2298, 2748, 2749, 2934, 3213, 3300, 3301, 6222). 4057 Some errata were not applicable due to other changes (Errata IDs: 4058 572, 575, 1569, 3305, 3602). 4060 Changes to the specification of the Urgent Pointer described in RFC 4061 1122 and 6093 were incorporated. See RFC 6093 for detailed 4062 discussion of why these changes were necessary. 4064 The discussion of the RTO from RFC 793 was updated to refer to RFC 4065 6298. The RFC 1122 text on the RTO originally replaced the 793 text, 4066 however, RFC 2988 should have updated 1122, and has subsequently been 4067 obsoleted by 6298. 4069 RFC 1122 contains a collection of other changes and clarifications to 4070 RFC 793. The normative items impacting the protocol have been 4071 incorporated here, though some historically useful implementation 4072 advice and informative discussion from RFC 1122 is not included here. 4074 RFC 1122 contains more than just TCP requirements, so this document 4075 can't obsolete RFC 1122 entirely. It is only marked as "updating" 4076 1122, however, it should be understood to effectively obsolete all of 4077 the RFC 1122 material on TCP. 4079 The more secure Initial Sequence Number generation algorithm from RFC 4080 6528 was incorporated. See RFC 6528 for discussion of the attacks 4081 that this mitigates, as well as advice on selecting PRF algorithms 4082 and managing secret key data. 4084 A note based on RFC 6429 was added to explicitly clarify that system 4085 resource management concerns allow connection resources to be 4086 reclaimed. RFC 6429 is obsoleted in the sense that this 4087 clarification has been reflected in this update to the base TCP 4088 specification now. 4090 The description of congestion control implementation was added, based 4091 on the set of documents that are IETF BCP or Standards Track on the 4092 topic, and the current state of common implementations. 4094 RFC EDITOR'S NOTE: the content below is for detailed change tracking 4095 and planning, and not to be included with the final revision of the 4096 document. 4098 This document started as draft-eddy-rfc793bis-00, that was merely a 4099 proposal and rough plan for updating RFC 793. 4101 The -01 revision of this draft-eddy-rfc793bis incorporates the 4102 content of RFC 793 Section 3 titled "FUNCTIONAL SPECIFICATION". 4103 Other content from RFC 793 has not been incorporated. The -01 4104 revision of this document makes some minor formatting changes to the 4105 RFC 793 content in order to convert the content into XML2RFC format 4106 and account for left-out parts of RFC 793. For instance, figure 4107 numbering differs and some indentation is not exactly the same. 4109 The -02 revision of draft-eddy-rfc793bis incorporates errata that 4110 have been verified: 4112 Errata ID 573: Reported by Bob Braden (note: This errata basically 4113 is just a reminder that RFC 1122 updates 793. Some of the 4114 associated changes are left pending to a separate revision that 4115 incorporates 1122. Bob's mention of PUSH in 793 section 2.8 was 4116 not applicable here because that section was not part of the 4117 "functional specification". Also the 1122 text on the 4118 retransmission timeout also has been updated by subsequent RFCs, 4119 so the change here deviates from Bob's suggestion to apply the 4120 1122 text.) 4121 Errata ID 574: Reported by Yin Shuming 4122 Errata ID 700: Reported by Yin Shuming 4123 Errata ID 701: Reported by Yin Shuming 4124 Errata ID 1283: Reported by Pei-chun Cheng 4125 Errata ID 1561: Reported by Constantin Hagemeier 4126 Errata ID 1562: Reported by Constantin Hagemeier 4127 Errata ID 1564: Reported by Constantin Hagemeier 4128 Errata ID 1565: Reported by Constantin Hagemeier 4129 Errata ID 1571: Reported by Constantin Hagemeier 4130 Errata ID 1572: Reported by Constantin Hagemeier 4131 Errata ID 2296: Reported by Vishwas Manral 4132 Errata ID 2297: Reported by Vishwas Manral 4133 Errata ID 2298: Reported by Vishwas Manral 4134 Errata ID 2748: Reported by Mykyta Yevstifeyev 4135 Errata ID 2749: Reported by Mykyta Yevstifeyev 4136 Errata ID 2934: Reported by Constantin Hagemeier 4137 Errata ID 3213: Reported by EugnJun Yi 4138 Errata ID 3300: Reported by Botong Huang 4139 Errata ID 3301: Reported by Botong Huang 4140 Errata ID 3305: Reported by Botong Huang 4141 Note: Some verified errata were not used in this update, as they 4142 relate to sections of RFC 793 elided from this document. These 4143 include Errata ID 572, 575, and 1569. 4144 Note: Errata ID 3602 was not applied in this revision as it is 4145 duplicative of the 1122 corrections. 4147 Not related to RFC 793 content, this revision also makes small tweaks 4148 to the introductory text, fixes indentation of the pseudo header 4149 diagram, and notes that the Security Considerations should also 4150 include privacy, when this section is written. 4152 The -03 revision of draft-eddy-rfc793bis revises all discussion of 4153 the urgent pointer in order to comply with RFC 6093, 1122, and 1011. 4154 Since 1122 held requirements on the urgent pointer, the full list of 4155 requirements was brought into an appendix of this document, so that 4156 it can be updated as-needed. 4158 The -04 revision of draft-eddy-rfc793bis includes the ISN generation 4159 changes from RFC 6528. 4161 The -05 revision of draft-eddy-rfc793bis incorporates MSS 4162 requirements and definitions from RFC 879, 1122, and 6691, as well as 4163 option-handling requirements from RFC 1122. 4165 The -00 revision of draft-ietf-tcpm-rfc793bis incorporates several 4166 additional clarifications and updates to the section on segmentation, 4167 many of which are based on feedback from Joe Touch improving from the 4168 initial text on this in the previous revision. 4170 The -01 revision incorporates the change to Reserved bits due to ECN, 4171 as well as many other changes that come from RFC 1122. 4173 The -02 revision has small formatting modifications in order to 4174 address xml2rfc warnings about long lines. It was a quick update to 4175 avoid document expiration. TCPM working group discussion in 2015 4176 also indicated that that we should not try to add sections on 4177 implementation advice or similar non-normative information. 4179 The -03 revision incorporates more content from RFC 1122: Passive 4180 OPEN Calls, Time-To-Live, Multihoming, IP Options, ICMP messages, 4181 Data Communications, When to Send Data, When to Send a Window Update, 4182 Managing the Window, Probing Zero Windows, When to Send an ACK 4183 Segment. The section on data communications was re-organized into 4184 clearer subsections (previously headings were embedded in the 793 4185 text), and windows management advice from 793 was removed (as 4186 reviewed by TCPM working group) in favor of the 1122 additions on 4187 SWS, ZWP, and related topics. 4189 The -04 revision includes reference to RFC 6429 on the ZWP condition, 4190 RFC1122 material on TCP Connection Failures, TCP Keep-Alives, 4191 Acknowledging Queued Segments, and Remote Address Validation. RTO 4192 computation is referenced from RFC 6298 rather than RFC 1122. 4194 The -05 revision includes the requirement to implement TCP congestion 4195 control with recommendation to implement ECN, the RFC 6633 update to 4196 1122, which changed the requirement on responding to source quench 4197 ICMP messages, and discussion of ICMP (and ICMPv6) soft and hard 4198 errors per RFC 5461 (ICMPv6 handling for TCP doesn't seem to be 4199 mentioned elsewhere in standards track). 4201 The -06 revision includes an appendix on "Other Implementation Notes" 4202 to capture widely-deployed fundamental features that are not 4203 contained in the RFC series yet. It also added mention of RFC 6994 4204 and the IANA TCP parameters registry as a reference. It includes 4205 references to RFC 5961 in appropriate places. The references to TOS 4206 were changed to DiffServ field, based on reflecting RFC 2474 as well 4207 as the IPv6 presence of traffic class (carrying DiffServ field) 4208 rather than TOS. 4210 The -07 revision includes reference to RFC 6191, updated security 4211 considerations, discussion of additional implementation 4212 considerations, and clarification of data on the SYN. 4214 The -08 revision includes changes based on: 4216 describing treatment of reserved bits (following TCPM mailing list 4217 thread from July 2014 on "793bis item - reserved bit behavior" 4218 addition a brief TCP key concepts section to make up for not 4219 including the outdated section 2 of RFC 793 4220 changed "TCP" to "host" to resolve conflict between 1122 wording 4221 on whether TCP or the network layer chooses an address when 4222 multihomed 4223 fixed/updated definition of options in glossary 4224 moved note on aggregating ACKs from 1122 to a more appropriate 4225 location 4226 resolved notes on IP precedence and security/compartment 4227 added implementation note on sequence number validation 4228 added note that PUSH does not apply when Nagle is active 4229 added 1122 content on asynchronous reports to replace 793 section 4230 on TCP to user messages 4232 The -09 revision fixes section numbering problems. 4234 The -10 revision includes additions to the security considerations 4235 based on comments from Joe Touch, and suggested edits on RST/FIN 4236 notification, RFC 2525 reference, and other edits suggested by 4237 Yuchung Cheng, as well as modifications to DiffServ text from Yuchung 4238 Cheng and Gorry Fairhurst. 4240 The -11 revision includes a start at identifying all of the 4241 requirements text and referencing each instance in the common table 4242 at the end of the document. 4244 The -12 revision completes the requirement language indexing started 4245 in -11 and adds necessary description of the PUSH functionality that 4246 was missing. 4248 The -13 revision contains only changes in the inline editor notes. 4250 The -14 revision includes updates with regard to several comments 4251 from the mailing list, including editorial fixes, adding IANA 4252 considerations for the header flags, improving figure title 4253 placement, and breaking up the "Terminology" section into more 4254 appropriately titled subsections. 4256 The -15 revision has many technical and editorial corrections from 4257 Gorry Fairhurst's review, and subsequent discussion on the TCPM list, 4258 as well as some other collected clarifications and improvements from 4259 mailing list discussion. 4261 The -16 revision addresses several discussions that rose from 4262 additional reviews and follow-up on some of Gorry Fairhurst's 4263 comments from revision 14. 4265 The -17 revision includes errata 6222 from Charles Deng, update to 4266 the key words boilerplate, updated description of the header flags 4267 registry changes, and clarification about connections rather than 4268 users in the discussion of OPEN calls. 4270 The -18 revision includes editorial changes to the IANA 4271 considerations, based on comments from Richard Scheffenegger at the 4272 IETF 108 TCPM virtual meeting. 4274 The -19 revision includes editorial changes from Errata 6281 and 6282 4275 reported by Merlin Buge. It also includes WGLC changes noted by 4276 Mohamed Boucadair, Rahul Jadhav, Praveen Balasubramanian, Matt Olson, 4277 Yi Huang, Joe Touch, and Juhamatti Kuusisaari. 4279 The -20 revision includes text on congestion control based on mailing 4280 list and meeting discussion, put together in its final form by Markku 4281 Kojo. It also clarifies that SACK, WS, and TS options are 4282 recommended for high performance, but not needed for basic 4283 interoperability. It also clarifies that the length field is 4284 required for new TCP options. 4286 The -21 revision includes slight changes to the header diagram for 4287 compatibility with tooling, from Stephen McQuistin, clarification on 4288 the meaning of idle connections from Yuchung Cheng, Neal Cardwell, 4289 Michael Scharf, and Richard Scheffenegger, editorial improvements 4290 from Markku Kojo, notes that some stacks suppress extra 4291 acknowledgments of the SYN when SYN-ACK carries data from Richard 4292 Scheffenegger, and adds MAY-18 numbering based on note from Jonathan 4293 Morton. 4295 The -22 revision includes small clarifications on terminology (might 4296 versus may) and IPv6 extension headers versus IPv4 options, based on 4297 comments from Gorry Fairhurst. 4299 The -23 revision has a fix to indentation from Michael Tuexen and 4300 idnits issues addressed from Michael Scharf. 4302 Some other suggested changes that will not be incorporated in this 4303 793 update unless TCPM consensus changes with regard to scope are: 4305 1. Tony Sabatini's suggestion for describing DO field 4306 2. Per discussion with Joe Touch (TAPS list, 6/20/2015), the 4307 description of the API could be revisited 4308 3. Reducing the R2 value for SYNs has been suggested as a possible 4309 topic for future consideration. 4311 Early in the process of updating RFC 793, Scott Brim mentioned that 4312 this should include a PERPASS/privacy review. This may be something 4313 for the chairs or AD to request during WGLC or IETF LC. 4315 5. IANA Considerations 4317 In the "Transmission Control Protocol (TCP) Header Flags" registry, 4318 IANA is asked to make several changes described in this section. 4320 RFC 3168 originally created this registry, but only populated it with 4321 the new bits defined in RFC 3168, neglecting the other bits that had 4322 previously been described in RFC 793 and other documents. Bit 7 has 4323 since also been updated by RFC 8311. 4325 The "Bit" column is renamed below as the "Bit Offset" column, since 4326 it references each header flag's offset within the 16-bit aligned 4327 view of the TCP header in Figure 1. The bits in offsets 0 through 4 4328 are the TCP segment Data Offset field, and not header flags. 4330 IANA should add a column for "Assignment Notes". 4332 IANA should assign values indicated below. 4334 TCP Header Flags 4336 Bit Name Reference Assignment Notes 4337 Offset 4338 --- ---- --------- ---------------- 4339 4 Reserved for future use (this document) 4340 5 Reserved for future use (this document) 4341 6 Reserved for future use (this document) 4342 7 Reserved for future use [RFC8311] Previously used by Historic [RFC3540] as NS (Nonce Sum) 4343 8 CWR (Congestion Window Reduced) [RFC3168] 4344 9 ECE (ECN-Echo) [RFC3168] 4345 10 Urgent Pointer field significant (URG) (this document) 4346 11 Acknowledgment field significant (ACK) (this document) 4347 12 Push Function (PSH) (this document) 4348 13 Reset the connection (RST) (this document) 4349 14 Synchronize sequence numbers (SYN) (this document) 4350 15 No more data from sender (FIN) (this document) 4352 This TCP Header Flags registry should also be moved to a sub-registry 4353 under the global "Transmission Control Protocol (TCP) Parameters 4354 registry (https://www.iana.org/assignments/tcp-parameters/tcp- 4355 parameters.xhtml). 4357 The registry's Registration Procedure should remain Standards Action, 4358 but the Reference can be updated to this document, and the Note 4359 removed. 4361 6. Security and Privacy Considerations 4363 The TCP design includes only rudimentary security features that 4364 improve the robustness and reliability of connections and application 4365 data transfer, but there are no built-in cryptographic capabilities 4366 to support any form of privacy, authentication, or other typical 4367 security functions. Non-cryptographic enhancements (e.g. [37]) have 4368 been developed to improve robustness of TCP connections to particular 4369 types of attacks, but the applicability and protections of non- 4370 cryptographic enhancements are limited (e.g. see section 1.1 of 4371 [37]). Applications typically utilize lower-layer (e.g. IPsec) and 4372 upper-layer (e.g. TLS) protocols to provide security and privacy for 4373 TCP connections and application data carried in TCP. Methods based 4374 on TCP options have been developed as well, to support some security 4375 capabilities. 4377 In order to fully protect TCP connections (including their control 4378 flags) IPsec or the TCP Authentication Option (TCP-AO) [36] are the 4379 only current effective methods. Other methods discussed in this 4380 section may protect the payload, but either only a subset of the 4381 fields (e.g. tcpcrypt [54]) or none at all (e.g. TLS). Other 4382 security features that have been added to TCP (e.g. ISN generation, 4383 sequence number checks, and others) are only capable of partially 4384 hindering attacks. 4386 Applications using long-lived TCP flows have been vulnerable to 4387 attacks that exploit the processing of control flags described in 4388 earlier TCP specifications [30]. TCP-MD5 was a commonly implemented 4389 TCP option to support authentication for some of these connections, 4390 but had flaws and is now deprecated. TCP-AO provides a capability to 4391 protect long-lived TCP connections from attacks, and has superior 4392 properties to TCP-MD5. It does not provide any privacy for 4393 application data, nor for the TCP headers. 4395 The "tcpcrypt" [54] Experimental extension to TCP provides the 4396 ability to cryptographically protect connection data. Metadata 4397 aspects of the TCP flow are still visible, but the application stream 4398 is well-protected. Within the TCP header, only the urgent pointer 4399 and FIN flag are protected through tcpcrypt. 4401 The TCP Roadmap [48] includes notes about several RFCs related to TCP 4402 security. Many of the enhancements provided by these RFCs have been 4403 integrated into the present document, including ISN generation, 4404 mitigating blind in-window attacks, and improving handling of soft 4405 errors and ICMP packets. These are all discussed in greater detail 4406 in the referenced RFCs that originally described the changes needed 4407 to earlier TCP specifications. Additionally, see RFC 6093 [38] for 4408 discussion of security considerations related to the urgent pointer 4409 field, that has been deprecated. 4411 Since TCP is often used for bulk transfer flows, some attacks are 4412 possible that abuse the TCP congestion control logic. An example is 4413 "ACK-division" attacks. Updates that have been made to the TCP 4414 congestion control specifications include mechanisms like Appropriate 4415 Byte Counting (ABC) [26] that act as mitigations to these attacks. 4417 Other attacks are focused on exhausting the resources of a TCP 4418 server. Examples include SYN flooding [29] or wasting resources on 4419 non-progressing connections [40]. Operating systems commonly 4420 implement mitigations for these attacks. Some common defenses also 4421 utilize proxies, stateful firewalls, and other technologies outside 4422 of the end-host TCP implementation. 4424 7. Acknowledgements 4426 This document is largely a revision of RFC 793, which Jon Postel was 4427 the editor of. Due to his excellent work, it was able to last for 4428 three decades before we felt the need to revise it. 4430 Andre Oppermann was a contributor and helped to edit the first 4431 revision of this document. 4433 We are thankful for the assistance of the IETF TCPM working group 4434 chairs, over the course of work on this document: 4436 Michael Scharf 4437 Yoshifumi Nishida 4438 Pasi Sarolahti 4439 Michael Tuexen 4441 During the discussions of this work on the TCPM mailing list and in 4442 working group meetings, helpful comments, critiques, and reviews were 4443 received from (listed alphabetically by last name): Praveen 4444 Balasubramanian, David Borman, Mohamed Boucadair, Bob Briscoe, Neal 4445 Cardwell, Yuchung Cheng, Martin Duke, Ted Faber, Gorry Fairhurst, 4446 Fernando Gont, Rodney Grimes, Yi Huang, Rahul Jadhav, Markku Kojo, 4447 Mike Kosek, Juhamatti Kuusisaari, Kevin Lahey, Kevin Mason, Matt 4448 Mathis, Stephen McQuistin, Jonathan Morton, Matt Olson, Tommy Pauly, 4449 Tom Petch, Hagen Paul Pfeifer, Anthony Sabatini, Michael Scharf, Greg 4450 Skinner, Joe Touch, Michael Tuexen, Reji Varghese, Tim Wicinski, 4451 Lloyd Wood, and Alex Zimmermann. 4453 Joe Touch provided additional help in clarifying the description of 4454 segment size parameters and PMTUD/PLPMTUD recommendations. Markku 4455 Kojo helped put together the text in the section on TCP Congestion 4456 Control. 4458 This document includes content from errata that were reported by 4459 (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, 4460 Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta 4461 Yevstifeyev, EungJun Yi, Botong Huang, Charles Deng, Merlin Buge. 4463 8. References 4465 8.1. Normative References 4467 [1] Postel, J., "Internet Protocol", STD 5, RFC 791, 4468 DOI 10.17487/RFC0791, September 1981, 4469 . 4471 [2] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 4472 DOI 10.17487/RFC1191, November 1990, 4473 . 4475 [3] Bradner, S., "Key words for use in RFCs to Indicate 4476 Requirement Levels", BCP 14, RFC 2119, 4477 DOI 10.17487/RFC2119, March 1997, 4478 . 4480 [4] Nichols, K., Blake, S., Baker, F., and D. Black, 4481 "Definition of the Differentiated Services Field (DS 4482 Field) in the IPv4 and IPv6 Headers", RFC 2474, 4483 DOI 10.17487/RFC2474, December 1998, 4484 . 4486 [5] Borman, D., Deering, S., and R. Hinden, "IPv6 Jumbograms", 4487 RFC 2675, DOI 10.17487/RFC2675, August 1999, 4488 . 4490 [6] Floyd, S., "Congestion Control Principles", BCP 41, 4491 RFC 2914, DOI 10.17487/RFC2914, September 2000, 4492 . 4494 [7] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 4495 of Explicit Congestion Notification (ECN) to IP", 4496 RFC 3168, DOI 10.17487/RFC3168, September 2001, 4497 . 4499 [8] Floyd, S. and M. Allman, "Specifying New Congestion 4500 Control Algorithms", BCP 133, RFC 5033, 4501 DOI 10.17487/RFC5033, August 2007, 4502 . 4504 [9] Paxson, V., Allman, M., Chu, J., and M. Sargent, 4505 "Computing TCP's Retransmission Timer", RFC 6298, 4506 DOI 10.17487/RFC6298, June 2011, 4507 . 4509 [10] Gont, F., "Deprecation of ICMP Source Quench Messages", 4510 RFC 6633, DOI 10.17487/RFC6633, May 2012, 4511 . 4513 [11] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 4514 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 4515 May 2017, . 4517 [12] Deering, S. and R. Hinden, "Internet Protocol, Version 6 4518 (IPv6) Specification", STD 86, RFC 8200, 4519 DOI 10.17487/RFC8200, July 2017, 4520 . 4522 [13] McCann, J., Deering, S., Mogul, J., and R. Hinden, Ed., 4523 "Path MTU Discovery for IP version 6", STD 87, RFC 8201, 4524 DOI 10.17487/RFC8201, July 2017, 4525 . 4527 [14] Allman, M., "Requirements for Time-Based Loss Detection", 4528 BCP 233, RFC 8961, DOI 10.17487/RFC8961, November 2020, 4529 . 4531 8.2. Informative References 4533 [15] Postel, J., "Transmission Control Protocol", STD 7, 4534 RFC 793, DOI 10.17487/RFC0793, September 1981, 4535 . 4537 [16] Nagle, J., "Congestion Control in IP/TCP Internetworks", 4538 RFC 896, DOI 10.17487/RFC0896, January 1984, 4539 . 4541 [17] Braden, R., Ed., "Requirements for Internet Hosts - 4542 Communication Layers", STD 3, RFC 1122, 4543 DOI 10.17487/RFC1122, October 1989, 4544 . 4546 [18] Almquist, P., "Type of Service in the Internet Protocol 4547 Suite", RFC 1349, DOI 10.17487/RFC1349, July 1992, 4548 . 4550 [19] Braden, R., "T/TCP -- TCP Extensions for Transactions 4551 Functional Specification", RFC 1644, DOI 10.17487/RFC1644, 4552 July 1994, . 4554 [20] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 4555 Selective Acknowledgment Options", RFC 2018, 4556 DOI 10.17487/RFC2018, October 1996, 4557 . 4559 [21] Paxson, V., Allman, M., Dawson, S., Fenner, W., Griner, 4560 J., Heavens, I., Lahey, K., Semke, J., and B. Volz, "Known 4561 TCP Implementation Problems", RFC 2525, 4562 DOI 10.17487/RFC2525, March 1999, 4563 . 4565 [22] Xiao, X., Hannan, A., Paxson, V., and E. Crabbe, "TCP 4566 Processing of the IPv4 Precedence Field", RFC 2873, 4567 DOI 10.17487/RFC2873, June 2000, 4568 . 4570 [23] Floyd, S., Mahdavi, J., Mathis, M., and M. Podolsky, "An 4571 Extension to the Selective Acknowledgement (SACK) Option 4572 for TCP", RFC 2883, DOI 10.17487/RFC2883, July 2000, 4573 . 4575 [24] Lahey, K., "TCP Problems with Path MTU Discovery", 4576 RFC 2923, DOI 10.17487/RFC2923, September 2000, 4577 . 4579 [25] Balakrishnan, H., Padmanabhan, V., Fairhurst, G., and M. 4580 Sooriyabandara, "TCP Performance Implications of Network 4581 Path Asymmetry", BCP 69, RFC 3449, DOI 10.17487/RFC3449, 4582 December 2002, . 4584 [26] Allman, M., "TCP Congestion Control with Appropriate Byte 4585 Counting (ABC)", RFC 3465, DOI 10.17487/RFC3465, February 4586 2003, . 4588 [27] Fenner, B., "Experimental Values In IPv4, IPv6, ICMPv4, 4589 ICMPv6, UDP, and TCP Headers", RFC 4727, 4590 DOI 10.17487/RFC4727, November 2006, 4591 . 4593 [28] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 4594 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 4595 . 4597 [29] Eddy, W., "TCP SYN Flooding Attacks and Common 4598 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 4599 . 4601 [30] Touch, J., "Defending TCP Against Spoofing Attacks", 4602 RFC 4953, DOI 10.17487/RFC4953, July 2007, 4603 . 4605 [31] Culley, P., Elzur, U., Recio, R., Bailey, S., and J. 4606 Carrier, "Marker PDU Aligned Framing for TCP 4607 Specification", RFC 5044, DOI 10.17487/RFC5044, October 4608 2007, . 4610 [32] Gont, F., "TCP's Reaction to Soft Errors", RFC 5461, 4611 DOI 10.17487/RFC5461, February 2009, 4612 . 4614 [33] StJohns, M., Atkinson, R., and G. Thomas, "Common 4615 Architecture Label IPv6 Security Option (CALIPSO)", 4616 RFC 5570, DOI 10.17487/RFC5570, July 2009, 4617 . 4619 [34] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 4620 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 4621 . 4623 [35] Sandlund, K., Pelletier, G., and L-E. Jonsson, "The RObust 4624 Header Compression (ROHC) Framework", RFC 5795, 4625 DOI 10.17487/RFC5795, March 2010, 4626 . 4628 [36] Touch, J., Mankin, A., and R. Bonica, "The TCP 4629 Authentication Option", RFC 5925, DOI 10.17487/RFC5925, 4630 June 2010, . 4632 [37] Ramaiah, A., Stewart, R., and M. Dalal, "Improving TCP's 4633 Robustness to Blind In-Window Attacks", RFC 5961, 4634 DOI 10.17487/RFC5961, August 2010, 4635 . 4637 [38] Gont, F. and A. Yourtchenko, "On the Implementation of the 4638 TCP Urgent Mechanism", RFC 6093, DOI 10.17487/RFC6093, 4639 January 2011, . 4641 [39] Gont, F., "Reducing the TIME-WAIT State Using TCP 4642 Timestamps", BCP 159, RFC 6191, DOI 10.17487/RFC6191, 4643 April 2011, . 4645 [40] Bashyam, M., Jethanandani, M., and A. Ramaiah, "TCP Sender 4646 Clarification for Persist Condition", RFC 6429, 4647 DOI 10.17487/RFC6429, December 2011, 4648 . 4650 [41] Gont, F. and S. Bellovin, "Defending against Sequence 4651 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 4652 2012, . 4654 [42] Borman, D., "TCP Options and Maximum Segment Size (MSS)", 4655 RFC 6691, DOI 10.17487/RFC6691, July 2012, 4656 . 4658 [43] Touch, J., "Updated Specification of the IPv4 ID Field", 4659 RFC 6864, DOI 10.17487/RFC6864, February 2013, 4660 . 4662 [44] Touch, J., "Shared Use of Experimental TCP Options", 4663 RFC 6994, DOI 10.17487/RFC6994, August 2013, 4664 . 4666 [45] McPherson, D., Oran, D., Thaler, D., and E. Osterweil, 4667 "Architectural Considerations of IP Anycast", RFC 7094, 4668 DOI 10.17487/RFC7094, January 2014, 4669 . 4671 [46] Borman, D., Braden, B., Jacobson, V., and R. 4672 Scheffenegger, Ed., "TCP Extensions for High Performance", 4673 RFC 7323, DOI 10.17487/RFC7323, September 2014, 4674 . 4676 [47] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 4677 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 4678 . 4680 [48] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. 4681 Zimmermann, "A Roadmap for Transmission Control Protocol 4682 (TCP) Specification Documents", RFC 7414, 4683 DOI 10.17487/RFC7414, February 2015, 4684 . 4686 [49] Black, D., Ed. and P. Jones, "Differentiated Services 4687 (Diffserv) and Real-Time Communication", RFC 7657, 4688 DOI 10.17487/RFC7657, November 2015, 4689 . 4691 [50] Fairhurst, G. and M. Welzl, "The Benefits of Using 4692 Explicit Congestion Notification (ECN)", RFC 8087, 4693 DOI 10.17487/RFC8087, March 2017, 4694 . 4696 [51] Fairhurst, G., Ed., Trammell, B., Ed., and M. Kuehlewind, 4697 Ed., "Services Provided by IETF Transport Protocols and 4698 Congestion Control Mechanisms", RFC 8095, 4699 DOI 10.17487/RFC8095, March 2017, 4700 . 4702 [52] Welzl, M., Tuexen, M., and N. Khademi, "On the Usage of 4703 Transport Features Provided by IETF Transport Protocols", 4704 RFC 8303, DOI 10.17487/RFC8303, February 2018, 4705 . 4707 [53] Chown, T., Loughney, J., and T. Winters, "IPv6 Node 4708 Requirements", BCP 220, RFC 8504, DOI 10.17487/RFC8504, 4709 January 2019, . 4711 [54] Bittau, A., Giffin, D., Handley, M., Mazieres, D., Slack, 4712 Q., and E. Smith, "Cryptographic Protection of TCP Streams 4713 (tcpcrypt)", RFC 8548, DOI 10.17487/RFC8548, May 2019, 4714 . 4716 [55] Ford, A., Raiciu, C., Handley, M., Bonaventure, O., and C. 4717 Paasch, "TCP Extensions for Multipath Operation with 4718 Multiple Addresses", RFC 8684, DOI 10.17487/RFC8684, March 4719 2020, . 4721 [56] IANA, "Transmission Control Protocol (TCP) Parameters, 4722 https://www.iana.org/assignments/tcp-parameters/tcp- 4723 parameters.xhtml", 2019. 4725 [57] IANA, "Transmission Control Protocol (TCP) Header Flags, 4726 https://www.iana.org/assignments/tcp-header-flags/tcp- 4727 header-flags.xhtml", 2019. 4729 [58] Gont, F., "Processing of IP Security/Compartment and 4730 Precedence Information by TCP", draft-gont-tcpm-tcp- 4731 seccomp-prec-00 (work in progress), March 2012. 4733 [59] Gont, F. and D. Borman, "On the Validation of TCP Sequence 4734 Numbers", draft-gont-tcpm-tcp-seq-validation-04 (work in 4735 progress), March 2019. 4737 [60] Touch, J. and W. Eddy, "TCP Extended Data Offset Option", 4738 draft-ietf-tcpm-tcp-edo-10 (work in progress), July 2018. 4740 [61] McQuistin, S., Band, V., Jacob, D., and C. Perkins, 4741 "Describing Protocol Data Units with Augmented Packet 4742 Header Diagrams", draft-mcquistin-augmented-ascii- 4743 diagrams-08 (work in progress), May 2021. 4745 [62] Minshall, G., "A Proposed Modification to Nagle's 4746 Algorithm", draft-minshall-nagle-01 (work in progress), 4747 June 1999. 4749 [63] Dalal, Y. and C. Sunshine, "Connection Management in 4750 Transport Protocols", Computer Networks Vol. 2, No. 6, pp. 4751 454-473, December 1978. 4753 [64] Faber, T., Touch, J., and W. Yui, "The TIME-WAIT state in 4754 TCP and Its Effect on Busy Servers", Proceedings of IEEE 4755 INFOCOM pp. 1573-1583, March 1999. 4757 Appendix A. Other Implementation Notes 4759 This section includes additional notes and references on TCP 4760 implementation decisions that are currently not a part of the RFC 4761 series or included within the TCP standard. These items can be 4762 considered by implementers, but there was not yet a consensus to 4763 include them in the standard. 4765 A.1. IP Security Compartment and Precedence 4767 The IPv4 specification [1] includes a precedence value in the (now 4768 obsoleted) Type of Service field (TOS) field. It was modified in 4769 [18], and then obsoleted by the definition of Differentiated Services 4770 (DiffServ) [4]. Setting and conveying TOS between the network layer, 4771 TCP implementation, and applications is obsolete, and replaced by 4772 DiffServ in the current TCP specification. 4774 RFC 793 requires checking the IP security compartment and precedence 4775 on incoming TCP segments for consistency within a connection, and 4776 with application requests. Each of these aspects of IP have become 4777 outdated, without specific updates to RFC 793. The issues with 4778 precedence were fixed by [22], which is Standards Track, and so this 4779 present TCP specification includes those changes. However, the state 4780 of IP security options that may be used by MLS systems is not as 4781 clean. 4783 Resetting connections when incoming packets do not meet expected 4784 security compartment or precedence expectations has been recognized 4785 as a possible attack vector [58], and there has been discussion about 4786 amending the TCP specification to prevent connections from being 4787 aborted due to non-matching IP security compartment and DiffServ 4788 codepoint values. 4790 A.1.1. Precedence 4792 In DiffServ the former precedence values are treated as Class 4793 Selector codepoints, and methods for compatible treatment are 4794 described in the DiffServ architecture. The RFC 793/1122 TCP 4795 specification includes logic intending to have connections use the 4796 highest precedence requested by either endpoint application, and to 4797 keep the precedence consistent throughout a connection. This logic 4798 from the obsolete TOS is not applicable for DiffServ, and should not 4799 be included in TCP implementations, though changes to DiffServ values 4800 within a connection are discouraged. For discussion of this, see RFC 4801 7657 (sec 5.1, 5.3, and 6) [49]. 4803 The obsoleted TOS processing rules in TCP assumed bidirectional (or 4804 symmetric) precedence values used on a connection, but the DiffServ 4805 architecture is asymmetric. Problems with the old TCP logic in this 4806 regard were described in [22] and the solution described is to ignore 4807 IP precedence in TCP. Since RFC 2873 is a Standards Track document 4808 (although not marked as updating RFC 793), current implementations 4809 are expected to be robust to these conditions. Note that the 4810 DiffServ field value used in each direction is a part of the 4811 interface between TCP and the network layer, and values in use can be 4812 indicated both ways between TCP and the application. 4814 A.1.2. MLS Systems 4816 The IP security option (IPSO) and compartment defined in [1] was 4817 refined in RFC 1038 that was later obsoleted by RFC 1108. The 4818 Commercial IP Security Option (CIPSO) is defined in FIPS-188, and is 4819 supported by some vendors and operating systems. RFC 1108 is now 4820 Historic, though RFC 791 itself has not been updated to remove the IP 4821 security option. For IPv6, a similar option (CALIPSO) has been 4822 defined [33]. RFC 793 includes logic that includes the IP security/ 4823 compartment information in treatment of TCP segments. References to 4824 the IP "security/compartment" in this document may be relevant for 4825 Multi-Level Secure (MLS) system implementers, but can be ignored for 4826 non-MLS implementations, consistent with running code on the 4827 Internet. See Appendix A.1 for further discussion. Note that RFC 4828 5570 describes some MLS networking scenarios where IPSO, CIPSO, or 4829 CALIPSO may be used. In these special cases, TCP implementers should 4830 see section 7.3.1 of RFC 5570, and follow the guidance in that 4831 document. 4833 A.2. Sequence Number Validation 4835 There are cases where the TCP sequence number validation rules can 4836 prevent ACK fields from being processed. This can result in 4837 connection issues, as described in [59], which includes descriptions 4838 of potential problems in conditions of simultaneous open, self- 4839 connects, simultaneous close, and simultaneous window probes. The 4840 document also describes potential changes to the TCP specification to 4841 mitigate the issue by expanding the acceptable sequence numbers. 4843 In Internet usage of TCP, these conditions are rarely occurring. 4844 Common operating systems include different alternative mitigations, 4845 and the standard has not been updated yet to codify one of them, but 4846 implementers should consider the problems described in [59]. 4848 A.3. Nagle Modification 4850 In common operating systems, both the Nagle algorithm and delayed 4851 acknowledgements are implemented and enabled by default. TCP is used 4852 by many applications that have a request-response style of 4853 communication, where the combination of the Nagle algorithm and 4854 delayed acknowledgements can result in poor application performance. 4855 A modification to the Nagle algorithm is described in [62] that 4856 improves the situation for these applications. 4858 This modification is implemented in some common operating systems, 4859 and does not impact TCP interoperability. Additionally, many 4860 applications simply disable Nagle, since this is generally supported 4861 by a socket option. The TCP standard has not been updated to include 4862 this Nagle modification, but implementers may find it beneficial to 4863 consider. 4865 A.4. Low Water Mark Settings 4867 Some operating system kernel TCP implementations include socket 4868 options that allow specifying the number of bytes in the buffer until 4869 the socket layer will pass sent data to TCP (SO_SNDLOWAT) or to the 4870 application on receiving (SO_RCVLOWAT). 4872 In addition, another socket option (TCP_NOTSENT_LOWAT) can be used to 4873 control the amount of unsent bytes in the write queue. This can help 4874 a sending TCP application to avoid creating large amounts of buffered 4875 data (and corresponding latency). As an example, this may be useful 4876 for applications that are multiplexing data from multiple upper level 4877 streams onto a connection, especially when streams may be a mix of 4878 interactive / real-time and bulk data transfer. 4880 Appendix B. TCP Requirement Summary 4882 This section is adapted from RFC 1122. 4884 Note that there is no requirement related to PLPMTUD in this list, 4885 but that PLPMTUD is recommended. 4887 | | | | |S| | 4888 | | | | |H| |F 4889 | | | | |O|M|o 4890 | | |S| |U|U|o 4891 | | |H| |L|S|t 4892 | |M|O| |D|T|n 4893 | |U|U|M| | |o 4894 | |S|L|A|N|N|t 4895 | |T|D|Y|O|O|t 4896 FEATURE | ReqID | | | |T|T|e 4897 -------------------------------------------------|--------|-|-|-|-|-|-- 4898 | | | | | | | 4899 Push flag | | | | | | | 4900 Aggregate or queue un-pushed data | MAY-16 | | |x| | | 4901 Sender collapse successive PSH flags | SHLD-27| |x| | | | 4902 SEND call can specify PUSH | MAY-15 | | |x| | | 4903 If cannot: sender buffer indefinitely | MUST-60| | | | |x| 4904 If cannot: PSH last segment | MUST-61|x| | | | | 4905 Notify receiving ALP of PSH | MAY-17 | | |x| | |1 4906 Send max size segment when possible | SHLD-28| |x| | | | 4907 | | | | | | | 4908 Window | | | | | | | 4909 Treat as unsigned number | MUST-1 |x| | | | | 4910 Handle as 32-bit number | REC-1 | |x| | | | 4911 Shrink window from right | SHLD-14| | | |x| | 4912 - Send new data when window shrinks | SHLD-15| | | |x| | 4913 - Retransmit old unacked data within window | SHLD-16| |x| | | | 4914 - Time out conn for data past right edge | SHLD-17| | | |x| | 4915 Robust against shrinking window | MUST-34|x| | | | | 4916 Receiver's window closed indefinitely | MAY-8 | | |x| | | 4917 Use standard probing logic | MUST-35|x| | | | | 4918 Sender probe zero window | MUST-36|x| | | | | 4919 First probe after RTO | SHLD-29| |x| | | | 4920 Exponential backoff | SHLD-30| |x| | | | 4921 Allow window stay zero indefinitely | MUST-37|x| | | | | 4922 Retransmit old data beyond SND.UNA+SND.WND | MAY-7 | | |x| | | 4923 Process RST and URG even with zero window | MUST-66|x| | | | | 4924 | | | | | | | 4925 Urgent Data | | | | | | | 4926 Include support for urgent pointer | MUST-30|x| | | | | 4927 Pointer indicates first non-urgent octet | MUST-62|x| | | | | 4928 Arbitrary length urgent data sequence | MUST-31|x| | | | | 4929 Inform ALP asynchronously of urgent data | MUST-32|x| | | | |1 4930 ALP can learn if/how much urgent data Q'd | MUST-33|x| | | | |1 4931 ALP employ the urgent mechanism | SHLD-13| | | |x| | 4932 | | | | | | | 4933 TCP Options | | | | | | | 4934 Support the mandatory option set | MUST-4 |x| | | | | 4935 Receive TCP option in any segment | MUST-5 |x| | | | | 4936 Ignore unsupported options | MUST-6 |x| | | | | 4937 Include length for all options except EOL+NOP | MUST-68|x| | | | | 4938 Cope with illegal option length | MUST-7 |x| | | | | 4939 Process options regardless of word alignment | MUST-64|x| | | | | 4940 Implement sending & receiving MSS option | MUST-14|x| | | | | 4941 IPv4 Send MSS option unless 536 | SHLD-5 | |x| | | | 4942 IPv6 Send MSS option unless 1220 | SHLD-5 | |x| | | | 4943 Send MSS option always | MAY-3 | | |x| | | 4944 IPv4 Send-MSS default is 536 | MUST-15|x| | | | | 4945 IPv6 Send-MSS default is 1220 | MUST-15|x| | | | | 4946 Calculate effective send seg size | MUST-16|x| | | | | 4947 MSS accounts for varying MTU | SHLD-6 | |x| | | | 4948 MSS not sent on non-SYN segments | MUST-65| | | | |x| 4949 MSS value based on MMS_R | MUST-67|x| | | | | 4950 | | | | | | | 4951 TCP Checksums | | | | | | | 4952 Sender compute checksum | MUST-2 |x| | | | | 4953 Receiver check checksum | MUST-3 |x| | | | | 4954 | | | | | | | 4955 ISN Selection | | | | | | | 4956 Include a clock-driven ISN generator component | MUST-8 |x| | | | | 4957 Secure ISN generator with a PRF component | SHLD-1 | |x| | | | 4958 PRF computable from outside the host | MUST-9 | | | | |x| 4959 | | | | | | | 4960 Opening Connections | | | | | | | 4961 Support simultaneous open attempts | MUST-10|x| | | | | 4962 SYN-RECEIVED remembers last state | MUST-11|x| | | | | 4963 Passive Open call interfere with others | MUST-41| | | | |x| 4964 Function: simultan. LISTENs for same port | MUST-42|x| | | | | 4965 Ask IP for src address for SYN if necc. | MUST-44|x| | | | | 4966 Otherwise, use local addr of conn. | MUST-45|x| | | | | 4967 OPEN to broadcast/multicast IP Address | MUST-46| | | | |x| 4968 Silently discard seg to bcast/mcast addr | MUST-57|x| | | | | 4969 | | | | | | | 4970 Closing Connections | | | | | | | 4971 RST can contain data | SHLD-2 | |x| | | | 4972 Inform application of aborted conn | MUST-12|x| | | | | 4973 Half-duplex close connections | MAY-1 | | |x| | | 4974 Send RST to indicate data lost | SHLD-3 | |x| | | | 4976 In TIME-WAIT state for 2MSL seconds | MUST-13|x| | | | | 4977 Accept SYN from TIME-WAIT state | MAY-2 | | |x| | | 4978 Use Timestamps to reduce TIME-WAIT | SHLD-4 | |x| | | | 4979 | | | | | | | 4980 Retransmissions | | | | | | | 4981 Implement exponential backoff, slow start, and | MUST-19|x| | | | | 4982 congestion avoidance | | | | | | | 4983 Retransmit with same IP ident | MAY-4 | | |x| | | 4984 Karn's algorithm | MUST-18|x| | | | | 4985 | | | | | | | 4986 Generating ACKs: | | | | | | | 4987 Aggregate whenever possible | MUST-58|x| | | | | 4988 Queue out-of-order segments | SHLD-31| |x| | | | 4989 Process all Q'd before send ACK | MUST-59|x| | | | | 4990 Send ACK for out-of-order segment | MAY-13 | | |x| | | 4991 Delayed ACKs | SHLD-18| |x| | | | 4992 Delay < 0.5 seconds | MUST-40|x| | | | | 4993 Every 2nd full-sized segment ACK'd | SHLD-19|x| | | | | 4994 Receiver SWS-Avoidance Algorithm | MUST-39|x| | | | | 4995 | | | | | | | 4996 Sending data | | | | | | | 4997 Configurable TTL | MUST-49|x| | | | | 4998 Sender SWS-Avoidance Algorithm | MUST-38|x| | | | | 4999 Nagle algorithm | SHLD-7 | |x| | | | 5000 Application can disable Nagle algorithm | MUST-17|x| | | | | 5001 | | | | | | | 5002 Connection Failures: | | | | | | | 5003 Negative advice to IP on R1 retxs | MUST-20|x| | | | | 5004 Close connection on R2 retxs | MUST-20|x| | | | | 5005 ALP can set R2 | MUST-21|x| | | | |1 5006 Inform ALP of R1<=retxs inform ALP | SHLD-25| |x| | | | 5034 Dest. Unreach (0,1,5) => abort conn | MUST-56| | | | |x| 5035 Dest. Unreach (2-4) => abort conn | SHLD-26| |x| | | | 5036 Source Quench => silent discard | MUST-55|x| | | | | 5037 Time Exceeded => tell ALP, don't abort | MUST-56| | | | |x| 5038 Param Problem => tell ALP, don't abort | MUST-56| | | | |x| 5039 | | | | | | | 5040 Address Validation | | | | | | | 5041 Reject OPEN call to invalid IP address | MUST-46|x| | | | | 5042 Reject SYN from invalid IP address | MUST-63|x| | | | | 5043 Silently discard SYN to bcast/mcast addr | MUST-57|x| | | | | 5044 | | | | | | | 5045 TCP/ALP Interface Services | | | | | | | 5046 Error Report mechanism | MUST-47|x| | | | | 5047 ALP can disable Error Report Routine | SHLD-20| |x| | | | 5048 ALP can specify DiffServ field for sending | MUST-48|x| | | | | 5049 Passed unchanged to IP | SHLD-22| |x| | | | 5050 ALP can change DiffServ field during connection| SHLD-21| |x| | | | 5051 ALP generally changing DiffServ during conn. | SHLD-23| | | |x| | 5052 Pass received DiffServ field up to ALP | MAY-9 | | |x| | | 5053 FLUSH call | MAY-14 | | |x| | | 5054 Optional local IP addr parm. in OPEN | MUST-43|x| | | | | 5055 | | | | | | | 5056 RFC 5961 Support: | | | | | | | 5057 Implement data injection protection | MAY-12 | | |x| | | 5058 | | | | | | | 5059 Explicit Congestion Notification: | | | | | | | 5060 Support ECN | SHLD-8 | |x| | | | 5061 | | | | | | | 5062 Alternative Congestion Control: | | | | | | | 5063 Implement alternative conformant algorithm(s) | MAY-18 | | |x| | | 5064 -------------------------------------------------|--------|-|-|-|-|-|- 5066 FOOTNOTES: (1) "ALP" means Application-Layer Program. 5068 Author's Address 5070 Wesley M. Eddy (editor) 5071 MTI Systems 5072 US 5074 Email: wes@mti-systems.com