idnits 2.17.1 draft-ietf-tcpm-rfc793bis-19.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 (October 27, 2020) is 1277 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 4225 -- Looks like a reference, but probably isn't: 'RFC3540' on line 4225 -- Looks like a reference, but probably isn't: 'RFC3168' on line 4227 ** 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. '20') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6093 (ref. '35') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6429 (ref. '37') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6528 (ref. '38') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6691 (ref. '39') (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, October 27, 2020 5 6528, 6691 (if approved) 6 Updates: 5961, 1122 (if approved) 7 Intended status: Standards Track 8 Expires: April 30, 2021 10 Transmission Control Protocol (TCP) Specification 11 draft-ietf-tcpm-rfc793bis-19 13 Abstract 15 This document specifies the Transmission Control Protocol (TCP). TCP 16 is an important transport layer protocol in the Internet protocol 17 stack, and has continuously evolved over decades of use and growth of 18 the Internet. Over this time, a number of changes have been made to 19 TCP as it was specified in RFC 793, though these have only been 20 documented in a piecemeal fashion. This document collects and brings 21 those changes together with the protocol specification from RFC 793. 22 This document obsoletes RFC 793, as well as RFCs 879, 2873, 6093, 23 6429, 6528, and 6691 that updated parts of RFC 793. It updates RFC 24 1122, and should be considered as a replacement for the portions of 25 that document dealing with TCP requirements. It also updates RFC 26 5961 by adding a small clarification in reset handling while in the 27 SYN-RECEIVED state. The TCP header control bits from RFC 793 have 28 also been updated based on RFC 3168. 30 RFC EDITOR NOTE: If approved for publication as an RFC, this should 31 be marked additionally as "STD: 7" and replace RFC 793 in that role. 33 Status of This Memo 35 This Internet-Draft is submitted in full conformance with the 36 provisions of BCP 78 and BCP 79. 38 Internet-Drafts are working documents of the Internet Engineering 39 Task Force (IETF). Note that other groups may also distribute 40 working documents as Internet-Drafts. The list of current Internet- 41 Drafts is at https://datatracker.ietf.org/drafts/current/. 43 Internet-Drafts are draft documents valid for a maximum of six months 44 and may be updated, replaced, or obsoleted by other documents at any 45 time. It is inappropriate to use Internet-Drafts as reference 46 material or to cite them other than as "work in progress." 48 This Internet-Draft will expire on April 30, 2021. 50 Copyright Notice 52 Copyright (c) 2020 IETF Trust and the persons identified as the 53 document authors. All rights reserved. 55 This document is subject to BCP 78 and the IETF Trust's Legal 56 Provisions Relating to IETF Documents 57 (https://trustee.ietf.org/license-info) in effect on the date of 58 publication of this document. Please review these documents 59 carefully, as they describe your rights and restrictions with respect 60 to this document. Code Components extracted from this document must 61 include Simplified BSD License text as described in Section 4.e of 62 the Trust Legal Provisions and are provided without warranty as 63 described in the Simplified BSD License. 65 This document may contain material from IETF Documents or IETF 66 Contributions published or made publicly available before November 67 10, 2008. The person(s) controlling the copyright in some of this 68 material may not have granted the IETF Trust the right to allow 69 modifications of such material outside the IETF Standards Process. 70 Without obtaining an adequate license from the person(s) controlling 71 the copyright in such materials, this document may not be modified 72 outside the IETF Standards Process, and derivative works of it may 73 not be created outside the IETF Standards Process, except to format 74 it for publication as an RFC or to translate it into languages other 75 than English. 77 Table of Contents 79 1. Purpose and Scope . . . . . . . . . . . . . . . . . . . . . . 3 80 2. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 81 2.1. Requirements Language . . . . . . . . . . . . . . . . . . 5 82 2.2. Key TCP Concepts . . . . . . . . . . . . . . . . . . . . 5 83 3. Functional Specification . . . . . . . . . . . . . . . . . . 6 84 3.1. Header Format . . . . . . . . . . . . . . . . . . . . . . 6 85 3.2. TCP Terminology Overview . . . . . . . . . . . . . . . . 12 86 3.2.1. Key Connection State Variables . . . . . . . . . . . 12 87 3.2.2. State Machine Overview . . . . . . . . . . . . . . . 14 88 3.3. Sequence Numbers . . . . . . . . . . . . . . . . . . . . 17 89 3.4. Establishing a connection . . . . . . . . . . . . . . . . 24 90 3.5. Closing a Connection . . . . . . . . . . . . . . . . . . 31 91 3.5.1. Half-Closed Connections . . . . . . . . . . . . . . . 33 92 3.6. Segmentation . . . . . . . . . . . . . . . . . . . . . . 34 93 3.6.1. Maximum Segment Size Option . . . . . . . . . . . . . 35 94 3.6.2. Path MTU Discovery . . . . . . . . . . . . . . . . . 37 95 3.6.3. Interfaces with Variable MTU Values . . . . . . . . . 37 96 3.6.4. Nagle Algorithm . . . . . . . . . . . . . . . . . . . 38 97 3.6.5. IPv6 Jumbograms . . . . . . . . . . . . . . . . . . . 38 99 3.7. Data Communication . . . . . . . . . . . . . . . . . . . 38 100 3.7.1. Retransmission Timeout . . . . . . . . . . . . . . . 39 101 3.7.2. TCP Congestion Control . . . . . . . . . . . . . . . 40 102 3.7.3. TCP Connection Failures . . . . . . . . . . . . . . . 40 103 3.7.4. TCP Keep-Alives . . . . . . . . . . . . . . . . . . . 41 104 3.7.5. The Communication of Urgent Information . . . . . . . 42 105 3.7.6. Managing the Window . . . . . . . . . . . . . . . . . 43 106 3.8. Interfaces . . . . . . . . . . . . . . . . . . . . . . . 47 107 3.8.1. User/TCP Interface . . . . . . . . . . . . . . . . . 48 108 3.8.2. TCP/Lower-Level Interface . . . . . . . . . . . . . . 56 109 3.9. Event Processing . . . . . . . . . . . . . . . . . . . . 59 110 3.10. Glossary . . . . . . . . . . . . . . . . . . . . . . . . 84 111 4. Changes from RFC 793 . . . . . . . . . . . . . . . . . . . . 89 112 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 94 113 6. Security and Privacy Considerations . . . . . . . . . . . . . 95 114 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 96 115 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 97 116 8.1. Normative References . . . . . . . . . . . . . . . . . . 97 117 8.2. Informative References . . . . . . . . . . . . . . . . . 98 118 Appendix A. Other Implementation Notes . . . . . . . . . . . . . 103 119 A.1. IP Security Compartment and Precedence . . . . . . . . . 103 120 A.1.1. Precedence . . . . . . . . . . . . . . . . . . . . . 104 121 A.1.2. MLS Systems . . . . . . . . . . . . . . . . . . . . . 104 122 A.2. Sequence Number Validation . . . . . . . . . . . . . . . 105 123 A.3. Nagle Modification . . . . . . . . . . . . . . . . . . . 105 124 A.4. Low Water Mark Settings . . . . . . . . . . . . . . . . . 105 125 Appendix B. TCP Requirement Summary . . . . . . . . . . . . . . 106 126 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 109 128 1. Purpose and Scope 130 In 1981, RFC 793 [13] was released, documenting the Transmission 131 Control Protocol (TCP), and replacing earlier specifications for TCP 132 that had been published in the past. 134 Since then, TCP has been widely implemented, and has been used as a 135 transport protocol for numerous applications on the Internet. 137 For several decades, RFC 793 plus a number of other documents have 138 combined to serve as the core specification for TCP [45]. Over time, 139 a number of errata have been filed against RFC 793, as well as 140 deficiencies in security, performance, and many other aspects. The 141 number of enhancements has grown over time across many separate 142 documents. These were never accumulated together into a 143 comprehensive update to the base specification. 145 The purpose of this document is to bring together all of the IETF 146 Standards Track changes that have been made to the base TCP 147 functional specification and unify them into an update of RFC 793. 149 Some companion documents are referenced for important algorithms that 150 are used by TCP (e.g. for congestion control), but have not been 151 completely included in this document. This is a conscious choice, as 152 this base specification can be used with multiple additional 153 algorithms that are developed and incorporated separately. This 154 document focuses on the common basis all TCP implementations must 155 support in order to interoperate. Since some additional TCP features 156 have become quite complicated themselves (e.g. advanced loss recovery 157 and congestion control), future companion documents may attempt to 158 similarly bring these together. 160 In addition to the protocol specification that describes the TCP 161 segment format, generation, and processing rules that are to be 162 implemented in code, RFC 793 and other updates also contain 163 informative and descriptive text for readers to understand aspects of 164 the protocol design and operation. This document does not attempt to 165 alter or update this informative text, and is focused only on 166 updating the normative protocol specification. This document 167 preserves references to the documentation containing the important 168 explanations and rationale, where appropriate. 170 This document is intended to be useful both in checking existing TCP 171 implementations for conformance purposes, as well as in writing new 172 implementations. 174 2. Introduction 176 RFC 793 contains a discussion of the TCP design goals and provides 177 examples of its operation, including examples of connection 178 establishment, connection termination, packet retransmion to repair 179 losses. 181 This document describes the basic functionality expected in modern 182 TCP implementations, and replaces the protocol specification in RFC 183 793. It does not replicate or attempt to update the introduction and 184 philosophy content in Sections 1 and 2 of RFC 793. Other documents 185 are referenced to provide explanation of the theory of operation, 186 rationale, and detailed discussion of design decisions. This 187 document only focuses on the normative behavior of the protocol. 189 The "TCP Roadmap" [45] provides a more extensive guide to the RFCs 190 that define TCP and describe various important algorithms. The TCP 191 Roadmap contains sections on strongly encouraged enhancements that 192 improve performance and other aspects of TCP beyond the basic 193 operation specified in this document. As one example, implementing 194 congestion control (e.g. [31]) is a TCP requirement, but is a complex 195 topic on its own, and not described in detail in this document, as 196 there are many options and possibilities that do not impact basic 197 interoperability. Similarly, most TCP implementations today include 198 the high-performance extensions in [43], but these are not strictly 199 required or discussed in this document. Multipath considerations for 200 TCP are also specified separately in [51]. 202 A list of changes from RFC 793 is contained in Section 4. 204 2.1. Requirements Language 206 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 207 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 208 "OPTIONAL" in this document are to be interpreted as described in BCP 209 14 [4][11] when, and only when, they appear in all capitals, as shown 210 here. 212 Each use of RFC 2119 keywords in the document is individually labeled 213 and referenced in Appendix B that summarizes implementation 214 requirements. 216 Sentences using "MUST" are labeled as "MUST-X" with X being a numeric 217 identifier enabling the requirement to be located easily when 218 referenced from Appendix B. 220 Similarly, sentences using "SHOULD" are labeled with "SHLD-X", "MAY" 221 with "MAY-X", and "RECOMMENDED" with "REC-X". 223 For the purposes of this labeling, "SHOULD NOT" and "MUST NOT" are 224 labeled the same as "SHOULD" and "MUST" instances. 226 2.2. Key TCP Concepts 228 TCP provides a reliable, in-order, byte-stream service to 229 applications. 231 The application byte-stream is conveyed over the network via TCP 232 segments, with each TCP segment sent as an Internet Protocol (IP) 233 datagram. 235 TCP reliability consists of detecting packet losses (via sequence 236 numbers) and errors (via per-segment checksums), as well as 237 correction via retransmission. 239 TCP supports unicast delivery of data. Anycast applications exist 240 that successfully use TCP without modifications, though there is some 241 risk of instability due to changes of lower-layer forwarding behavior 242 [42]. 244 TCP is connection-oriented, though does not inherently include a 245 liveness detection capability. 247 Data flow is supported bidirectionally over TCP connections, though 248 applications are free to send data only unidirectionally, if they so 249 choose. 251 TCP uses port numbers to identify application services and to 252 multiplex distinct flows between hosts. 254 A more detailed description of TCP features compared to other 255 transport protocols can be found in Section 3.1 of [48]. Further 256 description of the motivations for developing TCP and its role in the 257 Internet protocol stack can be found in Section 2 of [13] and earlier 258 versions of the TCP specification. 260 3. Functional Specification 262 3.1. Header Format 264 TCP segments are sent as internet datagrams. The Internet Protocol 265 (IP) header carries several information fields, including the source 266 and destination host addresses [1] [12]. A TCP header follows the IP 267 headers, supplying information specific to the TCP protocol. This 268 division allows for the existence of host level protocols other than 269 TCP. In early development of the Internet suite of protocols, the IP 270 header fields had been a part of TCP. 272 0 1 2 3 273 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 274 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 275 | Source Port | Destination Port | 276 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 277 | Sequence Number | 278 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 279 | Acknowledgment Number | 280 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 281 | Data | |C|E|U|A|P|R|S|F| | 282 | Offset| Rsrvd |W|C|R|C|S|S|Y|I| Window | 283 | | |R|E|G|K|H|T|N|N| | 284 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 285 | Checksum | Urgent Pointer | 286 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 287 | Options | Padding | 288 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 289 | Data | 290 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 292 Note that one tick mark represents one bit position. 294 Figure 1: TCP Header Format 296 Each of the TCP header fields is described as follows: 298 Source Port: 16 bits 300 The source port number. 302 Destination Port: 16 bits 304 The destination port number. 306 Sequence Number: 32 bits 308 The sequence number of the first data octet in this segment (except 309 when the SYN flag is set). If SYN is set the sequence number is 310 the initial sequence number (ISN) and the first data octet is 311 ISN+1. 313 Acknowledgment Number: 32 bits 315 If the ACK control bit is set, this field contains the value of the 316 next sequence number the sender of the segment is expecting to 317 receive. Once a connection is established, this is always sent. 319 Data Offset: 4 bits 320 The number of 32 bit words in the TCP Header. This indicates where 321 the data begins. The TCP header (even one including options) is an 322 integral number of 32 bits long. 324 Rsrvd - Reserved: 4 bits 326 A set of control bits reserved for future use. Must be zero in 327 generated segments and must be ignored in received segments, if 328 corresponding future features are unimplemented by the sending or 329 receiving host. 331 The control bits are also know as "flags". Assignment is managed 332 by IANA from the "TCP Header Flags" registry [53]. 334 Control Bits: 8 bits (from left to right) of currently assigned 335 control bits: 337 CWR: Congestion Window Reduced (see [8]) 338 ECE: ECN-Echo (see [8]) 339 URG: Urgent Pointer field significant 340 ACK: Acknowledgment field significant 341 PSH: Push Function (see the Send Call description in 342 Section 3.8.1) 343 RST: Reset the connection 344 SYN: Synchronize sequence numbers 345 FIN: No more data from sender 347 Window: 16 bits 349 The number of data octets beginning with the one indicated in the 350 acknowledgment field that the sender of this segment is willing to 351 accept. 353 The window size MUST be treated as an unsigned number, or else 354 large window sizes will appear like negative windows and TCP will 355 not work (MUST-1). It is RECOMMENDED that implementations will 356 reserve 32-bit fields for the send and receive window sizes in the 357 connection record and do all window computations with 32 bits (REC- 358 1). 360 Checksum: 16 bits 362 The checksum field is the 16 bit one's complement of the one's 363 complement sum of all 16 bit words in the header and text. The 364 checksum computation needs to ensure the 16-bit alignment of the 365 data being summed. If a segment contains an odd number of header 366 and text octets, alignment can be achieved by padding the last 367 octet with zeros on its right to form a 16 bit word for checksum 368 purposes. The pad is not transmitted as part of the segment. 369 While computing the checksum, the checksum field itself is replaced 370 with zeros. 372 The checksum also covers a pseudo header (Figure 2) conceptually 373 prefixed to the TCP header. The pseudo header is 96 bits for IPv4 374 and 320 bits for IPv6. Including the pseudo header in the checksum 375 gives the TCP connection protection against misrouted segments. 376 This information is carried in IP headers and is transferred across 377 the TCP/Network interface in the arguments or results of calls by 378 the TCP implementation on the IP layer. 380 +--------+--------+--------+--------+ 381 | Source Address | 382 +--------+--------+--------+--------+ 383 | Destination Address | 384 +--------+--------+--------+--------+ 385 | zero | PTCL | TCP Length | 386 +--------+--------+--------+--------+ 388 Figure 2: IPv4 Pseudo Header 390 Psuedo header components: 392 Source Address: the IPv4 source address in network byte order 394 Destination Address: the IPv4 destination address in network 395 byte order 397 zero: bits set to zero 399 PTCL: the protocol number from the IP header 401 TCP Length: the TCP header length plus the data length in octets 402 (this is not an explicitly transmitted quantity, but is 403 computed), and it does not count the 12 octets of the pseudo 404 header. 406 For IPv6, the pseudo header is defined in Section 8.1 of RFC 8200 407 [12], and contains the IPv6 Source Address and Destination Address, 408 an Upper Layer Packet Length (a 32-bit value otherwise equivalent 409 to TCP Length in the IPv4 pseudo header), three bytes of zero- 410 padding, and a Next Header value (differing from the IPv6 header 411 value in the case of extension headers present in between IPv6 and 412 TCP). 414 The TCP checksum is never optional. The sender MUST generate it 415 (MUST-2) and the receiver MUST check it (MUST-3). 417 Urgent Pointer: 16 bits 419 This field communicates the current value of the urgent pointer as 420 a positive offset from the sequence number in this segment. The 421 urgent pointer points to the sequence number of the octet following 422 the urgent data. This field is only be interpreted in segments 423 with the URG control bit set. 425 Options: variable 427 Options may occupy space at the end of the TCP header and are a 428 multiple of 8 bits in length. All options are included in the 429 checksum. An option may begin on any octet boundary. There are 430 two cases for the format of an option: 432 Case 1: A single octet of option-kind. 434 Case 2: An octet of option-kind (Kind), an octet of option- 435 length, and the actual option-data octets. 437 The option-length counts the two octets of option-kind and option- 438 length as well as the option-data octets. 440 Note that the list of options may be shorter than the data offset 441 field might imply. The content of the header beyond the End-of- 442 Option option must be header padding (i.e., zero). 444 The list of all currently defined options is managed by IANA [52], 445 and each option is defined in other RFCs, as indicated there. That 446 set includes experimental options that can be extended to support 447 multiple concurrent usages [41]. 449 A given TCP implementation can support any currently defined 450 options, but the following options MUST be supported (MUST-4) (kind 451 indicated in octal): 453 Kind Length Meaning 454 ---- ------ ------- 455 0 - End of option list. 456 1 - No-Operation. 457 2 4 Maximum Segment Size. 459 A TCP implementation MUST be able to receive a TCP option in any 460 segment (MUST-5). 461 A TCP implementation MUST (MUST-6) ignore without error any TCP 462 option it does not implement, assuming that the option has a length 463 field (all TCP options except End of option list and No-Operation 464 MUST have length fields). TCP implementations MUST be prepared to 465 handle an illegal option length (e.g., zero); a suggested procedure 466 is to reset the connection and log the error cause (MUST-7). 468 Note: There is ongoing work to extend the space available for TCP 469 options, such as [57]. 471 Specific Option Definitions 473 End of Option List 475 +--------+ 476 |00000000| 477 +--------+ 478 Kind=0 480 This option code indicates the end of the option list. This 481 might not coincide with the end of the TCP header according to 482 the Data Offset field. This is used at the end of all options, 483 not the end of each option, and need only be used if the end of 484 the options would not otherwise coincide with the end of the TCP 485 header. 487 No-Operation 489 +--------+ 490 |00000001| 491 +--------+ 492 Kind=1 494 This option code can be used between options, for example, to 495 align the beginning of a subsequent option on a word boundary. 496 There is no guarantee that senders will use this option, so 497 receivers MUST be prepared to process options even if they do 498 not begin on a word boundary (MUST-64). 500 Maximum Segment Size (MSS) 502 +--------+--------+---------+--------+ 503 |00000010|00000100| max seg size | 504 +--------+--------+---------+--------+ 505 Kind=2 Length=4 507 Maximum Segment Size Option Data: 16 bits 509 If this option is present, then it communicates the maximum 510 receive segment size at the TCP endpoint that sends this 511 segment. This value is limited by the IP reassembly limit. 512 This field may be sent in the initial connection request (i.e., 513 in segments with the SYN control bit set) and MUST NOT be sent 514 in other segments (MUST-65). If this option is not used, any 515 segment size is allowed. A more complete description of this 516 option is provided in Section 3.6.1. 518 Other Common Options 520 Additional RFCs define some other commonly used options that are 521 recommended to implement. These are the TCP Selective 522 Acknowledgement (SACK) option [18][21], TCP Timestamp (TS) 523 option [43], and TCP Window Scaling (WS) option [43]. 525 Experimental TCP Options 527 Experimental TCP option values are defined in [24], and [41] 528 describes the current recommended usage for these experimental 529 values. 531 Padding: variable 533 Padding is used to ensure that the TCP header ends and data begins 534 on a 32 bit boundary. The padding is composed of zeros. 536 3.2. TCP Terminology Overview 538 This section includes an overview of key terms needed to understand 539 the detailed protocol operation in the rest of the document. There 540 is a traditional glossary of terms in Section 3.10. 542 3.2.1. Key Connection State Variables 544 Before we can discuss very much about the operation of the TCP 545 implementation we need to introduce some detailed terminology. The 546 maintenance of a TCP connection requires the remembering of several 547 variables. We conceive of these variables being stored in a 548 connection record called a Transmission Control Block or TCB. Among 549 the variables stored in the TCB are the local and remote IP addresses 550 and port numbers, the IP security level and compartment of the 551 connection (see Appendix A.1), pointers to the user's send and 552 receive buffers, pointers to the retransmit queue and to the current 553 segment. In addition several variables relating to the send and 554 receive sequence numbers are stored in the TCB. 556 Send Sequence Variables: 558 SND.UNA - send unacknowledged 559 SND.NXT - send next 560 SND.WND - send window 561 SND.UP - send urgent pointer 562 SND.WL1 - segment sequence number used for last window update 563 SND.WL2 - segment acknowledgment number used for last window 564 update 565 ISS - initial send sequence number 567 Receive Sequence Variables: 569 RCV.NXT - receive next 570 RCV.WND - receive window 571 RCV.UP - receive urgent pointer 572 IRS - initial receive sequence number 574 The following diagrams may help to relate some of these variables to 575 the sequence space. 577 1 2 3 4 578 ----------|----------|----------|---------- 579 SND.UNA SND.NXT SND.UNA 580 +SND.WND 582 1 - old sequence numbers that have been acknowledged 583 2 - sequence numbers of unacknowledged data 584 3 - sequence numbers allowed for new data transmission 585 4 - future sequence numbers that are not yet allowed 587 Figure 3: Send Sequence Space 589 The send window is the portion of the sequence space labeled 3 in 590 Figure 3. 592 1 2 3 593 ----------|----------|---------- 594 RCV.NXT RCV.NXT 595 +RCV.WND 597 1 - old sequence numbers that have been acknowledged 598 2 - sequence numbers allowed for new reception 599 3 - future sequence numbers that are not yet allowed 601 Figure 4: Receive Sequence Space 603 The receive window is the portion of the sequence space labeled 2 in 604 Figure 4. 606 There are also some variables used frequently in the discussion that 607 take their values from the fields of the current segment. 609 Current Segment Variables: 611 SEG.SEQ - segment sequence number 612 SEG.ACK - segment acknowledgment number 613 SEG.LEN - segment length 614 SEG.WND - segment window 615 SEG.UP - segment urgent pointer 617 3.2.2. State Machine Overview 619 A connection progresses through a series of states during its 620 lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, 621 ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, 622 TIME-WAIT, and the fictional state CLOSED. CLOSED is fictional 623 because it represents the state when there is no TCB, and therefore, 624 no connection. Briefly the meanings of the states are: 626 LISTEN - represents waiting for a connection request from any 627 remote TCP peer and port. 629 SYN-SENT - represents waiting for a matching connection request 630 after having sent a connection request. 632 SYN-RECEIVED - represents waiting for a confirming connection 633 request acknowledgment after having both received and sent a 634 connection request. 636 ESTABLISHED - represents an open connection, data received can be 637 delivered to the user. The normal state for the data transfer 638 phase of the connection. 640 FIN-WAIT-1 - represents waiting for a connection termination 641 request from the remote TCP peer, or an acknowledgment of the 642 connection termination request previously sent. 644 FIN-WAIT-2 - represents waiting for a connection termination 645 request from the remote TCP peer. 647 CLOSE-WAIT - represents waiting for a connection termination 648 request from the local user. 650 CLOSING - represents waiting for a connection termination request 651 acknowledgment from the remote TCP peer. 653 LAST-ACK - represents waiting for an acknowledgment of the 654 connection termination request previously sent to the remote TCP 655 peer (this termination request sent to the remote TCP peer already 656 included an acknowledgment of the termination request sent from 657 the remote TCP peer). 659 TIME-WAIT - represents waiting for enough time to pass to be sure 660 the remote TCP peer received the acknowledgment of its connection 661 termination request, and to avoid new connections being impacted 662 by delayed segments from previous connections. 664 CLOSED - represents no connection state at all. 666 A TCP connection progresses from one state to another in response to 667 events. The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, 668 ABORT, and STATUS; the incoming segments, particularly those 669 containing the SYN, ACK, RST and FIN flags; and timeouts. 671 The state diagram in Figure 5 illustrates only state changes, 672 together with the causing events and resulting actions, but addresses 673 neither error conditions nor actions that are not connected with 674 state changes. In a later section, more detail is offered with 675 respect to the reaction of the TCP implementation to events. Some 676 state names are abbreviated or hyphenated differently in the diagram 677 from how they appear elsewhere in the document. 679 NOTA BENE: This diagram is only a summary and must not be taken as 680 the total specification. Many details are not included. 682 +---------+ ---------\ active OPEN 683 | CLOSED | \ ----------- 684 +---------+<---------\ \ create TCB 685 | ^ \ \ snd SYN 686 passive OPEN | | CLOSE \ \ 687 ------------ | | ---------- \ \ 688 create TCB | | delete TCB \ \ 689 V | \ \ 690 rcv RST (note 1) +---------+ CLOSE | \ 691 -------------------->| LISTEN | ---------- | | 692 / +---------+ delete TCB | | 693 / rcv SYN | | SEND | | 694 / ----------- | | ------- | V 695 +--------+ snd SYN,ACK / \ snd SYN +--------+ 696 | |<----------------- ------------------>| | 697 | SYN | rcv SYN | SYN | 698 | RCVD |<-----------------------------------------------| SENT | 699 | | snd SYN,ACK | | 700 | |------------------ -------------------| | 701 +--------+ rcv ACK of SYN \ / rcv SYN,ACK +--------+ 702 | -------------- | | ----------- 703 | x | | snd ACK 704 | V V 705 | CLOSE +---------+ 706 | ------- | ESTAB | 707 | snd FIN +---------+ 708 | CLOSE | | rcv FIN 709 V ------- | | ------- 710 +---------+ snd FIN / \ snd ACK +---------+ 711 | FIN |<---------------- ------------------>| CLOSE | 712 | WAIT-1 |------------------ | WAIT | 713 +---------+ rcv FIN \ +---------+ 714 | rcv ACK of FIN ------- | CLOSE | 715 | -------------- snd ACK | ------- | 716 V x V snd FIN V 717 +---------+ +---------+ +---------+ 718 |FINWAIT-2| | CLOSING | | LAST-ACK| 719 +---------+ +---------+ +---------+ 720 | rcv ACK of FIN | rcv ACK of FIN | 721 | rcv FIN -------------- | Timeout=2MSL -------------- | 722 | ------- x V ------------ x V 723 \ snd ACK +---------+delete TCB +---------+ 724 -------------------->|TIME-WAIT|------------------->| CLOSED | 725 +---------+ +---------+ 727 Figure 5: TCP Connection State Diagram 729 The following notes apply to Figure 5: 731 Note 1: The transition from SYN-RECEIVED to LISTEN on receiving a 732 RST is conditional on having reached SYN-RECEIVED after a passive 733 open. 735 Note 2: An unshown transition exists from FIN-WAIT-1 to TIME-WAIT 736 if a FIN is received and the local FIN is also acknowledged. 738 Note 3: A RST can be sent from any state with a corresponding 739 transition to TIME-WAIT (see [60] for rationale). These 740 transitions are not not explicitly shown, otherwise the diagram 741 would become very difficult to read. Similarly, receipt of a RST 742 from any state results in a transition to LISTEN or CLOSED, though 743 this is also omitted from the diagram for legibility. 745 3.3. Sequence Numbers 747 A fundamental notion in the design is that every octet of data sent 748 over a TCP connection has a sequence number. Since every octet is 749 sequenced, each of them can be acknowledged. The acknowledgment 750 mechanism employed is cumulative so that an acknowledgment of 751 sequence number X indicates that all octets up to but not including X 752 have been received. This mechanism allows for straight-forward 753 duplicate detection in the presence of retransmission. Numbering of 754 octets within a segment is that the first data octet immediately 755 following the header is the lowest numbered, and the following octets 756 are numbered consecutively. 758 It is essential to remember that the actual sequence number space is 759 finite, though very large. This space ranges from 0 to 2**32 - 1. 760 Since the space is finite, all arithmetic dealing with sequence 761 numbers must be performed modulo 2**32. This unsigned arithmetic 762 preserves the relationship of sequence numbers as they cycle from 763 2**32 - 1 to 0 again. There are some subtleties to computer modulo 764 arithmetic, so great care should be taken in programming the 765 comparison of such values. The symbol "=<" means "less than or 766 equal" (modulo 2**32). 768 The typical kinds of sequence number comparisons that the TCP 769 implementation must perform include: 771 (a) Determining that an acknowledgment refers to some sequence 772 number sent but not yet acknowledged. 774 (b) Determining that all sequence numbers occupied by a segment 775 have been acknowledged (e.g., to remove the segment from a 776 retransmission queue). 778 (c) Determining that an incoming segment contains sequence numbers 779 that are expected (i.e., that the segment "overlaps" the receive 780 window). 782 In response to sending data the TCP endpoint will receive 783 acknowledgments. The following comparisons are needed to process the 784 acknowledgments. 786 SND.UNA = oldest unacknowledged sequence number 788 SND.NXT = next sequence number to be sent 790 SEG.ACK = acknowledgment from the receiving TCP peer (next 791 sequence number expected by the receiving TCP peer) 793 SEG.SEQ = first sequence number of a segment 795 SEG.LEN = the number of octets occupied by the data in the segment 796 (counting SYN and FIN) 798 SEG.SEQ+SEG.LEN-1 = last sequence number of a segment 800 A new acknowledgment (called an "acceptable ack"), is one for which 801 the inequality below holds: 803 SND.UNA < SEG.ACK =< SND.NXT 805 A segment on the retransmission queue is fully acknowledged if the 806 sum of its sequence number and length is less or equal than the 807 acknowledgment value in the incoming segment. 809 When data is received the following comparisons are needed: 811 RCV.NXT = next sequence number expected on an incoming segments, 812 and is the left or lower edge of the receive window 814 RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming 815 segment, and is the right or upper edge of the receive window 817 SEG.SEQ = first sequence number occupied by the incoming segment 819 SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming 820 segment 822 A segment is judged to occupy a portion of valid receive sequence 823 space if 825 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 827 or 829 RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 831 The first part of this test checks to see if the beginning of the 832 segment falls in the window, the second part of the test checks to 833 see if the end of the segment falls in the window; if the segment 834 passes either part of the test it contains data in the window. 836 Actually, it is a little more complicated than this. Due to zero 837 windows and zero length segments, we have four cases for the 838 acceptability of an incoming segment: 840 Segment Receive Test 841 Length Window 842 ------- ------- ------------------------------------------- 844 0 0 SEG.SEQ = RCV.NXT 846 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 848 >0 0 not acceptable 850 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 851 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 853 Note that when the receive window is zero no segments should be 854 acceptable except ACK segments. Thus, it is possible for a TCP 855 implementation to maintain a zero receive window while transmitting 856 data and receiving ACKs. A TCP receiver MUST process the RST and URG 857 fields of all incoming segments, even when the receive window is zero 858 (MUST-66). 860 We have taken advantage of the numbering scheme to protect certain 861 control information as well. This is achieved by implicitly 862 including some control flags in the sequence space so they can be 863 retransmitted and acknowledged without confusion (i.e., one and only 864 one copy of the control will be acted upon). Control information is 865 not physically carried in the segment data space. Consequently, we 866 must adopt rules for implicitly assigning sequence numbers to 867 control. The SYN and FIN are the only controls requiring this 868 protection, and these controls are used only at connection opening 869 and closing. For sequence number purposes, the SYN is considered to 870 occur before the first actual data octet of the segment in which it 871 occurs, while the FIN is considered to occur after the last actual 872 data octet in a segment in which it occurs. The segment length 873 (SEG.LEN) includes both data and sequence space occupying controls. 874 When a SYN is present then SEG.SEQ is the sequence number of the SYN. 876 Initial Sequence Number Selection 878 A connection is defined by a pair of sockets. Connections can be 879 reused. New instances of a connection will be referred to as 880 incarnations of the connection. The problem that arises from this is 881 -- "how does the TCP implementation identify duplicate segments from 882 previous incarnations of the connection?" This problem becomes 883 apparent if the connection is being opened and closed in quick 884 succession, or if the connection breaks with loss of memory and is 885 then reestablished. To support this, the TIME-WAIT state limits the 886 rate of connection reuse, while the initial sequence number selection 887 described below further protects against amiguity about what 888 incarnation of a connection an incoming packet corresponds to. 890 To avoid confusion we must prevent segments from one incarnation of a 891 connection from being used while the same sequence numbers may still 892 be present in the network from an earlier incarnation. We want to 893 assure this, even if a TCP endpoint loses all knowledge of the 894 sequence numbers it has been using. When new connections are 895 created, an initial sequence number (ISN) generator is employed that 896 selects a new 32 bit ISN. There are security issues that result if 897 an off-path attacker is able to predict or guess ISN values. 899 TCP Initial Sequence Numbers are generated from a number sequence 900 that monotonically increases until it wraps, known loosely as a 901 "clock". This clock is a 32-bit counter that typically increments at 902 least once every roughly 4 microseconds, although it is neither 903 assumed to be realtime nor precise, and need not persist across 904 reboots. The clock component is intended to insure that with a 905 Maximum Segment Lifetime (MSL), generated ISNs will be unique, since 906 it cycles approximately every 4.55 hours, which is much longer than 907 the MSL. 909 A TCP implementation MUST use the above type of "clock" for clock- 910 driven selection of initial sequence numbers (MUST-8), and SHOULD 911 generate its Initial Sequence Numbers with the expression: 913 ISN = M + F(localip, localport, remoteip, remoteport, secretkey) 915 where M is the 4 microsecond timer, and F() is a pseudorandom 916 function (PRF) of the connection's identifying parameters ("localip, 917 localport, remoteip, remoteport") and a secret key ("secretkey") 918 (SHLD-1). F() MUST NOT be computable from the outside (MUST-9), or 919 an attacker could still guess at sequence numbers from the ISN used 920 for some other connection. The PRF could be implemented as a 921 cryptographic hash of the concatenation of the TCP connection 922 parameters and some secret data. For discussion of the selection of 923 a specific hash algorithm and management of the secret key data, 924 please see Section 3 of [38]. 926 For each connection there is a send sequence number and a receive 927 sequence number. The initial send sequence number (ISS) is chosen by 928 the data sending TCP peer, and the initial receive sequence number 929 (IRS) is learned during the connection establishing procedure. 931 For a connection to be established or initialized, the two TCP peers 932 must synchronize on each other's initial sequence numbers. This is 933 done in an exchange of connection establishing segments carrying a 934 control bit called "SYN" (for synchronize) and the initial sequence 935 numbers. As a shorthand, segments carrying the SYN bit are also 936 called "SYNs". Hence, the solution requires a suitable mechanism for 937 picking an initial sequence number and a slightly involved handshake 938 to exchange the ISNs. 940 The synchronization requires each side to send its own initial 941 sequence number and to receive a confirmation of it in acknowledgment 942 from the remote TCP peer. Each side must also receive the remote 943 peer's initial sequence number and send a confirming acknowledgment. 945 1) A --> B SYN my sequence number is X 946 2) A <-- B ACK your sequence number is X 947 3) A <-- B SYN my sequence number is Y 948 4) A --> B ACK your sequence number is Y 950 Because steps 2 and 3 can be combined in a single message this is 951 called the three-way (or three message) handshake (3WHS). 953 A 3WHS is necessary because sequence numbers are not tied to a global 954 clock in the network, and TCP implementations may have different 955 mechanisms for picking the ISNs. The receiver of the first SYN has 956 no way of knowing whether the segment was an old delayed one or not, 957 unless it remembers the last sequence number used on the connection 958 (which is not always possible), and so it must ask the sender to 959 verify this SYN. The three way handshake and the advantages of a 960 clock-driven scheme are discussed in [59]. 962 Knowing When to Keep Quiet 964 A theoretical problem exists where data could be corrupted due to 965 confusion between old segments in the network and new ones after a 966 host reboots, if the same port numbers and sequence space are reused. 967 The "Quiet Time" concept discussed below addresses this and the 968 discussion of it is included for situations where it might be 969 relevant, although it is not felt to be necessary in most current 970 implementations. The problem was more relevant earlier in the 971 history of TCP. In practical use on the Internet today, the error- 972 prone conditions are sufficiently unlikely that it is felt safe to 973 ignore. Reasons why it is now negligible include: (a) ISS and 974 ephemeral port randomization have reduced likelihood of reuse of port 975 numbers and sequence numbers after reboots, (b) the effective MSL of 976 the Internet has declined as links have become faster, and (c) 977 reboots often taking longer than an MSL anyways. 979 To be sure that a TCP implementation does not create a segment 980 carrying a sequence number that may be duplicated by an old segment 981 remaining in the network, the TCP endpoint must keep quiet for an MSL 982 before assigning any sequence numbers upon starting up or recovering 983 from a situation where memory of sequence numbers in use was lost. 984 For this specification the MSL is taken to be 2 minutes. This is an 985 engineering choice, and may be changed if experience indicates it is 986 desirable to do so. Note that if a TCP endpoint is reinitialized in 987 some sense, yet retains its memory of sequence numbers in use, then 988 it need not wait at all; it must only be sure to use sequence numbers 989 larger than those recently used. 991 The TCP Quiet Time Concept 993 Hosts that for any reason lose knowledge of the last sequence numbers 994 transmitted on each active (i.e., not closed) connection shall delay 995 emitting any TCP segments for at least the agreed MSL in the internet 996 system that the host is a part of. In the paragraphs below, an 997 explanation for this specification is given. TCP implementors may 998 violate the "quiet time" restriction, but only at the risk of causing 999 some old data to be accepted as new or new data rejected as old 1000 duplicated by some receivers in the internet system. 1002 TCP endpoints consume sequence number space each time a segment is 1003 formed and entered into the network output queue at a source host. 1004 The duplicate detection and sequencing algorithm in the TCP protocol 1005 relies on the unique binding of segment data to sequence space to the 1006 extent that sequence numbers will not cycle through all 2**32 values 1007 before the segment data bound to those sequence numbers has been 1008 delivered and acknowledged by the receiver and all duplicate copies 1009 of the segments have "drained" from the internet. Without such an 1010 assumption, two distinct TCP segments could conceivably be assigned 1011 the same or overlapping sequence numbers, causing confusion at the 1012 receiver as to which data is new and which is old. Remember that 1013 each segment is bound to as many consecutive sequence numbers as 1014 there are octets of data and SYN or FIN flags in the segment. 1016 Under normal conditions, TCP implementations keep track of the next 1017 sequence number to emit and the oldest awaiting acknowledgment so as 1018 to avoid mistakenly using a sequence number over before its first use 1019 has been acknowledged. This alone does not guarantee that old 1020 duplicate data is drained from the net, so the sequence space has 1021 been made very large to reduce the probability that a wandering 1022 duplicate will cause trouble upon arrival. At 2 megabits/sec. it 1023 takes 4.5 hours to use up 2**32 octets of sequence space. Since the 1024 maximum segment lifetime in the net is not likely to exceed a few 1025 tens of seconds, this is deemed ample protection for foreseeable 1026 nets, even if data rates escalate to l0's of megabits/sec. At 100 1027 megabits/sec, the cycle time is 5.4 minutes, which may be a little 1028 short, but still within reason. 1030 The basic duplicate detection and sequencing algorithm in TCP can be 1031 defeated, however, if a source TCP endpoint does not have any memory 1032 of the sequence numbers it last used on a given connection. For 1033 example, if the TCP implementation were to start all connections with 1034 sequence number 0, then upon the host rebooting, a TCP peer might re- 1035 form an earlier connection (possibly after half-open connection 1036 resolution) and emit packets with sequence numbers identical to or 1037 overlapping with packets still in the network, which were emitted on 1038 an earlier incarnation of the same connection. In the absence of 1039 knowledge about the sequence numbers used on a particular connection, 1040 the TCP specification recommends that the source delay for MSL 1041 seconds before emitting segments on the connection, to allow time for 1042 segments from the earlier connection incarnation to drain from the 1043 system. 1045 Even hosts that can remember the time of day and used it to select 1046 initial sequence number values are not immune from this problem 1047 (i.e., even if time of day is used to select an initial sequence 1048 number for each new connection incarnation). 1050 Suppose, for example, that a connection is opened starting with 1051 sequence number S. Suppose that this connection is not used much and 1052 that eventually the initial sequence number function (ISN(t)) takes 1053 on a value equal to the sequence number, say S1, of the last segment 1054 sent by this TCP endpoint on a particular connection. Now suppose, 1055 at this instant, the host reboots and establishes a new incarnation 1056 of the connection. The initial sequence number chosen is S1 = ISN(t) 1057 -- last used sequence number on old incarnation of connection! If 1058 the recovery occurs quickly enough, any old duplicates in the net 1059 bearing sequence numbers in the neighborhood of S1 may arrive and be 1060 treated as new packets by the receiver of the new incarnation of the 1061 connection. 1063 The problem is that the recovering host may not know for how long it 1064 was down between rebooting nor does it know whether there are still 1065 old duplicates in the system from earlier connection incarnations. 1067 One way to deal with this problem is to deliberately delay emitting 1068 segments for one MSL after recovery from a reboot - this is the 1069 "quiet time" specification. Hosts that prefer to avoid waiting are 1070 willing to risk possible confusion of old and new packets at a given 1071 destination may choose not to wait for the "quiet time". 1072 Implementors may provide TCP users with the ability to select on a 1073 connection by connection basis whether to wait after a reboot, or may 1074 informally implement the "quiet time" for all connections. 1075 Obviously, even where a user selects to "wait," this is not necessary 1076 after the host has been "up" for at least MSL seconds. 1078 To summarize: every segment emitted occupies one or more sequence 1079 numbers in the sequence space, the numbers occupied by a segment are 1080 "busy" or "in use" until MSL seconds have passed, upon rebooting a 1081 block of space-time is occupied by the octets and SYN or FIN flags of 1082 the last emitted segment, if a new connection is started too soon and 1083 uses any of the sequence numbers in the space-time footprint of the 1084 last segment of the previous connection incarnation, there is a 1085 potential sequence number overlap area that could cause confusion at 1086 the receiver. 1088 3.4. Establishing a connection 1090 The "three-way handshake" is the procedure used to establish a 1091 connection. This procedure normally is initiated by one TCP peer and 1092 responded to by another TCP peer. The procedure also works if two 1093 TCP peers simultaneously initiate the procedure. When simultaneous 1094 open occurs, each TCP peer receives a "SYN" segment that carries no 1095 acknowledgment after it has sent a "SYN". Of course, the arrival of 1096 an old duplicate "SYN" segment can potentially make it appear, to the 1097 recipient, that a simultaneous connection initiation is in progress. 1098 Proper use of "reset" segments can disambiguate these cases. 1100 Several examples of connection initiation follow. Although these 1101 examples do not show connection synchronization using data-carrying 1102 segments, this is perfectly legitimate, so long as the receiving TCP 1103 endpoint doesn't deliver the data to the user until it is clear the 1104 data is valid (e.g., the data is buffered at the receiver until the 1105 connection reaches the ESTABLISHED state, given that the three-way 1106 handshake reduces the possibility of false connections). It is the 1107 implementation of a trade-off between memory and messages to provide 1108 information for this checking. 1110 The simplest 3WHS is shown in Figure 6. The figures should be 1111 interpreted in the following way. Each line is numbered for 1112 reference purposes. Right arrows (-->) indicate departure of a TCP 1113 segment from TCP peer A to TCP peer B, or arrival of a segment at B 1114 from A. Left arrows (<--), indicate the reverse. Ellipsis (...) 1115 indicates a segment that is still in the network (delayed). Comments 1116 appear in parentheses. TCP connection states represent the state 1117 AFTER the departure or arrival of the segment (whose contents are 1118 shown in the center of each line). Segment contents are shown in 1119 abbreviated form, with sequence number, control flags, and ACK field. 1120 Other fields such as window, addresses, lengths, and text have been 1121 left out in the interest of clarity. 1123 TCP Peer A TCP Peer B 1125 1. CLOSED LISTEN 1127 2. SYN-SENT --> --> SYN-RECEIVED 1129 3. ESTABLISHED <-- <-- SYN-RECEIVED 1131 4. ESTABLISHED --> --> ESTABLISHED 1133 5. ESTABLISHED --> --> ESTABLISHED 1135 Figure 6: Basic 3-Way Handshake for Connection Synchronization 1137 In line 2 of Figure 6, TCP Peer A begins by sending a SYN segment 1138 indicating that it will use sequence numbers starting with sequence 1139 number 100. In line 3, TCP Peer B sends a SYN and acknowledges the 1140 SYN it received from TCP Peer A. Note that the acknowledgment field 1141 indicates TCP Peer B is now expecting to hear sequence 101, 1142 acknowledging the SYN that occupied sequence 100. 1144 At line 4, TCP Peer A responds with an empty segment containing an 1145 ACK for TCP Peer B's SYN; and in line 5, TCP Peer A sends some data. 1146 Note that the sequence number of the segment in line 5 is the same as 1147 in line 4 because the ACK does not occupy sequence number space (if 1148 it did, we would wind up ACKing ACKs!). 1150 Simultaneous initiation is only slightly more complex, as is shown in 1151 Figure 7. Each TCP peer's connection state cycles from CLOSED to 1152 SYN-SENT to SYN-RECEIVED to ESTABLISHED. 1154 TCP Peer A TCP Peer B 1156 1. CLOSED CLOSED 1158 2. SYN-SENT --> ... 1160 3. SYN-RECEIVED <-- <-- SYN-SENT 1162 4. ... --> SYN-RECEIVED 1164 5. SYN-RECEIVED --> ... 1166 6. ESTABLISHED <-- <-- SYN-RECEIVED 1168 7. ... --> ESTABLISHED 1170 Figure 7: Simultaneous Connection Synchronization 1172 A TCP implementation MUST support simultaneous open attempts (MUST- 1173 10). 1175 Note that a TCP implementation MUST keep track of whether a 1176 connection has reached SYN-RECEIVED state as the result of a passive 1177 OPEN or an active OPEN (MUST-11). 1179 The principal reason for the three-way handshake is to prevent old 1180 duplicate connection initiations from causing confusion. To deal 1181 with this, a special control message, reset, is specified. If the 1182 receiving TCP peer is in a non-synchronized state (i.e., SYN-SENT, 1183 SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset. 1184 If the TCP peer is in one of the synchronized states (ESTABLISHED, 1185 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it 1186 aborts the connection and informs its user. We discuss this latter 1187 case under "half-open" connections below. 1189 TCP Peer A TCP Peer B 1191 1. CLOSED LISTEN 1193 2. SYN-SENT --> ... 1195 3. (duplicate) ... --> SYN-RECEIVED 1197 4. SYN-SENT <-- <-- SYN-RECEIVED 1199 5. SYN-SENT --> --> LISTEN 1201 6. ... --> SYN-RECEIVED 1203 7. ESTABLISHED <-- <-- SYN-RECEIVED 1205 8. ESTABLISHED --> --> ESTABLISHED 1207 Figure 8: Recovery from Old Duplicate SYN 1209 As a simple example of recovery from old duplicates, consider 1210 Figure 8. At line 3, an old duplicate SYN arrives at TCP Peer B. 1211 TCP Peer B cannot tell that this is an old duplicate, so it responds 1212 normally (line 4). TCP Peer A detects that the ACK field is 1213 incorrect and returns a RST (reset) with its SEQ field selected to 1214 make the segment believable. TCP Peer B, on receiving the RST, 1215 returns to the LISTEN state. When the original SYN finally arrives 1216 at line 6, the synchronization proceeds normally. If the SYN at line 1217 6 had arrived before the RST, a more complex exchange might have 1218 occurred with RST's sent in both directions. 1220 Half-Open Connections and Other Anomalies 1222 An established connection is said to be "half-open" if one of the TCP 1223 peers has closed or aborted the connection at its end without the 1224 knowledge of the other, or if the two ends of the connection have 1225 become desynchronized owing to a failure or reboot that resulted in 1226 loss of memory. Such connections will automatically become reset if 1227 an attempt is made to send data in either direction. However, half- 1228 open connections are expected to be unusual. 1230 If at site A the connection no longer exists, then an attempt by the 1231 user at site B to send any data on it will result in the site B TCP 1232 endpoint receiving a reset control message. Such a message indicates 1233 to the site B TCP endpoint that something is wrong, and it is 1234 expected to abort the connection. 1236 Assume that two user processes A and B are communicating with one 1237 another when a failure or reboot occurs causing loss of memory to A's 1238 TCP implementation. Depending on the operating system supporting A's 1239 TCP implementation, it is likely that some error recovery mechanism 1240 exists. When the TCP endpoint is up again, A is likely to start 1241 again from the beginning or from a recovery point. As a result, A 1242 will probably try to OPEN the connection again or try to SEND on the 1243 connection it believes open. In the latter case, it receives the 1244 error message "connection not open" from the local (A's) TCP 1245 implementation. In an attempt to establish the connection, A's TCP 1246 implementation will send a segment containing SYN. This scenario 1247 leads to the example shown in Figure 9. After TCP Peer A reboots, 1248 the user attempts to re-open the connection. TCP Peer B, in the 1249 meantime, thinks the connection is open. 1251 TCP Peer A TCP Peer B 1253 1. (REBOOT) (send 300,receive 100) 1255 2. CLOSED ESTABLISHED 1257 3. SYN-SENT --> --> (??) 1259 4. (!!) <-- <-- ESTABLISHED 1261 5. SYN-SENT --> --> (Abort!!) 1263 6. SYN-SENT CLOSED 1265 7. SYN-SENT --> --> 1267 Figure 9: Half-Open Connection Discovery 1269 When the SYN arrives at line 3, TCP Peer B, being in a synchronized 1270 state, and the incoming segment outside the window, responds with an 1271 acknowledgment indicating what sequence it next expects to hear (ACK 1272 100). TCP Peer A sees that this segment does not acknowledge 1273 anything it sent and, being unsynchronized, sends a reset (RST) 1274 because it has detected a half-open connection. TCP Peer B aborts at 1275 line 5. TCP Peer A will continue to try to establish the connection; 1276 the problem is now reduced to the basic 3-way handshake of Figure 6. 1278 An interesting alternative case occurs when TCP Peer A reboots and 1279 TCP Peer B tries to send data on what it thinks is a synchronized 1280 connection. This is illustrated in Figure 10. In this case, the 1281 data arriving at TCP Peer A from TCP Peer B (line 2) is unacceptable 1282 because no such connection exists, so TCP Peer A sends a RST. The 1283 RST is acceptable so TCP Peer B processes it and aborts the 1284 connection. 1286 TCP Peer A TCP Peer B 1288 1. (REBOOT) (send 300,receive 100) 1290 2. (??) <-- <-- ESTABLISHED 1292 3. --> --> (ABORT!!) 1294 Figure 10: Active Side Causes Half-Open Connection Discovery 1296 In Figure 11, two TCP Peers A and B with passive connections waiting 1297 for SYN are depicted. An old duplicate arriving at TCP Peer B (line 1298 2) stirs B into action. A SYN-ACK is returned (line 3) and causes 1299 TCP A to generate a RST (the ACK in line 3 is not acceptable). TCP 1300 Peer B accepts the reset and returns to its passive LISTEN state. 1302 TCP Peer A TCP Peer B 1304 1. LISTEN LISTEN 1306 2. ... --> SYN-RECEIVED 1308 3. (??) <-- <-- SYN-RECEIVED 1310 4. --> --> (return to LISTEN!) 1312 5. LISTEN LISTEN 1314 Figure 11: Old Duplicate SYN Initiates a Reset on two Passive Sockets 1316 A variety of other cases are possible, all of which are accounted for 1317 by the following rules for RST generation and processing. 1319 Reset Generation 1321 A TCP user or application can issue a reset on a connection at any 1322 time, though reset events are also generated by the protocol itself 1323 when various error conditions occur, as described below. The side of 1324 a connection issuing a reset should enter the TIME-WAIT state, as 1325 this generally helps to reduce the load on busy servers for reasons 1326 described in [60]. 1328 As a general rule, reset (RST) is sent whenever a segment arrives 1329 that apparently is not intended for the current connection. A reset 1330 must not be sent if it is not clear that this is the case. 1332 There are three groups of states: 1334 1. If the connection does not exist (CLOSED) then a reset is sent 1335 in response to any incoming segment except another reset. A SYN 1336 segment that does not match an existing connection is rejected by 1337 this means. 1339 If the incoming segment has the ACK bit set, the reset takes its 1340 sequence number from the ACK field of the segment, otherwise the 1341 reset has sequence number zero and the ACK field is set to the sum 1342 of the sequence number and segment length of the incoming segment. 1343 The connection remains in the CLOSED state. 1345 2. If the connection is in any non-synchronized state (LISTEN, 1346 SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges 1347 something not yet sent (the segment carries an unacceptable ACK), 1348 or if an incoming segment has a security level or compartment that 1349 does not exactly match the level and compartment requested for the 1350 connection, a reset is sent. 1352 If the incoming segment has an ACK field, the reset takes its 1353 sequence number from the ACK field of the segment, otherwise the 1354 reset has sequence number zero and the ACK field is set to the sum 1355 of the sequence number and segment length of the incoming segment. 1356 The connection remains in the same state. 1358 3. If the connection is in a synchronized state (ESTABLISHED, 1359 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), 1360 any unacceptable segment (out of window sequence number or 1361 unacceptable acknowledgment number) must be responded to with an 1362 empty acknowledgment segment (without any user data) containing 1363 the current send-sequence number and an acknowledgment indicating 1364 the next sequence number expected to be received, and the 1365 connection remains in the same state. 1367 If an incoming segment has a security level, or compartment that 1368 does not exactly match the level and compartment requested for the 1369 connection, a reset is sent and the connection goes to the CLOSED 1370 state. The reset takes its sequence number from the ACK field of 1371 the incoming segment. 1373 Reset Processing 1374 In all states except SYN-SENT, all reset (RST) segments are validated 1375 by checking their SEQ-fields. A reset is valid if its sequence 1376 number is in the window. In the SYN-SENT state (a RST received in 1377 response to an initial SYN), the RST is acceptable if the ACK field 1378 acknowledges the SYN. 1380 The receiver of a RST first validates it, then changes state. If the 1381 receiver was in the LISTEN state, it ignores it. If the receiver was 1382 in SYN-RECEIVED state and had previously been in the LISTEN state, 1383 then the receiver returns to the LISTEN state, otherwise the receiver 1384 aborts the connection and goes to the CLOSED state. If the receiver 1385 was in any other state, it aborts the connection and advises the user 1386 and goes to the CLOSED state. 1388 TCP implementations SHOULD allow a received RST segment to include 1389 data (SHLD-2). 1391 3.5. Closing a Connection 1393 CLOSE is an operation meaning "I have no more data to send." The 1394 notion of closing a full-duplex connection is subject to ambiguous 1395 interpretation, of course, since it may not be obvious how to treat 1396 the receiving side of the connection. We have chosen to treat CLOSE 1397 in a simplex fashion. The user who CLOSEs may continue to RECEIVE 1398 until the TCP receiver is told that the remote peer has CLOSED also. 1399 Thus, a program could initiate several SENDs followed by a CLOSE, and 1400 then continue to RECEIVE until signaled that a RECEIVE failed because 1401 the remote peer has CLOSED. The TCP implementation will signal a 1402 user, even if no RECEIVEs are outstanding, that the remote peer has 1403 closed, so the user can terminate his side gracefully. A TCP 1404 implementation will reliably deliver all buffers SENT before the 1405 connection was CLOSED so a user who expects no data in return need 1406 only wait to hear the connection was CLOSED successfully to know that 1407 all their data was received at the destination TCP endpoint. Users 1408 must keep reading connections they close for sending until the TCP 1409 implementation indicates there is no more data. 1411 There are essentially three cases: 1413 1) The user initiates by telling the TCP implementation to CLOSE 1414 the connection (TCP Peer A in Figure 12). 1416 2) The remote TCP endpoint initiates by sending a FIN control 1417 signal (TCP Peer B in Figure 12). 1419 3) Both users CLOSE simultaneously (Figure 13). 1421 Case 1: Local user initiates the close 1422 In this case, a FIN segment can be constructed and placed on the 1423 outgoing segment queue. No further SENDs from the user will be 1424 accepted by the TCP implementation, and it enters the FIN-WAIT-1 1425 state. RECEIVEs are allowed in this state. All segments 1426 preceding and including FIN will be retransmitted until 1427 acknowledged. When the other TCP peer has both acknowledged the 1428 FIN and sent a FIN of its own, the first TCP peer can ACK this 1429 FIN. Note that a TCP endpoint receiving a FIN will ACK but not 1430 send its own FIN until its user has CLOSED the connection also. 1432 Case 2: TCP endpoint receives a FIN from the network 1434 If an unsolicited FIN arrives from the network, the receiving TCP 1435 endpoint can ACK it and tell the user that the connection is 1436 closing. The user will respond with a CLOSE, upon which the TCP 1437 endpoint can send a FIN to the other TCP peer after sending any 1438 remaining data. The TCP endpoint then waits until its own FIN is 1439 acknowledged whereupon it deletes the connection. If an ACK is 1440 not forthcoming, after the user timeout the connection is aborted 1441 and the user is told. 1443 Case 3: Both users close simultaneously 1445 A simultaneous CLOSE by users at both ends of a connection causes 1446 FIN segments to be exchanged (Figure 13). When all segments 1447 preceding the FINs have been processed and acknowledged, each TCP 1448 peer can ACK the FIN it has received. Both will, upon receiving 1449 these ACKs, delete the connection. 1451 TCP Peer A TCP Peer B 1453 1. ESTABLISHED ESTABLISHED 1455 2. (Close) 1456 FIN-WAIT-1 --> --> CLOSE-WAIT 1458 3. FIN-WAIT-2 <-- <-- CLOSE-WAIT 1460 4. (Close) 1461 TIME-WAIT <-- <-- LAST-ACK 1463 5. TIME-WAIT --> --> CLOSED 1465 6. (2 MSL) 1466 CLOSED 1468 Figure 12: Normal Close Sequence 1470 TCP Peer A TCP Peer B 1472 1. ESTABLISHED ESTABLISHED 1474 2. (Close) (Close) 1475 FIN-WAIT-1 --> ... FIN-WAIT-1 1476 <-- <-- 1477 ... --> 1479 3. CLOSING --> ... CLOSING 1480 <-- <-- 1481 ... --> 1483 4. TIME-WAIT TIME-WAIT 1484 (2 MSL) (2 MSL) 1485 CLOSED CLOSED 1487 Figure 13: Simultaneous Close Sequence 1489 A TCP connection may terminate in two ways: (1) the normal TCP close 1490 sequence using a FIN handshake (Figure 12), and (2) an "abort" in 1491 which one or more RST segments are sent and the connection state is 1492 immediately discarded. If the local TCP connection is closed by the 1493 remote side due to a FIN or RST received from the remote side, then 1494 the local application MUST be informed whether it closed normally or 1495 was aborted (MUST-12). 1497 3.5.1. Half-Closed Connections 1499 The normal TCP close sequence delivers buffered data reliably in both 1500 directions. Since the two directions of a TCP connection are closed 1501 independently, it is possible for a connection to be "half closed," 1502 i.e., closed in only one direction, and a host is permitted to 1503 continue sending data in the open direction on a half-closed 1504 connection. 1506 A host MAY implement a "half-duplex" TCP close sequence, so that an 1507 application that has called CLOSE cannot continue to read data from 1508 the connection (MAY-1). If such a host issues a CLOSE call while 1509 received data is still pending in the TCP connection, or if new data 1510 is received after CLOSE is called, its TCP implementation SHOULD send 1511 a RST to show that data was lost (SHLD-3). See [19] section 2.17 for 1512 discussion. 1514 When a connection is closed actively, it MUST linger in the TIME-WAIT 1515 state for a time 2xMSL (Maximum Segment Lifetime) (MUST-13). 1516 However, it MAY accept a new SYN from the remote TCP endpoint to 1517 reopen the connection directly from TIME-WAIT state (MAY-2), if it: 1519 (1) assigns its initial sequence number for the new connection to 1520 be larger than the largest sequence number it used on the previous 1521 connection incarnation, and 1523 (2) returns to TIME-WAIT state if the SYN turns out to be an old 1524 duplicate. 1526 When the TCP Timestamp options are available, an improved algorithm 1527 is described in [36] in order to support higher connection 1528 establishment rates. This algorithm for reducing TIME-WAIT is a Best 1529 Current Practice that SHOULD be implemented, since timestamp options 1530 are commonly used, and using them to reduce TIME-WAIT provides 1531 benefits for busy Internet servers (SHLD-4). 1533 3.6. Segmentation 1535 The term "segmentation" refers to the activity TCP performs when 1536 ingesting a stream of bytes from a sending application and 1537 packetizing that stream of bytes into TCP segments. Individual TCP 1538 segments often do not correspond one-for-one to individual send (or 1539 socket write) calls from the application. Applications may perform 1540 writes at the granularity of messages in the upper layer protocol, 1541 but TCP guarantees no boundary coherence between the TCP segments 1542 sent and received versus user application data read or write buffer 1543 boundaries. In some specific protocols, such as Remote Direct Memory 1544 Access (RDMA) using Direct Data Placement (DDP) and Marker PDU 1545 Aligned Framing (MPA) [28], there are performance optimizations 1546 possible when the relation between TCP segments and application data 1547 units can be controlled, and MPA includes a specific mechanism for 1548 detecting and verifying this relationship between TCP segments and 1549 application message data structures, but this is specific to 1550 applications like RDMA. In general, multiple goals influence the 1551 sizing of TCP segments created by a TCP implementation. 1553 Goals driving the sending of larger segments include: 1555 o Reducing the number of packets in flight within the network. 1557 o Increasing processing efficiency and potential performance by 1558 enabling a smaller number of interrupts and inter-layer 1559 interactions. 1561 o Limiting the overhead of TCP headers. 1563 Note that the performance benefits of sending larger segments may 1564 decrease as the size increases, and there may be boundaries where 1565 advantages are reversed. For instance, on some implementation 1566 architectures, 1025 bytes within a segment could lead to worse 1567 performance than 1024 bytes, due purely to data alignment on copy 1568 operations. 1570 Goals driving the sending of smaller segments include: 1572 o Avoiding sending a TCP segment that would result in an IP datagram 1573 larger than the smallest MTU along an IP network path, because 1574 this results in either packet loss or packet fragmentation. 1575 Making matters worse, some firewalls or middleboxes may drop 1576 fragmented packets or ICMP messages related to fragmentation. 1578 o Preventing delays to the application data stream, especially when 1579 TCP is waiting on the application to generate more data, or when 1580 the application is waiting on an event or input from its peer in 1581 order to generate more data. 1583 o Enabling "fate sharing" between TCP segments and lower-layer data 1584 units (e.g. below IP, for links with cell or frame sizes smaller 1585 than the IP MTU). 1587 Towards meeting these competing sets of goals, TCP includes several 1588 mechanisms, including the Maximum Segment Size option, Path MTU 1589 Discovery, the Nagle algorithm, and support for IPv6 Jumbograms, as 1590 discussed in the following subsections. 1592 3.6.1. Maximum Segment Size Option 1594 TCP endpoints MUST implement both sending and receiving the MSS 1595 option (MUST-14). 1597 TCP implementations SHOULD send an MSS option in every SYN segment 1598 when its receive MSS differs from the default 536 for IPv4 or 1220 1599 for IPv6 (SHLD-5), and MAY send it always (MAY-3). 1601 If an MSS option is not received at connection setup, TCP 1602 implementations MUST assume a default send MSS of 536 (576-40) for 1603 IPv4 or 1220 (1280 - 60) for IPv6 (MUST-15). 1605 The maximum size of a segment that TCP endpoint really sends, the 1606 "effective send MSS," MUST be the smaller (MUST-16) of the send MSS 1607 (that reflects the available reassembly buffer size at the remote 1608 host, the EMTU_R [15]) and the largest transmission size permitted by 1609 the IP layer (EMTU_S [15]): 1611 Eff.snd.MSS = 1613 min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize 1615 where: 1617 o SendMSS is the MSS value received from the remote host, or the 1618 default 536 for IPv4 or 1220 for IPv6, if no MSS option is 1619 received. 1621 o MMS_S is the maximum size for a transport-layer message that TCP 1622 may send. 1624 o TCPhdrsize is the size of the fixed TCP header and any options. 1625 This is 20 in the (rare) case that no options are present, but may 1626 be larger if TCP options are to be sent. Note that some options 1627 may not be included on all segments, but that for each segment 1628 sent, the sender should adjust the data length accordingly, within 1629 the Eff.snd.MSS. 1631 o IPoptionsize is the size of any IP options associated with a TCP 1632 connection. Note that some options may not be included on all 1633 packets, but that for each segment sent, the sender should adjust 1634 the data length accordingly, within the Eff.snd.MSS. 1636 The MSS value to be sent in an MSS option should be equal to the 1637 effective MTU minus the fixed IP and TCP headers. By ignoring both 1638 IP and TCP options when calculating the value for the MSS option, if 1639 there are any IP or TCP options to be sent in a packet, then the 1640 sender must decrease the size of the TCP data accordingly. RFC 6691 1641 [39] discusses this in greater detail. 1643 The MSS value to be sent in an MSS option must be less than or equal 1644 to: 1646 MMS_R - 20 1648 where MMS_R is the maximum size for a transport-layer message that 1649 can be received (and reassembled at the IP layer) (MUST-67). TCP 1650 obtains MMS_R and MMS_S from the IP layer; see the generic call 1651 GET_MAXSIZES in Section 3.4 of RFC 1122. These are defined in terms 1652 of their IP MTU equivalents, EMTU_R and EMTU_S [15]. 1654 When TCP is used in a situation where either the IP or TCP headers 1655 are not fixed, the sender must reduce the amount of TCP data in any 1656 given packet by the number of octets used by the IP and TCP options. 1657 This has been a point of confusion historically, as explained in RFC 1658 6691, Section 3.1. 1660 3.6.2. Path MTU Discovery 1662 A TCP implementation may be aware of the MTU on directly connected 1663 links, but will rarely have insight about MTUs across an entire 1664 network path. For IPv4, RFC 1122 recommends an IP-layer default 1665 effective MTU of less than or equal to 576 for destinations not 1666 directly connected. For IPv6, this would be 1280. In all cases, 1667 however, implementation of Path MTU Discovery (PMTUD) and 1668 Packetization Layer Path MTU Discovery (PLPMTUD) is strongly 1669 recommended in order for TCP to improve segmentation decisions. Both 1670 PMTUD and PLPMTUD help TCP choose segment sizes that avoid both on- 1671 path (for IPv4) and source fragmentation (IPv4 and IPv6). 1673 PMTUD for IPv4 [2] or IPv6 [3] is implemented in conjunction between 1674 TCP, IP, and ICMP protocols. It relies both on avoiding source 1675 fragmentation and setting the IPv4 DF (don't fragment) flag, the 1676 latter to inhibit on-path fragmentation. It relies on ICMP errors 1677 from routers along the path, whenever a segment is too large to 1678 traverse a link. Several adjustments to a TCP implementation with 1679 PMTUD are described in RFC 2923 in order to deal with problems 1680 experienced in practice [7]. PLPMTUD [25] is a Standards Track 1681 improvement to PMTUD that relaxes the requirement for ICMP support 1682 across a path, and improves performance in cases where ICMP is not 1683 consistently conveyed, but still tries to avoid source fragmentation. 1684 The mechanisms in all four of these RFCs are recommended to be 1685 included in TCP implementations. 1687 The TCP MSS option specifies an upper bound for the size of packets 1688 that can be received. Hence, setting the value in the MSS option too 1689 small can impact the ability for PMTUD or PLPMTUD to find a larger 1690 path MTU. RFC 1191 discusses this implication of many older TCP 1691 implementations setting MSS to 536 for non-local destinations, rather 1692 than deriving it from the MTUs of connected interfaces as 1693 recommended. 1695 3.6.3. Interfaces with Variable MTU Values 1697 The effective MTU can sometimes vary, as when used with variable 1698 compression, e.g., RObust Header Compression (ROHC) [32]. It is 1699 tempting for a TCP implementation to advertise the largest possible 1700 MSS, to support the most efficient use of compressed payloads. 1701 Unfortunately, some compression schemes occasionally need to transmit 1702 full headers (and thus smaller payloads) to resynchronize state at 1703 their endpoint compressors/decompressors. If the largest MTU is used 1704 to calculate the value to advertise in the MSS option, TCP 1705 retransmission may interfere with compressor resynchronization. 1707 As a result, when the effective MTU of an interface varies packet-to- 1708 packet, TCP implementations SHOULD use the smallest effective MTU of 1709 the interface to calculate the value to advertise in the MSS option 1710 (SHLD-6). 1712 3.6.4. Nagle Algorithm 1714 The "Nagle algorithm" was described in RFC 896 [14] and was 1715 recommended in RFC 1122 [15] for mitigation of an early problem of 1716 too many small packets being generated. It has been implemented in 1717 most current TCP code bases, sometimes with minor variations (see 1718 Appendix A.3). 1720 If there is unacknowledged data (i.e., SND.NXT > SND.UNA), then the 1721 sending TCP endpoint buffers all user data (regardless of the PSH 1722 bit), until the outstanding data has been acknowledged or until the 1723 TCP endpoint can send a full-sized segment (Eff.snd.MSS bytes). 1725 A TCP implementation SHOULD implement the Nagle Algorithm to coalesce 1726 short segments (SHLD-7). However, there MUST be a way for an 1727 application to disable the Nagle algorithm on an individual 1728 connection (MUST-17). In all cases, sending data is also subject to 1729 the limitation imposed by the Slow Start algorithm [31]. 1731 Since there can be problematic interactions between the Nagle 1732 Algorithm and delayed acknowledgements, some implementations use 1733 minor variations of the Nagle algorithm, such as the one described in 1734 Appendix A.3. 1736 3.6.5. IPv6 Jumbograms 1738 In order to support TCP over IPv6 Jumbograms, implementations need to 1739 be able to send TCP segments larger than the 64KB limit that the MSS 1740 option can convey. RFC 2675 [6] defines that an MSS value of 65,535 1741 bytes is to be treated as infinity, and Path MTU Discovery [3] is 1742 used to determine the actual MSS. 1744 The Jumbo Payload option need not be implemented or understood by 1745 IPv6 nodes that do not support attachment to links with a MTU greater 1746 than 65,575 [6], and the present IPv6 Node Requirements does not 1747 include support for Jumbograms [50]. 1749 3.7. Data Communication 1751 Once the connection is established data is communicated by the 1752 exchange of segments. Because segments may be lost due to errors 1753 (checksum test failure), or network congestion, TCP uses 1754 retransmission to ensure delivery of every segment. Duplicate 1755 segments may arrive due to network or TCP retransmission. As 1756 discussed in the section on sequence numbers the TCP implementation 1757 performs certain tests on the sequence and acknowledgment numbers in 1758 the segments to verify their acceptability. 1760 The sender of data keeps track of the next sequence number to use in 1761 the variable SND.NXT. The receiver of data keeps track of the next 1762 sequence number to expect in the variable RCV.NXT. The sender of 1763 data keeps track of the oldest unacknowledged sequence number in the 1764 variable SND.UNA. If the data flow is momentarily idle and all data 1765 sent has been acknowledged then the three variables will be equal. 1767 When the sender creates a segment and transmits it the sender 1768 advances SND.NXT. When the receiver accepts a segment it advances 1769 RCV.NXT and sends an acknowledgment. When the data sender receives 1770 an acknowledgment it advances SND.UNA. The extent to which the 1771 values of these variables differ is a measure of the delay in the 1772 communication. The amount by which the variables are advanced is the 1773 length of the data and SYN or FIN flags in the segment. Note that 1774 once in the ESTABLISHED state all segments must carry current 1775 acknowledgment information. 1777 The CLOSE user call implies a push function, as does the FIN control 1778 flag in an incoming segment. 1780 3.7.1. Retransmission Timeout 1782 Because of the variability of the networks that compose an 1783 internetwork system and the wide range of uses of TCP connections the 1784 retransmission timeout (RTO) must be dynamically determined. 1786 The RTO MUST be computed according to the algorithm in [9], including 1787 Karn's algorithm for taking RTT samples (MUST-18). 1789 RFC 793 contains an early example procedure for computing the RTO. 1790 This was then replaced by the algorithm described in RFC 1122, and 1791 subsequently updated in RFC 2988, and then again in RFC 6298. 1793 RFC 1122 allows that if a retransmitted packet is identical to the 1794 original packet (which implies not only that the data boundaries have 1795 not changed, but also that none of the headers have changed), then 1796 the same IPv4 Identification field MAY be used (see Section 3.2.1.5 1797 of RFC 1122) (MAY-4). The same IP identification field may be reused 1798 anyways, since it is only meaningful when a datagram is fragmented 1799 [40]. TCP implementations should not rely on or typically interact 1800 with this IPv4 header field in any way. It is not a reasonable way 1801 to either indicate duplicate sent segments, nor to identify duplicate 1802 received segments. 1804 3.7.2. TCP Congestion Control 1806 RFC 1122 required implementation of Van Jacobson's congestion control 1807 algorithm combining slow start with congestion avoidance. RFC 2581 1808 provided IETF Standards Track description of this, along with fast 1809 retransmit and fast recovery. RFC 5681 is the current description of 1810 these algorithms and is the current standard for TCP congestion 1811 control. 1813 A TCP endpoint MUST implement RFC 5681 (MUST-19). 1815 Explicit Congestion Notification (ECN) was defined in RFC 3168 and is 1816 an IETF Standards Track enhancement that has many benefits [47]. 1818 A TCP endpoint SHOULD implement ECN as described in RFC 3168 (SHLD- 1819 8). 1821 3.7.3. TCP Connection Failures 1823 Excessive retransmission of the same segment by a TCP endpoint 1824 indicates some failure of the remote host or the Internet path. This 1825 failure may be of short or long duration. The following procedure 1826 MUST be used to handle excessive retransmissions of data segments 1827 (MUST-20): 1829 (a) There are two thresholds R1 and R2 measuring the amount of 1830 retransmission that has occurred for the same segment. R1 and R2 1831 might be measured in time units or as a count of retransmissions. 1833 (b) When the number of transmissions of the same segment reaches 1834 or exceeds threshold R1, pass negative advice (see Section 3.3.1.4 1835 of [15]) to the IP layer, to trigger dead-gateway diagnosis. 1837 (c) When the number of transmissions of the same segment reaches a 1838 threshold R2 greater than R1, close the connection. 1840 (d) An application MUST (MUST-21) be able to set the value for R2 1841 for a particular connection. For example, an interactive 1842 application might set R2 to "infinity," giving the user control 1843 over when to disconnect. 1845 (e) TCP implementations SHOULD inform the application of the 1846 delivery problem (unless such information has been disabled by the 1847 application; see Asynchronous Reports section), when R1 is reached 1848 and before R2 (SHLD-9). This will allow a remote login (User 1849 Telnet) application program to inform the user, for example. 1851 The value of R1 SHOULD correspond to at least 3 retransmissions, at 1852 the current RTO (SHLD-10). The value of R2 SHOULD correspond to at 1853 least 100 seconds (SHLD-11). 1855 An attempt to open a TCP connection could fail with excessive 1856 retransmissions of the SYN segment or by receipt of a RST segment or 1857 an ICMP Port Unreachable. SYN retransmissions MUST be handled in the 1858 general way just described for data retransmissions, including 1859 notification of the application layer. 1861 However, the values of R1 and R2 may be different for SYN and data 1862 segments. In particular, R2 for a SYN segment MUST be set large 1863 enough to provide retransmission of the segment for at least 3 1864 minutes (MUST-23). The application can close the connection (i.e., 1865 give up on the open attempt) sooner, of course. 1867 3.7.4. TCP Keep-Alives 1869 Implementors MAY include "keep-alives" in their TCP implementations 1870 (MAY-5), although this practice is not universally accepted. Some 1871 TCP implementations, however, have included a keep-alive mechanism. 1872 To confirm that an idle connection is still active, these 1873 implementations send a probe segment designed to elicit a response 1874 from the TCP peer. Such a segment generally contains SEG.SEQ = 1875 SND.NXT-1 and may or may not contain one garbage octet of data. If 1876 keep-alives are included, the application MUST be able to turn them 1877 on or off for each TCP connection (MUST-24), and they MUST default to 1878 off (MUST-25). 1880 Keep-alive packets MUST only be sent when no sent data is 1881 outstanding, and no data or acknowledgement packets have been 1882 received for the connection within an interval (MUST-26). This 1883 interval MUST be configurable (MUST-27) and MUST default to no less 1884 than two hours (MUST-28). 1886 It is extremely important to remember that ACK segments that contain 1887 no data are not reliably transmitted by TCP. Consequently, if a 1888 keep-alive mechanism is implemented it MUST NOT interpret failure to 1889 respond to any specific probe as a dead connection (MUST-29). 1891 An implementation SHOULD send a keep-alive segment with no data 1892 (SHLD-12); however, it MAY be configurable to send a keep-alive 1893 segment containing one garbage octet (MAY-6), for compatibility with 1894 erroneous TCP implementations. 1896 3.7.5. The Communication of Urgent Information 1898 As a result of implementation differences and middlebox interactions, 1899 new applications SHOULD NOT employ the TCP urgent mechanism (SHLD- 1900 13). However, TCP implementations MUST still include support for the 1901 urgent mechanism (MUST-30). Details can be found in RFC 6093 [35]. 1903 The objective of the TCP urgent mechanism is to allow the sending 1904 user to stimulate the receiving user to accept some urgent data and 1905 to permit the receiving TCP endpoint to indicate to the receiving 1906 user when all the currently known urgent data has been received by 1907 the user. 1909 This mechanism permits a point in the data stream to be designated as 1910 the end of urgent information. Whenever this point is in advance of 1911 the receive sequence number (RCV.NXT) at the receiving TCP endpoint, 1912 that TCP must tell the user to go into "urgent mode"; when the 1913 receive sequence number catches up to the urgent pointer, the TCP 1914 implementation must tell user to go into "normal mode". If the 1915 urgent pointer is updated while the user is in "urgent mode", the 1916 update will be invisible to the user. 1918 The method employs an urgent field that is carried in all segments 1919 transmitted. The URG control flag indicates that the urgent field is 1920 meaningful and must be added to the segment sequence number to yield 1921 the urgent pointer. The absence of this flag indicates that there is 1922 no urgent data outstanding. 1924 To send an urgent indication the user must also send at least one 1925 data octet. If the sending user also indicates a push, timely 1926 delivery of the urgent information to the destination process is 1927 enhanced. 1929 A TCP implementation MUST support a sequence of urgent data of any 1930 length (MUST-31). [15] 1932 The urgent pointer MUST point to the sequence number of the octet 1933 following the urgent data (MUST-62). 1935 A TCP implementation MUST (MUST-32) inform the application layer 1936 asynchronously whenever it receives an Urgent pointer and there was 1937 previously no pending urgent data, or whenever the Urgent pointer 1938 advances in the data stream. The TCP implementation MUST (MUST-33) 1939 provide a way for the application to learn how much urgent data 1940 remains to be read from the connection, or at least to determine 1941 whether or not more urgent data remains to be read [15]. 1943 3.7.6. Managing the Window 1945 The window sent in each segment indicates the range of sequence 1946 numbers the sender of the window (the data receiver) is currently 1947 prepared to accept. There is an assumption that this is related to 1948 the currently available data buffer space available for this 1949 connection. 1951 The sending TCP endpoint packages the data to be transmitted into 1952 segments that fit the current window, and may repackage segments on 1953 the retransmission queue. Such repackaging is not required, but may 1954 be helpful. 1956 In a connection with a one-way data flow, the window information will 1957 be carried in acknowledgment segments that all have the same sequence 1958 number so there will be no way to reorder them if they arrive out of 1959 order. This is not a serious problem, but it will allow the window 1960 information to be on occasion temporarily based on old reports from 1961 the data receiver. A refinement to avoid this problem is to act on 1962 the window information from segments that carry the highest 1963 acknowledgment number (that is segments with acknowledgment number 1964 equal or greater than the highest previously received). 1966 Indicating a large window encourages transmissions. If more data 1967 arrives than can be accepted, it will be discarded. This will result 1968 in excessive retransmissions, adding unnecessarily to the load on the 1969 network and the TCP endpoints. Indicating a small window may 1970 restrict the transmission of data to the point of introducing a round 1971 trip delay between each new segment transmitted. 1973 The mechanisms provided allow a TCP endpoint to advertise a large 1974 window and to subsequently advertise a much smaller window without 1975 having accepted that much data. This, so called "shrinking the 1976 window," is strongly discouraged. The robustness principle [15] 1977 dictates that TCP peers will not shrink the window themselves, but 1978 will be prepared for such behavior on the part of other TCP peers. 1980 A TCP receiver SHOULD NOT shrink the window, i.e., move the right 1981 window edge to the left (SHLD-14). However, a sending TCP peer MUST 1982 be robust against window shrinking, which may cause the "useable 1983 window" (see Section 3.7.6.2.1) to become negative (MUST-34). 1985 If this happens, the sender SHOULD NOT send new data (SHLD-15), but 1986 SHOULD retransmit normally the old unacknowledged data between 1987 SND.UNA and SND.UNA+SND.WND (SHLD-16). The sender MAY also 1988 retransmit old data beyond SND.UNA+SND.WND (MAY-7), but SHOULD NOT 1989 time out the connection if data beyond the right window edge is not 1990 acknowledged (SHLD-17). If the window shrinks to zero, the TCP 1991 implementation MUST probe it in the standard way (described below) 1992 (MUST-35). 1994 3.7.6.1. Zero Window Probing 1996 The sending TCP peer must be prepared to accept from the user and 1997 send at least one octet of new data even if the send window is zero. 1998 The sending TCP peer must regularly retransmit to the receiving TCP 1999 peer even when the window is zero, in order to "probe" the window. 2000 Two minutes is recommended for the retransmission interval when the 2001 window is zero. This retransmission is essential to guarantee that 2002 when either TCP peer has a zero window the re-opening of the window 2003 will be reliably reported to the other. This is referred to as Zero- 2004 Window Probing (ZWP) in other documents. 2006 Probing of zero (offered) windows MUST be supported (MUST-36). 2008 A TCP implementation MAY keep its offered receive window closed 2009 indefinitely (MAY-8). As long as the receiving TCP peer continues to 2010 send acknowledgments in response to the probe segments, the sending 2011 TCP peer MUST allow the connection to stay open (MUST-37). This 2012 enables TCP to function in scenarios such as the "printer ran out of 2013 paper" situation described in Section 4.2.2.17 of RFC1122. The 2014 behavior is subject to the implementation's resource management 2015 concerns, as noted in [37]. 2017 When the receiving TCP peer has a zero window and a segment arrives 2018 it must still send an acknowledgment showing its next expected 2019 sequence number and current window (zero). 2021 The transmitting host SHOULD send the first zero-window probe when a 2022 zero window has existed for the retransmission timeout period (SHLD- 2023 29) (Section 3.7.1), and SHOULD increase exponentially the interval 2024 between successive probes (SHLD-30). 2026 3.7.6.2. Silly Window Syndrome Avoidance 2028 The "Silly Window Syndrome" (SWS) is a stable pattern of small 2029 incremental window movements resulting in extremely poor TCP 2030 performance. Algorithms to avoid SWS are described below for both 2031 the sending side and the receiving side. RFC 1122 contains more 2032 detailed discussion of the SWS problem. Note that the Nagle 2033 algorithm and the sender SWS avoidance algorithm play complementary 2034 roles in improving performance. The Nagle algorithm discourages 2035 sending tiny segments when the data to be sent increases in small 2036 increments, while the SWS avoidance algorithm discourages small 2037 segments resulting from the right window edge advancing in small 2038 increments. 2040 3.7.6.2.1. Sender's Algorithm - When to Send Data 2042 A TCP implementation MUST include a SWS avoidance algorithm in the 2043 sender (MUST-38). 2045 The Nagle algorithm from Section 3.6.4 additionally describes how to 2046 coalesce short segments. 2048 The sender's SWS avoidance algorithm is more difficult than the 2049 receivers's, because the sender does not know (directly) the 2050 receiver's total buffer space RCV.BUFF. An approach that has been 2051 found to work well is for the sender to calculate Max(SND.WND), the 2052 maximum send window it has seen so far on the connection, and to use 2053 this value as an estimate of RCV.BUFF. Unfortunately, this can only 2054 be an estimate; the receiver may at any time reduce the size of 2055 RCV.BUFF. To avoid a resulting deadlock, it is necessary to have a 2056 timeout to force transmission of data, overriding the SWS avoidance 2057 algorithm. In practice, this timeout should seldom occur. 2059 The "useable window" is: 2061 U = SND.UNA + SND.WND - SND.NXT 2063 i.e., the offered window less the amount of data sent but not 2064 acknowledged. If D is the amount of data queued in the sending TCP 2065 endpoint but not yet sent, then the following set of rules is 2066 recommended. 2068 Send data: 2070 (1) if a maximum-sized segment can be sent, i.e, if: 2072 min(D,U) >= Eff.snd.MSS; 2074 (2) or if the data is pushed and all queued data can be sent now, 2075 i.e., if: 2077 [SND.NXT = SND.UNA and] PUSHED and D <= U 2079 (the bracketed condition is imposed by the Nagle algorithm); 2081 (3) or if at least a fraction Fs of the maximum window can be sent, 2082 i.e., if: 2084 [SND.NXT = SND.UNA and] 2086 min(D.U) >= Fs * Max(SND.WND); 2088 (4) or if data is PUSHed and the override timeout occurs. 2090 Here Fs is a fraction whose recommended value is 1/2. The override 2091 timeout should be in the range 0.1 - 1.0 seconds. It may be 2092 convenient to combine this timer with the timer used to probe zero 2093 windows (Section 3.7.6.1). 2095 3.7.6.2.2. Receiver's Algorithm - When to Send a Window Update 2097 A TCP implementation MUST include a SWS avoidance algorithm in the 2098 receiver (MUST-39). 2100 The receiver's SWS avoidance algorithm determines when the right 2101 window edge may be advanced; this is customarily known as "updating 2102 the window". This algorithm combines with the delayed ACK algorithm 2103 (Section 3.7.6.3) to determine when an ACK segment containing the 2104 current window will really be sent to the receiver. 2106 The solution to receiver SWS is to avoid advancing the right window 2107 edge RCV.NXT+RCV.WND in small increments, even if data is received 2108 from the network in small segments. 2110 Suppose the total receive buffer space is RCV.BUFF. At any given 2111 moment, RCV.USER octets of this total may be tied up with data that 2112 has been received and acknowledged but that the user process has not 2113 yet consumed. When the connection is quiescent, RCV.WND = RCV.BUFF 2114 and RCV.USER = 0. 2116 Keeping the right window edge fixed as data arrives and is 2117 acknowledged requires that the receiver offer less than its full 2118 buffer space, i.e., the receiver must specify a RCV.WND that keeps 2119 RCV.NXT+RCV.WND constant as RCV.NXT increases. Thus, the total 2120 buffer space RCV.BUFF is generally divided into three parts: 2122 |<------- RCV.BUFF ---------------->| 2123 1 2 3 2124 ----|---------|------------------|------|---- 2125 RCV.NXT ^ 2126 (Fixed) 2128 1 - RCV.USER = data received but not yet consumed; 2129 2 - RCV.WND = space advertised to sender; 2130 3 - Reduction = space available but not yet 2131 advertised. 2133 The suggested SWS avoidance algorithm for the receiver is to keep 2134 RCV.NXT+RCV.WND fixed until the reduction satisfies: 2136 RCV.BUFF - RCV.USER - RCV.WND >= 2138 min( Fr * RCV.BUFF, Eff.snd.MSS ) 2140 where Fr is a fraction whose recommended value is 1/2, and 2141 Eff.snd.MSS is the effective send MSS for the connection (see 2142 Section 3.6.1). When the inequality is satisfied, RCV.WND is set to 2143 RCV.BUFF-RCV.USER. 2145 Note that the general effect of this algorithm is to advance RCV.WND 2146 in increments of Eff.snd.MSS (for realistic receive buffers: 2147 Eff.snd.MSS < RCV.BUFF/2). Note also that the receiver must use its 2148 own Eff.snd.MSS, assuming it is the same as the sender's. 2150 3.7.6.3. Delayed Acknowledgements - When to Send an ACK Segment 2152 A host that is receiving a stream of TCP data segments can increase 2153 efficiency in both the Internet and the hosts by sending fewer than 2154 one ACK (acknowledgment) segment per data segment received; this is 2155 known as a "delayed ACK". 2157 A TCP endpoint SHOULD implement a delayed ACK (SHLD-18), but an ACK 2158 should not be excessively delayed; in particular, the delay MUST be 2159 less than 0.5 seconds (MUST-40), and in a stream of full-sized 2160 segments there SHOULD be an ACK for at least every second segment 2161 (SHLD-19). Excessive delays on ACKs can disturb the round-trip 2162 timing and packet "clocking" algorithms. More complete discussion of 2163 delayed ACK behavior is in Section 4.2 of RFC 5681 [31], including 2164 rules for streams of segments that are not full-sized. Note that 2165 there are several current practices that further lead to a reduced 2166 number of ACKs, including generic receive offload (GRO), ACK 2167 compression, and ACK decimation [22]. 2169 3.8. Interfaces 2171 There are of course two interfaces of concern: the user/TCP interface 2172 and the TCP/lower-level interface. We have a fairly elaborate model 2173 of the user/TCP interface, but the interface to the lower level 2174 protocol module is left unspecified here, since it will be specified 2175 in detail by the specification of the lower level protocol. For the 2176 case that the lower level is IP we note some of the parameter values 2177 that TCP implementations might use. 2179 3.8.1. User/TCP Interface 2181 The following functional description of user commands to the TCP 2182 implementation is, at best, fictional, since every operating system 2183 will have different facilities. Consequently, we must warn readers 2184 that different TCP implementations may have different user 2185 interfaces. However, all TCP implementations must provide a certain 2186 minimum set of services to guarantee that all TCP implementations can 2187 support the same protocol hierarchy. This section specifies the 2188 functional interfaces required of all TCP implementations. 2190 Section 3.1 of [49] also identifies primitives provided by TCP, and 2191 could be used as an additional reference for implementers. 2193 TCP User Commands 2195 The following sections functionally characterize a USER/TCP 2196 interface. The notation used is similar to most procedure or 2197 function calls in high level languages, but this usage is not 2198 meant to rule out trap type service calls. 2200 The user commands described below specify the basic functions the 2201 TCP implementation must perform to support interprocess 2202 communication. Individual implementations must define their own 2203 exact format, and may provide combinations or subsets of the basic 2204 functions in single calls. In particular, some implementations 2205 may wish to automatically OPEN a connection on the first SEND or 2206 RECEIVE issued by the user for a given connection. 2208 In providing interprocess communication facilities, the TCP 2209 implementation must not only accept commands, but must also return 2210 information to the processes it serves. The latter consists of: 2212 (a) general information about a connection (e.g., interrupts, 2213 remote close, binding of unspecified remote socket). 2215 (b) replies to specific user commands indicating success or 2216 various types of failure. 2218 Open 2220 Format: OPEN (local port, remote socket, active/passive [, 2221 timeout] [, DiffServ field] [, security/compartment] [local IP 2222 address,] [, options]) -> local connection name 2224 If the active/passive flag is set to passive, then this is a 2225 call to LISTEN for an incoming connection. A passive open may 2226 have either a fully specified remote socket to wait for a 2227 particular connection or an unspecified remote socket to wait 2228 for any call. A fully specified passive call can be made 2229 active by the subsequent execution of a SEND. 2231 A transmission control block (TCB) is created and partially 2232 filled in with data from the OPEN command parameters. 2234 Every passive OPEN call either creates a new connection record 2235 in LISTEN state, or it returns an error; it MUST NOT affect any 2236 previously created connection record (MUST-41). 2238 A TCP implementation that supports multiple concurrent 2239 connections MUST provide an OPEN call that will functionally 2240 allow an application to LISTEN on a port while a connection 2241 block with the same local port is in SYN-SENT or SYN-RECEIVED 2242 state (MUST-42). 2244 On an active OPEN command, the TCP endpoint will begin the 2245 procedure to synchronize (i.e., establish) the connection at 2246 once. 2248 The timeout, if present, permits the caller to set up a timeout 2249 for all data submitted to TCP. If data is not successfully 2250 delivered to the destination within the timeout period, the TCP 2251 endpoint will abort the connection. The present global default 2252 is five minutes. 2254 The TCP implementation or some component of the operating 2255 system will verify the users authority to open a connection 2256 with the specified DiffServ field value or security/ 2257 compartment. The absence of a DiffServ field value or 2258 security/compartment specification in the OPEN call indicates 2259 the default values must be used. 2261 TCP will accept incoming requests as matching only if the 2262 security/compartment information is exactly the same as that 2263 requested in the OPEN call. 2265 The DiffServ field value indicated by the user only impacts 2266 outgoing packets, may be altered en route through the network, 2267 and has no direct bearing or relation to received packets. 2269 A local connection name will be returned to the user by the TCP 2270 implementation. The local connection name can then be used as 2271 a short hand term for the connection defined by the pair. 2274 The optional "local IP address" parameter MUST be supported to 2275 allow the specification of the local IP address (MUST-43). 2276 This enables applications that need to select the local IP 2277 address used when multihoming is present. 2279 A passive OPEN call with a specified "local IP address" 2280 parameter will await an incoming connection request to that 2281 address. If the parameter is unspecified, a passive OPEN will 2282 await an incoming connection request to any local IP address, 2283 and then bind the local IP address of the connection to the 2284 particular address that is used. 2286 For an active OPEN call, a specified "local IP address" 2287 parameter will be used for opening the connection. If the 2288 parameter is unspecified, the host will choose an appropriate 2289 local IP address (see RFC 1122 section 3.3.4.2). 2291 If an application on a multihomed host does not specify the 2292 local IP address when actively opening a TCP connection, then 2293 the TCP implementation MUST ask the IP layer to select a local 2294 IP address before sending the (first) SYN (MUST-44). See the 2295 function GET_SRCADDR() in Section 3.4 of RFC 1122. 2297 At all other times, a previous segment has either been sent or 2298 received on this connection, and TCP implementations MUST use 2299 the same local address is used that was used in those previous 2300 segments (MUST-45). 2302 A TCP implementation MUST reject as an error a local OPEN call 2303 for an invalid remote IP address (e.g., a broadcast or 2304 multicast address) (MUST-46). 2306 Send 2308 Format: SEND (local connection name, buffer address, byte 2309 count, PUSH flag (optional), URGENT flag [,timeout]) 2311 This call causes the data contained in the indicated user 2312 buffer to be sent on the indicated connection. If the 2313 connection has not been opened, the SEND is considered an 2314 error. Some implementations may allow users to SEND first; in 2315 which case, an automatic OPEN would be done. For example, this 2316 might be one way for application data to be included in SYN 2317 segments. If the calling process is not authorized to use this 2318 connection, an error is returned. 2320 A TCP endpoint MAY implement PUSH flags on SEND calls (MAY-15). 2321 If PUSH flags are not implemented, then the sending TCP peer: 2323 (1) MUST NOT buffer data indefinitely (MUST-60), and (2) MUST 2324 set the PSH bit in the last buffered segment (i.e., when there 2325 is no more queued data to be sent) (MUST-61). The remaining 2326 description below assumes the PUSH flag is supported on SEND 2327 calls. 2329 If the PUSH flag is set, the application intends the data to be 2330 transmitted promptly to the receiver, and the PUSH bit will be 2331 set in the last TCP segment created from the buffer. When an 2332 application issues a series of SEND calls without setting the 2333 PUSH flag, the TCP implementation MAY aggregate the data 2334 internally without sending it (MAY-16). 2336 The PSH bit is not a record marker and is independent of 2337 segment boundaries. The transmitter SHOULD collapse successive 2338 bits when it packetizes data, to send the largest possible 2339 segment (SHLD-27). 2341 If the PUSH flag is not set, the data may be combined with data 2342 from subsequent SENDs for transmission efficiency. Note that 2343 when the Nagle algorithm is in use, TCP implementations may 2344 buffer the data before sending, without regard to the PUSH flag 2345 (see Section 3.6.4). 2347 An application program is logically required to set the PUSH 2348 flag in a SEND call whenever it needs to force delivery of the 2349 data to avoid a communication deadlock. However, a TCP 2350 implementation SHOULD send a maximum-sized segment whenever 2351 possible (SHLD-28), to improve performance (see 2352 Section 3.7.6.2.1). 2354 New applications SHOULD NOT set the URGENT flag [35] due to 2355 implementation differences and middlebox issues (SHLD-13). 2357 If the URGENT flag is set, segments sent to the destination TCP 2358 peer will have the urgent pointer set. The receiving TCP peer 2359 will signal the urgent condition to the receiving process if 2360 the urgent pointer indicates that data preceding the urgent 2361 pointer has not been consumed by the receiving process. The 2362 purpose of urgent is to stimulate the receiver to process the 2363 urgent data and to indicate to the receiver when all the 2364 currently known urgent data has been received. The number of 2365 times the sending user's TCP implementation signals urgent will 2366 not necessarily be equal to the number of times the receiving 2367 user will be notified of the presence of urgent data. 2369 If no remote socket was specified in the OPEN, but the 2370 connection is established (e.g., because a LISTENing connection 2371 has become specific due to a remote segment arriving for the 2372 local socket), then the designated buffer is sent to the 2373 implied remote socket. Users who make use of OPEN with an 2374 unspecified remote socket can make use of SEND without ever 2375 explicitly knowing the remote socket address. 2377 However, if a SEND is attempted before the remote socket 2378 becomes specified, an error will be returned. Users can use 2379 the STATUS call to determine the status of the connection. 2380 Some TCP implementations may notify the user when an 2381 unspecified socket is bound. 2383 If a timeout is specified, the current user timeout for this 2384 connection is changed to the new one. 2386 In the simplest implementation, SEND would not return control 2387 to the sending process until either the transmission was 2388 complete or the timeout had been exceeded. However, this 2389 simple method is both subject to deadlocks (for example, both 2390 sides of the connection might try to do SENDs before doing any 2391 RECEIVEs) and offers poor performance, so it is not 2392 recommended. A more sophisticated implementation would return 2393 immediately to allow the process to run concurrently with 2394 network I/O, and, furthermore, to allow multiple SENDs to be in 2395 progress. Multiple SENDs are served in first come, first 2396 served order, so the TCP endpoint will queue those it cannot 2397 service immediately. 2399 We have implicitly assumed an asynchronous user interface in 2400 which a SEND later elicits some kind of SIGNAL or pseudo- 2401 interrupt from the serving TCP endpoint. An alternative is to 2402 return a response immediately. For instance, SENDs might 2403 return immediate local acknowledgment, even if the segment sent 2404 had not been acknowledged by the distant TCP endpoint. We 2405 could optimistically assume eventual success. If we are wrong, 2406 the connection will close anyway due to the timeout. In 2407 implementations of this kind (synchronous), there will still be 2408 some asynchronous signals, but these will deal with the 2409 connection itself, and not with specific segments or buffers. 2411 In order for the process to distinguish among error or success 2412 indications for different SENDs, it might be appropriate for 2413 the buffer address to be returned along with the coded response 2414 to the SEND request. TCP-to-user signals are discussed below, 2415 indicating the information that should be returned to the 2416 calling process. 2418 Receive 2419 Format: RECEIVE (local connection name, buffer address, byte 2420 count) -> byte count, urgent flag, push flag (optional) 2422 This command allocates a receiving buffer associated with the 2423 specified connection. If no OPEN precedes this command or the 2424 calling process is not authorized to use this connection, an 2425 error is returned. 2427 In the simplest implementation, control would not return to the 2428 calling program until either the buffer was filled, or some 2429 error occurred, but this scheme is highly subject to deadlocks. 2430 A more sophisticated implementation would permit several 2431 RECEIVEs to be outstanding at once. These would be filled as 2432 segments arrive. This strategy permits increased throughput at 2433 the cost of a more elaborate scheme (possibly asynchronous) to 2434 notify the calling program that a PUSH has been seen or a 2435 buffer filled. 2437 A TCP receiver MAY pass a received PSH flag to the application 2438 layer via the PUSH flag in the interface (MAY-17), but it is 2439 not required (this was clarified in RFC 1122 section 4.2.2.2). 2440 The remainder of text describing the RECEIVE call below assumes 2441 that passing the PUSH indication is supported. 2443 If enough data arrive to fill the buffer before a PUSH is seen, 2444 the PUSH flag will not be set in the response to the RECEIVE. 2445 The buffer will be filled with as much data as it can hold. If 2446 a PUSH is seen before the buffer is filled the buffer will be 2447 returned partially filled and PUSH indicated. 2449 If there is urgent data the user will have been informed as 2450 soon as it arrived via a TCP-to-user signal. The receiving 2451 user should thus be in "urgent mode". If the URGENT flag is 2452 on, additional urgent data remains. If the URGENT flag is off, 2453 this call to RECEIVE has returned all the urgent data, and the 2454 user may now leave "urgent mode". Note that data following the 2455 urgent pointer (non-urgent data) cannot be delivered to the 2456 user in the same buffer with preceding urgent data unless the 2457 boundary is clearly marked for the user. 2459 To distinguish among several outstanding RECEIVEs and to take 2460 care of the case that a buffer is not completely filled, the 2461 return code is accompanied by both a buffer pointer and a byte 2462 count indicating the actual length of the data received. 2464 Alternative implementations of RECEIVE might have the TCP 2465 endpoint allocate buffer storage, or the TCP endpoint might 2466 share a ring buffer with the user. 2468 Close 2470 Format: CLOSE (local connection name) 2472 This command causes the connection specified to be closed. If 2473 the connection is not open or the calling process is not 2474 authorized to use this connection, an error is returned. 2475 Closing connections is intended to be a graceful operation in 2476 the sense that outstanding SENDs will be transmitted (and 2477 retransmitted), as flow control permits, until all have been 2478 serviced. Thus, it should be acceptable to make several SEND 2479 calls, followed by a CLOSE, and expect all the data to be sent 2480 to the destination. It should also be clear that users should 2481 continue to RECEIVE on CLOSING connections, since the remote 2482 peer may be trying to transmit the last of its data. Thus, 2483 CLOSE means "I have no more to send" but does not mean "I will 2484 not receive any more." It may happen (if the user level 2485 protocol is not well thought out) that the closing side is 2486 unable to get rid of all its data before timing out. In this 2487 event, CLOSE turns into ABORT, and the closing TCP peer gives 2488 up. 2490 The user may CLOSE the connection at any time on their own 2491 initiative, or in response to various prompts from the TCP 2492 implementation (e.g., remote close executed, transmission 2493 timeout exceeded, destination inaccessible). 2495 Because closing a connection requires communication with the 2496 remote TCP peer, connections may remain in the closing state 2497 for a short time. Attempts to reopen the connection before the 2498 TCP peer replies to the CLOSE command will result in error 2499 responses. 2501 Close also implies push function. 2503 Status 2505 Format: STATUS (local connection name) -> status data 2507 This is an implementation dependent user command and could be 2508 excluded without adverse effect. Information returned would 2509 typically come from the TCB associated with the connection. 2511 This command returns a data block containing the following 2512 information: 2514 local socket, 2515 remote socket, 2516 local connection name, 2517 receive window, 2518 send window, 2519 connection state, 2520 number of buffers awaiting acknowledgment, 2521 number of buffers pending receipt, 2522 urgent state, 2523 DiffServ field value, 2524 security/compartment, 2525 and transmission timeout. 2527 Depending on the state of the connection, or on the 2528 implementation itself, some of this information may not be 2529 available or meaningful. If the calling process is not 2530 authorized to use this connection, an error is returned. This 2531 prevents unauthorized processes from gaining information about 2532 a connection. 2534 Abort 2536 Format: ABORT (local connection name) 2538 This command causes all pending SENDs and RECEIVES to be 2539 aborted, the TCB to be removed, and a special RESET message to 2540 be sent to the remote TCP peer of the connection. Depending on 2541 the implementation, users may receive abort indications for 2542 each outstanding SEND or RECEIVE, or may simply receive an 2543 ABORT-acknowledgment. 2545 Flush 2547 Some TCP implementations have included a FLUSH call, which will 2548 empty the TCP send queue of any data that the user has issued 2549 SEND calls but is still to the right of the current send 2550 window. That is, it flushes as much queued send data as 2551 possible without losing sequence number synchronization. The 2552 FLUSH call MAY be implemented (MAY-14). 2554 Asynchronous Reports 2556 There MUST be a mechanism for reporting soft TCP error 2557 conditions to the application (MUST-47). Generically, we 2558 assume this takes the form of an application-supplied 2559 ERROR_REPORT routine that may be upcalled asynchronously from 2560 the transport layer: 2562 ERROR_REPORT(local connection name, reason, subreason) 2564 The precise encoding of the reason and subreason parameters is 2565 not specified here. However, the conditions that are reported 2566 asynchronously to the application MUST include: 2568 * ICMP error message arrived (see Section 3.8.2.2 for 2569 description of handling each ICMP message type, since some 2570 message types need to be suppressed from generating reports 2571 to the application) 2573 * Excessive retransmissions (see Section 3.7.3) 2575 * Urgent pointer advance (see Section 3.7.5) 2577 However, an application program that does not want to receive 2578 such ERROR_REPORT calls SHOULD be able to effectively disable 2579 these calls (SHLD-20). 2581 Set Differentiated Services Field (IPv4 TOS or IPv6 Traffic Class) 2583 The application layer MUST be able to specify the 2584 Differentiated Services field for segments that are sent on a 2585 connection (MUST-48). The Differentiated Services field 2586 includes the 6-bit Differentiated Services Code Point (DSCP) 2587 value. It is not required, but the application SHOULD be able 2588 to change the Differentiated Services field during the 2589 connection lifetime (SHLD-21). TCP implementations SHOULD pass 2590 the current Differentiated Services field value without change 2591 to the IP layer, when it sends segments on the connection 2592 (SHLD-22). 2594 The Differentiated Services field will be specified 2595 independently in each direction on the connection, so that the 2596 receiver application will specify the Differentiated Services 2597 field used for ACK segments. 2599 TCP implementations MAY pass the most recently received 2600 Differentiated Services field up to the application (MAY-9). 2602 3.8.2. TCP/Lower-Level Interface 2604 The TCP endpoint calls on a lower level protocol module to actually 2605 send and receive information over a network. The two current 2606 standard Internet Protocol (IP) versions layered below TCP are IPv4 2607 [1] and IPv6 [12]. 2609 If the lower level protocol is IPv4 it provides arguments for a type 2610 of service (used within the Differentiated Services field) and for a 2611 time to live. TCP uses the following settings for these parameters: 2613 DiffServ field: The IP header value for the DiffServ field is 2614 given by the user. This includes the bits of the DiffServ Code 2615 Point (DSCP). 2617 Time to Live (TTL): The TTL value used to send TCP segments MUST 2618 be configurable (MUST-49). 2620 Note that RFC 793 specified one minute (60 seconds) as a 2621 constant for the TTL, because the assumed maximum segment 2622 lifetime was two minutes. This was intended to explicitly ask 2623 that a segment be destroyed if it cannot be delivered by the 2624 internet system within one minute. RFC 1122 changed this 2625 specification to require that the TTL be configurable. 2627 Note that the DiffServ field is permitted to change during a 2628 connection (Section 4.2.4.2 of RFC 1122). However, the 2629 application interface might not support this ability, and the 2630 application does not have knowledge about individual TCP 2631 segments, so this can only be done on a coarse granularity, at 2632 best. This limitation is further discussed in RFC 7657 (sec 2633 5.1, 5.3, and 6) [46]. Generally, an application SHOULD NOT 2634 change the DiffServ field value during the course of a 2635 connection (SHLD-23). 2637 Any lower level protocol will have to provide the source address, 2638 destination address, and protocol fields, and some way to determine 2639 the "TCP length", both to provide the functional equivalent service 2640 of IP and to be used in the TCP checksum. 2642 When received options are passed up to TCP from the IP layer, TCP 2643 implementations MUST ignore options that it does not understand 2644 (MUST-50). 2646 A TCP implementation MAY support the Time Stamp (MAY-10) and Record 2647 Route (MAY-11) options. 2649 3.8.2.1. Source Routing 2651 If the lower level is IP (or other protocol that provides this 2652 feature) and source routing is used, the interface must allow the 2653 route information to be communicated. This is especially important 2654 so that the source and destination addresses used in the TCP checksum 2655 be the originating source and ultimate destination. It is also 2656 important to preserve the return route to answer connection requests. 2658 An application MUST be able to specify a source route when it 2659 actively opens a TCP connection (MUST-51), and this MUST take 2660 precedence over a source route received in a datagram (MUST-52). 2662 When a TCP connection is OPENed passively and a packet arrives with a 2663 completed IP Source Route option (containing a return route), TCP 2664 implementations MUST save the return route and use it for all 2665 segments sent on this connection (MUST-53). If a different source 2666 route arrives in a later segment, the later definition SHOULD 2667 override the earlier one (SHLD-24). 2669 3.8.2.2. ICMP Messages 2671 TCP implementations MUST act on an ICMP error message passed up from 2672 the IP layer, directing it to the connection that created the error 2673 (MUST-54). The necessary demultiplexing information can be found in 2674 the IP header contained within the ICMP message. 2676 This applies to ICMPv6 in addition to IPv4 ICMP. 2678 [29] contains discussion of specific ICMP and ICMPv6 messages 2679 classified as either "soft" or "hard" errors that may bear different 2680 responses. Treatment for classes of ICMP messages is described 2681 below: 2683 Source Quench 2684 TCP implementations MUST silently discard any received ICMP Source 2685 Quench messages (MUST-55). See [10] for discussion. 2687 Soft Errors 2688 For ICMP these include: Destination Unreachable -- codes 0, 1, 5, 2689 Time Exceeded -- codes 0, 1, and Parameter Problem. 2690 For ICMPv6 these include: Destination Unreachable -- codes 0 and 3, 2691 Time Exceeded -- codes 0, 1, and Parameter Problem -- codes 0, 1, 2 2692 Since these Unreachable messages indicate soft error conditions, 2693 TCP implementations MUST NOT abort the connection (MUST-56), and it 2694 SHOULD make the information available to the application (SHLD-25). 2696 Hard Errors 2697 For ICMP these include Destination Unreachable -- codes 2-4"> 2698 These are hard error conditions, so TCP implementations SHOULD 2699 abort the connection (SHLD-26). [29] notes that some 2700 implementations do not abort connections when an ICMP hard error is 2701 received for a connection that is in any of the synchronized 2702 states. 2704 Note that [29] section 4 describes widespread implementation behavior 2705 that treats soft errors as hard errors during connection 2706 establishment. 2708 3.8.2.3. Source Address Validation 2710 RFC 1122 requires addresses to be validated in incoming SYN packets: 2712 An incoming SYN with an invalid source address MUST be ignored 2713 either by TCP or by the IP layer (MUST-63) (Section 3.2.1.3 of 2714 [15]). 2716 A TCP implementation MUST silently discard an incoming SYN segment 2717 that is addressed to a broadcast or multicast address (MUST-57). 2719 This prevents connection state and replies from being erroneously 2720 generated, and implementers should note that this guidance is 2721 applicable to all incoming segments, not just SYNs, as specifically 2722 indicated in RFC 1122. 2724 3.9. Event Processing 2726 The processing depicted in this section is an example of one possible 2727 implementation. Other implementations may have slightly different 2728 processing sequences, but they should differ from those in this 2729 section only in detail, not in substance. 2731 The activity of the TCP endpoint can be characterized as responding 2732 to events. The events that occur can be cast into three categories: 2733 user calls, arriving segments, and timeouts. This section describes 2734 the processing the TCP endpoint does in response to each of the 2735 events. In many cases the processing required depends on the state 2736 of the connection. 2738 Events that occur: 2740 User Calls 2742 OPEN 2743 SEND 2744 RECEIVE 2745 CLOSE 2746 ABORT 2747 STATUS 2749 Arriving Segments 2751 SEGMENT ARRIVES 2753 Timeouts 2755 USER TIMEOUT 2756 RETRANSMISSION TIMEOUT 2757 TIME-WAIT TIMEOUT 2759 The model of the TCP/user interface is that user commands receive an 2760 immediate return and possibly a delayed response via an event or 2761 pseudo interrupt. In the following descriptions, the term "signal" 2762 means cause a delayed response. 2764 Error responses in this document are identified by character strings. 2765 For example, user commands referencing connections that do not exist 2766 receive "error: connection not open". 2768 Please note in the following that all arithmetic on sequence numbers, 2769 acknowledgment numbers, windows, et cetera, is modulo 2**32 the size 2770 of the sequence number space. Also note that "=<" means less than or 2771 equal to (modulo 2**32). 2773 A natural way to think about processing incoming segments is to 2774 imagine that they are first tested for proper sequence number (i.e., 2775 that their contents lie in the range of the expected "receive window" 2776 in the sequence number space) and then that they are generally queued 2777 and processed in sequence number order. 2779 When a segment overlaps other already received segments we 2780 reconstruct the segment to contain just the new data, and adjust the 2781 header fields to be consistent. 2783 Note that if no state change is mentioned the TCP connection stays in 2784 the same state. 2786 OPEN Call 2788 CLOSED STATE (i.e., TCB does not exist) 2790 Create a new transmission control block (TCB) to hold 2791 connection state information. Fill in local socket identifier, 2792 remote socket, DiffServ field, security/compartment, and user 2793 timeout information. Note that some parts of the remote socket 2794 may be unspecified in a passive OPEN and are to be filled in by 2795 the parameters of the incoming SYN segment. Verify the 2796 security and DiffServ value requested are allowed for this 2797 user, if not return "error: precedence not allowed" or "error: 2798 security/compartment not allowed." If passive enter the LISTEN 2799 state and return. If active and the remote socket is 2800 unspecified, return "error: remote socket unspecified"; if 2801 active and the remote socket is specified, issue a SYN segment. 2802 An initial send sequence number (ISS) is selected. A SYN 2803 segment of the form is sent. Set SND.UNA to 2804 ISS, SND.NXT to ISS+1, enter SYN-SENT state, and return. 2806 If the caller does not have access to the local socket 2807 specified, return "error: connection illegal for this process". 2808 If there is no room to create a new connection, return "error: 2809 insufficient resources". 2811 LISTEN STATE 2813 If active and the remote socket is specified, then change the 2814 connection from passive to active, select an ISS. Send a SYN 2815 segment, set SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT 2816 state. Data associated with SEND may be sent with SYN segment 2817 or queued for transmission after entering ESTABLISHED state. 2818 The urgent bit if requested in the command must be sent with 2819 the data segments sent as a result of this command. If there 2820 is no room to queue the request, respond with "error: 2821 insufficient resources". If Foreign socket was not specified, 2822 then return "error: remote socket unspecified". 2824 SYN-SENT STATE 2825 SYN-RECEIVED STATE 2826 ESTABLISHED STATE 2827 FIN-WAIT-1 STATE 2828 FIN-WAIT-2 STATE 2829 CLOSE-WAIT STATE 2830 CLOSING STATE 2831 LAST-ACK STATE 2832 TIME-WAIT STATE 2834 Return "error: connection already exists". 2836 SEND Call 2838 CLOSED STATE (i.e., TCB does not exist) 2840 If the user does not have access to such a connection, then 2841 return "error: connection illegal for this process". 2843 Otherwise, return "error: connection does not exist". 2845 LISTEN STATE 2847 If the remote socket is specified, then change the connection 2848 from passive to active, select an ISS. Send a SYN segment, set 2849 SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT state. Data 2850 associated with SEND may be sent with SYN segment or queued for 2851 transmission after entering ESTABLISHED state. The urgent bit 2852 if requested in the command must be sent with the data segments 2853 sent as a result of this command. If there is no room to queue 2854 the request, respond with "error: insufficient resources". If 2855 Foreign socket was not specified, then return "error: remote 2856 socket unspecified". 2858 SYN-SENT STATE 2859 SYN-RECEIVED STATE 2861 Queue the data for transmission after entering ESTABLISHED 2862 state. If no space to queue, respond with "error: insufficient 2863 resources". 2865 ESTABLISHED STATE 2866 CLOSE-WAIT STATE 2868 Segmentize the buffer and send it with a piggybacked 2869 acknowledgment (acknowledgment value = RCV.NXT). If there is 2870 insufficient space to remember this buffer, simply return 2871 "error: insufficient resources". 2873 If the urgent flag is set, then SND.UP <- SND.NXT and set the 2874 urgent pointer in the outgoing segments. 2876 FIN-WAIT-1 STATE 2877 FIN-WAIT-2 STATE 2878 CLOSING STATE 2879 LAST-ACK STATE 2880 TIME-WAIT STATE 2882 Return "error: connection closing" and do not service request. 2884 RECEIVE Call 2886 CLOSED STATE (i.e., TCB does not exist) 2888 If the user does not have access to such a connection, return 2889 "error: connection illegal for this process". 2891 Otherwise return "error: connection does not exist". 2893 LISTEN STATE 2894 SYN-SENT STATE 2895 SYN-RECEIVED STATE 2897 Queue for processing after entering ESTABLISHED state. If 2898 there is no room to queue this request, respond with "error: 2899 insufficient resources". 2901 ESTABLISHED STATE 2902 FIN-WAIT-1 STATE 2903 FIN-WAIT-2 STATE 2905 If insufficient incoming segments are queued to satisfy the 2906 request, queue the request. If there is no queue space to 2907 remember the RECEIVE, respond with "error: insufficient 2908 resources". 2910 Reassemble queued incoming segments into receive buffer and 2911 return to user. Mark "push seen" (PUSH) if this is the case. 2913 If RCV.UP is in advance of the data currently being passed to 2914 the user notify the user of the presence of urgent data. 2916 When the TCP endpoint takes responsibility for delivering data 2917 to the user that fact must be communicated to the sender via an 2918 acknowledgment. The formation of such an acknowledgment is 2919 described below in the discussion of processing an incoming 2920 segment. 2922 CLOSE-WAIT STATE 2924 Since the remote side has already sent FIN, RECEIVEs must be 2925 satisfied by text already on hand, but not yet delivered to the 2926 user. If no text is awaiting delivery, the RECEIVE will get a 2927 "error: connection closing" response. Otherwise, any remaining 2928 text can be used to satisfy the RECEIVE. 2930 CLOSING STATE 2931 LAST-ACK STATE 2932 TIME-WAIT STATE 2934 Return "error: connection closing". 2936 CLOSE Call 2938 CLOSED STATE (i.e., TCB does not exist) 2940 If the user does not have access to such a connection, return 2941 "error: connection illegal for this process". 2943 Otherwise, return "error: connection does not exist". 2945 LISTEN STATE 2947 Any outstanding RECEIVEs are returned with "error: closing" 2948 responses. Delete TCB, enter CLOSED state, and return. 2950 SYN-SENT STATE 2952 Delete the TCB and return "error: closing" responses to any 2953 queued SENDs, or RECEIVEs. 2955 SYN-RECEIVED STATE 2957 If no SENDs have been issued and there is no pending data to 2958 send, then form a FIN segment and send it, and enter FIN-WAIT-1 2959 state; otherwise queue for processing after entering 2960 ESTABLISHED state. 2962 ESTABLISHED STATE 2964 Queue this until all preceding SENDs have been segmentized, 2965 then form a FIN segment and send it. In any case, enter FIN- 2966 WAIT-1 state. 2968 FIN-WAIT-1 STATE 2969 FIN-WAIT-2 STATE 2971 Strictly speaking, this is an error and should receive a 2972 "error: connection closing" response. An "ok" response would 2973 be acceptable, too, as long as a second FIN is not emitted (the 2974 first FIN may be retransmitted though). 2976 CLOSE-WAIT STATE 2978 Queue this request until all preceding SENDs have been 2979 segmentized; then send a FIN segment, enter LAST-ACK state. 2981 CLOSING STATE 2982 LAST-ACK STATE 2983 TIME-WAIT STATE 2984 Respond with "error: connection closing". 2986 ABORT Call 2988 CLOSED STATE (i.e., TCB does not exist) 2990 If the user should not have access to such a connection, return 2991 "error: connection illegal for this process". 2993 Otherwise return "error: connection does not exist". 2995 LISTEN STATE 2997 Any outstanding RECEIVEs should be returned with "error: 2998 connection reset" responses. Delete TCB, enter CLOSED state, 2999 and return. 3001 SYN-SENT STATE 3003 All queued SENDs and RECEIVEs should be given "connection 3004 reset" notification, delete the TCB, enter CLOSED state, and 3005 return. 3007 SYN-RECEIVED STATE 3008 ESTABLISHED STATE 3009 FIN-WAIT-1 STATE 3010 FIN-WAIT-2 STATE 3011 CLOSE-WAIT STATE 3013 Send a reset segment: 3015 3017 All queued SENDs and RECEIVEs should be given "connection 3018 reset" notification; all segments queued for transmission 3019 (except for the RST formed above) or retransmission should be 3020 flushed, delete the TCB, enter CLOSED state, and return. 3022 CLOSING STATE LAST-ACK STATE TIME-WAIT STATE 3024 Respond with "ok" and delete the TCB, enter CLOSED state, and 3025 return. 3027 STATUS Call 3029 CLOSED STATE (i.e., TCB does not exist) 3031 If the user should not have access to such a connection, return 3032 "error: connection illegal for this process". 3034 Otherwise return "error: connection does not exist". 3036 LISTEN STATE 3038 Return "state = LISTEN", and the TCB pointer. 3040 SYN-SENT STATE 3042 Return "state = SYN-SENT", and the TCB pointer. 3044 SYN-RECEIVED STATE 3046 Return "state = SYN-RECEIVED", and the TCB pointer. 3048 ESTABLISHED STATE 3050 Return "state = ESTABLISHED", and the TCB pointer. 3052 FIN-WAIT-1 STATE 3054 Return "state = FIN-WAIT-1", and the TCB pointer. 3056 FIN-WAIT-2 STATE 3058 Return "state = FIN-WAIT-2", and the TCB pointer. 3060 CLOSE-WAIT STATE 3062 Return "state = CLOSE-WAIT", and the TCB pointer. 3064 CLOSING STATE 3066 Return "state = CLOSING", and the TCB pointer. 3068 LAST-ACK STATE 3070 Return "state = LAST-ACK", and the TCB pointer. 3072 TIME-WAIT STATE 3074 Return "state = TIME-WAIT", and the TCB pointer. 3076 SEGMENT ARRIVES 3078 If the state is CLOSED (i.e., TCB does not exist) then 3080 all data in the incoming segment is discarded. An incoming 3081 segment containing a RST is discarded. An incoming segment not 3082 containing a RST causes a RST to be sent in response. The 3083 acknowledgment and sequence field values are selected to make 3084 the reset sequence acceptable to the TCP endpoint that sent the 3085 offending segment. 3087 If the ACK bit is off, sequence number zero is used, 3089 3091 If the ACK bit is on, 3093 3095 Return. 3097 If the state is LISTEN then 3099 first check for an RST 3101 An incoming RST should be ignored. Return. 3103 second check for an ACK 3105 Any acknowledgment is bad if it arrives on a connection 3106 still in the LISTEN state. An acceptable reset segment 3107 should be formed for any arriving ACK-bearing segment. The 3108 RST should be formatted as follows: 3110 3112 Return. 3114 third check for a SYN 3116 If the SYN bit is set, check the security. If the security/ 3117 compartment on the incoming segment does not exactly match 3118 the security/compartment in the TCB then send a reset and 3119 return. 3121 3123 Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any 3124 other control or text should be queued for processing later. 3125 ISS should be selected and a SYN segment sent of the form: 3127 3129 SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 3130 state should be changed to SYN-RECEIVED. Note that any 3131 other incoming control or data (combined with SYN) will be 3132 processed in the SYN-RECEIVED state, but processing of SYN 3133 and ACK should not be repeated. If the listen was not fully 3134 specified (i.e., the remote socket was not fully specified), 3135 then the unspecified fields should be filled in now. 3137 fourth other text or control 3139 Any other control or text-bearing segment (not containing 3140 SYN) must have an ACK and thus would be discarded by the ACK 3141 processing. An incoming RST segment could not be valid, 3142 since it could not have been sent in response to anything 3143 sent by this incarnation of the connection. So, if this 3144 unlikely condition is reached, the correct behavior is to 3145 drop the segment and return. 3147 If the state is SYN-SENT then 3149 first check the ACK bit 3151 If the ACK bit is set 3153 If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset 3154 (unless the RST bit is set, if so drop the segment and 3155 return) 3157 3159 and discard the segment. Return. 3161 If SND.UNA < SEG.ACK =< SND.NXT then the ACK is 3162 acceptable. Some deployed TCP code has used the check 3163 SEG.ACK == SND.NXT (using "==" rather than "=<", but this 3164 is not appropriate when the stack is capable of sending 3165 data on the SYN, because the TCP peer may not accept and 3166 acknowledge all of the data on the SYN. 3168 second check the RST bit 3170 If the RST bit is set 3171 A potential blind reset attack is described in RFC 5961 3172 [34]. The mitigation described in that document has 3173 specific applicability explained therein, and is not a 3174 substitute for cryptographic protection (e.g. IPsec or 3175 TCP-AO). A TCP implementation that supports the RFC 5961 3176 mitigation SHOULD first check that the sequence number 3177 exactly matches RCV.NXT prior to executing the action in 3178 the next paragraph. 3180 If the ACK was acceptable then signal the user "error: 3181 connection reset", drop the segment, enter CLOSED state, 3182 delete TCB, and return. Otherwise (no ACK) drop the 3183 segment and return. 3185 third check the security 3187 If the security/compartment in the segment does not exactly 3188 match the security/compartment in the TCB, send a reset 3190 If there is an ACK 3192 3194 Otherwise 3196 3198 If a reset was sent, discard the segment and return. 3200 fourth check the SYN bit 3202 This step should be reached only if the ACK is ok, or there 3203 is no ACK, and it the segment did not contain a RST. 3205 If the SYN bit is on and the security/compartment is 3206 acceptable then, RCV.NXT is set to SEG.SEQ+1, IRS is set to 3207 SEG.SEQ. SND.UNA should be advanced to equal SEG.ACK (if 3208 there is an ACK), and any segments on the retransmission 3209 queue that are thereby acknowledged should be removed. 3211 If SND.UNA > ISS (our SYN has been ACKed), change the 3212 connection state to ESTABLISHED, form an ACK segment 3214 3216 and send it. Data or controls that were queued for 3217 transmission may be included. If there are other controls 3218 or text in the segment then continue processing at the sixth 3219 step below where the URG bit is checked, otherwise return. 3221 Otherwise enter SYN-RECEIVED, form a SYN,ACK segment 3223 3225 and send it. Set the variables: 3227 SND.WND <- SEG.WND 3228 SND.WL1 <- SEG.SEQ 3229 SND.WL2 <- SEG.ACK 3231 If there are other controls or text in the segment, queue 3232 them for processing after the ESTABLISHED state has been 3233 reached, return. 3235 Note that it is legal to send and receive application data 3236 on SYN segments (this is the "text in the segment" mentioned 3237 above. There has been significant misinformation and 3238 misunderstanding of this topic historically. Some firewalls 3239 and security devices consider this suspicious. However, the 3240 capability was used in T/TCP [17] and is used in TCP Fast 3241 Open (TFO) [44], so is important for implementations and 3242 network devices to permit. 3244 fifth, if neither of the SYN or RST bits is set then drop the 3245 segment and return. 3247 Otherwise, 3249 first check sequence number 3251 SYN-RECEIVED STATE 3252 ESTABLISHED STATE 3253 FIN-WAIT-1 STATE 3254 FIN-WAIT-2 STATE 3255 CLOSE-WAIT STATE 3256 CLOSING STATE 3257 LAST-ACK STATE 3258 TIME-WAIT STATE 3260 Segments are processed in sequence. Initial tests on 3261 arrival are used to discard old duplicates, but further 3262 processing is done in SEG.SEQ order. If a segment's 3263 contents straddle the boundary between old and new, only the 3264 new parts should be processed. 3266 In general, the processing of received segments MUST be 3267 implemented to aggregate ACK segments whenever possible 3268 (MUST-58). For example, if the TCP endpoint is processing a 3269 series of queued segments, it MUST process them all before 3270 sending any ACK segments (MUST-59). 3272 There are four cases for the acceptability test for an 3273 incoming segment: 3275 Segment Receive Test 3276 Length Window 3277 ------- ------- ------------------------------------------- 3279 0 0 SEG.SEQ = RCV.NXT 3281 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3283 >0 0 not acceptable 3285 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 3286 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 3288 In implementing sequence number validation as described 3289 here, please note Appendix A.2. 3291 If the RCV.WND is zero, no segments will be acceptable, but 3292 special allowance should be made to accept valid ACKs, URGs 3293 and RSTs. 3295 If an incoming segment is not acceptable, an acknowledgment 3296 should be sent in reply (unless the RST bit is set, if so 3297 drop the segment and return): 3299 3301 After sending the acknowledgment, drop the unacceptable 3302 segment and return. 3304 Note that for the TIME-WAIT state, there is an improved 3305 algorithm described in [36] for handling incoming SYN 3306 segments, that utilizes timestamps rather than relying on 3307 the sequence number check described here. When the improved 3308 algorithm is implemented, the logic above is not applicable 3309 for incoming SYN segments with timestamp options, received 3310 on a connection in the TIME-WAIT state. 3312 In the following it is assumed that the segment is the 3313 idealized segment that begins at RCV.NXT and does not exceed 3314 the window. One could tailor actual segments to fit this 3315 assumption by trimming off any portions that lie outside the 3316 window (including SYN and FIN), and only processing further 3317 if the segment then begins at RCV.NXT. Segments with higher 3318 beginning sequence numbers SHOULD be held for later 3319 processing (SHLD-31). 3321 second check the RST bit, 3323 RFC 5961 [34] section 3 describes a potential blind reset 3324 attack and optional mitigation approach. This does not 3325 provide a cryptographic protection (e.g. as in IPsec or TCP- 3326 AO), but can be applicable in situations described in RFC 3327 5961. For stacks implementing the RFC 5961 protection, the 3328 three checks below apply, otherwise processing for these 3329 states is indicated further below. 3331 1) If the RST bit is set and the sequence number is 3332 outside the current receive window, silently drop the 3333 segment. 3335 2) If the RST bit is set and the sequence number exactly 3336 matches the next expected sequence number (RCV.NXT), then 3337 TCP endpoints MUST reset the connection in the manner 3338 prescribed below according to the connection state. 3340 3) If the RST bit is set and the sequence number does not 3341 exactly match the next expected sequence value, yet is 3342 within the current receive window, TCP endpoints MUST 3343 send an acknowledgement (challenge ACK): 3345 3347 After sending the challenge ACK, TCP endpoints MUST drop 3348 the unacceptable segment and stop processing the incoming 3349 packet further. Note that RFC 5961 and Errata ID 4772 3350 contain additional considerations for ACK throttling in 3351 an implementation. 3353 SYN-RECEIVED STATE 3355 If the RST bit is set 3357 If this connection was initiated with a passive OPEN 3358 (i.e., came from the LISTEN state), then return this 3359 connection to LISTEN state and return. The user need 3360 not be informed. If this connection was initiated 3361 with an active OPEN (i.e., came from SYN-SENT state) 3362 then the connection was refused, signal the user 3363 "connection refused". In either case, all segments on 3364 the retransmission queue should be removed. And in 3365 the active OPEN case, enter the CLOSED state and 3366 delete the TCB, and return. 3368 ESTABLISHED 3369 FIN-WAIT-1 3370 FIN-WAIT-2 3371 CLOSE-WAIT 3373 If the RST bit is set then, any outstanding RECEIVEs and 3374 SEND should receive "reset" responses. All segment 3375 queues should be flushed. Users should also receive an 3376 unsolicited general "connection reset" signal. Enter the 3377 CLOSED state, delete the TCB, and return. 3379 CLOSING STATE 3380 LAST-ACK STATE 3381 TIME-WAIT 3383 If the RST bit is set then, enter the CLOSED state, 3384 delete the TCB, and return. 3386 third check security 3388 SYN-RECEIVED 3390 If the security/compartment in the segment does not 3391 exactly match the security/compartment in the TCB then 3392 send a reset, and return. 3394 ESTABLISHED 3395 FIN-WAIT-1 3396 FIN-WAIT-2 3397 CLOSE-WAIT 3398 CLOSING 3399 LAST-ACK 3400 TIME-WAIT 3402 If the security/compartment in the segment does not 3403 exactly match the security/compartment in the TCB then 3404 send a reset, any outstanding RECEIVEs and SEND should 3405 receive "reset" responses. All segment queues should be 3406 flushed. Users should also receive an unsolicited 3407 general "connection reset" signal. Enter the CLOSED 3408 state, delete the TCB, and return. 3410 Note this check is placed following the sequence check to 3411 prevent a segment from an old connection between these port 3412 numbers with a different security from causing an abort of 3413 the current connection. 3415 fourth, check the SYN bit, 3417 SYN-RECEIVED 3419 If the connection was initiated with a passive OPEN, then 3420 return this connection to the LISTEN state and return. 3421 Otherwise, handle per the directions for synchronized 3422 states below. 3424 ESTABLISHED STATE 3425 FIN-WAIT STATE-1 3426 FIN-WAIT STATE-2 3427 CLOSE-WAIT STATE 3428 CLOSING STATE 3429 LAST-ACK STATE 3430 TIME-WAIT STATE 3432 If the SYN bit is set in these synchronized states, it 3433 may be either a legitimate new connection attempt (e.g. 3434 in the case of TIME-WAIT), an error where the connection 3435 should be reset, or the result of an attack attempt, as 3436 described in RFC 5961 [34]. For the TIME-WAIT state, new 3437 connections can be accepted if the timestamp option is 3438 used and meets expectations (per [36]). For all other 3439 cases, RFC 5961 provides a mitigation with applicability 3440 to some situations, though there are also alternatives 3441 that offer cryptographic protection (see Section 6). RFC 3442 5961 recommends that in these synchronized states, if the 3443 SYN bit is set, irrespective of the sequence number, TCP 3444 endpoints MUST send a "challenge ACK" to the remote peer: 3446 3448 After sending the acknowledgement, TCP implementations 3449 MUST drop the unacceptable segment and stop processing 3450 further. Note that RFC 5961 and Errata ID 4772 contain 3451 additional ACK throttling notes for an implementation. 3453 For implementations that do not follow RFC 5961, the 3454 original RFC 793 behavior follows in this paragraph. If 3455 the SYN is in the window it is an error, send a reset, 3456 any outstanding RECEIVEs and SEND should receive "reset" 3457 responses, all segment queues should be flushed, the user 3458 should also receive an unsolicited general "connection 3459 reset" signal, enter the CLOSED state, delete the TCB, 3460 and return. 3462 If the SYN is not in the window this step would not be 3463 reached and an ACK would have been sent in the first step 3464 (sequence number check). 3466 fifth check the ACK field, 3468 if the ACK bit is off drop the segment and return 3470 if the ACK bit is on 3472 RFC 5961 [34] section 5 describes a potential blind data 3473 injection attack, and mitigation that implementations MAY 3474 choose to include (MAY-12). TCP stacks that implement 3475 RFC 5961 MUST add an input check that the ACK value is 3476 acceptable only if it is in the range of ((SND.UNA - 3477 MAX.SND.WND) =< SEG.ACK =< SND.NXT). All incoming 3478 segments whose ACK value doesn't satisfy the above 3479 condition MUST be discarded and an ACK sent back. The 3480 new state variable MAX.SND.WND is defined as the largest 3481 window that the local sender has ever received from its 3482 peer (subject to window scaling) or may be hard-coded to 3483 a maximum permissible window value. When the ACK value 3484 is acceptable, the processing per-state below applies: 3486 SYN-RECEIVED STATE 3488 If SND.UNA < SEG.ACK =< SND.NXT then enter ESTABLISHED 3489 state and continue processing with variables below set 3490 to: 3492 SND.WND <- SEG.WND 3493 SND.WL1 <- SEG.SEQ 3494 SND.WL2 <- SEG.ACK 3496 If the segment acknowledgment is not acceptable, 3497 form a reset segment, 3499 3501 and send it. 3503 ESTABLISHED STATE 3505 If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- 3506 SEG.ACK. Any segments on the retransmission queue 3507 that are thereby entirely acknowledged are removed. 3508 Users should receive positive acknowledgments for 3509 buffers that have been SENT and fully acknowledged 3510 (i.e., SEND buffer should be returned with "ok" 3511 response). If the ACK is a duplicate (SEG.ACK =< 3512 SND.UNA), it can be ignored. If the ACK acks 3513 something not yet sent (SEG.ACK > SND.NXT) then send 3514 an ACK, drop the segment, and return. 3516 If SND.UNA =< SEG.ACK =< SND.NXT, the send window 3517 should be updated. If (SND.WL1 < SEG.SEQ or (SND.WL1 3518 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- 3519 SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- 3520 SEG.ACK. 3522 Note that SND.WND is an offset from SND.UNA, that 3523 SND.WL1 records the sequence number of the last 3524 segment used to update SND.WND, and that SND.WL2 3525 records the acknowledgment number of the last segment 3526 used to update SND.WND. The check here prevents using 3527 old segments to update the window. 3529 FIN-WAIT-1 STATE 3531 In addition to the processing for the ESTABLISHED 3532 state, if the FIN segment is now acknowledged then 3533 enter FIN-WAIT-2 and continue processing in that 3534 state. 3536 FIN-WAIT-2 STATE 3538 In addition to the processing for the ESTABLISHED 3539 state, if the retransmission queue is empty, the 3540 user's CLOSE can be acknowledged ("ok") but do not 3541 delete the TCB. 3543 CLOSE-WAIT STATE 3545 Do the same processing as for the ESTABLISHED state. 3547 CLOSING STATE 3548 In addition to the processing for the ESTABLISHED 3549 state, if the ACK acknowledges our FIN then enter the 3550 TIME-WAIT state, otherwise ignore the segment. 3552 LAST-ACK STATE 3554 The only thing that can arrive in this state is an 3555 acknowledgment of our FIN. If our FIN is now 3556 acknowledged, delete the TCB, enter the CLOSED state, 3557 and return. 3559 TIME-WAIT STATE 3561 The only thing that can arrive in this state is a 3562 retransmission of the remote FIN. Acknowledge it, and 3563 restart the 2 MSL timeout. 3565 sixth, check the URG bit, 3567 ESTABLISHED STATE 3568 FIN-WAIT-1 STATE 3569 FIN-WAIT-2 STATE 3571 If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and 3572 signal the user that the remote side has urgent data if 3573 the urgent pointer (RCV.UP) is in advance of the data 3574 consumed. If the user has already been signaled (or is 3575 still in the "urgent mode") for this continuous sequence 3576 of urgent data, do not signal the user again. 3578 CLOSE-WAIT STATE 3579 CLOSING STATE 3580 LAST-ACK STATE 3581 TIME-WAIT 3583 This should not occur, since a FIN has been received from 3584 the remote side. Ignore the URG. 3586 seventh, process the segment text, 3588 ESTABLISHED STATE 3589 FIN-WAIT-1 STATE 3590 FIN-WAIT-2 STATE 3592 Once in the ESTABLISHED state, it is possible to deliver 3593 segment text to user RECEIVE buffers. Text from segments 3594 can be moved into buffers until either the buffer is full 3595 or the segment is empty. If the segment empties and 3596 carries a PUSH flag, then the user is informed, when the 3597 buffer is returned, that a PUSH has been received. 3599 When the TCP endpoint takes responsibility for delivering 3600 the data to the user it must also acknowledge the receipt 3601 of the data. 3603 Once the TCP endpoint takes responsibility for the data 3604 it advances RCV.NXT over the data accepted, and adjusts 3605 RCV.WND as appropriate to the current buffer 3606 availability. The total of RCV.NXT and RCV.WND should 3607 not be reduced. 3609 A TCP implementation MAY send an ACK segment 3610 acknowledging RCV.NXT when a valid segment arrives that 3611 is in the window but not at the left window edge (MAY- 3612 13). 3614 Please note the window management suggestions in 3615 Section 3.7. 3617 Send an acknowledgment of the form: 3619 3621 This acknowledgment should be piggybacked on a segment 3622 being transmitted if possible without incurring undue 3623 delay. 3625 CLOSE-WAIT STATE 3626 CLOSING STATE 3627 LAST-ACK STATE 3628 TIME-WAIT STATE 3630 This should not occur, since a FIN has been received from 3631 the remote side. Ignore the segment text. 3633 eighth, check the FIN bit, 3635 Do not process the FIN if the state is CLOSED, LISTEN or 3636 SYN-SENT since the SEG.SEQ cannot be validated; drop the 3637 segment and return. 3639 If the FIN bit is set, signal the user "connection closing" 3640 and return any pending RECEIVEs with same message, advance 3641 RCV.NXT over the FIN, and send an acknowledgment for the 3642 FIN. Note that FIN implies PUSH for any segment text not 3643 yet delivered to the user. 3645 SYN-RECEIVED STATE 3646 ESTABLISHED STATE 3648 Enter the CLOSE-WAIT state. 3650 FIN-WAIT-1 STATE 3652 If our FIN has been ACKed (perhaps in this segment), 3653 then enter TIME-WAIT, start the time-wait timer, turn 3654 off the other timers; otherwise enter the CLOSING 3655 state. 3657 FIN-WAIT-2 STATE 3659 Enter the TIME-WAIT state. Start the time-wait timer, 3660 turn off the other timers. 3662 CLOSE-WAIT STATE 3664 Remain in the CLOSE-WAIT state. 3666 CLOSING STATE 3668 Remain in the CLOSING state. 3670 LAST-ACK STATE 3672 Remain in the LAST-ACK state. 3674 TIME-WAIT STATE 3676 Remain in the TIME-WAIT state. Restart the 2 MSL 3677 time-wait timeout. 3679 and return. 3681 USER TIMEOUT 3683 USER TIMEOUT 3685 For any state if the user timeout expires, flush all queues, 3686 signal the user "error: connection aborted due to user timeout" 3687 in general and for any outstanding calls, delete the TCB, enter 3688 the CLOSED state and return. 3690 RETRANSMISSION TIMEOUT 3692 For any state if the retransmission timeout expires on a 3693 segment in the retransmission queue, send the segment at the 3694 front of the retransmission queue again, reinitialize the 3695 retransmission timer, and return. 3697 TIME-WAIT TIMEOUT 3699 If the time-wait timeout expires on a connection delete the 3700 TCB, enter the CLOSED state and return. 3702 3.10. Glossary 3704 ACK 3705 A control bit (acknowledge) occupying no sequence space, 3706 which indicates that the acknowledgment field of this segment 3707 specifies the next sequence number the sender of this segment 3708 is expecting to receive, hence acknowledging receipt of all 3709 previous sequence numbers. 3711 connection 3712 A logical communication path identified by a pair of sockets. 3714 datagram 3715 A message sent in a packet switched computer communications 3716 network. 3718 Destination Address 3719 The network layer address of the remote endpoint. 3721 FIN 3722 A control bit (finis) occupying one sequence number, which 3723 indicates that the sender will send no more data or control 3724 occupying sequence space. 3726 fragment 3727 A portion of a logical unit of data, in particular an 3728 internet fragment is a portion of an internet datagram. 3730 header 3731 Control information at the beginning of a message, segment, 3732 fragment, packet or block of data. 3734 host 3735 A computer. In particular a source or destination of 3736 messages from the point of view of the communication network. 3738 Identification 3739 An Internet Protocol field. This identifying value assigned 3740 by the sender aids in assembling the fragments of a datagram. 3742 internet address 3743 A network layer address. 3745 internet datagram 3746 The unit of data exchanged between an internet module and the 3747 higher level protocol together with the internet header. 3749 internet fragment 3750 A portion of the data of an internet datagram with an 3751 internet header. 3753 IP 3754 Internet Protocol. See [1] and [12]. 3756 IRS 3757 The Initial Receive Sequence number. The first sequence 3758 number used by the sender on a connection. 3760 ISN 3761 The Initial Sequence Number. The first sequence number used 3762 on a connection, (either ISS or IRS). Selected in a way that 3763 is unique within a given period of time and is unpredictable 3764 to attackers. 3766 ISS 3767 The Initial Send Sequence number. The first sequence number 3768 used by the sender on a connection. 3770 left sequence 3771 This is the next sequence number to be acknowledged by the 3772 data receiving TCP endpoint (or the lowest currently 3773 unacknowledged sequence number) and is sometimes referred to 3774 as the left edge of the send window. 3776 module 3777 An implementation, usually in software, of a protocol or 3778 other procedure. 3780 MSL 3781 Maximum Segment Lifetime, the time a TCP segment can exist in 3782 the internetwork system. Arbitrarily defined to be 2 3783 minutes. 3785 octet 3786 An eight bit byte. 3788 Options 3789 An Option field may contain several options, and each option 3790 may be several octets in length. 3792 packet 3793 A package of data with a header that may or may not be 3794 logically complete. More often a physical packaging than a 3795 logical packaging of data. 3797 port 3798 The portion of a connection identifier used for 3799 demultiplexing connections at an endpoint. 3801 process 3802 A program in execution. A source or destination of data from 3803 the point of view of the TCP endpoint or other host-to-host 3804 protocol. 3806 PUSH 3807 A control bit occupying no sequence space, indicating that 3808 this segment contains data that must be pushed through to the 3809 receiving user. 3811 RCV.NXT 3812 receive next sequence number 3814 RCV.UP 3815 receive urgent pointer 3817 RCV.WND 3818 receive window 3820 receive next sequence number 3821 This is the next sequence number the local TCP endpoint is 3822 expecting to receive. 3824 receive window 3825 This represents the sequence numbers the local (receiving) 3826 TCP endpoint is willing to receive. Thus, the local TCP 3827 endpoint considers that segments overlapping the range 3828 RCV.NXT to RCV.NXT + RCV.WND - 1 carry acceptable data or 3829 control. Segments containing sequence numbers entirely 3830 outside of this range are considered duplicates and 3831 discarded. 3833 RST 3834 A control bit (reset), occupying no sequence space, 3835 indicating that the receiver should delete the connection 3836 without further interaction. The receiver can determine, 3837 based on the sequence number and acknowledgment fields of the 3838 incoming segment, whether it should honor the reset command 3839 or ignore it. In no case does receipt of a segment 3840 containing RST give rise to a RST in response. 3842 SEG.ACK 3843 segment acknowledgment 3845 SEG.LEN 3846 segment length 3848 SEG.SEQ 3849 segment sequence 3851 SEG.UP 3852 segment urgent pointer field 3854 SEG.WND 3855 segment window field 3857 segment 3858 A logical unit of data, in particular a TCP segment is the 3859 unit of data transferred between a pair of TCP modules. 3861 segment acknowledgment 3862 The sequence number in the acknowledgment field of the 3863 arriving segment. 3865 segment length 3866 The amount of sequence number space occupied by a segment, 3867 including any controls that occupy sequence space. 3869 segment sequence 3870 The number in the sequence field of the arriving segment. 3872 send sequence 3873 This is the next sequence number the local (sending) TCP 3874 endpoint will use on the connection. It is initially 3875 selected from an initial sequence number curve (ISN) and is 3876 incremented for each octet of data or sequenced control 3877 transmitted. 3879 send window 3880 This represents the sequence numbers that the remote 3881 (receiving) TCP endpoint is willing to receive. It is the 3882 value of the window field specified in segments from the 3883 remote (data receiving) TCP endpoint. The range of new 3884 sequence numbers that may be emitted by a TCP implementation 3885 lies between SND.NXT and SND.UNA + SND.WND - 1. 3886 (Retransmissions of sequence numbers between SND.UNA and 3887 SND.NXT are expected, of course.) 3889 SND.NXT 3890 send sequence 3892 SND.UNA 3893 left sequence 3895 SND.UP 3896 send urgent pointer 3898 SND.WL1 3899 segment sequence number at last window update 3901 SND.WL2 3902 segment acknowledgment number at last window update 3904 SND.WND 3905 send window 3907 socket (or socket number, or socket address, or socket identifier) 3908 An address that specifically includes a port identifier, that 3909 is, the concatenation of an Internet Address with a TCP port. 3911 Source Address 3912 The network layer address of the sending endpoint. 3914 SYN 3915 A control bit in the incoming segment, occupying one sequence 3916 number, used at the initiation of a connection, to indicate 3917 where the sequence numbering will start. 3919 TCB 3920 Transmission control block, the data structure that records 3921 the state of a connection. 3923 TCP 3924 Transmission Control Protocol: A host-to-host protocol for 3925 reliable communication in internetwork environments. 3927 TOS 3928 Type of Service, an obsoleted IPv4 field. The same header 3929 bits currently are used for the Differentiated Services field 3930 [5] containing the Differentiated Services Code Point (DSCP) 3931 value and the 2-bit ECN codepoint [8]. 3933 Type of Service 3934 An Internet Protocol field that indicates the type of service 3935 for this internet fragment. 3937 URG 3938 A control bit (urgent), occupying no sequence space, used to 3939 indicate that the receiving user should be notified to do 3940 urgent processing as long as there is data to be consumed 3941 with sequence numbers less than the value indicated in the 3942 urgent pointer. 3944 urgent pointer 3945 A control field meaningful only when the URG bit is on. This 3946 field communicates the value of the urgent pointer that 3947 indicates the data octet associated with the sending user's 3948 urgent call. 3950 4. Changes from RFC 793 3952 This document obsoletes RFC 793 as well as RFC 6093 and 6528, which 3953 updated 793. In all cases, only the normative protocol specification 3954 and requirements have been incorporated into this document, and some 3955 informational text with background and rationale may not have been 3956 carried in. The informational content of those documents is still 3957 valuable in learning about and understanding TCP, and they are valid 3958 Informational references, even though their normative content has 3959 been incorporated into this document. 3961 The main body of this document was adapted from RFC 793's Section 3, 3962 titled "FUNCTIONAL SPECIFICATION", with an attempt to keep formatting 3963 and layout as close as possible. 3965 The collection of applicable RFC Errata that have been reported and 3966 either accepted or held for an update to RFC 793 were incorporated 3967 (Errata IDs: 573, 574, 700, 701, 1283, 1561, 1562, 1564, 1565, 1571, 3968 1572, 2296, 2297, 2298, 2748, 2749, 2934, 3213, 3300, 3301, 6222). 3969 Some errata were not applicable due to other changes (Errata IDs: 3970 572, 575, 1569, 3305, 3602). 3972 Changes to the specification of the Urgent Pointer described in RFC 3973 1122 and 6093 were incorporated. See RFC 6093 for detailed 3974 discussion of why these changes were necessary. 3976 The discussion of the RTO from RFC 793 was updated to refer to RFC 3977 6298. The RFC 1122 text on the RTO originally replaced the 793 text, 3978 however, RFC 2988 should have updated 1122, and has subsequently been 3979 obsoleted by 6298. 3981 RFC 1122 contains a collection of other changes and clarifications to 3982 RFC 793. The normative items impacting the protocol have been 3983 incorporated here, though some historically useful implementation 3984 advice and informative discussion from RFC 1122 is not included here. 3986 RFC 1122 contains more than just TCP requirements, so this document 3987 can't obsolete RFC 1122 entirely. It is only marked as "updating" 3988 1122, however, it should be understood to effectively obsolete all of 3989 the RFC 1122 material on TCP. 3991 The more secure Initial Sequence Number generation algorithm from RFC 3992 6528 was incorporated. See RFC 6528 for discussion of the attacks 3993 that this mitigates, as well as advice on selecting PRF algorithms 3994 and managing secret key data. 3996 A note based on RFC 6429 was added to explicitly clarify that system 3997 resource management concerns allow connection resources to be 3998 reclaimed. RFC 6429 is obsoleted in the sense that this 3999 clarification has been reflected in this update to the base TCP 4000 specification now. 4002 RFC EDITOR'S NOTE: the content below is for detailed change tracking 4003 and planning, and not to be included with the final revision of the 4004 document. 4006 This document started as draft-eddy-rfc793bis-00, that was merely a 4007 proposal and rough plan for updating RFC 793. 4009 The -01 revision of this draft-eddy-rfc793bis incorporates the 4010 content of RFC 793 Section 3 titled "FUNCTIONAL SPECIFICATION". 4011 Other content from RFC 793 has not been incorporated. The -01 4012 revision of this document makes some minor formatting changes to the 4013 RFC 793 content in order to convert the content into XML2RFC format 4014 and account for left-out parts of RFC 793. For instance, figure 4015 numbering differs and some indentation is not exactly the same. 4017 The -02 revision of draft-eddy-rfc793bis incorporates errata that 4018 have been verified: 4020 Errata ID 573: Reported by Bob Braden (note: This errata basically 4021 is just a reminder that RFC 1122 updates 793. Some of the 4022 associated changes are left pending to a separate revision that 4023 incorporates 1122. Bob's mention of PUSH in 793 section 2.8 was 4024 not applicable here because that section was not part of the 4025 "functional specification". Also the 1122 text on the 4026 retransmission timeout also has been updated by subsequent RFCs, 4027 so the change here deviates from Bob's suggestion to apply the 4028 1122 text.) 4029 Errata ID 574: Reported by Yin Shuming 4030 Errata ID 700: Reported by Yin Shuming 4031 Errata ID 701: Reported by Yin Shuming 4032 Errata ID 1283: Reported by Pei-chun Cheng 4033 Errata ID 1561: Reported by Constantin Hagemeier 4034 Errata ID 1562: Reported by Constantin Hagemeier 4035 Errata ID 1564: Reported by Constantin Hagemeier 4036 Errata ID 1565: Reported by Constantin Hagemeier 4037 Errata ID 1571: Reported by Constantin Hagemeier 4038 Errata ID 1572: Reported by Constantin Hagemeier 4039 Errata ID 2296: Reported by Vishwas Manral 4040 Errata ID 2297: Reported by Vishwas Manral 4041 Errata ID 2298: Reported by Vishwas Manral 4042 Errata ID 2748: Reported by Mykyta Yevstifeyev 4043 Errata ID 2749: Reported by Mykyta Yevstifeyev 4044 Errata ID 2934: Reported by Constantin Hagemeier 4045 Errata ID 3213: Reported by EugnJun Yi 4046 Errata ID 3300: Reported by Botong Huang 4047 Errata ID 3301: Reported by Botong Huang 4048 Errata ID 3305: Reported by Botong Huang 4049 Note: Some verified errata were not used in this update, as they 4050 relate to sections of RFC 793 elided from this document. These 4051 include Errata ID 572, 575, and 1569. 4052 Note: Errata ID 3602 was not applied in this revision as it is 4053 duplicative of the 1122 corrections. 4055 Not related to RFC 793 content, this revision also makes small tweaks 4056 to the introductory text, fixes indentation of the pseudo header 4057 diagram, and notes that the Security Considerations should also 4058 include privacy, when this section is written. 4060 The -03 revision of draft-eddy-rfc793bis revises all discussion of 4061 the urgent pointer in order to comply with RFC 6093, 1122, and 1011. 4062 Since 1122 held requirements on the urgent pointer, the full list of 4063 requirements was brought into an appendix of this document, so that 4064 it can be updated as-needed. 4066 The -04 revision of draft-eddy-rfc793bis includes the ISN generation 4067 changes from RFC 6528. 4069 The -05 revision of draft-eddy-rfc793bis incorporates MSS 4070 requirements and definitions from RFC 879, 1122, and 6691, as well as 4071 option-handling requirements from RFC 1122. 4073 The -00 revision of draft-ietf-tcpm-rfc793bis incorporates several 4074 additional clarifications and updates to the section on segmentation, 4075 many of which are based on feedback from Joe Touch improving from the 4076 initial text on this in the previous revision. 4078 The -01 revision incorporates the change to Reserved bits due to ECN, 4079 as well as many other changes that come from RFC 1122. 4081 The -02 revision has small formatting modifications in order to 4082 address xml2rfc warnings about long lines. It was a quick update to 4083 avoid document expiration. TCPM working group discussion in 2015 4084 also indicated that that we should not try to add sections on 4085 implementation advice or similar non-normative information. 4087 The -03 revision incorporates more content from RFC 1122: Passive 4088 OPEN Calls, Time-To-Live, Multihoming, IP Options, ICMP messages, 4089 Data Communications, When to Send Data, When to Send a Window Update, 4090 Managing the Window, Probing Zero Windows, When to Send an ACK 4091 Segment. The section on data communications was re-organized into 4092 clearer subsections (previously headings were embedded in the 793 4093 text), and windows management advice from 793 was removed (as 4094 reviewed by TCPM working group) in favor of the 1122 additions on 4095 SWS, ZWP, and related topics. 4097 The -04 revision includes reference to RFC 6429 on the ZWP condition, 4098 RFC1122 material on TCP Connection Failures, TCP Keep-Alives, 4099 Acknowledging Queued Segments, and Remote Address Validation. RTO 4100 computation is referenced from RFC 6298 rather than RFC 1122. 4102 The -05 revision includes the requirement to implement TCP congestion 4103 control with recommendation to implement ECN, the RFC 6633 update to 4104 1122, which changed the requirement on responding to source quench 4105 ICMP messages, and discussion of ICMP (and ICMPv6) soft and hard 4106 errors per RFC 5461 (ICMPv6 handling for TCP doesn't seem to be 4107 mentioned elsewhere in standards track). 4109 The -06 revision includes an appendix on "Other Implementation Notes" 4110 to capture widely-deployed fundamental features that are not 4111 contained in the RFC series yet. It also added mention of RFC 6994 4112 and the IANA TCP parameters registry as a reference. It includes 4113 references to RFC 5961 in appropriate places. The references to TOS 4114 were changed to DiffServ field, based on reflecting RFC 2474 as well 4115 as the IPv6 presence of traffic class (carrying DiffServ field) 4116 rather than TOS. 4118 The -07 revision includes reference to RFC 6191, updated security 4119 considerations, discussion of additional implementation 4120 considerations, and clarification of data on the SYN. 4122 The -08 revision includes changes based on: 4124 describing treatment of reserved bits (following TCPM mailing list 4125 thread from July 2014 on "793bis item - reserved bit behavior" 4126 addition a brief TCP key concepts section to make up for not 4127 including the outdated section 2 of RFC 793 4128 changed "TCP" to "host" to resolve conflict between 1122 wording 4129 on whether TCP or the network layer chooses an address when 4130 multihomed 4131 fixed/updated definition of options in glossary 4132 moved note on aggregating ACKs from 1122 to a more appropriate 4133 location 4134 resolved notes on IP precedence and security/compartment 4135 added implementation note on sequence number validation 4136 added note that PUSH does not apply when Nagle is active 4137 added 1122 content on asynchronous reports to replace 793 section 4138 on TCP to user messages 4140 The -09 revision fixes section numbering problems. 4142 The -10 revision includes additions to the security considerations 4143 based on comments from Joe Touch, and suggested edits on RST/FIN 4144 notification, RFC 2525 reference, and other edits suggested by 4145 Yuchung Cheng, as well as modifications to DiffServ text from Yuchung 4146 Cheng and Gorry Fairhurst. 4148 The -11 revision includes a start at identifying all of the 4149 requirements text and referencing each instance in the common table 4150 at the end of the document. 4152 The -12 revision completes the requirement language indexing started 4153 in -11 and adds necessary description of the PUSH functionality that 4154 was missing. 4156 The -13 revision contains only changes in the inline editor notes. 4158 The -14 revision includes updates with regard to several comments 4159 from the mailing list, including editorial fixes, adding IANA 4160 considerations for the header flags, improving figure title 4161 placement, and breaking up the "Terminology" section into more 4162 appropriately titled subsections. 4164 The -15 revision has many technical and editorial corrections from 4165 Gorry Fairhurst's review, and subsequent discussion on the TCPM list, 4166 as well as some other collected clarifications and improvements from 4167 mailing list discussion. 4169 The -16 revision addresses several discussions that rose from 4170 additional reviews and follow-up on some of Gorry Fairhurst's 4171 comments from revision 14. 4173 The -17 revision includes errata 6222 from Charles Deng, update to 4174 the key words boilerplate, updated description of the header flags 4175 registry changes, and clarification about connections rather than 4176 users in the discussion of OPEN calls. 4178 The -18 revision includes editorial changes to the IANA 4179 considerations, based on comments from Richard Scheffenegger at the 4180 IETF 108 TCPM virtual meeting. 4182 The -19 revision includes editorial changes from Errata 6281 and 6282 4183 reported by Merlin Buge. It also includes WGLC changes noted by 4184 Mohamed Boucadair, Rahul Jadhav, Praveen Balasubramanian, Matt Olson, 4185 Yi Huang, Joe Touch, and Juhamatti Kuusisaari. 4187 Some other suggested changes that will not be incorporated in this 4188 793 update unless TCPM consensus changes with regard to scope are: 4190 1. Tony Sabatini's suggestion for describing DO field 4191 2. Per discussion with Joe Touch (TAPS list, 6/20/2015), the 4192 description of the API could be revisited 4194 Early in the process of updating RFC 793, Scott Brim mentioned that 4195 this should include a PERPASS/privacy review. This may be something 4196 for the chairs or AD to request during WGLC or IETF LC. 4198 5. IANA Considerations 4200 In the "Transmission Control Protocol (TCP) Header Flags" registry, 4201 IANA is asked to make several changes described in this section. 4203 RFC 3168 originally created this registry, but only populated it with 4204 the new bits defined in RFC 3168, neglecting the other bits that had 4205 previously been described in RFC 793 and other documents. Bit 7 has 4206 since also been updated by RFC 8311. 4208 The "Bit" column is renamed below as the "Bit Offset" column, since 4209 it references each header flag's offset within the 16-bit aligned 4210 view of the TCP header in Figure 1. The bits in offsets 0 through 4 4211 are the TCP segment Data Offset field, and not header flags. 4213 IANA should add a column for "Assignment Notes". 4215 IANA should assign values indicated below. 4217 TCP Header Flags 4219 Bit Name Reference Assignment Notes 4220 Offset 4221 --- ---- --------- ---------------- 4222 4 Reserved for future use (this document) 4223 5 Reserved for future use (this document) 4224 6 Reserved for future use (this document) 4225 7 Reserved for future use [RFC8311] Previously used by Historic [RFC3540] as NS (Nonce Sum) 4226 8 CWR (Congestion Window Reduced) [RFC3168] 4227 9 ECE (ECN-Echo) [RFC3168] 4228 10 Urgent Pointer field significant (URG) (this document) 4229 11 Acknowledgment field significant (ACK) (this document) 4230 12 Push Function (PSH) (this document) 4231 13 Reset the connection (RST) (this document) 4232 14 Synchronize sequence numbers (SYN) (this document) 4233 15 No more data from sender (FIN) (this document) 4235 This TCP Header Flags registry should also be moved to a sub-registry 4236 under the global "Transmission Control Protocol (TCP) Parameters 4237 registry (https://www.iana.org/assignments/tcp-parameters/tcp- 4238 parameters.xhtml). 4240 The registry's Registration Procedure should remain Standards Action, 4241 but the Reference can be updated to this document, and the Note 4242 removed. 4244 6. Security and Privacy Considerations 4246 The TCP design includes only rudimentary security features that 4247 improve the robustness and reliability of connections and application 4248 data transfer, but there are no built-in cryptographic capabilities 4249 to support any form of privacy, authentication, or other typical 4250 security functions. Non-cryptographic enhancements (e.g. [34]) have 4251 been developed to improve robustness of TCP connections to particular 4252 types of attacks, but the applicability and protections of non- 4253 cryptographic enhancements are limited (e.g. see section 1.1 of 4254 [34]). Applications typically utilize lower-layer (e.g. IPsec) and 4255 upper-layer (e.g. TLS) protocols to provide security and privacy for 4256 TCP connections and application data carried in TCP. Methods based 4257 on TCP options have been developed as well, to support some security 4258 capabilities. 4260 In order to fully protect TCP connections (including their control 4261 flags) IPsec or the TCP Authentication Option (TCP-AO) [33] are the 4262 only current effective methods. Other methods discussed in this 4263 section may protect the payload, but either only a subset of the 4264 fields (e.g. tcpcrypt [56]) or none at all (e.g. TLS). Other 4265 security features that have been added to TCP (e.g. ISN generation, 4266 sequence number checks, and others) are only capable of partially 4267 hindering attacks. 4269 Applications using long-lived TCP flows have been vulnerable to 4270 attacks that exploit the processing of control flags described in 4271 earlier TCP specifications [27]. TCP-MD5 was a commonly implemented 4272 TCP option to support authentication for some of these connections, 4273 but had flaws and is now deprecated. TCP-AO provides a capability to 4274 protect long-lived TCP connections from attacks, and has superior 4275 properties to TCP-MD5. It does not provide any privacy for 4276 application data, nor for the TCP headers. 4278 The "tcpcrypt" [56] Experimental extension to TCP provides the 4279 ability to cryptographically protect connection data. Metadata 4280 aspects of the TCP flow are still visible, but the application stream 4281 is well-protected. Within the TCP header, only the urgent pointer 4282 and FIN flag are protected through tcpcrypt. 4284 The TCP Roadmap [45] includes notes about several RFCs related to TCP 4285 security. Many of the enhancements provided by these RFCs have been 4286 integrated into the present document, including ISN generation, 4287 mitigating blind in-window attacks, and improving handling of soft 4288 errors and ICMP packets. These are all discussed in greater detail 4289 in the referenced RFCs that originally described the changes needed 4290 to earlier TCP specifications. Additionally, see RFC 6093 [35] for 4291 discussion of security considerations related to the urgent pointer 4292 field, that has been deprecated. 4294 Since TCP is often used for bulk transfer flows, some attacks are 4295 possible that abuse the TCP congestion control logic. An example is 4296 "ACK-division" attacks. Updates that have been made to the TCP 4297 congestion control specifications include mechanisms like Appropriate 4298 Byte Counting (ABC) [23] that act as mitigations to these attacks. 4300 Other attacks are focused on exhausting the resources of a TCP 4301 server. Examples include SYN flooding [26] or wasting resources on 4302 non-progressing connections [37]. Operating systems commonly 4303 implement mitigations for these attacks. Some common defenses also 4304 utilize proxies, stateful firewalls, and other technologies outside 4305 of the end-host TCP implementation. 4307 7. Acknowledgements 4309 This document is largely a revision of RFC 793, which Jon Postel was 4310 the editor of. Due to his excellent work, it was able to last for 4311 three decades before we felt the need to revise it. 4313 Andre Oppermann was a contributor and helped to edit the first 4314 revision of this document. 4316 We are thankful for the assistance of the IETF TCPM working group 4317 chairs, over the course of work on this document: 4319 Michael Scharf 4320 Yoshifumi Nishida 4321 Pasi Sarolahti 4322 Michael Tuexen 4324 During the discussions of this work on the TCPM mailing list and in 4325 working group meetings, helpful comments, critiques, and reviews were 4326 received from (listed alphabetically by last name): Praveen 4327 Balasubramanian, David Borman, Mohamed Boucadair, Bob Briscoe, Neal 4328 Cardwell, Yuchung Cheng, Martin Duke, Ted Faber, Gorry Fairhurst, 4329 Fernando Gont, Rodney Grimes, Yi Huang, Rahul Jadhav, Mike Kosek, 4330 Juhamatti Kuusisaari, Kevin Lahey, Kevin Mason, Matt Mathis, Jonathan 4331 Morton, Matt Olson, Tommy Pauly, Tom Petch, Hagen Paul Pfeifer, 4332 Anthony Sabatini, Michael Scharf, Greg Skinner, Joe Touch, Michael 4333 Tuexen, Reji Varghese, Tim Wicinski, Lloyd Wood, and Alex Zimmermann. 4334 Joe Touch provided additional help in clarifying the description of 4335 segment size parameters and PMTUD/PLPMTUD recommendations. 4337 This document includes content from errata that were reported by 4338 (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, 4339 Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta 4340 Yevstifeyev, EungJun Yi, Botong Huang, Charles Deng, Merlin Buge. 4342 8. References 4344 8.1. Normative References 4346 [1] Postel, J., "Internet Protocol", STD 5, RFC 791, 4347 DOI 10.17487/RFC0791, September 1981, 4348 . 4350 [2] Mogul, J. and S. Deering, "Path MTU discovery", RFC 1191, 4351 DOI 10.17487/RFC1191, November 1990, 4352 . 4354 [3] McCann, J., Deering, S., and J. Mogul, "Path MTU Discovery 4355 for IP version 6", RFC 1981, DOI 10.17487/RFC1981, August 4356 1996, . 4358 [4] Bradner, S., "Key words for use in RFCs to Indicate 4359 Requirement Levels", BCP 14, RFC 2119, 4360 DOI 10.17487/RFC2119, March 1997, 4361 . 4363 [5] Nichols, K., Blake, S., Baker, F., and D. Black, 4364 "Definition of the Differentiated Services Field (DS 4365 Field) in the IPv4 and IPv6 Headers", RFC 2474, 4366 DOI 10.17487/RFC2474, December 1998, 4367 . 4369 [6] Borman, D., Deering, S., and R. Hinden, "IPv6 Jumbograms", 4370 RFC 2675, DOI 10.17487/RFC2675, August 1999, 4371 . 4373 [7] Lahey, K., "TCP Problems with Path MTU Discovery", 4374 RFC 2923, DOI 10.17487/RFC2923, September 2000, 4375 . 4377 [8] Ramakrishnan, K., Floyd, S., and D. Black, "The Addition 4378 of Explicit Congestion Notification (ECN) to IP", 4379 RFC 3168, DOI 10.17487/RFC3168, September 2001, 4380 . 4382 [9] Paxson, V., Allman, M., Chu, J., and M. Sargent, 4383 "Computing TCP's Retransmission Timer", RFC 6298, 4384 DOI 10.17487/RFC6298, June 2011, 4385 . 4387 [10] Gont, F., "Deprecation of ICMP Source Quench Messages", 4388 RFC 6633, DOI 10.17487/RFC6633, May 2012, 4389 . 4391 [11] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 4392 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 4393 May 2017, . 4395 [12] Deering, S. and R. Hinden, "Internet Protocol, Version 6 4396 (IPv6) Specification", STD 86, RFC 8200, 4397 DOI 10.17487/RFC8200, July 2017, 4398 . 4400 8.2. Informative References 4402 [13] Postel, J., "Transmission Control Protocol", STD 7, 4403 RFC 793, DOI 10.17487/RFC0793, September 1981, 4404 . 4406 [14] Nagle, J., "Congestion Control in IP/TCP Internetworks", 4407 RFC 896, DOI 10.17487/RFC0896, January 1984, 4408 . 4410 [15] Braden, R., Ed., "Requirements for Internet Hosts - 4411 Communication Layers", STD 3, RFC 1122, 4412 DOI 10.17487/RFC1122, October 1989, 4413 . 4415 [16] Almquist, P., "Type of Service in the Internet Protocol 4416 Suite", RFC 1349, DOI 10.17487/RFC1349, July 1992, 4417 . 4419 [17] Braden, R., "T/TCP -- TCP Extensions for Transactions 4420 Functional Specification", RFC 1644, DOI 10.17487/RFC1644, 4421 July 1994, . 4423 [18] Mathis, M., Mahdavi, J., Floyd, S., and A. Romanow, "TCP 4424 Selective Acknowledgment Options", RFC 2018, 4425 DOI 10.17487/RFC2018, October 1996, 4426 . 4428 [19] Paxson, V., Allman, M., Dawson, S., Fenner, W., Griner, 4429 J., Heavens, I., Lahey, K., Semke, J., and B. Volz, "Known 4430 TCP Implementation Problems", RFC 2525, 4431 DOI 10.17487/RFC2525, March 1999, 4432 . 4434 [20] Xiao, X., Hannan, A., Paxson, V., and E. Crabbe, "TCP 4435 Processing of the IPv4 Precedence Field", RFC 2873, 4436 DOI 10.17487/RFC2873, June 2000, 4437 . 4439 [21] Floyd, S., Mahdavi, J., Mathis, M., and M. Podolsky, "An 4440 Extension to the Selective Acknowledgement (SACK) Option 4441 for TCP", RFC 2883, DOI 10.17487/RFC2883, July 2000, 4442 . 4444 [22] Balakrishnan, H., Padmanabhan, V., Fairhurst, G., and M. 4445 Sooriyabandara, "TCP Performance Implications of Network 4446 Path Asymmetry", BCP 69, RFC 3449, DOI 10.17487/RFC3449, 4447 December 2002, . 4449 [23] Allman, M., "TCP Congestion Control with Appropriate Byte 4450 Counting (ABC)", RFC 3465, DOI 10.17487/RFC3465, February 4451 2003, . 4453 [24] Fenner, B., "Experimental Values In IPv4, IPv6, ICMPv4, 4454 ICMPv6, UDP, and TCP Headers", RFC 4727, 4455 DOI 10.17487/RFC4727, November 2006, 4456 . 4458 [25] Mathis, M. and J. Heffner, "Packetization Layer Path MTU 4459 Discovery", RFC 4821, DOI 10.17487/RFC4821, March 2007, 4460 . 4462 [26] Eddy, W., "TCP SYN Flooding Attacks and Common 4463 Mitigations", RFC 4987, DOI 10.17487/RFC4987, August 2007, 4464 . 4466 [27] Touch, J., "Defending TCP Against Spoofing Attacks", 4467 RFC 4953, DOI 10.17487/RFC4953, July 2007, 4468 . 4470 [28] Culley, P., Elzur, U., Recio, R., Bailey, S., and J. 4471 Carrier, "Marker PDU Aligned Framing for TCP 4472 Specification", RFC 5044, DOI 10.17487/RFC5044, October 4473 2007, . 4475 [29] Gont, F., "TCP's Reaction to Soft Errors", RFC 5461, 4476 DOI 10.17487/RFC5461, February 2009, 4477 . 4479 [30] StJohns, M., Atkinson, R., and G. Thomas, "Common 4480 Architecture Label IPv6 Security Option (CALIPSO)", 4481 RFC 5570, DOI 10.17487/RFC5570, July 2009, 4482 . 4484 [31] Allman, M., Paxson, V., and E. Blanton, "TCP Congestion 4485 Control", RFC 5681, DOI 10.17487/RFC5681, September 2009, 4486 . 4488 [32] Sandlund, K., Pelletier, G., and L-E. Jonsson, "The RObust 4489 Header Compression (ROHC) Framework", RFC 5795, 4490 DOI 10.17487/RFC5795, March 2010, 4491 . 4493 [33] Touch, J., Mankin, A., and R. Bonica, "The TCP 4494 Authentication Option", RFC 5925, DOI 10.17487/RFC5925, 4495 June 2010, . 4497 [34] Ramaiah, A., Stewart, R., and M. Dalal, "Improving TCP's 4498 Robustness to Blind In-Window Attacks", RFC 5961, 4499 DOI 10.17487/RFC5961, August 2010, 4500 . 4502 [35] Gont, F. and A. Yourtchenko, "On the Implementation of the 4503 TCP Urgent Mechanism", RFC 6093, DOI 10.17487/RFC6093, 4504 January 2011, . 4506 [36] Gont, F., "Reducing the TIME-WAIT State Using TCP 4507 Timestamps", BCP 159, RFC 6191, DOI 10.17487/RFC6191, 4508 April 2011, . 4510 [37] Bashyam, M., Jethanandani, M., and A. Ramaiah, "TCP Sender 4511 Clarification for Persist Condition", RFC 6429, 4512 DOI 10.17487/RFC6429, December 2011, 4513 . 4515 [38] Gont, F. and S. Bellovin, "Defending against Sequence 4516 Number Attacks", RFC 6528, DOI 10.17487/RFC6528, February 4517 2012, . 4519 [39] Borman, D., "TCP Options and Maximum Segment Size (MSS)", 4520 RFC 6691, DOI 10.17487/RFC6691, July 2012, 4521 . 4523 [40] Touch, J., "Updated Specification of the IPv4 ID Field", 4524 RFC 6864, DOI 10.17487/RFC6864, February 2013, 4525 . 4527 [41] Touch, J., "Shared Use of Experimental TCP Options", 4528 RFC 6994, DOI 10.17487/RFC6994, August 2013, 4529 . 4531 [42] McPherson, D., Oran, D., Thaler, D., and E. Osterweil, 4532 "Architectural Considerations of IP Anycast", RFC 7094, 4533 DOI 10.17487/RFC7094, January 2014, 4534 . 4536 [43] Borman, D., Braden, B., Jacobson, V., and R. 4537 Scheffenegger, Ed., "TCP Extensions for High Performance", 4538 RFC 7323, DOI 10.17487/RFC7323, September 2014, 4539 . 4541 [44] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 4542 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 4543 . 4545 [45] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. 4546 Zimmermann, "A Roadmap for Transmission Control Protocol 4547 (TCP) Specification Documents", RFC 7414, 4548 DOI 10.17487/RFC7414, February 2015, 4549 . 4551 [46] Black, D., Ed. and P. Jones, "Differentiated Services 4552 (Diffserv) and Real-Time Communication", RFC 7657, 4553 DOI 10.17487/RFC7657, November 2015, 4554 . 4556 [47] Fairhurst, G. and M. Welzl, "The Benefits of Using 4557 Explicit Congestion Notification (ECN)", RFC 8087, 4558 DOI 10.17487/RFC8087, March 2017, 4559 . 4561 [48] Fairhurst, G., Ed., Trammell, B., Ed., and M. Kuehlewind, 4562 Ed., "Services Provided by IETF Transport Protocols and 4563 Congestion Control Mechanisms", RFC 8095, 4564 DOI 10.17487/RFC8095, March 2017, 4565 . 4567 [49] Welzl, M., Tuexen, M., and N. Khademi, "On the Usage of 4568 Transport Features Provided by IETF Transport Protocols", 4569 RFC 8303, DOI 10.17487/RFC8303, February 2018, 4570 . 4572 [50] Chown, T., Loughney, J., and T. Winters, "IPv6 Node 4573 Requirements", BCP 220, RFC 8504, DOI 10.17487/RFC8504, 4574 January 2019, . 4576 [51] Ford, A., Raiciu, C., Handley, M., Bonaventure, O., and C. 4577 Paasch, "TCP Extensions for Multipath Operation with 4578 Multiple Addresses", RFC 8684, DOI 10.17487/RFC8684, March 4579 2020, . 4581 [52] IANA, "Transmission Control Protocol (TCP) Parameters, 4582 https://www.iana.org/assignments/tcp-parameters/tcp- 4583 parameters.xhtml", 2019. 4585 [53] IANA, "Transmission Control Protocol (TCP) Header Flags, 4586 https://www.iana.org/assignments/tcp-header-flags/tcp- 4587 header-flags.xhtml", 2019. 4589 [54] Gont, F., "Processing of IP Security/Compartment and 4590 Precedence Information by TCP", draft-gont-tcpm-tcp- 4591 seccomp-prec-00 (work in progress), March 2012. 4593 [55] Gont, F. and D. Borman, "On the Validation of TCP Sequence 4594 Numbers", draft-gont-tcpm-tcp-seq-validation-02 (work in 4595 progress), March 2015. 4597 [56] Bittau, A., Giffin, D., Handley, M., Mazieres, D., Slack, 4598 Q., and E. Smith, "Cryptographic protection of TCP Streams 4599 (tcpcrypt)", draft-ietf-tcpinc-tcpcrypt-09 (work in 4600 progress), November 2017. 4602 [57] Touch, J. and W. Eddy, "TCP Extended Data Offset Option", 4603 draft-ietf-tcpm-tcp-edo-10 (work in progress), July 2018. 4605 [58] Minshall, G., "A Proposed Modification to Nagle's 4606 Algorithm", draft-minshall-nagle-01 (work in progress), 4607 June 1999. 4609 [59] Dalal, Y. and C. Sunshine, "Connection Management in 4610 Transport Protocols", Computer Networks Vol. 2, No. 6, pp. 4611 454-473, December 1978. 4613 [60] Faber, T., Touch, J., and W. Yui, "The TIME-WAIT state in 4614 TCP and Its Effect on Busy Servers", Proceedings of IEEE 4615 INFOCOM pp. 1573-1583, March 1999. 4617 Appendix A. Other Implementation Notes 4619 This section includes additional notes and references on TCP 4620 implementation decisions that are currently not a part of the RFC 4621 series or included within the TCP standard. These items can be 4622 considered by implementers, but there was not yet a consensus to 4623 include them in the standard. 4625 A.1. IP Security Compartment and Precedence 4627 The IPv4 specification [1] includes a precedence value in the (now 4628 obsoleted) Type of Service field (TOS) field. It was modified in 4629 [16], and then obsoleted by the definition of Differentiated Services 4630 (DiffServ) [5]. Setting and conveying TOS between the network layer, 4631 TCP implementation, and applications is obsolete, and replaced by 4632 DiffServ in the current TCP specification. 4634 RFC 793 requires checking the IP security compartment and precedence 4635 on incoming TCP segments for consistency within a connection, and 4636 with application requests. Each of these aspects of IP have become 4637 outdated, without specific updates to RFC 793. The issues with 4638 precedence were fixed by [20], which is Standards Track, and so this 4639 present TCP specification includes those changes. However, the state 4640 of IP security options that may be used by MLS systems is not as 4641 clean. 4643 Resetting connections when incoming packets do not meet expected 4644 security compartment or precedence expectations has been recognized 4645 as a possible attack vector [54], and there has been discussion about 4646 amending the TCP specification to prevent connections from being 4647 aborted due to non-matching IP security compartment and DiffServ 4648 codepoint values. 4650 A.1.1. Precedence 4652 In DiffServ the former precedence values are treated as Class 4653 Selector codepoints, and methods for compatible treatment are 4654 described in the DiffServ architecture. The RFC 793/1122 TCP 4655 specification includes logic intending to have connections use the 4656 highest precedence requested by either endpoint application, and to 4657 keep the precedence consistent throughout a connection. This logic 4658 from the obsolete TOS is not applicable for DiffServ, and should not 4659 be included in TCP implementations, though changes to DiffServ values 4660 within a connection are discouraged. For discussion of this, see RFC 4661 7657 (sec 5.1, 5.3, and 6) [46]. 4663 The obsoleted TOS processing rules in TCP assumed bidirectional (or 4664 symmetric) precedence values used on a connection, but the DiffServ 4665 architecture is asymmetric. Problems with the old TCP logic in this 4666 regard were described in [20] and the solution described is to ignore 4667 IP precedence in TCP. Since RFC 2873 is a Standards Track document 4668 (although not marked as updating RFC 793), current implementations 4669 are expected to be robust to these conditions. Note that the 4670 DiffServ field value used in each direction is a part of the 4671 interface between TCP and the network layer, and values in use can be 4672 indicated both ways between TCP and the application. 4674 A.1.2. MLS Systems 4676 The IP security option (IPSO) and compartment defined in [1] was 4677 refined in RFC 1038 that was later obsoleted by RFC 1108. The 4678 Commercial IP Security Option (CIPSO) is defined in FIPS-188, and is 4679 supported by some vendors and operating systems. RFC 1108 is now 4680 Historic, though RFC 791 itself has not been updated to remove the IP 4681 security option. For IPv6, a similar option (CALIPSO) has been 4682 defined [30]. RFC 793 includes logic that includes the IP security/ 4683 compartment information in treatment of TCP segments. References to 4684 the IP "security/compartment" in this document may be relevant for 4685 Multi-Level Secure (MLS) system implementers, but can be ignored for 4686 non-MLS implementations, consistent with running code on the 4687 Internet. See Appendix A.1 for further discussion. Note that RFC 4688 5570 describes some MLS networking scenarios where IPSO, CIPSO, or 4689 CALIPSO may be used. In these special cases, TCP implementers should 4690 see section 7.3.1 of RFC 5570, and follow the guidance in that 4691 document. 4693 A.2. Sequence Number Validation 4695 There are cases where the TCP sequence number validation rules can 4696 prevent ACK fields from being processed. This can result in 4697 connection issues, as described in [55], which includes descriptions 4698 of potential problems in conditions of simultaneous open, self- 4699 connects, simultaneous close, and simultaneous window probes. The 4700 document also describes potential changes to the TCP specification to 4701 mitigate the issue by expanding the acceptable sequence numbers. 4703 In Internet usage of TCP, these conditions are rarely occurring. 4704 Common operating systems include different alternative mitigations, 4705 and the standard has not been updated yet to codify one of them, but 4706 implementers should consider the problems described in [55]. 4708 A.3. Nagle Modification 4710 In common operating systems, both the Nagle algorithm and delayed 4711 acknowledgements are implemented and enabled by default. TCP is used 4712 by many applications that have a request-response style of 4713 communication, where the combination of the Nagle algorithm and 4714 delayed acknowledgements can result in poor application performance. 4715 A modification to the Nagle algorithm is described in [58] that 4716 improves the situation for these applications. 4718 This modification is implemented in some common operating systems, 4719 and does not impact TCP interoperability. Additionally, many 4720 applications simply disable Nagle, since this is generally supported 4721 by a socket option. The TCP standard has not been updated to include 4722 this Nagle modification, but implementers may find it beneficial to 4723 consider. 4725 A.4. Low Water Mark Settings 4727 Some operating system kernel TCP implementations include socket 4728 options that allow specifying the number of bytes in the buffer until 4729 the socket layer will pass sent data to TCP (SO_SNDLOWAT) or to the 4730 application on receiving (SO_RCVLOWAT). 4732 In addition, another socket option (TCP_NOTSENT_LOWAT) can be used to 4733 control the amount of unsent bytes in the write queue. This can help 4734 a sending TCP application to avoid creating large amounts of buffered 4735 data (and corresponding latency). As an example, this may be useful 4736 for applications that are multiplexing data from multiple upper level 4737 streams onto a connection, especially when streams may be a mix of 4738 interactive / real-time and bulk data transfer. 4740 Appendix B. TCP Requirement Summary 4742 This section is adapted from RFC 1122. 4744 Note that there is no requirement related to PLPMTUD in this list, 4745 but that PLPMTUD is recommended. 4747 | | | | |S| | 4748 | | | | |H| |F 4749 | | | | |O|M|o 4750 | | |S| |U|U|o 4751 | | |H| |L|S|t 4752 | |M|O| |D|T|n 4753 | |U|U|M| | |o 4754 | |S|L|A|N|N|t 4755 | |T|D|Y|O|O|t 4756 FEATURE | ReqID | | | |T|T|e 4757 -------------------------------------------------|--------|-|-|-|-|-|-- 4758 | | | | | | | 4759 Push flag | | | | | | | 4760 Aggregate or queue un-pushed data | MAY-16 | | |x| | | 4761 Sender collapse successive PSH flags | SHLD-27| |x| | | | 4762 SEND call can specify PUSH | MAY-15 | | |x| | | 4763 If cannot: sender buffer indefinitely | MUST-60| | | | |x| 4764 If cannot: PSH last segment | MUST-61|x| | | | | 4765 Notify receiving ALP of PSH | MAY-17 | | |x| | |1 4766 Send max size segment when possible | SHLD-28| |x| | | | 4767 | | | | | | | 4768 Window | | | | | | | 4769 Treat as unsigned number | MUST-1 |x| | | | | 4770 Handle as 32-bit number | REC-1 | |x| | | | 4771 Shrink window from right | SHLD-14| | | |x| | 4772 - Send new data when window shrinks | SHLD-15| | | |x| | 4773 - Retransmit old unacked data within window | SHLD-16| |x| | | | 4774 - Time out conn for data past right edge | SHLD-17| | | |x| | 4775 Robust against shrinking window | MUST-34|x| | | | | 4776 Receiver's window closed indefinitely | MAY-8 | | |x| | | 4777 Use standard probing logic | MUST-35|x| | | | | 4778 Sender probe zero window | MUST-36|x| | | | | 4779 First probe after RTO | SHLD-29| |x| | | | 4780 Exponential backoff | SHLD-30| |x| | | | 4781 Allow window stay zero indefinitely | MUST-37|x| | | | | 4782 Retransmit old data beyond SND.UNA+SND.WND | MAY-7 | | |x| | | 4783 Process RST and URG even with zero window | MUST-66|x| | | | | 4784 | | | | | | | 4785 Urgent Data | | | | | | | 4786 Include support for urgent pointer | MUST-30|x| | | | | 4787 Pointer indicates first non-urgent octet | MUST-62|x| | | | | 4788 Arbitrary length urgent data sequence | MUST-31|x| | | | | 4789 Inform ALP asynchronously of urgent data | MUST-32|x| | | | |1 4790 ALP can learn if/how much urgent data Q'd | MUST-33|x| | | | |1 4791 ALP employ the urgent mechanism | SHLD-13| | | |x| | 4792 | | | | | | | 4793 TCP Options | | | | | | | 4794 Support the mandatory option set | MUST-4 |x| | | | | 4795 Receive TCP option in any segment | MUST-5 |x| | | | | 4796 Ignore unsupported options | MUST-6 |x| | | | | 4797 Cope with illegal option length | MUST-7 |x| | | | | 4798 Process options regardless of word alignment | MUST-64|x| | | | | 4799 Implement sending & receiving MSS option | MUST-14|x| | | | | 4800 IPv4 Send MSS option unless 536 | SHLD-5 | |x| | | | 4801 IPv6 Send MSS option unless 1220 | SHLD-5 | |x| | | | 4802 Send MSS option always | MAY-3 | | |x| | | 4803 IPv4 Send-MSS default is 536 | MUST-15|x| | | | | 4804 IPv6 Send-MSS default is 1220 | MUST-15|x| | | | | 4805 Calculate effective send seg size | MUST-16|x| | | | | 4806 MSS accounts for varying MTU | SHLD-6 | |x| | | | 4807 MSS not sent on non-SYN segments | MUST-65| | | | |x| 4808 MSS value based on MMS_R | MUST-67|x| | | | | 4809 | | | | | | | 4810 TCP Checksums | | | | | | | 4811 Sender compute checksum | MUST-2 |x| | | | | 4812 Receiver check checksum | MUST-3 |x| | | | | 4813 | | | | | | | 4814 ISN Selection | | | | | | | 4815 Include a clock-driven ISN generator component | MUST-8 |x| | | | | 4816 Secure ISN generator with a PRF component | SHLD-1 | |x| | | | 4817 PRF computable from outside the host | MUST-9 | | | | |x| 4818 | | | | | | | 4819 Opening Connections | | | | | | | 4820 Support simultaneous open attempts | MUST-10|x| | | | | 4821 SYN-RECEIVED remembers last state | MUST-11|x| | | | | 4822 Passive Open call interfere with others | MUST-41| | | | |x| 4823 Function: simultan. LISTENs for same port | MUST-42|x| | | | | 4824 Ask IP for src address for SYN if necc. | MUST-44|x| | | | | 4825 Otherwise, use local addr of conn. | MUST-45|x| | | | | 4826 OPEN to broadcast/multicast IP Address | MUST-46| | | | |x| 4827 Silently discard seg to bcast/mcast addr | MUST-57|x| | | | | 4828 | | | | | | | 4829 Closing Connections | | | | | | | 4830 RST can contain data | SHLD-2 | |x| | | | 4831 Inform application of aborted conn | MUST-12|x| | | | | 4832 Half-duplex close connections | MAY-1 | | |x| | | 4833 Send RST to indicate data lost | SHLD-3 | |x| | | | 4834 In TIME-WAIT state for 2MSL seconds | MUST-13|x| | | | | 4835 Accept SYN from TIME-WAIT state | MAY-2 | | |x| | | 4836 Use Timestamps to reduce TIME-WAIT | SHLD-4 | |x| | | | 4837 | | | | | | | 4838 Retransmissions | | | | | | | 4839 Implement RFC 5681 | MUST-19|x| | | | | 4840 Retransmit with same IP ident | MAY-4 | | |x| | | 4841 Karn's algorithm | MUST-18|x| | | | | 4842 | | | | | | | 4843 Generating ACKs: | | | | | | | 4844 Aggregate whenever possible | MUST-58|x| | | | | 4845 Queue out-of-order segments | SHLD-31| |x| | | | 4846 Process all Q'd before send ACK | MUST-59|x| | | | | 4847 Send ACK for out-of-order segment | MAY-13 | | |x| | | 4848 Delayed ACKs | SHLD-18| |x| | | | 4849 Delay < 0.5 seconds | MUST-40|x| | | | | 4850 Every 2nd full-sized segment ACK'd | SHLD-19|x| | | | | 4851 Receiver SWS-Avoidance Algorithm | MUST-39|x| | | | | 4852 | | | | | | | 4853 Sending data | | | | | | | 4854 Configurable TTL | MUST-49|x| | | | | 4855 Sender SWS-Avoidance Algorithm | MUST-38|x| | | | | 4856 Nagle algorithm | SHLD-7 | |x| | | | 4857 Application can disable Nagle algorithm | MUST-17|x| | | | | 4858 | | | | | | | 4859 Connection Failures: | | | | | | | 4860 Negative advice to IP on R1 retxs | MUST-20|x| | | | | 4861 Close connection on R2 retxs | MUST-20|x| | | | | 4862 ALP can set R2 | MUST-21|x| | | | |1 4863 Inform ALP of R1<=retxs inform ALP | SHLD-25| |x| | | | 4891 Dest. Unreach (0,1,5) => abort conn | MUST-56| | | | |x| 4892 Dest. Unreach (2-4) => abort conn | SHLD-26| |x| | | | 4893 Source Quench => silent discard | MUST-55|x| | | | | 4894 Time Exceeded => tell ALP, don't abort | MUST-56| | | | |x| 4895 Param Problem => tell ALP, don't abort | MUST-56| | | | |x| 4896 | | | | | | | 4897 Address Validation | | | | | | | 4898 Reject OPEN call to invalid IP address | MUST-46|x| | | | | 4899 Reject SYN from invalid IP address | MUST-63|x| | | | | 4900 Silently discard SYN to bcast/mcast addr | MUST-57|x| | | | | 4901 | | | | | | | 4902 TCP/ALP Interface Services | | | | | | | 4903 Error Report mechanism | MUST-47|x| | | | | 4904 ALP can disable Error Report Routine | SHLD-20| |x| | | | 4905 ALP can specify DiffServ field for sending | MUST-48|x| | | | | 4906 Passed unchanged to IP | SHLD-22| |x| | | | 4907 ALP can change DiffServ field during connection| SHLD-21| |x| | | | 4908 ALP generally changing DiffServ during conn. | SHLD-23| | | |x| | 4909 Pass received DiffServ field up to ALP | MAY-9 | | |x| | | 4910 FLUSH call | MAY-14 | | |x| | | 4911 Optional local IP addr parm. in OPEN | MUST-43|x| | | | | 4912 | | | | | | | 4913 RFC 5961 Support: | | | | | | | 4914 Implement data injection protection | MAY-12 | | |x| | | 4915 | | | | | | | 4916 Explicit Congestion Notification: | | | | | | | 4917 Support ECN | SHLD-8 | |x| | | | 4918 -------------------------------------------------|--------|-|-|-|-|-|- 4920 FOOTNOTES: (1) "ALP" means Application-Layer Program. 4922 Author's Address 4924 Wesley M. Eddy (editor) 4925 MTI Systems 4926 US 4928 Email: wes@mti-systems.com