idnits 2.17.00 (12 Aug 2021) /tmp/idnits59875/draft-eddy-rfc793bis-03.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 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 == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, 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 12, 2014) is 2838 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) == Outdated reference: draft-ietf-tcpm-tcp-rfc4614bis has been published as RFC 7414 Summary: 1 error (**), 0 flaws (~~), 4 warnings (==), 3 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 (if approved) August 12, 2014 5 Updates: 1122 (if approved) 6 Intended status: Standards Track 7 Expires: February 13, 2015 9 Transmission Control Protocol Specification 10 draft-eddy-rfc793bis-03 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 13, 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 . . . . . . . . . . . . . . . . . . 5 82 3.1. Header Format . . . . . . . . . . . . . . . . . . . . . . 5 83 3.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 9 84 3.3. Sequence Numbers . . . . . . . . . . . . . . . . . . . . 13 85 3.4. Establishing a connection . . . . . . . . . . . . . . . . 19 86 3.5. Closing a Connection . . . . . . . . . . . . . . . . . . 26 87 3.6. Precedence and Security . . . . . . . . . . . . . . . . . 28 88 3.7. Data Communication . . . . . . . . . . . . . . . . . . . 29 89 3.8. Interfaces . . . . . . . . . . . . . . . . . . . . . . . 33 90 3.8.1. User/TCP Interface . . . . . . . . . . . . . . . . . 33 91 3.8.2. TCP/Lower-Level Interface . . . . . . . . . . . . . . 40 92 3.9. Event Processing . . . . . . . . . . . . . . . . . . . . 41 93 3.10. Glossary . . . . . . . . . . . . . . . . . . . . . . . . 64 94 4. Changes from RFC 793 . . . . . . . . . . . . . . . . . . . . 69 95 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 72 96 6. Security and Privacy Considerations . . . . . . . . . . . . . 72 97 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 72 98 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 73 99 8.1. Normative References . . . . . . . . . . . . . . . . . . 73 100 8.2. Informative References . . . . . . . . . . . . . . . . . 73 101 Appendix A. TCP Requirement Summary . . . . . . . . . . . . . . 73 102 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 76 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 each revision is roughly: 175 -00 was a proposal for the scope of the document and description 176 of the need for an update to RFC 793 178 -01 incorporated the RFC 793 section 3 content with no additional 179 changes into XML2RFC format for easy tracking of the changes 180 between RFC 793 and future revisions of the document 182 -02 incorporates the verified errata on RFC 793 as of March 20, 183 2014 185 -03 incorporates urgent pointer changes from RFC 6093 187 -04 will incorporate RFC 6528 189 -05 and beyond are intended to incorporate changes from other RFCs 190 that updated 793 192 3. Functional Specification 194 3.1. Header Format 196 TCP segments are sent as internet datagrams. The Internet Protocol 197 header carries several information fields, including the source and 198 destination host addresses [2]. A TCP header follows the internet 199 header, supplying information specific to the TCP protocol. This 200 division allows for the existence of host level protocols other than 201 TCP. 203 TCP Header Format 205 0 1 2 3 206 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 207 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 208 | Source Port | Destination Port | 209 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 210 | Sequence Number | 211 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 212 | Acknowledgment Number | 213 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 214 | Data | |U|A|P|R|S|F| | 215 | Offset| Reserved |R|C|S|S|Y|I| Window | 216 | | |G|K|H|T|N|N| | 217 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 218 | Checksum | Urgent Pointer | 219 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 220 | Options | Padding | 221 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 222 | data | 223 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 225 TCP Header Format 227 Note that one tick mark represents one bit position. 229 Figure 1 231 Source Port: 16 bits 233 The source port number. 235 Destination Port: 16 bits 237 The destination port number. 239 Sequence Number: 32 bits 240 The sequence number of the first data octet in this segment (except 241 when SYN is present). If SYN is present the sequence number is the 242 initial sequence number (ISN) and the first data octet is ISN+1. 244 Acknowledgment Number: 32 bits 246 If the ACK control bit is set this field contains the value of the 247 next sequence number the sender of the segment is expecting to 248 receive. Once a connection is established this is always sent. 250 Data Offset: 4 bits 252 The number of 32 bit words in the TCP Header. This indicates where 253 the data begins. The TCP header (even one including options) is an 254 integral number of 32 bits long. 256 Reserved: 6 bits 258 Reserved for future use. Must be zero. 260 Control Bits: 6 bits (from left to right): 262 URG: Urgent Pointer field significant 263 ACK: Acknowledgment field significant 264 PSH: Push Function 265 RST: Reset the connection 266 SYN: Synchronize sequence numbers 267 FIN: No more data from sender 269 Window: 16 bits 271 The number of data octets beginning with the one indicated in the 272 acknowledgment field which the sender of this segment is willing to 273 accept. 275 Checksum: 16 bits 277 The checksum field is the 16 bit one's complement of the one's 278 complement sum of all 16 bit words in the header and text. If a 279 segment contains an odd number of header and text octets to be 280 checksummed, the last octet is padded on the right with zeros to 281 form a 16 bit word for checksum purposes. The pad is not 282 transmitted as part of the segment. While computing the checksum, 283 the checksum field itself is replaced with zeros. 285 The checksum also covers a 96 bit pseudo header conceptually 286 prefixed to the TCP header. This pseudo header contains the Source 287 Address, the Destination Address, the Protocol, and TCP length. 289 This gives the TCP protection against misrouted segments. This 290 information is carried in the Internet Protocol and is transferred 291 across the TCP/Network interface in the arguments or results of 292 calls by the TCP on the IP. 294 +--------+--------+--------+--------+ 295 | Source Address | 296 +--------+--------+--------+--------+ 297 | Destination Address | 298 +--------+--------+--------+--------+ 299 | zero | PTCL | TCP Length | 300 +--------+--------+--------+--------+ 302 The TCP Length is the TCP header length plus the data length in 303 octets (this is not an explicitly transmitted quantity, but is 304 computed), and it does not count the 12 octets of the pseudo 305 header. 307 Urgent Pointer: 16 bits 309 This field communicates the current value of the urgent pointer as 310 a positive offset from the sequence number in this segment. The 311 urgent pointer points to the sequence number of the octet following 312 the urgent data. This field is only be interpreted in segments 313 with the URG control bit set. 315 Options: variable 317 Options may occupy space at the end of the TCP header and are a 318 multiple of 8 bits in length. All options are included in the 319 checksum. An option may begin on any octet boundary. There are 320 two cases for the format of an option: 322 Case 1: A single octet of option-kind. 324 Case 2: An octet of option-kind, an octet of option-length, and 325 the actual option-data octets. 327 The option-length counts the two octets of option-kind and option- 328 length as well as the option-data octets. 330 Note that the list of options may be shorter than the data offset 331 field might imply. The content of the header beyond the End-of- 332 Option option must be header padding (i.e., zero). 334 A TCP must implement all options. 336 Currently defined options include (kind indicated in octal): 338 Kind Length Meaning 339 ---- ------ ------- 340 0 - End of option list. 341 1 - No-Operation. 342 2 4 Maximum Segment Size. 344 Specific Option Definitions 346 End of Option List 348 +--------+ 349 |00000000| 350 +--------+ 351 Kind=0 353 This option code indicates the end of the option list. This 354 might not coincide with the end of the TCP header according to 355 the Data Offset field. This is used at the end of all options, 356 not the end of each option, and need only be used if the end of 357 the options would not otherwise coincide with the end of the TCP 358 header. 360 No-Operation 362 +--------+ 363 |00000001| 364 +--------+ 365 Kind=1 367 This option code may be used between options, for example, to 368 align the beginning of a subsequent option on a word boundary. 369 There is no guarantee that senders will use this option, so 370 receivers must be prepared to process options even if they do 371 not begin on a word boundary. 373 Maximum Segment Size 375 +--------+--------+---------+--------+ 376 |00000010|00000100| max seg size | 377 +--------+--------+---------+--------+ 378 Kind=2 Length=4 380 Maximum Segment Size Option Data: 16 bits 382 If this option is present, then it communicates the maximum 383 receive segment size at the TCP which sends this segment. This 384 field may be sent in the initial connection request (i.e., in 385 segments with the SYN control bit set) and must not be sent in 386 other segments. If this option is not used, any segment size is 387 allowed. 389 Padding: variable 391 The TCP header padding is used to ensure that the TCP header ends 392 and data begins on a 32 bit boundary. The padding is composed of 393 zeros. 395 3.2. Terminology 397 Before we can discuss very much about the operation of the TCP we 398 need to introduce some detailed terminology. The maintenance of a 399 TCP connection requires the remembering of several variables. We 400 conceive of these variables being stored in a connection record 401 called a Transmission Control Block or TCB. Among the variables 402 stored in the TCB are the local and remote socket numbers, the 403 security and precedence of the connection, pointers to the user's 404 send and receive buffers, pointers to the retransmit queue and to the 405 current segment. In addition several variables relating to the send 406 and receive sequence numbers are stored in the TCB. 408 Send Sequence Variables 410 SND.UNA - send unacknowledged 411 SND.NXT - send next 412 SND.WND - send window 413 SND.UP - send urgent pointer 414 SND.WL1 - segment sequence number used for last window update 415 SND.WL2 - segment acknowledgment number used for last window 416 update 417 ISS - initial send sequence number 419 Receive Sequence Variables 421 RCV.NXT - receive next 422 RCV.WND - receive window 423 RCV.UP - receive urgent pointer 424 IRS - initial receive sequence number 426 The following diagrams may help to relate some of these variables to 427 the sequence space. 429 Send Sequence Space 431 1 2 3 4 432 ----------|----------|----------|---------- 433 SND.UNA SND.NXT SND.UNA 434 +SND.WND 436 1 - old sequence numbers which have been acknowledged 437 2 - sequence numbers of unacknowledged data 438 3 - sequence numbers allowed for new data transmission 439 4 - future sequence numbers which are not yet allowed 441 Send Sequence Space 443 Figure 2 445 The send window is the portion of the sequence space labeled 3 in 446 Figure 2. 448 Receive Sequence Space 450 1 2 3 451 ----------|----------|---------- 452 RCV.NXT RCV.NXT 453 +RCV.WND 455 1 - old sequence numbers which have been acknowledged 456 2 - sequence numbers allowed for new reception 457 3 - future sequence numbers which are not yet allowed 459 Receive Sequence Space 461 Figure 3 463 The receive window is the portion of the sequence space labeled 2 in 464 Figure 3. 466 There are also some variables used frequently in the discussion that 467 take their values from the fields of the current segment. 469 Current Segment Variables 471 SEG.SEQ - segment sequence number 472 SEG.ACK - segment acknowledgment number 473 SEG.LEN - segment length 474 SEG.WND - segment window 475 SEG.UP - segment urgent pointer 476 SEG.PRC - segment precedence value 478 A connection progresses through a series of states during its 479 lifetime. The states are: LISTEN, SYN-SENT, SYN-RECEIVED, 480 ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, 481 TIME-WAIT, and the fictional state CLOSED. CLOSED is fictional 482 because it represents the state when there is no TCB, and therefore, 483 no connection. Briefly the meanings of the states are: 485 LISTEN - represents waiting for a connection request from any 486 remote TCP and port. 488 SYN-SENT - represents waiting for a matching connection request 489 after having sent a connection request. 491 SYN-RECEIVED - represents waiting for a confirming connection 492 request acknowledgment after having both received and sent a 493 connection request. 495 ESTABLISHED - represents an open connection, data received can be 496 delivered to the user. The normal state for the data transfer 497 phase of the connection. 499 FIN-WAIT-1 - represents waiting for a connection termination 500 request from the remote TCP, or an acknowledgment of the 501 connection termination request previously sent. 503 FIN-WAIT-2 - represents waiting for a connection termination 504 request from the remote TCP. 506 CLOSE-WAIT - represents waiting for a connection termination 507 request from the local user. 509 CLOSING - represents waiting for a connection termination request 510 acknowledgment from the remote TCP. 512 LAST-ACK - represents waiting for an acknowledgment of the 513 connection termination request previously sent to the remote TCP 514 (this termination request sent to the remote TCP already included 515 an acknowledgment of the termination request sent from the remote 516 TCP). 518 TIME-WAIT - represents waiting for enough time to pass to be sure 519 the remote TCP received the acknowledgment of its connection 520 termination request. 522 CLOSED - represents no connection state at all. 524 A TCP connection progresses from one state to another in response to 525 events. The events are the user calls, OPEN, SEND, RECEIVE, CLOSE, 526 ABORT, and STATUS; the incoming segments, particularly those 527 containing the SYN, ACK, RST and FIN flags; and timeouts. 529 The state diagram in Figure 4 illustrates only state changes, 530 together with the causing events and resulting actions, but addresses 531 neither error conditions nor actions which are not connected with 532 state changes. In a later section, more detail is offered with 533 respect to the reaction of the TCP to events. 535 NOTA BENE: this diagram is only a summary and must not be taken as 536 the total specification. 538 +---------+ ---------\ active OPEN 539 | CLOSED | \ ----------- 540 +---------+<---------\ \ create TCB 541 | ^ \ \ snd SYN 542 passive OPEN | | CLOSE \ \ 543 ------------ | | ---------- \ \ 544 create TCB | | delete TCB \ \ 545 V | \ \ 546 rcv RST (note 1) +---------+ CLOSE | \ 547 -------------------->| LISTEN | ---------- | | 548 / +---------+ delete TCB | | 549 / rcv SYN | | SEND | | 550 / ----------- | | ------- | V 551 +---------+ snd SYN,ACK / \ snd SYN +---------+ 552 | |<----------------- ------------------>| | 553 | SYN | rcv SYN | SYN | 554 | RCVD |<-----------------------------------------------| SENT | 555 | | snd SYN,ACK | | 556 | |------------------ -------------------| | 557 +---------+ rcv ACK of SYN \ / rcv SYN,ACK +---------+ 558 | -------------- | | ----------- 559 | x | | snd ACK 560 | V V 561 | CLOSE +---------+ 562 | ------- | ESTAB | 563 | snd FIN +---------+ 564 | CLOSE | | rcv FIN 565 V ------- | | ------- 566 +---------+ snd FIN / \ snd ACK +---------+ 567 | FIN |<----------------- ------------------>| CLOSE | 568 | WAIT-1 |------------------ | WAIT | 569 +---------+ rcv FIN \ +---------+ 570 | rcv ACK of FIN ------- | CLOSE | 571 | -------------- snd ACK | ------- | 572 V x V snd FIN V 573 +---------+ +---------+ +---------+ 574 |FINWAIT-2| | CLOSING | | LAST-ACK| 575 +---------+ +---------+ +---------+ 576 | rcv ACK of FIN | rcv ACK of FIN | 577 | rcv FIN -------------- | Timeout=2MSL -------------- | 578 | ------- x V ------------ x V 579 \ snd ACK +---------+delete TCB +---------+ 580 ------------------------>|TIME WAIT|------------------>| CLOSED | 581 +---------+ +---------+ 583 note 1: The transition from SYN-RCVD to LISTEN on receiving a RST is 584 conditional on having reached SYN-RCVD after a passive open. 586 note 2: An unshown transition exists from FIN-WAIT-1 to TIME-WAIT if 587 a FIN is received and the local FIN is also acknowledged. 589 TCP Connection State Diagram 591 Figure 4 593 3.3. Sequence Numbers 595 A fundamental notion in the design is that every octet of data sent 596 over a TCP connection has a sequence number. Since every octet is 597 sequenced, each of them can be acknowledged. The acknowledgment 598 mechanism employed is cumulative so that an acknowledgment of 599 sequence number X indicates that all octets up to but not including X 600 have been received. This mechanism allows for straight-forward 601 duplicate detection in the presence of retransmission. Numbering of 602 octets within a segment is that the first data octet immediately 603 following the header is the lowest numbered, and the following octets 604 are numbered consecutively. 606 It is essential to remember that the actual sequence number space is 607 finite, though very large. This space ranges from 0 to 2**32 - 1. 608 Since the space is finite, all arithmetic dealing with sequence 609 numbers must be performed modulo 2**32. This unsigned arithmetic 610 preserves the relationship of sequence numbers as they cycle from 611 2**32 - 1 to 0 again. There are some subtleties to computer modulo 612 arithmetic, so great care should be taken in programming the 613 comparison of such values. The symbol "=<" means "less than or 614 equal" (modulo 2**32). 616 The typical kinds of sequence number comparisons which the TCP must 617 perform include: 619 (a) Determining that an acknowledgment refers to some sequence 620 number sent but not yet acknowledged. 622 (b) Determining that all sequence numbers occupied by a segment 623 have been acknowledged (e.g., to remove the segment from a 624 retransmission queue). 626 (c) Determining that an incoming segment contains sequence numbers 627 which are expected (i.e., that the segment "overlaps" the receive 628 window). 630 In response to sending data the TCP will receive acknowledgments. 631 The following comparisons are needed to process the acknowledgments. 633 SND.UNA = oldest unacknowledged sequence number 635 SND.NXT = next sequence number to be sent 637 SEG.ACK = acknowledgment from the receiving TCP (next sequence 638 number expected by the receiving TCP) 640 SEG.SEQ = first sequence number of a segment 642 SEG.LEN = the number of octets occupied by the data in the segment 643 (counting SYN and FIN) 645 SEG.SEQ+SEG.LEN-1 = last sequence number of a segment 647 A new acknowledgment (called an "acceptable ack"), is one for which 648 the inequality below holds: 650 SND.UNA < SEG.ACK =< SND.NXT 652 A segment on the retransmission queue is fully acknowledged if the 653 sum of its sequence number and length is less or equal than the 654 acknowledgment value in the incoming segment. 656 When data is received the following comparisons are needed: 658 RCV.NXT = next sequence number expected on an incoming segments, 659 and is the left or lower edge of the receive window 661 RCV.NXT+RCV.WND-1 = last sequence number expected on an incoming 662 segment, and is the right or upper edge of the receive window 664 SEG.SEQ = first sequence number occupied by the incoming segment 666 SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming 667 segment 669 A segment is judged to occupy a portion of valid receive sequence 670 space if 672 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 674 or 676 RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 678 The first part of this test checks to see if the beginning of the 679 segment falls in the window, the second part of the test checks to 680 see if the end of the segment falls in the window; if the segment 681 passes either part of the test it contains data in the window. 683 Actually, it is a little more complicated than this. Due to zero 684 windows and zero length segments, we have four cases for the 685 acceptability of an incoming segment: 687 Segment Receive Test 688 Length Window 689 ------- ------- ------------------------------------------- 691 0 0 SEG.SEQ = RCV.NXT 693 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 695 >0 0 not acceptable 697 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 698 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 700 Note that when the receive window is zero no segments should be 701 acceptable except ACK segments. Thus, it is be possible for a TCP to 702 maintain a zero receive window while transmitting data and receiving 703 ACKs. However, even when the receive window is zero, a TCP must 704 process the RST and URG fields of all incoming segments. 706 We have taken advantage of the numbering scheme to protect certain 707 control information as well. This is achieved by implicitly 708 including some control flags in the sequence space so they can be 709 retransmitted and acknowledged without confusion (i.e., one and only 710 one copy of the control will be acted upon). Control information is 711 not physically carried in the segment data space. Consequently, we 712 must adopt rules for implicitly assigning sequence numbers to 713 control. The SYN and FIN are the only controls requiring this 714 protection, and these controls are used only at connection opening 715 and closing. For sequence number purposes, the SYN is considered to 716 occur before the first actual data octet of the segment in which it 717 occurs, while the FIN is considered to occur after the last actual 718 data octet in a segment in which it occurs. The segment length 719 (SEG.LEN) includes both data and sequence space occupying controls. 720 When a SYN is present then SEG.SEQ is the sequence number of the SYN. 722 Initial Sequence Number Selection 724 The protocol places no restriction on a particular connection being 725 used over and over again. A connection is defined by a pair of 726 sockets. New instances of a connection will be referred to as 727 incarnations of the connection. The problem that arises from this is 728 -- "how does the TCP identify duplicate segments from previous 729 incarnations of the connection?" This problem becomes apparent if 730 the connection is being opened and closed in quick succession, or if 731 the connection breaks with loss of memory and is then reestablished. 733 To avoid confusion we must prevent segments from one incarnation of a 734 connection from being used while the same sequence numbers may still 735 be present in the network from an earlier incarnation. We want to 736 assure this, even if a TCP crashes and loses all knowledge of the 737 sequence numbers it has been using. When new connections are 738 created, an initial sequence number (ISN) generator is employed which 739 selects a new 32 bit ISN. The generator is bound to a (possibly 740 fictitious) 32 bit clock whose low order bit is incremented roughly 741 every 4 microseconds. Thus, the ISN cycles approximately every 4.55 742 hours. Since we assume that segments will stay in the network no 743 more than the Maximum Segment Lifetime (MSL) and that the MSL is less 744 than 4.55 hours we can reasonably assume that ISN's will be unique. 746 For each connection there is a send sequence number and a receive 747 sequence number. The initial send sequence number (ISS) is chosen by 748 the data sending TCP, and the initial receive sequence number (IRS) 749 is learned during the connection establishing procedure. 751 For a connection to be established or initialized, the two TCPs must 752 synchronize on each other's initial sequence numbers. This is done 753 in an exchange of connection establishing segments carrying a control 754 bit called "SYN" (for synchronize) and the initial sequence numbers. 755 As a shorthand, segments carrying the SYN bit are also called "SYNs". 756 Hence, the solution requires a suitable mechanism for picking an 757 initial sequence number and a slightly involved handshake to exchange 758 the ISN's. 760 The synchronization requires each side to send it's own initial 761 sequence number and to receive a confirmation of it in acknowledgment 762 from the other side. Each side must also receive the other side's 763 initial sequence number and send a confirming acknowledgment. 765 1) A --> B SYN my sequence number is X 766 2) A <-- B ACK your sequence number is X 767 3) A <-- B SYN my sequence number is Y 768 4) A --> B ACK your sequence number is Y 770 Because steps 2 and 3 can be combined in a single message this is 771 called the three way (or three message) handshake. 773 A three way handshake is necessary because sequence numbers are not 774 tied to a global clock in the network, and TCPs may have different 775 mechanisms for picking the ISN's. The receiver of the first SYN has 776 no way of knowing whether the segment was an old delayed one or not, 777 unless it remembers the last sequence number used on the connection 778 (which is not always possible), and so it must ask the sender to 779 verify this SYN. The three way handshake and the advantages of a 780 clock-driven scheme are discussed in [3]. 782 Knowing When to Keep Quiet 784 To be sure that a TCP does not create a segment that carries a 785 sequence number which may be duplicated by an old segment remaining 786 in the network, the TCP must keep quiet for a maximum segment 787 lifetime (MSL) before assigning any sequence numbers upon starting up 788 or recovering from a crash in which memory of sequence numbers in use 789 was lost. For this specification the MSL is taken to be 2 minutes. 790 This is an engineering choice, and may be changed if experience 791 indicates it is desirable to do so. Note that if a TCP is 792 reinitialized in some sense, yet retains its memory of sequence 793 numbers in use, then it need not wait at all; it must only be sure to 794 use sequence numbers larger than those recently used. 796 The TCP Quiet Time Concept 798 This specification provides that hosts which "crash" without 799 retaining any knowledge of the last sequence numbers transmitted on 800 each active (i.e., not closed) connection shall delay emitting any 801 TCP segments for at least the agreed Maximum Segment Lifetime (MSL) 802 in the internet system of which the host is a part. In the 803 paragraphs below, an explanation for this specification is given. 804 TCP implementors may violate the "quiet time" restriction, but only 805 at the risk of causing some old data to be accepted as new or new 806 data rejected as old duplicated by some receivers in the internet 807 system. 809 TCPs consume sequence number space each time a segment is formed and 810 entered into the network output queue at a source host. The 811 duplicate detection and sequencing algorithm in the TCP protocol 812 relies on the unique binding of segment data to sequence space to the 813 extent that sequence numbers will not cycle through all 2**32 values 814 before the segment data bound to those sequence numbers has been 815 delivered and acknowledged by the receiver and all duplicate copies 816 of the segments have "drained" from the internet. Without such an 817 assumption, two distinct TCP segments could conceivably be assigned 818 the same or overlapping sequence numbers, causing confusion at the 819 receiver as to which data is new and which is old. Remember that 820 each segment is bound to as many consecutive sequence numbers as 821 there are octets of data and SYN or FIN flags in the segment. 823 Under normal conditions, TCPs keep track of the next sequence number 824 to emit and the oldest awaiting acknowledgment so as to avoid 825 mistakenly using a sequence number over before its first use has been 826 acknowledged. This alone does not guarantee that old duplicate data 827 is drained from the net, so the sequence space has been made very 828 large to reduce the probability that a wandering duplicate will cause 829 trouble upon arrival. At 2 megabits/sec. it takes 4.5 hours to use 830 up 2**32 octets of sequence space. Since the maximum segment 831 lifetime in the net is not likely to exceed a few tens of seconds, 832 this is deemed ample protection for foreseeable nets, even if data 833 rates escalate to l0's of megabits/sec. At 100 megabits/sec, the 834 cycle time is 5.4 minutes which may be a little short, but still 835 within reason. 837 The basic duplicate detection and sequencing algorithm in TCP can be 838 defeated, however, if a source TCP does not have any memory of the 839 sequence numbers it last used on a given connection. For example, if 840 the TCP were to start all connections with sequence number 0, then 841 upon crashing and restarting, a TCP might re-form an earlier 842 connection (possibly after half-open connection resolution) and emit 843 packets with sequence numbers identical to or overlapping with 844 packets still in the network which were emitted on an earlier 845 incarnation of the same connection. In the absence of knowledge 846 about the sequence numbers used on a particular connection, the TCP 847 specification recommends that the source delay for MSL seconds before 848 emitting segments on the connection, to allow time for segments from 849 the earlier connection incarnation to drain from the system. 851 Even hosts which can remember the time of day and used it to select 852 initial sequence number values are not immune from this problem 853 (i.e., even if time of day is used to select an initial sequence 854 number for each new connection incarnation). 856 Suppose, for example, that a connection is opened starting with 857 sequence number S. Suppose that this connection is not used much and 858 that eventually the initial sequence number function (ISN(t)) takes 859 on a value equal to the sequence number, say S1, of the last segment 860 sent by this TCP on a particular connection. Now suppose, at this 861 instant, the host crashes, recovers, and establishes a new 862 incarnation of the connection. The initial sequence number chosen is 863 S1 = ISN(t) -- last used sequence number on old incarnation of 864 connection! If the recovery occurs quickly enough, any old 865 duplicates in the net bearing sequence numbers in the neighborhood of 866 S1 may arrive and be treated as new packets by the receiver of the 867 new incarnation of the connection. 869 The problem is that the recovering host may not know for how long it 870 crashed nor does it know whether there are still old duplicates in 871 the system from earlier connection incarnations. 873 One way to deal with this problem is to deliberately delay emitting 874 segments for one MSL after recovery from a crash- this is the "quiet 875 time" specification. Hosts which prefer to avoid waiting are willing 876 to risk possible confusion of old and new packets at a given 877 destination may choose not to wait for the "quite time". 878 Implementors may provide TCP users with the ability to select on a 879 connection by connection basis whether to wait after a crash, or may 880 informally implement the "quite time" for all connections. 881 Obviously, even where a user selects to "wait," this is not necessary 882 after the host has been "up" for at least MSL seconds. 884 To summarize: every segment emitted occupies one or more sequence 885 numbers in the sequence space, the numbers occupied by a segment are 886 "busy" or "in use" until MSL seconds have passed, upon crashing a 887 block of space-time is occupied by the octets and SYN or FIN flags of 888 the last emitted segment, if a new connection is started too soon and 889 uses any of the sequence numbers in the space-time footprint of the 890 last segment of the previous connection incarnation, there is a 891 potential sequence number overlap area which could cause confusion at 892 the receiver. 894 3.4. Establishing a connection 896 The "three-way handshake" is the procedure used to establish a 897 connection. This procedure normally is initiated by one TCP and 898 responded to by another TCP. The procedure also works if two TCP 899 simultaneously initiate the procedure. When simultaneous attempt 900 occurs, each TCP receives a "SYN" segment which carries no 901 acknowledgment after it has sent a "SYN". Of course, the arrival of 902 an old duplicate "SYN" segment can potentially make it appear, to the 903 recipient, that a simultaneous connection initiation is in progress. 904 Proper use of "reset" segments can disambiguate these cases. 906 Several examples of connection initiation follow. Although these 907 examples do not show connection synchronization using data-carrying 908 segments, this is perfectly legitimate, so long as the receiving TCP 909 doesn't deliver the data to the user until it is clear the data is 910 valid (i.e., the data must be buffered at the receiver until the 911 connection reaches the ESTABLISHED state). The three-way handshake 912 reduces the possibility of false connections. It is the 913 implementation of a trade-off between memory and messages to provide 914 information for this checking. 916 The simplest three-way handshake is shown in Figure 5 below. The 917 figures should be interpreted in the following way. Each line is 918 numbered for reference purposes. Right arrows (-->) indicate 919 departure of a TCP segment from TCP A to TCP B, or arrival of a 920 segment at B from A. Left arrows (<--), indicate the reverse. 921 Ellipsis (...) indicates a segment which is still in the network 922 (delayed). An "XXX" indicates a segment which is lost or rejected. 923 Comments appear in parentheses. TCP states represent the state AFTER 924 the departure or arrival of the segment (whose contents are shown in 925 the center of each line). Segment contents are shown in abbreviated 926 form, with sequence number, control flags, and ACK field. Other 927 fields such as window, addresses, lengths, and text have been left 928 out in the interest of clarity. 930 TCP A TCP B 932 1. CLOSED LISTEN 934 2. SYN-SENT --> --> SYN-RECEIVED 936 3. ESTABLISHED <-- <-- SYN-RECEIVED 938 4. ESTABLISHED --> --> ESTABLISHED 940 5. ESTABLISHED --> --> ESTABLISHED 942 Basic 3-Way Handshake for Connection Synchronization 944 Figure 5 946 In line 2 of Figure 5, TCP A begins by sending a SYN segment 947 indicating that it will use sequence numbers starting with sequence 948 number 100. In line 3, TCP B sends a SYN and acknowledges the SYN it 949 received from TCP A. Note that the acknowledgment field indicates 950 TCP B is now expecting to hear sequence 101, acknowledging the SYN 951 which occupied sequence 100. 953 At line 4, TCP A responds with an empty segment containing an ACK for 954 TCP B's SYN; and in line 5, TCP A sends some data. Note that the 955 sequence number of the segment in line 5 is the same as in line 4 956 because the ACK does not occupy sequence number space (if it did, we 957 would wind up ACKing ACK's!). 959 Simultaneous initiation is only slightly more complex, as is shown in 960 Figure 6. Each TCP cycles from CLOSED to SYN-SENT to SYN-RECEIVED to 961 ESTABLISHED. 963 TCP A TCP B 965 1. CLOSED CLOSED 967 2. SYN-SENT --> ... 969 3. SYN-RECEIVED <-- <-- SYN-SENT 971 4. ... --> SYN-RECEIVED 973 5. SYN-RECEIVED --> ... 975 6. ESTABLISHED <-- <-- SYN-RECEIVED 977 7. ... --> ESTABLISHED 979 Simultaneous Connection Synchronization 981 Figure 6 983 The principle reason for the three-way handshake is to prevent old 984 duplicate connection initiations from causing confusion. To deal 985 with this, a special control message, reset, has been devised. If 986 the receiving TCP is in a non-synchronized state (i.e., SYN-SENT, 987 SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset. 988 If the TCP is in one of the synchronized states (ESTABLISHED, FIN- 989 WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), it 990 aborts the connection and informs its user. We discuss this latter 991 case under "half-open" connections below. 993 TCP A TCP B 995 1. CLOSED LISTEN 997 2. SYN-SENT --> ... 999 3. (duplicate) ... --> SYN-RECEIVED 1001 4. SYN-SENT <-- <-- SYN-RECEIVED 1003 5. SYN-SENT --> --> LISTEN 1005 6. ... --> SYN-RECEIVED 1007 7. SYN-SENT <-- <-- SYN-RECEIVED 1009 8. ESTABLISHED --> --> ESTABLISHED 1011 Recovery from Old Duplicate SYN 1013 Figure 7 1015 As a simple example of recovery from old duplicates, consider 1016 Figure 7. At line 3, an old duplicate SYN arrives at TCP B. TCP B 1017 cannot tell that this is an old duplicate, so it responds normally 1018 (line 4). TCP A detects that the ACK field is incorrect and returns 1019 a RST (reset) with its SEQ field selected to make the segment 1020 believable. TCP B, on receiving the RST, returns to the LISTEN 1021 state. When the original SYN (pun intended) finally arrives at line 1022 6, the synchronization proceeds normally. If the SYN at line 6 had 1023 arrived before the RST, a more complex exchange might have occurred 1024 with RST's sent in both directions. 1026 Half-Open Connections and Other Anomalies 1028 An established connection is said to be "half-open" if one of the 1029 TCPs has closed or aborted the connection at its end without the 1030 knowledge of the other, or if the two ends of the connection have 1031 become desynchronized owing to a crash that resulted in loss of 1032 memory. Such connections will automatically become reset if an 1033 attempt is made to send data in either direction. However, half-open 1034 connections are expected to be unusual, and the recovery procedure is 1035 mildly involved. 1037 If at site A the connection no longer exists, then an attempt by the 1038 user at site B to send any data on it will result in the site B TCP 1039 receiving a reset control message. Such a message indicates to the 1040 site B TCP that something is wrong, and it is expected to abort the 1041 connection. 1043 Assume that two user processes A and B are communicating with one 1044 another when a crash occurs causing loss of memory to A's TCP. 1045 Depending on the operating system supporting A's TCP, it is likely 1046 that some error recovery mechanism exists. When the TCP is up again, 1047 A is likely to start again from the beginning or from a recovery 1048 point. As a result, A will probably try to OPEN the connection again 1049 or try to SEND on the connection it believes open. In the latter 1050 case, it receives the error message "connection not open" from the 1051 local (A's) TCP. In an attempt to establish the connection, A's TCP 1052 will send a segment containing SYN. This scenario leads to the 1053 example shown in Figure 8. After TCP A crashes, the user attempts to 1054 re-open the connection. TCP B, in the meantime, thinks the 1055 connection is open. 1057 TCP A TCP B 1059 1. (CRASH) (send 300,receive 100) 1061 2. CLOSED ESTABLISHED 1063 3. SYN-SENT --> --> (??) 1065 4. (!!) <-- <-- ESTABLISHED 1067 5. SYN-SENT --> --> (Abort!!) 1069 6. SYN-SENT CLOSED 1071 7. SYN-SENT --> --> 1073 Half-Open Connection Discovery 1075 Figure 8 1077 When the SYN arrives at line 3, TCP B, being in a synchronized state, 1078 and the incoming segment outside the window, responds with an 1079 acknowledgment indicating what sequence it next expects to hear (ACK 1080 100). TCP A sees that this segment does not acknowledge anything it 1081 sent and, being unsynchronized, sends a reset (RST) because it has 1082 detected a half-open connection. TCP B aborts at line 5. TCP A will 1083 continue to try to establish the connection; the problem is now 1084 reduced to the basic 3-way handshake of Figure 5. 1086 An interesting alternative case occurs when TCP A crashes and TCP B 1087 tries to send data on what it thinks is a synchronized connection. 1089 This is illustrated in Figure 9. In this case, the data arriving at 1090 TCP A from TCP B (line 2) is unacceptable because no such connection 1091 exists, so TCP A sends a RST. The RST is acceptable so TCP B 1092 processes it and aborts the connection. 1094 TCP A TCP B 1096 1. (CRASH) (send 300,receive 100) 1098 2. (??) <-- <-- ESTABLISHED 1100 3. --> --> (ABORT!!) 1102 Active Side Causes Half-Open Connection Discovery 1104 Figure 9 1106 In Figure 10, we find the two TCPs A and B with passive connections 1107 waiting for SYN. An old duplicate arriving at TCP B (line 2) stirs B 1108 into action. A SYN-ACK is returned (line 3) and causes TCP A to 1109 generate a RST (the ACK in line 3 is not acceptable). TCP B accepts 1110 the reset and returns to its passive LISTEN state. 1112 TCP A TCP B 1114 1. LISTEN LISTEN 1116 2. ... --> SYN-RECEIVED 1118 3. (??) <-- <-- SYN-RECEIVED 1120 4. --> --> (return to LISTEN!) 1122 5. LISTEN LISTEN 1124 Old Duplicate SYN Initiates a Reset on two Passive Sockets 1126 Figure 10 1128 A variety of other cases are possible, all of which are accounted for 1129 by the following rules for RST generation and processing. 1131 Reset Generation 1132 As a general rule, reset (RST) must be sent whenever a segment 1133 arrives which apparently is not intended for the current connection. 1134 A reset must not be sent if it is not clear that this is the case. 1136 There are three groups of states: 1138 1. If the connection does not exist (CLOSED) then a reset is sent 1139 in response to any incoming segment except another reset. In 1140 particular, SYNs addressed to a non-existent connection are 1141 rejected by this means. 1143 If the incoming segment has the ACK bit set, the reset takes its 1144 sequence number from the ACK field of the segment, otherwise the 1145 reset has sequence number zero and the ACK field is set to the sum 1146 of the sequence number and segment length of the incoming segment. 1147 The connection remains in the CLOSED state. 1149 2. If the connection is in any non-synchronized state (LISTEN, 1150 SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges 1151 something not yet sent (the segment carries an unacceptable ACK), 1152 or if an incoming segment has a security level or compartment 1153 which does not exactly match the level and compartment requested 1154 for the connection, a reset is sent. 1156 If our SYN has not been acknowledged and the precedence level of 1157 the incoming segment is higher than the precedence level requested 1158 then either raise the local precedence level (if allowed by the 1159 user and the system) or send a reset; or if the precedence level 1160 of the incoming segment is lower than the precedence level 1161 requested then continue as if the precedence matched exactly (if 1162 the remote TCP cannot raise the precedence level to match ours 1163 this will be detected in the next segment it sends, and the 1164 connection will be terminated then). If our SYN has been 1165 acknowledged (perhaps in this incoming segment) the precedence 1166 level of the incoming segment must match the local precedence 1167 level exactly, if it does not a reset must be sent. 1169 If the incoming segment has an ACK field, the reset takes its 1170 sequence number from the ACK field of the segment, otherwise the 1171 reset has sequence number zero and the ACK field is set to the sum 1172 of the sequence number and segment length of the incoming segment. 1173 The connection remains in the same state. 1175 3. If the connection is in a synchronized state (ESTABLISHED, 1176 FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT), 1177 any unacceptable segment (out of window sequence number or 1178 unacceptable acknowledgment number) must elicit only an empty 1179 acknowledgment segment containing the current send-sequence number 1180 and an acknowledgment indicating the next sequence number expected 1181 to be received, and the connection remains in the same state. 1183 If an incoming segment has a security level, or compartment, or 1184 precedence which does not exactly match the level, and 1185 compartment, and precedence requested for the connection,a reset 1186 is sent and the connection goes to the CLOSED state. The reset 1187 takes its sequence number from the ACK field of the incoming 1188 segment. 1190 Reset Processing 1192 In all states except SYN-SENT, all reset (RST) segments are validated 1193 by checking their SEQ-fields. A reset is valid if its sequence 1194 number is in the window. In the SYN-SENT state (a RST received in 1195 response to an initial SYN), the RST is acceptable if the ACK field 1196 acknowledges the SYN. 1198 The receiver of a RST first validates it, then changes state. If the 1199 receiver was in the LISTEN state, it ignores it. If the receiver was 1200 in SYN-RECEIVED state and had previously been in the LISTEN state, 1201 then the receiver returns to the LISTEN state, otherwise the receiver 1202 aborts the connection and goes to the CLOSED state. If the receiver 1203 was in any other state, it aborts the connection and advises the user 1204 and goes to the CLOSED state. 1206 3.5. Closing a Connection 1208 CLOSE is an operation meaning "I have no more data to send." The 1209 notion of closing a full-duplex connection is subject to ambiguous 1210 interpretation, of course, since it may not be obvious how to treat 1211 the receiving side of the connection. We have chosen to treat CLOSE 1212 in a simplex fashion. The user who CLOSEs may continue to RECEIVE 1213 until he is told that the other side has CLOSED also. Thus, a 1214 program could initiate several SENDs followed by a CLOSE, and then 1215 continue to RECEIVE until signaled that a RECEIVE failed because the 1216 other side has CLOSED. We assume that the TCP will signal a user, 1217 even if no RECEIVEs are outstanding, that the other side has closed, 1218 so the user can terminate his side gracefully. A TCP will reliably 1219 deliver all buffers SENT before the connection was CLOSED so a user 1220 who expects no data in return need only wait to hear the connection 1221 was CLOSED successfully to know that all his data was received at the 1222 destination TCP. Users must keep reading connections they close for 1223 sending until the TCP says no more data. 1225 There are essentially three cases: 1227 1) The user initiates by telling the TCP to CLOSE the connection 1228 2) The remote TCP initiates by sending a FIN control signal 1230 3) Both users CLOSE simultaneously 1232 Case 1: Local user initiates the close 1234 In this case, a FIN segment can be constructed and placed on the 1235 outgoing segment queue. No further SENDs from the user will be 1236 accepted by the TCP, and it enters the FIN-WAIT-1 state. RECEIVEs 1237 are allowed in this state. All segments preceding and including 1238 FIN will be retransmitted until acknowledged. When the other TCP 1239 has both acknowledged the FIN and sent a FIN of its own, the first 1240 TCP can ACK this FIN. Note that a TCP receiving a FIN will ACK 1241 but not send its own FIN until its user has CLOSED the connection 1242 also. 1244 Case 2: TCP receives a FIN from the network 1246 If an unsolicited FIN arrives from the network, the receiving TCP 1247 can ACK it and tell the user that the connection is closing. The 1248 user will respond with a CLOSE, upon which the TCP can send a FIN 1249 to the other TCP after sending any remaining data. The TCP then 1250 waits until its own FIN is acknowledged whereupon it deletes the 1251 connection. If an ACK is not forthcoming, after the user timeout 1252 the connection is aborted and the user is told. 1254 Case 3: both users close simultaneously 1256 A simultaneous CLOSE by users at both ends of a connection causes 1257 FIN segments to be exchanged. When all segments preceding the 1258 FINs have been processed and acknowledged, each TCP can ACK the 1259 FIN it has received. Both will, upon receiving these ACKs, delete 1260 the connection. 1262 TCP A TCP B 1264 1. ESTABLISHED ESTABLISHED 1266 2. (Close) 1267 FIN-WAIT-1 --> --> CLOSE-WAIT 1269 3. FIN-WAIT-2 <-- <-- CLOSE-WAIT 1271 4. (Close) 1272 TIME-WAIT <-- <-- LAST-ACK 1274 5. TIME-WAIT --> --> CLOSED 1276 6. (2 MSL) 1277 CLOSED 1279 Normal Close Sequence 1281 Figure 11 1283 TCP A TCP B 1285 1. ESTABLISHED ESTABLISHED 1287 2. (Close) (Close) 1288 FIN-WAIT-1 --> ... FIN-WAIT-1 1289 <-- <-- 1290 ... --> 1292 3. CLOSING --> ... CLOSING 1293 <-- <-- 1294 ... --> 1296 4. TIME-WAIT TIME-WAIT 1297 (2 MSL) (2 MSL) 1298 CLOSED CLOSED 1300 Simultaneous Close Sequence 1302 Figure 12 1304 3.6. Precedence and Security 1306 The intent is that connection be allowed only between ports operating 1307 with exactly the same security and compartment values and at the 1308 higher of the precedence level requested by the two ports. 1310 The precedence and security parameters used in TCP are exactly those 1311 defined in the Internet Protocol (IP) [2]. Throughout this TCP 1312 specification the term "security/compartment" is intended to indicate 1313 the security parameters used in IP including security, compartment, 1314 user group, and handling restriction. 1316 A connection attempt with mismatched security/compartment values or a 1317 lower precedence value must be rejected by sending a reset. 1318 Rejecting a connection due to too low a precedence only occurs after 1319 an acknowledgment of the SYN has been received. 1321 Note that TCP modules which operate only at the default value of 1322 precedence will still have to check the precedence of incoming 1323 segments and possibly raise the precedence level they use on the 1324 connection. 1326 The security parameters may be used even in a non-secure environment 1327 (the values would indicate unclassified data), thus hosts in non- 1328 secure environments must be prepared to receive the security 1329 parameters, though they need not send them. 1331 3.7. Data Communication 1333 Once the connection is established data is communicated by the 1334 exchange of segments. Because segments may be lost due to errors 1335 (checksum test failure), or network congestion, TCP uses 1336 retransmission (after a timeout) to ensure delivery of every segment. 1337 Duplicate segments may arrive due to network or TCP retransmission. 1338 As discussed in the section on sequence numbers the TCP performs 1339 certain tests on the sequence and acknowledgment numbers in the 1340 segments to verify their acceptability. 1342 The sender of data keeps track of the next sequence number to use in 1343 the variable SND.NXT. The receiver of data keeps track of the next 1344 sequence number to expect in the variable RCV.NXT. The sender of 1345 data keeps track of the oldest unacknowledged sequence number in the 1346 variable SND.UNA. If the data flow is momentarily idle and all data 1347 sent has been acknowledged then the three variables will be equal. 1349 When the sender creates a segment and transmits it the sender 1350 advances SND.NXT. When the receiver accepts a segment it advances 1351 RCV.NXT and sends an acknowledgment. When the data sender receives 1352 an acknowledgment it advances SND.UNA. The extent to which the 1353 values of these variables differ is a measure of the delay in the 1354 communication. The amount by which the variables are advanced is the 1355 length of the data and SYN or FIN flags in the segment. Note that 1356 once in the ESTABLISHED state all segments must carry current 1357 acknowledgment information. 1359 The CLOSE user call implies a push function, as does the FIN control 1360 flag in an incoming segment. 1362 Retransmission Timeout 1364 NOTE: TODO this needs to be updated in light of 1122 4.2.2.15 and 1365 errata 573; this will be done as part of RFC 1122 incorporation into 1366 this document. 1367 Because of the variability of the networks that compose an 1368 internetwork system and the wide range of uses of TCP connections the 1369 retransmission timeout must be dynamically determined. One procedure 1370 for determining a retransmission timeout is given here as an 1371 illustration. 1373 An Example Retransmission Timeout Procedure 1375 Measure the elapsed time between sending a data octet with a 1376 particular sequence number and receiving an acknowledgment that 1377 covers that sequence number (segments sent do not have to match 1378 segments received). This measured elapsed time is the Round Trip 1379 Time (RTT). Next compute a Smoothed Round Trip Time (SRTT) as: 1381 SRTT = ( ALPHA * SRTT ) + ((1-ALPHA) * RTT) 1383 and based on this, compute the retransmission timeout (RTO) as: 1385 RTO = min[UBOUND,max[LBOUND,(BETA*SRTT)]] 1387 where UBOUND is an upper bound on the timeout (e.g., 1 minute), 1388 LBOUND is a lower bound on the timeout (e.g., 1 second), ALPHA is 1389 a smoothing factor (e.g., .8 to .9), and BETA is a delay variance 1390 factor (e.g., 1.3 to 2.0). 1392 The Communication of Urgent Information 1394 As a result of implementation differences and middlebox interactions, 1395 new applications SHOULD NOT employ the TCP urgent mechanism. 1396 However, TCP implementations MUST still include support for the 1397 urgent mechanism. Details can be found in RFC 6093 [5]. 1399 The objective of the TCP urgent mechanism is to allow the sending 1400 user to stimulate the receiving user to accept some urgent data and 1401 to permit the receiving TCP to indicate to the receiving user when 1402 all the currently known urgent data has been received by the user. 1404 This mechanism permits a point in the data stream to be designated as 1405 the end of urgent information. Whenever this point is in advance of 1406 the receive sequence number (RCV.NXT) at the receiving TCP, that TCP 1407 must tell the user to go into "urgent mode"; when the receive 1408 sequence number catches up to the urgent pointer, the TCP must tell 1409 user to go into "normal mode". If the urgent pointer is updated 1410 while the user is in "urgent mode", the update will be invisible to 1411 the user. 1413 The method employs a urgent field which is carried in all segments 1414 transmitted. The URG control flag indicates that the urgent field is 1415 meaningful and must be added to the segment sequence number to yield 1416 the urgent pointer. The absence of this flag indicates that there is 1417 no urgent data outstanding. 1419 To send an urgent indication the user must also send at least one 1420 data octet. If the sending user also indicates a push, timely 1421 delivery of the urgent information to the destination process is 1422 enhanced. 1424 A TCP MUST support a sequence of urgent data of any length. [3] 1426 A TCP MUST inform the application layer asynchronously whenever it 1427 receives an Urgent pointer and there was previously no pending urgent 1428 data, or whenvever the Urgent pointer advances in the data stream. 1429 There MUST be a way for the application to learn how much urgent data 1430 remains to be read from the connection, or at least to determine 1431 whether or not more urgent data remains to be read. [3] 1433 Managing the Window 1435 The window sent in each segment indicates the range of sequence 1436 numbers the sender of the window (the data receiver) is currently 1437 prepared to accept. There is an assumption that this is related to 1438 the currently available data buffer space available for this 1439 connection. 1441 Indicating a large window encourages transmissions. If more data 1442 arrives than can be accepted, it will be discarded. This will result 1443 in excessive retransmissions, adding unnecessarily to the load on the 1444 network and the TCPs. Indicating a small window may restrict the 1445 transmission of data to the point of introducing a round trip delay 1446 between each new segment transmitted. 1448 The mechanisms provided allow a TCP to advertise a large window and 1449 to subsequently advertise a much smaller window without having 1450 accepted that much data. This, so called "shrinking the window," is 1451 strongly discouraged. The robustness principle dictates that TCPs 1452 will not shrink the window themselves, but will be prepared for such 1453 behavior on the part of other TCPs. 1455 The sending TCP must be prepared to accept from the user and send at 1456 least one octet of new data even if the send window is zero. The 1457 sending TCP must regularly retransmit to the receiving TCP even when 1458 the window is zero. Two minutes is recommended for the 1459 retransmission interval when the window is zero. This retransmission 1460 is essential to guarantee that when either TCP has a zero window the 1461 re-opening of the window will be reliably reported to the other. 1463 When the receiving TCP has a zero window and a segment arrives it 1464 must still send an acknowledgment showing its next expected sequence 1465 number and current window (zero). 1467 The sending TCP packages the data to be transmitted into segments 1468 which fit the current window, and may repackage segments on the 1469 retransmission queue. Such repackaging is not required, but may be 1470 helpful. 1472 In a connection with a one-way data flow, the window information will 1473 be carried in acknowledgment segments that all have the same sequence 1474 number so there will be no way to reorder them if they arrive out of 1475 order. This is not a serious problem, but it will allow the window 1476 information to be on occasion temporarily based on old reports from 1477 the data receiver. A refinement to avoid this problem is to act on 1478 the window information from segments that carry the highest 1479 acknowledgment number (that is segments with acknowledgment number 1480 equal or greater than the highest previously received). 1482 The window management procedure has significant influence on the 1483 communication performance. The following comments are suggestions to 1484 implementers. 1486 Window Management Suggestions 1488 Allocating a very small window causes data to be transmitted in 1489 many small segments when better performance is achieved using 1490 fewer large segments. 1492 One suggestion for avoiding small windows is for the receiver to 1493 defer updating a window until the additional allocation is at 1494 least X percent of the maximum allocation possible for the 1495 connection (where X might be 20 to 40). 1497 Another suggestion is for the sender to avoid sending small 1498 segments by waiting until the window is large enough before 1499 sending data. If the user signals a push function then the data 1500 must be sent even if it is a small segment. 1502 Note that the acknowledgments should not be delayed or unnecessary 1503 retransmissions will result. One strategy would be to send an 1504 acknowledgment when a small segment arrives (with out updating the 1505 window information), and then to send another acknowledgment with 1506 new window information when the window is larger. 1508 The segment sent to probe a zero window may also begin a break up 1509 of transmitted data into smaller and smaller segments. If a 1510 segment containing a single data octet sent to probe a zero window 1511 is accepted, it consumes one octet of the window now available. 1512 If the sending TCP simply sends as much as it can whenever the 1513 window is non zero, the transmitted data will be broken into 1514 alternating big and small segments. As time goes on, occasional 1515 pauses in the receiver making window allocation available will 1516 result in breaking the big segments into a small and not quite so 1517 big pair. And after a while the data transmission will be in 1518 mostly small segments. 1520 The suggestion here is that the TCP implementations need to 1521 actively attempt to combine small window allocations into larger 1522 windows, since the mechanisms for managing the window tend to lead 1523 to many small windows in the simplest minded implementations. 1525 3.8. Interfaces 1527 There are of course two interfaces of concern: the user/TCP interface 1528 and the TCP/lower-level interface. We have a fairly elaborate model 1529 of the user/TCP interface, but the interface to the lower level 1530 protocol module is left unspecified here, since it will be specified 1531 in detail by the specification of the lower level protocol. For the 1532 case that the lower level is IP we note some of the parameter values 1533 that TCPs might use. 1535 3.8.1. User/TCP Interface 1537 The following functional description of user commands to the TCP is, 1538 at best, fictional, since every operating system will have different 1539 facilities. Consequently, we must warn readers that different TCP 1540 implementations may have different user interfaces. However, all 1541 TCPs must provide a certain minimum set of services to guarantee that 1542 all TCP implementations can support the same protocol hierarchy. 1543 This section specifies the functional interfaces required of all TCP 1544 implementations. 1546 TCP User Commands 1548 The following sections functionally characterize a USER/TCP 1549 interface. The notation used is similar to most procedure or 1550 function calls in high level languages, but this usage is not 1551 meant to rule out trap type service calls (e.g., SVCs, UUOs, 1552 EMTs). 1554 The user commands described below specify the basic functions the 1555 TCP must perform to support interprocess communication. 1556 Individual implementations must define their own exact format, and 1557 may provide combinations or subsets of the basic functions in 1558 single calls. In particular, some implementations may wish to 1559 automatically OPEN a connection on the first SEND or RECEIVE 1560 issued by the user for a given connection. 1562 In providing interprocess communication facilities, the TCP must 1563 not only accept commands, but must also return information to the 1564 processes it serves. The latter consists of: 1566 (a) general information about a connection (e.g., interrupts, 1567 remote close, binding of unspecified foreign socket). 1569 (b) replies to specific user commands indicating success or 1570 various types of failure. 1572 Open 1574 Format: OPEN (local port, foreign socket, active/passive [, 1575 timeout] [, precedence] [, security/compartment] [, options]) 1576 -> local connection name 1578 We assume that the local TCP is aware of the identity of the 1579 processes it serves and will check the authority of the process 1580 to use the connection specified. Depending upon the 1581 implementation of the TCP, the local network and TCP 1582 identifiers for the source address will either be supplied by 1583 the TCP or the lower level protocol (e.g., IP). These 1584 considerations are the result of concern about security, to the 1585 extent that no TCP be able to masquerade as another one, and so 1586 on. Similarly, no process can masquerade as another without 1587 the collusion of the TCP. 1589 If the active/passive flag is set to passive, then this is a 1590 call to LISTEN for an incoming connection. A passive open may 1591 have either a fully specified foreign socket to wait for a 1592 particular connection or an unspecified foreign socket to wait 1593 for any call. A fully specified passive call can be made 1594 active by the subsequent execution of a SEND. 1596 A transmission control block (TCB) is created and partially 1597 filled in with data from the OPEN command parameters. 1599 On an active OPEN command, the TCP will begin the procedure to 1600 synchronize (i.e., establish) the connection at once. 1602 The timeout, if present, permits the caller to set up a timeout 1603 for all data submitted to TCP. If data is not successfully 1604 delivered to the destination within the timeout period, the TCP 1605 will abort the connection. The present global default is five 1606 minutes. 1608 The TCP or some component of the operating system will verify 1609 the users authority to open a connection with the specified 1610 precedence or security/compartment. The absence of precedence 1611 or security/compartment specification in the OPEN call 1612 indicates the default values must be used. 1614 TCP will accept incoming requests as matching only if the 1615 security/compartment information is exactly the same and only 1616 if the precedence is equal to or higher than the precedence 1617 requested in the OPEN call. 1619 The precedence for the connection is the higher of the values 1620 requested in the OPEN call and received from the incoming 1621 request, and fixed at that value for the life of the 1622 connection.Implementers may want to give the user control of 1623 this precedence negotiation. For example, the user might be 1624 allowed to specify that the precedence must be exactly matched, 1625 or that any attempt to raise the precedence be confirmed by the 1626 user. 1628 A local connection name will be returned to the user by the 1629 TCP. The local connection name can then be used as a short 1630 hand term for the connection defined by the pair. 1633 Send 1635 Format: SEND (local connection name, buffer address, byte 1636 count, PUSH flag, URGENT flag [,timeout]) 1638 This call causes the data contained in the indicated user 1639 buffer to be sent on the indicated connection. If the 1640 connection has not been opened, the SEND is considered an 1641 error. Some implementations may allow users to SEND first; in 1642 which case, an automatic OPEN would be done. If the calling 1643 process is not authorized to use this connection, an error is 1644 returned. 1646 If the PUSH flag is set, the data must be transmitted promptly 1647 to the receiver, and the PUSH bit will be set in the last TCP 1648 segment created from the buffer. If the PUSH flag is not set, 1649 the data may be combined with data from subsequent SENDs for 1650 transmission efficiency. 1652 New applications SHOULD NOT set the URGENT flag [5] due to 1653 implementation differences and middlebox issues. 1655 If the URGENT flag is set, segments sent to the destination TCP 1656 will have the urgent pointer set. The receiving TCP will 1657 signal the urgent condition to the receiving process if the 1658 urgent pointer indicates that data preceding the urgent pointer 1659 has not been consumed by the receiving process. The purpose of 1660 urgent is to stimulate the receiver to process the urgent data 1661 and to indicate to the receiver when all the currently known 1662 urgent data has been received. The number of times the sending 1663 user's TCP signals urgent will not necessarily be equal to the 1664 number of times the receiving user will be notified of the 1665 presence of urgent data. 1667 If no foreign socket was specified in the OPEN, but the 1668 connection is established (e.g., because a LISTENing connection 1669 has become specific due to a foreign segment arriving for the 1670 local socket), then the designated buffer is sent to the 1671 implied foreign socket. Users who make use of OPEN with an 1672 unspecified foreign socket can make use of SEND without ever 1673 explicitly knowing the foreign socket address. 1675 However, if a SEND is attempted before the foreign socket 1676 becomes specified, an error will be returned. Users can use 1677 the STATUS call to determine the status of the connection. In 1678 some implementations the TCP may notify the user when an 1679 unspecified socket is bound. 1681 If a timeout is specified, the current user timeout for this 1682 connection is changed to the new one. 1684 In the simplest implementation, SEND would not return control 1685 to the sending process until either the transmission was 1686 complete or the timeout had been exceeded. However, this 1687 simple method is both subject to deadlocks (for example, both 1688 sides of the connection might try to do SENDs before doing any 1689 RECEIVEs) and offers poor performance, so it is not 1690 recommended. A more sophisticated implementation would return 1691 immediately to allow the process to run concurrently with 1692 network I/O, and, furthermore, to allow multiple SENDs to be in 1693 progress. Multiple SENDs are served in first come, first 1694 served order, so the TCP will queue those it cannot service 1695 immediately. 1697 We have implicitly assumed an asynchronous user interface in 1698 which a SEND later elicits some kind of SIGNAL or pseudo- 1699 interrupt from the serving TCP. An alternative is to return a 1700 response immediately. For instance, SENDs might return 1701 immediate local acknowledgment, even if the segment sent had 1702 not been acknowledged by the distant TCP. We could 1703 optimistically assume eventual success. If we are wrong, the 1704 connection will close anyway due to the timeout. In 1705 implementations of this kind (synchronous), there will still be 1706 some asynchronous signals, but these will deal with the 1707 connection itself, and not with specific segments or buffers. 1709 In order for the process to distinguish among error or success 1710 indications for different SENDs, it might be appropriate for 1711 the buffer address to be returned along with the coded response 1712 to the SEND request. TCP-to-user signals are discussed below, 1713 indicating the information which should be returned to the 1714 calling process. 1716 Receive 1718 Format: RECEIVE (local connection name, buffer address, byte 1719 count) -> byte count, urgent flag, push flag 1721 This command allocates a receiving buffer associated with the 1722 specified connection. If no OPEN precedes this command or the 1723 calling process is not authorized to use this connection, an 1724 error is returned. 1726 In the simplest implementation, control would not return to the 1727 calling program until either the buffer was filled, or some 1728 error occurred, but this scheme is highly subject to deadlocks. 1729 A more sophisticated implementation would permit several 1730 RECEIVEs to be outstanding at once. These would be filled as 1731 segments arrive. This strategy permits increased throughput at 1732 the cost of a more elaborate scheme (possibly asynchronous) to 1733 notify the calling program that a PUSH has been seen or a 1734 buffer filled. 1736 If enough data arrive to fill the buffer before a PUSH is seen, 1737 the PUSH flag will not be set in the response to the RECEIVE. 1738 The buffer will be filled with as much data as it can hold. If 1739 a PUSH is seen before the buffer is filled the buffer will be 1740 returned partially filled and PUSH indicated. 1742 If there is urgent data the user will have been informed as 1743 soon as it arrived via a TCP-to-user signal. The receiving 1744 user should thus be in "urgent mode". If the URGENT flag is 1745 on, additional urgent data remains. If the URGENT flag is off, 1746 this call to RECEIVE has returned all the urgent data, and the 1747 user may now leave "urgent mode". Note that data following the 1748 urgent pointer (non-urgent data) cannot be delivered to the 1749 user in the same buffer with preceding urgent data unless the 1750 boundary is clearly marked for the user. 1752 To distinguish among several outstanding RECEIVEs and to take 1753 care of the case that a buffer is not completely filled, the 1754 return code is accompanied by both a buffer pointer and a byte 1755 count indicating the actual length of the data received. 1757 Alternative implementations of RECEIVE might have the TCP 1758 allocate buffer storage, or the TCP might share a ring buffer 1759 with the user. 1761 Close 1763 Format: CLOSE (local connection name) 1765 This command causes the connection specified to be closed. If 1766 the connection is not open or the calling process is not 1767 authorized to use this connection, an error is returned. 1768 Closing connections is intended to be a graceful operation in 1769 the sense that outstanding SENDs will be transmitted (and 1770 retransmitted), as flow control permits, until all have been 1771 serviced. Thus, it should be acceptable to make several SEND 1772 calls, followed by a CLOSE, and expect all the data to be sent 1773 to the destination. It should also be clear that users should 1774 continue to RECEIVE on CLOSING connections, since the other 1775 side may be trying to transmit the last of its data. Thus, 1776 CLOSE means "I have no more to send" but does not mean "I will 1777 not receive any more." It may happen (if the user level 1778 protocol is not well thought out) that the closing side is 1779 unable to get rid of all its data before timing out. In this 1780 event, CLOSE turns into ABORT, and the closing TCP gives up. 1782 The user may CLOSE the connection at any time on his own 1783 initiative, or in response to various prompts from the TCP 1784 (e.g., remote close executed, transmission timeout exceeded, 1785 destination inaccessible). 1787 Because closing a connection requires communication with the 1788 foreign TCP, connections may remain in the closing state for a 1789 short time. Attempts to reopen the connection before the TCP 1790 replies to the CLOSE command will result in error responses. 1792 Close also implies push function. 1794 Status 1796 Format: STATUS (local connection name) -> status data 1798 This is an implementation dependent user command and could be 1799 excluded without adverse effect. Information returned would 1800 typically come from the TCB associated with the connection. 1802 This command returns a data block containing the following 1803 information: 1805 local socket, 1806 foreign socket, 1807 local connection name, 1808 receive window, 1809 send window, 1810 connection state, 1811 number of buffers awaiting acknowledgment, 1812 number of buffers pending receipt, 1813 urgent state, 1814 precedence, 1815 security/compartment, 1816 and transmission timeout. 1818 Depending on the state of the connection, or on the 1819 implementation itself, some of this information may not be 1820 available or meaningful. If the calling process is not 1821 authorized to use this connection, an error is returned. This 1822 prevents unauthorized processes from gaining information about 1823 a connection. 1825 Abort 1827 Format: ABORT (local connection name) 1829 This command causes all pending SENDs and RECEIVES to be 1830 aborted, the TCB to be removed, and a special RESET message to 1831 be sent to the TCP on the other side of the connection. 1832 Depending on the implementation, users may receive abort 1833 indications for each outstanding SEND or RECEIVE, or may simply 1834 receive an ABORT-acknowledgment. 1836 TCP-to-User Messages 1837 It is assumed that the operating system environment provides a 1838 means for the TCP to asynchronously signal the user program. 1839 When the TCP does signal a user program, certain information is 1840 passed to the user. Often in the specification the information 1841 will be an error message. In other cases there will be 1842 information relating to the completion of processing a SEND or 1843 RECEIVE or other user call. 1845 The following information is provided: 1847 Local Connection Name Always 1848 Response String Always 1849 Buffer Address Send & Receive 1850 Byte count (counts bytes received) Receive 1851 Push flag Receive 1852 Urgent flag Receive 1854 3.8.2. TCP/Lower-Level Interface 1856 The TCP calls on a lower level protocol module to actually send and 1857 receive information over a network. One case is that of the ARPA 1858 internetwork system where the lower level module is the Internet 1859 Protocol (IP) [2]. 1861 If the lower level protocol is IP it provides arguments for a type of 1862 service and for a time to live. TCP uses the following settings for 1863 these parameters: 1865 Type of Service = Precedence: given by user, Delay: normal, 1866 Throughput: normal, Reliability: normal; or binary XXX00000, where 1867 XXX are the three bits determining precedence, e.g. 000 means 1868 routine precedence. 1870 Time to Live = one minute, or 00111100. 1872 Note that the assumed maximum segment lifetime is two minutes. 1873 Here we explicitly ask that a segment be destroyed if it cannot 1874 be delivered by the internet system within one minute. 1876 If the lower level is IP (or other protocol that provides this 1877 feature) and source routing is used, the interface must allow the 1878 route information to be communicated. This is especially important 1879 so that the source and destination addresses used in the TCP checksum 1880 be the originating source and ultimate destination. It is also 1881 important to preserve the return route to answer connection requests. 1883 Any lower level protocol will have to provide the source address, 1884 destination address, and protocol fields, and some way to determine 1885 the "TCP length", both to provide the functional equivalent service 1886 of IP and to be used in the TCP checksum. 1888 3.9. Event Processing 1890 The processing depicted in this section is an example of one possible 1891 implementation. Other implementations may have slightly different 1892 processing sequences, but they should differ from those in this 1893 section only in detail, not in substance. 1895 The activity of the TCP can be characterized as responding to events. 1896 The events that occur can be cast into three categories: user calls, 1897 arriving segments, and timeouts. This section describes the 1898 processing the TCP does in response to each of the events. In many 1899 cases the processing required depends on the state of the connection. 1901 Events that occur: 1903 User Calls 1905 OPEN 1906 SEND 1907 RECEIVE 1908 CLOSE 1909 ABORT 1910 STATUS 1912 Arriving Segments 1914 SEGMENT ARRIVES 1916 Timeouts 1918 USER TIMEOUT 1919 RETRANSMISSION TIMEOUT 1920 TIME-WAIT TIMEOUT 1922 The model of the TCP/user interface is that user commands receive an 1923 immediate return and possibly a delayed response via an event or 1924 pseudo interrupt. In the following descriptions, the term "signal" 1925 means cause a delayed response. 1927 Error responses are given as character strings. For example, user 1928 commands referencing connections that do not exist receive "error: 1929 connection not open". 1931 Please note in the following that all arithmetic on sequence numbers, 1932 acknowledgment numbers, windows, et cetera, is modulo 2**32 the size 1933 of the sequence number space. Also note that "=<" means less than or 1934 equal to (modulo 2**32). 1936 A natural way to think about processing incoming segments is to 1937 imagine that they are first tested for proper sequence number (i.e., 1938 that their contents lie in the range of the expected "receive window" 1939 in the sequence number space) and then that they are generally queued 1940 and processed in sequence number order. 1942 When a segment overlaps other already received segments we 1943 reconstruct the segment to contain just the new data, and adjust the 1944 header fields to be consistent. 1946 Note that if no state change is mentioned the TCP stays in the same 1947 state. 1949 OPEN Call 1951 CLOSED STATE (i.e., TCB does not exist) 1953 Create a new transmission control block (TCB) to hold 1954 connection state information. Fill in local socket identifier, 1955 foreign socket, precedence, security/compartment, and user 1956 timeout information. Note that some parts of the foreign 1957 socket may be unspecified in a passive OPEN and are to be 1958 filled in by the parameters of the incoming SYN segment. 1959 Verify the security and precedence requested are allowed for 1960 this user, if not return "error: precedence not allowed" or 1961 "error: security/compartment not allowed." If passive enter 1962 the LISTEN state and return. If active and the foreign socket 1963 is unspecified, return "error: foreign socket unspecified"; if 1964 active and the foreign socket is specified, issue a SYN 1965 segment. An initial send sequence number (ISS) is selected. A 1966 SYN segment of the form is sent. Set 1967 SND.UNA to ISS, SND.NXT to ISS+1, enter SYN-SENT state, and 1968 return. 1970 If the caller does not have access to the local socket 1971 specified, return "error: connection illegal for this process". 1972 If there is no room to create a new connection, return "error: 1973 insufficient resources". 1975 LISTEN STATE 1977 If active and the foreign socket is specified, then change the 1978 connection from passive to active, select an ISS. Send a SYN 1979 segment, set SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT 1980 state. Data associated with SEND may be sent with SYN segment 1981 or queued for transmission after entering ESTABLISHED state. 1982 The urgent bit if requested in the command must be sent with 1983 the data segments sent as a result of this command. If there 1984 is no room to queue the request, respond with "error: 1985 insufficient resources". If Foreign socket was not specified, 1986 then return "error: foreign socket unspecified". 1988 SYN-SENT STATE 1989 SYN-RECEIVED STATE 1990 ESTABLISHED STATE 1991 FIN-WAIT-1 STATE 1992 FIN-WAIT-2 STATE 1993 CLOSE-WAIT STATE 1994 CLOSING STATE 1995 LAST-ACK STATE 1996 TIME-WAIT STATE 1998 Return "error: connection already exists". 2000 SEND Call 2002 CLOSED STATE (i.e., TCB does not exist) 2004 If the user does not have access to such a connection, then 2005 return "error: connection illegal for this process". 2007 Otherwise, return "error: connection does not exist". 2009 LISTEN STATE 2011 If the foreign socket is specified, then change the connection 2012 from passive to active, select an ISS. Send a SYN segment, set 2013 SND.UNA to ISS, SND.NXT to ISS+1. Enter SYN-SENT state. Data 2014 associated with SEND may be sent with SYN segment or queued for 2015 transmission after entering ESTABLISHED state. The urgent bit 2016 if requested in the command must be sent with the data segments 2017 sent as a result of this command. If there is no room to queue 2018 the request, respond with "error: insufficient resources". If 2019 Foreign socket was not specified, then return "error: foreign 2020 socket unspecified". 2022 SYN-SENT STATE 2023 SYN-RECEIVED STATE 2025 Queue the data for transmission after entering ESTABLISHED 2026 state. If no space to queue, respond with "error: insufficient 2027 resources". 2029 ESTABLISHED STATE 2030 CLOSE-WAIT STATE 2032 Segmentize the buffer and send it with a piggybacked 2033 acknowledgment (acknowledgment value = RCV.NXT). If there is 2034 insufficient space to remember this buffer, simply return 2035 "error: insufficient resources". 2037 If the urgent flag is set, then SND.UP <- SND.NXT and set the 2038 urgent pointer in the outgoing segments. 2040 FIN-WAIT-1 STATE 2041 FIN-WAIT-2 STATE 2042 CLOSING STATE 2043 LAST-ACK STATE 2044 TIME-WAIT STATE 2046 Return "error: connection closing" and do not service request. 2048 RECEIVE Call 2050 CLOSED STATE (i.e., TCB does not exist) 2052 If the user does not have access to such a connection, return 2053 "error: connection illegal for this process". 2055 Otherwise return "error: connection does not exist". 2057 LISTEN STATE 2058 SYN-SENT STATE 2059 SYN-RECEIVED STATE 2061 Queue for processing after entering ESTABLISHED state. If 2062 there is no room to queue this request, respond with "error: 2063 insufficient resources". 2065 ESTABLISHED STATE 2066 FIN-WAIT-1 STATE 2067 FIN-WAIT-2 STATE 2069 If insufficient incoming segments are queued to satisfy the 2070 request, queue the request. If there is no queue space to 2071 remember the RECEIVE, respond with "error: insufficient 2072 resources". 2074 Reassemble queued incoming segments into receive buffer and 2075 return to user. Mark "push seen" (PUSH) if this is the case. 2077 If RCV.UP is in advance of the data currently being passed to 2078 the user notify the user of the presence of urgent data. 2080 When the TCP takes responsibility for delivering data to the 2081 user that fact must be communicated to the sender via an 2082 acknowledgment. The formation of such an acknowledgment is 2083 described below in the discussion of processing an incoming 2084 segment. 2086 CLOSE-WAIT STATE 2088 Since the remote side has already sent FIN, RECEIVEs must be 2089 satisfied by text already on hand, but not yet delivered to the 2090 user. If no text is awaiting delivery, the RECEIVE will get a 2091 "error: connection closing" response. Otherwise, any remaining 2092 text can be used to satisfy the RECEIVE. 2094 CLOSING STATE 2095 LAST-ACK STATE 2096 TIME-WAIT STATE 2098 Return "error: connection closing". 2100 CLOSE Call 2102 CLOSED STATE (i.e., TCB does not exist) 2104 If the user does not have access to such a connection, return 2105 "error: connection illegal for this process". 2107 Otherwise, return "error: connection does not exist". 2109 LISTEN STATE 2111 Any outstanding RECEIVEs are returned with "error: closing" 2112 responses. Delete TCB, enter CLOSED state, and return. 2114 SYN-SENT STATE 2116 Delete the TCB and return "error: closing" responses to any 2117 queued SENDs, or RECEIVEs. 2119 SYN-RECEIVED STATE 2121 If no SENDs have been issued and there is no pending data to 2122 send, then form a FIN segment and send it, and enter FIN-WAIT-1 2123 state; otherwise queue for processing after entering 2124 ESTABLISHED state. 2126 ESTABLISHED STATE 2128 Queue this until all preceding SENDs have been segmentized, 2129 then form a FIN segment and send it. In any case, enter FIN- 2130 WAIT-1 state. 2132 FIN-WAIT-1 STATE 2133 FIN-WAIT-2 STATE 2135 Strictly speaking, this is an error and should receive a 2136 "error: connection closing" response. An "ok" response would 2137 be acceptable, too, as long as a second FIN is not emitted (the 2138 first FIN may be retransmitted though). 2140 CLOSE-WAIT STATE 2142 Queue this request until all preceding SENDs have been 2143 segmentized; then send a FIN segment, enter LAST-ACK state. 2145 CLOSING STATE 2146 LAST-ACK STATE 2147 TIME-WAIT STATE 2148 Respond with "error: connection closing". 2150 ABORT Call 2152 CLOSED STATE (i.e., TCB does not exist) 2154 If the user should not have access to such a connection, return 2155 "error: connection illegal for this process". 2157 Otherwise return "error: connection does not exist". 2159 LISTEN STATE 2161 Any outstanding RECEIVEs should be returned with "error: 2162 connection reset" responses. Delete TCB, enter CLOSED state, 2163 and return. 2165 SYN-SENT STATE 2167 All queued SENDs and RECEIVEs should be given "connection 2168 reset" notification, delete the TCB, enter CLOSED state, and 2169 return. 2171 SYN-RECEIVED STATE 2172 ESTABLISHED STATE 2173 FIN-WAIT-1 STATE 2174 FIN-WAIT-2 STATE 2175 CLOSE-WAIT STATE 2177 Send a reset segment: 2179 2181 All queued SENDs and RECEIVEs should be given "connection 2182 reset" notification; all segments queued for transmission 2183 (except for the RST formed above) or retransmission should be 2184 flushed, delete the TCB, enter CLOSED state, and return. 2186 CLOSING STATE LAST-ACK STATE TIME-WAIT STATE 2188 Respond with "ok" and delete the TCB, enter CLOSED state, and 2189 return. 2191 STATUS Call 2193 CLOSED STATE (i.e., TCB does not exist) 2195 If the user should not have access to such a connection, return 2196 "error: connection illegal for this process". 2198 Otherwise return "error: connection does not exist". 2200 LISTEN STATE 2202 Return "state = LISTEN", and the TCB pointer. 2204 SYN-SENT STATE 2206 Return "state = SYN-SENT", and the TCB pointer. 2208 SYN-RECEIVED STATE 2210 Return "state = SYN-RECEIVED", and the TCB pointer. 2212 ESTABLISHED STATE 2214 Return "state = ESTABLISHED", and the TCB pointer. 2216 FIN-WAIT-1 STATE 2218 Return "state = FIN-WAIT-1", and the TCB pointer. 2220 FIN-WAIT-2 STATE 2222 Return "state = FIN-WAIT-2", and the TCB pointer. 2224 CLOSE-WAIT STATE 2226 Return "state = CLOSE-WAIT", and the TCB pointer. 2228 CLOSING STATE 2230 Return "state = CLOSING", and the TCB pointer. 2232 LAST-ACK STATE 2234 Return "state = LAST-ACK", and the TCB pointer. 2236 TIME-WAIT STATE 2238 Return "state = TIME-WAIT", and the TCB pointer. 2240 SEGMENT ARRIVES 2242 If the state is CLOSED (i.e., TCB does not exist) then 2244 all data in the incoming segment is discarded. An incoming 2245 segment containing a RST is discarded. An incoming segment not 2246 containing a RST causes a RST to be sent in response. The 2247 acknowledgment and sequence field values are selected to make 2248 the reset sequence acceptable to the TCP that sent the 2249 offending segment. 2251 If the ACK bit is off, sequence number zero is used, 2253 2255 If the ACK bit is on, 2257 2259 Return. 2261 If the state is LISTEN then 2263 first check for an RST 2265 An incoming RST should be ignored. Return. 2267 second check for an ACK 2269 Any acknowledgment is bad if it arrives on a connection 2270 still in the LISTEN state. An acceptable reset segment 2271 should be formed for any arriving ACK-bearing segment. The 2272 RST should be formatted as follows: 2274 2276 Return. 2278 third check for a SYN 2280 If the SYN bit is set, check the security. If the security/ 2281 compartment on the incoming segment does not exactly match 2282 the security/compartment in the TCB then send a reset and 2283 return. 2285 2287 If the SEG.PRC is greater than the TCB.PRC then if allowed 2288 by the user and the system set TCB.PRC<-SEG.PRC, if not 2289 allowed send a reset and return. 2291 2293 If the SEG.PRC is less than the TCB.PRC then continue. 2295 Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any 2296 other control or text should be queued for processing later. 2297 ISS should be selected and a SYN segment sent of the form: 2299 2301 SND.NXT is set to ISS+1 and SND.UNA to ISS. The connection 2302 state should be changed to SYN-RECEIVED. Note that any 2303 other incoming control or data (combined with SYN) will be 2304 processed in the SYN-RECEIVED state, but processing of SYN 2305 and ACK should not be repeated. If the listen was not fully 2306 specified (i.e., the foreign socket was not fully 2307 specified), then the unspecified fields should be filled in 2308 now. 2310 fourth other text or control 2312 Any other control or text-bearing segment (not containing 2313 SYN) must have an ACK and thus would be discarded by the ACK 2314 processing. An incoming RST segment could not be valid, 2315 since it could not have been sent in response to anything 2316 sent by this incarnation of the connection. So you are 2317 unlikely to get here, but if you do, drop the segment, and 2318 return. 2320 If the state is SYN-SENT then 2322 first check the ACK bit 2324 If the ACK bit is set 2326 If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, send a reset 2327 (unless the RST bit is set, if so drop the segment and 2328 return) 2330 2332 and discard the segment. Return. 2334 If SND.UNA < SEG.ACK =< SND.NXT then the ACK is 2335 acceptable. (TODO: in processing Errata ID 3300, it was 2336 noted that some stacks in the wild that do not send data 2337 on the SYN are just checking that SEG.ACK == SND.NXT ... 2338 think about whether anything should be said about that 2339 here) 2341 second check the RST bit 2343 If the RST bit is set 2345 If the ACK was acceptable then signal the user "error: 2346 connection reset", drop the segment, enter CLOSED state, 2347 delete TCB, and return. Otherwise (no ACK) drop the 2348 segment and return. 2350 third check the security and precedence 2352 If the security/compartment in the segment does not exactly 2353 match the security/compartment in the TCB, send a reset 2355 If there is an ACK 2357 2359 Otherwise 2361 2363 If there is an ACK 2365 The precedence in the segment must match the precedence 2366 in the TCB, if not, send a reset 2368 2370 If there is no ACK 2372 If the precedence in the segment is higher than the 2373 precedence in the TCB then if allowed by the user and the 2374 system raise the precedence in the TCB to that in the 2375 segment, if not allowed to raise the prec then send a 2376 reset. 2378 2380 If the precedence in the segment is lower than the 2381 precedence in the TCB continue. 2383 If a reset was sent, discard the segment and return. 2385 fourth check the SYN bit 2387 This step should be reached only if the ACK is ok, or there 2388 is no ACK, and it the segment did not contain a RST. 2390 If the SYN bit is on and the security/compartment and 2391 precedence are acceptable then, RCV.NXT is set to SEG.SEQ+1, 2392 IRS is set to SEG.SEQ. SND.UNA should be advanced to equal 2393 SEG.ACK (if there is an ACK), and any segments on the 2394 retransmission queue which are thereby acknowledged should 2395 be removed. 2397 If SND.UNA > ISS (our SYN has been ACKed), change the 2398 connection state to ESTABLISHED, form an ACK segment 2400 2402 and send it. Data or controls which were queued for 2403 transmission may be included. If there are other controls 2404 or text in the segment then continue processing at the sixth 2405 step below where the URG bit is checked, otherwise return. 2407 Otherwise enter SYN-RECEIVED, form a SYN,ACK segment 2409 2411 and send it. Set the variables: 2413 SND.WND <- SEG.WND 2414 SND.WL1 <- SEG.SEQ 2415 SND.WL2 <- SEG.ACK 2417 If there are other controls or text in the segment, queue 2418 them for processing after the ESTABLISHED state has been 2419 reached, return. 2421 fifth, if neither of the SYN or RST bits is set then drop the 2422 segment and return. 2424 Otherwise, 2426 first check sequence number 2428 SYN-RECEIVED STATE 2429 ESTABLISHED STATE 2430 FIN-WAIT-1 STATE 2431 FIN-WAIT-2 STATE 2432 CLOSE-WAIT STATE 2433 CLOSING STATE 2434 LAST-ACK STATE 2435 TIME-WAIT STATE 2437 Segments are processed in sequence. Initial tests on 2438 arrival are used to discard old duplicates, but further 2439 processing is done in SEG.SEQ order. If a segment's 2440 contents straddle the boundary between old and new, only the 2441 new parts should be processed. 2443 There are four cases for the acceptability test for an 2444 incoming segment: 2446 Segment Receive Test 2447 Length Window 2448 ------- ------- ------------------------------------------- 2450 0 0 SEG.SEQ = RCV.NXT 2452 0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 2454 >0 0 not acceptable 2456 >0 >0 RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND 2457 or RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND 2459 If the RCV.WND is zero, no segments will be acceptable, but 2460 special allowance should be made to accept valid ACKs, URGs 2461 and RSTs. 2463 If an incoming segment is not acceptable, an acknowledgment 2464 should be sent in reply (unless the RST bit is set, if so 2465 drop the segment and return): 2467 2469 After sending the acknowledgment, drop the unacceptable 2470 segment and return. 2472 In the following it is assumed that the segment is the 2473 idealized segment that begins at RCV.NXT and does not exceed 2474 the window. One could tailor actual segments to fit this 2475 assumption by trimming off any portions that lie outside the 2476 window (including SYN and FIN), and only processing further 2477 if the segment then begins at RCV.NXT. Segments with higher 2478 beginning sequence numbers should be held for later 2479 processing. 2481 second check the RST bit, 2483 SYN-RECEIVED STATE 2485 If the RST bit is set 2487 If this connection was initiated with a passive OPEN 2488 (i.e., came from the LISTEN state), then return this 2489 connection to LISTEN state and return. The user need 2490 not be informed. If this connection was initiated 2491 with an active OPEN (i.e., came from SYN-SENT state) 2492 then the connection was refused, signal the user 2493 "connection refused". In either case, all segments on 2494 the retransmission queue should be removed. And in 2495 the active OPEN case, enter the CLOSED state and 2496 delete the TCB, and return. 2498 ESTABLISHED 2499 FIN-WAIT-1 2500 FIN-WAIT-2 2501 CLOSE-WAIT 2503 If the RST bit is set then, any outstanding RECEIVEs and 2504 SEND should receive "reset" responses. All segment 2505 queues should be flushed. Users should also receive an 2506 unsolicited general "connection reset" signal. Enter the 2507 CLOSED state, delete the TCB, and return. 2509 CLOSING STATE 2510 LAST-ACK STATE 2511 TIME-WAIT 2513 If the RST bit is set then, enter the CLOSED state, 2514 delete the TCB, and return. 2516 third check security and precedence 2518 SYN-RECEIVED 2520 If the security/compartment and precedence in the segment 2521 do not exactly match the security/compartment and 2522 precedence in the TCB then send a reset, and return. 2524 ESTABLISHED 2525 FIN-WAIT-1 2526 FIN-WAIT-2 2527 CLOSE-WAIT 2528 CLOSING 2529 LAST-ACK 2530 TIME-WAIT 2532 If the security/compartment and precedence in the segment 2533 do not exactly match the security/compartment and 2534 precedence in the TCB then send a reset, any outstanding 2535 RECEIVEs and SEND should receive "reset" responses. All 2536 segment queues should be flushed. Users should also 2537 receive an unsolicited general "connection reset" signal. 2538 Enter the CLOSED state, delete the TCB, and return. 2540 Note this check is placed following the sequence check to 2541 prevent a segment from an old connection between these ports 2542 with a different security or precedence from causing an 2543 abort of the current connection. 2545 fourth, check the SYN bit, 2547 SYN-RECEIVED 2548 ESTABLISHED STATE 2549 FIN-WAIT STATE-1 2550 FIN-WAIT STATE-2 2551 CLOSE-WAIT STATE 2552 CLOSING STATE 2553 LAST-ACK STATE 2554 TIME-WAIT STATE 2556 TODO: need to incorporate RFC 1122 4.2.2.20(e) here 2558 If the SYN is in the window it is an error, send a reset, 2559 any outstanding RECEIVEs and SEND should receive "reset" 2560 responses, all segment queues should be flushed, the user 2561 should also receive an unsolicited general "connection 2562 reset" signal, enter the CLOSED state, delete the TCB, 2563 and return. 2565 If the SYN is not in the window this step would not be 2566 reached and an ack would have been sent in the first step 2567 (sequence number check). 2569 fifth check the ACK field, 2571 if the ACK bit is off drop the segment and return 2572 if the ACK bit is on 2574 SYN-RECEIVED STATE 2576 If SND.UNA < SEG.ACK =< SND.NXT then enter ESTABLISHED 2577 state and continue processing with variables below set 2578 to: 2580 SND.WND <- SEG.WND 2581 SND.WL1 <- SEG.SEQ 2582 SND.WL2 <- SEG.ACK 2584 If the segment acknowledgment is not acceptable, 2585 form a reset segment, 2587 2589 and send it. 2591 ESTABLISHED STATE 2593 If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- 2594 SEG.ACK. Any segments on the retransmission queue 2595 which are thereby entirely acknowledged are removed. 2596 Users should receive positive acknowledgments for 2597 buffers which have been SENT and fully acknowledged 2598 (i.e., SEND buffer should be returned with "ok" 2599 response). If the ACK is a duplicate (SEG.ACK =< 2600 SND.UNA), it can be ignored. If the ACK acks 2601 something not yet sent (SEG.ACK > SND.NXT) then send 2602 an ACK, drop the segment, and return. 2604 If SND.UNA =< SEG.ACK =< SND.NXT, the send window 2605 should be updated. If (SND.WL1 < SEG.SEQ or (SND.WL1 2606 = SEG.SEQ and SND.WL2 =< SEG.ACK)), set SND.WND <- 2607 SEG.WND, set SND.WL1 <- SEG.SEQ, and set SND.WL2 <- 2608 SEG.ACK. 2610 Note that SND.WND is an offset from SND.UNA, that 2611 SND.WL1 records the sequence number of the last 2612 segment used to update SND.WND, and that SND.WL2 2613 records the acknowledgment number of the last segment 2614 used to update SND.WND. The check here prevents using 2615 old segments to update the window. 2617 FIN-WAIT-1 STATE 2618 In addition to the processing for the ESTABLISHED 2619 state, if our FIN is now acknowledged then enter FIN- 2620 WAIT-2 and continue processing in that state. 2622 FIN-WAIT-2 STATE 2624 In addition to the processing for the ESTABLISHED 2625 state, if the retransmission queue is empty, the 2626 user's CLOSE can be acknowledged ("ok") but do not 2627 delete the TCB. 2629 CLOSE-WAIT STATE 2631 Do the same processing as for the ESTABLISHED state. 2633 CLOSING STATE 2635 In addition to the processing for the ESTABLISHED 2636 state, if the ACK acknowledges our FIN then enter the 2637 TIME-WAIT state, otherwise ignore the segment. 2639 LAST-ACK STATE 2641 The only thing that can arrive in this state is an 2642 acknowledgment of our FIN. If our FIN is now 2643 acknowledged, delete the TCB, enter the CLOSED state, 2644 and return. 2646 TIME-WAIT STATE 2648 The only thing that can arrive in this state is a 2649 retransmission of the remote FIN. Acknowledge it, and 2650 restart the 2 MSL timeout. 2652 sixth, check the URG bit, 2654 ESTABLISHED STATE 2655 FIN-WAIT-1 STATE 2656 FIN-WAIT-2 STATE 2658 If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and 2659 signal the user that the remote side has urgent data if 2660 the urgent pointer (RCV.UP) is in advance of the data 2661 consumed. If the user has already been signaled (or is 2662 still in the "urgent mode") for this continuous sequence 2663 of urgent data, do not signal the user again. 2665 CLOSE-WAIT STATE 2666 CLOSING STATE 2667 LAST-ACK STATE 2668 TIME-WAIT 2670 This should not occur, since a FIN has been received from 2671 the remote side. Ignore the URG. 2673 seventh, process the segment text, 2675 ESTABLISHED STATE 2676 FIN-WAIT-1 STATE 2677 FIN-WAIT-2 STATE 2679 Once in the ESTABLISHED state, it is possible to deliver 2680 segment text to user RECEIVE buffers. Text from segments 2681 can be moved into buffers until either the buffer is full 2682 or the segment is empty. If the segment empties and 2683 carries an PUSH flag, then the user is informed, when the 2684 buffer is returned, that a PUSH has been received. 2686 When the TCP takes responsibility for delivering the data 2687 to the user it must also acknowledge the receipt of the 2688 data. 2690 Once the TCP takes responsibility for the data it 2691 advances RCV.NXT over the data accepted, and adjusts 2692 RCV.WND as appropriate to the current buffer 2693 availability. The total of RCV.NXT and RCV.WND should 2694 not be reduced. 2696 Please note the window management suggestions in section 2697 3.7. 2699 Send an acknowledgment of the form: 2701 2703 This acknowledgment should be piggybacked on a segment 2704 being transmitted if possible without incurring undue 2705 delay. 2707 CLOSE-WAIT STATE 2708 CLOSING STATE 2709 LAST-ACK STATE 2710 TIME-WAIT STATE 2712 This should not occur, since a FIN has been received from 2713 the remote side. Ignore the segment text. 2715 eighth, check the FIN bit, 2717 Do not process the FIN if the state is CLOSED, LISTEN or 2718 SYN-SENT since the SEG.SEQ cannot be validated; drop the 2719 segment and return. 2721 If the FIN bit is set, signal the user "connection closing" 2722 and return any pending RECEIVEs with same message, advance 2723 RCV.NXT over the FIN, and send an acknowledgment for the 2724 FIN. Note that FIN implies PUSH for any segment text not 2725 yet delivered to the user. 2727 SYN-RECEIVED STATE 2728 ESTABLISHED STATE 2730 Enter the CLOSE-WAIT state. 2732 FIN-WAIT-1 STATE 2734 If our FIN has been ACKed (perhaps in this segment), 2735 then enter TIME-WAIT, start the time-wait timer, turn 2736 off the other timers; otherwise enter the CLOSING 2737 state. 2739 FIN-WAIT-2 STATE 2741 Enter the TIME-WAIT state. Start the time-wait timer, 2742 turn off the other timers. 2744 CLOSE-WAIT STATE 2746 Remain in the CLOSE-WAIT state. 2748 CLOSING STATE 2750 Remain in the CLOSING state. 2752 LAST-ACK STATE 2754 Remain in the LAST-ACK state. 2756 TIME-WAIT STATE 2758 Remain in the TIME-WAIT state. Restart the 2 MSL 2759 time-wait timeout. 2761 and return. 2763 USER TIMEOUT 2765 USER TIMEOUT 2767 For any state if the user timeout expires, flush all queues, 2768 signal the user "error: connection aborted due to user timeout" 2769 in general and for any outstanding calls, delete the TCB, enter 2770 the CLOSED state and return. 2772 RETRANSMISSION TIMEOUT 2774 For any state if the retransmission timeout expires on a 2775 segment in the retransmission queue, send the segment at the 2776 front of the retransmission queue again, reinitialize the 2777 retransmission timer, and return. 2779 TIME-WAIT TIMEOUT 2781 If the time-wait timeout expires on a connection delete the 2782 TCB, enter the CLOSED state and return. 2784 3.10. Glossary 2786 1822 BBN Report 1822, "The Specification of the Interconnection of 2787 a Host and an IMP". The specification of interface between a 2788 host and the ARPANET. 2790 ACK 2791 A control bit (acknowledge) occupying no sequence space, 2792 which indicates that the acknowledgment field of this segment 2793 specifies the next sequence number the sender of this segment 2794 is expecting to receive, hence acknowledging receipt of all 2795 previous sequence numbers. 2797 ARPANET message 2798 The unit of transmission between a host and an IMP in the 2799 ARPANET. The maximum size is about 1012 octets (8096 bits). 2801 ARPANET packet 2802 A unit of transmission used internally in the ARPANET between 2803 IMPs. The maximum size is about 126 octets (1008 bits). 2805 connection 2806 A logical communication path identified by a pair of sockets. 2808 datagram 2809 A message sent in a packet switched computer communications 2810 network. 2812 Destination Address 2813 The destination address, usually the network and host 2814 identifiers. 2816 FIN 2817 A control bit (finis) occupying one sequence number, which 2818 indicates that the sender will send no more data or control 2819 occupying sequence space. 2821 fragment 2822 A portion of a logical unit of data, in particular an 2823 internet fragment is a portion of an internet datagram. 2825 FTP 2826 A file transfer protocol. 2828 header 2829 Control information at the beginning of a message, segment, 2830 fragment, packet or block of data. 2832 host 2833 A computer. In particular a source or destination of 2834 messages from the point of view of the communication network. 2836 Identification 2837 An Internet Protocol field. This identifying value assigned 2838 by the sender aids in assembling the fragments of a datagram. 2840 IMP 2841 The Interface Message Processor, the packet switch of the 2842 ARPANET. 2844 internet address 2845 A source or destination address specific to the host level. 2847 internet datagram 2848 The unit of data exchanged between an internet module and the 2849 higher level protocol together with the internet header. 2851 internet fragment 2852 A portion of the data of an internet datagram with an 2853 internet header. 2855 IP 2856 Internet Protocol. 2858 IRS 2859 The Initial Receive Sequence number. The first sequence 2860 number used by the sender on a connection. 2862 ISN 2863 The Initial Sequence Number. The first sequence number used 2864 on a connection, (either ISS or IRS). Selected on a clock 2865 based procedure. 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 TODO: this entire section will need to be edited and condensed before 3069 the document is finalized. It currently represents a plan for future 3070 updates mixed with notes on what changes have already been completed. 3072 It should likely be an appendix, and in the final RFC, only the 3073 changes should be listed, and not what particular revision of the I-D 3074 they were made within. 3076 The -00 revision of this document was merely a proposal and rough 3077 plan for updating RFC 793. 3079 The -01 revision of this document incorporates the content of RFC 793 3080 Section 3 titled "FUNCTIONAL SPECIFICATION". Other content from RFC 3081 793 has not been incorporated. The -01 revision of this document 3082 makes some minor formatting changes to the RFC 793 content in order 3083 to convert the content into XML2RFC format and account for left-out 3084 parts of RFC 793. For instance, figure numbering differs and some 3085 indentation is not exactly the same. 3087 The -02 revision of this document incorporates errata that have been 3088 verified: 3090 Errata ID 573: Reported by Bob Braden (note: This errata basically 3091 is just a reminder that RFC 1122 updates 793. Some of the 3092 associated changes are left pending to a separate revision that 3093 incorporates 1122. Bob's mention of PUSH in 793 section 2.8 was 3094 not applicable here because that section was not part of the 3095 "functional specification". Also the 1122 text on the 3096 retransmission timeout also has been updated by subsequent RFCs, 3097 so the change here deviates from Bob's suggestion to apply the 3098 1122 text.) 3099 Errata ID 574: Reported by Yin Shuming 3100 Errata ID 700: Reported by Yin Shuming 3101 Errata ID 701: Reported by Yin Shuming 3102 Errata ID 1283: Reported by Pei-chun Cheng 3103 Errata ID 1561: Reported by Constantin Hagemeier 3104 Errata ID 1562: Reported by Constantin Hagemeier 3105 Errata ID 1564: Reported by Constantin Hagemeier 3106 Errata ID 1565: Reported by Constantin Hagemeier 3107 Errata ID 1571: Reported by Constantin Hagemeier 3108 Errata ID 1572: Reported by Constantin Hagemeier 3109 Errata ID 2296: Reported by Vishwas Manral 3110 Errata ID 2297: Reported by Vishwas Manral 3111 Errata ID 2298: Reported by Vishwas Manral 3112 Errata ID 2748: Reported by Mykyta Yevstifeyev 3113 Errata ID 2749: Reported by Mykyta Yevstifeyev 3114 Errata ID 2934: Reported by Constantin Hagemeier 3115 Errata ID 3213: Reported by EugnJun Yi 3116 Errata ID 3300: Reported by Botong Huang 3117 Errata ID 3301: Reported by Botong Huang 3118 Note: Some verified errata were not used in this update, as they 3119 relate to sections of RFC 793 elided from this document. These 3120 include Errata ID 572, 575, and 1569. 3121 Note: Errata ID 3602 was not applied in this revision as it is 3122 duplicative of the 1122 corrections. 3123 There is an errata 3305 currently reported that need to be 3124 verified, held, or rejected by the ADs; it is addressing the same 3125 issue as draft-gont-tcpm-tcp-seq-validation and was not attempted 3126 to be applied to this document. 3128 Not related to RFC 793 content, this revision also makes small tweaks 3129 to the introductory text, fixes indentation of the pseudoheader 3130 diagram, and notes that the Security Considerations should also 3131 include privacy, when this section is written. 3133 The -03 revision of this document revises all discussion of the 3134 urgent pointer in order to comply with RFC 6093, 1122, and 1011. 3135 Since 1122 held requirements on the urgent pointer, the full list of 3136 requirements was brought into an appendix of this document, so that 3137 it can be updated as-needed. 3139 TODO: Incomplete list of planned changes - these need to be added to 3140 and made more specific, as the document proceeds: 3142 1. incorporate 1122 additions 3143 2. point to major additional docs like 1323bis and 5681 3144 3. incorporate relevant parts of 3168 (ECN) 3145 4. incorporate 6528 (sequence number) 3146 5. incorporate Fernando's new number-checking fixes (if past the 3147 IESG in time) 3148 6. point to PMTUD? 3149 7. point to 5461 (soft errors) 3150 8. mention 5961 state machine option 3151 9. mention 6161 (reducing TIME-WAIT) 3152 10. incorporate 6429 (ZWP/persist) 3153 11. incorporate 6691 (MSS) 3154 12. look at Tony Sabatini suggestion for describing DO field 3155 13. clearly specify treatment of reserved bits (see TCPM thread on 3156 EDO draft April 25, 2014) 3157 14. look at possible mention of draft-minshall-nagle (e.g. as in 3158 Linux) 3159 15. make sure that clarifications in RFC 1011 are captured 3160 16. per TCPM discussion, discussion of checking reserved bits may 3161 need to be altered from 793 3163 5. IANA Considerations 3165 This memo includes no request to IANA. Existing IANA registries for 3166 TCP parameters are sufficient. 3168 TODO: check whether entries pointing to 793 and other documents 3169 obsoleted by this one should be updated to point to this one instead. 3171 6. Security and Privacy Considerations 3173 TODO 3175 See RFC 6093 [5] for discussion of security considerations related to 3176 the urgent pointer field. 3178 Editor's Note: Scott Brim mentioned that this should include a 3179 PERPASS/privacy review. 3181 7. Acknowledgements 3183 This document is largely a revision of RFC 793, which Jon Postel was 3184 the editor of. Due to his excellent work, it was able to last for 3185 three decades before we felt the need to revise it. 3187 Andre Oppermann was a contributor and helped to edit the first 3188 revision of this document. 3190 We are thankful for the assistance of the IETF TCPM working group 3191 chairs: 3193 Michael Scharf 3194 Yoshifumi Nishida 3195 Pasi Sarolahti 3197 On the TCPM mailing list, and at the IETF 88 meeting in Vancouver, 3198 helpful comments, critiques, and reviews were received from (listed 3199 alphebetically): David Borman, Yuchung Cheng, Martin Duke, Kevin 3200 Lahey, Kevin Mason, Matt Mathis, Hagen Paul Pfeifer, Anthony 3201 Sabatini, Joe Touch, Reji Varghese, Lloyd Wood, and Alex Zimmermann. 3203 This document includes content from errata that were reported by 3204 (listed chronologically): Yin Shuming, Bob Braden, Morris M. Keesan, 3205 Pei-chun Cheng, Constantin Hagemeier, Vishwas Manral, Mykyta 3206 Yevstifeyev, EungJun Yi, Botong Huang. 3208 8. References 3210 8.1. Normative References 3212 [1] Bradner, S., "Key words for use in RFCs to Indicate 3213 Requirement Levels", BCP 14, RFC 2119, March 1997. 3215 8.2. Informative References 3217 [2] Postel, J., "Transmission Control Protocol", STD 7, RFC 3218 793, September 1981. 3220 [3] Braden, R., "Requirements for Internet Hosts - 3221 Communication Layers", STD 3, RFC 1122, October 1989. 3223 [4] Duke, M., Braden, R., Eddy, W., Blanton, E., and A. 3224 Zimmermann, "A Roadmap for Transmission Control Protocol 3225 (TCP) Specification Documents", draft-ietf-tcpm-tcp- 3226 rfc4614bis-07 (work in progress), July 2014. 3228 [5] Gont, F. and A. Yourtchenko, "On the Implementation of the 3229 TCP Urgent Mechanism", RFC 6093, January 2011. 3231 Appendix A. TCP Requirement Summary 3233 This section is adapted from RFC 1122. 3235 TODO: this needs to be seriously redone, to use 793bis section 3236 numbers instead of 1122 ones, and all 1122 requirements need to be 3237 reflected in 793bis text. 3239 | | | | |S| | 3240 | | | | |H| |F 3241 | | | | |O|M|o 3242 | | |S| |U|U|o 3243 | | |H| |L|S|t 3244 | |M|O| |D|T|n 3245 | |U|U|M| | |o 3246 | |S|L|A|N|N|t 3247 |1122 |T|D|Y|O|O|t 3248 FEATURE |SECTION | | | |T|T|e 3249 -------------------------------------------------|--------|-|-|-|-|-|-- 3250 | | | | | | | 3251 Push flag | | | | | | | 3252 Aggregate or queue un-pushed data |4.2.2.2 | | |x| | | 3253 Sender collapse successive PSH flags |4.2.2.2 | |x| | | | 3254 SEND call can specify PUSH |4.2.2.2 | | |x| | | 3255 If cannot: sender buffer indefinitely |4.2.2.2 | | | | |x| 3256 If cannot: PSH last segment |4.2.2.2 |x| | | | | 3257 Notify receiving ALP of PSH |4.2.2.2 | | |x| | |1 3258 Send max size segment when possible |4.2.2.2 | |x| | | | 3259 | | | | | | | 3260 Window | | | | | | | 3261 Treat as unsigned number |4.2.2.3 |x| | | | | 3262 Handle as 32-bit number |4.2.2.3 | |x| | | | 3263 Shrink window from right |4.2.2.16| | | |x| | 3264 Robust against shrinking window |4.2.2.16|x| | | | | 3265 Receiver's window closed indefinitely |4.2.2.17| | |x| | | 3266 Sender probe zero window |4.2.2.17|x| | | | | 3267 First probe after RTO |4.2.2.17| |x| | | | 3268 Exponential backoff |4.2.2.17| |x| | | | 3269 Allow window stay zero indefinitely |4.2.2.17|x| | | | | 3270 Sender timeout OK conn with zero wind |4.2.2.17| | | | |x| 3271 | | | | | | | 3272 Urgent Data | | | | | | | 3273 Pointer indicates first non-urgent octet |4.2.2.4 |x| | | | | 3274 Arbitrary length urgent data sequence |4.2.2.4 |x| | | | | 3275 Inform ALP asynchronously of urgent data |4.2.2.4 |x| | | | |1 3276 ALP can learn if/how much urgent data Q'd |4.2.2.4 |x| | | | |1 3277 | | | | | | | 3278 TCP Options | | | | | | | 3279 Receive TCP option in any segment |4.2.2.5 |x| | | | | 3280 Ignore unsupported options |4.2.2.5 |x| | | | | 3281 Cope with illegal option length |4.2.2.5 |x| | | | | 3282 Implement sending & receiving MSS option |4.2.2.6 |x| | | | | 3283 Send MSS option unless 536 |4.2.2.6 | |x| | | | 3284 Send MSS option always |4.2.2.6 | | |x| | | 3285 Send-MSS default is 536 |4.2.2.6 |x| | | | | 3286 Calculate effective send seg size |4.2.2.6 |x| | | | | 3287 | | | | | | | 3288 TCP Checksums | | | | | | | 3289 Sender compute checksum |4.2.2.7 |x| | | | | 3290 Receiver check checksum |4.2.2.7 |x| | | | | 3291 | | | | | | | 3292 Use clock-driven ISN selection |4.2.2.9 |x| | | | | 3293 | | | | | | | 3294 Opening Connections | | | | | | | 3295 Support simultaneous open attempts |4.2.2.10|x| | | | | 3296 SYN-RCVD remembers last state |4.2.2.11|x| | | | | 3297 Passive Open call interfere with others |4.2.2.18| | | | |x| 3298 Function: simultan. LISTENs for same port |4.2.2.18|x| | | | | 3299 Ask IP for src address for SYN if necc. |4.2.3.7 |x| | | | | 3300 Otherwise, use local addr of conn. |4.2.3.7 |x| | | | | 3301 OPEN to broadcast/multicast IP Address |4.2.3.14| | | | |x| 3302 Silently discard seg to bcast/mcast addr |4.2.3.14|x| | | | | 3303 | | | | | | | 3304 Closing Connections | | | | | | | 3305 RST can contain data |4.2.2.12| |x| | | | 3306 Inform application of aborted conn |4.2.2.13|x| | | | | 3307 Half-duplex close connections |4.2.2.13| | |x| | | 3308 Send RST to indicate data lost |4.2.2.13| |x| | | | 3309 In TIME-WAIT state for 2xMSL seconds |4.2.2.13|x| | | | | 3310 Accept SYN from TIME-WAIT state |4.2.2.13| | |x| | | 3311 | | | | | | | 3312 Retransmissions | | | | | | | 3313 Jacobson Slow Start algorithm |4.2.2.15|x| | | | | 3314 Jacobson Congestion-Avoidance algorithm |4.2.2.15|x| | | | | 3315 Retransmit with same IP ident |4.2.2.15| | |x| | | 3316 Karn's algorithm |4.2.3.1 |x| | | | | 3317 Jacobson's RTO estimation alg. |4.2.3.1 |x| | | | | 3318 Exponential backoff |4.2.3.1 |x| | | | | 3319 SYN RTO calc same as data |4.2.3.1 | |x| | | | 3320 Recommended initial values and bounds |4.2.3.1 | |x| | | | 3321 | | | | | | | 3322 Generating ACK's: | | | | | | | 3323 Queue out-of-order segments |4.2.2.20| |x| | | | 3324 Process all Q'd before send ACK |4.2.2.20|x| | | | | 3325 Send ACK for out-of-order segment |4.2.2.21| | |x| | | 3326 Delayed ACK's |4.2.3.2 | |x| | | | 3327 Delay < 0.5 seconds |4.2.3.2 |x| | | | | 3328 Every 2nd full-sized segment ACK'd |4.2.3.2 |x| | | | | 3329 Receiver SWS-Avoidance Algorithm |4.2.3.3 |x| | | | | 3330 | | | | | | | 3331 Sending data | | | | | | | 3332 Configurable TTL |4.2.2.19|x| | | | | 3333 Sender SWS-Avoidance Algorithm |4.2.3.4 |x| | | | | 3334 Nagle algorithm |4.2.3.4 | |x| | | | 3335 Application can disable Nagle algorithm |4.2.3.4 |x| | | | | 3336 | | | | | | | 3337 Connection Failures: | | | | | | | 3338 Negative advice to IP on R1 retxs |4.2.3.5 |x| | | | | 3339 Close connection on R2 retxs |4.2.3.5 |x| | | | | 3340 ALP can set R2 |4.2.3.5 |x| | | | |1 3341 Inform ALP of R1<=retxs inform ALP |4.2.3.9 | |x| | | | 3366 Dest. Unreach (0,1,5) => abort conn |4.2.3.9 | | | | |x| 3367 Dest. Unreach (2-4) => abort conn |4.2.3.9 | |x| | | | 3368 Source Quench => slow start |4.2.3.9 | |x| | | | 3369 Time Exceeded => tell ALP, don't abort |4.2.3.9 | |x| | | | 3370 Param Problem => tell ALP, don't abort |4.2.3.9 | |x| | | | 3371 | | | | | | | 3372 Address Validation | | | | | | | 3373 Reject OPEN call to invalid IP address |4.2.3.10|x| | | | | 3374 Reject SYN from invalid IP address |4.2.3.10|x| | | | | 3375 Silently discard SYN to bcast/mcast addr |4.2.3.10|x| | | | | 3376 | | | | | | | 3377 TCP/ALP Interface Services | | | | | | | 3378 Error Report mechanism |4.2.4.1 |x| | | | | 3379 ALP can disable Error Report Routine |4.2.4.1 | |x| | | | 3380 ALP can specify TOS for sending |4.2.4.2 |x| | | | | 3381 Passed unchanged to IP |4.2.4.2 | |x| | | | 3382 ALP can change TOS during connection |4.2.4.2 | |x| | | | 3383 Pass received TOS up to ALP |4.2.4.2 | | |x| | | 3384 FLUSH call |4.2.4.3 | | |x| | | 3385 Optional local IP addr parm. in OPEN |4.2.4.4 |x| | | | | 3386 -------------------------------------------------|--------|-|-|-|-|-|-- 3388 FOOTNOTES: (1) "ALP" means Application-Layer program. 3390 Author's Address 3392 Wesley M. Eddy (editor) 3393 MTI Systems 3394 US 3396 Email: wes@mti-systems.com