idnits 2.17.1 draft-ietf-tcpm-rfc793bis-18.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 (August 6, 2020) is 1330 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: 'RFC8311' on line 4167 -- Looks like a reference, but probably isn't: 'RFC3540' on line 4167 -- Looks like a reference, but probably isn't: 'RFC3168' on line 4169 ** Obsolete normative reference: RFC 1981 (ref. '3') (Obsoleted by RFC 8201) ** Downref: Normative reference to an Informational RFC: RFC 2923 (ref. '7') -- Obsolete informational reference (is this intentional?): RFC 793 (ref. '13') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 896 (ref. '14') (Obsoleted by RFC 7805) -- Obsolete informational reference (is this intentional?): RFC 1349 (ref. '16') (Obsoleted by RFC 2474) -- Obsolete informational reference (is this intentional?): RFC 1644 (ref. '17') (Obsoleted by RFC 6247) -- Obsolete informational reference (is this intentional?): RFC 2873 (ref. '19') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6093 (ref. '33') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6429 (ref. '35') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6528 (ref. '36') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6691 (ref. '37') (Obsoleted by RFC 9293) == Outdated reference: A later version (-04) exists of draft-gont-tcpm-tcp-seq-validation-02 == Outdated reference: A later version (-15) exists of draft-ietf-tcpinc-tcpcrypt-09 == Outdated reference: A later version (-13) exists of draft-ietf-tcpm-tcp-edo-10 Summary: 4 errors (**), 0 flaws (~~), 6 warnings (==), 18 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, August 6, 2020 5 6528, 6691 (if approved) 6 Updates: 5961, 1122 (if approved) 7 Intended status: Standards Track 8 Expires: February 7, 2021 10 Transmission Control Protocol Specification 11 draft-ietf-tcpm-rfc793bis-18 13 Abstract 15 This document specifies the Internet's Transmission Control Protocol 16 (TCP). TCP is an important transport layer protocol in the Internet 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 879, 2873, 6093, 6429, 23 6528, and 6691 that updated parts of RFC 793. It updates RFC 1122, 24 and should be considered as a replacement for the portions of that 25 document dealing with TCP requirements. It updates RFC 5961 due to a 26 small clarification in reset handling while in the SYN-RECEIVED 27 state. 29 RFC EDITOR NOTE: If approved for publication as an RFC, this should 30 be marked additionally as "STD: 7" and replace RFC 793 in that role. 32 Requirements Language 34 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 35 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 36 "OPTIONAL" in this document are to be interpreted as described in BCP 37 14 [4][11] when, and only when, they appear in all capitals, as shown 38 here. 40 Status of This Memo 42 This Internet-Draft is submitted in full conformance with the 43 provisions of BCP 78 and BCP 79. 45 Internet-Drafts are working documents of the Internet Engineering 46 Task Force (IETF). Note that other groups may also distribute 47 working documents as Internet-Drafts. The list of current Internet- 48 Drafts is at https://datatracker.ietf.org/drafts/current/. 50 Internet-Drafts are draft documents valid for a maximum of six months 51 and may be updated, replaced, or obsoleted by other documents at any 52 time. It is inappropriate to use Internet-Drafts as reference 53 material or to cite them other than as "work in progress." 55 This Internet-Draft will expire on February 7, 2021. 57 Copyright Notice 59 Copyright (c) 2020 IETF Trust and the persons identified as the 60 document authors. All rights reserved. 62 This document is subject to BCP 78 and the IETF Trust's Legal 63 Provisions Relating to IETF Documents 64 (https://trustee.ietf.org/license-info) in effect on the date of 65 publication of this document. Please review these documents 66 carefully, as they describe your rights and restrictions with respect 67 to this document. Code Components extracted from this document must 68 include Simplified BSD License text as described in Section 4.e of 69 the Trust Legal Provisions and are provided without warranty as 70 described in the Simplified BSD License. 72 This document may contain material from IETF Documents or IETF 73 Contributions published or made publicly available before November 74 10, 2008. The person(s) controlling the copyright in some of this 75 material may not have granted the IETF Trust the right to allow 76 modifications of such material outside the IETF Standards Process. 77 Without obtaining an adequate license from the person(s) controlling 78 the copyright in such materials, this document may not be modified 79 outside the IETF Standards Process, and derivative works of it may 80 not be created outside the IETF Standards Process, except to format 81 it for publication as an RFC or to translate it into languages other 82 than English. 84 Table of Contents 86 1. Purpose and Scope . . . . . . . . . . . . . . . . . . . . . . 3 87 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 88 2.1. Key TCP Concepts . . . . . . . . . . . . . . . . . . . . 5 89 3. Functional Specification . . . . . . . . . . . . . . . . . . 6 90 3.1. Header Format . . . . . . . . . . . . . . . . . . . . . . 6 91 3.2. Terminology Overview . . . . . . . . . . . . . . . . . . 11 92 3.2.1. Key Connection State Variables . . . . . . . . . . . 11 93 3.2.2. State Machine Overview . . . . . . . . . . . . . . . 13 94 3.3. Sequence Numbers . . . . . . . . . . . . . . . . . . . . 16 95 3.4. Establishing a connection . . . . . . . . . . . . . . . . 23 96 3.5. Closing a Connection . . . . . . . . . . . . . . . . . . 29 97 3.5.1. Half-Closed Connections . . . . . . . . . . . . . . . 32 99 3.6. Segmentation . . . . . . . . . . . . . . . . . . . . . . 32 100 3.6.1. Maximum Segment Size Option . . . . . . . . . . . . . 34 101 3.6.2. Path MTU Discovery . . . . . . . . . . . . . . . . . 35 102 3.6.3. Interfaces with Variable MTU Values . . . . . . . . . 36 103 3.6.4. Nagle Algorithm . . . . . . . . . . . . . . . . . . . 36 104 3.6.5. IPv6 Jumbograms . . . . . . . . . . . . . . . . . . . 37 105 3.7. Data Communication . . . . . . . . . . . . . . . . . . . 37 106 3.7.1. Retransmission Timeout . . . . . . . . . . . . . . . 38 107 3.7.2. TCP Congestion Control . . . . . . . . . . . . . . . 38 108 3.7.3. TCP Connection Failures . . . . . . . . . . . . . . . 38 109 3.7.4. TCP Keep-Alives . . . . . . . . . . . . . . . . . . . 39 110 3.7.5. The Communication of Urgent Information . . . . . . . 40 111 3.7.6. Managing the Window . . . . . . . . . . . . . . . . . 41 112 3.8. Interfaces . . . . . . . . . . . . . . . . . . . . . . . 46 113 3.8.1. User/TCP Interface . . . . . . . . . . . . . . . . . 46 114 3.8.2. TCP/Lower-Level Interface . . . . . . . . . . . . . . 55 115 3.9. Event Processing . . . . . . . . . . . . . . . . . . . . 57 116 3.10. Glossary . . . . . . . . . . . . . . . . . . . . . . . . 82 117 4. Changes from RFC 793 . . . . . . . . . . . . . . . . . . . . 87 118 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 92 119 6. Security and Privacy Considerations . . . . . . . . . . . . . 93 120 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 94 121 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 95 122 8.1. Normative References . . . . . . . . . . . . . . . . . . 95 123 8.2. Informative References . . . . . . . . . . . . . . . . . 96 124 Appendix A. Other Implementation Notes . . . . . . . . . . . . . 100 125 A.1. IP Security Compartment and Precedence . . . . . . . . . 100 126 A.1.1. Precedence . . . . . . . . . . . . . . . . . . . . . 101 127 A.1.2. MLS Systems . . . . . . . . . . . . . . . . . . . . . 101 128 A.2. Sequence Number Validation . . . . . . . . . . . . . . . 102 129 A.3. Nagle Modification . . . . . . . . . . . . . . . . . . . 102 130 A.4. Low Water Mark Settings . . . . . . . . . . . . . . . . . 102 131 Appendix B. TCP Requirement Summary . . . . . . . . . . . . . . 103 132 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 106 134 1. Purpose and Scope 136 In 1981, RFC 793 [13] was released, documenting the Transmission 137 Control Protocol (TCP), and replacing earlier specifications for TCP 138 that had been published in the past. 140 Since then, TCP has been implemented many times, and has been used as 141 a transport protocol for numerous applications on the Internet. 143 For several decades, RFC 793 plus a number of other documents have 144 combined to serve as the specification for TCP [42]. Over time, a 145 number of errata have been identified on RFC 793, as well as 146 deficiencies in security, performance, and other aspects. The number 147 of enhancements has grown over time across many separate documents. 148 These were never accumulated together into an update to the base 149 specification. 151 The purpose of this document is to bring together all of the IETF 152 Standards Track changes that have been made to the basic TCP 153 functional specification and unify them into an update of the RFC 793 154 protocol specification. Some companion documents are referenced for 155 important algorithms that TCP uses (e.g. for congestion control), but 156 have not been attempted to include in this document. This is a 157 conscious choice, as this base specification can be used with 158 multiple additional algorithms that are developed and incorporated 159 separately, but all TCP implementations need to implement this 160 specification as a common basis in order to interoperate. As some 161 additional TCP features have become quite complicated themselves 162 (e.g. advanced loss recovery and congestion control), future 163 companion documents may attempt to similarly bring these together. 165 In addition to the protocol specification that descibes the TCP 166 segment format, generation, and processing rules that are to be 167 implemented in code, RFC 793 and other updates also contain 168 informative and descriptive text for human readers to understand 169 aspects of the protocol design and operation. This document does not 170 attempt to alter or update this informative text, and is focused only 171 on updating the normative protocol specification. We preserve 172 references to the documentation containing the important explanations 173 and rationale, where appropriate. 175 This document is intended to be useful both in checking existing TCP 176 implementations for conformance, as well as in writing new 177 implementations. 179 2. Introduction 181 RFC 793 contains a discussion of the TCP design goals and provides 182 examples of its operation, including examples of connection 183 establishment, closing connections, and retransmitting packets to 184 repair losses. 186 This document describes the basic functionality expected in modern 187 implementations of TCP, and replaces the protocol specification in 188 RFC 793. It does not replicate or attempt to update the introduction 189 and philosophy content in RFC 793 (sections 1 and 2 of that 190 document). Other documents are referenced to provide explanation of 191 the theory of operation, rationale, and detailed discussion of design 192 decisions. This document only focuses on the normative behavior of 193 the protocol. 195 The "TCP Roadmap" [42] provides a more extensive guide to the RFCs 196 that define TCP and describe various important algorithms. The TCP 197 Roadmap contains sections on strongly encouraged enhancements that 198 improve performance and other aspects of TCP beyond the basic 199 operation specified in this document. As one example, implementing 200 congestion control (e.g. [29]) is a TCP requirement, but is a complex 201 topic on its own, and not described in detail in this document, as 202 there are many options and possibilities that do not impact basic 203 interoperability. Similarly, most common TCP implementations today 204 include the high-performance extensions in [40], but these are not 205 strictly required or discussed in this document. 207 A list of changes from RFC 793 is contained in Section 4. 209 Each use of RFC 2119 keywords in the document is individually labeled 210 and referenced in Appendix B that summarizes implementation 211 requirements. Sentences using "MUST" are labeled as "MUST-X" with X 212 being a numeric identifier enabling the requirement to be located 213 easily when referenced from Appendix B. Similarly, sentences using 214 "SHOULD" are labeled with "SHLD-X", "MAY" with "MAY-X", and 215 "RECOMMENDED" with "REC-X". For the purposes of this labeling, 216 "SHOULD NOT" and "MUST NOT" are labeled the same as "SHOULD" and 217 "MUST" instances. 219 2.1. Key TCP Concepts 221 TCP provides a reliable, in-order, byte-stream service to 222 applications. 224 The application byte-stream is conveyed over the network via TCP 225 segments, with each TCP segment sent as an Internet Protocol (IP) 226 datagram. 228 TCP reliability consists of detecting packet losses (via sequence 229 numbers) and errors (via per-segment checksums), as well as 230 correction via retransmission. 232 TCP supports unicast delivery of data. Anycast applications exist 233 that successfully use TCP without modifications, though there is some 234 risk of instability due to changes of lower-layer forwarding 235 behavior. 237 TCP is connection-oriented, though does not inherently include a 238 liveness detection capability. 240 Data flow is supported bidirectionally over TCP connections, though 241 applications are free to send data only unidirectionally, if they so 242 choose. 244 TCP uses port numbers to identify application services and to 245 multiplex multiple flows between hosts. 247 A more detailed description of TCP's features compared to other 248 transport protocols can be found in Section 3.1 of [45]. Further 249 description of the motivations for developing TCP and its role in the 250 Internet stack can be found in Section 2 of [13] and earlier versions 251 of the TCP specification. 253 3. Functional Specification 255 3.1. Header Format 257 TCP segments are sent as internet datagrams. The Internet Protocol 258 (IP) header carries several information fields, including the source 259 and destination host addresses [1] [12]. A TCP header follows the 260 Internet header, supplying information specific to the TCP protocol. 261 This division allows for the existence of host level protocols other 262 than TCP. In early development of the Internet suite of protocols, 263 the IP header fields had been a part of TCP. 265 0 1 2 3 266 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 267 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 268 | Source Port | Destination Port | 269 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 270 | Sequence Number | 271 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 272 | Acknowledgment Number | 273 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 274 | Data | |C|E|U|A|P|R|S|F| | 275 | Offset| Rsrvd |W|C|R|C|S|S|Y|I| Window | 276 | | |R|E|G|K|H|T|N|N| | 277 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 278 | Checksum | Urgent Pointer | 279 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 280 | Options | Padding | 281 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 282 | data | 283 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 285 Note that one tick mark represents one bit position. 287 Figure 1: TCP Header Format 289 Source Port: 16 bits 291 The source port number. 293 Destination Port: 16 bits 295 The destination port number. 297 Sequence Number: 32 bits 299 The sequence number of the first data octet in this segment (except 300 when SYN is present). If SYN is present the sequence number is the 301 initial sequence number (ISN) and the first data octet is ISN+1. 303 Acknowledgment Number: 32 bits 305 If the ACK control bit is set, this field contains the value of the 306 next sequence number the sender of the segment is expecting to 307 receive. Once a connection is established, this is always sent. 309 Data Offset: 4 bits 311 The number of 32 bit words in the TCP Header. This indicates where 312 the data begins. The TCP header (even one including options) is an 313 integral number of 32 bits long. 315 Rsrvd - Reserved: 4 bits 317 Reserved for future use. Must be zero in generated segments and 318 must be ignored in received segments, if corresponding future 319 features are unimplemented by the sending or receiving host. 321 Control Bits: 8 bits (from left to right): 323 CWR: Congestion Window Reduced (see [8]) 324 ECE: ECN-Echo (see [8]) 325 URG: Urgent Pointer field significant 326 ACK: Acknowledgment field significant 327 PSH: Push Function (see the Send Call description in 328 Section 3.8.1) 329 RST: Reset the connection 330 SYN: Synchronize sequence numbers 331 FIN: No more data from sender 333 The control bits are also know as "flags". Assignment is managed 334 by IANA from the "TCP Header Flags" registry [49]. 336 Window: 16 bits 338 The number of data octets beginning with the one indicated in the 339 acknowledgment field that the sender of this segment is willing to 340 accept. 342 The window size MUST be treated as an unsigned number, or else 343 large window sizes will appear like negative windows and TCP will 344 now work (MUST-1). It is RECOMMENDED that implementations will 345 reserve 32-bit fields for the send and receive window sizes in the 346 connection record and do all window computations with 32 bits (REC- 347 1). 349 Checksum: 16 bits 351 The checksum field is the 16 bit one's complement of the one's 352 complement sum of all 16 bit words in the header and text. The 353 checksum computation needs to ensure the 16-bit alignment of the 354 data being summed. If a segment contains an odd number of header 355 and text octets, alignment can be achieved by padding the last 356 octet with zeros on its right to form a 16 bit word for checksum 357 purposes. The pad is not transmitted as part of the segment. 358 While computing the checksum, the checksum field itself is replaced 359 with zeros. 361 The checksum also covers a pseudo header conceptually prefixed to 362 the TCP header. The pseudo header is 96 bits for IPv4 and 320 bits 363 for IPv6. For IPv4, this pseudo header contains the Source 364 Address, the Destination Address, the Protocol (PTCL), and TCP 365 length. This gives the TCP connection protection against misrouted 366 segments. This information is carried in IP headers and is 367 transferred across the TCP/Network interface in the arguments or 368 results of calls by the TCP implementation on the IP layer. 370 +--------+--------+--------+--------+ 371 | Source Address | 372 +--------+--------+--------+--------+ 373 | Destination Address | 374 +--------+--------+--------+--------+ 375 | zero | PTCL | TCP Length | 376 +--------+--------+--------+--------+ 378 Psuedo header components: 380 Source Address: the IPv4 source address in network byte order 382 Destination Address: the IPv4 destination address in network 383 byte order 385 zero: bits set to zero 387 PTCL: the protocol number from the IP header 388 TCP Length: the TCP header length plus the data length in octets 389 (this is not an explicitly transmitted quantity, but is 390 computed), and it does not count the 12 octets of the pseudo 391 header. 393 For IPv6, the pseudo header is contained in section 8.1 of RFC 8200 394 [12], and contains the IPv6 Source Address and Destination Address, 395 an Upper Layer Packet Length (a 32-bit value otherwise equivalent 396 to TCP Length in the IPv4 pseudo header), three bytes of zero- 397 padding, and a Next Header value (differing from the IPv6 header 398 value in the case of extension headers present in between IPv6 and 399 TCP). 401 The TCP checksum is never optional. The sender MUST generate it 402 (MUST-2) and the receiver MUST check it (MUST-3). 404 Urgent Pointer: 16 bits 406 This field communicates the current value of the urgent pointer as 407 a positive offset from the sequence number in this segment. The 408 urgent pointer points to the sequence number of the octet following 409 the urgent data. This field is only be interpreted in segments 410 with the URG control bit set. 412 Options: variable 414 Options may occupy space at the end of the TCP header and are a 415 multiple of 8 bits in length. All options are included in the 416 checksum. An option may begin on any octet boundary. There are 417 two cases for the format of an option: 419 Case 1: A single octet of option-kind. 421 Case 2: An octet of option-kind, an octet of option-length, and 422 the actual option-data octets. 424 The option-length counts the two octets of option-kind and option- 425 length as well as the option-data octets. 427 Note that the list of options may be shorter than the data offset 428 field might imply. The content of the header beyond the End-of- 429 Option option must be header padding (i.e., zero). 431 The list of all currently defined options is managed by IANA [48], 432 and each option is defined in other RFCs, as indicated there. That 433 set includes experimental options that can be extended to support 434 multiple concurrent usages [39]. 436 A given TCP implementation can support any currently defined 437 options, but the following options MUST be supported (MUST-4) (kind 438 indicated in octal): 440 Kind Length Meaning 441 ---- ------ ------- 442 0 - End of option list. 443 1 - No-Operation. 444 2 4 Maximum Segment Size. 446 A TCP implementation MUST be able to receive a TCP option in any 447 segment (MUST-5). 448 A TCP implementation MUST (MUST-6) ignore without error any TCP 449 option it does not implement, assuming that the option has a length 450 field (all TCP options except End of option list and No-Operation 451 have length fields). TCP implementations MUST be prepared to 452 handle an illegal option length (e.g., zero); a suggested procedure 453 is to reset the connection and log the reason (MUST-7). 455 Specific Option Definitions 457 End of Option List 459 +--------+ 460 |00000000| 461 +--------+ 462 Kind=0 464 This option code indicates the end of the option list. This 465 might not coincide with the end of the TCP header according to 466 the Data Offset field. This is used at the end of all options, 467 not the end of each option, and need only be used if the end of 468 the options would not otherwise coincide with the end of the TCP 469 header. 471 No-Operation 473 +--------+ 474 |00000001| 475 +--------+ 476 Kind=1 478 This option code can be used between options, for example, to 479 align the beginning of a subsequent option on a word boundary. 480 There is no guarantee that senders will use this option, so 481 receivers MUST be prepared to process options even if they do 482 not begin on a word boundary (MUST-64). 484 Maximum Segment Size (MSS) 486 +--------+--------+---------+--------+ 487 |00000010|00000100| max seg size | 488 +--------+--------+---------+--------+ 489 Kind=2 Length=4 491 Maximum Segment Size Option Data: 16 bits 493 If this option is present, then it communicates the maximum 494 receive segment size at the TCP endpoint that sends this 495 segment. This value is limited by the IP reassembly limit. 496 This field may be sent in the initial connection request (i.e., 497 in segments with the SYN control bit set) and MUST NOT be sent 498 in other segments (MUST-65). If this option is not used, any 499 segment size is allowed. A more complete description of this 500 option is in Section 3.6.1. 502 Experimental TCP option values are defined in [22], and [39] 503 describes the current recommended usage for these experimental 504 values. 506 Note: There is ongoing work to extend the space available for 507 TCP options, such as [53]. 509 Padding: variable 511 The TCP header padding is used to ensure that the TCP header ends 512 and data begins on a 32 bit boundary. The padding is composed of 513 zeros. 515 3.2. Terminology Overview 517 This section includes an overview of key terms needed to understand 518 the detailed protocol operation in the rest of the document. There 519 is a traditional glossary of terms in Section 3.10. 521 3.2.1. Key Connection State Variables 523 Before we can discuss very much about the operation of the TCP 524 implementation we need to introduce some detailed terminology. The 525 maintenance of a TCP connection requires the remembering of several 526 variables. We conceive of these variables being stored in a 527 connection record called a Transmission Control Block or TCB. Among 528 the variables stored in the TCB are the local and remote IP addresses 529 and port numbers, the IP security level and compartment of the 530 connection (see Appendix A.1), pointers to the user's send and 531 receive buffers, pointers to the retransmit queue and to the current 532 segment. In addition several variables relating to the send and 533 receive sequence numbers are stored in the TCB. 535 Send Sequence Variables 537 SND.UNA - send unacknowledged 538 SND.NXT - send next 539 SND.WND - send window 540 SND.UP - send urgent pointer 541 SND.WL1 - segment sequence number used for last window update 542 SND.WL2 - segment acknowledgment number used for last window 543 update 544 ISS - initial send sequence number 546 Receive Sequence Variables 548 RCV.NXT - receive next 549 RCV.WND - receive window 550 RCV.UP - receive urgent pointer 551 IRS - initial receive sequence number 553 The following diagrams may help to relate some of these variables to 554 the sequence space. 556 1 2 3 4 557 ----------|----------|----------|---------- 558 SND.UNA SND.NXT SND.UNA 559 +SND.WND 561 1 - old sequence numbers that have been acknowledged 562 2 - sequence numbers of unacknowledged data 563 3 - sequence numbers allowed for new data transmission 564 4 - future sequence numbers that are not yet allowed 566 Figure 2: Send Sequence Space 568 The send window is the portion of the sequence space labeled 3 in 569 Figure 2. 571 1 2 3 572 ----------|----------|---------- 573 RCV.NXT RCV.NXT 574 +RCV.WND 576 1 - old sequence numbers that have been acknowledged 577 2 - sequence numbers allowed for new reception 578 3 - future sequence numbers that are not yet allowed 580 Figure 3: Receive Sequence Space 582 The receive window is the portion of the sequence space labeled 2 in 583 Figure 3. 585 There are also some variables used frequently in the discussion that 586 take their values from the fields of the current segment. 588 Current Segment Variables 590 SEG.SEQ - segment sequence number 591 SEG.ACK - segment acknowledgment number 592 SEG.LEN - segment length 593 SEG.WND - segment window 594 SEG.UP - segment urgent pointer 596 3.2.2. State Machine Overview 598 A connection progresses through a series of states during its 599 lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, 600 ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, 601 TIME-WAIT, and the fictional state CLOSED. CLOSED is fictional 602 because it represents the state when there is no TCB, and therefore, 603 no connection. Briefly the meanings of the states are: 605 LISTEN - represents waiting for a connection request from any 606 remote TCP peer and port. 608 SYN-SENT - represents waiting for a matching connection request 609 after having sent a connection request. 611 SYN-RECEIVED - represents waiting for a confirming connection 612 request acknowledgment after having both received and sent a 613 connection request. 615 ESTABLISHED - represents an open connection, data received can be 616 delivered to the user. The normal state for the data transfer 617 phase of the connection. 619 FIN-WAIT-1 - represents waiting for a connection termination 620 request from the remote TCP peer, or an acknowledgment of the 621 connection termination request previously sent. 623 FIN-WAIT-2 - represents waiting for a connection termination 624 request from the remote TCP peer. 626 CLOSE-WAIT - represents waiting for a connection termination 627 request from the local user. 629 CLOSING - represents waiting for a connection termination request 630 acknowledgment from the remote TCP peer. 632 LAST-ACK - represents waiting for an acknowledgment of the 633 connection termination request previously sent to the remote TCP 634 peer (this termination request sent to the remote TCP peer already 635 included an acknowledgment of the termination request sent from 636 the remote TCP peer). 638 TIME-WAIT - represents waiting for enough time to pass to be sure 639 the remote TCP peer received the acknowledgment of its connection 640 termination request. 642 CLOSED - represents no connection state at all. 644 A TCP connection progresses from one state to another in response to 645 events. The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, 646 ABORT, and STATUS; the incoming segments, particularly those 647 containing the SYN, ACK, RST and FIN flags; and timeouts. 649 The state diagram in Figure 4 illustrates only state changes, 650 together with the causing events and resulting actions, but addresses 651 neither error conditions nor actions that are not connected with 652 state changes. In a later section, more detail is offered with 653 respect to the reaction of the TCP implementation to events. Some 654 state names are abbreviated or hyphenated differently in the diagram 655 from how they appear elsewhere in the document. 657 NOTA BENE: This diagram is only a summary and must not be taken as 658 the total specification. Many details are not included. 660 +---------+ ---------\ active OPEN 661 | CLOSED | \ ----------- 662 +---------+<---------\ \ create TCB 663 | ^ \ \ snd SYN 664 passive OPEN | | CLOSE \ \ 665 ------------ | | ---------- \ \ 666 create TCB | | delete TCB \ \ 667 V | \ \ 668 rcv RST (note 1) +---------+ CLOSE | \ 669 -------------------->| LISTEN | ---------- | | 670 / +---------+ delete TCB | | 671 / rcv SYN | | SEND | | 672 / ----------- | | ------- | V 673 +--------+ snd SYN,ACK / \ snd SYN +--------+ 674 | |<----------------- ------------------>| | 675 | SYN | rcv SYN | SYN | 676 | RCVD |<-----------------------------------------------| SENT | 677 | | snd SYN,ACK | | 678 | |------------------ -------------------| | 679 +--------+ rcv ACK of SYN \ / rcv SYN,ACK +--------+ 680 | -------------- | | ----------- 681 | x | | snd ACK 682 | V V 683 | CLOSE +---------+ 684 | ------- | ESTAB | 685 | snd FIN +---------+ 686 | CLOSE | | rcv FIN 687 V ------- | | ------- 688 +---------+ snd FIN / \ snd ACK +---------+ 689 | FIN |<----------------- ------------------>| CLOSE | 690 | WAIT-1 |------------------ | WAIT | 691 +---------+ rcv FIN \ +---------+ 692 | rcv ACK of FIN ------- | CLOSE | 693 | -------------- snd ACK | ------- | 694 V x V snd FIN V 695 +---------+ +---------+ +---------+ 696 |FINWAIT-2| | CLOSING | | LAST-ACK| 697 +---------+ +---------+ +---------+ 698 | rcv ACK of FIN | rcv ACK of FIN | 699 | rcv FIN -------------- | Timeout=2MSL -------------- | 700 | ------- x V ------------ x V 701 \ snd ACK +---------+delete TCB +---------+ 702 ------------------------>|TIME WAIT|------------------>| CLOSED | 703 +---------+ +---------+ 705 note 1: The transition from SYN-RECEIVED to LISTEN on receiving a RST is 706 conditional on having reached SYN-RECEIVED after a passive open. 708 note 2: An unshown transition exists from FIN-WAIT-1 to TIME-WAIT if 709 a FIN is received and the local FIN is also acknowledged. 711 Figure 4: TCP Connection State Diagram 713 3.3. Sequence Numbers 715 A fundamental notion in the design is that every octet of data sent 716 over a TCP connection has a sequence number. Since every octet is 717 sequenced, each of them can be acknowledged. The acknowledgment 718 mechanism employed is cumulative so that an acknowledgment of 719 sequence number X indicates that all octets up to but not including X 720 have been received. This mechanism allows for straight-forward 721 duplicate detection in the presence of retransmission. Numbering of 722 octets within a segment is that the first data octet immediately 723 following the header is the lowest numbered, and the following octets 724 are numbered consecutively. 726 It is essential to remember that the actual sequence number space is 727 finite, though very large. This space ranges from 0 to 2**32 - 1. 728 Since the space is finite, all arithmetic dealing with sequence 729 numbers must be performed modulo 2**32. This unsigned arithmetic 730 preserves the relationship of sequence numbers as they cycle from 731 2**32 - 1 to 0 again. There are some subtleties to computer modulo 732 arithmetic, so great care should be taken in programming the 733 comparison of such values. The symbol "=<" means "less than or 734 equal" (modulo 2**32). 736 The typical kinds of sequence number comparisons that the TCP 737 implementation must perform include: 739 (a) Determining that an acknowledgment refers to some sequence 740 number sent but not yet acknowledged. 742 (b) Determining that all sequence numbers occupied by a segment 743 have been acknowledged (e.g., to remove the segment from a 744 retransmission queue). 746 (c) Determining that an incoming segment contains sequence numbers 747 that are expected (i.e., that the segment "overlaps" the receive 748 window). 750 In response to sending data the TCP endpoint will receive 751 acknowledgments. The following comparisons are needed to process the 752 acknowledgments. 754 SND.UNA = oldest unacknowledged sequence number 756 SND.NXT = next sequence number to be sent 758 SEG.ACK = acknowledgment from the receiving TCP peer (next 759 sequence number expected by the receiving TCP peer) 760 SEG.SEQ = first sequence number of a segment 762 SEG.LEN = the number of octets occupied by the data in the segment 763 (counting SYN and FIN) 765 SEG.SEQ+SEG.LEN-1 = last sequence number of a segment 767 A new acknowledgment (called an "acceptable ack"), is one for which 768 the inequality below holds: 770 SND.UNA < SEG.ACK =< SND.NXT 772 A segment on the retransmission queue is fully acknowledged if the 773 sum of its sequence number and length is less or equal than the 774 acknowledgment value in the incoming segment. 776 When data is received the following comparisons are needed: 778 RCV.NXT = next sequence number expected on an incoming segments, 779 and is the left or lower edge of the receive window 781 RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming 782 segment, and is the right or upper edge of the receive window 784 SEG.SEQ = first sequence number occupied by the incoming segment 786 SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming 787 segment 789 A segment is judged to occupy a portion of valid receive sequence 790 space if 792 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 794 or 796 RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 798 The first part of this test checks to see if the beginning of the 799 segment falls in the window, the second part of the test checks to 800 see if the end of the segment falls in the window; if the segment 801 passes either part of the test it contains data in the window. 803 Actually, it is a little more complicated than this. Due to zero 804 windows and zero length segments, we have four cases for the 805 acceptability of an incoming segment: 807 Segment Receive Test 808 Length Window 809 ------- ------- ------------------------------------------- 811 0 0 SEG.SEQ = RCV.NXT 813 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 815 >0 0 not acceptable 817 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 818 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 820 Note that when the receive window is zero no segments should be 821 acceptable except ACK segments. Thus, it is be possible for a TCP 822 implementation to maintain a zero receive window while transmitting 823 data and receiving ACKs. A TCP receiver MUST process the RST and URG 824 fields of all incoming segments, even when the receive window is zero 825 (MUST-66). 827 We have taken advantage of the numbering scheme to protect certain 828 control information as well. This is achieved by implicitly 829 including some control flags in the sequence space so they can be 830 retransmitted and acknowledged without confusion (i.e., one and only 831 one copy of the control will be acted upon). Control information is 832 not physically carried in the segment data space. Consequently, we 833 must adopt rules for implicitly assigning sequence numbers to 834 control. The SYN and FIN are the only controls requiring this 835 protection, and these controls are used only at connection opening 836 and closing. For sequence number purposes, the SYN is considered to 837 occur before the first actual data octet of the segment in which it 838 occurs, while the FIN is considered to occur after the last actual 839 data octet in a segment in which it occurs. The segment length 840 (SEG.LEN) includes both data and sequence space occupying controls. 841 When a SYN is present then SEG.SEQ is the sequence number of the SYN. 843 Initial Sequence Number Selection 845 The protocol places no restriction on a particular connection being 846 used over and over again. A connection is defined by a pair of 847 sockets. New instances of a connection will be referred to as 848 incarnations of the connection. The problem that arises from this is 849 -- "how does the TCP implementation identify duplicate segments from 850 previous incarnations of the connection?" This problem becomes 851 apparent if the connection is being opened and closed in quick 852 succession, or if the connection breaks with loss of memory and is 853 then reestablished. 855 To avoid confusion we must prevent segments from one incarnation of a 856 connection from being used while the same sequence numbers may still 857 be present in the network from an earlier incarnation. We want to 858 assure this, even if a TCP endpoint loses all knowledge of the 859 sequence numbers it has been using. When new connections are 860 created, an initial sequence number (ISN) generator is employed that 861 selects a new 32 bit ISN. There are security issues that result if 862 an off-path attacker is able to predict or guess ISN values. 864 The recommended ISN generator is based on the combination of a 865 (possibly fictitious) 32 bit clock whose low order bit is incremented 866 roughly every 4 microseconds, and a pseudorandom hash function (PRF). 867 The clock component is intended to insure that with a Maximum Segment 868 Lifetime (MSL), generated ISNs will be unique, since it cycles 869 approximately every 4.55 hours, which is much longer than the MSL. 870 This recommended algorithm is further described in RFC 6528 [36] and 871 builds on the basic clock-driven algorithm from RFC 793. 873 A TCP implementation MUST use a clock-driven selection of initial 874 sequence numbers (MUST-8), and SHOULD generate its Initial Sequence 875 Numbers with the expression: 877 ISN = M + F(localip, localport, remoteip, remoteport, secretkey) 879 where M is the 4 microsecond timer, and F() is a pseudorandom 880 function (PRF) of the connection's identifying parameters ("localip, 881 localport, remoteip, remoteport") and a secret key ("secretkey") 882 (SHLD-1). F() MUST NOT be computable from the outside (MUST-9), or 883 an attacker could still guess at sequence numbers from the ISN used 884 for some other connection. The PRF could be implemented as a 885 cryptographic hash of the concatenation of the TCP connection 886 parameters and some secret data. For discussion of the selection of 887 a specific hash algorithm and management of the secret key data, 888 please see Section 3 of [36]. 890 For each connection there is a send sequence number and a receive 891 sequence number. The initial send sequence number (ISS) is chosen by 892 the data sending TCP peer, and the initial receive sequence number 893 (IRS) is learned during the connection establishing procedure. 895 For a connection to be established or initialized, the two TCP peers 896 must synchronize on each other's initial sequence numbers. This is 897 done in an exchange of connection establishing segments carrying a 898 control bit called "SYN" (for synchronize) and the initial sequence 899 numbers. As a shorthand, segments carrying the SYN bit are also 900 called "SYNs". Hence, the solution requires a suitable mechanism for 901 picking an initial sequence number and a slightly involved handshake 902 to exchange the ISN's. 904 The synchronization requires each side to send its own initial 905 sequence number and to receive a confirmation of it in acknowledgment 906 from the remote TCP peer. Each side must also receive the remote 907 peer's initial sequence number and send a confirming acknowledgment. 909 1) A --> B SYN my sequence number is X 910 2) A <-- B ACK your sequence number is X 911 3) A <-- B SYN my sequence number is Y 912 4) A --> B ACK your sequence number is Y 914 Because steps 2 and 3 can be combined in a single message this is 915 called the three way (or three message) handshake. 917 A three way handshake is necessary because sequence numbers are not 918 tied to a global clock in the network, and TCP implementations may 919 have different mechanisms for picking the ISN's. The receiver of the 920 first SYN has no way of knowing whether the segment was an old 921 delayed one or not, unless it remembers the last sequence number used 922 on the connection (which is not always possible), and so it must ask 923 the sender to verify this SYN. The three way handshake and the 924 advantages of a clock-driven scheme are discussed in [55]. 926 Knowing When to Keep Quiet 928 A theoretical problem exists where data could be corrupted due to 929 confusion between old segments in the network and new ones after a 930 host reboots, if the same port numbers and sequence space are reused. 931 The "Quiet Time" concept discussed below addresses this and the 932 discussion of it is included for situations where it might be 933 relevant, although it is not felt to be necessary in most current 934 implementations. The problem have been more relevant earlier in the 935 history of TCP. In practical use on the Internet today, the error- 936 prone conditions are sufficiently unlikely that it is felt safe to 937 ignore. Reasons why it is now negligible include: (a) ISS and 938 ephemeral port randomization have reduced likelihood of reuse of 939 ports and sequency numbers after reboots, (b) the effective MSL of 940 the Internet has declined as links have become faster, and (c) 941 reboots often taking longer than an MSL anyways. 943 To be sure that a TCP implementation does not create a segment 944 carrying a sequence number that may be duplicated by an old segment 945 remaining in the network, the TCP endpoint must keep quiet for an MSL 946 before assigning any sequence numbers upon starting up or recovering 947 from a situation where memory of sequence numbers in use was lost. 948 For this specification the MSL is taken to be 2 minutes. This is an 949 engineering choice, and may be changed if experience indicates it is 950 desirable to do so. Note that if a TCP endpoint is reinitialized in 951 some sense, yet retains its memory of sequence numbers in use, then 952 it need not wait at all; it must only be sure to use sequence numbers 953 larger than those recently used. 955 The TCP Quiet Time Concept 957 Hosts that for any reason lose knowledge of the last sequence numbers 958 transmitted on each active (i.e., not closed) connection shall delay 959 emitting any TCP segments for at least the agreed MSL in the internet 960 system that the host is a part of. In the paragraphs below, an 961 explanation for this specification is given. TCP implementors may 962 violate the "quiet time" restriction, but only at the risk of causing 963 some old data to be accepted as new or new data rejected as old 964 duplicated by some receivers in the internet system. 966 TCP endpoints consume sequence number space each time a segment is 967 formed and entered into the network output queue at a source host. 968 The duplicate detection and sequencing algorithm in the TCP protocol 969 relies on the unique binding of segment data to sequence space to the 970 extent that sequence numbers will not cycle through all 2**32 values 971 before the segment data bound to those sequence numbers has been 972 delivered and acknowledged by the receiver and all duplicate copies 973 of the segments have "drained" from the internet. Without such an 974 assumption, two distinct TCP segments could conceivably be assigned 975 the same or overlapping sequence numbers, causing confusion at the 976 receiver as to which data is new and which is old. Remember that 977 each segment is bound to as many consecutive sequence numbers as 978 there are octets of data and SYN or FIN flags in the segment. 980 Under normal conditions, TCP implementations keep track of the next 981 sequence number to emit and the oldest awaiting acknowledgment so as 982 to avoid mistakenly using a sequence number over before its first use 983 has been acknowledged. This alone does not guarantee that old 984 duplicate data is drained from the net, so the sequence space has 985 been made very large to reduce the probability that a wandering 986 duplicate will cause trouble upon arrival. At 2 megabits/sec. it 987 takes 4.5 hours to use up 2**32 octets of sequence space. Since the 988 maximum segment lifetime in the net is not likely to exceed a few 989 tens of seconds, this is deemed ample protection for foreseeable 990 nets, even if data rates escalate to l0's of megabits/sec. At 100 991 megabits/sec, the cycle time is 5.4 minutes, which may be a little 992 short, but still within reason. 994 The basic duplicate detection and sequencing algorithm in TCP can be 995 defeated, however, if a source TCP endpoint does not have any memory 996 of the sequence numbers it last used on a given connection. For 997 example, if the TCP implementation were to start all connections with 998 sequence number 0, then upon the host rebooting, a TCP peer might re- 999 form an earlier connection (possibly after half-open connection 1000 resolution) and emit packets with sequence numbers identical to or 1001 overlapping with packets still in the network, which were emitted on 1002 an earlier incarnation of the same connection. In the absence of 1003 knowledge about the sequence numbers used on a particular connection, 1004 the TCP specification recommends that the source delay for MSL 1005 seconds before emitting segments on the connection, to allow time for 1006 segments from the earlier connection incarnation to drain from the 1007 system. 1009 Even hosts that can remember the time of day and used it to select 1010 initial sequence number values are not immune from this problem 1011 (i.e., even if time of day is used to select an initial sequence 1012 number for each new connection incarnation). 1014 Suppose, for example, that a connection is opened starting with 1015 sequence number S. Suppose that this connection is not used much and 1016 that eventually the initial sequence number function (ISN(t)) takes 1017 on a value equal to the sequence number, say S1, of the last segment 1018 sent by this TCP endpoint on a particular connection. Now suppose, 1019 at this instant, the host reboots and establishes a new incarnation 1020 of the connection. The initial sequence number chosen is S1 = ISN(t) 1021 -- last used sequence number on old incarnation of connection! If 1022 the recovery occurs quickly enough, any old duplicates in the net 1023 bearing sequence numbers in the neighborhood of S1 may arrive and be 1024 treated as new packets by the receiver of the new incarnation of the 1025 connection. 1027 The problem is that the recovering host may not know for how long it 1028 was down between rebooting nor does it know whether there are still 1029 old duplicates in the system from earlier connection incarnations. 1031 One way to deal with this problem is to deliberately delay emitting 1032 segments for one MSL after recovery from a reboot - this is the 1033 "quiet time" specification. Hosts that prefer to avoid waiting are 1034 willing to risk possible confusion of old and new packets at a given 1035 destination may choose not to wait for the "quiet time". 1036 Implementors may provide TCP users with the ability to select on a 1037 connection by connection basis whether to wait after a reboot, or may 1038 informally implement the "quiet time" for all connections. 1039 Obviously, even where a user selects to "wait," this is not necessary 1040 after the host has been "up" for at least MSL seconds. 1042 To summarize: every segment emitted occupies one or more sequence 1043 numbers in the sequence space, the numbers occupied by a segment are 1044 "busy" or "in use" until MSL seconds have passed, upon rebooting a 1045 block of space-time is occupied by the octets and SYN or FIN flags of 1046 the last emitted segment, if a new connection is started too soon and 1047 uses any of the sequence numbers in the space-time footprint of the 1048 last segment of the previous connection incarnation, there is a 1049 potential sequence number overlap area that could cause confusion at 1050 the receiver. 1052 3.4. Establishing a connection 1054 The "three-way handshake" is the procedure used to establish a 1055 connection. This procedure normally is initiated by one TCP peer and 1056 responded to by another TCP peer. The procedure also works if two 1057 TCP peers simultaneously initiate the procedure. When simultaneous 1058 open occurs, each TCP peer receives a "SYN" segment that carries no 1059 acknowledgment after it has sent a "SYN". Of course, the arrival of 1060 an old duplicate "SYN" segment can potentially make it appear, to the 1061 recipient, that a simultaneous connection initiation is in progress. 1062 Proper use of "reset" segments can disambiguate these cases. 1064 Several examples of connection initiation follow. Although these 1065 examples do not show connection synchronization using data-carrying 1066 segments, this is perfectly legitimate, so long as the receiving TCP 1067 endpoint doesn't deliver the data to the user until it is clear the 1068 data is valid (e.g., the data is buffered at the receiver until the 1069 connection reaches the ESTABLISHED state, given that the three-way 1070 handshake reduces the possibility of false connections). It is the 1071 implementation of a trade-off between memory and messages to provide 1072 information for this checking. 1074 The simplest three-way handshake is shown in Figure 5 below. The 1075 figures should be interpreted in the following way. Each line is 1076 numbered for reference purposes. Right arrows (-->) indicate 1077 departure of a TCP segment from TCP peer A to TCP peer B, or arrival 1078 of a segment at B from A. Left arrows (<--), indicate the reverse. 1079 Ellipsis (...) indicates a segment that is still in the network 1080 (delayed). Comments appear in parentheses. TCP connection states 1081 represent the state AFTER the departure or arrival of the segment 1082 (whose contents are shown in the center of each line). Segment 1083 contents are shown in abbreviated form, with sequence number, control 1084 flags, and ACK field. Other fields such as window, addresses, 1085 lengths, and text have been left out in the interest of clarity. 1087 TCP Peer A TCP Peer B 1089 1. CLOSED LISTEN 1091 2. SYN-SENT --> --> SYN-RECEIVED 1093 3. ESTABLISHED <-- <-- SYN-RECEIVED 1095 4. ESTABLISHED --> --> ESTABLISHED 1097 5. ESTABLISHED --> --> ESTABLISHED 1099 Figure 5: Basic 3-Way Handshake for Connection Synchronization 1101 In line 2 of Figure 5, TCP Peer A begins by sending a SYN segment 1102 indicating that it will use sequence numbers starting with sequence 1103 number 100. In line 3, TCP Peer B sends a SYN and acknowledges the 1104 SYN it received from TCP Peer A. Note that the acknowledgment field 1105 indicates TCP Peer B is now expecting to hear sequence 101, 1106 acknowledging the SYN that occupied sequence 100. 1108 At line 4, TCP Peer A responds with an empty segment containing an 1109 ACK for TCP Peer B's SYN; and in line 5, TCP Peer A sends some data. 1110 Note that the sequence number of the segment in line 5 is the same as 1111 in line 4 because the ACK does not occupy sequence number space (if 1112 it did, we would wind up ACKing ACK's!). 1114 Simultaneous initiation is only slightly more complex, as is shown in 1115 Figure 6. Each TCP peer's connection state cycles from CLOSED to 1116 SYN-SENT to SYN-RECEIVED to ESTABLISHED. 1118 TCP Peer A TCP Peer B 1120 1. CLOSED CLOSED 1122 2. SYN-SENT --> ... 1124 3. SYN-RECEIVED <-- <-- SYN-SENT 1126 4. ... --> SYN-RECEIVED 1128 5. SYN-RECEIVED --> ... 1130 6. ESTABLISHED <-- <-- SYN-RECEIVED 1132 7. ... --> ESTABLISHED 1134 Figure 6: Simultaneous Connection Synchronization 1136 A TCP implementation MUST support simultaneous open attempts (MUST- 1137 10). 1139 Note that a TCP implementation MUST keep track of whether a 1140 connection has reached SYN-RECEIVED state as the result of a passive 1141 OPEN or an active OPEN (MUST-11). 1143 The principal reason for the three-way handshake is to prevent old 1144 duplicate connection initiations from causing confusion. To deal 1145 with this, a special control message, reset, is specified. If the 1146 receiving TCP peer is in a non-synchronized state (i.e., SYN-SENT, 1147 SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset. 1148 If the TCP peer is in one of the synchronized states (ESTABLISHED, 1149 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it 1150 aborts the connection and informs its user. We discuss this latter 1151 case under "half-open" connections below. 1153 TCP Peer A TCP Peer B 1155 1. CLOSED LISTEN 1157 2. SYN-SENT --> ... 1159 3. (duplicate) ... --> SYN-RECEIVED 1161 4. SYN-SENT <-- <-- SYN-RECEIVED 1163 5. SYN-SENT --> --> LISTEN 1165 6. ... --> SYN-RECEIVED 1167 7. ESTABLISHED <-- <-- SYN-RECEIVED 1169 8. ESTABLISHED --> --> ESTABLISHED 1171 Figure 7: Recovery from Old Duplicate SYN 1173 As a simple example of recovery from old duplicates, consider 1174 Figure 7. At line 3, an old duplicate SYN arrives at TCP Peer B. 1175 TCP Peer B cannot tell that this is an old duplicate, so it responds 1176 normally (line 4). TCP Peer A detects that the ACK field is 1177 incorrect and returns a RST (reset) with its SEQ field selected to 1178 make the segment believable. TCP Peer B, on receiving the RST, 1179 returns to the LISTEN state. When the original SYN finally arrives 1180 at line 6, the synchronization proceeds normally. If the SYN at line 1181 6 had arrived before the RST, a more complex exchange might have 1182 occurred with RST's sent in both directions. 1184 Half-Open Connections and Other Anomalies 1186 An established connection is said to be "half-open" if one of the TCP 1187 peers has closed or aborted the connection at its end without the 1188 knowledge of the other, or if the two ends of the connection have 1189 become desynchronized owing to a failure or reboot that resulted in 1190 loss of memory. Such connections will automatically become reset if 1191 an attempt is made to send data in either direction. However, half- 1192 open connections are expected to be unusual. 1194 If at site A the connection no longer exists, then an attempt by the 1195 user at site B to send any data on it will result in the site B TCP 1196 endpoint receiving a reset control message. Such a message indicates 1197 to the site B TCP endpoint that something is wrong, and it is 1198 expected to abort the connection. 1200 Assume that two user processes A and B are communicating with one 1201 another when a failure or reboot occurs causing loss of memory to A's 1202 TCP implementation. Depending on the operating system supporting A's 1203 TCP implementation, it is likely that some error recovery mechanism 1204 exists. When the TCP endpoint is up again, A is likely to start 1205 again from the beginning or from a recovery point. As a result, A 1206 will probably try to OPEN the connection again or try to SEND on the 1207 connection it believes open. In the latter case, it receives the 1208 error message "connection not open" from the local (A's) TCP 1209 implementation. In an attempt to establish the connection, A's TCP 1210 implementation will send a segment containing SYN. This scenario 1211 leads to the example shown in Figure 8. After TCP Peer A reboots, 1212 the user attempts to re-open the connection. TCP Peer B, in the 1213 meantime, thinks the connection is open. 1215 TCP Peer A TCP Peer B 1217 1. (REBOOT) (send 300,receive 100) 1219 2. CLOSED ESTABLISHED 1221 3. SYN-SENT --> --> (??) 1223 4. (!!) <-- <-- ESTABLISHED 1225 5. SYN-SENT --> --> (Abort!!) 1227 6. SYN-SENT CLOSED 1229 7. SYN-SENT --> --> 1231 Figure 8: Half-Open Connection Discovery 1233 When the SYN arrives at line 3, TCP Peer B, being in a synchronized 1234 state, and the incoming segment outside the window, responds with an 1235 acknowledgment indicating what sequence it next expects to hear (ACK 1236 100). TCP Peer A sees that this segment does not acknowledge 1237 anything it sent and, being unsynchronized, sends a reset (RST) 1238 because it has detected a half-open connection. TCP Peer B aborts at 1239 line 5. TCP Peer A will continue to try to establish the connection; 1240 the problem is now reduced to the basic 3-way handshake of Figure 5. 1242 An interesting alternative case occurs when TCP Peer A reboots and 1243 TCP Peer B tries to send data on what it thinks is a synchronized 1244 connection. This is illustrated in Figure 9. In this case, the data 1245 arriving at TCP Peer A from TCP Peer B (line 2) is unacceptable 1246 because no such connection exists, so TCP Peer A sends a RST. The 1247 RST is acceptable so TCP Peer B processes it and aborts the 1248 connection. 1250 TCP Peer A TCP Peer B 1252 1. (REBOOT) (send 300,receive 100) 1254 2. (??) <-- <-- ESTABLISHED 1256 3. --> --> (ABORT!!) 1258 Figure 9: Active Side Causes Half-Open Connection Discovery 1260 In Figure 10, we find the two TCP Peers A and B with passive 1261 connections waiting for SYN. An old duplicate arriving at TCP Peer B 1262 (line 2) stirs B into action. A SYN-ACK is returned (line 3) and 1263 causes TCP A to generate a RST (the ACK in line 3 is not acceptable). 1264 TCP Peer B accepts the reset and returns to its passive LISTEN state. 1266 TCP Peer A TCP Peer B 1268 1. LISTEN LISTEN 1270 2. ... --> SYN-RECEIVED 1272 3. (??) <-- <-- SYN-RECEIVED 1274 4. --> --> (return to LISTEN!) 1276 5. LISTEN LISTEN 1278 Figure 10: Old Duplicate SYN Initiates a Reset on two Passive Sockets 1279 A variety of other cases are possible, all of which are accounted for 1280 by the following rules for RST generation and processing. 1282 Reset Generation 1284 As a general rule, reset (RST) is sent whenever a segment arrives 1285 that apparently is not intended for the current connection. A reset 1286 must not be sent if it is not clear that this is the case. 1288 There are three groups of states: 1290 1. If the connection does not exist (CLOSED) then a reset is sent 1291 in response to any incoming segment except another reset. A SYN 1292 segment that does not match an existing connection is rejected by 1293 this means. 1295 If the incoming segment has the ACK bit set, the reset takes its 1296 sequence number from the ACK field of the segment, otherwise the 1297 reset has sequence number zero and the ACK field is set to the sum 1298 of the sequence number and segment length of the incoming segment. 1299 The connection remains in the CLOSED state. 1301 2. If the connection is in any non-synchronized state (LISTEN, 1302 SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges 1303 something not yet sent (the segment carries an unacceptable ACK), 1304 or if an incoming segment has a security level or compartment that 1305 does not exactly match the level and compartment requested for the 1306 connection, a reset is sent. 1308 If the incoming segment has an ACK field, the reset takes its 1309 sequence number from the ACK field of the segment, otherwise the 1310 reset has sequence number zero and the ACK field is set to the sum 1311 of the sequence number and segment length of the incoming segment. 1312 The connection remains in the same state. 1314 3. If the connection is in a synchronized state (ESTABLISHED, 1315 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), 1316 any unacceptable segment (out of window sequence number or 1317 unacceptable acknowledgment number) must be responded to with an 1318 empty acknowledgment segment (without any user data) containing 1319 the current send-sequence number and an acknowledgment indicating 1320 the next sequence number expected to be received, and the 1321 connection remains in the same state. 1323 If an incoming segment has a security level, or compartment that 1324 does not exactly match the level and compartment requested for the 1325 connection, a reset is sent and the connection goes to the CLOSED 1326 state. The reset takes its sequence number from the ACK field of 1327 the incoming segment. 1329 Reset Processing 1331 In all states except SYN-SENT, all reset (RST) segments are validated 1332 by checking their SEQ-fields. A reset is valid if its sequence 1333 number is in the window. In the SYN-SENT state (a RST received in 1334 response to an initial SYN), the RST is acceptable if the ACK field 1335 acknowledges the SYN. 1337 The receiver of a RST first validates it, then changes state. If the 1338 receiver was in the LISTEN state, it ignores it. If the receiver was 1339 in SYN-RECEIVED state and had previously been in the LISTEN state, 1340 then the receiver returns to the LISTEN state, otherwise the receiver 1341 aborts the connection and goes to the CLOSED state. If the receiver 1342 was in any other state, it aborts the connection and advises the user 1343 and goes to the CLOSED state. 1345 TCP implementations SHOULD allow a received RST segment to include 1346 data (SHLD-2). 1348 3.5. Closing a Connection 1350 CLOSE is an operation meaning "I have no more data to send." The 1351 notion of closing a full-duplex connection is subject to ambiguous 1352 interpretation, of course, since it may not be obvious how to treat 1353 the receiving side of the connection. We have chosen to treat CLOSE 1354 in a simplex fashion. The user who CLOSEs may continue to RECEIVE 1355 until the TCP receiver is told that the remote peer has CLOSED also. 1356 Thus, a program could initiate several SENDs followed by a CLOSE, and 1357 then continue to RECEIVE until signaled that a RECEIVE failed because 1358 the remote peer has CLOSED. The TCP implementation will signal a 1359 user, even if no RECEIVEs are outstanding, that the remote peer has 1360 closed, so the user can terminate his side gracefully. A TCP 1361 implementation will reliably deliver all buffers SENT before the 1362 connection was CLOSED so a user who expects no data in return need 1363 only wait to hear the connection was CLOSED successfully to know that 1364 all their data was received at the destination TCP endpoint. Users 1365 must keep reading connections they close for sending until the TCP 1366 implementation indicates there is no more data. 1368 There are essentially three cases: 1370 1) The user initiates by telling the TCP implementation to CLOSE 1371 the connection 1372 2) The remote TCP endpoint initiates by sending a FIN control 1373 signal 1375 3) Both users CLOSE simultaneously 1377 Case 1: Local user initiates the close 1379 In this case, a FIN segment can be constructed and placed on the 1380 outgoing segment queue. No further SENDs from the user will be 1381 accepted by the TCP implementation, and it enters the FIN-WAIT-1 1382 state. RECEIVEs are allowed in this state. All segments 1383 preceding and including FIN will be retransmitted until 1384 acknowledged. When the other TCP peer has both acknowledged the 1385 FIN and sent a FIN of its own, the first TCP peer can ACK this 1386 FIN. Note that a TCP endpoint receiving a FIN will ACK but not 1387 send its own FIN until its user has CLOSED the connection also. 1389 Case 2: TCP endpoint receives a FIN from the network 1391 If an unsolicited FIN arrives from the network, the receiving TCP 1392 endpoint can ACK it and tell the user that the connection is 1393 closing. The user will respond with a CLOSE, upon which the TCP 1394 endpoint can send a FIN to the other TCP peer after sending any 1395 remaining data. The TCP endpoint then waits until its own FIN is 1396 acknowledged whereupon it deletes the connection. If an ACK is 1397 not forthcoming, after the user timeout the connection is aborted 1398 and the user is told. 1400 Case 3: Both users close simultaneously 1402 A simultaneous CLOSE by users at both ends of a connection causes 1403 FIN segments to be exchanged. When all segments preceding the 1404 FINs have been processed and acknowledged, each TCP peer can ACK 1405 the FIN it has received. Both will, upon receiving these ACKs, 1406 delete the connection. 1408 TCP Peer A TCP Peer B 1410 1. ESTABLISHED ESTABLISHED 1412 2. (Close) 1413 FIN-WAIT-1 --> --> CLOSE-WAIT 1415 3. FIN-WAIT-2 <-- <-- CLOSE-WAIT 1417 4. (Close) 1418 TIME-WAIT <-- <-- LAST-ACK 1420 5. TIME-WAIT --> --> CLOSED 1422 6. (2 MSL) 1423 CLOSED 1425 Figure 11: Normal Close Sequence 1427 TCP Peer A TCP Peer B 1429 1. ESTABLISHED ESTABLISHED 1431 2. (Close) (Close) 1432 FIN-WAIT-1 --> ... FIN-WAIT-1 1433 <-- <-- 1434 ... --> 1436 3. CLOSING --> ... CLOSING 1437 <-- <-- 1438 ... --> 1440 4. TIME-WAIT TIME-WAIT 1441 (2 MSL) (2 MSL) 1442 CLOSED CLOSED 1444 Figure 12: Simultaneous Close Sequence 1446 A TCP connection may terminate in two ways: (1) the normal TCP close 1447 sequence using a FIN handshake, and (2) an "abort" in which one or 1448 more RST segments are sent and the connection state is immediately 1449 discarded. If the local TCP connection is closed by the remote side 1450 due to a FIN or RST received from the remote side, then the local 1451 application MUST be informed whether it closed normally or was 1452 aborted (MUST-12). 1454 3.5.1. Half-Closed Connections 1456 The normal TCP close sequence delivers buffered data reliably in both 1457 directions. Since the two directions of a TCP connection are closed 1458 independently, it is possible for a connection to be "half closed," 1459 i.e., closed in only one direction, and a host is permitted to 1460 continue sending data in the open direction on a half-closed 1461 connection. 1463 A host MAY implement a "half-duplex" TCP close sequence, so that an 1464 application that has called CLOSE cannot continue to read data from 1465 the connection (MAY-1). If such a host issues a CLOSE call while 1466 received data is still pending in the TCP connection, or if new data 1467 is received after CLOSE is called, its TCP implementation SHOULD send 1468 a RST to show that data was lost (SHLD-3). See [18] section 2.17 for 1469 discussion. 1471 When a connection is closed actively, it MUST linger in TIME-WAIT 1472 state for a time 2xMSL (Maximum Segment Lifetime) (MUST-13). 1473 However, it MAY accept a new SYN from the remote TCP endpoint to 1474 reopen the connection directly from TIME-WAIT state (MAY-2), if it: 1476 (1) assigns its initial sequence number for the new connection to 1477 be larger than the largest sequence number it used on the previous 1478 connection incarnation, and 1480 (2) returns to TIME-WAIT state if the SYN turns out to be an old 1481 duplicate. 1483 When the TCP Timestamp options are available, an improved algorithm 1484 is described in [34] in order to support higher connection 1485 establishment rates. This algorithm for reducing TIME-WAIT is a Best 1486 Current Practice that SHOULD be implemented, since timestamp options 1487 are commonly used, and using them to reduce TIME-WAIT provides 1488 benefits for busy Internet servers (SHLD-4). 1490 3.6. Segmentation 1492 The term "segmentation" refers to the activity TCP performs when 1493 ingesting a stream of bytes from a sending application and 1494 packetizing that stream of bytes into TCP segments. Individual TCP 1495 segments often do not correspond one-for-one to individual send (or 1496 socket write) calls from the application. Applications may perform 1497 writes at the granularity of messages in the upper layer protocol, 1498 but TCP guarantees no boundary coherence between the TCP segments 1499 sent and received versus user application data read or write buffer 1500 boundaries. In some specific protocols, such as RDMA using DDP and 1501 MPA [26], there are performance optimizations possible when the 1502 relation between TCP segments and application data units can be 1503 controlled, and MPA includes a specific mechanism for detecting and 1504 verifying this relationship between TCP segments and application 1505 message data strcutures, but this is specific to applications like 1506 RDMA. In general, multiple goals influence the sizing of TCP 1507 segments created by a TCP implementation. 1509 Goals driving the sending of larger segments include: 1511 o Reducing the number of packets in flight within the network. 1513 o Increasing processing efficiency and potential performance by 1514 enabling a smaller number of interrupts and inter-layer 1515 interactions. 1517 o Limiting the overhead of TCP headers. 1519 Note that the performance benefits of sending larger segments may 1520 decrease as the size increases, and there may be boundaries where 1521 advantages are reversed. For instance, on some implementation 1522 architectures, 1025 bytes within a segment could lead to worse 1523 performance than 1024 bytes, due purely to data alignment on copy 1524 operations. 1526 Goals driving the sending of smaller segments include: 1528 o Avoiding sending a TCP segment that would result in an IP datagram 1529 larger than the smallest MTU along an IP network path, because 1530 this results in either packet loss or packet fragmentation. 1531 Making matters worse, some firewalls or middleboxes may drop 1532 fragmented packets or ICMP messages related related to 1533 fragmentation. 1535 o Preventing delays to the application data stream, especially when 1536 TCP is waiting on the application to generate more data, or when 1537 the application is waiting on an event or input from its peer in 1538 order to generate more data. 1540 o Enabling "fate sharing" between TCP segments and lower-layer data 1541 units (e.g. below IP, for links with cell or frame sizes smaller 1542 than the IP MTU). 1544 Towards meeting these competing sets of goals, TCP includes several 1545 mechanisms, including the Maximum Segment Size option, Path MTU 1546 Discovery, the Nagle algorithm, and support for IPv6 Jumbograms, as 1547 discussed in the following subsections. 1549 3.6.1. Maximum Segment Size Option 1551 TCP endpoints MUST implement both sending and receiving the MSS 1552 option (MUST-14). 1554 TCP implementations SHOULD send an MSS option in every SYN segment 1555 when its receive MSS differs from the default 536 for IPv4 or 1220 1556 for IPv6 (SHLD-5), and MAY send it always (MAY-3). 1558 If an MSS option is not received at connection setup, TCP 1559 implementations MUST assume a default send MSS of 536 (576-40) for 1560 IPv4 or 1220 (1280 - 60) for IPv6 (MUST-15). 1562 The maximum size of a segment that TCP endpoint really sends, the 1563 "effective send MSS," MUST be the smaller (MUST-16) of the send MSS 1564 (that reflects the available reassembly buffer size at the remote 1565 host, the EMTU_R [15]) and the largest transmission size permitted by 1566 the IP layer (EMTU_S [15]): 1568 Eff.snd.MSS = 1570 min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize 1572 where: 1574 o SendMSS is the MSS value received from the remote host, or the 1575 default 536 for IPv4 or 1220 for IPv6, if no MSS option is 1576 received. 1578 o MMS_S is the maximum size for a transport-layer message that TCP 1579 may send. 1581 o TCPhdrsize is the size of the fixed TCP header and any options. 1582 This is 20 in the (rare) case that no options are present, but may 1583 be larger if TCP options are to be sent. Note that some options 1584 may not be included on all segments, but that for each segment 1585 sent, the sender should adjust the data length accordingly, within 1586 the Eff.snd.MSS. 1588 o IPoptionsize is the size of any IP options associated with a TCP 1589 connection. Note that some options may not be included on all 1590 packets, but that for each segment sent, the sender should adjust 1591 the data length accordingly, within the Eff.snd.MSS. 1593 The MSS value to be sent in an MSS option should be equal to the 1594 effective MTU minus the fixed IP and TCP headers. By ignoring both 1595 IP and TCP options when calculating the value for the MSS option, if 1596 there are any IP or TCP options to be sent in a packet, then the 1597 sender must decrease the size of the TCP data accordingly. RFC 6691 1598 [37] discusses this in greater detail. 1600 The MSS value to be sent in an MSS option must be less than or equal 1601 to: 1603 MMS_R - 20 1605 where MMS_R is the maximum size for a transport-layer message that 1606 can be received (and reassembled at the IP layer) (MUST-67). TCP 1607 obtains MMS_R and MMS_S from the IP layer; see the generic call 1608 GET_MAXSIZES in Section 3.4 of RFC 1122. These are defined in terms 1609 of their IP MTU equivalents, EMTU_R and EMTU_S [15]. 1611 When TCP is used in a situation where either the IP or TCP headers 1612 are not fixed, the sender must reduce the amount of TCP data in any 1613 given packet by the number of octets used by the IP and TCP options. 1614 This has been a point of confusion historically, as explained in RFC 1615 6691, Section 3.1. 1617 3.6.2. Path MTU Discovery 1619 A TCP implementation may be aware of the MTU on directly connected 1620 links, but will rarely have insight about MTUs across an entire 1621 network path. For IPv4, RFC 1122 provides an IP-layer recommendation 1622 on the default effective MTU for sending to be less than or equal to 1623 576 for destinations not directly connected. For IPv6, this would be 1624 1280. In all cases, however, implementation of Path MTU Discovery 1625 (PMTUD) and Packetization Layer Path MTU Discovery (PLPMTUD) is 1626 strongly recommended in order for TCP to improve segmentation 1627 decisions. Both PMTUD and PLPMTUD help TCP choose segment sizes that 1628 avoid both on-path (for IPv4) and source fragmentation (IPv4 and 1629 IPv6). 1631 PMTUD for IPv4 [2] or IPv6 [3] is implemented in conjunction between 1632 TCP, IP, and ICMP protocols. It relies both on avoiding source 1633 fragmentation and setting the IPv4 DF (don't fragment) flag, the 1634 latter to inhibit on-path fragmentation. It relies on ICMP errors 1635 from routers along the path, whenever a segment is too large to 1636 traverse a link. Several adjustments to a TCP implementation with 1637 PMTUD are described in RFC 2923 in order to deal with problems 1638 experienced in practice [7]. PLPMTUD [23] is a Standards Track 1639 improvement to PMTUD that relaxes the requirement for ICMP support 1640 across a path, and improves performance in cases where ICMP is not 1641 consistently conveyed, but still tries to avoid source fragmentation. 1642 The mechanisms in all four of these RFCs are recommended to be 1643 included in TCP implementations. 1645 The TCP MSS option specifies an upper bound for the size of packets 1646 that can be received. Hence, setting the value in the MSS option too 1647 small can impact the ability for PMTUD or PLPMTUD to find a larger 1648 path MTU. RFC 1191 discusses this implication of many older TCP 1649 implementations setting MSS to 536 for non-local destinations, rather 1650 than deriving it from the MTUs of connected interfaces as 1651 recommended. 1653 3.6.3. Interfaces with Variable MTU Values 1655 The effective MTU can sometimes vary, as when used with variable 1656 compression, e.g., RObust Header Compression (ROHC) [30]. It is 1657 tempting for a TCP implementation to want to advertise the largest 1658 possible MSS, to support the most efficient use of compressed 1659 payloads. Unfortunately, some compression schemes occasionally need 1660 to transmit full headers (and thus smaller payloads) to resynchronize 1661 state at their endpoint compressors/decompressors. If the largest 1662 MTU is used to calculate the value to advertise in the MSS option, 1663 TCP retransmission may interfere with compressor resynchronization. 1665 As a result, when the effective MTU of an interface varies packet-to- 1666 packet, TCP implementations SHOULD use the smallest effective MTU of 1667 the interface to calculate the value to advertise in the MSS option 1668 (SHLD-6). 1670 3.6.4. Nagle Algorithm 1672 The "Nagle algorithm" was described in RFC 896 [14] and was 1673 recommended in RFC 1122 [15] for mitigation of an early problem of 1674 too many small packets being generated. It has been implemented in 1675 most current TCP code bases, sometimes with minor variations (see 1676 Appendix A.3). 1678 If there is unacknowledged data (i.e., SND.NXT > SND.UNA), then the 1679 sending TCP endpoint buffers all user data (regardless of the PSH 1680 bit), until the outstanding data has been acknowledged or until the 1681 TCP endpoint can send a full-sized segment (Eff.snd.MSS bytes). 1683 A TCP implementation SHOULD implement the Nagle Algorithm to coalesce 1684 short segments (SHLD-7). However, there MUST be a way for an 1685 application to disable the Nagle algorithm on an individual 1686 connection (MUST-17). In all cases, sending data is also subject to 1687 the limitation imposed by the Slow Start algorithm [29]. 1689 3.6.5. IPv6 Jumbograms 1691 In order to support TCP over IPv6 jumbograms, implementations need to 1692 be able to send TCP segments larger than the 64KB limit that the MSS 1693 option can convey. RFC 2675 [6] defines that an MSS value of 65,535 1694 bytes is to be treated as infinity, and Path MTU Discovery [3] is 1695 used to determine the actual MSS. 1697 The Jumbo Payload option need not be implemented or understood by 1698 IPv6 nodes that do not support attachment to links with a MTU greater 1699 than 65,575 [6], and the present IPv6 Node Requiements does not 1700 include support for Jumbograms [47]. 1702 3.7. Data Communication 1704 Once the connection is established data is communicated by the 1705 exchange of segments. Because segments may be lost due to errors 1706 (checksum test failure), or network congestion, TCP uses 1707 retransmission to ensure delivery of every segment. Duplicate 1708 segments may arrive due to network or TCP retransmission. As 1709 discussed in the section on sequence numbers the TCP implementation 1710 performs certain tests on the sequence and acknowledgment numbers in 1711 the segments to verify their acceptability. 1713 The sender of data keeps track of the next sequence number to use in 1714 the variable SND.NXT. The receiver of data keeps track of the next 1715 sequence number to expect in the variable RCV.NXT. The sender of 1716 data keeps track of the oldest unacknowledged sequence number in the 1717 variable SND.UNA. If the data flow is momentarily idle and all data 1718 sent has been acknowledged then the three variables will be equal. 1720 When the sender creates a segment and transmits it the sender 1721 advances SND.NXT. When the receiver accepts a segment it advances 1722 RCV.NXT and sends an acknowledgment. When the data sender receives 1723 an acknowledgment it advances SND.UNA. The extent to which the 1724 values of these variables differ is a measure of the delay in the 1725 communication. The amount by which the variables are advanced is the 1726 length of the data and SYN or FIN flags in the segment. Note that 1727 once in the ESTABLISHED state all segments must carry current 1728 acknowledgment information. 1730 The CLOSE user call implies a push function, as does the FIN control 1731 flag in an incoming segment. 1733 3.7.1. Retransmission Timeout 1735 Because of the variability of the networks that compose an 1736 internetwork system and the wide range of uses of TCP connections the 1737 retransmission timeout (RTO) must be dynamically determined. 1739 The RTO MUST be computed according to the algorithm in [9], including 1740 Karn's algorithm for taking RTT samples (MUST-18). 1742 RFC 793 contains an early example procedure for computing the RTO. 1743 This was then replaced by the algorithm described in RFC 1122, and 1744 subsequently updated in RFC 2988, and then again in RFC 6298. 1746 RFC 1122 allows that if a retransmitted packet is identical to the 1747 original packet (which implies not only that the data boundaries have 1748 not changed, but also that none of the headers have changed), then 1749 the same IPv4 Identification field MAY be used (see Section 3.2.1.5 1750 of RFC 1122) (MAY-4). The same IP identification field may be reused 1751 anyways, since it is only meaningful when a datagram is fragmented 1752 [38]. TCP implementations should not rely on or typically interact 1753 with this IPv4 header field in any way. It is not a reasonable way 1754 to either indicate duplicate sent segments, nor to identify duplicate 1755 received segments. 1757 3.7.2. TCP Congestion Control 1759 RFC 1122 required implementation of Van Jacobson's congestion control 1760 algorithm combining slow start with congestion avoidance. RFC 2581 1761 provided IETF Standards Track description of this, along with fast 1762 retransmit and fast recovery. RFC 5681 is the current description of 1763 these algorithms and is the current standard for TCP congestion 1764 control. 1766 A TCP endpoint MUST implement RFC 5681 (MUST-19). 1768 Explicit Congestion Notification (ECN) was defined in RFC 3168 and is 1769 an IETF Standards Track enhancement that has many benefits [44]. 1771 A TCP endpoint SHOULD implement ECN as described in RFC 3168 (SHLD- 1772 8). 1774 3.7.3. TCP Connection Failures 1776 Excessive retransmission of the same segment by a TCP endpoint 1777 indicates some failure of the remote host or the Internet path. This 1778 failure may be of short or long duration. The following procedure 1779 MUST be used to handle excessive retransmissions of data segments 1780 (MUST-20): 1782 (a) There are two thresholds R1 and R2 measuring the amount of 1783 retransmission that has occurred for the same segment. R1 and R2 1784 might be measured in time units or as a count of retransmissions. 1786 (b) When the number of transmissions of the same segment reaches 1787 or exceeds threshold R1, pass negative advice (see [15] 1788 Section 3.3.1.4) to the IP layer, to trigger dead-gateway 1789 diagnosis. 1791 (c) When the number of transmissions of the same segment reaches a 1792 threshold R2 greater than R1, close the connection. 1794 (d) An application MUST (MUST-21) be able to set the value for R2 1795 for a particular connection. For example, an interactive 1796 application might set R2 to "infinity," giving the user control 1797 over when to disconnect. 1799 (e) TCP implementations SHOULD inform the application of the 1800 delivery problem (unless such information has been disabled by the 1801 application; see Asynchronous Reports section), when R1 is reached 1802 and before R2 (SHLD-9). This will allow a remote login (User 1803 Telnet) application program to inform the user, for example. 1805 The value of R1 SHOULD correspond to at least 3 retransmissions, at 1806 the current RTO (SHLD-10). The value of R2 SHOULD correspond to at 1807 least 100 seconds (SHLD-11). 1809 An attempt to open a TCP connection could fail with excessive 1810 retransmissions of the SYN segment or by receipt of a RST segment or 1811 an ICMP Port Unreachable. SYN retransmissions MUST be handled in the 1812 general way just described for data retransmissions, including 1813 notification of the application layer. 1815 However, the values of R1 and R2 may be different for SYN and data 1816 segments. In particular, R2 for a SYN segment MUST be set large 1817 enough to provide retransmission of the segment for at least 3 1818 minutes (MUST-23). The application can close the connection (i.e., 1819 give up on the open attempt) sooner, of course. 1821 3.7.4. TCP Keep-Alives 1823 Implementors MAY include "keep-alives" in their TCP implementations 1824 (MAY-5), although this practice is not universally accepted. Some 1825 TCP implementations, however, have included a keep-alive mechanism. 1826 To confirm that an idle connection is still active, these 1827 implementations send a probe segment designed to elicit a response 1828 from the TCP peer. Such a segment generally contains SEG.SEQ = 1829 SND.NXT-1 and may or may not contain one garbage octet of data. If 1830 keep-alives are included, the application MUST be able to turn them 1831 on or off for each TCP connection (MUST-24), and they MUST default to 1832 off (MUST-25). 1834 Keep-alive packets MUST only be sent when no data or acknowledgement 1835 packets have been received for the connection within an interval 1836 (MUST-26). This interval MUST be configurable (MUST-27) and MUST 1837 default to no less than two hours (MUST-28). 1839 It is extremely important to remember that ACK segments that contain 1840 no data are not reliably transmitted by TCP. Consequently, if a 1841 keep-alive mechanism is implemented it MUST NOT interpret failure to 1842 respond to any specific probe as a dead connection (MUST-29). 1844 An implementation SHOULD send a keep-alive segment with no data 1845 (SHLD-12); however, it MAY be configurable to send a keep-alive 1846 segment containing one garbage octet (MAY-6), for compatibility with 1847 erroneous TCP implementations. 1849 3.7.5. The Communication of Urgent Information 1851 As a result of implementation differences and middlebox interactions, 1852 new applications SHOULD NOT employ the TCP urgent mechanism (SHLD- 1853 13). However, TCP implementations MUST still include support for the 1854 urgent mechanism (MUST-30). Details can be found in RFC 6093 [33]. 1856 The objective of the TCP urgent mechanism is to allow the sending 1857 user to stimulate the receiving user to accept some urgent data and 1858 to permit the receiving TCP endpoint to indicate to the receiving 1859 user when all the currently known urgent data has been received by 1860 the user. 1862 This mechanism permits a point in the data stream to be designated as 1863 the end of urgent information. Whenever this point is in advance of 1864 the receive sequence number (RCV.NXT) at the receiving TCP endpoint, 1865 that TCP must tell the user to go into "urgent mode"; when the 1866 receive sequence number catches up to the urgent pointer, the TCP 1867 implementation must tell user to go into "normal mode". If the 1868 urgent pointer is updated while the user is in "urgent mode", the 1869 update will be invisible to the user. 1871 The method employs a urgent field that is carried in all segments 1872 transmitted. The URG control flag indicates that the urgent field is 1873 meaningful and must be added to the segment sequence number to yield 1874 the urgent pointer. The absence of this flag indicates that there is 1875 no urgent data outstanding. 1877 To send an urgent indication the user must also send at least one 1878 data octet. If the sending user also indicates a push, timely 1879 delivery of the urgent information to the destination process is 1880 enhanced. 1882 A TCP implementation MUST support a sequence of urgent data of any 1883 length (MUST-31). [15] 1885 The urgent pointer MUST point to the sequence number of the octet 1886 following the urgent data (MUST-62). 1888 A TCP implementation MUST (MUST-32) inform the application layer 1889 asynchronously whenever it receives an Urgent pointer and there was 1890 previously no pending urgent data, or whenvever the Urgent pointer 1891 advances in the data stream. There MUST (MUST-33) be a way for the 1892 application to learn how much urgent data remains to be read from the 1893 connection, or at least to determine whether or not more urgent data 1894 remains to be read. [15] 1896 3.7.6. Managing the Window 1898 The window sent in each segment indicates the range of sequence 1899 numbers the sender of the window (the data receiver) is currently 1900 prepared to accept. There is an assumption that this is related to 1901 the currently available data buffer space available for this 1902 connection. 1904 The sending TCP endpoint packages the data to be transmitted into 1905 segments that fit the current window, and may repackage segments on 1906 the retransmission queue. Such repackaging is not required, but may 1907 be helpful. 1909 In a connection with a one-way data flow, the window information will 1910 be carried in acknowledgment segments that all have the same sequence 1911 number so there will be no way to reorder them if they arrive out of 1912 order. This is not a serious problem, but it will allow the window 1913 information to be on occasion temporarily based on old reports from 1914 the data receiver. A refinement to avoid this problem is to act on 1915 the window information from segments that carry the highest 1916 acknowledgment number (that is segments with acknowledgment number 1917 equal or greater than the highest previously received). 1919 Indicating a large window encourages transmissions. If more data 1920 arrives than can be accepted, it will be discarded. This will result 1921 in excessive retransmissions, adding unnecessarily to the load on the 1922 network and the TCP endpoints. Indicating a small window may 1923 restrict the transmission of data to the point of introducing a round 1924 trip delay between each new segment transmitted. 1926 The mechanisms provided allow a TCP endpoint to advertise a large 1927 window and to subsequently advertise a much smaller window without 1928 having accepted that much data. This, so called "shrinking the 1929 window," is strongly discouraged. The robustness principle [15] 1930 dictates that TCP peers will not shrink the window themselves, but 1931 will be prepared for such behavior on the part of other TCP peers. 1933 A TCP receiver SHOULD NOT shrink the window, i.e., move the right 1934 window edge to the left (SHLD-14). However, a sending TCP peer MUST 1935 be robust against window shrinking, which may cause the "useable 1936 window" (see Section 3.7.6.2.1) to become negative (MUST-34). 1938 If this happens, the sender SHOULD NOT send new data (SHLD-15), but 1939 SHOULD retransmit normally the old unacknowledged data between 1940 SND.UNA and SND.UNA+SND.WND (SHLD-16). The sender MAY also 1941 retransmit old data beyond SND.UNA+SND.WND (MAY-7), but SHOULD NOT 1942 time out the connection if data beyond the right window edge is not 1943 acknowledged (SHLD-17). If the window shrinks to zero, the TCP 1944 implementation MUST probe it in the standard way (described below) 1945 (MUST-35). 1947 3.7.6.1. Zero Window Probing 1949 The sending TCP peer must be prepared to accept from the user and 1950 send at least one octet of new data even if the send window is zero. 1951 The sending TCP peer must regularly retransmit to the receiving TCP 1952 peer even when the window is zero, in order to "probe" the window. 1953 Two minutes is recommended for the retransmission interval when the 1954 window is zero. This retransmission is essential to guarantee that 1955 when either TCP peer has a zero window the re-opening of the window 1956 will be reliably reported to the other. This is referred to as Zero- 1957 Window Probing (ZWP) in other documents. 1959 Probing of zero (offered) windows MUST be supported (MUST-36). 1961 A TCP implementation MAY keep its offered receive window closed 1962 indefinitely (MAY-8). As long as the receiving TCP peer continues to 1963 send acknowledgments in response to the probe segments, the sending 1964 TCP peer MUST allow the connection to stay open (MUST-37). This 1965 enables TCP to function in scenarios such as the "printer ran out of 1966 paper" situation described in Section 4.2.2.17 of RFC1122. The 1967 behavior is subject to the implementation's resource management 1968 concerns, as noted in [35]. 1970 When the receiving TCP peer has a zero window and a segment arrives 1971 it must still send an acknowledgment showing its next expected 1972 sequence number and current window (zero). 1974 The transmitting host SHOULD send the first zero-window probe when a 1975 zero window has existed for the retransmission timeout period (SHLD- 1976 29) (see Section 3.7.1), and SHOULD increase exponentially the 1977 interval between successive probes (SHLD-30). 1979 3.7.6.2. Silly Window Syndrome Avoidance 1981 The "Silly Window Syndrome" (SWS) is a stable pattern of small 1982 incremental window movements resulting in extremely poor TCP 1983 performance. Algorithms to avoid SWS are described below for both 1984 the sending side and the receiving side. RFC 1122 contains more 1985 detailed discussion of the SWS problem. Note that the Nagle 1986 algorithm and the sender SWS avoidance algorithm play complementary 1987 roles in improving performance. The Nagle algorithm discourages 1988 sending tiny segments when the data to be sent increases in small 1989 increments, while the SWS avoidance algorithm discourages small 1990 segments resulting from the right window edge advancing in small 1991 increments. 1993 3.7.6.2.1. Sender's Algorithm - When to Send Data 1995 A TCP implementation MUST include a SWS avoidance algorithm in the 1996 sender (MUST-38). 1998 The Nagle algorithm from Section 3.6.4 additionally describes how to 1999 coalesce short segments. 2001 The sender's SWS avoidance algorithm is more difficult than the 2002 receivers's, because the sender does not know (directly) the 2003 receiver's total buffer space RCV.BUFF. An approach that has been 2004 found to work well is for the sender to calculate Max(SND.WND), the 2005 maximum send window it has seen so far on the connection, and to use 2006 this value as an estimate of RCV.BUFF. Unfortunately, this can only 2007 be an estimate; the receiver may at any time reduce the size of 2008 RCV.BUFF. To avoid a resulting deadlock, it is necessary to have a 2009 timeout to force transmission of data, overriding the SWS avoidance 2010 algorithm. In practice, this timeout should seldom occur. 2012 The "useable window" is: 2014 U = SND.UNA + SND.WND - SND.NXT 2016 i.e., the offered window less the amount of data sent but not 2017 acknowledged. If D is the amount of data queued in the sending TCP 2018 endpoint but not yet sent, then the following set of rules is 2019 recommended. 2021 Send data: 2023 (1) if a maximum-sized segment can be sent, i.e, if: 2025 min(D,U) >= Eff.snd.MSS; 2027 (2) or if the data is pushed and all queued data can be sent now, 2028 i.e., if: 2030 [SND.NXT = SND.UNA and] PUSHED and D <= U 2032 (the bracketed condition is imposed by the Nagle algorithm); 2034 (3) or if at least a fraction Fs of the maximum window can be sent, 2035 i.e., if: 2037 [SND.NXT = SND.UNA and] 2039 min(D.U) >= Fs * Max(SND.WND); 2041 (4) or if data is PUSHed and the override timeout occurs. 2043 Here Fs is a fraction whose recommended value is 1/2. The override 2044 timeout should be in the range 0.1 - 1.0 seconds. It may be 2045 convenient to combine this timer with the timer used to probe zero 2046 windows (Section Section 3.7.6.1). 2048 3.7.6.2.2. Receiver's Algorithm - When to Send a Window Update 2050 A TCP implementation MUST include a SWS avoidance algorithm in the 2051 receiver (MUST-39). 2053 The receiver's SWS avoidance algorithm determines when the right 2054 window edge may be advanced; this is customarily known as "updating 2055 the window". This algorithm combines with the delayed ACK algorithm 2056 (see Section 3.7.6.3) to determine when an ACK segment containing the 2057 current window will really be sent to the receiver. 2059 The solution to receiver SWS is to avoid advancing the right window 2060 edge RCV.NXT+RCV.WND in small increments, even if data is received 2061 from the network in small segments. 2063 Suppose the total receive buffer space is RCV.BUFF. At any given 2064 moment, RCV.USER octets of this total may be tied up with data that 2065 has been received and acknowledged but that the user process has not 2066 yet consumed. When the connection is quiescent, RCV.WND = RCV.BUFF 2067 and RCV.USER = 0. 2069 Keeping the right window edge fixed as data arrives and is 2070 acknowledged requires that the receiver offer less than its full 2071 buffer space, i.e., the receiver must specify a RCV.WND that keeps 2072 RCV.NXT+RCV.WND constant as RCV.NXT increases. Thus, the total 2073 buffer space RCV.BUFF is generally divided into three parts: 2075 |<------- RCV.BUFF ---------------->| 2076 1 2 3 2077 ----|---------|------------------|------|---- 2078 RCV.NXT ^ 2079 (Fixed) 2081 1 - RCV.USER = data received but not yet consumed; 2082 2 - RCV.WND = space advertised to sender; 2083 3 - Reduction = space available but not yet 2084 advertised. 2086 The suggested SWS avoidance algorithm for the receiver is to keep 2087 RCV.NXT+RCV.WND fixed until the reduction satisfies: 2089 RCV.BUFF - RCV.USER - RCV.WND >= 2091 min( Fr * RCV.BUFF, Eff.snd.MSS ) 2093 where Fr is a fraction whose recommended value is 1/2, and 2094 Eff.snd.MSS is the effective send MSS for the connection (see 2095 Section 3.6.1). When the inequality is satisfied, RCV.WND is set to 2096 RCV.BUFF-RCV.USER. 2098 Note that the general effect of this algorithm is to advance RCV.WND 2099 in increments of Eff.snd.MSS (for realistic receive buffers: 2100 Eff.snd.MSS < RCV.BUFF/2). Note also that the receiver must use its 2101 own Eff.snd.MSS, assuming it is the same as the sender's. 2103 3.7.6.3. Delayed Acknowledgements - When to Send an ACK Segment 2105 A host that is receiving a stream of TCP data segments can increase 2106 efficiency in both the Internet and the hosts by sending fewer than 2107 one ACK (acknowledgment) segment per data segment received; this is 2108 known as a "delayed ACK". 2110 A TCP endpoint SHOULD implement a delayed ACK (SHLD-18), but an ACK 2111 should not be excessively delayed; in particular, the delay MUST be 2112 less than 0.5 seconds (MUST-40), and in a stream of full-sized 2113 segments there SHOULD be an ACK for at least every second segment 2114 (SHLD-19). Excessive delays on ACK's can disturb the round-trip 2115 timing and packet "clocking" algorithms. More complete discussion of 2116 delayed ACK behavior is in Section 4.2 of RFC 5681 [29], including 2117 rules for streams of segments that are not full-sized. Note that 2118 there are several current practices that further lead to a reduced 2119 number of ACKs, including generic receive offload (GRO), ACK 2120 compression, and ACK decimation [20]. 2122 3.8. Interfaces 2124 There are of course two interfaces of concern: the user/TCP interface 2125 and the TCP/lower-level interface. We have a fairly elaborate model 2126 of the user/TCP interface, but the interface to the lower level 2127 protocol module is left unspecified here, since it will be specified 2128 in detail by the specification of the lower level protocol. For the 2129 case that the lower level is IP we note some of the parameter values 2130 that TCP implementations might use. 2132 3.8.1. User/TCP Interface 2134 The following functional description of user commands to the TCP 2135 implementation is, at best, fictional, since every operating system 2136 will have different facilities. Consequently, we must warn readers 2137 that different TCP implementations may have different user 2138 interfaces. However, all TCP implementations must provide a certain 2139 minimum set of services to guarantee that all TCP implementations can 2140 support the same protocol hierarchy. This section specifies the 2141 functional interfaces required of all TCP implementations. 2143 Section 3.1 of [46] also identifies primitives provided by TCP, and 2144 could be used as an additional reference for implementers. 2146 TCP User Commands 2148 The following sections functionally characterize a USER/TCP 2149 interface. The notation used is similar to most procedure or 2150 function calls in high level languages, but this usage is not 2151 meant to rule out trap type service calls. 2153 The user commands described below specify the basic functions the 2154 TCP implementation must perform to support interprocess 2155 communication. Individual implementations must define their own 2156 exact format, and may provide combinations or subsets of the basic 2157 functions in single calls. In particular, some implementations 2158 may wish to automatically OPEN a connection on the first SEND or 2159 RECEIVE issued by the user for a given connection. 2161 In providing interprocess communication facilities, the TCP 2162 implementation must not only accept commands, but must also return 2163 information to the processes it serves. The latter consists of: 2165 (a) general information about a connection (e.g., interrupts, 2166 remote close, binding of unspecified remote socket). 2168 (b) replies to specific user commands indicating success or 2169 various types of failure. 2171 Open 2173 Format: OPEN (local port, remote socket, active/passive [, 2174 timeout] [, DiffServ field] [, security/compartment] [local IP 2175 address,] [, options]) -> local connection name 2177 If the active/passive flag is set to passive, then this is a 2178 call to LISTEN for an incoming connection. A passive open may 2179 have either a fully specified remote socket to wait for a 2180 particular connection or an unspecified remote socket to wait 2181 for any call. A fully specified passive call can be made 2182 active by the subsequent execution of a SEND. 2184 A transmission control block (TCB) is created and partially 2185 filled in with data from the OPEN command parameters. 2187 Every passive OPEN call either creates a new connection record 2188 in LISTEN state, or it returns an error; it MUST NOT affect any 2189 previously created connection record (MUST-41). 2191 A TCP implementation that supports multiple concurrent 2192 connections MUST provide an OPEN call that will functionally 2193 allow an application to LISTEN on a port while a connection 2194 block with the same local port is in SYN-SENT or SYN-RECEIVED 2195 state (MUST-42). 2197 On an active OPEN command, the TCP endpoint will begin the 2198 procedure to synchronize (i.e., establish) the connection at 2199 once. 2201 The timeout, if present, permits the caller to set up a timeout 2202 for all data submitted to TCP. If data is not successfully 2203 delivered to the destination within the timeout period, the TCP 2204 endpoint will abort the connection. The present global default 2205 is five minutes. 2207 The TCP implementation or some component of the operating 2208 system will verify the users authority to open a connection 2209 with the specified DiffServ field value or security/ 2210 compartment. The absence of a DiffServ field value or 2211 security/compartment specification in the OPEN call indicates 2212 the default values must be used. 2214 TCP will accept incoming requests as matching only if the 2215 security/compartment information is exactly the same as that 2216 requested in the OPEN call. 2218 The DiffServ field value indicated by the user only impacts 2219 outgoing packets, may be altered en route through the network, 2220 and has no direct bearing or relation to received packets. 2222 A local connection name will be returned to the user by the TCP 2223 implementation. The local connection name can then be used as 2224 a short hand term for the connection defined by the pair. 2227 The optional "local IP address" parameter MUST be supported to 2228 allow the specification of the local IP address (MUST-43). 2229 This enables applications that need to select the local IP 2230 address used when multihoming is present. 2232 A passive OPEN call with a specified "local IP address" 2233 parameter will await an incoming connection request to that 2234 address. If the parameter is unspecified, a passive OPEN will 2235 await an incoming connection request to any local IP address, 2236 and then bind the local IP address of the connection to the 2237 particular address that is used. 2239 For an active OPEN call, a specified "local IP address" 2240 parameter will be used for opening the connection. If the 2241 parameter is unspecified, the host will choose an appropriate 2242 local IP address (see RFC 1122 section 3.3.4.2). 2244 If an application on a multihomed host does not specify the 2245 local IP address when actively opening a TCP connection, then 2246 the TCP implementation MUST ask the IP layer to select a local 2247 IP address before sending the (first) SYN (MUST-44). See the 2248 function GET_SRCADDR() in Section 3.4 of RFC 1122. 2250 At all other times, a previous segment has either been sent or 2251 received on this connection, and TCP implementations MUST use 2252 the same local address is used that was used in those previous 2253 segments (MUST-45). 2255 A TCP implementation MUST reject as an error a local OPEN call 2256 for an invalid remote IP address (e.g., a broadcast or 2257 multicast address) (MUST-46). 2259 Send 2260 Format: SEND (local connection name, buffer address, byte 2261 count, PUSH flag (optional), URGENT flag [,timeout]) 2263 This call causes the data contained in the indicated user 2264 buffer to be sent on the indicated connection. If the 2265 connection has not been opened, the SEND is considered an 2266 error. Some implementations may allow users to SEND first; in 2267 which case, an automatic OPEN would be done. For example, this 2268 might be one way for application data to be included in SYN 2269 segments. If the calling process is not authorized to use this 2270 connection, an error is returned. 2272 A TCP endpoint MAY implement PUSH flags on SEND calls (MAY-15). 2273 If PUSH flags are not implemented, then the sending TCP peer: 2274 (1) MUST NOT buffer data indefinitely (MUST-60), and (2) MUST 2275 set the PSH bit in the last buffered segment (i.e., when there 2276 is no more queued data to be sent) (MUST-61). The remaining 2277 description below assumes the PUSH flag is supported on SEND 2278 calls. 2280 If the PUSH flag is set, the application intends the data to be 2281 transmitted promptly to the receiver, and the PUSH bit will be 2282 set in the last TCP segment created from the buffer. When an 2283 application issues a series of SEND calls without setting the 2284 PUSH flag, the TCP implementation MAY aggregate the data 2285 internally without sending it (MAY-16). 2287 The PSH bit is not a record marker and is independent of 2288 segment boundaries. The transmitter SHOULD collapse successive 2289 bits when it packetizes data, to send the largest possible 2290 segment (SHLD-27). 2292 If the PUSH flag is not set, the data may be combined with data 2293 from subsequent SENDs for transmission efficiency. Note that 2294 when the Nagle algorithm is in use, TCP implementations may 2295 buffer the data before sending, without regard to the PUSH flag 2296 (see Section 3.6.4). 2298 An application program is logically required to set the PUSH 2299 flag in a SEND call whenever it needs to force delivery of the 2300 data to avoid a communication deadlock. However, a TCP 2301 implementation SHOULD send a maximum-sized segment whenever 2302 possible (SHLD-28), to improve performance (see 2303 Section 3.7.6.2.1). 2305 New applications SHOULD NOT set the URGENT flag [33] due to 2306 implementation differences and middlebox issues (SHLD-13). 2308 If the URGENT flag is set, segments sent to the destination TCP 2309 peer will have the urgent pointer set. The receiving TCP peer 2310 will signal the urgent condition to the receiving process if 2311 the urgent pointer indicates that data preceding the urgent 2312 pointer has not been consumed by the receiving process. The 2313 purpose of urgent is to stimulate the receiver to process the 2314 urgent data and to indicate to the receiver when all the 2315 currently known urgent data has been received. The number of 2316 times the sending user's TCP implementation signals urgent will 2317 not necessarily be equal to the number of times the receiving 2318 user will be notified of the presence of urgent data. 2320 If no remote socket was specified in the OPEN, but the 2321 connection is established (e.g., because a LISTENing connection 2322 has become specific due to a remote segment arriving for the 2323 local socket), then the designated buffer is sent to the 2324 implied remote socket. Users who make use of OPEN with an 2325 unspecified remote socket can make use of SEND without ever 2326 explicitly knowing the remote socket address. 2328 However, if a SEND is attempted before the remote socket 2329 becomes specified, an error will be returned. Users can use 2330 the STATUS call to determine the status of the connection. 2331 Some TCP implementations may notify the user when an 2332 unspecified socket is bound. 2334 If a timeout is specified, the current user timeout for this 2335 connection is changed to the new one. 2337 In the simplest implementation, SEND would not return control 2338 to the sending process until either the transmission was 2339 complete or the timeout had been exceeded. However, this 2340 simple method is both subject to deadlocks (for example, both 2341 sides of the connection might try to do SENDs before doing any 2342 RECEIVEs) and offers poor performance, so it is not 2343 recommended. A more sophisticated implementation would return 2344 immediately to allow the process to run concurrently with 2345 network I/O, and, furthermore, to allow multiple SENDs to be in 2346 progress. Multiple SENDs are served in first come, first 2347 served order, so the TCP endpoint will queue those it cannot 2348 service immediately. 2350 We have implicitly assumed an asynchronous user interface in 2351 which a SEND later elicits some kind of SIGNAL or pseudo- 2352 interrupt from the serving TCP endpoint. An alternative is to 2353 return a response immediately. For instance, SENDs might 2354 return immediate local acknowledgment, even if the segment sent 2355 had not been acknowledged by the distant TCP endpoint. We 2356 could optimistically assume eventual success. If we are wrong, 2357 the connection will close anyway due to the timeout. In 2358 implementations of this kind (synchronous), there will still be 2359 some asynchronous signals, but these will deal with the 2360 connection itself, and not with specific segments or buffers. 2362 In order for the process to distinguish among error or success 2363 indications for different SENDs, it might be appropriate for 2364 the buffer address to be returned along with the coded response 2365 to the SEND request. TCP-to-user signals are discussed below, 2366 indicating the information that should be returned to the 2367 calling process. 2369 Receive 2371 Format: RECEIVE (local connection name, buffer address, byte 2372 count) -> byte count, urgent flag, push flag (optional) 2374 This command allocates a receiving buffer associated with the 2375 specified connection. If no OPEN precedes this command or the 2376 calling process is not authorized to use this connection, an 2377 error is returned. 2379 In the simplest implementation, control would not return to the 2380 calling program until either the buffer was filled, or some 2381 error occurred, but this scheme is highly subject to deadlocks. 2382 A more sophisticated implementation would permit several 2383 RECEIVEs to be outstanding at once. These would be filled as 2384 segments arrive. This strategy permits increased throughput at 2385 the cost of a more elaborate scheme (possibly asynchronous) to 2386 notify the calling program that a PUSH has been seen or a 2387 buffer filled. 2389 A TCP receiver MAY pass a received PSH flag to the application 2390 layer via the PUSH flag in the interface (MAY-17), but it is 2391 not required (this was clarified in RFC 1122 section 4.2.2.2). 2392 The remainder of text describing the RECEIVE call below assumes 2393 that passing the PUSH indication is supported. 2395 If enough data arrive to fill the buffer before a PUSH is seen, 2396 the PUSH flag will not be set in the response to the RECEIVE. 2397 The buffer will be filled with as much data as it can hold. If 2398 a PUSH is seen before the buffer is filled the buffer will be 2399 returned partially filled and PUSH indicated. 2401 If there is urgent data the user will have been informed as 2402 soon as it arrived via a TCP-to-user signal. The receiving 2403 user should thus be in "urgent mode". If the URGENT flag is 2404 on, additional urgent data remains. If the URGENT flag is off, 2405 this call to RECEIVE has returned all the urgent data, and the 2406 user may now leave "urgent mode". Note that data following the 2407 urgent pointer (non-urgent data) cannot be delivered to the 2408 user in the same buffer with preceding urgent data unless the 2409 boundary is clearly marked for the user. 2411 To distinguish among several outstanding RECEIVEs and to take 2412 care of the case that a buffer is not completely filled, the 2413 return code is accompanied by both a buffer pointer and a byte 2414 count indicating the actual length of the data received. 2416 Alternative implementations of RECEIVE might have the TCP 2417 endpoint allocate buffer storage, or the TCP endpoint might 2418 share a ring buffer with the user. 2420 Close 2422 Format: CLOSE (local connection name) 2424 This command causes the connection specified to be closed. If 2425 the connection is not open or the calling process is not 2426 authorized to use this connection, an error is returned. 2427 Closing connections is intended to be a graceful operation in 2428 the sense that outstanding SENDs will be transmitted (and 2429 retransmitted), as flow control permits, until all have been 2430 serviced. Thus, it should be acceptable to make several SEND 2431 calls, followed by a CLOSE, and expect all the data to be sent 2432 to the destination. It should also be clear that users should 2433 continue to RECEIVE on CLOSING connections, since the remote 2434 peer may be trying to transmit the last of its data. Thus, 2435 CLOSE means "I have no more to send" but does not mean "I will 2436 not receive any more." It may happen (if the user level 2437 protocol is not well thought out) that the closing side is 2438 unable to get rid of all its data before timing out. In this 2439 event, CLOSE turns into ABORT, and the closing TCP peer gives 2440 up. 2442 The user may CLOSE the connection at any time on his own 2443 initiative, or in response to various prompts from the TCP 2444 implementation (e.g., remote close executed, transmission 2445 timeout exceeded, destination inaccessible). 2447 Because closing a connection requires communication with the 2448 remote TCP peer, connections may remain in the closing state 2449 for a short time. Attempts to reopen the connection before the 2450 TCP peer replies to the CLOSE command will result in error 2451 responses. 2453 Close also implies push function. 2455 Status 2457 Format: STATUS (local connection name) -> status data 2459 This is an implementation dependent user command and could be 2460 excluded without adverse effect. Information returned would 2461 typically come from the TCB associated with the connection. 2463 This command returns a data block containing the following 2464 information: 2466 local socket, 2467 remote socket, 2468 local connection name, 2469 receive window, 2470 send window, 2471 connection state, 2472 number of buffers awaiting acknowledgment, 2473 number of buffers pending receipt, 2474 urgent state, 2475 DiffServ field value, 2476 security/compartment, 2477 and transmission timeout. 2479 Depending on the state of the connection, or on the 2480 implementation itself, some of this information may not be 2481 available or meaningful. If the calling process is not 2482 authorized to use this connection, an error is returned. This 2483 prevents unauthorized processes from gaining information about 2484 a connection. 2486 Abort 2488 Format: ABORT (local connection name) 2490 This command causes all pending SENDs and RECEIVES to be 2491 aborted, the TCB to be removed, and a special RESET message to 2492 be sent to the remote TCP peer of the connection. Depending on 2493 the implementation, users may receive abort indications for 2494 each outstanding SEND or RECEIVE, or may simply receive an 2495 ABORT-acknowledgment. 2497 Flush 2499 Some TCP implementations have included a FLUSH call, which will 2500 empty the TCP send queue of any data that the user has issued 2501 SEND calls but is still to the right of the current send 2502 window. That is, it flushes as much queued send data as 2503 possible without losing sequence number synchronization. The 2504 FLUSH call MAY be implemented (MAY-14). 2506 Asynchronous Reports 2508 There MUST be a mechanism for reporting soft TCP error 2509 conditions to the application (MUST-47). Generically, we 2510 assume this takes the form of an application-supplied 2511 ERROR_REPORT routine that may be upcalled asynchronously from 2512 the transport layer: 2514 ERROR_REPORT(local connection name, reason, subreason) 2516 The precise encoding of the reason and subreason parameters is 2517 not specified here. However, the conditions that are reported 2518 asynchronously to the application MUST include: 2520 * ICMP error message arrived (see Section 3.8.2.2 for 2521 description of handling each ICMP message type, since some 2522 message types need to be suppressed from generating reports 2523 to the application) 2525 * Excessive retransmissions (see Section 3.7.3) 2527 * Urgent pointer advance (see Section 3.7.5) 2529 However, an application program that does not want to receive 2530 such ERROR_REPORT calls SHOULD be able to effectively disable 2531 these calls (SHLD-20). 2533 Set Differentiated Services Field (IPv4 TOS or IPv6 Traffic Class) 2535 The application layer MUST be able to specify the 2536 Differentiated Services field for segments that are sent on a 2537 connection (MUST-48). The Differentiated Services field 2538 includes the 6-bit Differentiated Services Code Point (DSCP) 2539 value. It is not required, but the application SHOULD be able 2540 to change the Differentiated Services field during the 2541 connection lifetime (SHLD-21). TCP implementations SHOULD pass 2542 the current Differentiated Services field value without change 2543 to the IP layer, when it sends segments on the connection 2544 (SHLD-22). 2546 The Differentiated Services field will be specified 2547 independently in each direction on the connection, so that the 2548 receiver application will specify the Differentiated Services 2549 field used for ACK segments. 2551 TCP implementations MAY pass the most recently received 2552 Differentiated Services field up to the application (MAY-9). 2554 3.8.2. TCP/Lower-Level Interface 2556 The TCP endpoint calls on a lower level protocol module to actually 2557 send and receive information over a network. The two current 2558 standard Internet Protocol (IP) versions layered below TCP are IPv4 2559 [1] and IPv6 [12]. 2561 If the lower level protocol is IPv4 it provides arguments for a type 2562 of service (used within the Differentiated Services field) and for a 2563 time to live. TCP uses the following settings for these parameters: 2565 DiffServ field: The IP header value for the DiffServ field is 2566 given by the user. This includes the bits of the DiffServ Code 2567 Point (DSCP). 2569 Time to Live (TTL): The TTL value used to send TCP segments MUST 2570 be configurable (MUST-49). 2572 Note that RFC 793 specified one minute (60 seconds) as a 2573 constant for the TTL, because the assumed maximum segment 2574 lifetime was two minutes. This was intended to explicitly ask 2575 that a segment be destroyed if it cannot be delivered by the 2576 internet system within one minute. RFC 1122 changed this 2577 specification to require that the TTL be configurable. 2579 Note that the DiffServ field is permitted to change during a 2580 connection (section 4.2.4.2 of RFC 1122). However, the 2581 application interface might not support this ability, and the 2582 application does not have knowledge about individual TCP 2583 segments, so this can only be done on a coarse granularity, at 2584 best. This limitation is further discussed in RFC 7657 (sec 2585 5.1, 5.3, and 6) [43]. Generally, an application SHOULD NOT 2586 change the DiffServ field value during the course of a 2587 connection (SHLD-23). 2589 Any lower level protocol will have to provide the source address, 2590 destination address, and protocol fields, and some way to determine 2591 the "TCP length", both to provide the functional equivalent service 2592 of IP and to be used in the TCP checksum. 2594 When received options are passed up to TCP from the IP layer, TCP 2595 implementations MUST ignore options that it does not understand 2596 (MUST-50). 2598 A TCP implementation MAY support the Time Stamp (MAY-10) and Record 2599 Route (MAY-11) options. 2601 3.8.2.1. Source Routing 2603 If the lower level is IP (or other protocol that provides this 2604 feature) and source routing is used, the interface must allow the 2605 route information to be communicated. This is especially important 2606 so that the source and destination addresses used in the TCP checksum 2607 be the originating source and ultimate destination. It is also 2608 important to preserve the return route to answer connection requests. 2610 An application MUST be able to specify a source route when it 2611 actively opens a TCP connection (MUST-51), and this MUST take 2612 precedence over a source route received in a datagram (MUST-52). 2614 When a TCP connection is OPENed passively and a packet arrives with a 2615 completed IP Source Route option (containing a return route), TCP 2616 implementations MUST save the return route and use it for all 2617 segments sent on this connection (MUST-53). If a different source 2618 route arrives in a later segment, the later definition SHOULD 2619 override the earlier one (SHLD-24). 2621 3.8.2.2. ICMP Messages 2623 TCP implementations MUST act on an ICMP error message passed up from 2624 the IP layer, directing it to the connection that created the error 2625 (MUST-54). The necessary demultiplexing information can be found in 2626 the IP header contained within the ICMP message. 2628 This applies to ICMPv6 in addition to IPv4 ICMP. 2630 [27] contains discussion of specific ICMP and ICMPv6 messages 2631 classified as either "soft" or "hard" errors that may bear different 2632 responses. Treatment for classes of ICMP messages is described 2633 below: 2635 Source Quench 2636 TCP implementations MUST silently discard any received ICMP Source 2637 Quench messages (MUST-55). See [10] for discussion. 2639 Soft Errors 2640 For ICMP these include: Destination Unreachable -- codes 0, 1, 5, 2641 Time Exceeded -- codes 0, 1, and Parameter Problem. 2643 For ICMPv6 these include: Destination Unreachable -- codes 0 and 3, 2644 Time Exceeded -- codes 0, 1, and Parameter Problem -- codes 0, 1, 2 2645 Since these Unreachable messages indicate soft error conditions, 2646 TCP implementations MUST NOT abort the connection (MUST-56), and it 2647 SHOULD make the information available to the application (SHLD-25). 2649 Hard Errors 2650 For ICMP these include Destination Unreachable -- codes 2-4"> 2651 These are hard error conditions, so TCP implementations SHOULD 2652 abort the connection (SHLD-26). [27] notes that some 2653 implementations do not abort connections when an ICMP hard error is 2654 received for a connection that is in any of the synchronized 2655 states. 2657 Note that [27] section 4 describes widespread implementation behavior 2658 that treats soft errors as hard errors during connection 2659 establishment. 2661 3.8.2.3. Remote Address Validation 2663 RFC 1122 requires addresses to be validated in incoming SYN packets: 2665 An incoming SYN with an invalid source address MUST be ignored 2666 either by TCP or by the IP layer (MUST-63) (see Section 3.2.1.3 of 2667 [15]). 2669 A TCP implementation MUST silently discard an incoming SYN segment 2670 that is addressed to a broadcast or multicast address (MUST-57). 2672 This prevents connection state and replies from being erroneously 2673 generated, and implementers should note that this guidance is 2674 applicable to all incoming segments, not just SYNs, as specifically 2675 indicated in RFC 1122. 2677 3.9. Event Processing 2679 The processing depicted in this section is an example of one possible 2680 implementation. Other implementations may have slightly different 2681 processing sequences, but they should differ from those in this 2682 section only in detail, not in substance. 2684 The activity of the TCP endpoint can be characterized as responding 2685 to events. The events that occur can be cast into three categories: 2686 user calls, arriving segments, and timeouts. This section describes 2687 the processing the TCP endpoint does in response to each of the 2688 events. In many cases the processing required depends on the state 2689 of the connection. 2691 Events that occur: 2693 User Calls 2695 OPEN 2696 SEND 2697 RECEIVE 2698 CLOSE 2699 ABORT 2700 STATUS 2702 Arriving Segments 2704 SEGMENT ARRIVES 2706 Timeouts 2708 USER TIMEOUT 2709 RETRANSMISSION TIMEOUT 2710 TIME-WAIT TIMEOUT 2712 The model of the TCP/user interface is that user commands receive an 2713 immediate return and possibly a delayed response via an event or 2714 pseudo interrupt. In the following descriptions, the term "signal" 2715 means cause a delayed response. 2717 Error responses in this document are identified by character strings. 2718 For example, user commands referencing connections that do not exist 2719 receive "error: connection not open". 2721 Please note in the following that all arithmetic on sequence numbers, 2722 acknowledgment numbers, windows, et cetera, is modulo 2**32 the size 2723 of the sequence number space. Also note that "=<" means less than or 2724 equal to (modulo 2**32). 2726 A natural way to think about processing incoming segments is to 2727 imagine that they are first tested for proper sequence number (i.e., 2728 that their contents lie in the range of the expected "receive window" 2729 in the sequence number space) and then that they are generally queued 2730 and processed in sequence number order. 2732 When a segment overlaps other already received segments we 2733 reconstruct the segment to contain just the new data, and adjust the 2734 header fields to be consistent. 2736 Note that if no state change is mentioned the TCP connection stays in 2737 the same state. 2739 OPEN Call 2741 CLOSED STATE (i.e., TCB does not exist) 2743 Create a new transmission control block (TCB) to hold 2744 connection state information. Fill in local socket identifier, 2745 remote socket, DiffServ field, security/compartment, and user 2746 timeout information. Note that some parts of the remote socket 2747 may be unspecified in a passive OPEN and are to be filled in by 2748 the parameters of the incoming SYN segment. Verify the 2749 security and DiffServ value requested are allowed for this 2750 user, if not return "error: precedence not allowed" or "error: 2751 security/compartment not allowed." If passive enter the LISTEN 2752 state and return. If active and the remote socket is 2753 unspecified, return "error: remote socket unspecified"; if 2754 active and the remote socket is specified, issue a SYN segment. 2755 An initial send sequence number (ISS) is selected. A SYN 2756 segment of the form is sent. Set SND.UNA to 2757 ISS, SND.NXT to ISS+1, enter SYN-SENT state, and return. 2759 If the caller does not have access to the local socket 2760 specified, return "error: connection illegal for this process". 2761 If there is no room to create a new connection, return "error: 2762 insufficient resources". 2764 LISTEN STATE 2766 If active and the remote socket is specified, then change the 2767 connection from passive to active, select an ISS. Send a SYN 2768 segment, set SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT 2769 state. Data associated with SEND may be sent with SYN segment 2770 or queued for transmission after entering ESTABLISHED state. 2771 The urgent bit if requested in the command must be sent with 2772 the data segments sent as a result of this command. If there 2773 is no room to queue the request, respond with "error: 2774 insufficient resources". If Foreign socket was not specified, 2775 then return "error: remote socket unspecified". 2777 SYN-SENT STATE 2778 SYN-RECEIVED STATE 2779 ESTABLISHED STATE 2780 FIN-WAIT-1 STATE 2781 FIN-WAIT-2 STATE 2782 CLOSE-WAIT STATE 2783 CLOSING STATE 2784 LAST-ACK STATE 2785 TIME-WAIT STATE 2787 Return "error: connection already exists". 2789 SEND Call 2791 CLOSED STATE (i.e., TCB does not exist) 2793 If the user does not have access to such a connection, then 2794 return "error: connection illegal for this process". 2796 Otherwise, return "error: connection does not exist". 2798 LISTEN STATE 2800 If the remote socket is specified, then change the connection 2801 from passive to active, select an ISS. Send a SYN segment, set 2802 SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT state. Data 2803 associated with SEND may be sent with SYN segment or queued for 2804 transmission after entering ESTABLISHED state. The urgent bit 2805 if requested in the command must be sent with the data segments 2806 sent as a result of this command. If there is no room to queue 2807 the request, respond with "error: insufficient resources". If 2808 Foreign socket was not specified, then return "error: remote 2809 socket unspecified". 2811 SYN-SENT STATE 2812 SYN-RECEIVED STATE 2814 Queue the data for transmission after entering ESTABLISHED 2815 state. If no space to queue, respond with "error: insufficient 2816 resources". 2818 ESTABLISHED STATE 2819 CLOSE-WAIT STATE 2821 Segmentize the buffer and send it with a piggybacked 2822 acknowledgment (acknowledgment value = RCV.NXT). If there is 2823 insufficient space to remember this buffer, simply return 2824 "error: insufficient resources". 2826 If the urgent flag is set, then SND.UP <- SND.NXT and set the 2827 urgent pointer in the outgoing segments. 2829 FIN-WAIT-1 STATE 2830 FIN-WAIT-2 STATE 2831 CLOSING STATE 2832 LAST-ACK STATE 2833 TIME-WAIT STATE 2835 Return "error: connection closing" and do not service request. 2837 RECEIVE Call 2839 CLOSED STATE (i.e., TCB does not exist) 2841 If the user does not have access to such a connection, return 2842 "error: connection illegal for this process". 2844 Otherwise return "error: connection does not exist". 2846 LISTEN STATE 2847 SYN-SENT STATE 2848 SYN-RECEIVED STATE 2850 Queue for processing after entering ESTABLISHED state. If 2851 there is no room to queue this request, respond with "error: 2852 insufficient resources". 2854 ESTABLISHED STATE 2855 FIN-WAIT-1 STATE 2856 FIN-WAIT-2 STATE 2858 If insufficient incoming segments are queued to satisfy the 2859 request, queue the request. If there is no queue space to 2860 remember the RECEIVE, respond with "error: insufficient 2861 resources". 2863 Reassemble queued incoming segments into receive buffer and 2864 return to user. Mark "push seen" (PUSH) if this is the case. 2866 If RCV.UP is in advance of the data currently being passed to 2867 the user notify the user of the presence of urgent data. 2869 When the TCP endpoint takes responsibility for delivering data 2870 to the user that fact must be communicated to the sender via an 2871 acknowledgment. The formation of such an acknowledgment is 2872 described below in the discussion of processing an incoming 2873 segment. 2875 CLOSE-WAIT STATE 2877 Since the remote side has already sent FIN, RECEIVEs must be 2878 satisfied by text already on hand, but not yet delivered to the 2879 user. If no text is awaiting delivery, the RECEIVE will get a 2880 "error: connection closing" response. Otherwise, any remaining 2881 text can be used to satisfy the RECEIVE. 2883 CLOSING STATE 2884 LAST-ACK STATE 2885 TIME-WAIT STATE 2887 Return "error: connection closing". 2889 CLOSE Call 2891 CLOSED STATE (i.e., TCB does not exist) 2893 If the user does not have access to such a connection, return 2894 "error: connection illegal for this process". 2896 Otherwise, return "error: connection does not exist". 2898 LISTEN STATE 2900 Any outstanding RECEIVEs are returned with "error: closing" 2901 responses. Delete TCB, enter CLOSED state, and return. 2903 SYN-SENT STATE 2905 Delete the TCB and return "error: closing" responses to any 2906 queued SENDs, or RECEIVEs. 2908 SYN-RECEIVED STATE 2910 If no SENDs have been issued and there is no pending data to 2911 send, then form a FIN segment and send it, and enter FIN-WAIT-1 2912 state; otherwise queue for processing after entering 2913 ESTABLISHED state. 2915 ESTABLISHED STATE 2917 Queue this until all preceding SENDs have been segmentized, 2918 then form a FIN segment and send it. In any case, enter FIN- 2919 WAIT-1 state. 2921 FIN-WAIT-1 STATE 2922 FIN-WAIT-2 STATE 2924 Strictly speaking, this is an error and should receive a 2925 "error: connection closing" response. An "ok" response would 2926 be acceptable, too, as long as a second FIN is not emitted (the 2927 first FIN may be retransmitted though). 2929 CLOSE-WAIT STATE 2931 Queue this request until all preceding SENDs have been 2932 segmentized; then send a FIN segment, enter LAST-ACK state. 2934 CLOSING STATE 2935 LAST-ACK STATE 2936 TIME-WAIT STATE 2937 Respond with "error: connection closing". 2939 ABORT Call 2941 CLOSED STATE (i.e., TCB does not exist) 2943 If the user should not have access to such a connection, return 2944 "error: connection illegal for this process". 2946 Otherwise return "error: connection does not exist". 2948 LISTEN STATE 2950 Any outstanding RECEIVEs should be returned with "error: 2951 connection reset" responses. Delete TCB, enter CLOSED state, 2952 and return. 2954 SYN-SENT STATE 2956 All queued SENDs and RECEIVEs should be given "connection 2957 reset" notification, delete the TCB, enter CLOSED state, and 2958 return. 2960 SYN-RECEIVED STATE 2961 ESTABLISHED STATE 2962 FIN-WAIT-1 STATE 2963 FIN-WAIT-2 STATE 2964 CLOSE-WAIT STATE 2966 Send a reset segment: 2968 2970 All queued SENDs and RECEIVEs should be given "connection 2971 reset" notification; all segments queued for transmission 2972 (except for the RST formed above) or retransmission should be 2973 flushed, delete the TCB, enter CLOSED state, and return. 2975 CLOSING STATE LAST-ACK STATE TIME-WAIT STATE 2977 Respond with "ok" and delete the TCB, enter CLOSED state, and 2978 return. 2980 STATUS Call 2982 CLOSED STATE (i.e., TCB does not exist) 2984 If the user should not have access to such a connection, return 2985 "error: connection illegal for this process". 2987 Otherwise return "error: connection does not exist". 2989 LISTEN STATE 2991 Return "state = LISTEN", and the TCB pointer. 2993 SYN-SENT STATE 2995 Return "state = SYN-SENT", and the TCB pointer. 2997 SYN-RECEIVED STATE 2999 Return "state = SYN-RECEIVED", and the TCB pointer. 3001 ESTABLISHED STATE 3003 Return "state = ESTABLISHED", and the TCB pointer. 3005 FIN-WAIT-1 STATE 3007 Return "state = FIN-WAIT-1", and the TCB pointer. 3009 FIN-WAIT-2 STATE 3011 Return "state = FIN-WAIT-2", and the TCB pointer. 3013 CLOSE-WAIT STATE 3015 Return "state = CLOSE-WAIT", and the TCB pointer. 3017 CLOSING STATE 3019 Return "state = CLOSING", and the TCB pointer. 3021 LAST-ACK STATE 3023 Return "state = LAST-ACK", and the TCB pointer. 3025 TIME-WAIT STATE 3027 Return "state = TIME-WAIT", and the TCB pointer. 3029 SEGMENT ARRIVES 3031 If the state is CLOSED (i.e., TCB does not exist) then 3033 all data in the incoming segment is discarded. An incoming 3034 segment containing a RST is discarded. An incoming segment not 3035 containing a RST causes a RST to be sent in response. The 3036 acknowledgment and sequence field values are selected to make 3037 the reset sequence acceptable to the TCP endpoint that sent the 3038 offending segment. 3040 If the ACK bit is off, sequence number zero is used, 3042 3044 If the ACK bit is on, 3046 3048 Return. 3050 If the state is LISTEN then 3052 first check for an RST 3054 An incoming RST should be ignored. Return. 3056 second check for an ACK 3058 Any acknowledgment is bad if it arrives on a connection 3059 still in the LISTEN state. An acceptable reset segment 3060 should be formed for any arriving ACK-bearing segment. The 3061 RST should be formatted as follows: 3063 3065 Return. 3067 third check for a SYN 3069 If the SYN bit is set, check the security. If the security/ 3070 compartment on the incoming segment does not exactly match 3071 the security/compartment in the TCB then send a reset and 3072 return. 3074 3076 Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any 3077 other control or text should be queued for processing later. 3078 ISS should be selected and a SYN segment sent of the form: 3080 3082 SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 3083 state should be changed to SYN-RECEIVED. Note that any 3084 other incoming control or data (combined with SYN) will be 3085 processed in the SYN-RECEIVED state, but processing of SYN 3086 and ACK should not be repeated. If the listen was not fully 3087 specified (i.e., the remote socket was not fully specified), 3088 then the unspecified fields should be filled in now. 3090 fourth other text or control 3092 Any other control or text-bearing segment (not containing 3093 SYN) must have an ACK and thus would be discarded by the ACK 3094 processing. An incoming RST segment could not be valid, 3095 since it could not have been sent in response to anything 3096 sent by this incarnation of the connection. So, if this 3097 unlikely condition is reached, the correct behavior is to 3098 drop the segment and return. 3100 If the state is SYN-SENT then 3102 first check the ACK bit 3104 If the ACK bit is set 3106 If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset 3107 (unless the RST bit is set, if so drop the segment and 3108 return) 3110 3112 and discard the segment. Return. 3114 If SND.UNA < SEG.ACK =< SND.NXT then the ACK is 3115 acceptable. Some deployed TCP code has used the check 3116 SEG.ACK == SND.NXT (using "==" rather than "=<", but this 3117 is not appropriate when the stack is capable of sending 3118 data on the SYN, because the TCP peer may not accept and 3119 acknowledge all of the data on the SYN. 3121 second check the RST bit 3123 If the RST bit is set 3124 A potential blind reset attack is described in RFC 5961 3125 [32], with the mitigation that a TCP implementation 3126 SHOULD first check that the sequence number exactly 3127 matches RCV.NXT prior to executing the action in the next 3128 paragraph. 3130 If the ACK was acceptable then signal the user "error: 3131 connection reset", drop the segment, enter CLOSED state, 3132 delete TCB, and return. Otherwise (no ACK) drop the 3133 segment and return. 3135 third check the security 3137 If the security/compartment in the segment does not exactly 3138 match the security/compartment in the TCB, send a reset 3140 If there is an ACK 3142 3144 Otherwise 3146 3148 If a reset was sent, discard the segment and return. 3150 fourth check the SYN bit 3152 This step should be reached only if the ACK is ok, or there 3153 is no ACK, and it the segment did not contain a RST. 3155 If the SYN bit is on and the security/compartment is 3156 acceptable then, RCV.NXT is set to SEG.SEQ+1, IRS is set to 3157 SEG.SEQ. SND.UNA should be advanced to equal SEG.ACK (if 3158 there is an ACK), and any segments on the retransmission 3159 queue that are thereby acknowledged should be removed. 3161 If SND.UNA > ISS (our SYN has been ACKed), change the 3162 connection state to ESTABLISHED, form an ACK segment 3164 3166 and send it. Data or controls that were queued for 3167 transmission may be included. If there are other controls 3168 or text in the segment then continue processing at the sixth 3169 step below where the URG bit is checked, otherwise return. 3171 Otherwise enter SYN-RECEIVED, form a SYN,ACK segment 3172 3174 and send it. Set the variables: 3176 SND.WND <- SEG.WND 3177 SND.WL1 <- SEG.SEQ 3178 SND.WL2 <- SEG.ACK 3180 If there are other controls or text in the segment, queue 3181 them for processing after the ESTABLISHED state has been 3182 reached, return. 3184 Note that it is legal to send and receive application data 3185 on SYN segments (this is the "text in the segment" mentioned 3186 above. There has been significant misinformation and 3187 misunderstanding of this topic historically. Some firewalls 3188 and security devices consider this suspicious. However, the 3189 capability was used in T/TCP [17] and is used in TCP Fast 3190 Open (TFO) [41], so is important for implementations and 3191 network devices to permit. 3193 fifth, if neither of the SYN or RST bits is set then drop the 3194 segment and return. 3196 Otherwise, 3198 first check sequence number 3200 SYN-RECEIVED STATE 3201 ESTABLISHED STATE 3202 FIN-WAIT-1 STATE 3203 FIN-WAIT-2 STATE 3204 CLOSE-WAIT STATE 3205 CLOSING STATE 3206 LAST-ACK STATE 3207 TIME-WAIT STATE 3209 Segments are processed in sequence. Initial tests on 3210 arrival are used to discard old duplicates, but further 3211 processing is done in SEG.SEQ order. If a segment's 3212 contents straddle the boundary between old and new, only the 3213 new parts should be processed. 3215 In general, the processing of received segments MUST be 3216 implemented to aggregate ACK segments whenever possible 3217 (MUST-58). For example, if the TCP endpoint is processing a 3218 series of queued segments, it MUST process them all before 3219 sending any ACK segments (MUST-59). 3221 There are four cases for the acceptability test for an 3222 incoming segment: 3224 Segment Receive Test 3225 Length Window 3226 ------- ------- ------------------------------------------- 3228 0 0 SEG.SEQ = RCV.NXT 3230 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3232 >0 0 not acceptable 3234 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3235 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 3237 In implementing sequence number validation as described 3238 here, please note Appendix A.2. 3240 If the RCV.WND is zero, no segments will be acceptable, but 3241 special allowance should be made to accept valid ACKs, URGs 3242 and RSTs. 3244 If an incoming segment is not acceptable, an acknowledgment 3245 should be sent in reply (unless the RST bit is set, if so 3246 drop the segment and return): 3248 3250 After sending the acknowledgment, drop the unacceptable 3251 segment and return. 3253 Note that for the TIME-WAIT state, there is an improved 3254 algorithm described in [34] for handling incoming SYN 3255 segments, that utilizes timestamps rather than relying on 3256 the sequence number check described here. When the improved 3257 algorithm is implemented, the logic above is not applicable 3258 for incoming SYN segments with timestamp options, received 3259 on a connection in the TIME-WAIT state. 3261 In the following it is assumed that the segment is the 3262 idealized segment that begins at RCV.NXT and does not exceed 3263 the window. One could tailor actual segments to fit this 3264 assumption by trimming off any portions that lie outside the 3265 window (including SYN and FIN), and only processing further 3266 if the segment then begins at RCV.NXT. Segments with higher 3267 beginning sequence numbers SHOULD be held for later 3268 processing (SHLD-31). 3270 second check the RST bit, 3272 RFC 5961 section 3 describes a potential blind reset attack 3273 and optional mitigation approach that SHOULD be implemented. 3274 For stacks implementing RFC 5961, the three checks below 3275 apply, otherwise processesing for these states is indicated 3276 further below. 3278 1) If the RST bit is set and the sequence number is 3279 outside the current receive window, silently drop the 3280 segment. 3282 2) If the RST bit is set and the sequence number exactly 3283 matches the next expected sequence number (RCV.NXT), then 3284 TCP endpoints MUST reset the connection in the manner 3285 prescribed below according to the connection state. 3287 3) If the RST bit is set and the sequence number does not 3288 exactly match the next expected sequence value, yet is 3289 within the current receive window, TCP endpoints MUST 3290 send an acknowledgement (challenge ACK): 3292 3294 After sending the challenge ACK, TCP endpoints MUST drop 3295 the unacceptable segment and stop processing the incoming 3296 packet further. Note that RFC 5961 and Errata ID 4772 3297 contain additional considerations for ACK throttling in 3298 an implementation. 3300 SYN-RECEIVED STATE 3302 If the RST bit is set 3304 If this connection was initiated with a passive OPEN 3305 (i.e., came from the LISTEN state), then return this 3306 connection to LISTEN state and return. The user need 3307 not be informed. If this connection was initiated 3308 with an active OPEN (i.e., came from SYN-SENT state) 3309 then the connection was refused, signal the user 3310 "connection refused". In either case, all segments on 3311 the retransmission queue should be removed. And in 3312 the active OPEN case, enter the CLOSED state and 3313 delete the TCB, and return. 3315 ESTABLISHED 3316 FIN-WAIT-1 3317 FIN-WAIT-2 3318 CLOSE-WAIT 3320 If the RST bit is set then, any outstanding RECEIVEs and 3321 SEND should receive "reset" responses. All segment 3322 queues should be flushed. Users should also receive an 3323 unsolicited general "connection reset" signal. Enter the 3324 CLOSED state, delete the TCB, and return. 3326 CLOSING STATE 3327 LAST-ACK STATE 3328 TIME-WAIT 3330 If the RST bit is set then, enter the CLOSED state, 3331 delete the TCB, and return. 3333 third check security 3335 SYN-RECEIVED 3337 If the security/compartment in the segment does not 3338 exactly match the security/compartment in the TCB then 3339 send a reset, and return. 3341 ESTABLISHED 3342 FIN-WAIT-1 3343 FIN-WAIT-2 3344 CLOSE-WAIT 3345 CLOSING 3346 LAST-ACK 3347 TIME-WAIT 3349 If the security/compartment in the segment does not 3350 exactly match the security/compartment in the TCB then 3351 send a reset, any outstanding RECEIVEs and SEND should 3352 receive "reset" responses. All segment queues should be 3353 flushed. Users should also receive an unsolicited 3354 general "connection reset" signal. Enter the CLOSED 3355 state, delete the TCB, and return. 3357 Note this check is placed following the sequence check to 3358 prevent a segment from an old connection between these ports 3359 with a different security from causing an abort of the 3360 current connection. 3362 fourth, check the SYN bit, 3364 SYN-RECEIVED 3366 If the connection was initiated with a passive OPEN, then 3367 return this connection to the LISTEN state and return. 3368 Otherwise, handle per the directions for synchronized 3369 states below. 3371 ESTABLISHED STATE 3372 FIN-WAIT STATE-1 3373 FIN-WAIT STATE-2 3374 CLOSE-WAIT STATE 3375 CLOSING STATE 3376 LAST-ACK STATE 3377 TIME-WAIT STATE 3379 If the SYN bit is set in these synchronized states, it 3380 may be either a legitimate new connection attempt (e.g. 3381 in the case of TIME-WAIT), an error where the connection 3382 should be reset, or the result of an attack attempt, as 3383 described in RFC 5961 [32]. For the TIME-WAIT state, new 3384 connections can be accepted if the timestamp option is 3385 used and meets expectations (per [34]). For all other 3386 caess, RFC 5961 provides a mitigation that SHOULD be 3387 implemented, though there are alternatives (see 3388 Section 6). RFC 5961 recommends that in these 3389 synchronized states, if the SYN bit is set, irrespective 3390 of the sequence number, TCP endpoints MUST send a 3391 "challenge ACK" to the remote peer: 3393 3395 After sending the acknowledgement, TCP implementations 3396 MUST drop the unacceptable segment and stop processing 3397 further. Note that RFC 5961 and Errata ID 4772 contain 3398 additional ACK throttling notes for an implementation. 3400 For implementations that do not follow RFC 5961, the 3401 original RFC 793 behavior follows in this paragraph. If 3402 the SYN is in the window it is an error, send a reset, 3403 any outstanding RECEIVEs and SEND should receive "reset" 3404 responses, all segment queues should be flushed, the user 3405 should also receive an unsolicited general "connection 3406 reset" signal, enter the CLOSED state, delete the TCB, 3407 and return. 3409 If the SYN is not in the window this step would not be 3410 reached and an ack would have been sent in the first step 3411 (sequence number check). 3413 fifth check the ACK field, 3415 if the ACK bit is off drop the segment and return 3417 if the ACK bit is on 3419 RFC 5961 section 5 describes a potential blind data 3420 injection attack, and mitigation that implementations MAY 3421 choose to include (MAY-12). TCP stacks that implement 3422 RFC 5961 MUST add an input check that the ACK value is 3423 acceptable only if it is in the range of ((SND.UNA - 3424 MAX.SND.WND) =< SEG.ACK =< SND.NXT). All incoming 3425 segments whose ACK value doesn't satisfy the above 3426 condition MUST be discarded and an ACK sent back. The 3427 new state variable MAX.SND.WND is defined as the largest 3428 window that the local sender has ever received from its 3429 peer (subject to window scaling) or may be hard-coded to 3430 a maximum permissible window value. When the ACK value 3431 is acceptable, the processing per-state below applies: 3433 SYN-RECEIVED STATE 3435 If SND.UNA < SEG.ACK =< SND.NXT then enter ESTABLISHED 3436 state and continue processing with variables below set 3437 to: 3439 SND.WND <- SEG.WND 3440 SND.WL1 <- SEG.SEQ 3441 SND.WL2 <- SEG.ACK 3443 If the segment acknowledgment is not acceptable, 3444 form a reset segment, 3446 3448 and send it. 3450 ESTABLISHED STATE 3452 If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- 3453 SEG.ACK. Any segments on the retransmission queue 3454 that are thereby entirely acknowledged are removed. 3455 Users should receive positive acknowledgments for 3456 buffers that have been SENT and fully acknowledged 3457 (i.e., SEND buffer should be returned with "ok" 3458 response). If the ACK is a duplicate (SEG.ACK =< 3459 SND.UNA), it can be ignored. If the ACK acks 3460 something not yet sent (SEG.ACK > SND.NXT) then send 3461 an ACK, drop the segment, and return. 3463 If SND.UNA =< SEG.ACK =< SND.NXT, the send window 3464 should be updated. If (SND.WL1 < SEG.SEQ or (SND.WL1 3465 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- 3466 SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- 3467 SEG.ACK. 3469 Note that SND.WND is an offset from SND.UNA, that 3470 SND.WL1 records the sequence number of the last 3471 segment used to update SND.WND, and that SND.WL2 3472 records the acknowledgment number of the last segment 3473 used to update SND.WND. The check here prevents using 3474 old segments to update the window. 3476 FIN-WAIT-1 STATE 3478 In addition to the processing for the ESTABLISHED 3479 state, if the FIN segment is now acknowledged then 3480 enter FIN-WAIT-2 and continue processing in that 3481 state. 3483 FIN-WAIT-2 STATE 3485 In addition to the processing for the ESTABLISHED 3486 state, if the retransmission queue is empty, the 3487 user's CLOSE can be acknowledged ("ok") but do not 3488 delete the TCB. 3490 CLOSE-WAIT STATE 3492 Do the same processing as for the ESTABLISHED state. 3494 CLOSING STATE 3496 In addition to the processing for the ESTABLISHED 3497 state, if the ACK acknowledges our FIN then enter the 3498 TIME-WAIT state, otherwise ignore the segment. 3500 LAST-ACK STATE 3502 The only thing that can arrive in this state is an 3503 acknowledgment of our FIN. If our FIN is now 3504 acknowledged, delete the TCB, enter the CLOSED state, 3505 and return. 3507 TIME-WAIT STATE 3509 The only thing that can arrive in this state is a 3510 retransmission of the remote FIN. Acknowledge it, and 3511 restart the 2 MSL timeout. 3513 sixth, check the URG bit, 3515 ESTABLISHED STATE 3516 FIN-WAIT-1 STATE 3517 FIN-WAIT-2 STATE 3519 If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and 3520 signal the user that the remote side has urgent data if 3521 the urgent pointer (RCV.UP) is in advance of the data 3522 consumed. If the user has already been signaled (or is 3523 still in the "urgent mode") for this continuous sequence 3524 of urgent data, do not signal the user again. 3526 CLOSE-WAIT STATE 3527 CLOSING STATE 3528 LAST-ACK STATE 3529 TIME-WAIT 3531 This should not occur, since a FIN has been received from 3532 the remote side. Ignore the URG. 3534 seventh, process the segment text, 3536 ESTABLISHED STATE 3537 FIN-WAIT-1 STATE 3538 FIN-WAIT-2 STATE 3540 Once in the ESTABLISHED state, it is possible to deliver 3541 segment text to user RECEIVE buffers. Text from segments 3542 can be moved into buffers until either the buffer is full 3543 or the segment is empty. If the segment empties and 3544 carries a PUSH flag, then the user is informed, when the 3545 buffer is returned, that a PUSH has been received. 3547 When the TCP endpoint takes responsibility for delivering 3548 the data to the user it must also acknowledge the receipt 3549 of the data. 3551 Once the TCP endpoint takes responsibility for the data 3552 it advances RCV.NXT over the data accepted, and adjusts 3553 RCV.WND as appropriate to the current buffer 3554 availability. The total of RCV.NXT and RCV.WND should 3555 not be reduced. 3557 A TCP implementation MAY send an ACK segment 3558 acknowledging RCV.NXT when a valid segment arrives that 3559 is in the window but not at the left window edge (MAY- 3560 13). 3562 Please note the window management suggestions in 3563 Section 3.7. 3565 Send an acknowledgment of the form: 3567 3569 This acknowledgment should be piggybacked on a segment 3570 being transmitted if possible without incurring undue 3571 delay. 3573 CLOSE-WAIT STATE 3574 CLOSING STATE 3575 LAST-ACK STATE 3576 TIME-WAIT STATE 3578 This should not occur, since a FIN has been received from 3579 the remote side. Ignore the segment text. 3581 eighth, check the FIN bit, 3583 Do not process the FIN if the state is CLOSED, LISTEN or 3584 SYN-SENT since the SEG.SEQ cannot be validated; drop the 3585 segment and return. 3587 If the FIN bit is set, signal the user "connection closing" 3588 and return any pending RECEIVEs with same message, advance 3589 RCV.NXT over the FIN, and send an acknowledgment for the 3590 FIN. Note that FIN implies PUSH for any segment text not 3591 yet delivered to the user. 3593 SYN-RECEIVED STATE 3594 ESTABLISHED STATE 3596 Enter the CLOSE-WAIT state. 3598 FIN-WAIT-1 STATE 3599 If our FIN has been ACKed (perhaps in this segment), 3600 then enter TIME-WAIT, start the time-wait timer, turn 3601 off the other timers; otherwise enter the CLOSING 3602 state. 3604 FIN-WAIT-2 STATE 3606 Enter the TIME-WAIT state. Start the time-wait timer, 3607 turn off the other timers. 3609 CLOSE-WAIT STATE 3611 Remain in the CLOSE-WAIT state. 3613 CLOSING STATE 3615 Remain in the CLOSING state. 3617 LAST-ACK STATE 3619 Remain in the LAST-ACK state. 3621 TIME-WAIT STATE 3623 Remain in the TIME-WAIT state. Restart the 2 MSL 3624 time-wait timeout. 3626 and return. 3628 USER TIMEOUT 3630 USER TIMEOUT 3632 For any state if the user timeout expires, flush all queues, 3633 signal the user "error: connection aborted due to user timeout" 3634 in general and for any outstanding calls, delete the TCB, enter 3635 the CLOSED state and return. 3637 RETRANSMISSION TIMEOUT 3639 For any state if the retransmission timeout expires on a 3640 segment in the retransmission queue, send the segment at the 3641 front of the retransmission queue again, reinitialize the 3642 retransmission timer, and return. 3644 TIME-WAIT TIMEOUT 3646 If the time-wait timeout expires on a connection delete the 3647 TCB, enter the CLOSED state and return. 3649 3.10. Glossary 3651 ACK 3652 A control bit (acknowledge) occupying no sequence space, 3653 which indicates that the acknowledgment field of this segment 3654 specifies the next sequence number the sender of this segment 3655 is expecting to receive, hence acknowledging receipt of all 3656 previous sequence numbers. 3658 connection 3659 A logical communication path identified by a pair of sockets. 3661 datagram 3662 A message sent in a packet switched computer communications 3663 network. 3665 Destination Address 3666 The network layer address of the remote endpoint. 3668 FIN 3669 A control bit (finis) occupying one sequence number, which 3670 indicates that the sender will send no more data or control 3671 occupying sequence space. 3673 fragment 3674 A portion of a logical unit of data, in particular an 3675 internet fragment is a portion of an internet datagram. 3677 header 3678 Control information at the beginning of a message, segment, 3679 fragment, packet or block of data. 3681 host 3682 A computer. In particular a source or destination of 3683 messages from the point of view of the communication network. 3685 Identification 3686 An Internet Protocol field. This identifying value assigned 3687 by the sender aids in assembling the fragments of a datagram. 3689 internet address 3690 A network layer address. 3692 internet datagram 3693 The unit of data exchanged between an internet module and the 3694 higher level protocol together with the internet header. 3696 internet fragment 3697 A portion of the data of an internet datagram with an 3698 internet header. 3700 IP 3701 Internet Protocol. See [1] and [12]. 3703 IRS 3704 The Initial Receive Sequence number. The first sequence 3705 number used by the sender on a connection. 3707 ISN 3708 The Initial Sequence Number. The first sequence number used 3709 on a connection, (either ISS or IRS). Selected in a way that 3710 is unique within a given period of time and is unpredictable 3711 to attackers. 3713 ISS 3714 The Initial Send Sequence number. The first sequence number 3715 used by the sender on a connection. 3717 left sequence 3718 This is the next sequence number to be acknowledged by the 3719 data receiving TCP endpoint (or the lowest currently 3720 unacknowledged sequence number) and is sometimes referred to 3721 as the left edge of the send window. 3723 module 3724 An implementation, usually in software, of a protocol or 3725 other procedure. 3727 MSL 3728 Maximum Segment Lifetime, the time a TCP segment can exist in 3729 the internetwork system. Arbitrarily defined to be 2 3730 minutes. 3732 octet 3733 An eight bit byte. 3735 Options 3736 An Option field may contain several options, and each option 3737 may be several octets in length. 3739 packet 3740 A package of data with a header that may or may not be 3741 logically complete. More often a physical packaging than a 3742 logical packaging of data. 3744 port 3745 The portion of a connection identifier used for 3746 demultiplexing connections at an endpoint. 3748 process 3749 A program in execution. A source or destination of data from 3750 the point of view of the TCP endpoint or other host-to-host 3751 protocol. 3753 PUSH 3754 A control bit occupying no sequence space, indicating that 3755 this segment contains data that must be pushed through to the 3756 receiving user. 3758 RCV.NXT 3759 receive next sequence number 3761 RCV.UP 3762 receive urgent pointer 3764 RCV.WND 3765 receive window 3767 receive next sequence number 3768 This is the next sequence number the local TCP endpoint is 3769 expecting to receive. 3771 receive window 3772 This represents the sequence numbers the local (receiving) 3773 TCP endpoint is willing to receive. Thus, the local TCP 3774 endpoint considers that segments overlapping the range 3775 RCV.NXT to RCV.NXT + RCV.WND - 1 carry acceptable data or 3776 control. Segments containing sequence numbers entirely 3777 outside of this range are considered duplicates and 3778 discarded. 3780 RST 3781 A control bit (reset), occupying no sequence space, 3782 indicating that the receiver should delete the connection 3783 without further interaction. The receiver can determine, 3784 based on the sequence number and acknowledgment fields of the 3785 incoming segment, whether it should honor the reset command 3786 or ignore it. In no case does receipt of a segment 3787 containing RST give rise to a RST in response. 3789 SEG.ACK 3790 segment acknowledgment 3792 SEG.LEN 3793 segment length 3795 SEG.SEQ 3796 segment sequence 3798 SEG.UP 3799 segment urgent pointer field 3801 SEG.WND 3802 segment window field 3804 segment 3805 A logical unit of data, in particular a TCP segment is the 3806 unit of data transfered between a pair of TCP modules. 3808 segment acknowledgment 3809 The sequence number in the acknowledgment field of the 3810 arriving segment. 3812 segment length 3813 The amount of sequence number space occupied by a segment, 3814 including any controls that occupy sequence space. 3816 segment sequence 3817 The number in the sequence field of the arriving segment. 3819 send sequence 3820 This is the next sequence number the local (sending) TCP 3821 endpoint will use on the connection. It is initially 3822 selected from an initial sequence number curve (ISN) and is 3823 incremented for each octet of data or sequenced control 3824 transmitted. 3826 send window 3827 This represents the sequence numbers that the remote 3828 (receiving) TCP endpoint is willing to receive. It is the 3829 value of the window field specified in segments from the 3830 remote (data receiving) TCP endpoint. The range of new 3831 sequence numbers that may be emitted by a TCP implementation 3832 lies between SND.NXT and SND.UNA + SND.WND - 1. 3833 (Retransmissions of sequence numbers between SND.UNA and 3834 SND.NXT are expected, of course.) 3836 SND.NXT 3837 send sequence 3839 SND.UNA 3840 left sequence 3842 SND.UP 3843 send urgent pointer 3845 SND.WL1 3846 segment sequence number at last window update 3848 SND.WL2 3849 segment acknowledgment number at last window update 3851 SND.WND 3852 send window 3854 socket (or socket number, or socket address, or socket identifier) 3855 An address that specifically includes a port identifier, that 3856 is, the concatenation of an Internet Address with a TCP port. 3858 Source Address 3859 The network layer address of the sending endpoint. 3861 SYN 3862 A control bit in the incoming segment, occupying one sequence 3863 number, used at the initiation of a connection, to indicate 3864 where the sequence numbering will start. 3866 TCB 3867 Transmission control block, the data structure that records 3868 the state of a connection. 3870 TCP 3871 Transmission Control Protocol: A host-to-host protocol for 3872 reliable communication in internetwork environments. 3874 TOS 3875 Type of Service, an obsoleted IPv4 field. The same header 3876 bits currently are used for the Differentiated Services field 3877 [5] containing the Differentiated Services Code Point (DSCP) 3878 value and the 2-bit ECN codepoint [8]. 3880 Type of Service 3881 An Internet Protocol field that indicates the type of service 3882 for this internet fragment. 3884 URG 3885 A control bit (urgent), occupying no sequence space, used to 3886 indicate that the receiving user should be notified to do 3887 urgent processing as long as there is data to be consumed 3888 with sequence numbers less than the value indicated in the 3889 urgent pointer. 3891 urgent pointer 3892 A control field meaningful only when the URG bit is on. This 3893 field communicates the value of the urgent pointer that 3894 indicates the data octet associated with the sending user's 3895 urgent call. 3897 4. Changes from RFC 793 3899 This document obsoletes RFC 793 as well as RFC 6093 and 6528, which 3900 updated 793. In all cases, only the normative protocol specification 3901 and requirements have been incorporated into this document, and some 3902 informational text with background and rationale may not have been 3903 carried in. The informational content of those documents is still 3904 valuable in learning about and understanding TCP, and they are valid 3905 Informational references, even though their normative content has 3906 been incorporated into this document. 3908 The main body of this document was adapted from RFC 793's Section 3, 3909 titled "FUNCTIONAL SPECIFICATION", with an attempt to keep formatting 3910 and layout as close as possible. 3912 The collection of applicable RFC Errata that have been reported and 3913 either accepted or held for an update to RFC 793 were incorporated 3914 (Errata IDs: 573, 574, 700, 701, 1283, 1561, 1562, 1564, 1565, 1571, 3915 1572, 2296, 2297, 2298, 2748, 2749, 2934, 3213, 3300, 3301, 6222). 3916 Some errata were not applicable due to other changes (Errata IDs: 3917 572, 575, 1569, 3305, 3602). 3919 Changes to the specification of the Urgent Pointer described in RFC 3920 1122 and 6093 were incorporated. See RFC 6093 for detailed 3921 discussion of why these changes were necessary. 3923 The discussion of the RTO from RFC 793 was updated to refer to RFC 3924 6298. The RFC 1122 text on the RTO originally replaced the 793 text, 3925 however, RFC 2988 should have updated 1122, and has subsequently been 3926 obsoleted by 6298. 3928 RFC 1122 contains a collection of other changes and clarifications to 3929 RFC 793. The normative items impacting the protocol have been 3930 incorporated here, though some historically useful implementation 3931 advice and informative discussion from RFC 1122 is not included here. 3933 RFC 1122 contains more than just TCP requirements, so this document 3934 can't obsolete RFC 1122 entirely. It is only marked as "updating" 3935 1122, however, it should be understood to effectively obsolete all of 3936 the RFC 1122 material on TCP. 3938 The more secure Initial Sequence Number generation algorithm from RFC 3939 6528 was incorporated. See RFC 6528 for discussion of the attacks 3940 that this mitigates, as well as advice on selecting PRF algorithms 3941 and managing secret key data. 3943 A note based on RFC 6429 was added to explicitly clarify that system 3944 resource mangement concerns allow connection resources to be 3945 reclaimed. RFC 6429 is obsoleted in the sense that this 3946 clarification has been reflected in this update to the base TCP 3947 specification now. 3949 RFC EDITOR'S NOTE: the content below is for detailed change tracking 3950 and planning, and not to be included with the final revision of the 3951 document. 3953 This document started as draft-eddy-rfc793bis-00, that was merely a 3954 proposal and rough plan for updating RFC 793. 3956 The -01 revision of this draft-eddy-rfc793bis incorporates the 3957 content of RFC 793 Section 3 titled "FUNCTIONAL SPECIFICATION". 3958 Other content from RFC 793 has not been incorporated. The -01 3959 revision of this document makes some minor formatting changes to the 3960 RFC 793 content in order to convert the content into XML2RFC format 3961 and account for left-out parts of RFC 793. For instance, figure 3962 numbering differs and some indentation is not exactly the same. 3964 The -02 revision of draft-eddy-rfc793bis incorporates errata that 3965 have been verified: 3967 Errata ID 573: Reported by Bob Braden (note: This errata basically 3968 is just a reminder that RFC 1122 updates 793. Some of the 3969 associated changes are left pending to a separate revision that 3970 incorporates 1122. Bob's mention of PUSH in 793 section 2.8 was 3971 not applicable here because that section was not part of the 3972 "functional specification". Also the 1122 text on the 3973 retransmission timeout also has been updated by subsequent RFCs, 3974 so the change here deviates from Bob's suggestion to apply the 3975 1122 text.) 3976 Errata ID 574: Reported by Yin Shuming 3977 Errata ID 700: Reported by Yin Shuming 3978 Errata ID 701: Reported by Yin Shuming 3979 Errata ID 1283: Reported by Pei-chun Cheng 3980 Errata ID 1561: Reported by Constantin Hagemeier 3981 Errata ID 1562: Reported by Constantin Hagemeier 3982 Errata ID 1564: Reported by Constantin Hagemeier 3983 Errata ID 1565: Reported by Constantin Hagemeier 3984 Errata ID 1571: Reported by Constantin Hagemeier 3985 Errata ID 1572: Reported by Constantin Hagemeier 3986 Errata ID 2296: Reported by Vishwas Manral 3987 Errata ID 2297: Reported by Vishwas Manral 3988 Errata ID 2298: Reported by Vishwas Manral 3989 Errata ID 2748: Reported by Mykyta Yevstifeyev 3990 Errata ID 2749: Reported by Mykyta Yevstifeyev 3991 Errata ID 2934: Reported by Constantin Hagemeier 3992 Errata ID 3213: Reported by EugnJun Yi 3993 Errata ID 3300: Reported by Botong Huang 3994 Errata ID 3301: Reported by Botong Huang 3995 Errata ID 3305: Reported by Botong Huang 3996 Note: Some verified errata were not used in this update, as they 3997 relate to sections of RFC 793 elided from this document. These 3998 include Errata ID 572, 575, and 1569. 3999 Note: Errata ID 3602 was not applied in this revision as it is 4000 duplicative of the 1122 corrections. 4002 Not related to RFC 793 content, this revision also makes small tweaks 4003 to the introductory text, fixes indentation of the pseudoheader 4004 diagram, and notes that the Security Considerations should also 4005 include privacy, when this section is written. 4007 The -03 revision of draft-eddy-rfc793bis revises all discussion of 4008 the urgent pointer in order to comply with RFC 6093, 1122, and 1011. 4009 Since 1122 held requirements on the urgent pointer, the full list of 4010 requirements was brought into an appendix of this document, so that 4011 it can be updated as-needed. 4013 The -04 revision of draft-eddy-rfc793bis includes the ISN generation 4014 changes from RFC 6528. 4016 The -05 revision of draft-eddy-rfc793bis incorporates MSS 4017 requirements and definitions from RFC 879, 1122, and 6691, as well as 4018 option-handling requirements from RFC 1122. 4020 The -00 revision of draft-ietf-tcpm-rfc793bis incorporates several 4021 additional clarifications and updates to the section on segmentation, 4022 many of which are based on feedback from Joe Touch improving from the 4023 initial text on this in the previous revision. 4025 The -01 revision incorporates the change to Reserved bits due to ECN, 4026 as well as many other changes that come from RFC 1122. 4028 The -02 revision has small formating modifications in order to 4029 address xml2rfc warnings about long lines. It was a quick update to 4030 avoid document expiration. TCPM working group discussion in 2015 4031 also indicated that that we should not try to add sections on 4032 implementation advice or similar non-normative information. 4034 The -03 revision incorporates more content from RFC 1122: Passive 4035 OPEN Calls, Time-To-Live, Multihoming, IP Options, ICMP messages, 4036 Data Communications, When to Send Data, When to Send a Window Update, 4037 Managing the Window, Probing Zero Windows, When to Send an ACK 4038 Segment. The section on data communications was re-organized into 4039 clearer subsections (previously headings were embedded in the 793 4040 text), and windows management advice from 793 was removed (as 4041 reviewed by TCPM working group) in favor of the 1122 additions on 4042 SWS, ZWP, and related topics. 4044 The -04 revision includes reference to RFC 6429 on the ZWP condition, 4045 RFC1122 material on TCP Connection Failures, TCP Keep-Alives, 4046 Acknowledging Queued Segments, and Remote Address Validation. RTO 4047 computation is referenced from RFC 6298 rather than RFC 1122. 4049 The -05 revision includes the requirement to implement TCP congestion 4050 control with recommendation to implemente ECN, the RFC 6633 update to 4051 1122, which changed the requirement on responding to source quench 4052 ICMP messages, and discussion of ICMP (and ICMPv6) soft and hard 4053 errors per RFC 5461 (ICMPv6 handling for TCP doesn't seem to be 4054 mentioned elsewhere in standards track). 4056 The -06 revision includes an appendix on "Other Implementation Notes" 4057 to capture widely-deployed fundamental features that are not 4058 contained in the RFC series yet. It also added mention of RFC 6994 4059 and the IANA TCP parameters registry as a reference. It includes 4060 references to RFC 5961 in appropriate places. The references to TOS 4061 were changed to DiffServ field, based on reflecting RFC 2474 as well 4062 as the IPv6 presence of traffic class (carrying DiffServ field) 4063 rather than TOS. 4065 The -07 revision includes reference to RFC 6191, updated security 4066 considerations, discussion of additional implementation 4067 considerations, and clarification of data on the SYN. 4069 The -08 revision includes changes based on: 4071 describing treatment of reserved bits (following TCPM mailing list 4072 thread from July 2014 on "793bis item - reserved bit behavior" 4073 addition a brief TCP key concepts section to make up for not 4074 including the outdated section 2 of RFC 793 4075 changed "TCP" to "host" to resolve conflict between 1122 wording 4076 on whether TCP or the network layer chooses an address when 4077 multihomed 4078 fixed/updated definition of options in glossary 4079 moved note on aggregating ACKs from 1122 to a more appropriate 4080 location 4081 resolved notes on IP precedence and security/compartment 4082 added implementation note on sequence number validation 4083 added note that PUSH does not apply when Nagle is active 4084 added 1122 content on asynchronous reports to replace 793 section 4085 on TCP to user messages 4087 The -09 revision fixes section numbering problems. 4089 The -10 revision includes additions to the security considerations 4090 based on comments from Joe Touch, and suggested edits on RST/FIN 4091 notification, RFC 2525 reference, and other edits suggested by 4092 Yuchung Cheng, as well as modifications to DiffServ text from Yuchung 4093 Cheng and Gorry Fairhurst. 4095 The -11 revision includes a start at identifying all of the 4096 requirements text and referencing each instance in the common table 4097 at the end of the document. 4099 The -12 revision completes the requirement language indexing started 4100 in -11 and adds necessary description of the PUSH functionality that 4101 was missing. 4103 The -13 revision contains only changes in the inline editor notes. 4105 The -14 revision includes updates with regard to several comments 4106 from the mailing list, including editorial fixes, adding IANA 4107 considerations for the header flags, improving figure title 4108 placement, and breaking up the "Terminology" section into more 4109 appropriately titled subsections. 4111 The -15 revision has many technical and editorial corrections from 4112 Gorry Fairhurst's review, and subsequent discussion on the TCPM list, 4113 as well as some other collected clarifications and improvements from 4114 mailing list discussion. 4116 The -16 revision addresses several discussions that rose from 4117 additional reviews and follow-up on some of Gorry Fairhurst's 4118 comments from revision 14. 4120 The -17 revision includes errata 6222 from Charles Deng, update to 4121 the key words boilerplate, updated description of the header flags 4122 registry changes, and clarification about connections rather than 4123 users in the discussion of OPEN calls. 4125 The -18 revision includes editorial changes to the IANA 4126 considerations, based on comments from Richard Scheffenegger at the 4127 IETF 108 TCPM virtual meeting. 4129 Some other suggested changes that will not be incorporated in this 4130 793 update unless TCPM consensus changes with regard to scope are: 4132 1. Tony Sabatini's suggestion for describing DO field 4133 2. Per discussion with Joe Touch (TAPS list, 6/20/2015), the 4134 description of the API could be revisited 4136 Early in the process of updating RFC 793, Scott Brim mentioned that 4137 this should include a PERPASS/privacy review. This may be something 4138 for the chairs or AD to request during WGLC or IETF LC. 4140 5. IANA Considerations 4142 In the "Transmission Control Protocol (TCP) Header Flags" registry, 4143 IANA is asked to make several changes described in this section. 4145 RFC 3168 originally created this registry, but only populated it with 4146 the new bits defined in RFC 3168, neglecting the other bits that had 4147 previously been described in RFC 793 and other documents. Bit 7 has 4148 since also been updated by RFC 8311. 4150 The "Bit" column is renamed below as the "Bit Offset" column, since 4151 it references each header flag's offset within the 16-bit aligned 4152 view of the TCP header in Figure 1. The bits in offsets 0 through 4 4153 are the TCP segment Data Offset field, and not header flags. 4155 IANA should add a column for "Assignment Notes". 4157 IANA should assign values indicated below. 4159 TCP Header Flags 4161 Bit Name Reference Assignment Notes 4162 Offset 4163 --- ---- --------- ---------------- 4164 4 Reserved (this document) 4165 5 Reserved (this document) 4166 6 Reserved (this document) 4167 7 Reserved [RFC8311] Previously used by Historic [RFC3540] as NS (Nonce Sum) 4168 8 CWR (Congestion Window Reduced) [RFC3168] 4169 9 ECE (ECN-Echo) [RFC3168] 4170 10 Urgent Pointer field significant (URG) (this document) 4171 11 Acknowledgment field significant (ACK) (this document) 4172 12 Push Function (PSH) (this document) 4173 13 Reset the connection (RST) (this document) 4174 14 Synchronize sequence numbers (SYN) (this document) 4175 15 No more data from sender (FIN) (this document) 4176 This TCP Header Flags registry should also be moved to a sub-registry 4177 under the global "Transmission Control Protocol (TCP) Parameters 4178 registry (https://www.iana.org/assignments/tcp-parameters/tcp- 4179 parameters.xhtml). 4181 The registry's Registration Procedure should remain Standards Action, 4182 but the Reference can be updated to this document, and the Note 4183 removed. 4185 6. Security and Privacy Considerations 4187 The TCP design includes only rudimentary security features that 4188 improve the robustness and reliability of connections and application 4189 data transfer, but there are no built-in cryptographic capabilities 4190 to support any form of privacy, authentication, or other typical 4191 security functions. Non-cryptographic enhancements (e.g. [32]) have 4192 been developed to improve robustness of TCP connections to particular 4193 types of attacks, but the applicability and protections of non- 4194 cryptographic enhancements are limited (e.g. see section 1.1 of 4195 [32]). Applications typically utilize lower-layer (e.g. IPsec) and 4196 upper-layer (e.g. TLS) protocols to provide security and privacy for 4197 TCP connections and application data carried in TCP. Methods based 4198 on TCP options have been developed as well, to support some security 4199 capabilities. 4201 In order to fully protect TCP connections (including their control 4202 flags) IPsec or the TCP Authentication Option (TCP-AO) [31] are the 4203 only current effective methods. Other methods discussed in this 4204 section may protect the payload, but either only a subset of the 4205 fields (e.g. tcpcrypt) or none at all (e.g. TLS). Other security 4206 features that have been added to TCP (e.g. ISN generation, sequence 4207 number checks, etc.) are only capable of partially hindering attacks. 4209 Applications using long-lived TCP flows have been vulnerable to 4210 attacks that exploit the processing of control flags described in 4211 earlier TCP specifications [25]. TCP-MD5 was a commonly implemented 4212 TCP option to support authentication for some of these connections, 4213 but had flaws and is now deprecated. TCP-AO provides a capability to 4214 protect long-lived TCP connections from attacks, and has superior 4215 properties to TCP-MD5. It does not provide any privacy for 4216 application data, nor for the TCP headers. 4218 The "tcpcrypt" [52] Experimental extension to TCP provides the 4219 ability to cryptographically protect connection data. Metadata 4220 aspects of the TCP flow are still visible, but the application stream 4221 is well-protected. Within the TCP header, only the urgent pointer 4222 and FIN flag are protected through tcpcrypt. 4224 The TCP Roadmap [42] includes notes about several RFCs related to TCP 4225 security. Many of the enhancements provided by these RFCs have been 4226 integrated into the present document, including ISN generation, 4227 mitigating blind in-window attacks, and improving handling of soft 4228 errors and ICMP packets. These are all discussed in greater detail 4229 in the referenced RFCs that originally described the changes needed 4230 to earlier TCP specifications. Additionally, see RFC 6093 [33] for 4231 discussion of security considerations related to the urgent pointer 4232 field, that has been deprecated. 4234 Since TCP is often used for bulk transfer flows, some attacks are 4235 possible that abuse the TCP congestion control logic. An example is 4236 "ACK-division" attacks. Updates that have been made to the TCP 4237 congestion control specifications include mechanisms like Appropriate 4238 Byte Counting (ABC) [21] that act as mitigations to these attacks. 4240 Other attacks are focused on exhausting the resources of a TCP 4241 server. Examples include SYN flooding [24] or wasting resources on 4242 non-progressing connections [35]. Operating systems commonly 4243 implement mitigations for these attacks. Some common defenses also 4244 utilize proxies, stateful firewalls, and other technologies outside 4245 of the end-host TCP implementation. 4247 7. Acknowledgements 4249 This document is largely a revision of RFC 793, which Jon Postel was 4250 the editor of. Due to his excellent work, it was able to last for 4251 three decades before we felt the need to revise it. 4253 Andre Oppermann was a contributor and helped to edit the first 4254 revision of this document. 4256 We are thankful for the assistance of the IETF TCPM working group 4257 chairs, over the course of work on this document: 4259 Michael Scharf 4260 Yoshifumi Nishida 4261 Pasi Sarolahti 4262 Michael Tuexen 4264 During the discussions of this work on the TCPM mailing list and in 4265 working group meetings, helpful comments, critiques, and reviews were 4266 received from (listed alphabetically): David Borman, Mohamed 4267 Boucadair, Bob Briscoe, Neal Cardwell, Yuchung Cheng, Martin Duke, 4268 Ted Faber, Gorry Fairhurst, Fernando Gont, Rodney Grimes, Mike Kosek, 4269 Kevin Lahey, Kevin Mason, Matt Mathis, Jonathan Morton, Tommy Pauly, 4270 Tom Petch, Hagen Paul Pfeifer, Anthony Sabatini, Michael Scharf, Greg 4271 Skinner, Joe Touch, Michael Tuexen, Reji Varghese, Tim Wicinski, 4272 Lloyd Wood, and Alex Zimmermann. Joe Touch provided additional help 4273 in clarifying the description of segment size parameters and PMTUD/ 4274 PLPMTUD recommendations. 4276 This document includes content from errata that were reported by 4277 (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, 4278 Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta 4279 Yevstifeyev, EungJun Yi, Botong Huang, Charles Deng. 4281 8. References 4283 8.1. Normative References 4285 [1] Postel, J., "Internet Protocol", STD 5, RFC 791, 4286 DOI 10.17487/RFC0791, September 1981, 4287 . 4289 [2] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 4290 DOI 10.17487/RFC1191, November 1990, 4291 . 4293 [3] McCann, J., Deering, S., and J. Mogul, "Path MTU Discovery 4294 for IP version 6", RFC 1981, DOI 10.17487/RFC1981, August 4295 1996, . 4297 [4] Bradner, S., "Key words for use in RFCs to Indicate 4298 Requirement Levels", BCP 14, RFC 2119, 4299 DOI 10.17487/RFC2119, March 1997, 4300 . 4302 [5] Nichols, K., Blake, S., Baker, F., and D. Black, 4303 "Definition of the Differentiated Services Field (DS 4304 Field) in the IPv4 and IPv6 Headers", RFC 2474, 4305 DOI 10.17487/RFC2474, December 1998, 4306 . 4308 [6] Borman, D., Deering, S., and R. Hinden, "IPv6 Jumbograms", 4309 RFC 2675, DOI 10.17487/RFC2675, August 1999, 4310 . 4312 [7] Lahey, K., "TCP Problems with Path MTU Discovery", 4313 RFC 2923, DOI 10.17487/RFC2923, September 2000, 4314 . 4316 [8] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 4317 of Explicit Congestion Notification (ECN) to IP", 4318 RFC 3168, DOI 10.17487/RFC3168, September 2001, 4319 . 4321 [9] Paxson, V., Allman, M., Chu, J., and M. Sargent, 4322 "Computing TCP's Retransmission Timer", RFC 6298, 4323 DOI 10.17487/RFC6298, June 2011, 4324 . 4326 [10] Gont, F., "Deprecation of ICMP Source Quench Messages", 4327 RFC 6633, DOI 10.17487/RFC6633, May 2012, 4328 . 4330 [11] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 4331 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 4332 May 2017, . 4334 [12] Deering, S. and R. Hinden, "Internet Protocol, Version 6 4335 (IPv6) Specification", STD 86, RFC 8200, 4336 DOI 10.17487/RFC8200, July 2017, 4337 . 4339 8.2. Informative References 4341 [13] Postel, J., "Transmission Control Protocol", STD 7, 4342 RFC 793, DOI 10.17487/RFC0793, September 1981, 4343 . 4345 [14] Nagle, J., "Congestion Control in IP/TCP Internetworks", 4346 RFC 896, DOI 10.17487/RFC0896, January 1984, 4347 . 4349 [15] Braden, R., Ed., "Requirements for Internet Hosts - 4350 Communication Layers", STD 3, RFC 1122, 4351 DOI 10.17487/RFC1122, October 1989, 4352 . 4354 [16] Almquist, P., "Type of Service in the Internet Protocol 4355 Suite", RFC 1349, DOI 10.17487/RFC1349, July 1992, 4356 . 4358 [17] Braden, R., "T/TCP -- TCP Extensions for Transactions 4359 Functional Specification", RFC 1644, DOI 10.17487/RFC1644, 4360 July 1994, . 4362 [18] Paxson, V., Allman, M., Dawson, S., Fenner, W., Griner, 4363 J., Heavens, I., Lahey, K., Semke, J., and B. Volz, "Known 4364 TCP Implementation Problems", RFC 2525, 4365 DOI 10.17487/RFC2525, March 1999, 4366 . 4368 [19] Xiao, X., Hannan, A., Paxson, V., and E. Crabbe, "TCP 4369 Processing of the IPv4 Precedence Field", RFC 2873, 4370 DOI 10.17487/RFC2873, June 2000, 4371 . 4373 [20] Balakrishnan, H., Padmanabhan, V., Fairhurst, G., and M. 4374 Sooriyabandara, "TCP Performance Implications of Network 4375 Path Asymmetry", BCP 69, RFC 3449, DOI 10.17487/RFC3449, 4376 December 2002, . 4378 [21] Allman, M., "TCP Congestion Control with Appropriate Byte 4379 Counting (ABC)", RFC 3465, DOI 10.17487/RFC3465, February 4380 2003, . 4382 [22] Fenner, B., "Experimental Values In IPv4, IPv6, ICMPv4, 4383 ICMPv6, UDP, and TCP Headers", RFC 4727, 4384 DOI 10.17487/RFC4727, November 2006, 4385 . 4387 [23] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 4388 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 4389 . 4391 [24] Eddy, W., "TCP SYN Flooding Attacks and Common 4392 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 4393 . 4395 [25] Touch, J., "Defending TCP Against Spoofing Attacks", 4396 RFC 4953, DOI 10.17487/RFC4953, July 2007, 4397 . 4399 [26] Culley, P., Elzur, U., Recio, R., Bailey, S., and J. 4400 Carrier, "Marker PDU Aligned Framing for TCP 4401 Specification", RFC 5044, DOI 10.17487/RFC5044, October 4402 2007, . 4404 [27] Gont, F., "TCP's Reaction to Soft Errors", RFC 5461, 4405 DOI 10.17487/RFC5461, February 2009, 4406 . 4408 [28] StJohns, M., Atkinson, R., and G. Thomas, "Common 4409 Architecture Label IPv6 Security Option (CALIPSO)", 4410 RFC 5570, DOI 10.17487/RFC5570, July 2009, 4411 . 4413 [29] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 4414 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 4415 . 4417 [30] Sandlund, K., Pelletier, G., and L-E. Jonsson, "The RObust 4418 Header Compression (ROHC) Framework", RFC 5795, 4419 DOI 10.17487/RFC5795, March 2010, 4420 . 4422 [31] Touch, J., Mankin, A., and R. Bonica, "The TCP 4423 Authentication Option", RFC 5925, DOI 10.17487/RFC5925, 4424 June 2010, . 4426 [32] Ramaiah, A., Stewart, R., and M. Dalal, "Improving TCP's 4427 Robustness to Blind In-Window Attacks", RFC 5961, 4428 DOI 10.17487/RFC5961, August 2010, 4429 . 4431 [33] Gont, F. and A. Yourtchenko, "On the Implementation of the 4432 TCP Urgent Mechanism", RFC 6093, DOI 10.17487/RFC6093, 4433 January 2011, . 4435 [34] Gont, F., "Reducing the TIME-WAIT State Using TCP 4436 Timestamps", BCP 159, RFC 6191, DOI 10.17487/RFC6191, 4437 April 2011, . 4439 [35] Bashyam, M., Jethanandani, M., and A. Ramaiah, "TCP Sender 4440 Clarification for Persist Condition", RFC 6429, 4441 DOI 10.17487/RFC6429, December 2011, 4442 . 4444 [36] Gont, F. and S. Bellovin, "Defending against Sequence 4445 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 4446 2012, . 4448 [37] Borman, D., "TCP Options and Maximum Segment Size (MSS)", 4449 RFC 6691, DOI 10.17487/RFC6691, July 2012, 4450 . 4452 [38] Touch, J., "Updated Specification of the IPv4 ID Field", 4453 RFC 6864, DOI 10.17487/RFC6864, February 2013, 4454 . 4456 [39] Touch, J., "Shared Use of Experimental TCP Options", 4457 RFC 6994, DOI 10.17487/RFC6994, August 2013, 4458 . 4460 [40] Borman, D., Braden, B., Jacobson, V., and R. 4461 Scheffenegger, Ed., "TCP Extensions for High Performance", 4462 RFC 7323, DOI 10.17487/RFC7323, September 2014, 4463 . 4465 [41] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 4466 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 4467 . 4469 [42] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. 4470 Zimmermann, "A Roadmap for Transmission Control Protocol 4471 (TCP) Specification Documents", RFC 7414, 4472 DOI 10.17487/RFC7414, February 2015, 4473 . 4475 [43] Black, D., Ed. and P. Jones, "Differentiated Services 4476 (Diffserv) and Real-Time Communication", RFC 7657, 4477 DOI 10.17487/RFC7657, November 2015, 4478 . 4480 [44] Fairhurst, G. and M. Welzl, "The Benefits of Using 4481 Explicit Congestion Notification (ECN)", RFC 8087, 4482 DOI 10.17487/RFC8087, March 2017, 4483 . 4485 [45] Fairhurst, G., Ed., Trammell, B., Ed., and M. Kuehlewind, 4486 Ed., "Services Provided by IETF Transport Protocols and 4487 Congestion Control Mechanisms", RFC 8095, 4488 DOI 10.17487/RFC8095, March 2017, 4489 . 4491 [46] Welzl, M., Tuexen, M., and N. Khademi, "On the Usage of 4492 Transport Features Provided by IETF Transport Protocols", 4493 RFC 8303, DOI 10.17487/RFC8303, February 2018, 4494 . 4496 [47] Chown, T., Loughney, J., and T. Winters, "IPv6 Node 4497 Requirements", BCP 220, RFC 8504, DOI 10.17487/RFC8504, 4498 January 2019, . 4500 [48] IANA, "Transmission Control Protocol (TCP) Parameters, 4501 https://www.iana.org/assignments/tcp-parameters/tcp- 4502 parameters.xhtml", 2019. 4504 [49] IANA, "Transmission Control Protocol (TCP) Header Flags, 4505 https://www.iana.org/assignments/tcp-header-flags/tcp- 4506 header-flags.xhtml", 2019. 4508 [50] Gont, F., "Processing of IP Security/Compartment and 4509 Precedence Information by TCP", draft-gont-tcpm-tcp- 4510 seccomp-prec-00 (work in progress), March 2012. 4512 [51] Gont, F. and D. Borman, "On the Validation of TCP Sequence 4513 Numbers", draft-gont-tcpm-tcp-seq-validation-02 (work in 4514 progress), March 2015. 4516 [52] Bittau, A., Giffin, D., Handley, M., Mazieres, D., Slack, 4517 Q., and E. Smith, "Cryptographic protection of TCP Streams 4518 (tcpcrypt)", draft-ietf-tcpinc-tcpcrypt-09 (work in 4519 progress), November 2017. 4521 [53] Touch, J. and W. Eddy, "TCP Extended Data Offset Option", 4522 draft-ietf-tcpm-tcp-edo-10 (work in progress), July 2018. 4524 [54] Minshall, G., "A Proposed Modification to Nagle's 4525 Algorithm", draft-minshall-nagle-01 (work in progress), 4526 June 1999. 4528 [55] Dalal, Y. and C. Sunshine, "Connection Management in 4529 Transport Protocols", Computer Networks Vol. 2, No. 6, pp. 4530 454-473, December 1978. 4532 Appendix A. Other Implementation Notes 4534 This section includes additional notes and references on TCP 4535 implementation decisions that are currently not a part of the RFC 4536 series or included within the TCP standard. These items can be 4537 considered by implementers, but there was not yet a consensus to 4538 include them in the standard. 4540 A.1. IP Security Compartment and Precedence 4542 The IPv4 specification [1] includes a precedence value in the (now 4543 obsoleted) Type of Service field (TOS) field. It was modified in 4544 [16], and then obsoleted by the definition of Differentiated Services 4545 (DiffServ) [5]. Setting and conveying TOS between the network layer, 4546 TCP implementation, and applications is obsolete, and replaced by 4547 DiffServ in the current TCP specification. 4549 RFC 793 requires checking the IP security compartment and precedence 4550 on incoming TCP segments for consistency within a connection, and 4551 with application requests. Each of these aspects of IP have become 4552 outdated, without specific updates to RFC 793. The issues with 4553 precedence were fixed by [19], which is Standards Track, and so this 4554 present TCP specification includes those changes. However, the state 4555 of IP security options that may be used by MLS systems is not as 4556 clean. 4558 Reseting connections when incoming packets do not meet expected 4559 security compartment or precedence expectations has been recognized 4560 as a possible attack vector [50], and there has been discussion about 4561 ammending the TCP specification to prevent connections from being 4562 aborted due to non-matching IP security compartment and DiffServ 4563 codepoint values. 4565 A.1.1. Precedence 4567 In DiffServ the former precedence values are treated as Class 4568 Selector codepoints, and methods for compatible treatment are 4569 described in the DiffServ architecture. The RFC 793/1122 TCP 4570 specification includes logic intending to have connections use the 4571 highest precedence requested by either endpoint application, and to 4572 keep the precedence consistent throughout a connection. This logic 4573 from the obsolete TOS is not applicable for DiffServ, and should not 4574 be included in TCP implementations, though changes to DiffServ values 4575 within a connection are discouraged. For discussion of this, see RFC 4576 7657 (sec 5.1, 5.3, and 6) [43]. 4578 The obsoleted TOS processing rules in TCP assumed bidirectional (or 4579 symmetric) precedence values used on a connection, but the DiffServ 4580 architecture is asymmetric. Problems with the old TCP logic in this 4581 regard were described in [19] and the solution described is to ignore 4582 IP precedence in TCP. Since RFC 2873 is a Standards Track document 4583 (although not marked as updating RFC 793), current implementations 4584 are expected to be robust to these conditions. Note that the 4585 DiffServ field value used in each direction is a part of the 4586 interface between TCP and the network layer, and values in use can be 4587 indicated both ways between TCP and the application. 4589 A.1.2. MLS Systems 4591 The IP security option (IPSO) and compartment defined in [1] was 4592 refined in RFC 1038 that was later obsoleted by RFC 1108. The 4593 Commercial IP Security Option (CIPSO) is defined in FIPS-188, and is 4594 supported by some vendors and operating systems. RFC 1108 is now 4595 Historic, though RFC 791 itself has not been updated to remove the IP 4596 security option. For IPv6, a similar option (CALIPSO) has been 4597 defined [28]. RFC 793 includes logic that includes the IP security/ 4598 compartment information in treatment of TCP segments. References to 4599 the IP "security/compartment" in this document may be relevant for 4600 Multi-Level Secure (MLS) system implementers, but can be ignored for 4601 non-MLS implementations, consistent with running code on the 4602 Internet. See Appendix A.1 for further discussion. Note that RFC 4603 5570 describes some MLS networking scenarios where IPSO, CIPSO, or 4604 CALIPSO may be used. In these special cases, TCP implementers should 4605 see section 7.3.1 of RFC 5570, and follow the guidance in that 4606 document. 4608 A.2. Sequence Number Validation 4610 There are cases where the TCP sequence number validation rules can 4611 prevent ACK fields from being processed. This can result in 4612 connection issues, as described in [51], which includes descriptions 4613 of potential problems in conditions of simultaneous open, self- 4614 connects, simultaneous close, and simultaneous window probes. The 4615 document also describes potential changes to the TCP specification to 4616 mitigate the issue by expanding the acceptable sequence numbers. 4618 In Internet usage of TCP, these conditions are rarely occuring. 4619 Common operating systems include different alternative mitigations, 4620 and the standard has not been updated yet to codify one of them, but 4621 implementers should consider the problems described in [51]. 4623 A.3. Nagle Modification 4625 In common operating systems, both the Nagle algorithm and delayed 4626 acknowledgements are implemented and enabled by default. TCP is used 4627 by many applications that have a request-response style of 4628 communication, where the combination of the Nagle algorithm and 4629 delayed acknowledgements can result in poor application performance. 4630 A modification to the Nagle algorithm is described in [54] that 4631 improves the situation for these applications. 4633 This modification is implemented in some common operating systems, 4634 and does not impact TCP interoperability. Additionally, many 4635 applications simply disable Nagle, since this is generally supported 4636 by a socket option. The TCP standard has not been updated to include 4637 this Nagle modification, but implementers may find it beneficial to 4638 consider. 4640 A.4. Low Water Mark Settings 4642 Some operating system kernel TCP implementations include socket 4643 options that allow specifying the number of bytes in the buffer until 4644 the socket layer will pass sent data to TCP (SO_SNDLOWAT) or to the 4645 application on receiving (SO_RCVLOWAT). 4647 In addition, another socket option (TCP_NOTSENT_LOWAT) can be used to 4648 control the amount of unsent bytes in the write queue. This can help 4649 a sending TCP application to avoid creating large amounts of buffered 4650 data (and corresponding latency). As an example, this may be useful 4651 for applications that are multiplexing data from multiple upper level 4652 streams onto a connection, especially when streams may be a mix of 4653 interactive/realtime and bulk data transfer. 4655 Appendix B. TCP Requirement Summary 4657 This section is adapted from RFC 1122. 4659 Note that there is no requirement related to PLPMTUD in this list, 4660 but that PLPMTUD is recommended. 4662 | | | | |S| | 4663 | | | | |H| |F 4664 | | | | |O|M|o 4665 | | |S| |U|U|o 4666 | | |H| |L|S|t 4667 | |M|O| |D|T|n 4668 | |U|U|M| | |o 4669 | |S|L|A|N|N|t 4670 | |T|D|Y|O|O|t 4671 FEATURE | ReqID | | | |T|T|e 4672 -------------------------------------------------|--------|-|-|-|-|-|-- 4673 | | | | | | | 4674 Push flag | | | | | | | 4675 Aggregate or queue un-pushed data | MAY-16 | | |x| | | 4676 Sender collapse successive PSH flags | SHLD-27| |x| | | | 4677 SEND call can specify PUSH | MAY-15 | | |x| | | 4678 If cannot: sender buffer indefinitely | MUST-60| | | | |x| 4679 If cannot: PSH last segment | MUST-61|x| | | | | 4680 Notify receiving ALP of PSH | MAY-17 | | |x| | |1 4681 Send max size segment when possible | SHLD-28| |x| | | | 4682 | | | | | | | 4683 Window | | | | | | | 4684 Treat as unsigned number | MUST-1 |x| | | | | 4685 Handle as 32-bit number | REC-1 | |x| | | | 4686 Shrink window from right | SHLD-14| | | |x| | 4687 - Send new data when window shrinks | SHLD-15| | | |x| | 4688 - Retransmit old unacked data within window | SHLD-16| |x| | | | 4689 - Time out conn for data past right edge | SHLD-17| | | |x| | 4690 Robust against shrinking window | MUST-34|x| | | | | 4691 Receiver's window closed indefinitely | MAY-8 | | |x| | | 4692 Use standard probing logic | MUST-35|x| | | | | 4693 Sender probe zero window | MUST-36|x| | | | | 4694 First probe after RTO | SHLD-29| |x| | | | 4695 Exponential backoff | SHLD-30| |x| | | | 4696 Allow window stay zero indefinitely | MUST-37|x| | | | | 4697 Retransmit old data beyond SND.UNA+SND.WND | MAY-7 | | |x| | | 4698 Process RST and URG even with zero window | MUST-66|x| | | | | 4699 | | | | | | | 4700 Urgent Data | | | | | | | 4701 Include support for urgent pointer | MUST-30|x| | | | | 4702 Pointer indicates first non-urgent octet | MUST-62|x| | | | | 4703 Arbitrary length urgent data sequence | MUST-31|x| | | | | 4704 Inform ALP asynchronously of urgent data | MUST-32|x| | | | |1 4705 ALP can learn if/how much urgent data Q'd | MUST-33|x| | | | |1 4706 ALP employ the urgent mechanism | SHLD-13| | | |x| | 4707 | | | | | | | 4708 TCP Options | | | | | | | 4709 Support the mandatory option set | MUST-4 |x| | | | | 4710 Receive TCP option in any segment | MUST-5 |x| | | | | 4711 Ignore unsupported options | MUST-6 |x| | | | | 4712 Cope with illegal option length | MUST-7 |x| | | | | 4713 Process options regardless of word alignment | MUST-64|x| | | | | 4714 Implement sending & receiving MSS option | MUST-14|x| | | | | 4715 IPv4 Send MSS option unless 536 | SHLD-5 | |x| | | | 4716 IPv6 Send MSS option unless 1220 | SHLD-5 | |x| | | | 4717 Send MSS option always | MAY-3 | | |x| | | 4718 IPv4 Send-MSS default is 536 | MUST-15|x| | | | | 4719 IPv6 Send-MSS default is 1220 | MUST-15|x| | | | | 4720 Calculate effective send seg size | MUST-16|x| | | | | 4721 MSS accounts for varying MTU | SHLD-6 | |x| | | | 4722 MSS not sent on non-SYN segments | MUST-65| | | | |x| 4723 MSS value based on MMS_R | MUST-67|x| | | | | 4724 | | | | | | | 4725 TCP Checksums | | | | | | | 4726 Sender compute checksum | MUST-2 |x| | | | | 4727 Receiver check checksum | MUST-3 |x| | | | | 4728 | | | | | | | 4729 ISN Selection | | | | | | | 4730 Include a clock-driven ISN generator component | MUST-8 |x| | | | | 4731 Secure ISN generator with a PRF component | SHLD-1 | |x| | | | 4732 PRF computable from outside the host | MUST-9 | | | | |x| 4733 | | | | | | | 4734 Opening Connections | | | | | | | 4735 Support simultaneous open attempts | MUST-10|x| | | | | 4736 SYN-RECEIVED remembers last state | MUST-11|x| | | | | 4737 Passive Open call interfere with others | MUST-41| | | | |x| 4738 Function: simultan. LISTENs for same port | MUST-42|x| | | | | 4739 Ask IP for src address for SYN if necc. | MUST-44|x| | | | | 4740 Otherwise, use local addr of conn. | MUST-45|x| | | | | 4741 OPEN to broadcast/multicast IP Address | MUST-46| | | | |x| 4742 Silently discard seg to bcast/mcast addr | MUST-57|x| | | | | 4743 | | | | | | | 4744 Closing Connections | | | | | | | 4745 RST can contain data | SHLD-2 | |x| | | | 4746 Inform application of aborted conn | MUST-12|x| | | | | 4747 Half-duplex close connections | MAY-1 | | |x| | | 4748 Send RST to indicate data lost | SHLD-3 | |x| | | | 4749 In TIME-WAIT state for 2MSL seconds | MUST-13|x| | | | | 4750 Accept SYN from TIME-WAIT state | MAY-2 | | |x| | | 4751 Use Timestamps to reduce TIME-WAIT | SHLD-4 | |x| | | | 4752 | | | | | | | 4753 Retransmissions | | | | | | | 4754 Implement RFC 5681 | MUST-19|x| | | | | 4755 Retransmit with same IP ident | MAY-4 | | |x| | | 4756 Karn's algorithm | MUST-18|x| | | | | 4757 | | | | | | | 4758 Generating ACK's: | | | | | | | 4759 Aggregate whenever possible | MUST-58|x| | | | | 4760 Queue out-of-order segments | SHLD-31| |x| | | | 4761 Process all Q'd before send ACK | MUST-59|x| | | | | 4762 Send ACK for out-of-order segment | MAY-13 | | |x| | | 4763 Delayed ACK's | SHLD-18| |x| | | | 4764 Delay < 0.5 seconds | MUST-40|x| | | | | 4765 Every 2nd full-sized segment ACK'd | SHLD-19|x| | | | | 4766 Receiver SWS-Avoidance Algorithm | MUST-39|x| | | | | 4767 | | | | | | | 4768 Sending data | | | | | | | 4769 Configurable TTL | MUST-49|x| | | | | 4770 Sender SWS-Avoidance Algorithm | MUST-38|x| | | | | 4771 Nagle algorithm | SHLD-7 | |x| | | | 4772 Application can disable Nagle algorithm | MUST-17|x| | | | | 4773 | | | | | | | 4774 Connection Failures: | | | | | | | 4775 Negative advice to IP on R1 retxs | MUST-20|x| | | | | 4776 Close connection on R2 retxs | MUST-20|x| | | | | 4777 ALP can set R2 | MUST-21|x| | | | |1 4778 Inform ALP of R1<=retxs inform ALP | SHLD-25| |x| | | | 4806 Dest. Unreach (0,1,5) => abort conn | MUST-56| | | | |x| 4807 Dest. Unreach (2-4) => abort conn | SHLD-26| |x| | | | 4808 Source Quench => silent discard | MUST-55|x| | | | | 4809 Time Exceeded => tell ALP, don't abort | MUST-56| | | | |x| 4810 Param Problem => tell ALP, don't abort | MUST-56| | | | |x| 4811 | | | | | | | 4812 Address Validation | | | | | | | 4813 Reject OPEN call to invalid IP address | MUST-46|x| | | | | 4814 Reject SYN from invalid IP address | MUST-63|x| | | | | 4815 Silently discard SYN to bcast/mcast addr | MUST-57|x| | | | | 4816 | | | | | | | 4817 TCP/ALP Interface Services | | | | | | | 4818 Error Report mechanism | MUST-47|x| | | | | 4819 ALP can disable Error Report Routine | SHLD-20| |x| | | | 4820 ALP can specify DiffServ field for sending | MUST-48|x| | | | | 4821 Passed unchanged to IP | SHLD-22| |x| | | | 4822 ALP can change DiffServ field during connection| SHLD-21| |x| | | | 4823 ALP generally changing DiffServ during conn. | SHLD-23| | | |x| | 4824 Pass received DiffServ field up to ALP | MAY-9 | | |x| | | 4825 FLUSH call | MAY-14 | | |x| | | 4826 Optional local IP addr parm. in OPEN | MUST-43|x| | | | | 4827 | | | | | | | 4828 RFC 5961 Support: | | | | | | | 4829 Implement data injection protection | MAY-12 | | |x| | | 4830 | | | | | | | 4831 Explicit Congestion Notification: | | | | | | | 4832 Support ECN | SHLD-8 | |x| | | | 4833 -------------------------------------------------|--------|-|-|-|-|-|- 4835 FOOTNOTES: (1) "ALP" means Application-Layer program. 4837 Author's Address 4839 Wesley M. Eddy (editor) 4840 MTI Systems 4841 US 4843 Email: wes@mti-systems.com