idnits 2.17.1 draft-eddy-rfc793bis-04.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 2 instances of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. -- 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 RFC6528, but the abstract doesn't seem to mention this, which it should. -- The draft header indicates that this document updates RFC1122, 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 (Using the creation date from RFC1122, updated by this document, for RFC5378 checks: 1989-10-01) -- The document seems to contain a disclaimer for pre-RFC5378 work, and may have content which was first submitted before 10 November 2008. The disclaimer is necessary when there are original authors that you have been unable to contact, or if some do not wish to grant the BCP78 rights to the IETF Trust. If you are able to get all authors (current and original) to grant those rights, you can and should remove the disclaimer; otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (August 25, 2014) is 3526 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) -- Obsolete informational reference (is this intentional?): RFC 793 (ref. '2') (Obsoleted by RFC 9293) == Outdated reference: A later version (-08) exists of draft-ietf-tcpm-tcp-rfc4614bis-07 -- Obsolete informational reference (is this intentional?): RFC 6093 (ref. '5') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 6528 (ref. '6') (Obsoleted by RFC 9293) Summary: 1 error (**), 0 flaws (~~), 3 warnings (==), 8 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, 6093, 6528 (if approved) August 25, 2014 5 Updates: 1122 (if approved) 6 Intended status: Standards Track 7 Expires: February 26, 2015 9 Transmission Control Protocol Specification 10 draft-eddy-rfc793bis-04 12 Abstract 14 This document specifies the Internet's Transmission Control Protocol 15 (TCP). TCP is an important transport layer protocol in the Internet 16 stack, and has continuously evolved over decades of use and growth of 17 the Internet. Over this time, a number of changes have been made to 18 TCP as it was specified in RFC 793, though these have only been 19 documented in a piecemeal fashion. This document collects and brings 20 those changes together with the protocol specification from RFC 793. 21 This document obsoletes RFC 793 and several other RFCs (TODO: list 22 all actual RFCs when finished). 24 RFC EDITOR NOTE: If approved for publication as an RFC, this should 25 be marked additionally as "STD: 7" and replace RFC 793 in that role. 27 Requirements Language 29 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 30 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 31 document are to be interpreted as described in RFC 2119 [1]. 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 http://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 February 26, 2015. 50 Copyright Notice 52 Copyright (c) 2014 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 (http://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 3. Functional Specification . . . . . . . . . . . . . . . . . . 4 82 3.1. Header Format . . . . . . . . . . . . . . . . . . . . . . 4 83 3.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 9 84 3.3. Sequence Numbers . . . . . . . . . . . . . . . . . . . . 13 85 3.4. Establishing a connection . . . . . . . . . . . . . . . . 20 86 3.5. Closing a Connection . . . . . . . . . . . . . . . . . . 27 87 3.6. Precedence and Security . . . . . . . . . . . . . . . . . 29 88 3.7. Data Communication . . . . . . . . . . . . . . . . . . . 30 89 3.8. Interfaces . . . . . . . . . . . . . . . . . . . . . . . 34 90 3.8.1. User/TCP Interface . . . . . . . . . . . . . . . . . 34 91 3.8.2. TCP/Lower-Level Interface . . . . . . . . . . . . . . 41 92 3.9. Event Processing . . . . . . . . . . . . . . . . . . . . 42 93 3.10. Glossary . . . . . . . . . . . . . . . . . . . . . . . . 65 94 4. Changes from RFC 793 . . . . . . . . . . . . . . . . . . . . 70 95 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 73 96 6. Security and Privacy Considerations . . . . . . . . . . . . . 73 97 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 73 98 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 74 99 8.1. Normative References . . . . . . . . . . . . . . . . . . 74 100 8.2. Informative References . . . . . . . . . . . . . . . . . 74 101 Appendix A. TCP Requirement Summary . . . . . . . . . . . . . . 75 102 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 78 104 1. Purpose and Scope 106 In 1981, RFC 793 [2] was released, documenting the Transmission 107 Control Protocol (TCP), and replacing earlier specifications for TCP 108 that had been published in the past. 110 Since then, TCP has been implemented many times, and has been used as 111 a transport protocol for numerous applications on the Internet. 113 For several decades, RFC 793 plus a number of other documents have 114 combined to serve as the specification for TCP [4]. Over time, a 115 number of errata have been identified on RFC 793, as well as 116 deficiencies in security, performance, and other aspects. A number 117 of enhancements has grown and been documented separately. These were 118 never accumulated together into an update to the base specification. 120 The purpose of this document is to bring together all of the IETF 121 Standards Track changes that have been made to the basic TCP 122 functional specification and unify them into an update of the RFC 793 123 protocol specification. Some companion documents are referenced for 124 important algorithms that TCP uses (e.g. for congestion control), but 125 have not been attempted to include in this document. This is a 126 conscious choice, as this base specification can be used with 127 multiple additional algorithms that are developed and incorporated 128 separately, but all TCP implementations need to implement this 129 specification as a common basis in order to interoperate. As some 130 additional TCP features have become quite complicated themselves 131 (e.g. advanced loss recovery and congestion control), future 132 companion documents may attempt to similarly bring these together. 134 In addition to the protocol specification that descibes the TCP 135 segment format, generation, and processing rules that are to be 136 implemented in code, RFC 793 and other updates also contain 137 informative and descriptive text for human readers to understand 138 aspects of the protocol design and operation. This document does not 139 attempt to alter or update this informative text, and is focused only 140 on updating the normative protocol specification. We preserve 141 references to the documentation containing the important explanations 142 and rationale, where appropriate. 144 This document is intended to be useful both in checking existing TCP 145 implementations for conformance, as well as in writing new 146 implementations. 148 2. Introduction 150 RFC 793 contains a discussion of the TCP design goals and provides 151 examples of its operation, including examples of connection 152 establishment, closing connections, and retransmitting packets to 153 repair losses. 155 This document describes the basic functionality expected in modern 156 implementations of TCP, and replaces the protocol specification in 157 RFC 793. It does not replicate or attempt to update the examples and 158 other discussion in RFC 793. Other documents are referenced to 159 provide explanation of the theory of operation, rationale, and 160 detailed discussion of design decisions. This document only focuses 161 on the normative behavior of the protocol. 163 TEMPORARY EDITOR'S NOTE: This is an early revision in the process of 164 updating RFC 793. Many planned changes are not yet incorporated. 166 ***Please do not use this revision as a basis for any work or 167 reference.*** 169 A list of changes from RFC 793 is contained in Section 4. 171 TEMPORARY EDITOR'S NOTE: the current revision of this document does 172 not yet collect all of the changes that will be in the final version. 173 The set of content changes planned for future revisions is kept in 174 Section 4. 176 3. Functional Specification 178 3.1. Header Format 180 TCP segments are sent as internet datagrams. The Internet Protocol 181 header carries several information fields, including the source and 182 destination host addresses [2]. A TCP header follows the internet 183 header, supplying information specific to the TCP protocol. This 184 division allows for the existence of host level protocols other than 185 TCP. 187 TCP Header Format 188 0 1 2 3 189 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 190 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 191 | Source Port | Destination Port | 192 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 193 | Sequence Number | 194 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 195 | Acknowledgment Number | 196 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 197 | Data | |U|A|P|R|S|F| | 198 | Offset| Reserved |R|C|S|S|Y|I| Window | 199 | | |G|K|H|T|N|N| | 200 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 201 | Checksum | Urgent Pointer | 202 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 203 | Options | Padding | 204 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 205 | data | 206 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 208 TCP Header Format 210 Note that one tick mark represents one bit position. 212 Figure 1 214 Source Port: 16 bits 216 The source port number. 218 Destination Port: 16 bits 220 The destination port number. 222 Sequence Number: 32 bits 224 The sequence number of the first data octet in this segment (except 225 when SYN is present). If SYN is present the sequence number is the 226 initial sequence number (ISN) and the first data octet is ISN+1. 228 Acknowledgment Number: 32 bits 230 If the ACK control bit is set this field contains the value of the 231 next sequence number the sender of the segment is expecting to 232 receive. Once a connection is established this is always sent. 234 Data Offset: 4 bits 235 The number of 32 bit words in the TCP Header. This indicates where 236 the data begins. The TCP header (even one including options) is an 237 integral number of 32 bits long. 239 Reserved: 6 bits 241 Reserved for future use. Must be zero. 243 Control Bits: 6 bits (from left to right): 245 URG: Urgent Pointer field significant 246 ACK: Acknowledgment field significant 247 PSH: Push Function 248 RST: Reset the connection 249 SYN: Synchronize sequence numbers 250 FIN: No more data from sender 252 Window: 16 bits 254 The number of data octets beginning with the one indicated in the 255 acknowledgment field which the sender of this segment is willing to 256 accept. 258 Checksum: 16 bits 260 The checksum field is the 16 bit one's complement of the one's 261 complement sum of all 16 bit words in the header and text. If a 262 segment contains an odd number of header and text octets to be 263 checksummed, the last octet is padded on the right with zeros to 264 form a 16 bit word for checksum purposes. The pad is not 265 transmitted as part of the segment. While computing the checksum, 266 the checksum field itself is replaced with zeros. 268 The checksum also covers a 96 bit pseudo header conceptually 269 prefixed to the TCP header. This pseudo header contains the Source 270 Address, the Destination Address, the Protocol, and TCP length. 271 This gives the TCP protection against misrouted segments. This 272 information is carried in the Internet Protocol and is transferred 273 across the TCP/Network interface in the arguments or results of 274 calls by the TCP on the IP. 276 +--------+--------+--------+--------+ 277 | Source Address | 278 +--------+--------+--------+--------+ 279 | Destination Address | 280 +--------+--------+--------+--------+ 281 | zero | PTCL | TCP Length | 282 +--------+--------+--------+--------+ 284 The TCP Length is the TCP header length plus the data length in 285 octets (this is not an explicitly transmitted quantity, but is 286 computed), and it does not count the 12 octets of the pseudo 287 header. 289 Urgent Pointer: 16 bits 291 This field communicates the current value of the urgent pointer as 292 a positive offset from the sequence number in this segment. The 293 urgent pointer points to the sequence number of the octet following 294 the urgent data. This field is only be interpreted in segments 295 with the URG control bit set. 297 Options: variable 299 Options may occupy space at the end of the TCP header and are a 300 multiple of 8 bits in length. All options are included in the 301 checksum. An option may begin on any octet boundary. There are 302 two cases for the format of an option: 304 Case 1: A single octet of option-kind. 306 Case 2: An octet of option-kind, an octet of option-length, and 307 the actual option-data octets. 309 The option-length counts the two octets of option-kind and option- 310 length as well as the option-data octets. 312 Note that the list of options may be shorter than the data offset 313 field might imply. The content of the header beyond the End-of- 314 Option option must be header padding (i.e., zero). 316 A TCP must implement all options. 318 Currently defined options include (kind indicated in octal): 320 Kind Length Meaning 321 ---- ------ ------- 322 0 - End of option list. 323 1 - No-Operation. 324 2 4 Maximum Segment Size. 326 Specific Option Definitions 328 End of Option List 330 +--------+ 331 |00000000| 332 +--------+ 333 Kind=0 335 This option code indicates the end of the option list. This 336 might not coincide with the end of the TCP header according to 337 the Data Offset field. This is used at the end of all options, 338 not the end of each option, and need only be used if the end of 339 the options would not otherwise coincide with the end of the TCP 340 header. 342 No-Operation 344 +--------+ 345 |00000001| 346 +--------+ 347 Kind=1 349 This option code may be used between options, for example, to 350 align the beginning of a subsequent option on a word boundary. 351 There is no guarantee that senders will use this option, so 352 receivers must be prepared to process options even if they do 353 not begin on a word boundary. 355 Maximum Segment Size 357 +--------+--------+---------+--------+ 358 |00000010|00000100| max seg size | 359 +--------+--------+---------+--------+ 360 Kind=2 Length=4 362 Maximum Segment Size Option Data: 16 bits 364 If this option is present, then it communicates the maximum 365 receive segment size at the TCP which sends this segment. This 366 field may be sent in the initial connection request (i.e., in 367 segments with the SYN control bit set) and must not be sent in 368 other segments. If this option is not used, any segment size is 369 allowed. 371 Padding: variable 373 The TCP header padding is used to ensure that the TCP header ends 374 and data begins on a 32 bit boundary. The padding is composed of 375 zeros. 377 3.2. Terminology 379 Before we can discuss very much about the operation of the TCP we 380 need to introduce some detailed terminology. The maintenance of a 381 TCP connection requires the remembering of several variables. We 382 conceive of these variables being stored in a connection record 383 called a Transmission Control Block or TCB. Among the variables 384 stored in the TCB are the local and remote socket numbers, the 385 security and precedence of the connection, pointers to the user's 386 send and receive buffers, pointers to the retransmit queue and to the 387 current segment. In addition several variables relating to the send 388 and receive sequence numbers are stored in the TCB. 390 Send Sequence Variables 392 SND.UNA - send unacknowledged 393 SND.NXT - send next 394 SND.WND - send window 395 SND.UP - send urgent pointer 396 SND.WL1 - segment sequence number used for last window update 397 SND.WL2 - segment acknowledgment number used for last window 398 update 399 ISS - initial send sequence number 401 Receive Sequence Variables 403 RCV.NXT - receive next 404 RCV.WND - receive window 405 RCV.UP - receive urgent pointer 406 IRS - initial receive sequence number 408 The following diagrams may help to relate some of these variables to 409 the sequence space. 411 Send Sequence Space 413 1 2 3 4 414 ----------|----------|----------|---------- 415 SND.UNA SND.NXT SND.UNA 416 +SND.WND 418 1 - old sequence numbers which have been acknowledged 419 2 - sequence numbers of unacknowledged data 420 3 - sequence numbers allowed for new data transmission 421 4 - future sequence numbers which are not yet allowed 423 Send Sequence Space 425 Figure 2 427 The send window is the portion of the sequence space labeled 3 in 428 Figure 2. 430 Receive Sequence Space 432 1 2 3 433 ----------|----------|---------- 434 RCV.NXT RCV.NXT 435 +RCV.WND 437 1 - old sequence numbers which have been acknowledged 438 2 - sequence numbers allowed for new reception 439 3 - future sequence numbers which are not yet allowed 441 Receive Sequence Space 443 Figure 3 445 The receive window is the portion of the sequence space labeled 2 in 446 Figure 3. 448 There are also some variables used frequently in the discussion that 449 take their values from the fields of the current segment. 451 Current Segment Variables 453 SEG.SEQ - segment sequence number 454 SEG.ACK - segment acknowledgment number 455 SEG.LEN - segment length 456 SEG.WND - segment window 457 SEG.UP - segment urgent pointer 458 SEG.PRC - segment precedence value 460 A connection progresses through a series of states during its 461 lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, 462 ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, 463 TIME-WAIT, and the fictional state CLOSED. CLOSED is fictional 464 because it represents the state when there is no TCB, and therefore, 465 no connection. Briefly the meanings of the states are: 467 LISTEN - represents waiting for a connection request from any 468 remote TCP and port. 470 SYN-SENT - represents waiting for a matching connection request 471 after having sent a connection request. 473 SYN-RECEIVED - represents waiting for a confirming connection 474 request acknowledgment after having both received and sent a 475 connection request. 477 ESTABLISHED - represents an open connection, data received can be 478 delivered to the user. The normal state for the data transfer 479 phase of the connection. 481 FIN-WAIT-1 - represents waiting for a connection termination 482 request from the remote TCP, or an acknowledgment of the 483 connection termination request previously sent. 485 FIN-WAIT-2 - represents waiting for a connection termination 486 request from the remote TCP. 488 CLOSE-WAIT - represents waiting for a connection termination 489 request from the local user. 491 CLOSING - represents waiting for a connection termination request 492 acknowledgment from the remote TCP. 494 LAST-ACK - represents waiting for an acknowledgment of the 495 connection termination request previously sent to the remote TCP 496 (this termination request sent to the remote TCP already included 497 an acknowledgment of the termination request sent from the remote 498 TCP). 500 TIME-WAIT - represents waiting for enough time to pass to be sure 501 the remote TCP received the acknowledgment of its connection 502 termination request. 504 CLOSED - represents no connection state at all. 506 A TCP connection progresses from one state to another in response to 507 events. The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, 508 ABORT, and STATUS; the incoming segments, particularly those 509 containing the SYN, ACK, RST and FIN flags; and timeouts. 511 The state diagram in Figure 4 illustrates only state changes, 512 together with the causing events and resulting actions, but addresses 513 neither error conditions nor actions which are not connected with 514 state changes. In a later section, more detail is offered with 515 respect to the reaction of the TCP to events. 517 NOTA BENE: this diagram is only a summary and must not be taken as 518 the total specification. 520 +---------+ ---------\ active OPEN 521 | CLOSED | \ ----------- 522 +---------+<---------\ \ create TCB 523 | ^ \ \ snd SYN 524 passive OPEN | | CLOSE \ \ 525 ------------ | | ---------- \ \ 526 create TCB | | delete TCB \ \ 527 V | \ \ 528 rcv RST (note 1) +---------+ CLOSE | \ 529 -------------------->| LISTEN | ---------- | | 530 / +---------+ delete TCB | | 531 / rcv SYN | | SEND | | 532 / ----------- | | ------- | V 533 +---------+ snd SYN,ACK / \ snd SYN +---------+ 534 | |<----------------- ------------------>| | 535 | SYN | rcv SYN | SYN | 536 | RCVD |<-----------------------------------------------| SENT | 537 | | snd SYN,ACK | | 538 | |------------------ -------------------| | 539 +---------+ rcv ACK of SYN \ / rcv SYN,ACK +---------+ 540 | -------------- | | ----------- 541 | x | | snd ACK 542 | V V 543 | CLOSE +---------+ 544 | ------- | ESTAB | 545 | snd FIN +---------+ 546 | CLOSE | | rcv FIN 547 V ------- | | ------- 548 +---------+ snd FIN / \ snd ACK +---------+ 549 | FIN |<----------------- ------------------>| CLOSE | 550 | WAIT-1 |------------------ | WAIT | 551 +---------+ rcv FIN \ +---------+ 552 | rcv ACK of FIN ------- | CLOSE | 553 | -------------- snd ACK | ------- | 554 V x V snd FIN V 555 +---------+ +---------+ +---------+ 556 |FINWAIT-2| | CLOSING | | LAST-ACK| 557 +---------+ +---------+ +---------+ 558 | rcv ACK of FIN | rcv ACK of FIN | 559 | rcv FIN -------------- | Timeout=2MSL -------------- | 560 | ------- x V ------------ x V 561 \ snd ACK +---------+delete TCB +---------+ 562 ------------------------>|TIME WAIT|------------------>| CLOSED | 563 +---------+ +---------+ 565 note 1: The transition from SYN-RCVD to LISTEN on receiving a RST is 566 conditional on having reached SYN-RCVD after a passive open. 568 note 2: An unshown transition exists from FIN-WAIT-1 to TIME-WAIT if 569 a FIN is received and the local FIN is also acknowledged. 571 TCP Connection State Diagram 573 Figure 4 575 3.3. Sequence Numbers 577 A fundamental notion in the design is that every octet of data sent 578 over a TCP connection has a sequence number. Since every octet is 579 sequenced, each of them can be acknowledged. The acknowledgment 580 mechanism employed is cumulative so that an acknowledgment of 581 sequence number X indicates that all octets up to but not including X 582 have been received. This mechanism allows for straight-forward 583 duplicate detection in the presence of retransmission. Numbering of 584 octets within a segment is that the first data octet immediately 585 following the header is the lowest numbered, and the following octets 586 are numbered consecutively. 588 It is essential to remember that the actual sequence number space is 589 finite, though very large. This space ranges from 0 to 2**32 - 1. 590 Since the space is finite, all arithmetic dealing with sequence 591 numbers must be performed modulo 2**32. This unsigned arithmetic 592 preserves the relationship of sequence numbers as they cycle from 593 2**32 - 1 to 0 again. There are some subtleties to computer modulo 594 arithmetic, so great care should be taken in programming the 595 comparison of such values. The symbol "=<" means "less than or 596 equal" (modulo 2**32). 598 The typical kinds of sequence number comparisons which the TCP must 599 perform include: 601 (a) Determining that an acknowledgment refers to some sequence 602 number sent but not yet acknowledged. 604 (b) Determining that all sequence numbers occupied by a segment 605 have been acknowledged (e.g., to remove the segment from a 606 retransmission queue). 608 (c) Determining that an incoming segment contains sequence numbers 609 which are expected (i.e., that the segment "overlaps" the receive 610 window). 612 In response to sending data the TCP will receive acknowledgments. 613 The following comparisons are needed to process the acknowledgments. 615 SND.UNA = oldest unacknowledged sequence number 617 SND.NXT = next sequence number to be sent 619 SEG.ACK = acknowledgment from the receiving TCP (next sequence 620 number expected by the receiving TCP) 622 SEG.SEQ = first sequence number of a segment 624 SEG.LEN = the number of octets occupied by the data in the segment 625 (counting SYN and FIN) 627 SEG.SEQ+SEG.LEN-1 = last sequence number of a segment 629 A new acknowledgment (called an "acceptable ack"), is one for which 630 the inequality below holds: 632 SND.UNA < SEG.ACK =< SND.NXT 634 A segment on the retransmission queue is fully acknowledged if the 635 sum of its sequence number and length is less or equal than the 636 acknowledgment value in the incoming segment. 638 When data is received the following comparisons are needed: 640 RCV.NXT = next sequence number expected on an incoming segments, 641 and is the left or lower edge of the receive window 643 RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming 644 segment, and is the right or upper edge of the receive window 646 SEG.SEQ = first sequence number occupied by the incoming segment 648 SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming 649 segment 651 A segment is judged to occupy a portion of valid receive sequence 652 space if 654 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 656 or 658 RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 660 The first part of this test checks to see if the beginning of the 661 segment falls in the window, the second part of the test checks to 662 see if the end of the segment falls in the window; if the segment 663 passes either part of the test it contains data in the window. 665 Actually, it is a little more complicated than this. Due to zero 666 windows and zero length segments, we have four cases for the 667 acceptability of an incoming segment: 669 Segment Receive Test 670 Length Window 671 ------- ------- ------------------------------------------- 673 0 0 SEG.SEQ = RCV.NXT 675 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 677 >0 0 not acceptable 679 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 680 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 682 Note that when the receive window is zero no segments should be 683 acceptable except ACK segments. Thus, it is be possible for a TCP to 684 maintain a zero receive window while transmitting data and receiving 685 ACKs. However, even when the receive window is zero, a TCP must 686 process the RST and URG fields of all incoming segments. 688 We have taken advantage of the numbering scheme to protect certain 689 control information as well. This is achieved by implicitly 690 including some control flags in the sequence space so they can be 691 retransmitted and acknowledged without confusion (i.e., one and only 692 one copy of the control will be acted upon). Control information is 693 not physically carried in the segment data space. Consequently, we 694 must adopt rules for implicitly assigning sequence numbers to 695 control. The SYN and FIN are the only controls requiring this 696 protection, and these controls are used only at connection opening 697 and closing. For sequence number purposes, the SYN is considered to 698 occur before the first actual data octet of the segment in which it 699 occurs, while the FIN is considered to occur after the last actual 700 data octet in a segment in which it occurs. The segment length 701 (SEG.LEN) includes both data and sequence space occupying controls. 702 When a SYN is present then SEG.SEQ is the sequence number of the SYN. 704 Initial Sequence Number Selection 706 The protocol places no restriction on a particular connection being 707 used over and over again. A connection is defined by a pair of 708 sockets. New instances of a connection will be referred to as 709 incarnations of the connection. The problem that arises from this is 710 -- "how does the TCP identify duplicate segments from previous 711 incarnations of the connection?" This problem becomes apparent if 712 the connection is being opened and closed in quick succession, or if 713 the connection breaks with loss of memory and is then reestablished. 715 To avoid confusion we must prevent segments from one incarnation of a 716 connection from being used while the same sequence numbers may still 717 be present in the network from an earlier incarnation. We want to 718 assure this, even if a TCP crashes and loses all knowledge of the 719 sequence numbers it has been using. When new connections are 720 created, an initial sequence number (ISN) generator is employed which 721 selects a new 32 bit ISN. There are security issues that result if 722 an off-path attacker is able to predict or guess ISN values. 724 The recommended ISN generator is based on the combination of a 725 (possibly fictitious) 32 bit clock whose low order bit is incremented 726 roughly every 4 microseconds, and a pseudorandom hash function (PRF). 727 The clock component is intended to insure that with a Maximum Segment 728 Lifetime (MSL), generated ISNs will be unique, since it cycles 729 approximately every 4.55 hours, which is much longer than the MSL. 731 TCP SHOULD generate its Initial Sequence Numbers with the expression: 733 ISN = M + F(localip, localport, remoteip, remoteport, secretkey) 735 where M is the 4 microsecond timer, and F() is a pseudorandom 736 function (PRF) of the connection's identifying parameters ("localip, 737 localport, remoteip, remoteport") and a secret key ("secretkey"). 738 F() MUST NOT be computable from the outside, or an attacker could 739 still guess at sequence numbers from the ISN used for some other 740 connection. The PRF could be implemented as a cryptographic has of 741 the concatenation of the TCP connection parameters and some secret 742 data. For discussion of the selection of a specific hash algorithm 743 and management of the secret key data, please see Section 3 of [6]. 745 For each connection there is a send sequence number and a receive 746 sequence number. The initial send sequence number (ISS) is chosen by 747 the data sending TCP, and the initial receive sequence number (IRS) 748 is learned during the connection establishing procedure. 750 For a connection to be established or initialized, the two TCPs must 751 synchronize on each other's initial sequence numbers. This is done 752 in an exchange of connection establishing segments carrying a control 753 bit called "SYN" (for synchronize) and the initial sequence numbers. 754 As a shorthand, segments carrying the SYN bit are also called "SYNs". 755 Hence, the solution requires a suitable mechanism for picking an 756 initial sequence number and a slightly involved handshake to exchange 757 the ISN's. 759 The synchronization requires each side to send it's own initial 760 sequence number and to receive a confirmation of it in acknowledgment 761 from the other side. Each side must also receive the other side's 762 initial sequence number and send a confirming acknowledgment. 764 1) A --> B SYN my sequence number is X 765 2) A <-- B ACK your sequence number is X 766 3) A <-- B SYN my sequence number is Y 767 4) A --> B ACK your sequence number is Y 769 Because steps 2 and 3 can be combined in a single message this is 770 called the three way (or three message) handshake. 772 A three way handshake is necessary because sequence numbers are not 773 tied to a global clock in the network, and TCPs may have different 774 mechanisms for picking the ISN's. The receiver of the first SYN has 775 no way of knowing whether the segment was an old delayed one or not, 776 unless it remembers the last sequence number used on the connection 777 (which is not always possible), and so it must ask the sender to 778 verify this SYN. The three way handshake and the advantages of a 779 clock-driven scheme are discussed in [3]. 781 Knowing When to Keep Quiet 783 To be sure that a TCP does not create a segment that carries a 784 sequence number which may be duplicated by an old segment remaining 785 in the network, the TCP must keep quiet for a maximum segment 786 lifetime (MSL) before assigning any sequence numbers upon starting up 787 or recovering from a crash in which memory of sequence numbers in use 788 was lost. For this specification the MSL is taken to be 2 minutes. 789 This is an engineering choice, and may be changed if experience 790 indicates it is desirable to do so. Note that if a TCP is 791 reinitialized in some sense, yet retains its memory of sequence 792 numbers in use, then it need not wait at all; it must only be sure to 793 use sequence numbers larger than those recently used. 795 The TCP Quiet Time Concept 797 This specification provides that hosts which "crash" without 798 retaining any knowledge of the last sequence numbers transmitted on 799 each active (i.e., not closed) connection shall delay emitting any 800 TCP segments for at least the agreed Maximum Segment Lifetime (MSL) 801 in the internet system of which the host is a part. In the 802 paragraphs below, an explanation for this specification is given. 803 TCP implementors may violate the "quiet time" restriction, but only 804 at the risk of causing some old data to be accepted as new or new 805 data rejected as old duplicated by some receivers in the internet 806 system. 808 TCPs consume sequence number space each time a segment is formed and 809 entered into the network output queue at a source host. The 810 duplicate detection and sequencing algorithm in the TCP protocol 811 relies on the unique binding of segment data to sequence space to the 812 extent that sequence numbers will not cycle through all 2**32 values 813 before the segment data bound to those sequence numbers has been 814 delivered and acknowledged by the receiver and all duplicate copies 815 of the segments have "drained" from the internet. Without such an 816 assumption, two distinct TCP segments could conceivably be assigned 817 the same or overlapping sequence numbers, causing confusion at the 818 receiver as to which data is new and which is old. Remember that 819 each segment is bound to as many consecutive sequence numbers as 820 there are octets of data and SYN or FIN flags in the segment. 822 Under normal conditions, TCPs keep track of the next sequence number 823 to emit and the oldest awaiting acknowledgment so as to avoid 824 mistakenly using a sequence number over before its first use has been 825 acknowledged. This alone does not guarantee that old duplicate data 826 is drained from the net, so the sequence space has been made very 827 large to reduce the probability that a wandering duplicate will cause 828 trouble upon arrival. At 2 megabits/sec. it takes 4.5 hours to use 829 up 2**32 octets of sequence space. Since the maximum segment 830 lifetime in the net is not likely to exceed a few tens of seconds, 831 this is deemed ample protection for foreseeable nets, even if data 832 rates escalate to l0's of megabits/sec. At 100 megabits/sec, the 833 cycle time is 5.4 minutes which may be a little short, but still 834 within reason. 836 The basic duplicate detection and sequencing algorithm in TCP can be 837 defeated, however, if a source TCP does not have any memory of the 838 sequence numbers it last used on a given connection. For example, if 839 the TCP were to start all connections with sequence number 0, then 840 upon crashing and restarting, a TCP might re-form an earlier 841 connection (possibly after half-open connection resolution) and emit 842 packets with sequence numbers identical to or overlapping with 843 packets still in the network which were emitted on an earlier 844 incarnation of the same connection. In the absence of knowledge 845 about the sequence numbers used on a particular connection, the TCP 846 specification recommends that the source delay for MSL seconds before 847 emitting segments on the connection, to allow time for segments from 848 the earlier connection incarnation to drain from the system. 850 Even hosts which can remember the time of day and used it to select 851 initial sequence number values are not immune from this problem 852 (i.e., even if time of day is used to select an initial sequence 853 number for each new connection incarnation). 855 Suppose, for example, that a connection is opened starting with 856 sequence number S. Suppose that this connection is not used much and 857 that eventually the initial sequence number function (ISN(t)) takes 858 on a value equal to the sequence number, say S1, of the last segment 859 sent by this TCP on a particular connection. Now suppose, at this 860 instant, the host crashes, recovers, and establishes a new 861 incarnation of the connection. The initial sequence number chosen is 862 S1 = ISN(t) -- last used sequence number on old incarnation of 863 connection! If the recovery occurs quickly enough, any old 864 duplicates in the net bearing sequence numbers in the neighborhood of 865 S1 may arrive and be treated as new packets by the receiver of the 866 new incarnation of the connection. 868 The problem is that the recovering host may not know for how long it 869 crashed nor does it know whether there are still old duplicates in 870 the system from earlier connection incarnations. 872 One way to deal with this problem is to deliberately delay emitting 873 segments for one MSL after recovery from a crash- this is the "quiet 874 time" specification. Hosts which prefer to avoid waiting are willing 875 to risk possible confusion of old and new packets at a given 876 destination may choose not to wait for the "quite time". 877 Implementors may provide TCP users with the ability to select on a 878 connection by connection basis whether to wait after a crash, or may 879 informally implement the "quite time" for all connections. 880 Obviously, even where a user selects to "wait," this is not necessary 881 after the host has been "up" for at least MSL seconds. 883 To summarize: every segment emitted occupies one or more sequence 884 numbers in the sequence space, the numbers occupied by a segment are 885 "busy" or "in use" until MSL seconds have passed, upon crashing a 886 block of space-time is occupied by the octets and SYN or FIN flags of 887 the last emitted segment, if a new connection is started too soon and 888 uses any of the sequence numbers in the space-time footprint of the 889 last segment of the previous connection incarnation, there is a 890 potential sequence number overlap area which could cause confusion at 891 the receiver. 893 3.4. Establishing a connection 895 The "three-way handshake" is the procedure used to establish a 896 connection. This procedure normally is initiated by one TCP and 897 responded to by another TCP. The procedure also works if two TCP 898 simultaneously initiate the procedure. When simultaneous attempt 899 occurs, each TCP receives a "SYN" segment which carries no 900 acknowledgment after it has sent a "SYN". Of course, the arrival of 901 an old duplicate "SYN" segment can potentially make it appear, to the 902 recipient, that a simultaneous connection initiation is in progress. 903 Proper use of "reset" segments can disambiguate these cases. 905 Several examples of connection initiation follow. Although these 906 examples do not show connection synchronization using data-carrying 907 segments, this is perfectly legitimate, so long as the receiving TCP 908 doesn't deliver the data to the user until it is clear the data is 909 valid (i.e., the data must be buffered at the receiver until the 910 connection reaches the ESTABLISHED state). The three-way handshake 911 reduces the possibility of false connections. It is the 912 implementation of a trade-off between memory and messages to provide 913 information for this checking. 915 The simplest three-way handshake is shown in Figure 5 below. The 916 figures should be interpreted in the following way. Each line is 917 numbered for reference purposes. Right arrows (-->) indicate 918 departure of a TCP segment from TCP A to TCP B, or arrival of a 919 segment at B from A. Left arrows (<--), indicate the reverse. 920 Ellipsis (...) indicates a segment which is still in the network 921 (delayed). An "XXX" indicates a segment which is lost or rejected. 922 Comments appear in parentheses. TCP states represent the state AFTER 923 the departure or arrival of the segment (whose contents are shown in 924 the center of each line). Segment contents are shown in abbreviated 925 form, with sequence number, control flags, and ACK field. Other 926 fields such as window, addresses, lengths, and text have been left 927 out in the interest of clarity. 929 TCP A TCP B 931 1. CLOSED LISTEN 933 2. SYN-SENT --> --> SYN-RECEIVED 935 3. ESTABLISHED <-- <-- SYN-RECEIVED 937 4. ESTABLISHED --> --> ESTABLISHED 939 5. ESTABLISHED --> --> ESTABLISHED 941 Basic 3-Way Handshake for Connection Synchronization 943 Figure 5 945 In line 2 of Figure 5, TCP A begins by sending a SYN segment 946 indicating that it will use sequence numbers starting with sequence 947 number 100. In line 3, TCP B sends a SYN and acknowledges the SYN it 948 received from TCP A. Note that the acknowledgment field indicates 949 TCP B is now expecting to hear sequence 101, acknowledging the SYN 950 which occupied sequence 100. 952 At line 4, TCP A responds with an empty segment containing an ACK for 953 TCP B's SYN; and in line 5, TCP A sends some data. Note that the 954 sequence number of the segment in line 5 is the same as in line 4 955 because the ACK does not occupy sequence number space (if it did, we 956 would wind up ACKing ACK's!). 958 Simultaneous initiation is only slightly more complex, as is shown in 959 Figure 6. Each TCP cycles from CLOSED to SYN-SENT to SYN-RECEIVED to 960 ESTABLISHED. 962 TCP A TCP B 964 1. CLOSED CLOSED 966 2. SYN-SENT --> ... 968 3. SYN-RECEIVED <-- <-- SYN-SENT 970 4. ... --> SYN-RECEIVED 972 5. SYN-RECEIVED --> ... 974 6. ESTABLISHED <-- <-- SYN-RECEIVED 976 7. ... --> ESTABLISHED 978 Simultaneous Connection Synchronization 980 Figure 6 982 The principle reason for the three-way handshake is to prevent old 983 duplicate connection initiations from causing confusion. To deal 984 with this, a special control message, reset, has been devised. If 985 the receiving TCP is in a non-synchronized state (i.e., SYN-SENT, 986 SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset. 987 If the TCP is in one of the synchronized states (ESTABLISHED, FIN- 988 WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it 989 aborts the connection and informs its user. We discuss this latter 990 case under "half-open" connections below. 992 TCP A TCP B 994 1. CLOSED LISTEN 996 2. SYN-SENT --> ... 998 3. (duplicate) ... --> SYN-RECEIVED 1000 4. SYN-SENT <-- <-- SYN-RECEIVED 1002 5. SYN-SENT --> --> LISTEN 1004 6. ... --> SYN-RECEIVED 1006 7. SYN-SENT <-- <-- SYN-RECEIVED 1008 8. ESTABLISHED --> --> ESTABLISHED 1010 Recovery from Old Duplicate SYN 1012 Figure 7 1014 As a simple example of recovery from old duplicates, consider 1015 Figure 7. At line 3, an old duplicate SYN arrives at TCP B. TCP B 1016 cannot tell that this is an old duplicate, so it responds normally 1017 (line 4). TCP A detects that the ACK field is incorrect and returns 1018 a RST (reset) with its SEQ field selected to make the segment 1019 believable. TCP B, on receiving the RST, returns to the LISTEN 1020 state. When the original SYN (pun intended) finally arrives at line 1021 6, the synchronization proceeds normally. If the SYN at line 6 had 1022 arrived before the RST, a more complex exchange might have occurred 1023 with RST's sent in both directions. 1025 Half-Open Connections and Other Anomalies 1027 An established connection is said to be "half-open" if one of the 1028 TCPs has closed or aborted the connection at its end without the 1029 knowledge of the other, or if the two ends of the connection have 1030 become desynchronized owing to a crash that resulted in loss of 1031 memory. Such connections will automatically become reset if an 1032 attempt is made to send data in either direction. However, half-open 1033 connections are expected to be unusual, and the recovery procedure is 1034 mildly involved. 1036 If at site A the connection no longer exists, then an attempt by the 1037 user at site B to send any data on it will result in the site B TCP 1038 receiving a reset control message. Such a message indicates to the 1039 site B TCP that something is wrong, and it is expected to abort the 1040 connection. 1042 Assume that two user processes A and B are communicating with one 1043 another when a crash occurs causing loss of memory to A's TCP. 1044 Depending on the operating system supporting A's TCP, it is likely 1045 that some error recovery mechanism exists. When the TCP is up again, 1046 A is likely to start again from the beginning or from a recovery 1047 point. As a result, A will probably try to OPEN the connection again 1048 or try to SEND on the connection it believes open. In the latter 1049 case, it receives the error message "connection not open" from the 1050 local (A's) TCP. In an attempt to establish the connection, A's TCP 1051 will send a segment containing SYN. This scenario leads to the 1052 example shown in Figure 8. After TCP A crashes, the user attempts to 1053 re-open the connection. TCP B, in the meantime, thinks the 1054 connection is open. 1056 TCP A TCP B 1058 1. (CRASH) (send 300,receive 100) 1060 2. CLOSED ESTABLISHED 1062 3. SYN-SENT --> --> (??) 1064 4. (!!) <-- <-- ESTABLISHED 1066 5. SYN-SENT --> --> (Abort!!) 1068 6. SYN-SENT CLOSED 1070 7. SYN-SENT --> --> 1072 Half-Open Connection Discovery 1074 Figure 8 1076 When the SYN arrives at line 3, TCP B, being in a synchronized state, 1077 and the incoming segment outside the window, responds with an 1078 acknowledgment indicating what sequence it next expects to hear (ACK 1079 100). TCP A sees that this segment does not acknowledge anything it 1080 sent and, being unsynchronized, sends a reset (RST) because it has 1081 detected a half-open connection. TCP B aborts at line 5. TCP A will 1082 continue to try to establish the connection; the problem is now 1083 reduced to the basic 3-way handshake of Figure 5. 1085 An interesting alternative case occurs when TCP A crashes and TCP B 1086 tries to send data on what it thinks is a synchronized connection. 1088 This is illustrated in Figure 9. In this case, the data arriving at 1089 TCP A from TCP B (line 2) is unacceptable because no such connection 1090 exists, so TCP A sends a RST. The RST is acceptable so TCP B 1091 processes it and aborts the connection. 1093 TCP A TCP B 1095 1. (CRASH) (send 300,receive 100) 1097 2. (??) <-- <-- ESTABLISHED 1099 3. --> --> (ABORT!!) 1101 Active Side Causes Half-Open Connection Discovery 1103 Figure 9 1105 In Figure 10, we find the two TCPs A and B with passive connections 1106 waiting for SYN. An old duplicate arriving at TCP B (line 2) stirs B 1107 into action. A SYN-ACK is returned (line 3) and causes TCP A to 1108 generate a RST (the ACK in line 3 is not acceptable). TCP B accepts 1109 the reset and returns to its passive LISTEN state. 1111 TCP A TCP B 1113 1. LISTEN LISTEN 1115 2. ... --> SYN-RECEIVED 1117 3. (??) <-- <-- SYN-RECEIVED 1119 4. --> --> (return to LISTEN!) 1121 5. LISTEN LISTEN 1123 Old Duplicate SYN Initiates a Reset on two Passive Sockets 1125 Figure 10 1127 A variety of other cases are possible, all of which are accounted for 1128 by the following rules for RST generation and processing. 1130 Reset Generation 1131 As a general rule, reset (RST) must be sent whenever a segment 1132 arrives which apparently is not intended for the current connection. 1133 A reset must not be sent if it is not clear that this is the case. 1135 There are three groups of states: 1137 1. If the connection does not exist (CLOSED) then a reset is sent 1138 in response to any incoming segment except another reset. In 1139 particular, SYNs addressed to a non-existent connection are 1140 rejected by this means. 1142 If the incoming segment has the ACK bit set, the reset takes its 1143 sequence number from the ACK field of the segment, otherwise the 1144 reset has sequence number zero and the ACK field is set to the sum 1145 of the sequence number and segment length of the incoming segment. 1146 The connection remains in the CLOSED state. 1148 2. If the connection is in any non-synchronized state (LISTEN, 1149 SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges 1150 something not yet sent (the segment carries an unacceptable ACK), 1151 or if an incoming segment has a security level or compartment 1152 which does not exactly match the level and compartment requested 1153 for the connection, a reset is sent. 1155 If our SYN has not been acknowledged and the precedence level of 1156 the incoming segment is higher than the precedence level requested 1157 then either raise the local precedence level (if allowed by the 1158 user and the system) or send a reset; or if the precedence level 1159 of the incoming segment is lower than the precedence level 1160 requested then continue as if the precedence matched exactly (if 1161 the remote TCP cannot raise the precedence level to match ours 1162 this will be detected in the next segment it sends, and the 1163 connection will be terminated then). If our SYN has been 1164 acknowledged (perhaps in this incoming segment) the precedence 1165 level of the incoming segment must match the local precedence 1166 level exactly, if it does not a reset must be sent. 1168 If the incoming segment has an ACK field, the reset takes its 1169 sequence number from the ACK field of the segment, otherwise the 1170 reset has sequence number zero and the ACK field is set to the sum 1171 of the sequence number and segment length of the incoming segment. 1172 The connection remains in the same state. 1174 3. If the connection is in a synchronized state (ESTABLISHED, 1175 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), 1176 any unacceptable segment (out of window sequence number or 1177 unacceptable acknowledgment number) must elicit only an empty 1178 acknowledgment segment containing the current send-sequence number 1179 and an acknowledgment indicating the next sequence number expected 1180 to be received, and the connection remains in the same state. 1182 If an incoming segment has a security level, or compartment, or 1183 precedence which does not exactly match the level, and 1184 compartment, and precedence requested for the connection,a reset 1185 is sent and the connection goes to the CLOSED state. The reset 1186 takes its sequence number from the ACK field of the incoming 1187 segment. 1189 Reset Processing 1191 In all states except SYN-SENT, all reset (RST) segments are validated 1192 by checking their SEQ-fields. A reset is valid if its sequence 1193 number is in the window. In the SYN-SENT state (a RST received in 1194 response to an initial SYN), the RST is acceptable if the ACK field 1195 acknowledges the SYN. 1197 The receiver of a RST first validates it, then changes state. If the 1198 receiver was in the LISTEN state, it ignores it. If the receiver was 1199 in SYN-RECEIVED state and had previously been in the LISTEN state, 1200 then the receiver returns to the LISTEN state, otherwise the receiver 1201 aborts the connection and goes to the CLOSED state. If the receiver 1202 was in any other state, it aborts the connection and advises the user 1203 and goes to the CLOSED state. 1205 3.5. Closing a Connection 1207 CLOSE is an operation meaning "I have no more data to send." The 1208 notion of closing a full-duplex connection is subject to ambiguous 1209 interpretation, of course, since it may not be obvious how to treat 1210 the receiving side of the connection. We have chosen to treat CLOSE 1211 in a simplex fashion. The user who CLOSEs may continue to RECEIVE 1212 until he is told that the other side has CLOSED also. Thus, a 1213 program could initiate several SENDs followed by a CLOSE, and then 1214 continue to RECEIVE until signaled that a RECEIVE failed because the 1215 other side has CLOSED. We assume that the TCP will signal a user, 1216 even if no RECEIVEs are outstanding, that the other side has closed, 1217 so the user can terminate his side gracefully. A TCP will reliably 1218 deliver all buffers SENT before the connection was CLOSED so a user 1219 who expects no data in return need only wait to hear the connection 1220 was CLOSED successfully to know that all his data was received at the 1221 destination TCP. Users must keep reading connections they close for 1222 sending until the TCP says no more data. 1224 There are essentially three cases: 1226 1) The user initiates by telling the TCP to CLOSE the connection 1227 2) The remote TCP initiates by sending a FIN control signal 1229 3) Both users CLOSE simultaneously 1231 Case 1: Local user initiates the close 1233 In this case, a FIN segment can be constructed and placed on the 1234 outgoing segment queue. No further SENDs from the user will be 1235 accepted by the TCP, and it enters the FIN-WAIT-1 state. RECEIVEs 1236 are allowed in this state. All segments preceding and including 1237 FIN will be retransmitted until acknowledged. When the other TCP 1238 has both acknowledged the FIN and sent a FIN of its own, the first 1239 TCP can ACK this FIN. Note that a TCP receiving a FIN will ACK 1240 but not send its own FIN until its user has CLOSED the connection 1241 also. 1243 Case 2: TCP receives a FIN from the network 1245 If an unsolicited FIN arrives from the network, the receiving TCP 1246 can ACK it and tell the user that the connection is closing. The 1247 user will respond with a CLOSE, upon which the TCP can send a FIN 1248 to the other TCP after sending any remaining data. The TCP then 1249 waits until its own FIN is acknowledged whereupon it deletes the 1250 connection. If an ACK is not forthcoming, after the user timeout 1251 the connection is aborted and the user is told. 1253 Case 3: both users close simultaneously 1255 A simultaneous CLOSE by users at both ends of a connection causes 1256 FIN segments to be exchanged. When all segments preceding the 1257 FINs have been processed and acknowledged, each TCP can ACK the 1258 FIN it has received. Both will, upon receiving these ACKs, delete 1259 the connection. 1261 TCP A TCP B 1263 1. ESTABLISHED ESTABLISHED 1265 2. (Close) 1266 FIN-WAIT-1 --> --> CLOSE-WAIT 1268 3. FIN-WAIT-2 <-- <-- CLOSE-WAIT 1270 4. (Close) 1271 TIME-WAIT <-- <-- LAST-ACK 1273 5. TIME-WAIT --> --> CLOSED 1275 6. (2 MSL) 1276 CLOSED 1278 Normal Close Sequence 1280 Figure 11 1282 TCP A TCP B 1284 1. ESTABLISHED ESTABLISHED 1286 2. (Close) (Close) 1287 FIN-WAIT-1 --> ... FIN-WAIT-1 1288 <-- <-- 1289 ... --> 1291 3. CLOSING --> ... CLOSING 1292 <-- <-- 1293 ... --> 1295 4. TIME-WAIT TIME-WAIT 1296 (2 MSL) (2 MSL) 1297 CLOSED CLOSED 1299 Simultaneous Close Sequence 1301 Figure 12 1303 3.6. Precedence and Security 1305 The intent is that connection be allowed only between ports operating 1306 with exactly the same security and compartment values and at the 1307 higher of the precedence level requested by the two ports. 1309 The precedence and security parameters used in TCP are exactly those 1310 defined in the Internet Protocol (IP) [2]. Throughout this TCP 1311 specification the term "security/compartment" is intended to indicate 1312 the security parameters used in IP including security, compartment, 1313 user group, and handling restriction. 1315 A connection attempt with mismatched security/compartment values or a 1316 lower precedence value must be rejected by sending a reset. 1317 Rejecting a connection due to too low a precedence only occurs after 1318 an acknowledgment of the SYN has been received. 1320 Note that TCP modules which operate only at the default value of 1321 precedence will still have to check the precedence of incoming 1322 segments and possibly raise the precedence level they use on the 1323 connection. 1325 The security parameters may be used even in a non-secure environment 1326 (the values would indicate unclassified data), thus hosts in non- 1327 secure environments must be prepared to receive the security 1328 parameters, though they need not send them. 1330 3.7. Data Communication 1332 Once the connection is established data is communicated by the 1333 exchange of segments. Because segments may be lost due to errors 1334 (checksum test failure), or network congestion, TCP uses 1335 retransmission (after a timeout) to ensure delivery of every segment. 1336 Duplicate segments may arrive due to network or TCP retransmission. 1337 As discussed in the section on sequence numbers the TCP performs 1338 certain tests on the sequence and acknowledgment numbers in the 1339 segments to verify their acceptability. 1341 The sender of data keeps track of the next sequence number to use in 1342 the variable SND.NXT. The receiver of data keeps track of the next 1343 sequence number to expect in the variable RCV.NXT. The sender of 1344 data keeps track of the oldest unacknowledged sequence number in the 1345 variable SND.UNA. If the data flow is momentarily idle and all data 1346 sent has been acknowledged then the three variables will be equal. 1348 When the sender creates a segment and transmits it the sender 1349 advances SND.NXT. When the receiver accepts a segment it advances 1350 RCV.NXT and sends an acknowledgment. When the data sender receives 1351 an acknowledgment it advances SND.UNA. The extent to which the 1352 values of these variables differ is a measure of the delay in the 1353 communication. The amount by which the variables are advanced is the 1354 length of the data and SYN or FIN flags in the segment. Note that 1355 once in the ESTABLISHED state all segments must carry current 1356 acknowledgment information. 1358 The CLOSE user call implies a push function, as does the FIN control 1359 flag in an incoming segment. 1361 Retransmission Timeout 1363 NOTE: TODO this needs to be updated in light of 1122 4.2.2.15 and 1364 errata 573; this will be done as part of RFC 1122 incorporation into 1365 this document. 1366 Because of the variability of the networks that compose an 1367 internetwork system and the wide range of uses of TCP connections the 1368 retransmission timeout must be dynamically determined. One procedure 1369 for determining a retransmission timeout is given here as an 1370 illustration. 1372 An Example Retransmission Timeout Procedure 1374 Measure the elapsed time between sending a data octet with a 1375 particular sequence number and receiving an acknowledgment that 1376 covers that sequence number (segments sent do not have to match 1377 segments received). This measured elapsed time is the Round Trip 1378 Time (RTT). Next compute a Smoothed Round Trip Time (SRTT) as: 1380 SRTT = ( ALPHA * SRTT ) + ((1-ALPHA) * RTT) 1382 and based on this, compute the retransmission timeout (RTO) as: 1384 RTO = min[UBOUND,max[LBOUND,(BETA*SRTT)]] 1386 where UBOUND is an upper bound on the timeout (e.g., 1 minute), 1387 LBOUND is a lower bound on the timeout (e.g., 1 second), ALPHA is 1388 a smoothing factor (e.g., .8 to .9), and BETA is a delay variance 1389 factor (e.g., 1.3 to 2.0). 1391 The Communication of Urgent Information 1393 As a result of implementation differences and middlebox interactions, 1394 new applications SHOULD NOT employ the TCP urgent mechanism. 1395 However, TCP implementations MUST still include support for the 1396 urgent mechanism. Details can be found in RFC 6093 [5]. 1398 The objective of the TCP urgent mechanism is to allow the sending 1399 user to stimulate the receiving user to accept some urgent data and 1400 to permit the receiving TCP to indicate to the receiving user when 1401 all the currently known urgent data has been received by the user. 1403 This mechanism permits a point in the data stream to be designated as 1404 the end of urgent information. Whenever this point is in advance of 1405 the receive sequence number (RCV.NXT) at the receiving TCP, that TCP 1406 must tell the user to go into "urgent mode"; when the receive 1407 sequence number catches up to the urgent pointer, the TCP must tell 1408 user to go into "normal mode". If the urgent pointer is updated 1409 while the user is in "urgent mode", the update will be invisible to 1410 the user. 1412 The method employs a urgent field which is carried in all segments 1413 transmitted. The URG control flag indicates that the urgent field is 1414 meaningful and must be added to the segment sequence number to yield 1415 the urgent pointer. The absence of this flag indicates that there is 1416 no urgent data outstanding. 1418 To send an urgent indication the user must also send at least one 1419 data octet. If the sending user also indicates a push, timely 1420 delivery of the urgent information to the destination process is 1421 enhanced. 1423 A TCP MUST support a sequence of urgent data of any length. [3] 1425 A TCP MUST inform the application layer asynchronously whenever it 1426 receives an Urgent pointer and there was previously no pending urgent 1427 data, or whenvever the Urgent pointer advances in the data stream. 1428 There MUST be a way for the application to learn how much urgent data 1429 remains to be read from the connection, or at least to determine 1430 whether or not more urgent data remains to be read. [3] 1432 Managing the Window 1434 The window sent in each segment indicates the range of sequence 1435 numbers the sender of the window (the data receiver) is currently 1436 prepared to accept. There is an assumption that this is related to 1437 the currently available data buffer space available for this 1438 connection. 1440 Indicating a large window encourages transmissions. If more data 1441 arrives than can be accepted, it will be discarded. This will result 1442 in excessive retransmissions, adding unnecessarily to the load on the 1443 network and the TCPs. Indicating a small window may restrict the 1444 transmission of data to the point of introducing a round trip delay 1445 between each new segment transmitted. 1447 The mechanisms provided allow a TCP to advertise a large window and 1448 to subsequently advertise a much smaller window without having 1449 accepted that much data. This, so called "shrinking the window," is 1450 strongly discouraged. The robustness principle dictates that TCPs 1451 will not shrink the window themselves, but will be prepared for such 1452 behavior on the part of other TCPs. 1454 The sending TCP must be prepared to accept from the user and send at 1455 least one octet of new data even if the send window is zero. The 1456 sending TCP must regularly retransmit to the receiving TCP even when 1457 the window is zero. Two minutes is recommended for the 1458 retransmission interval when the window is zero. This retransmission 1459 is essential to guarantee that when either TCP has a zero window the 1460 re-opening of the window will be reliably reported to the other. 1462 When the receiving TCP has a zero window and a segment arrives it 1463 must still send an acknowledgment showing its next expected sequence 1464 number and current window (zero). 1466 The sending TCP packages the data to be transmitted into segments 1467 which fit the current window, and may repackage segments on the 1468 retransmission queue. Such repackaging is not required, but may be 1469 helpful. 1471 In a connection with a one-way data flow, the window information will 1472 be carried in acknowledgment segments that all have the same sequence 1473 number so there will be no way to reorder them if they arrive out of 1474 order. This is not a serious problem, but it will allow the window 1475 information to be on occasion temporarily based on old reports from 1476 the data receiver. A refinement to avoid this problem is to act on 1477 the window information from segments that carry the highest 1478 acknowledgment number (that is segments with acknowledgment number 1479 equal or greater than the highest previously received). 1481 The window management procedure has significant influence on the 1482 communication performance. The following comments are suggestions to 1483 implementers. 1485 Window Management Suggestions 1487 Allocating a very small window causes data to be transmitted in 1488 many small segments when better performance is achieved using 1489 fewer large segments. 1491 One suggestion for avoiding small windows is for the receiver to 1492 defer updating a window until the additional allocation is at 1493 least X percent of the maximum allocation possible for the 1494 connection (where X might be 20 to 40). 1496 Another suggestion is for the sender to avoid sending small 1497 segments by waiting until the window is large enough before 1498 sending data. If the user signals a push function then the data 1499 must be sent even if it is a small segment. 1501 Note that the acknowledgments should not be delayed or unnecessary 1502 retransmissions will result. One strategy would be to send an 1503 acknowledgment when a small segment arrives (with out updating the 1504 window information), and then to send another acknowledgment with 1505 new window information when the window is larger. 1507 The segment sent to probe a zero window may also begin a break up 1508 of transmitted data into smaller and smaller segments. If a 1509 segment containing a single data octet sent to probe a zero window 1510 is accepted, it consumes one octet of the window now available. 1511 If the sending TCP simply sends as much as it can whenever the 1512 window is non zero, the transmitted data will be broken into 1513 alternating big and small segments. As time goes on, occasional 1514 pauses in the receiver making window allocation available will 1515 result in breaking the big segments into a small and not quite so 1516 big pair. And after a while the data transmission will be in 1517 mostly small segments. 1519 The suggestion here is that the TCP implementations need to 1520 actively attempt to combine small window allocations into larger 1521 windows, since the mechanisms for managing the window tend to lead 1522 to many small windows in the simplest minded implementations. 1524 3.8. Interfaces 1526 There are of course two interfaces of concern: the user/TCP interface 1527 and the TCP/lower-level interface. We have a fairly elaborate model 1528 of the user/TCP interface, but the interface to the lower level 1529 protocol module is left unspecified here, since it will be specified 1530 in detail by the specification of the lower level protocol. For the 1531 case that the lower level is IP we note some of the parameter values 1532 that TCPs might use. 1534 3.8.1. User/TCP Interface 1536 The following functional description of user commands to the TCP is, 1537 at best, fictional, since every operating system will have different 1538 facilities. Consequently, we must warn readers that different TCP 1539 implementations may have different user interfaces. However, all 1540 TCPs must provide a certain minimum set of services to guarantee that 1541 all TCP implementations can support the same protocol hierarchy. 1542 This section specifies the functional interfaces required of all TCP 1543 implementations. 1545 TCP User Commands 1547 The following sections functionally characterize a USER/TCP 1548 interface. The notation used is similar to most procedure or 1549 function calls in high level languages, but this usage is not 1550 meant to rule out trap type service calls (e.g., SVCs, UUOs, 1551 EMTs). 1553 The user commands described below specify the basic functions the 1554 TCP must perform to support interprocess communication. 1555 Individual implementations must define their own exact format, and 1556 may provide combinations or subsets of the basic functions in 1557 single calls. In particular, some implementations may wish to 1558 automatically OPEN a connection on the first SEND or RECEIVE 1559 issued by the user for a given connection. 1561 In providing interprocess communication facilities, the TCP must 1562 not only accept commands, but must also return information to the 1563 processes it serves. The latter consists of: 1565 (a) general information about a connection (e.g., interrupts, 1566 remote close, binding of unspecified foreign socket). 1568 (b) replies to specific user commands indicating success or 1569 various types of failure. 1571 Open 1573 Format: OPEN (local port, foreign socket, active/passive [, 1574 timeout] [, precedence] [, security/compartment] [, options]) 1575 -> local connection name 1577 We assume that the local TCP is aware of the identity of the 1578 processes it serves and will check the authority of the process 1579 to use the connection specified. Depending upon the 1580 implementation of the TCP, the local network and TCP 1581 identifiers for the source address will either be supplied by 1582 the TCP or the lower level protocol (e.g., IP). These 1583 considerations are the result of concern about security, to the 1584 extent that no TCP be able to masquerade as another one, and so 1585 on. Similarly, no process can masquerade as another without 1586 the collusion of the TCP. 1588 If the active/passive flag is set to passive, then this is a 1589 call to LISTEN for an incoming connection. A passive open may 1590 have either a fully specified foreign socket to wait for a 1591 particular connection or an unspecified foreign socket to wait 1592 for any call. A fully specified passive call can be made 1593 active by the subsequent execution of a SEND. 1595 A transmission control block (TCB) is created and partially 1596 filled in with data from the OPEN command parameters. 1598 On an active OPEN command, the TCP will begin the procedure to 1599 synchronize (i.e., establish) the connection at once. 1601 The timeout, if present, permits the caller to set up a timeout 1602 for all data submitted to TCP. If data is not successfully 1603 delivered to the destination within the timeout period, the TCP 1604 will abort the connection. The present global default is five 1605 minutes. 1607 The TCP or some component of the operating system will verify 1608 the users authority to open a connection with the specified 1609 precedence or security/compartment. The absence of precedence 1610 or security/compartment specification in the OPEN call 1611 indicates the default values must be used. 1613 TCP will accept incoming requests as matching only if the 1614 security/compartment information is exactly the same and only 1615 if the precedence is equal to or higher than the precedence 1616 requested in the OPEN call. 1618 The precedence for the connection is the higher of the values 1619 requested in the OPEN call and received from the incoming 1620 request, and fixed at that value for the life of the 1621 connection.Implementers may want to give the user control of 1622 this precedence negotiation. For example, the user might be 1623 allowed to specify that the precedence must be exactly matched, 1624 or that any attempt to raise the precedence be confirmed by the 1625 user. 1627 A local connection name will be returned to the user by the 1628 TCP. The local connection name can then be used as a short 1629 hand term for the connection defined by the pair. 1632 Send 1634 Format: SEND (local connection name, buffer address, byte 1635 count, PUSH flag, URGENT flag [,timeout]) 1637 This call causes the data contained in the indicated user 1638 buffer to be sent on the indicated connection. If the 1639 connection has not been opened, the SEND is considered an 1640 error. Some implementations may allow users to SEND first; in 1641 which case, an automatic OPEN would be done. If the calling 1642 process is not authorized to use this connection, an error is 1643 returned. 1645 If the PUSH flag is set, the data must be transmitted promptly 1646 to the receiver, and the PUSH bit will be set in the last TCP 1647 segment created from the buffer. If the PUSH flag is not set, 1648 the data may be combined with data from subsequent SENDs for 1649 transmission efficiency. 1651 New applications SHOULD NOT set the URGENT flag [5] due to 1652 implementation differences and middlebox issues. 1654 If the URGENT flag is set, segments sent to the destination TCP 1655 will have the urgent pointer set. The receiving TCP will 1656 signal the urgent condition to the receiving process if the 1657 urgent pointer indicates that data preceding the urgent pointer 1658 has not been consumed by the receiving process. The purpose of 1659 urgent is to stimulate the receiver to process the urgent data 1660 and to indicate to the receiver when all the currently known 1661 urgent data has been received. The number of times the sending 1662 user's TCP signals urgent will not necessarily be equal to the 1663 number of times the receiving user will be notified of the 1664 presence of urgent data. 1666 If no foreign socket was specified in the OPEN, but the 1667 connection is established (e.g., because a LISTENing connection 1668 has become specific due to a foreign segment arriving for the 1669 local socket), then the designated buffer is sent to the 1670 implied foreign socket. Users who make use of OPEN with an 1671 unspecified foreign socket can make use of SEND without ever 1672 explicitly knowing the foreign socket address. 1674 However, if a SEND is attempted before the foreign socket 1675 becomes specified, an error will be returned. Users can use 1676 the STATUS call to determine the status of the connection. In 1677 some implementations the TCP may notify the user when an 1678 unspecified socket is bound. 1680 If a timeout is specified, the current user timeout for this 1681 connection is changed to the new one. 1683 In the simplest implementation, SEND would not return control 1684 to the sending process until either the transmission was 1685 complete or the timeout had been exceeded. However, this 1686 simple method is both subject to deadlocks (for example, both 1687 sides of the connection might try to do SENDs before doing any 1688 RECEIVEs) and offers poor performance, so it is not 1689 recommended. A more sophisticated implementation would return 1690 immediately to allow the process to run concurrently with 1691 network I/O, and, furthermore, to allow multiple SENDs to be in 1692 progress. Multiple SENDs are served in first come, first 1693 served order, so the TCP will queue those it cannot service 1694 immediately. 1696 We have implicitly assumed an asynchronous user interface in 1697 which a SEND later elicits some kind of SIGNAL or pseudo- 1698 interrupt from the serving TCP. An alternative is to return a 1699 response immediately. For instance, SENDs might return 1700 immediate local acknowledgment, even if the segment sent had 1701 not been acknowledged by the distant TCP. We could 1702 optimistically assume eventual success. If we are wrong, the 1703 connection will close anyway due to the timeout. In 1704 implementations of this kind (synchronous), there will still be 1705 some asynchronous signals, but these will deal with the 1706 connection itself, and not with specific segments or buffers. 1708 In order for the process to distinguish among error or success 1709 indications for different SENDs, it might be appropriate for 1710 the buffer address to be returned along with the coded response 1711 to the SEND request. TCP-to-user signals are discussed below, 1712 indicating the information which should be returned to the 1713 calling process. 1715 Receive 1717 Format: RECEIVE (local connection name, buffer address, byte 1718 count) -> byte count, urgent flag, push flag 1720 This command allocates a receiving buffer associated with the 1721 specified connection. If no OPEN precedes this command or the 1722 calling process is not authorized to use this connection, an 1723 error is returned. 1725 In the simplest implementation, control would not return to the 1726 calling program until either the buffer was filled, or some 1727 error occurred, but this scheme is highly subject to deadlocks. 1728 A more sophisticated implementation would permit several 1729 RECEIVEs to be outstanding at once. These would be filled as 1730 segments arrive. This strategy permits increased throughput at 1731 the cost of a more elaborate scheme (possibly asynchronous) to 1732 notify the calling program that a PUSH has been seen or a 1733 buffer filled. 1735 If enough data arrive to fill the buffer before a PUSH is seen, 1736 the PUSH flag will not be set in the response to the RECEIVE. 1737 The buffer will be filled with as much data as it can hold. If 1738 a PUSH is seen before the buffer is filled the buffer will be 1739 returned partially filled and PUSH indicated. 1741 If there is urgent data the user will have been informed as 1742 soon as it arrived via a TCP-to-user signal. The receiving 1743 user should thus be in "urgent mode". If the URGENT flag is 1744 on, additional urgent data remains. If the URGENT flag is off, 1745 this call to RECEIVE has returned all the urgent data, and the 1746 user may now leave "urgent mode". Note that data following the 1747 urgent pointer (non-urgent data) cannot be delivered to the 1748 user in the same buffer with preceding urgent data unless the 1749 boundary is clearly marked for the user. 1751 To distinguish among several outstanding RECEIVEs and to take 1752 care of the case that a buffer is not completely filled, the 1753 return code is accompanied by both a buffer pointer and a byte 1754 count indicating the actual length of the data received. 1756 Alternative implementations of RECEIVE might have the TCP 1757 allocate buffer storage, or the TCP might share a ring buffer 1758 with the user. 1760 Close 1762 Format: CLOSE (local connection name) 1764 This command causes the connection specified to be closed. If 1765 the connection is not open or the calling process is not 1766 authorized to use this connection, an error is returned. 1767 Closing connections is intended to be a graceful operation in 1768 the sense that outstanding SENDs will be transmitted (and 1769 retransmitted), as flow control permits, until all have been 1770 serviced. Thus, it should be acceptable to make several SEND 1771 calls, followed by a CLOSE, and expect all the data to be sent 1772 to the destination. It should also be clear that users should 1773 continue to RECEIVE on CLOSING connections, since the other 1774 side may be trying to transmit the last of its data. Thus, 1775 CLOSE means "I have no more to send" but does not mean "I will 1776 not receive any more." It may happen (if the user level 1777 protocol is not well thought out) that the closing side is 1778 unable to get rid of all its data before timing out. In this 1779 event, CLOSE turns into ABORT, and the closing TCP gives up. 1781 The user may CLOSE the connection at any time on his own 1782 initiative, or in response to various prompts from the TCP 1783 (e.g., remote close executed, transmission timeout exceeded, 1784 destination inaccessible). 1786 Because closing a connection requires communication with the 1787 foreign TCP, connections may remain in the closing state for a 1788 short time. Attempts to reopen the connection before the TCP 1789 replies to the CLOSE command will result in error responses. 1791 Close also implies push function. 1793 Status 1795 Format: STATUS (local connection name) -> status data 1797 This is an implementation dependent user command and could be 1798 excluded without adverse effect. Information returned would 1799 typically come from the TCB associated with the connection. 1801 This command returns a data block containing the following 1802 information: 1804 local socket, 1805 foreign socket, 1806 local connection name, 1807 receive window, 1808 send window, 1809 connection state, 1810 number of buffers awaiting acknowledgment, 1811 number of buffers pending receipt, 1812 urgent state, 1813 precedence, 1814 security/compartment, 1815 and transmission timeout. 1817 Depending on the state of the connection, or on the 1818 implementation itself, some of this information may not be 1819 available or meaningful. If the calling process is not 1820 authorized to use this connection, an error is returned. This 1821 prevents unauthorized processes from gaining information about 1822 a connection. 1824 Abort 1826 Format: ABORT (local connection name) 1828 This command causes all pending SENDs and RECEIVES to be 1829 aborted, the TCB to be removed, and a special RESET message to 1830 be sent to the TCP on the other side of the connection. 1831 Depending on the implementation, users may receive abort 1832 indications for each outstanding SEND or RECEIVE, or may simply 1833 receive an ABORT-acknowledgment. 1835 TCP-to-User Messages 1836 It is assumed that the operating system environment provides a 1837 means for the TCP to asynchronously signal the user program. 1838 When the TCP does signal a user program, certain information is 1839 passed to the user. Often in the specification the information 1840 will be an error message. In other cases there will be 1841 information relating to the completion of processing a SEND or 1842 RECEIVE or other user call. 1844 The following information is provided: 1846 Local Connection Name Always 1847 Response String Always 1848 Buffer Address Send & Receive 1849 Byte count (counts bytes received) Receive 1850 Push flag Receive 1851 Urgent flag Receive 1853 3.8.2. TCP/Lower-Level Interface 1855 The TCP calls on a lower level protocol module to actually send and 1856 receive information over a network. One case is that of the ARPA 1857 internetwork system where the lower level module is the Internet 1858 Protocol (IP) [2]. 1860 If the lower level protocol is IP it provides arguments for a type of 1861 service and for a time to live. TCP uses the following settings for 1862 these parameters: 1864 Type of Service = Precedence: given by user, Delay: normal, 1865 Throughput: normal, Reliability: normal; or binary XXX00000, where 1866 XXX are the three bits determining precedence, e.g. 000 means 1867 routine precedence. 1869 Time to Live = one minute, or 00111100. 1871 Note that the assumed maximum segment lifetime is two minutes. 1872 Here we explicitly ask that a segment be destroyed if it cannot 1873 be delivered by the internet system within one minute. 1875 If the lower level is IP (or other protocol that provides this 1876 feature) and source routing is used, the interface must allow the 1877 route information to be communicated. This is especially important 1878 so that the source and destination addresses used in the TCP checksum 1879 be the originating source and ultimate destination. It is also 1880 important to preserve the return route to answer connection requests. 1882 Any lower level protocol will have to provide the source address, 1883 destination address, and protocol fields, and some way to determine 1884 the "TCP length", both to provide the functional equivalent service 1885 of IP and to be used in the TCP checksum. 1887 3.9. Event Processing 1889 The processing depicted in this section is an example of one possible 1890 implementation. Other implementations may have slightly different 1891 processing sequences, but they should differ from those in this 1892 section only in detail, not in substance. 1894 The activity of the TCP can be characterized as responding to events. 1895 The events that occur can be cast into three categories: user calls, 1896 arriving segments, and timeouts. This section describes the 1897 processing the TCP does in response to each of the events. In many 1898 cases the processing required depends on the state of the connection. 1900 Events that occur: 1902 User Calls 1904 OPEN 1905 SEND 1906 RECEIVE 1907 CLOSE 1908 ABORT 1909 STATUS 1911 Arriving Segments 1913 SEGMENT ARRIVES 1915 Timeouts 1917 USER TIMEOUT 1918 RETRANSMISSION TIMEOUT 1919 TIME-WAIT TIMEOUT 1921 The model of the TCP/user interface is that user commands receive an 1922 immediate return and possibly a delayed response via an event or 1923 pseudo interrupt. In the following descriptions, the term "signal" 1924 means cause a delayed response. 1926 Error responses are given as character strings. For example, user 1927 commands referencing connections that do not exist receive "error: 1928 connection not open". 1930 Please note in the following that all arithmetic on sequence numbers, 1931 acknowledgment numbers, windows, et cetera, is modulo 2**32 the size 1932 of the sequence number space. Also note that "=<" means less than or 1933 equal to (modulo 2**32). 1935 A natural way to think about processing incoming segments is to 1936 imagine that they are first tested for proper sequence number (i.e., 1937 that their contents lie in the range of the expected "receive window" 1938 in the sequence number space) and then that they are generally queued 1939 and processed in sequence number order. 1941 When a segment overlaps other already received segments we 1942 reconstruct the segment to contain just the new data, and adjust the 1943 header fields to be consistent. 1945 Note that if no state change is mentioned the TCP stays in the same 1946 state. 1948 OPEN Call 1950 CLOSED STATE (i.e., TCB does not exist) 1952 Create a new transmission control block (TCB) to hold 1953 connection state information. Fill in local socket identifier, 1954 foreign socket, precedence, security/compartment, and user 1955 timeout information. Note that some parts of the foreign 1956 socket may be unspecified in a passive OPEN and are to be 1957 filled in by the parameters of the incoming SYN segment. 1958 Verify the security and precedence requested are allowed for 1959 this user, if not return "error: precedence not allowed" or 1960 "error: security/compartment not allowed." If passive enter 1961 the LISTEN state and return. If active and the foreign socket 1962 is unspecified, return "error: foreign socket unspecified"; if 1963 active and the foreign socket is specified, issue a SYN 1964 segment. An initial send sequence number (ISS) is selected. A 1965 SYN segment of the form is sent. Set 1966 SND.UNA to ISS, SND.NXT to ISS+1, enter SYN-SENT state, and 1967 return. 1969 If the caller does not have access to the local socket 1970 specified, return "error: connection illegal for this process". 1971 If there is no room to create a new connection, return "error: 1972 insufficient resources". 1974 LISTEN STATE 1976 If active and the foreign socket is specified, then change the 1977 connection from passive to active, select an ISS. Send a SYN 1978 segment, set SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT 1979 state. Data associated with SEND may be sent with SYN segment 1980 or queued for transmission after entering ESTABLISHED state. 1981 The urgent bit if requested in the command must be sent with 1982 the data segments sent as a result of this command. If there 1983 is no room to queue the request, respond with "error: 1984 insufficient resources". If Foreign socket was not specified, 1985 then return "error: foreign socket unspecified". 1987 SYN-SENT STATE 1988 SYN-RECEIVED STATE 1989 ESTABLISHED STATE 1990 FIN-WAIT-1 STATE 1991 FIN-WAIT-2 STATE 1992 CLOSE-WAIT STATE 1993 CLOSING STATE 1994 LAST-ACK STATE 1995 TIME-WAIT STATE 1997 Return "error: connection already exists". 1999 SEND Call 2001 CLOSED STATE (i.e., TCB does not exist) 2003 If the user does not have access to such a connection, then 2004 return "error: connection illegal for this process". 2006 Otherwise, return "error: connection does not exist". 2008 LISTEN STATE 2010 If the foreign socket is specified, then change the connection 2011 from passive to active, select an ISS. Send a SYN segment, set 2012 SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT state. Data 2013 associated with SEND may be sent with SYN segment or queued for 2014 transmission after entering ESTABLISHED state. The urgent bit 2015 if requested in the command must be sent with the data segments 2016 sent as a result of this command. If there is no room to queue 2017 the request, respond with "error: insufficient resources". If 2018 Foreign socket was not specified, then return "error: foreign 2019 socket unspecified". 2021 SYN-SENT STATE 2022 SYN-RECEIVED STATE 2024 Queue the data for transmission after entering ESTABLISHED 2025 state. If no space to queue, respond with "error: insufficient 2026 resources". 2028 ESTABLISHED STATE 2029 CLOSE-WAIT STATE 2031 Segmentize the buffer and send it with a piggybacked 2032 acknowledgment (acknowledgment value = RCV.NXT). If there is 2033 insufficient space to remember this buffer, simply return 2034 "error: insufficient resources". 2036 If the urgent flag is set, then SND.UP <- SND.NXT and set the 2037 urgent pointer in the outgoing segments. 2039 FIN-WAIT-1 STATE 2040 FIN-WAIT-2 STATE 2041 CLOSING STATE 2042 LAST-ACK STATE 2043 TIME-WAIT STATE 2045 Return "error: connection closing" and do not service request. 2047 RECEIVE Call 2049 CLOSED STATE (i.e., TCB does not exist) 2051 If the user does not have access to such a connection, return 2052 "error: connection illegal for this process". 2054 Otherwise return "error: connection does not exist". 2056 LISTEN STATE 2057 SYN-SENT STATE 2058 SYN-RECEIVED STATE 2060 Queue for processing after entering ESTABLISHED state. If 2061 there is no room to queue this request, respond with "error: 2062 insufficient resources". 2064 ESTABLISHED STATE 2065 FIN-WAIT-1 STATE 2066 FIN-WAIT-2 STATE 2068 If insufficient incoming segments are queued to satisfy the 2069 request, queue the request. If there is no queue space to 2070 remember the RECEIVE, respond with "error: insufficient 2071 resources". 2073 Reassemble queued incoming segments into receive buffer and 2074 return to user. Mark "push seen" (PUSH) if this is the case. 2076 If RCV.UP is in advance of the data currently being passed to 2077 the user notify the user of the presence of urgent data. 2079 When the TCP takes responsibility for delivering data to the 2080 user that fact must be communicated to the sender via an 2081 acknowledgment. The formation of such an acknowledgment is 2082 described below in the discussion of processing an incoming 2083 segment. 2085 CLOSE-WAIT STATE 2087 Since the remote side has already sent FIN, RECEIVEs must be 2088 satisfied by text already on hand, but not yet delivered to the 2089 user. If no text is awaiting delivery, the RECEIVE will get a 2090 "error: connection closing" response. Otherwise, any remaining 2091 text can be used to satisfy the RECEIVE. 2093 CLOSING STATE 2094 LAST-ACK STATE 2095 TIME-WAIT STATE 2097 Return "error: connection closing". 2099 CLOSE Call 2101 CLOSED STATE (i.e., TCB does not exist) 2103 If the user does not have access to such a connection, return 2104 "error: connection illegal for this process". 2106 Otherwise, return "error: connection does not exist". 2108 LISTEN STATE 2110 Any outstanding RECEIVEs are returned with "error: closing" 2111 responses. Delete TCB, enter CLOSED state, and return. 2113 SYN-SENT STATE 2115 Delete the TCB and return "error: closing" responses to any 2116 queued SENDs, or RECEIVEs. 2118 SYN-RECEIVED STATE 2120 If no SENDs have been issued and there is no pending data to 2121 send, then form a FIN segment and send it, and enter FIN-WAIT-1 2122 state; otherwise queue for processing after entering 2123 ESTABLISHED state. 2125 ESTABLISHED STATE 2127 Queue this until all preceding SENDs have been segmentized, 2128 then form a FIN segment and send it. In any case, enter FIN- 2129 WAIT-1 state. 2131 FIN-WAIT-1 STATE 2132 FIN-WAIT-2 STATE 2134 Strictly speaking, this is an error and should receive a 2135 "error: connection closing" response. An "ok" response would 2136 be acceptable, too, as long as a second FIN is not emitted (the 2137 first FIN may be retransmitted though). 2139 CLOSE-WAIT STATE 2141 Queue this request until all preceding SENDs have been 2142 segmentized; then send a FIN segment, enter LAST-ACK state. 2144 CLOSING STATE 2145 LAST-ACK STATE 2146 TIME-WAIT STATE 2147 Respond with "error: connection closing". 2149 ABORT Call 2151 CLOSED STATE (i.e., TCB does not exist) 2153 If the user should not have access to such a connection, return 2154 "error: connection illegal for this process". 2156 Otherwise return "error: connection does not exist". 2158 LISTEN STATE 2160 Any outstanding RECEIVEs should be returned with "error: 2161 connection reset" responses. Delete TCB, enter CLOSED state, 2162 and return. 2164 SYN-SENT STATE 2166 All queued SENDs and RECEIVEs should be given "connection 2167 reset" notification, delete the TCB, enter CLOSED state, and 2168 return. 2170 SYN-RECEIVED STATE 2171 ESTABLISHED STATE 2172 FIN-WAIT-1 STATE 2173 FIN-WAIT-2 STATE 2174 CLOSE-WAIT STATE 2176 Send a reset segment: 2178 2180 All queued SENDs and RECEIVEs should be given "connection 2181 reset" notification; all segments queued for transmission 2182 (except for the RST formed above) or retransmission should be 2183 flushed, delete the TCB, enter CLOSED state, and return. 2185 CLOSING STATE LAST-ACK STATE TIME-WAIT STATE 2187 Respond with "ok" and delete the TCB, enter CLOSED state, and 2188 return. 2190 STATUS Call 2192 CLOSED STATE (i.e., TCB does not exist) 2194 If the user should not have access to such a connection, return 2195 "error: connection illegal for this process". 2197 Otherwise return "error: connection does not exist". 2199 LISTEN STATE 2201 Return "state = LISTEN", and the TCB pointer. 2203 SYN-SENT STATE 2205 Return "state = SYN-SENT", and the TCB pointer. 2207 SYN-RECEIVED STATE 2209 Return "state = SYN-RECEIVED", and the TCB pointer. 2211 ESTABLISHED STATE 2213 Return "state = ESTABLISHED", and the TCB pointer. 2215 FIN-WAIT-1 STATE 2217 Return "state = FIN-WAIT-1", and the TCB pointer. 2219 FIN-WAIT-2 STATE 2221 Return "state = FIN-WAIT-2", and the TCB pointer. 2223 CLOSE-WAIT STATE 2225 Return "state = CLOSE-WAIT", and the TCB pointer. 2227 CLOSING STATE 2229 Return "state = CLOSING", and the TCB pointer. 2231 LAST-ACK STATE 2233 Return "state = LAST-ACK", and the TCB pointer. 2235 TIME-WAIT STATE 2237 Return "state = TIME-WAIT", and the TCB pointer. 2239 SEGMENT ARRIVES 2241 If the state is CLOSED (i.e., TCB does not exist) then 2243 all data in the incoming segment is discarded. An incoming 2244 segment containing a RST is discarded. An incoming segment not 2245 containing a RST causes a RST to be sent in response. The 2246 acknowledgment and sequence field values are selected to make 2247 the reset sequence acceptable to the TCP that sent the 2248 offending segment. 2250 If the ACK bit is off, sequence number zero is used, 2252 2254 If the ACK bit is on, 2256 2258 Return. 2260 If the state is LISTEN then 2262 first check for an RST 2264 An incoming RST should be ignored. Return. 2266 second check for an ACK 2268 Any acknowledgment is bad if it arrives on a connection 2269 still in the LISTEN state. An acceptable reset segment 2270 should be formed for any arriving ACK-bearing segment. The 2271 RST should be formatted as follows: 2273 2275 Return. 2277 third check for a SYN 2279 If the SYN bit is set, check the security. If the security/ 2280 compartment on the incoming segment does not exactly match 2281 the security/compartment in the TCB then send a reset and 2282 return. 2284 2286 If the SEG.PRC is greater than the TCB.PRC then if allowed 2287 by the user and the system set TCB.PRC<-SEG.PRC, if not 2288 allowed send a reset and return. 2290 2292 If the SEG.PRC is less than the TCB.PRC then continue. 2294 Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any 2295 other control or text should be queued for processing later. 2296 ISS should be selected and a SYN segment sent of the form: 2298 2300 SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 2301 state should be changed to SYN-RECEIVED. Note that any 2302 other incoming control or data (combined with SYN) will be 2303 processed in the SYN-RECEIVED state, but processing of SYN 2304 and ACK should not be repeated. If the listen was not fully 2305 specified (i.e., the foreign socket was not fully 2306 specified), then the unspecified fields should be filled in 2307 now. 2309 fourth other text or control 2311 Any other control or text-bearing segment (not containing 2312 SYN) must have an ACK and thus would be discarded by the ACK 2313 processing. An incoming RST segment could not be valid, 2314 since it could not have been sent in response to anything 2315 sent by this incarnation of the connection. So you are 2316 unlikely to get here, but if you do, drop the segment, and 2317 return. 2319 If the state is SYN-SENT then 2321 first check the ACK bit 2323 If the ACK bit is set 2325 If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset 2326 (unless the RST bit is set, if so drop the segment and 2327 return) 2329 2331 and discard the segment. Return. 2333 If SND.UNA < SEG.ACK =< SND.NXT then the ACK is 2334 acceptable. (TODO: in processing Errata ID 3300, it was 2335 noted that some stacks in the wild that do not send data 2336 on the SYN are just checking that SEG.ACK == SND.NXT ... 2337 think about whether anything should be said about that 2338 here) 2340 second check the RST bit 2342 If the RST bit is set 2344 If the ACK was acceptable then signal the user "error: 2345 connection reset", drop the segment, enter CLOSED state, 2346 delete TCB, and return. Otherwise (no ACK) drop the 2347 segment and return. 2349 third check the security and precedence 2351 If the security/compartment in the segment does not exactly 2352 match the security/compartment in the TCB, send a reset 2354 If there is an ACK 2356 2358 Otherwise 2360 2362 If there is an ACK 2364 The precedence in the segment must match the precedence 2365 in the TCB, if not, send a reset 2367 2369 If there is no ACK 2371 If the precedence in the segment is higher than the 2372 precedence in the TCB then if allowed by the user and the 2373 system raise the precedence in the TCB to that in the 2374 segment, if not allowed to raise the prec then send a 2375 reset. 2377 2379 If the precedence in the segment is lower than the 2380 precedence in the TCB continue. 2382 If a reset was sent, discard the segment and return. 2384 fourth check the SYN bit 2386 This step should be reached only if the ACK is ok, or there 2387 is no ACK, and it the segment did not contain a RST. 2389 If the SYN bit is on and the security/compartment and 2390 precedence are acceptable then, RCV.NXT is set to SEG.SEQ+1, 2391 IRS is set to SEG.SEQ. SND.UNA should be advanced to equal 2392 SEG.ACK (if there is an ACK), and any segments on the 2393 retransmission queue which are thereby acknowledged should 2394 be removed. 2396 If SND.UNA > ISS (our SYN has been ACKed), change the 2397 connection state to ESTABLISHED, form an ACK segment 2399 2401 and send it. Data or controls which were queued for 2402 transmission may be included. If there are other controls 2403 or text in the segment then continue processing at the sixth 2404 step below where the URG bit is checked, otherwise return. 2406 Otherwise enter SYN-RECEIVED, form a SYN,ACK segment 2408 2410 and send it. Set the variables: 2412 SND.WND <- SEG.WND 2413 SND.WL1 <- SEG.SEQ 2414 SND.WL2 <- SEG.ACK 2416 If there are other controls or text in the segment, queue 2417 them for processing after the ESTABLISHED state has been 2418 reached, return. 2420 fifth, if neither of the SYN or RST bits is set then drop the 2421 segment and return. 2423 Otherwise, 2425 first check sequence number 2427 SYN-RECEIVED STATE 2428 ESTABLISHED STATE 2429 FIN-WAIT-1 STATE 2430 FIN-WAIT-2 STATE 2431 CLOSE-WAIT STATE 2432 CLOSING STATE 2433 LAST-ACK STATE 2434 TIME-WAIT STATE 2436 Segments are processed in sequence. Initial tests on 2437 arrival are used to discard old duplicates, but further 2438 processing is done in SEG.SEQ order. If a segment's 2439 contents straddle the boundary between old and new, only the 2440 new parts should be processed. 2442 There are four cases for the acceptability test for an 2443 incoming segment: 2445 Segment Receive Test 2446 Length Window 2447 ------- ------- ------------------------------------------- 2449 0 0 SEG.SEQ = RCV.NXT 2451 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 2453 >0 0 not acceptable 2455 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 2456 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 2458 If the RCV.WND is zero, no segments will be acceptable, but 2459 special allowance should be made to accept valid ACKs, URGs 2460 and RSTs. 2462 If an incoming segment is not acceptable, an acknowledgment 2463 should be sent in reply (unless the RST bit is set, if so 2464 drop the segment and return): 2466 2468 After sending the acknowledgment, drop the unacceptable 2469 segment and return. 2471 In the following it is assumed that the segment is the 2472 idealized segment that begins at RCV.NXT and does not exceed 2473 the window. One could tailor actual segments to fit this 2474 assumption by trimming off any portions that lie outside the 2475 window (including SYN and FIN), and only processing further 2476 if the segment then begins at RCV.NXT. Segments with higher 2477 beginning sequence numbers should be held for later 2478 processing. 2480 second check the RST bit, 2482 SYN-RECEIVED STATE 2484 If the RST bit is set 2486 If this connection was initiated with a passive OPEN 2487 (i.e., came from the LISTEN state), then return this 2488 connection to LISTEN state and return. The user need 2489 not be informed. If this connection was initiated 2490 with an active OPEN (i.e., came from SYN-SENT state) 2491 then the connection was refused, signal the user 2492 "connection refused". In either case, all segments on 2493 the retransmission queue should be removed. And in 2494 the active OPEN case, enter the CLOSED state and 2495 delete the TCB, and return. 2497 ESTABLISHED 2498 FIN-WAIT-1 2499 FIN-WAIT-2 2500 CLOSE-WAIT 2502 If the RST bit is set then, any outstanding RECEIVEs and 2503 SEND should receive "reset" responses. All segment 2504 queues should be flushed. Users should also receive an 2505 unsolicited general "connection reset" signal. Enter the 2506 CLOSED state, delete the TCB, and return. 2508 CLOSING STATE 2509 LAST-ACK STATE 2510 TIME-WAIT 2512 If the RST bit is set then, enter the CLOSED state, 2513 delete the TCB, and return. 2515 third check security and precedence 2517 SYN-RECEIVED 2519 If the security/compartment and precedence in the segment 2520 do not exactly match the security/compartment and 2521 precedence in the TCB then send a reset, and return. 2523 ESTABLISHED 2524 FIN-WAIT-1 2525 FIN-WAIT-2 2526 CLOSE-WAIT 2527 CLOSING 2528 LAST-ACK 2529 TIME-WAIT 2531 If the security/compartment and precedence in the segment 2532 do not exactly match the security/compartment and 2533 precedence in the TCB then send a reset, any outstanding 2534 RECEIVEs and SEND should receive "reset" responses. All 2535 segment queues should be flushed. Users should also 2536 receive an unsolicited general "connection reset" signal. 2537 Enter the CLOSED state, delete the TCB, and return. 2539 Note this check is placed following the sequence check to 2540 prevent a segment from an old connection between these ports 2541 with a different security or precedence from causing an 2542 abort of the current connection. 2544 fourth, check the SYN bit, 2546 SYN-RECEIVED 2547 ESTABLISHED STATE 2548 FIN-WAIT STATE-1 2549 FIN-WAIT STATE-2 2550 CLOSE-WAIT STATE 2551 CLOSING STATE 2552 LAST-ACK STATE 2553 TIME-WAIT STATE 2555 TODO: need to incorporate RFC 1122 4.2.2.20(e) here 2557 If the SYN is in the window it is an error, send a reset, 2558 any outstanding RECEIVEs and SEND should receive "reset" 2559 responses, all segment queues should be flushed, the user 2560 should also receive an unsolicited general "connection 2561 reset" signal, enter the CLOSED state, delete the TCB, 2562 and return. 2564 If the SYN is not in the window this step would not be 2565 reached and an ack would have been sent in the first step 2566 (sequence number check). 2568 fifth check the ACK field, 2570 if the ACK bit is off drop the segment and return 2571 if the ACK bit is on 2573 SYN-RECEIVED STATE 2575 If SND.UNA < SEG.ACK =< SND.NXT then enter ESTABLISHED 2576 state and continue processing with variables below set 2577 to: 2579 SND.WND <- SEG.WND 2580 SND.WL1 <- SEG.SEQ 2581 SND.WL2 <- SEG.ACK 2583 If the segment acknowledgment is not acceptable, 2584 form a reset segment, 2586 2588 and send it. 2590 ESTABLISHED STATE 2592 If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- 2593 SEG.ACK. Any segments on the retransmission queue 2594 which are thereby entirely acknowledged are removed. 2595 Users should receive positive acknowledgments for 2596 buffers which have been SENT and fully acknowledged 2597 (i.e., SEND buffer should be returned with "ok" 2598 response). If the ACK is a duplicate (SEG.ACK =< 2599 SND.UNA), it can be ignored. If the ACK acks 2600 something not yet sent (SEG.ACK > SND.NXT) then send 2601 an ACK, drop the segment, and return. 2603 If SND.UNA =< SEG.ACK =< SND.NXT, the send window 2604 should be updated. If (SND.WL1 < SEG.SEQ or (SND.WL1 2605 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- 2606 SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- 2607 SEG.ACK. 2609 Note that SND.WND is an offset from SND.UNA, that 2610 SND.WL1 records the sequence number of the last 2611 segment used to update SND.WND, and that SND.WL2 2612 records the acknowledgment number of the last segment 2613 used to update SND.WND. The check here prevents using 2614 old segments to update the window. 2616 FIN-WAIT-1 STATE 2617 In addition to the processing for the ESTABLISHED 2618 state, if our FIN is now acknowledged then enter FIN- 2619 WAIT-2 and continue processing in that state. 2621 FIN-WAIT-2 STATE 2623 In addition to the processing for the ESTABLISHED 2624 state, if the retransmission queue is empty, the 2625 user's CLOSE can be acknowledged ("ok") but do not 2626 delete the TCB. 2628 CLOSE-WAIT STATE 2630 Do the same processing as for the ESTABLISHED state. 2632 CLOSING STATE 2634 In addition to the processing for the ESTABLISHED 2635 state, if the ACK acknowledges our FIN then enter the 2636 TIME-WAIT state, otherwise ignore the segment. 2638 LAST-ACK STATE 2640 The only thing that can arrive in this state is an 2641 acknowledgment of our FIN. If our FIN is now 2642 acknowledged, delete the TCB, enter the CLOSED state, 2643 and return. 2645 TIME-WAIT STATE 2647 The only thing that can arrive in this state is a 2648 retransmission of the remote FIN. Acknowledge it, and 2649 restart the 2 MSL timeout. 2651 sixth, check the URG bit, 2653 ESTABLISHED STATE 2654 FIN-WAIT-1 STATE 2655 FIN-WAIT-2 STATE 2657 If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and 2658 signal the user that the remote side has urgent data if 2659 the urgent pointer (RCV.UP) is in advance of the data 2660 consumed. If the user has already been signaled (or is 2661 still in the "urgent mode") for this continuous sequence 2662 of urgent data, do not signal the user again. 2664 CLOSE-WAIT STATE 2665 CLOSING STATE 2666 LAST-ACK STATE 2667 TIME-WAIT 2669 This should not occur, since a FIN has been received from 2670 the remote side. Ignore the URG. 2672 seventh, process the segment text, 2674 ESTABLISHED STATE 2675 FIN-WAIT-1 STATE 2676 FIN-WAIT-2 STATE 2678 Once in the ESTABLISHED state, it is possible to deliver 2679 segment text to user RECEIVE buffers. Text from segments 2680 can be moved into buffers until either the buffer is full 2681 or the segment is empty. If the segment empties and 2682 carries an PUSH flag, then the user is informed, when the 2683 buffer is returned, that a PUSH has been received. 2685 When the TCP takes responsibility for delivering the data 2686 to the user it must also acknowledge the receipt of the 2687 data. 2689 Once the TCP takes responsibility for the data it 2690 advances RCV.NXT over the data accepted, and adjusts 2691 RCV.WND as appropriate to the current buffer 2692 availability. The total of RCV.NXT and RCV.WND should 2693 not be reduced. 2695 Please note the window management suggestions in section 2696 3.7. 2698 Send an acknowledgment of the form: 2700 2702 This acknowledgment should be piggybacked on a segment 2703 being transmitted if possible without incurring undue 2704 delay. 2706 CLOSE-WAIT STATE 2707 CLOSING STATE 2708 LAST-ACK STATE 2709 TIME-WAIT STATE 2711 This should not occur, since a FIN has been received from 2712 the remote side. Ignore the segment text. 2714 eighth, check the FIN bit, 2716 Do not process the FIN if the state is CLOSED, LISTEN or 2717 SYN-SENT since the SEG.SEQ cannot be validated; drop the 2718 segment and return. 2720 If the FIN bit is set, signal the user "connection closing" 2721 and return any pending RECEIVEs with same message, advance 2722 RCV.NXT over the FIN, and send an acknowledgment for the 2723 FIN. Note that FIN implies PUSH for any segment text not 2724 yet delivered to the user. 2726 SYN-RECEIVED STATE 2727 ESTABLISHED STATE 2729 Enter the CLOSE-WAIT state. 2731 FIN-WAIT-1 STATE 2733 If our FIN has been ACKed (perhaps in this segment), 2734 then enter TIME-WAIT, start the time-wait timer, turn 2735 off the other timers; otherwise enter the CLOSING 2736 state. 2738 FIN-WAIT-2 STATE 2740 Enter the TIME-WAIT state. Start the time-wait timer, 2741 turn off the other timers. 2743 CLOSE-WAIT STATE 2745 Remain in the CLOSE-WAIT state. 2747 CLOSING STATE 2749 Remain in the CLOSING state. 2751 LAST-ACK STATE 2753 Remain in the LAST-ACK state. 2755 TIME-WAIT STATE 2757 Remain in the TIME-WAIT state. Restart the 2 MSL 2758 time-wait timeout. 2760 and return. 2762 USER TIMEOUT 2764 USER TIMEOUT 2766 For any state if the user timeout expires, flush all queues, 2767 signal the user "error: connection aborted due to user timeout" 2768 in general and for any outstanding calls, delete the TCB, enter 2769 the CLOSED state and return. 2771 RETRANSMISSION TIMEOUT 2773 For any state if the retransmission timeout expires on a 2774 segment in the retransmission queue, send the segment at the 2775 front of the retransmission queue again, reinitialize the 2776 retransmission timer, and return. 2778 TIME-WAIT TIMEOUT 2780 If the time-wait timeout expires on a connection delete the 2781 TCB, enter the CLOSED state and return. 2783 3.10. Glossary 2785 1822 BBN Report 1822, "The Specification of the Interconnection of 2786 a Host and an IMP". The specification of interface between a 2787 host and the ARPANET. 2789 ACK 2790 A control bit (acknowledge) occupying no sequence space, 2791 which indicates that the acknowledgment field of this segment 2792 specifies the next sequence number the sender of this segment 2793 is expecting to receive, hence acknowledging receipt of all 2794 previous sequence numbers. 2796 ARPANET message 2797 The unit of transmission between a host and an IMP in the 2798 ARPANET. The maximum size is about 1012 octets (8096 bits). 2800 ARPANET packet 2801 A unit of transmission used internally in the ARPANET between 2802 IMPs. The maximum size is about 126 octets (1008 bits). 2804 connection 2805 A logical communication path identified by a pair of sockets. 2807 datagram 2808 A message sent in a packet switched computer communications 2809 network. 2811 Destination Address 2812 The destination address, usually the network and host 2813 identifiers. 2815 FIN 2816 A control bit (finis) occupying one sequence number, which 2817 indicates that the sender will send no more data or control 2818 occupying sequence space. 2820 fragment 2821 A portion of a logical unit of data, in particular an 2822 internet fragment is a portion of an internet datagram. 2824 FTP 2825 A file transfer protocol. 2827 header 2828 Control information at the beginning of a message, segment, 2829 fragment, packet or block of data. 2831 host 2832 A computer. In particular a source or destination of 2833 messages from the point of view of the communication network. 2835 Identification 2836 An Internet Protocol field. This identifying value assigned 2837 by the sender aids in assembling the fragments of a datagram. 2839 IMP 2840 The Interface Message Processor, the packet switch of the 2841 ARPANET. 2843 internet address 2844 A source or destination address specific to the host level. 2846 internet datagram 2847 The unit of data exchanged between an internet module and the 2848 higher level protocol together with the internet header. 2850 internet fragment 2851 A portion of the data of an internet datagram with an 2852 internet header. 2854 IP 2855 Internet Protocol. 2857 IRS 2858 The Initial Receive Sequence number. The first sequence 2859 number used by the sender on a connection. 2861 ISN 2862 The Initial Sequence Number. The first sequence number used 2863 on a connection, (either ISS or IRS). Selected in a way that 2864 is unique within a given period of time and is unpredictable 2865 to attackers. 2867 ISS 2868 The Initial Send Sequence number. The first sequence number 2869 used by the sender on a connection. 2871 leader 2872 Control information at the beginning of a message or block of 2873 data. In particular, in the ARPANET, the control information 2874 on an ARPANET message at the host-IMP interface. 2876 left sequence 2877 This is the next sequence number to be acknowledged by the 2878 data receiving TCP (or the lowest currently unacknowledged 2879 sequence number) and is sometimes referred to as the left 2880 edge of the send window. 2882 local packet 2883 The unit of transmission within a local network. 2885 module 2886 An implementation, usually in software, of a protocol or 2887 other procedure. 2889 MSL 2890 Maximum Segment Lifetime, the time a TCP segment can exist in 2891 the internetwork system. Arbitrarily defined to be 2 2892 minutes. 2894 octet 2895 An eight bit byte. 2897 Options 2898 An Option field may contain several options, and each option 2899 may be several octets in length. The options are used 2900 primarily in testing situations; for example, to carry 2901 timestamps. Both the Internet Protocol and TCP provide for 2902 options fields. 2904 packet 2905 A package of data with a header which may or may not be 2906 logically complete. More often a physical packaging than a 2907 logical packaging of data. 2909 port 2910 The portion of a socket that specifies which logical input or 2911 output channel of a process is associated with the data. 2913 process 2914 A program in execution. A source or destination of data from 2915 the point of view of the TCP or other host-to-host protocol. 2917 PUSH 2918 A control bit occupying no sequence space, indicating that 2919 this segment contains data that must be pushed through to the 2920 receiving user. 2922 RCV.NXT 2923 receive next sequence number 2925 RCV.UP 2926 receive urgent pointer 2928 RCV.WND 2929 receive window 2931 receive next sequence number 2932 This is the next sequence number the local TCP is expecting 2933 to receive. 2935 receive window 2936 This represents the sequence numbers the local (receiving) 2937 TCP is willing to receive. Thus, the local TCP considers 2938 that segments overlapping the range RCV.NXT to RCV.NXT + 2939 RCV.WND - 1 carry acceptable data or control. Segments 2940 containing sequence numbers entirely outside of this range 2941 are considered duplicates and discarded. 2943 RST 2944 A control bit (reset), occupying no sequence space, 2945 indicating that the receiver should delete the connection 2946 without further interaction. The receiver can determine, 2947 based on the sequence number and acknowledgment fields of the 2948 incoming segment, whether it should honor the reset command 2949 or ignore it. In no case does receipt of a segment 2950 containing RST give rise to a RST in response. 2952 RTP 2953 Real Time Protocol: A host-to-host protocol for communication 2954 of time critical information. 2956 SEG.ACK 2957 segment acknowledgment 2959 SEG.LEN 2960 segment length 2962 SEG.PRC 2963 segment precedence value 2965 SEG.SEQ 2966 segment sequence 2968 SEG.UP 2969 segment urgent pointer field 2971 SEG.WND 2972 segment window field 2974 segment 2975 A logical unit of data, in particular a TCP segment is the 2976 unit of data transfered between a pair of TCP modules. 2978 segment acknowledgment 2979 The sequence number in the acknowledgment field of the 2980 arriving segment. 2982 segment length 2983 The amount of sequence number space occupied by a segment, 2984 including any controls which occupy sequence space. 2986 segment sequence 2987 The number in the sequence field of the arriving segment. 2989 send sequence 2990 This is the next sequence number the local (sending) TCP will 2991 use on the connection. It is initially selected from an 2992 initial sequence number curve (ISN) and is incremented for 2993 each octet of data or sequenced control transmitted. 2995 send window 2996 This represents the sequence numbers which the remote 2997 (receiving) TCP is willing to receive. It is the value of 2998 the window field specified in segments from the remote (data 2999 receiving) TCP. The range of new sequence numbers which may 3000 be emitted by a TCP lies between SND.NXT and SND.UNA + 3001 SND.WND - 1. (Retransmissions of sequence numbers between 3002 SND.UNA and SND.NXT are expected, of course.) 3004 SND.NXT 3005 send sequence 3007 SND.UNA 3008 left sequence 3010 SND.UP 3011 send urgent pointer 3013 SND.WL1 3014 segment sequence number at last window update 3016 SND.WL2 3017 segment acknowledgment number at last window update 3019 SND.WND 3020 send window 3022 socket 3023 An address which specifically includes a port identifier, 3024 that is, the concatenation of an Internet Address with a TCP 3025 port. 3027 Source Address 3028 The source address, usually the network and host identifiers. 3030 SYN 3031 A control bit in the incoming segment, occupying one sequence 3032 number, used at the initiation of a connection, to indicate 3033 where the sequence numbering will start. 3035 TCB 3036 Transmission control block, the data structure that records 3037 the state of a connection. 3039 TCB.PRC 3040 The precedence of the connection. 3042 TCP 3043 Transmission Control Protocol: A host-to-host protocol for 3044 reliable communication in internetwork environments. 3046 TOS 3047 Type of Service, an Internet Protocol field. 3049 Type of Service 3050 An Internet Protocol field which indicates the type of 3051 service for this internet fragment. 3053 URG 3054 A control bit (urgent), occupying no sequence space, used to 3055 indicate that the receiving user should be notified to do 3056 urgent processing as long as there is data to be consumed 3057 with sequence numbers less than the value indicated in the 3058 urgent pointer. 3060 urgent pointer 3061 A control field meaningful only when the URG bit is on. This 3062 field communicates the value of the urgent pointer which 3063 indicates the data octet associated with the sending user's 3064 urgent call. 3066 4. Changes from RFC 793 3068 This document obsoletes RFC 793 as well as RFC 6093 and 6528, which 3069 updated 793. In all cases, only the normative protocol specification 3070 and requirements have been incorporated into this document, and the 3071 informational text with background and rationale has not been carried 3072 in. The informational content of those documents is still valuable 3073 in learning about and understanding TCP, and they are valid 3074 Informational references, even though their normative content has 3075 been incorporated into this document. 3077 The main body of this document was adapted from RFC 793's Section 3, 3078 titled "FUNCTIONAL SPECIFICATION", with an attempt to keep formatting 3079 and layout as close as possible. 3081 The collection of applicable RFC Errata that have been reported and 3082 either accepted or held for an update to RFC 793 were incorporated 3083 (Errata IDs: 573, 574, 700, 701, 1283, 1561, 1562, 1564, 1565, 1571, 3084 1572, 2296, 2297, 2298, 2748, 2749, 2934, 3213, 3300, 3301). Some 3085 errata were not applicable due to other changes (Errata IDs: 572, 3086 575, 1569, 3602). TODO: 3305 3088 Changes to the specification of the Urgent Pointer described in RFC 3089 1122 and 6093 were incorporated. See RFC 6093 for detailed 3090 discussion of why these changes were necessary. 3092 The more secure Initial Sequence Number generation algorithm from RFC 3093 6528 was incorporated. See RFC 6528 for discussion of the attacks 3094 that this mitigates, as well as advice on selecting PRF algorithms 3095 and managing secret key data. 3097 RFC EDITOR'S NOTE: the content below is for detailed change tracking 3098 and planning, and not to be included with the final revision of the 3099 document. 3101 The -00 revision of this document was merely a proposal and rough 3102 plan for updating RFC 793. 3104 The -01 revision of this document incorporates the content of RFC 793 3105 Section 3 titled "FUNCTIONAL SPECIFICATION". Other content from RFC 3106 793 has not been incorporated. The -01 revision of this document 3107 makes some minor formatting changes to the RFC 793 content in order 3108 to convert the content into XML2RFC format and account for left-out 3109 parts of RFC 793. For instance, figure numbering differs and some 3110 indentation is not exactly the same. 3112 The -02 revision of this document incorporates errata that have been 3113 verified: 3115 Errata ID 573: Reported by Bob Braden (note: This errata basically 3116 is just a reminder that RFC 1122 updates 793. Some of the 3117 associated changes are left pending to a separate revision that 3118 incorporates 1122. Bob's mention of PUSH in 793 section 2.8 was 3119 not applicable here because that section was not part of the 3120 "functional specification". Also the 1122 text on the 3121 retransmission timeout also has been updated by subsequent RFCs, 3122 so the change here deviates from Bob's suggestion to apply the 3123 1122 text.) 3124 Errata ID 574: Reported by Yin Shuming 3125 Errata ID 700: Reported by Yin Shuming 3126 Errata ID 701: Reported by Yin Shuming 3127 Errata ID 1283: Reported by Pei-chun Cheng 3128 Errata ID 1561: Reported by Constantin Hagemeier 3129 Errata ID 1562: Reported by Constantin Hagemeier 3130 Errata ID 1564: Reported by Constantin Hagemeier 3131 Errata ID 1565: Reported by Constantin Hagemeier 3132 Errata ID 1571: Reported by Constantin Hagemeier 3133 Errata ID 1572: Reported by Constantin Hagemeier 3134 Errata ID 2296: Reported by Vishwas Manral 3135 Errata ID 2297: Reported by Vishwas Manral 3136 Errata ID 2298: Reported by Vishwas Manral 3137 Errata ID 2748: Reported by Mykyta Yevstifeyev 3138 Errata ID 2749: Reported by Mykyta Yevstifeyev 3139 Errata ID 2934: Reported by Constantin Hagemeier 3140 Errata ID 3213: Reported by EugnJun Yi 3141 Errata ID 3300: Reported by Botong Huang 3142 Errata ID 3301: Reported by Botong Huang 3143 Note: Some verified errata were not used in this update, as they 3144 relate to sections of RFC 793 elided from this document. These 3145 include Errata ID 572, 575, and 1569. 3146 Note: Errata ID 3602 was not applied in this revision as it is 3147 duplicative of the 1122 corrections. 3148 There is an errata 3305 currently reported that need to be 3149 verified, held, or rejected by the ADs; it is addressing the same 3150 issue as draft-gont-tcpm-tcp-seq-validation and was not attempted 3151 to be applied to this document. 3153 Not related to RFC 793 content, this revision also makes small tweaks 3154 to the introductory text, fixes indentation of the pseudoheader 3155 diagram, and notes that the Security Considerations should also 3156 include privacy, when this section is written. 3158 The -03 revision of this document revises all discussion of the 3159 urgent pointer in order to comply with RFC 6093, 1122, and 1011. 3160 Since 1122 held requirements on the urgent pointer, the full list of 3161 requirements was brought into an appendix of this document, so that 3162 it can be updated as-needed. 3164 The -04 revision of this document includes the ISN generation changes 3165 from RFC 6528. 3167 TODO: Incomplete list of planned changes - these need to be added to 3168 and made more specific, as the document proceeds: 3170 1. incorporate 1122 additions 3171 2. point to major additional docs like 1323bis and 5681 3172 3. incorporate relevant parts of 3168 (ECN) 3173 4. incorporate Fernando's new number-checking fixes (if past the 3174 IESG in time) 3175 5. point to PMTUD? 3176 6. point to 5461 (soft errors) 3177 7. mention 5961 state machine option 3178 8. mention 6161 (reducing TIME-WAIT) 3179 9. incorporate 6429 (ZWP/persist) 3180 10. incorporate 6691 (MSS) 3181 11. look at Tony Sabatini suggestion for describing DO field 3182 12. clearly specify treatment of reserved bits (see TCPM thread on 3183 EDO draft April 25, 2014) 3184 13. look at possible mention of draft-minshall-nagle (e.g. as in 3185 Linux) 3186 14. make sure that clarifications in RFC 1011 are captured 3187 15. per TCPM discussion, discussion of checking reserved bits may 3188 need to be altered from 793 3189 16. MSL acronymn is defined multiple times 3191 5. IANA Considerations 3193 This memo includes no request to IANA. Existing IANA registries for 3194 TCP parameters are sufficient. 3196 TODO: check whether entries pointing to 793 and other documents 3197 obsoleted by this one should be updated to point to this one instead. 3199 6. Security and Privacy Considerations 3201 TODO 3203 See RFC 6093 [5] for discussion of security considerations related to 3204 the urgent pointer field. 3206 Editor's Note: Scott Brim mentioned that this should include a 3207 PERPASS/privacy review. 3209 7. Acknowledgements 3211 This document is largely a revision of RFC 793, which Jon Postel was 3212 the editor of. Due to his excellent work, it was able to last for 3213 three decades before we felt the need to revise it. 3215 Andre Oppermann was a contributor and helped to edit the first 3216 revision of this document. 3218 We are thankful for the assistance of the IETF TCPM working group 3219 chairs: 3221 Michael Scharf 3222 Yoshifumi Nishida 3223 Pasi Sarolahti 3225 On the TCPM mailing list, and at the IETF 88 meeting in Vancouver, 3226 helpful comments, critiques, and reviews were received from (listed 3227 alphebetically): David Borman, Yuchung Cheng, Martin Duke, Kevin 3228 Lahey, Kevin Mason, Matt Mathis, Hagen Paul Pfeifer, Anthony 3229 Sabatini, Joe Touch, Reji Varghese, Lloyd Wood, and Alex Zimmermann. 3231 This document includes content from errata that were reported by 3232 (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, 3233 Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta 3234 Yevstifeyev, EungJun Yi, Botong Huang. 3236 8. References 3238 8.1. Normative References 3240 [1] Bradner, S., "Key words for use in RFCs to Indicate 3241 Requirement Levels", BCP 14, RFC 2119, March 1997. 3243 8.2. Informative References 3245 [2] Postel, J., "Transmission Control Protocol", STD 7, RFC 3246 793, September 1981. 3248 [3] Braden, R., "Requirements for Internet Hosts - 3249 Communication Layers", STD 3, RFC 1122, October 1989. 3251 [4] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. 3252 Zimmermann, "A Roadmap for Transmission Control Protocol 3253 (TCP) Specification Documents", draft-ietf-tcpm-tcp- 3254 rfc4614bis-07 (work in progress), July 2014. 3256 [5] Gont, F. and A. Yourtchenko, "On the Implementation of the 3257 TCP Urgent Mechanism", RFC 6093, January 2011. 3259 [6] Gont, F. and S. Bellovin, "Defending against Sequence 3260 Number Attacks", RFC 6528, February 2012. 3262 Appendix A. TCP Requirement Summary 3264 This section is adapted from RFC 1122. 3266 TODO: this needs to be seriously redone, to use 793bis section 3267 numbers instead of 1122 ones, and all 1122 requirements need to be 3268 reflected in 793bis text. 3270 RFC EDITOR'S NOTE: 793bis in the heading below should be replaced by 3271 the number of this RFC 3273 | | | | |S| | 3274 | | | | |H| |F 3275 | | | | |O|M|o 3276 | | |S| |U|U|o 3277 | | |H| |L|S|t 3278 | |M|O| |D|T|n 3279 | |U|U|M| | |o 3280 | |S|L|A|N|N|t 3281 |RFC1122 |T|D|Y|O|O|t 3282 FEATURE |SECTION | | | |T|T|e 3283 -------------------------------------------------|--------|-|-|-|-|-|-- 3284 | | | | | | | 3285 Push flag | | | | | | | 3286 Aggregate or queue un-pushed data |4.2.2.2 | | |x| | | 3287 Sender collapse successive PSH flags |4.2.2.2 | |x| | | | 3288 SEND call can specify PUSH |4.2.2.2 | | |x| | | 3289 If cannot: sender buffer indefinitely |4.2.2.2 | | | | |x| 3290 If cannot: PSH last segment |4.2.2.2 |x| | | | | 3291 Notify receiving ALP of PSH |4.2.2.2 | | |x| | |1 3292 Send max size segment when possible |4.2.2.2 | |x| | | | 3293 | | | | | | | 3294 Window | | | | | | | 3295 Treat as unsigned number |4.2.2.3 |x| | | | | 3296 Handle as 32-bit number |4.2.2.3 | |x| | | | 3297 Shrink window from right |4.2.2.16| | | |x| | 3298 Robust against shrinking window |4.2.2.16|x| | | | | 3299 Receiver's window closed indefinitely |4.2.2.17| | |x| | | 3300 Sender probe zero window |4.2.2.17|x| | | | | 3301 First probe after RTO |4.2.2.17| |x| | | | 3302 Exponential backoff |4.2.2.17| |x| | | | 3303 Allow window stay zero indefinitely |4.2.2.17|x| | | | | 3304 Sender timeout OK conn with zero wind |4.2.2.17| | | | |x| 3305 | | | | | | | 3306 Urgent Data | | | | | | | 3307 Pointer indicates first non-urgent octet |4.2.2.4 |x| | | | | 3308 Arbitrary length urgent data sequence |4.2.2.4 |x| | | | | 3309 Inform ALP asynchronously of urgent data |4.2.2.4 |x| | | | |1 3310 ALP can learn if/how much urgent data Q'd |4.2.2.4 |x| | | | |1 3311 | | | | | | | 3312 TCP Options | | | | | | | 3313 Receive TCP option in any segment |4.2.2.5 |x| | | | | 3314 Ignore unsupported options |4.2.2.5 |x| | | | | 3315 Cope with illegal option length |4.2.2.5 |x| | | | | 3316 Implement sending & receiving MSS option |4.2.2.6 |x| | | | | 3317 Send MSS option unless 536 |4.2.2.6 | |x| | | | 3318 Send MSS option always |4.2.2.6 | | |x| | | 3319 Send-MSS default is 536 |4.2.2.6 |x| | | | | 3320 Calculate effective send seg size |4.2.2.6 |x| | | | | 3321 | | | | | | | 3322 TCP Checksums | | | | | | | 3323 Sender compute checksum |4.2.2.7 |x| | | | | 3324 Receiver check checksum |4.2.2.7 |x| | | | | 3325 | | | | | | | 3326 ISN Selection | | | | | | | 3327 Include a clock-driven ISN generator component |4.2.2.9 |x| | | | | 3328 Secure ISN generator with a PRF component | N/A | |x| | | | 3329 | | | | | | | 3330 Opening Connections | | | | | | | 3331 Support simultaneous open attempts |4.2.2.10|x| | | | | 3332 SYN-RCVD remembers last state |4.2.2.11|x| | | | | 3333 Passive Open call interfere with others |4.2.2.18| | | | |x| 3334 Function: simultan. LISTENs for same port |4.2.2.18|x| | | | | 3335 Ask IP for src address for SYN if necc. |4.2.3.7 |x| | | | | 3336 Otherwise, use local addr of conn. |4.2.3.7 |x| | | | | 3337 OPEN to broadcast/multicast IP Address |4.2.3.14| | | | |x| 3338 Silently discard seg to bcast/mcast addr |4.2.3.14|x| | | | | 3339 | | | | | | | 3340 Closing Connections | | | | | | | 3341 RST can contain data |4.2.2.12| |x| | | | 3342 Inform application of aborted conn |4.2.2.13|x| | | | | 3343 Half-duplex close connections |4.2.2.13| | |x| | | 3344 Send RST to indicate data lost |4.2.2.13| |x| | | | 3345 In TIME-WAIT state for 2xMSL seconds |4.2.2.13|x| | | | | 3346 Accept SYN from TIME-WAIT state |4.2.2.13| | |x| | | 3347 | | | | | | | 3348 Retransmissions | | | | | | | 3349 Jacobson Slow Start algorithm |4.2.2.15|x| | | | | 3350 Jacobson Congestion-Avoidance algorithm |4.2.2.15|x| | | | | 3351 Retransmit with same IP ident |4.2.2.15| | |x| | | 3352 Karn's algorithm |4.2.3.1 |x| | | | | 3353 Jacobson's RTO estimation alg. |4.2.3.1 |x| | | | | 3354 Exponential backoff |4.2.3.1 |x| | | | | 3355 SYN RTO calc same as data |4.2.3.1 | |x| | | | 3356 Recommended initial values and bounds |4.2.3.1 | |x| | | | 3357 | | | | | | | 3358 Generating ACK's: | | | | | | | 3359 Queue out-of-order segments |4.2.2.20| |x| | | | 3360 Process all Q'd before send ACK |4.2.2.20|x| | | | | 3361 Send ACK for out-of-order segment |4.2.2.21| | |x| | | 3362 Delayed ACK's |4.2.3.2 | |x| | | | 3363 Delay < 0.5 seconds |4.2.3.2 |x| | | | | 3364 Every 2nd full-sized segment ACK'd |4.2.3.2 |x| | | | | 3365 Receiver SWS-Avoidance Algorithm |4.2.3.3 |x| | | | | 3366 | | | | | | | 3367 Sending data | | | | | | | 3368 Configurable TTL |4.2.2.19|x| | | | | 3369 Sender SWS-Avoidance Algorithm |4.2.3.4 |x| | | | | 3370 Nagle algorithm |4.2.3.4 | |x| | | | 3371 Application can disable Nagle algorithm |4.2.3.4 |x| | | | | 3372 | | | | | | | 3373 Connection Failures: | | | | | | | 3374 Negative advice to IP on R1 retxs |4.2.3.5 |x| | | | | 3375 Close connection on R2 retxs |4.2.3.5 |x| | | | | 3376 ALP can set R2 |4.2.3.5 |x| | | | |1 3377 Inform ALP of R1<=retxs inform ALP |4.2.3.9 | |x| | | | 3402 Dest. Unreach (0,1,5) => abort conn |4.2.3.9 | | | | |x| 3403 Dest. Unreach (2-4) => abort conn |4.2.3.9 | |x| | | | 3404 Source Quench => slow start |4.2.3.9 | |x| | | | 3405 Time Exceeded => tell ALP, don't abort |4.2.3.9 | |x| | | | 3406 Param Problem => tell ALP, don't abort |4.2.3.9 | |x| | | | 3407 | | | | | | | 3408 Address Validation | | | | | | | 3409 Reject OPEN call to invalid IP address |4.2.3.10|x| | | | | 3410 Reject SYN from invalid IP address |4.2.3.10|x| | | | | 3411 Silently discard SYN to bcast/mcast addr |4.2.3.10|x| | | | | 3412 | | | | | | | 3413 TCP/ALP Interface Services | | | | | | | 3414 Error Report mechanism |4.2.4.1 |x| | | | | 3415 ALP can disable Error Report Routine |4.2.4.1 | |x| | | | 3416 ALP can specify TOS for sending |4.2.4.2 |x| | | | | 3417 Passed unchanged to IP |4.2.4.2 | |x| | | | 3418 ALP can change TOS during connection |4.2.4.2 | |x| | | | 3419 Pass received TOS up to ALP |4.2.4.2 | | |x| | | 3420 FLUSH call |4.2.4.3 | | |x| | | 3421 Optional local IP addr parm. in OPEN |4.2.4.4 |x| | | | | 3422 -------------------------------------------------|--------|-|-|-|-|-|-- 3424 FOOTNOTES: (1) "ALP" means Application-Layer program. 3426 Author's Address 3428 Wesley M. Eddy (editor) 3429 MTI Systems 3430 US 3432 Email: wes@mti-systems.com