home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 700s / rfc761.txt < prev    next >
Text File  |  1992-10-14  |  167KB  |  5,186 lines

  1.  
  2.  
  3. RFC: 761
  4. IEN: 129
  5.                                     
  6.                                     
  7.                                     
  8.                                     
  9.                                     
  10.                                     
  11.                                     
  12.                               DOD STANDARD
  13.                                     
  14.                      TRANSMISSION CONTROL PROTOCOL
  15.                                     
  16.                                     
  17.                                     
  18.                               January 1980
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.                               prepared for
  35.                                     
  36.                Defense Advanced Research Projects Agency
  37.                 Information Processing Techniques Office
  38.                          1400 Wilson Boulevard
  39.                        Arlington, Virginia  22209
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.                                    by
  48.  
  49.                      Information Sciences Institute
  50.                    University of Southern California
  51.                            4676 Admiralty Way
  52.                    Marina del Rey, California  90291
  53.  
  54. January 1980                                                            
  55.                                            Transmission Control Protocol
  56.  
  57.  
  58.  
  59.                            TABLE OF CONTENTS
  60.  
  61.     PREFACE ........................................................ iii
  62.  
  63. 1.  INTRODUCTION ..................................................... 1
  64.  
  65.   1.1  Motivation .................................................... 1
  66.   1.2  Scope ......................................................... 2
  67.   1.3  About This Document ........................................... 2
  68.   1.4  Interfaces .................................................... 3
  69.   1.5  Operation ..................................................... 3
  70.  
  71. 2.  PHILOSOPHY ....................................................... 7
  72.  
  73.   2.1  Elements of the Internetwork System ........................... 7
  74.   2.2  Model of Operation ............................................ 7
  75.   2.3  The Host Environment .......................................... 8
  76.   2.4  Interfaces .................................................... 9
  77.   2.5  Relation to Other Protocols ................................... 9
  78.   2.6  Reliable Communication ....................................... 10
  79.   2.7  Connection Establishment and Clearing ........................ 10
  80.   2.8  Data Communication ........................................... 12
  81.   2.9  Precedence and Security ...................................... 13
  82.   2.10 Robustness Principle ......................................... 13
  83.  
  84. 3.  FUNCTIONAL SPECIFICATION ........................................ 15
  85.  
  86.   3.1  Header Format ................................................ 15
  87.   3.2  Terminology .................................................. 19
  88.   3.3  Sequence Numbers ............................................. 24
  89.   3.4  Establishing a connection .................................... 29
  90.   3.5  Closing a Connection ......................................... 35
  91.   3.6  Precedence and Security ...................................... 38
  92.   3.7  Data Communication ........................................... 38
  93.   3.8  Interfaces ................................................... 42
  94.   3.9  Event Processing ............................................. 52
  95.  
  96. GLOSSARY ............................................................ 75
  97.  
  98. REFERENCES .......................................................... 83
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.                                                                 [Page i]
  111.  
  112.  
  113.                                                             January 1980
  114. Transmission Control Protocol
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. [Page ii]                                                               
  170.  
  171.  
  172. January 1980                                                            
  173.                                            Transmission Control Protocol
  174.  
  175.  
  176.  
  177.                                 PREFACE
  178.  
  179.  
  180.  
  181. This document describes the DoD Standard Transmission Control Protocol
  182. (TCP).  There have been eight earlier editions of the ARPA TCP
  183. specification on which this standard is based, and the present text
  184. draws heavily from them.  There have been many contributors to this work
  185. both in terms of concepts and in terms of text.  This edition
  186. incorporates the addition of security, compartmentation, and precedence
  187. concepts into the TCP specification.
  188.  
  189.                                                            Jon Postel
  190.  
  191.                                                            Editor
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.                                                               [Page iii]
  229.  
  230.  
  231. January 1980 
  232. RFC:761
  233. IEN:129
  234. Replaces:  IENs 124, 112,
  235. 81, 55, 44, 40, 27, 21, 5
  236.  
  237.                               DOD STANDARD
  238.  
  239.                      TRANSMISSION CONTROL PROTOCOL
  240.  
  241.  
  242.  
  243.                             1.  INTRODUCTION
  244.  
  245. The Transmission Control Protocol (TCP) is intended for use as a highly
  246. reliable host-to-host protocol between hosts in packet-switched computer
  247. communication networks, and especially in interconnected systems of such
  248. networks.
  249.  
  250. This document describes the functions to be performed by the
  251. Transmission Control Protocol, the program that implements it, and its
  252. interface to programs or users that require its services.
  253.  
  254. 1.1.  Motivation
  255.  
  256.   Computer communication systems are playing an increasingly important
  257.   role in military, government, and civilian environments.  This
  258.   document primarily focuses its attention on military computer
  259.   communication requirements, especially robustness in the presence of
  260.   communication unreliability and availability in the presence of
  261.   congestion, but many of these problems are found in the civilian and
  262.   government sector as well.
  263.  
  264.   As strategic and tactical computer communication networks are
  265.   developed and deployed, it is essential to provide means of
  266.   interconnecting them and to provide standard interprocess
  267.   communication protocols which can support a broad range of
  268.   applications.  In anticipation of the need for such standards, the
  269.   Deputy Undersecretary of Defense for Research and Engineering has
  270.   declared the Transmission Control Protocol (TCP) described herein to
  271.   be a basis for DoD-wide inter-process communication protocol
  272.   standardization.
  273.  
  274.   TCP is a connection-oriented, end-to-end reliable protocol designed to
  275.   fit into a layered hierarchy of protocols which support multi-network
  276.   applications.  The TCP provides for reliable inter-process
  277.   communication between pairs of processes in host computers attached to
  278.   distinct but interconnected computer communication networks.  Very few
  279.   assumptions are made as to the reliability of the communication
  280.   protocols below the TCP layer.  TCP assumes it can obtain a simple,
  281.   potentially unreliable datagram service from the lower level
  282.   protocols.  In principle, the TCP should be able to operate above a
  283.   wide spectrum of communication systems ranging from hard-wired
  284.   connections to packet-switched or circuit-switched networks.
  285.  
  286.  
  287.                                                                 [Page 1]
  288.  
  289.  
  290.                                                             January 1980
  291. Transmission Control Protocol
  292. Introduction
  293.  
  294.  
  295.  
  296.   TCP is based on concepts first described by Cerf and Kahn in [1].  The
  297.   TCP fits into a layered protocol architecture just above a basic
  298.   Internet Protocol [2] which provides a way for the TCP to send and
  299.   receive variable-length segments of information enclosed in internet
  300.   datagram "envelopes".  The internet datagram provides a means for
  301.   addressing source and destination TCPs in different networks.  The
  302.   internet protocol also deals with any fragmentation or reassembly of
  303.   the TCP segments required to achieve transport and delivery through
  304.   multiple networks and interconnecting gateways.  The internet protocol
  305.   also carries information on the precedence, security classification
  306.   and compartmentation of the TCP segments, so this information can be
  307.   communicated end-to-end across multiple networks.
  308.  
  309.                            Protocol Layering
  310.  
  311.                         +---------------------+
  312.                         |     higher-level    |
  313.                         +---------------------+
  314.                         |        TCP          |
  315.                         +---------------------+
  316.                         |  internet protocol  |
  317.                         +---------------------+
  318.                         |communication network|
  319.                         +---------------------+
  320.  
  321.                                 Figure 1
  322.  
  323.   Much of this document is written in the context of TCP implementations
  324.   which are co-resident with higher level protocols in the host
  325.   computer.  As a practical matter, many computer systems will be
  326.   connected to networks via front-end computers which house the TCP and
  327.   internet protocol layers, as well as network specific software.  The
  328.   TCP specification describes an interface to the higher level protocols
  329.   which appears to be implementable even for the front-end case, as long
  330.   as a suitable host-to-front end protocol is implemented.
  331.  
  332. 1.2.  Scope
  333.  
  334.   The TCP is intended to provide a reliable process-to-process
  335.   communication service in a multinetwork environment.  The TCP is
  336.   intended to be a host-to-host protocol in common use in multiple
  337.   networks.
  338.  
  339. 1.3.  About this Document
  340.  
  341.   This document represents a specification of the behavior required of
  342.   any TCP implementation, both in its interactions with higher level
  343.   protocols and in its interactions with other TCPs.  The rest of this
  344.  
  345.  
  346. [Page 2]                                                                
  347.  
  348.  
  349. January 1980                                                            
  350.                                            Transmission Control Protocol
  351.                                                             Introduction
  352.  
  353.  
  354.  
  355.   section offers a very brief view of the protocol interfaces and
  356.   operation.  Section 2 summarizes the philosophical basis for the TCP
  357.   design.  Section 3 offers both a detailed description of the actions
  358.   required of TCP when various events occur (arrival of new segments,
  359.   user calls, errors, etc.) and the details of the formats of TCP
  360.   segments.
  361.  
  362. 1.4.  Interfaces
  363.  
  364.   The TCP interfaces on one side to user or application processes and on
  365.   the other side to a lower level protocol such as Internet Protocol.
  366.  
  367.   The interface between an application process and the TCP is
  368.   illustrated in reasonable detail.  This interface consists of a set of
  369.   calls much like the calls an operating system provides to an
  370.   application process for manipulating files.  For example, there are
  371.   calls to open and close connections and to send and receive letters on
  372.   established connections.  It is also expected that the TCP can
  373.   asynchronously communicate with application programs.  Although
  374.   considerable freedom is permitted to TCP implementors to design
  375.   interfaces which are appropriate to a particular operating system
  376.   environment, a minimum functionality is required at the TCP/user
  377.   interface for any valid implementation.
  378.  
  379.   The interface between TCP and lower level protocol is essentially
  380.   unspecified except that it is assumed there is a mechanism whereby the
  381.   two levels can asynchronously pass information to each other.
  382.   Typically, one expects the lower level protocol to specify this
  383.   interface.  TCP is designed to work in a very general environment of
  384.   interconnected networks.  The lower level protocol which is assumed
  385.   throughout this document is the Internet Protocol [2].
  386.  
  387. 1.5.  Operation
  388.  
  389.   As noted above, the primary purpose of the TCP is to provide reliable,
  390.   securable logical circuit or connection service between pairs of
  391.   processes.  To provide this service on top of a less reliable internet
  392.   communication system requires facilities in the following areas:
  393.  
  394.     Basic Data Transfer
  395.     Reliability
  396.     Flow Control
  397.     Multiplexing
  398.     Connections
  399.     Precedence and Security
  400.  
  401.   The basic operation of the TCP in each of these areas is described in
  402.   the following paragraphs.
  403.  
  404.  
  405.                                                                 [Page 3]
  406.  
  407.  
  408.                                                             January 1980
  409. Transmission Control Protocol
  410. Introduction
  411.  
  412.  
  413.  
  414.   Basic Data Transfer:
  415.  
  416.     The TCP is able to transfer a continuous stream of octets in each
  417.     direction between its users by packaging some number of octets into
  418.     segments for transmission through the internet system.  In this
  419.     stream mode, the TCPs decide when to block and forward data at their
  420.     own convenience.
  421.  
  422.     For users who desire a record-oriented service, the TCP also permits
  423.     the user to submit records, called letters, for transmission.  When
  424.     the sending user indicates a record boundary (end-of-letter), this
  425.     causes the TCPs to promptly forward and deliver data up to that
  426.     point to the receiver.
  427.  
  428.   Reliability:
  429.  
  430.     The TCP must recover from data that is damaged, lost, duplicated, or
  431.     delivered out of order by the internet communication system.  This
  432.     is achieved by assigning a sequence number to each octet
  433.     transmitted, and requiring a positive acknowledgment (ACK) from the
  434.     receiving TCP.  If the ACK is not received within a timeout
  435.     interval, the data is retransmitted.  At the receiver, the sequence
  436.     numbers are used to correctly order segments that may be received
  437.     out of order and to eliminate duplicates.  Damage is handled by
  438.     adding a checksum to each segment transmitted, checking it at the
  439.     receiver, and discarding damaged segments.
  440.  
  441.     As long as the TCPs continue to function properly and the internet
  442.     system does not become completely partitioned, no transmission
  443.     errors will affect the users.  TCP recovers from internet
  444.     communication system errors.
  445.  
  446.   Flow Control:
  447.  
  448.     TCP provides a means for the receiver to govern the amount of data
  449.     sent by the sender.  This is achieved by returning a "window" with
  450.     every ACK indicating a range of acceptable sequence numbers beyond
  451.     the last segment successfully received.  For stream mode, the window
  452.     indicates an allowed number of octets that the sender may transmit
  453.     before receiving further permission.  For record mode, the window
  454.     indicates an allowed amount of buffer space the sender may consume,
  455.     this may be more than the number of data octets transmitted if there
  456.     is a mismatch between letter size and buffer size.
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464. [Page 4]                                                                
  465.  
  466.  
  467. January 1980                                                            
  468.                                            Transmission Control Protocol
  469.                                                             Introduction
  470.  
  471.  
  472.  
  473.   Multiplexing:
  474.  
  475.     To allow for many processes within a single Host to use TCP
  476.     communication facilities simultaneously, the TCP provides a set of
  477.     addresses or ports within each host.  Concatenated with the network
  478.     and host addresses from the internet communication layer, this forms
  479.     a socket.  A pair of sockets uniquely identifies each connection.
  480.     That is, a socket may be simultaneously used in multiple
  481.     connections.
  482.  
  483.     The binding of ports to processes is handled independently by each
  484.     Host.  However, it proves useful to attach frequently used processes
  485.     (e.g., a "logger" or timesharing service) to fixed sockets which are
  486.     made known to the public.  These services can then be accessed
  487.     through the known addresses.  Establishing and learning the port
  488.     addresses of other processes may involve more dynamic mechanisms.
  489.  
  490.   Connections:
  491.  
  492.     The reliability and flow control mechanisms described above require
  493.     that TCPs initialize and maintain certain status information for
  494.     each data stream.  The combination of this information, including
  495.     sockets, sequence numbers, and window sizes, is called a connection.
  496.     Each connection is uniquely specified by a pair of sockets
  497.     identifying its two sides.
  498.  
  499.     When two processes wish to communicate, their TCP's must first
  500.     establish a connection (initialize the status information on each
  501.     side).  When their communication is complete, the connection is
  502.     terminated or closed to free the resources for other uses.
  503.  
  504.     Since connections must be established between unreliable hosts and
  505.     over the unreliable internet communication system, a handshake
  506.     mechanism with clock-based sequence numbers is used to avoid
  507.     erroneous initialization of connections.
  508.  
  509.   Precedence and Security:
  510.  
  511.     The users of TCP may indicate the security and precedence of their
  512.     communication.  Provision is made for default values to be used when
  513.     these features are not needed.
  514.  
  515.     
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                                                 [Page 5]
  524.  
  525.  
  526.                                                             January 1980
  527. Transmission Control Protocol
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582. [Page 6]                                                                
  583.  
  584.  
  585. January 1980                                                            
  586.                                            Transmission Control Protocol
  587.  
  588.  
  589.  
  590.                              2.  PHILOSOPHY
  591.  
  592. 2.1.  Elements of the Internetwork System
  593.  
  594.   The internetwork environment consists of hosts connected to networks
  595.   which are in turn interconnected via gateways.  It is assumed here
  596.   that the networks may be either local networks (e.g., the ETHERNET) or
  597.   large networks (e.g., the ARPANET), but in any case are based on
  598.   packet switching technology.  The active agents that produce and
  599.   consume messages are processes.  Various levels of protocols in the
  600.   networks, the gateways, and the hosts support an interprocess
  601.   communication system that provides two-way data flow on logical
  602.   connections between process ports.
  603.  
  604.   We specifically assume that data is transmitted from host to host
  605.   through means of a set of  networks.  When we say network, we have in
  606.   mind a packet switched network (PSN).  This assumption is probably
  607.   unnecessary, since a circuit switched network or a hybrid combination
  608.   of the two could also be used; but for concreteness, we explicitly
  609.   assume that the hosts are connected to one or more packet switches of
  610.   a PSN.
  611.  
  612.   The term packet is used generically here to mean the data of one
  613.   transaction between a host and a packet switch.  The format of data
  614.   blocks exchanged between the packet switches in a network will
  615.   generally not be of concern to us.
  616.  
  617.   Hosts are computers attached to a network, and from the communication
  618.   network's point of view, are the sources and destinations of packets.
  619.   Processes are viewed as the active elements in host computers (in
  620.   accordance with the fairly common definition of a process as a program
  621.   in execution).  Even terminals and files or other I/O devices are
  622.   viewed as communicating with each other through the use of processes.
  623.   Thus, all communication is viewed as inter-process communication.
  624.  
  625.   Since a process may need to distinguish among several communication
  626.   streams between itself and another process (or processes), we imagine
  627.   that each process may have a number of ports through which it
  628.   communicates with the ports of other processes.
  629.  
  630. 2.2.  Model of Operation
  631.  
  632.   Processes transmit data by calling on the TCP and passing buffers of
  633.   data as arguments.  The TCP packages the data from these buffers into
  634.   segments and calls on the internet module to transmit each segment to
  635.   the destination TCP.  The receiving TCP places the data from a segment
  636.   into the receiving user's buffer and notifies the receiving user.  The
  637.   TCPs include control information in the segments which they use to
  638.   ensure reliable ordered data transmission.
  639.  
  640.  
  641.                                                                 [Page 7]
  642.  
  643.  
  644.                                                             January 1980
  645. Transmission Control Protocol
  646. Philosophy
  647.  
  648.  
  649.  
  650.   The model of internet communication is that there is an internet
  651.   protocol module associated with each TCP which provides an interface
  652.   to the local network.  This internet module packages TCP segments
  653.   inside internet datagrams and routes these datagrams to a destination
  654.   internet module or intermediate gateway.  To transmit the datagram
  655.   through the local network, it is embedded in a local network packet.
  656.  
  657.   The packet switches may perform further packaging, fragmentation, or
  658.   other operations to achieve the delivery of the local packet to the
  659.   destination internet module.
  660.  
  661.   At a gateway between networks, the internet datagram is "unwrapped"
  662.   from its local packet and examined to determine through which network
  663.   the internet datagram should travel next.  The internet datagram is
  664.   then "wrapped" in a local packet suitable to the next network and
  665.   routed to the next gateway, or to the final destination.
  666.  
  667.   A gateway is permitted to break up an internet datagram into smaller
  668.   internet datagram fragments if this is necessary for transmission
  669.   through the next network.  To do this, the gateway produces a set of
  670.   internet datagrams; each carrying a fragment.  Fragments may be broken
  671.   into smaller ones at intermediate gateways.  The internet datagram
  672.   fragment format is designed so that the destination internet module
  673.   can reassemble fragments into internet datagrams.
  674.  
  675.   A destination internet module unwraps the segment from the datagram
  676.   (after reassembling the datagram, if necessary) and passes it to the
  677.   destination TCP.
  678.  
  679.   This simple model of the operation glosses over many details.  One
  680.   important feature is the type of service.  This provides information
  681.   to the gateway (or internet module) to guide it in selecting the
  682.   service parameters to be used in traversing the next network.
  683.   Included in the type of service information is the precedence of the
  684.   datagram.  Datagrams may also carry security information to permit
  685.   host and gateways that operate in multilevel secure environments to
  686.   properly segregate datagrams for security considerations.
  687.  
  688. 2.3.  The Host Environment
  689.  
  690.   The TCP is assumed to be a module in a time sharing operating system.
  691.   The users access the TCP much like they would access the file system.
  692.   The TCP may call on other operating system functions, for example, to
  693.   manage data structures.  The actual interface to the network is
  694.   assumed to be controlled by a device driver module.  The TCP does not
  695.   call on the network device driver directly, but rather calls on the
  696.   internet datagram protocol module which may in turn call on the device
  697.   driver.
  698.  
  699.  
  700. [Page 8]                                                                
  701.  
  702.  
  703. January 1980                                                            
  704.                                            Transmission Control Protocol
  705.                                                               Philosophy
  706.  
  707.  
  708.  
  709.   Though it is assumed here that processes are supported by the host
  710.   operating system, the mechanisms of TCP do not preclude implementation
  711.   of the TCP in a front-end processor.  However, in such an
  712.   implementation, a host-to-front-end protocol must provide the
  713.   functionality to support the type of TCP-user interface described
  714.   above.
  715.  
  716. 2.4.  Interfaces
  717.  
  718.   The TCP/user interface provides for calls made by the user on the TCP
  719.   to OPEN or CLOSE a connection, to SEND or RECEIVE data, or to obtain
  720.   STATUS about a connection.  These calls are like other calls from user
  721.   programs on the operating system, for example, the calls to open, read
  722.   from, and close a file.
  723.  
  724.   The TCP/internet interface provides calls to send and receive
  725.   datagrams addressed to TCP modules in hosts anywhere in the internet
  726.   system.  These calls have parameters for passing the address, type of
  727.   service, precedence, security, and other control information.
  728.  
  729. 2.5.  Relation to Other Protocols
  730.  
  731.   The following diagram illustrates the place of the TCP in the protocol
  732.   hierarchy:
  733.  
  734.                                     
  735.        +------+ +-----+ +-----+       +-----+                    
  736.        |Telnet| | FTP | |Voice|  ...  |     |  Application Level 
  737.        +------+ +-----+ +-----+       +-----+                    
  738.              |   |         |             |                       
  739.             +-----+     +-----+       +-----+                    
  740.             | TCP |     | RTP |  ...  |     |  Host Level        
  741.             +-----+     +-----+       +-----+                    
  742.                |           |             |                       
  743.             +-------------------------------+                    
  744.             |      Internet Protocol        |  Gateway Level     
  745.             +-------------------------------+                    
  746.                            |                                     
  747.               +---------------------------+                      
  748.               |   Local Network Protocol  |    Network Level     
  749.               +---------------------------+                      
  750.                            |                                     
  751.  
  752.  
  753.  
  754.                          Protocol Relationships
  755.  
  756.                                Figure 2.
  757.  
  758.  
  759.                                                                 [Page 9]
  760.  
  761.  
  762.                                                             January 1980
  763. Transmission Control Protocol
  764. Philosophy
  765.  
  766.  
  767.  
  768.   It is expected that the TCP will be able to support higher level
  769.   protocols efficiently.  It should be easy to interface higher level
  770.   protocols like the ARPANET Telnet [3] or AUTODIN II THP to the TCP.
  771.  
  772. 2.6.  Reliable Communication
  773.  
  774.   A stream of data sent on a TCP connection is delivered reliably and in
  775.   order at the destination.
  776.  
  777.   Transmission is made reliable via the use of sequence numbers and
  778.   acknowledgments.  Conceptually, each octet of data is assigned a
  779.   sequence number.  The sequence number of the first octet of data in a
  780.   segment is the sequence number transmitted with that segment and is
  781.   called the segment sequence number.  Segments also carry an
  782.   acknowledgment number which is the sequence number of the next
  783.   expected data octet of transmissions in the reverse direction.  When
  784.   the TCP transmits a segment, it puts a copy on a retransmission queue
  785.   and starts a timer; when the acknowledgment for that data is received,
  786.   the segment is deleted from the queue.  If the acknowledgment is not
  787.   received before the timer runs out, the segment is retransmitted.
  788.  
  789.   An acknowledgment by TCP does not guarantee that the data has been
  790.   delivered to the end user, but only that the receiving TCP has taken
  791.   the responsibility to do so.
  792.  
  793.   To govern the flow of data into a TCP, a flow control mechanism is
  794.   employed.  The the data receiving TCP reports a window to the sending
  795.   TCP.  This window specifies the number of octets, starting with the
  796.   acknowledgment number that the data receiving TCP is currently
  797.   prepared to receive.
  798.  
  799. 2.7.  Connection Establishment and Clearing
  800.  
  801.   To identify the separate data streams that a TCP may handle, the TCP
  802.   provides a port identifier.  Since port identifiers are selected
  803.   independently by each operating system, TCP, or user, they might not
  804.   be unique.  To provide for unique addresses at each TCP, we
  805.   concatenate an internet address identifying the TCP with a port
  806.   identifier to create a socket which will be unique throughout all
  807.   networks connected together.
  808.  
  809.   A connection is fully specified by the pair of sockets at the ends.  A
  810.   local socket may participate in many connections to different foreign
  811.   sockets.  A connection can be used to carry data in both directions,
  812.   that is, it is "full duplex".
  813.  
  814.   TCPs are free to associate ports with processes however they choose.
  815.   However, several basic concepts seem necessary in any implementation.
  816.  
  817.  
  818. [Page 10]                                                               
  819.  
  820.  
  821. January 1980                                                            
  822.                                            Transmission Control Protocol
  823.                                                               Philosophy
  824.  
  825.  
  826.  
  827.   There must be well-known sockets which the TCP associates only with
  828.   the "appropriate" processes by some means.  We envision that processes
  829.   may "own" ports, and that processes can only initiate connections on
  830.   the ports they own.  (Means for implementing ownership is a local
  831.   issue, but we envision a Request Port user command, or a method of
  832.   uniquely allocating a group of ports to a given process, e.g., by
  833.   associating the high order bits of a port name with a given process.)
  834.  
  835.   A connection is specified in the OPEN call by the local port and
  836.   foreign socket arguments.  In return, the TCP supplies a (short) local
  837.   connection name by which the user refers to the connection in
  838.   subsequent calls.  There are several things that must be remembered
  839.   about a connection.  To store this information we imagine that there
  840.   is a data structure called a Transmission Control Block (TCB).  One
  841.   implementation strategy would have the local connection name be a
  842.   pointer to the TCB for this connection.  The OPEN call also specifies
  843.   whether the connection establishment is to be actively pursued, or to
  844.   be passively waited for.
  845.  
  846.   A passive OPEN request means that the process wants to accept incoming
  847.   connection requests rather than attempting to initiate a connection.
  848.   Often the process requesting a passive OPEN will accept a connection
  849.   request from any caller.  In this case a foreign socket of all zeros
  850.   is used to denote an unspecified socket.  Unspecified foreign sockets
  851.   are allowed only on passive OPENs.
  852.  
  853.   A service process that wished to provide services for unknown other
  854.   processes could issue a passive OPEN request with an unspecified
  855.   foreign socket.  Then a connection could be made with any process that
  856.   requested a connection to this local socket.  It would help if this
  857.   local socket were known to be associated with this service.
  858.  
  859.   Well-known sockets are a convenient mechanism for a priori associating
  860.   a socket address with a standard service.  For instance, the
  861.   "Telnet-Server" process might be permanently assigned to a particular
  862.   socket, and other sockets might be reserved for File Transfer, Remote
  863.   Job Entry, Text Generator, Echoer, and Sink processes (the last three
  864.   being for test purposes).  A socket address might be reserved for
  865.   access to a "Look-Up" service which would return the specific socket
  866.   at which a newly created service would be provided.  The concept of a
  867.   well-known socket is part of the TCP specification, but the assignment
  868.   of sockets to services is outside this specification.
  869.  
  870.   Processes can issue passive OPENs and wait for matching calls from
  871.   other processes and be informed by the TCP when connections have been
  872.   established.  Two processes which issue calls to each other at the
  873.   same time are correctly connected.  This flexibility is critical for
  874.  
  875.  
  876.  
  877.                                                                [Page 11]
  878.  
  879.  
  880.                                                             January 1980
  881. Transmission Control Protocol
  882. Philosophy
  883.  
  884.  
  885.  
  886.   the support of distributed computing in which components act
  887.   asynchronously with respect to each other.
  888.  
  889.   There are two cases for matching the sockets in the local request and
  890.   an incoming segment.  In the first case, the local request has fully
  891.   specified the foreign socket.  In this case, the match must be exact.
  892.   In the second case, the local request has left the foreign socket
  893.   unspecified.  In this case, any foreign socket is acceptable as long
  894.   as the local sockets match.
  895.  
  896.   If there are several pending passive OPENs (recorded in TCBs) with the
  897.   same local socket, an incoming segment should be matched to a request
  898.   with the specific foreign socket in the segment, if such a request
  899.   exists, before selecting a request with an unspecified foreign socket.
  900.  
  901.   The procedures to establish and clear connections utilize synchronize
  902.   (SYN) and finis (FIN) control flags and involve an exchange of three
  903.   messages.  This exchange has been termed a three-way hand shake [4].
  904.  
  905.   A connection is initiated by the rendezvous of an arriving segment
  906.   containing a SYN and a waiting TCB entry created by a user OPEN
  907.   command.  The matching of local and foreign sockets determines when a
  908.   connection has been initiated.  The connection becomes "established"
  909.   when sequence numbers have been synchronized in both directions.
  910.  
  911.   The clearing of a connection also involves the exchange of segments,
  912.   in this case carrying the FIN control flag.
  913.  
  914. 2.8.  Data Communication
  915.  
  916.   The data that flows on a connection may be thought of as a stream of
  917.   octets, or as a sequence of records.  In TCP the records are called
  918.   letters and are of variable length.  The sending user indicates in
  919.   each SEND call whether the data in that call completes a letter by the
  920.   setting of the end-of-letter parameter.
  921.  
  922.   The length of a letter may be such that it must be broken into
  923.   segments before it can be transmitted to its destination.  We assume
  924.   that the segments will normally be reassembled into a letter before
  925.   being passed to the receiving process.  A segment may contain all or a
  926.   part of a letter, but a segment never contains parts of more than one
  927.   letter.  The end of a letter is marked by the appearance of an EOL
  928.   control flag in a segment.  A sending TCP is allowed to collect data
  929.   from the sending user and to send that data in segments at its own
  930.   convenience, until the end of letter is signaled then it must send all
  931.   unsent data.  When a receiving TCP has a complete letter, it must not
  932.   wait for more data from the sending TCP before passing the letter to
  933.   the receiving process.
  934.  
  935.  
  936. [Page 12]                                                               
  937.  
  938.  
  939. January 1980                                                            
  940.                                            Transmission Control Protocol
  941.                                                               Philosophy
  942.  
  943.  
  944.  
  945.   There is a coupling between letters as sent and the use of buffers of
  946.   data that cross the TCP/user interface.  Each time an end-of-letter
  947.   (EOL) flag is associated with data placed into the receiving user's
  948.   buffer, the buffer is returned to the user for processing even if the
  949.   buffer is not filled.  If a letter is longer than the user's buffer,
  950.   the letter is passed to the user in buffer size units, the last of
  951.   which may be only partly full.  The receiving TCP's buffer size may be
  952.   communicated to the sending TCP when the connection is being
  953.   established.
  954.  
  955.   The TCP is responsible for regulating the flow of segments on the
  956.   connections, as a way of preventing itself from becoming saturated or
  957.   overloaded with traffic.  This is done using a window flow control
  958.   mechanism.  The data receiving TCP reports to the data sending TCP a
  959.   window which is the range of sequence numbers of data octets that data
  960.   receiving TCP is currently prepared to accept.
  961.  
  962.   TCP also provides a means to communicate to the receiver of data that
  963.   at some point further along in the data stream than the receiver is
  964.   currently reading there is urgent data.  TCP does not attempt to
  965.   define what the user specifically does upon being notified of pending
  966.   urgent data, but the general notion is that the receiving process
  967.   should take action to read through the end urgent data quickly.
  968.  
  969. 2.9.  Precedence and Security
  970.  
  971.   The TCP makes use of the internet protocol type of service field and
  972.   security option to provide precedence and security on a per connection
  973.   basis to TCP users.  Not all TCP modules will necessarily function in
  974.   a multilevel secure environment, some may be limited to unclassified
  975.   use only, and others may operate at only one security level and
  976.   compartment.  Consequently, some TCP implementations and services to
  977.   users may be limited to a subset of the multilevel secure case.
  978.  
  979.   TCP modules which operate in a multilevel secure environment should
  980.   properly mark outgoing segments with the security, compartment, and
  981.   precedence.  Such TCP modules should also provide to their users or
  982.   higher level protocols such as Telnet or THP an interface to allow
  983.   them to specify the desired security level, compartment, and
  984.   precedence of connections.
  985.  
  986. 2.10.  Robustness Principle
  987.  
  988.   TCP implementations should follow a general principle of robustness:
  989.   be conservative in what you do, be liberal in what you accept from
  990.   others.
  991.  
  992.   
  993.  
  994.  
  995.                                                                [Page 13]
  996.  
  997.  
  998.                                                             January 1980
  999. Transmission Control Protocol
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054. [Page 14]                                                               
  1055.  
  1056.  
  1057. January 1980                                                            
  1058.                                            Transmission Control Protocol
  1059.  
  1060.  
  1061.  
  1062.                       3.  FUNCTIONAL SPECIFICATION
  1063.  
  1064. 3.1.  Header Format
  1065.  
  1066.   TCP segments are sent as internet datagrams.  The Internet Protocol
  1067.   header carries several information fields, including the source and
  1068.   destination host addresses [2].  A TCP header follows the internet
  1069.   header, supplying information specific to the TCP protocol.  This
  1070.   division allows for the existence of host level protocols other than
  1071.   TCP.
  1072.  
  1073.   TCP Header Format
  1074.  
  1075.                                     
  1076.     0                   1                   2                   3   
  1077.     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 
  1078.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1079.    |          Source Port          |       Destination Port        |
  1080.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1081.    |                        Sequence Number                        |
  1082.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1083.    |                    Acknowledgment Number                      |
  1084.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1085.    |  Data |           |U|A|E|R|S|F|                               |
  1086.    | Offset| Reserved  |R|C|O|S|Y|I|            Window             |
  1087.    |       |           |G|K|L|T|N|N|                               |
  1088.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1089.    |           Checksum            |         Urgent Pointer        |
  1090.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1091.    |                    Options                    |    Padding    |
  1092.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1093.    |                             data                              |
  1094.    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1095.  
  1096.                             TCP Header Format
  1097.  
  1098.           Note that one tick mark represents one bit position.
  1099.  
  1100.                                Figure 3.
  1101.  
  1102.   Source Port:  16 bits
  1103.  
  1104.     The source port number.
  1105.  
  1106.   Destination Port:  16 bits
  1107.  
  1108.     The destination port number.
  1109.  
  1110.  
  1111.  
  1112.  
  1113.                                                                [Page 15]
  1114.  
  1115.  
  1116.                                                             January 1980
  1117. Transmission Control Protocol
  1118. Functional Specification
  1119.  
  1120.  
  1121.  
  1122.   Sequence Number:  32 bits
  1123.  
  1124.     The sequence number of the first data octet in this segment (except
  1125.     when SYN is present).
  1126.  
  1127.   Acknowledgment Number:  32 bits
  1128.  
  1129.     If the ACK control bit is set this field contains the value of the
  1130.     next sequence number the sender of the segment is expecting to
  1131.     receive.  Once a connection is established this is always sent.
  1132.  
  1133.   Data Offset:  4 bits
  1134.  
  1135.     The number of 32 bit words in the TCP Header.  This indicates where
  1136.     the data begins.  The TCP header including options is an integral
  1137.     number of 32 bits long.
  1138.  
  1139.   Reserved:  6 bits
  1140.  
  1141.     Reserved for future use.  Must be zero.
  1142.  
  1143.   Control Bits:  8 bits (from left to right):
  1144.  
  1145.     URG:  Urgent Pointer field significant
  1146.     ACK:  Acknowledgment field significant
  1147.     EOL:  End of Letter
  1148.     RST:  Reset the connection
  1149.     SYN:  Synchronize sequence numbers
  1150.     FIN:  No more data from sender
  1151.  
  1152.   Window:  16 bits
  1153.  
  1154.     The number of data octets beginning with the one indicated in the
  1155.     acknowledgment field which the sender of this segment is willing to
  1156.     accept.
  1157.  
  1158.   Checksum:  16 bits
  1159.  
  1160.     The checksum field is the 16 bit one's complement of the one's
  1161.     complement sum of all 16 bit words in the header and text.  If a
  1162.     segment contains an odd number of header and text octets to be
  1163.     checksummed, the last octet is padded on the right with zeros to
  1164.     form a 16 bit word for checksum purposes.  The pad is not
  1165.     transmitted as part of the segment.  While computing the checksum,
  1166.     the checksum field itself is replaced with zeros.
  1167.  
  1168.     The checksum also covers a 96 bit pseudo header conceptually
  1169.     prefixed to the TCP header.  This pseudo header contains the Source
  1170.  
  1171.  
  1172. [Page 16]                                                               
  1173.  
  1174.  
  1175. January 1980                                                            
  1176.                                            Transmission Control Protocol
  1177.                                                 Functional Specification
  1178.  
  1179.  
  1180.  
  1181.     Address, the Destination Address, the Protocol, and TCP length.
  1182.     This gives the TCP protection against misrouted segments.  This
  1183.     information is carried in the Internet Protocol and is transferred
  1184.     across the TCP/Network interface in the arguments or results of
  1185.     calls by the TCP on the IP.
  1186.  
  1187.                      +--------------------------+
  1188.                      |      Source Address      |
  1189.                      +--------------------------+
  1190.                      |    Destination Address   |
  1191.                      +--------------------------+
  1192.                      | zero | PTCL | TCP Length |
  1193.                      +--------------------------+
  1194.  
  1195.       The TCP Length is the TCP header plus the data length in octets
  1196.       (this is not an explicitly transmitted quantity, but is computed
  1197.       from the total length, and the header length).
  1198.  
  1199.   Urgent Pointer:  16 bits
  1200.  
  1201.     This field communicates the current value of the urgent pointer as a
  1202.     positive offset from the sequence number in this segment.  The
  1203.     urgent pointer points to the sequence number of the octet following
  1204.     the urgent data.  This field should only be interpreted in segments
  1205.     with the URG control bit set.
  1206.  
  1207.   Options:  variable
  1208.  
  1209.     Options may occupy space at the end of the TCP header and are a
  1210.     multiple of 8 bits in length.  All options are included in the
  1211.     checksum.  An option may begin on any octet boundary.  There are two
  1212.     cases for the format of an option:
  1213.  
  1214.       Case 1:  A single octet of option-kind.
  1215.  
  1216.       Case 2:  An octet of option-kind, an octet of option-length, and
  1217.                the actual option-data octets.
  1218.  
  1219.     The option-length counts the two octets of option-kind and
  1220.     option-length as well as the option-data octets.
  1221.  
  1222.     Note that the list of options may be shorter than the data offset
  1223.     field might imply.  The content of the header beyond the
  1224.     End-of-Option option should be header padding (i.e., zero).
  1225.  
  1226.     A TCP must implement all options.
  1227.  
  1228.  
  1229.  
  1230.  
  1231.                                                                [Page 17]
  1232.  
  1233.  
  1234.                                                             January 1980
  1235. Transmission Control Protocol
  1236. Functional Specification
  1237.  
  1238.  
  1239.  
  1240.     Currently defined options include (kind indicated in octal):
  1241.  
  1242.       Kind     Length    Meaning
  1243.       ----     ------    -------
  1244.        0         -       End of option list.
  1245.        1         -       No-Operation.
  1246.       100        -       Reserved.
  1247.       105        4       Buffer Size.
  1248.       
  1249.  
  1250.     Specific Option Definitions
  1251.  
  1252.       End of Option List
  1253.  
  1254.         +--------+
  1255.         |00000000|
  1256.         +--------+
  1257.          Kind=0
  1258.  
  1259.         This option code indicates the end of the option list.  This
  1260.         might not coincide with the end of the TCP header according to
  1261.         the Data Offset field.  This is used at the end of all options,
  1262.         not the end of each option, and need only be used if the end of
  1263.         the options would not otherwise coincide with the end of the TCP
  1264.         header.
  1265.  
  1266.       No-Operation
  1267.  
  1268.         +--------+
  1269.         |00000001|
  1270.         +--------+
  1271.          Kind=1
  1272.  
  1273.         This option code may be used between options, for example, to
  1274.         align the beginning of a subsequent option on a word boundary.
  1275.         There is no guarantee that senders will use this option, so
  1276.         receivers must be prepared to process options even if they do
  1277.         not begin on a word boundary.
  1278.  
  1279.       Buffer Size
  1280.  
  1281.         +--------+--------+---------+--------+
  1282.         |01000101|00000100|    buffer size   |
  1283.         +--------+--------+---------+--------+
  1284.          Kind=105 Length=4
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290. [Page 18]                                                               
  1291.  
  1292.  
  1293. January 1980                                                            
  1294.                                            Transmission Control Protocol
  1295.                                                 Functional Specification
  1296.  
  1297.  
  1298.  
  1299.         Buffer Size Option Data:  16 bits
  1300.  
  1301.           If this option is present, then it communicates the receive
  1302.           buffer size at the TCP which sends this segment.  This field
  1303.           should only be sent in the initial connection request (i.e.,
  1304.           in segments with the SYN control bit set).  If this option is
  1305.           not used, the default buffer size of one octet is assumed.
  1306.  
  1307.   Padding:  variable
  1308.  
  1309.     The TCP header padding is used to ensure that the TCP header ends
  1310.     and data begins on a 32 bit boundary.  The padding is composed of
  1311.     zeros.
  1312.  
  1313. 3.2.  Terminology
  1314.  
  1315.   Before we can discuss very much about the operation of the TCP we need
  1316.   to introduce some detailed terminology.  The maintenance of a TCP
  1317.   connection requires the remembering of several variables.  We conceive
  1318.   of these variables being stored in a connection record called a
  1319.   Transmission Control Block or TCB.  Among the variables stored in the
  1320.   TCB are the local and remote socket numbers, the security and
  1321.   precedence of the connection, pointers to the user's send and receive
  1322.   buffers, pointers to the retransmit queue and to the current segment.
  1323.   In addition several variables relating to the send and receive
  1324.   sequence numbers are stored in the TCB.
  1325.  
  1326.     Send Sequence Variables
  1327.  
  1328.       SND.UNA - send unacknowledged
  1329.       SND.NXT - send sequence
  1330.       SND.WND - send window
  1331.       SND.BS  - send buffer size
  1332.       SND.UP  - send urgent pointer
  1333.       SND.WL  - send sequence number used for last window update
  1334.       SND.LBB - send last buffer beginning
  1335.       ISS     - initial send sequence number
  1336.  
  1337.     Receive Sequence Variables
  1338.  
  1339.       RCV.NXT - receive sequence
  1340.       RCV.WND - receive window
  1341.       RCV.BS  - receive buffer size
  1342.       RCV.UP  - receive urgent pointer
  1343.       RCV.LBB - receive last buffer beginning
  1344.       IRS     - initial receive sequence number
  1345.  
  1346.  
  1347.  
  1348.  
  1349.                                                                [Page 19]
  1350.  
  1351.  
  1352.                                                             January 1980
  1353. Transmission Control Protocol
  1354. Functional Specification
  1355.  
  1356.  
  1357.  
  1358.   The following diagrams may help to relate some of these variables to
  1359.   the sequence space.
  1360.  
  1361.   Send Sequence Space
  1362.  
  1363.                    1         2          3          4      
  1364.               ----------|----------|----------|---------- 
  1365.                      SND.UNA    SND.NXT    SND.UNA        
  1366.                                           +SND.WND        
  1367.  
  1368.         1 - old sequence numbers which have been acknowledged  
  1369.         2 - sequence numbers of unacknowledged data            
  1370.         3 - sequence numbers allowed for new data transmission 
  1371.         4 - future sequence numbers which are not yet allowed  
  1372.  
  1373.                           Send Sequence Space
  1374.  
  1375.                                Figure 4.
  1376.     
  1377.     
  1378.  
  1379.   Receive Sequence Space
  1380.  
  1381.                        1          2          3      
  1382.                    ----------|----------|---------- 
  1383.                           RCV.NXT    RCV.NXT        
  1384.                                     +RCV.WND        
  1385.  
  1386.         1 - old sequence numbers which have been acknowledged  
  1387.         2 - sequence numbers allowed for new reception         
  1388.         3 - future sequence numbers which are not yet allowed  
  1389.  
  1390.                          Receive Sequence Space
  1391.  
  1392.                                Figure 5.
  1393.     
  1394.     
  1395.  
  1396.   There are also some variables used frequently in the discussion that
  1397.   take their values from the fields of the current segment.
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408. [Page 20]                                                               
  1409.  
  1410.  
  1411. January 1980                                                            
  1412.                                            Transmission Control Protocol
  1413.                                                 Functional Specification
  1414.  
  1415.  
  1416.  
  1417.     Current Segment Variables
  1418.  
  1419.       SEG.SEQ - segment sequence number
  1420.       SEG.ACK - segment acknowledgment number
  1421.       SEG.LEN - segment length
  1422.       SEG.WND - segment window
  1423.       SEG.UP  - segment urgent pointer
  1424.       SEG.PRC - segment precedence value
  1425.  
  1426.   A connection progresses through a series of states during its
  1427.   lifetime.  The states are:  LISTEN, SYN-SENT, SYN-RECEIVED,
  1428.   ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING,
  1429.   and the fictional state CLOSED.  CLOSED is fictional because it
  1430.   represents the state when there is no TCB, and therefore, no
  1431.   connection.  Briefly the meanings of the states are:
  1432.  
  1433.     LISTEN - represents waiting for a connection request from any remote
  1434.     TCP and port.
  1435.  
  1436.     SYN-SENT - represents waiting for a matching connection request
  1437.     after having sent a connection request.
  1438.  
  1439.     SYN-RECEIVED - represents waiting for a confirming connection
  1440.     request acknowledgment after having both received and sent a
  1441.     connection request.
  1442.  
  1443.     ESTABLISHED - represents an open connection, ready to transmit and
  1444.     receive data segments.
  1445.  
  1446.     FIN-WAIT-1 - represents waiting for a connection termination request
  1447.     from the remote TCP, or an acknowledgment of the connection
  1448.     termination request previously sent.
  1449.  
  1450.     FIN-WAIT-2 - represents waiting for a connection termination request
  1451.     from the remote TCP.
  1452.  
  1453.     TIME-WAIT - represents waiting for enough time to pass to be sure
  1454.     the remote TCP received the acknowledgment of its connection
  1455.     termination request.
  1456.  
  1457.     CLOSE-WAIT - represents waiting for a connection termination request
  1458.     from the local user.
  1459.  
  1460.     CLOSING - represents waiting for a connection termination request
  1461.     acknowledgment from the remote TCP.
  1462.  
  1463.     CLOSED - represents no connection state at all.
  1464.  
  1465.  
  1466.  
  1467.                                                                [Page 21]
  1468.  
  1469.  
  1470.                                                             January 1980
  1471. Transmission Control Protocol
  1472. Functional Specification
  1473.  
  1474.  
  1475.  
  1476.   A TCP connection progresses from one state to another in response to
  1477.   events.  The events are the user calls, OPEN, SEND, RECEIVE, CLOSE,
  1478.   ABORT, and STATUS; the incoming segments, particularly those
  1479.   containing the SYN and FIN flags; and timeouts.
  1480.  
  1481.   The Glossary contains a more complete list of terms and their
  1482.   definitions.
  1483.  
  1484.   The state diagram in figure 6 only illustrates state changes, together
  1485.   with the causing events and resulting actions, but addresses neither
  1486.   error conditions nor actions which are not connected with state
  1487.   changes.  In a later section, more detail is offered with respect to
  1488.   the reaction of the TCP to events.
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526. [Page 22]                                                               
  1527.  
  1528.  
  1529. January 1980                                                            
  1530.                                            Transmission Control Protocol
  1531.                                                 Functional Specification
  1532.  
  1533.  
  1534.  
  1535.                                     
  1536.                               +---------+ ---------\      active OPEN  
  1537.                               |  CLOSED |            \    -----------  
  1538.                               +---------+<---------\   \   create TCB  
  1539.                                 |     ^              \   \  snd SYN    
  1540.                    passive OPEN |     |   CLOSE        \   \           
  1541.                    ------------ |     | ----------       \   \         
  1542.                     create TCB  |     | delete TCB         \   \       
  1543.                                 V     |                      \   \     
  1544.                               +---------+            CLOSE    |    \   
  1545.                               |  LISTEN |          ---------- |     |  
  1546.                               +---------+          delete TCB |     |  
  1547.                    rcv SYN      |     |     SEND              |     |  
  1548.                   -----------   |     |    -------            |     V  
  1549.  +---------+      snd SYN,ACK  /       \   snd SYN          +---------+
  1550.  |         |<-----------------           ------------------>|         |
  1551.  |   SYN   |                    rcv SYN                     |   SYN   |
  1552.  |   RCVD  |<-----------------------------------------------|   SENT  |
  1553.  |         |                    snd ACK                     |         |
  1554.  |         |------------------           -------------------|         |
  1555.  +---------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +---------+
  1556.    |           --------------   |     |   -----------                  
  1557.    |                  x         |     |     snd ACK                    
  1558.    |                            V     V                                
  1559.    |  CLOSE                   +---------+                              
  1560.    | -------                  |  ESTAB  |                              
  1561.    | snd FIN                  +---------+                              
  1562.    |                   CLOSE    |     |    rcv FIN                     
  1563.    V                  -------   |     |    -------                     
  1564.  +---------+          snd FIN  /       \   snd ACK          +---------+
  1565.  |  FIN    |<-----------------           ------------------>|  CLOSE  |
  1566.  | WAIT-1  |------------------           -------------------|   WAIT  |
  1567.  +---------+          rcv FIN  \       /   CLOSE            +---------+
  1568.    | rcv ACK of FIN   -------   |     |   -------                      
  1569.    | --------------   snd ACK   |     |   snd FIN                      
  1570.    V        x                   V     V                                
  1571.  +---------+                  +---------+                              
  1572.  |FINWAIT-2|                  | CLOSING |                              
  1573.  +---------+                  +---------+                              
  1574.    | rcv FIN                          | rcv ACK of FIN                 
  1575.    | -------    Timeout=2MSL          | --------------                 
  1576.    V snd ACK    ------------          V   delete TCB                   
  1577.  +---------+     delete TCB   +---------+                              
  1578.  |TIME WAIT|----------------->| CLOSED  |                              
  1579.  +---------+                  +---------+                              
  1580.  
  1581.                       TCP Connection State Diagram
  1582.                                Figure 6.
  1583.  
  1584.  
  1585.                                                                [Page 23]
  1586.  
  1587.  
  1588.                                                             January 1980
  1589. Transmission Control Protocol
  1590. Functional Specification
  1591.  
  1592.  
  1593.  
  1594. 3.3.  Sequence Numbers
  1595.  
  1596.   A fundamental notion in the design is that every octet of data sent
  1597.   over a TCP connection has a sequence number.  Since every octet is
  1598.   sequenced, each of them can be acknowledged.  The acknowledgment
  1599.   mechanism employed is cumulative so that an acknowledgment of sequence
  1600.   number X indicates that all octets up to but not including X have been
  1601.   received.  This mechanism allows for straight-forward duplicate
  1602.   detection in the presence of retransmission.  Numbering of octets
  1603.   within a segment is that the first data octet immediately following
  1604.   the header is the lowest numbered, and the following octets are
  1605.   numbered consecutively.
  1606.  
  1607.   It is essential to remember that the actual sequence number space is
  1608.   finite, though very large.  This space ranges from 0 to 2**32 - 1.
  1609.   Since the space is finite, all arithmetic dealing with sequence
  1610.   numbers must be performed modulo 2**32.  This unsigned arithmetic
  1611.   preserves the relationship of sequence numbers as they cycle from
  1612.   2**32 - 1 to 0 again.  There are some subtleties to computer modulo
  1613.   arithmetic, so great care should be taken in programming the
  1614.   comparison of such values.  The typical kinds of sequence number
  1615.   comparisons which the TCP must perform include:
  1616.  
  1617.     (a)  Determining that an acknowledgment refers to some sequence
  1618.          number sent but not yet acknowledged.
  1619.  
  1620.     (b)  Determining that all sequence numbers occupied by a segment
  1621.          have been acknowledged (e.g., to remove the segment from a
  1622.          retransmission queue).
  1623.  
  1624.     (c)  Determining that an incoming segment contains sequence numbers
  1625.          which are expected (i.e., that the segment "overlaps" the
  1626.          receive window).
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644. [Page 24]                                                               
  1645.  
  1646.  
  1647. January 1980                                                            
  1648.                                            Transmission Control Protocol
  1649.                                                 Functional Specification
  1650.  
  1651.  
  1652.  
  1653.   On send connections the following comparisons are needed:
  1654.  
  1655.     older sequence numbers                        newer sequence numbers
  1656.  
  1657.                                     
  1658.         SND.UNA                SEG.ACK                 SND.NXT  
  1659.            |                      |                       |     
  1660.        ----|----XXXXXXX------XXXXXXXXXX---------XXXXXX----|---- 
  1661.            |    |            |    |             |         |     
  1662.                 |            |                  |               
  1663.              Segment 1    Segment 2          Segment 3          
  1664.  
  1665.                       <----- sequence space ----->
  1666.  
  1667.                    Sending Sequence Space Information
  1668.  
  1669.                                Figure 7.
  1670.  
  1671.     SND.UNA = oldest unacknowledged sequence number
  1672.  
  1673.     SND.NXT = next sequence number to be sent
  1674.  
  1675.     SEG.ACK = acknowledgment (next sequence number expected by the
  1676.               acknowledging TCP)
  1677.  
  1678.     SEG.SEQ = first sequence number of a segment
  1679.  
  1680.     SEG.SEQ+SEG.LEN-1 = last sequence number of a segment
  1681.  
  1682.   A new acknowledgment (called an "acceptable ack"), is one for which
  1683.   the inequality below holds:
  1684.  
  1685.     SND.UNA < SEG.ACK =< SND.NXT
  1686.  
  1687.   All arithmetic is modulo 2**32 and that comparisons are unsigned.
  1688.   "=<" means "less than or equal".
  1689.  
  1690.   A segment on the retransmission queue is fully acknowledged if the sum
  1691.   of its sequence number and length is less than the acknowledgment
  1692.   value in the incoming segment.
  1693.  
  1694.   SEG.LEN is the number of octets occupied by the data in the segment.
  1695.   It is important to note that SEG.LEN must be non-zero; segments which
  1696.   do not occupy any sequence space (e.g., empty acknowledgment segments)
  1697.   are never placed on the retransmission queue, so would not go through
  1698.   this particular test.
  1699.  
  1700.  
  1701.  
  1702.  
  1703.                                                                [Page 25]
  1704.  
  1705.  
  1706.                                                             January 1980
  1707. Transmission Control Protocol
  1708. Functional Specification
  1709.  
  1710.  
  1711.  
  1712.   On receive connections the following comparisons are needed:
  1713.  
  1714.     older sequence numbers                        newer sequence numbers
  1715.  
  1716.                                     
  1717.                 RCV.NXT                         RCV.NXT+RCV.WND 
  1718.                    |                               |            
  1719.        ---------XXX|XXX------XXXXXXXXXX---------XXX|XX--------- 
  1720.                 |  |         |                  |  |            
  1721.                 |            |                  |               
  1722.              Segment 1    Segment 2          Segment 3          
  1723.  
  1724.                       <----- sequence space ----->
  1725.  
  1726.                   Receiving Sequence Space Information
  1727.  
  1728.                                 Figure 8.
  1729.  
  1730.     RCV.NXT = next sequence number expected on incoming segments
  1731.  
  1732.     RCV.NXT+RCV.WND = last sequence number expected on incoming
  1733.         segments, plus one
  1734.  
  1735.     SEG.SEQ = first sequence number occupied by the incoming segment
  1736.  
  1737.     SEG.SEQ+SEG.LEN-1 = last sequence number occupied by the incoming
  1738.         segment
  1739.  
  1740.   A segment is judged to occupy a portion of valid receive sequence
  1741.   space if
  1742.  
  1743.      0 =< (SEG.SEQ+SEG.LEN-1 - RCV.NXT) < (RCV.NXT+RCV.WND - RCV.NXT)
  1744.  
  1745.   SEG.SEQ+SEG.LEN-1 is the last sequence number occupied by the segment;
  1746.   RCV.NXT is the next sequence number expected on an incoming segment;
  1747.   and RCV.NXT+RCV.WND is the right edge of the receive window.
  1748.  
  1749.   Actually, it is a little more complicated than this.  Due to zero
  1750.   windows and zero length segments, we have four cases for the
  1751.   acceptability of an incoming segment:
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762. [Page 26]                                                               
  1763.  
  1764.  
  1765. January 1980                                                            
  1766.                                            Transmission Control Protocol
  1767.                                                 Functional Specification
  1768.  
  1769.  
  1770.  
  1771.     Segment Receive  Test
  1772.     Length  Window
  1773.     ------- -------  -------------------------------------------
  1774.  
  1775.        0       0     SEG.SEQ = RCV.NXT
  1776.  
  1777.        0      >0     RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
  1778.  
  1779.       >0       0     not acceptable
  1780.  
  1781.       >0      >0     RCV.NXT < SEG.SEQ+SEG.LEN =< RCV.NXT+RCV.WND
  1782.  
  1783.   Note that the acceptance test for a segment, since it requires the end
  1784.   of a segment to lie in the window, is somewhat more restrictive than
  1785.   is absolutely necessary.  If at least the first sequence number of the
  1786.   segment lies in the receive window, or if some part of the segment
  1787.   lies in the receive window, then the segment might be judged
  1788.   acceptable.  Thus, in figure 8, at least segments 1 and 2 are
  1789.   acceptable by the strict rule, and segment 3 may or may not be,
  1790.   depending on the strictness of interpretation of the rule.
  1791.  
  1792.   Note that when the receive window is zero no segments should be
  1793.   acceptable except ACK segments.  Thus, it should be possible for a TCP
  1794.   to maintain a zero receive window while transmitting data and
  1795.   receiving ACKs.
  1796.  
  1797.   We have taken advantage of the numbering scheme to protect certain
  1798.   control information as well.  This is achieved by implicitly including
  1799.   some control flags in the sequence space so they can be retransmitted
  1800.   and acknowledged without confusion (i.e., one and only one copy of the
  1801.   control will be acted upon).  Control information is not physically
  1802.   carried in the segment data space.  Consequently, we must adopt rules
  1803.   for implicitly assigning sequence numbers to control.  The SYN and FIN
  1804.   are the only controls requiring this protection, and these controls
  1805.   are used only at connection opening and closing.  For sequence number
  1806.   purposes, the SYN is considered to occur before the first actual data
  1807.   octet of the segment in which it occurs, while the FIN is considered
  1808.   to occur after the last actual data octet in a segment in which it
  1809.   occurs.  The segment length includes both data and sequence space
  1810.   occupying controls.  When a SYN is present then SEG.SEQ is the
  1811.   sequence number of the SYN.
  1812.  
  1813.   Initial Sequence Number Selection
  1814.  
  1815.   The protocol places no restriction on a particular connection being
  1816.   used over and over again.  A connection is defined by a pair of
  1817.   sockets.  New instances of a connection will be referred to as
  1818.   incarnations of the connection.  The problem that arises owing to this
  1819.  
  1820.  
  1821.                                                                [Page 27]
  1822.  
  1823.  
  1824.                                                             January 1980
  1825. Transmission Control Protocol
  1826. Functional Specification
  1827.  
  1828.  
  1829.  
  1830.   is -- "how does the TCP identify duplicate segments from previous
  1831.   incarnations of the connection?"  This problem becomes apparent if the
  1832.   connection is being opened and closed in quick succession, or if the
  1833.   connection breaks with loss of memory and is then reestablished.
  1834.  
  1835.   To avoid confusion we must prevent segments from one incarnation of a
  1836.   connection from being used while the same sequence numbers may still
  1837.   be present in the network from an earlier incarnation.  We want to
  1838.   assure this, even if a TCP crashes and loses all knowledge of the
  1839.   sequence numbers it has been using.  When new connections are created,
  1840.   an initial sequence number (ISN) generator is employed which selects a
  1841.   new 32 bit ISN.  The generator is bound to a (possibly fictitious) 32
  1842.   bit clock whose low order bit is incremented roughly every 4
  1843.   microseconds.  Thus, the ISN cycles approximately every 4.55 hours.
  1844.   Since we assume that segments will stay in the network no more than
  1845.   tens of seconds or minutes, at worst, we can reasonably assume that
  1846.   ISN's will be unique.
  1847.  
  1848.   For each connection there is a send sequence number and a receive
  1849.   sequence number.  The initial send sequence number (ISS) is chosen by
  1850.   the data sending TCP, and the initial receive sequence number (IRS) is
  1851.   learned during the connection establishing procedure.
  1852.  
  1853.   For a connection to be established or initialized, the two TCPs must
  1854.   synchronize on each other's initial sequence numbers.  This is done in
  1855.   an exchange of connection establishing messages carrying a control bit
  1856.   called "SYN" (for synchronize) and the initial sequence numbers.  As a
  1857.   shorthand, messages carrying the SYN bit are also called "SYNs".
  1858.   Hence, the solution requires a suitable mechanism for picking an
  1859.   initial sequence number and a slightly involved handshake to exchange
  1860.   the ISN's.  A "three way handshake" is necessary because sequence
  1861.   numbers are not tied to a global clock in the network, and TCPs may
  1862.   have different mechanisms for picking the ISN's.  The receiver of the
  1863.   first SYN has no way of knowing whether the segment was an old delayed
  1864.   one or not, unless it remembers the last sequence number used on the
  1865.   connection (which is not always possible), and so it must ask the
  1866.   sender to verify this SYN.
  1867.  
  1868.   The "three way handshake" and the advantages of a "clock-driven"
  1869.   scheme are discussed in [4].
  1870.  
  1871.   Knowing When to Keep Quiet
  1872.  
  1873.   To be sure that a TCP does not create a segment that carries a
  1874.   sequence number which may be duplicated by an old segment remaining in
  1875.   the network, the TCP must keep quiet for a maximum segment lifetime
  1876.   (MSL) before assigning any sequence numbers upon starting up or
  1877.   recovering from a crash in which memory of sequence numbers in use was
  1878.  
  1879.  
  1880. [Page 28]                                                               
  1881.  
  1882.  
  1883. January 1980                                                            
  1884.                                            Transmission Control Protocol
  1885.                                                 Functional Specification
  1886.  
  1887.  
  1888.  
  1889.   lost.  For this specification the MSL is taken to be 2 minutes.  This
  1890.   is an engineering choice, and may be changed if experience indicates
  1891.   it is desirable to do so.  Note that if a TCP is reinitialized in some
  1892.   sense, yet retains its memory of sequence numbers in use, then it need
  1893.   not wait at all; it must only be sure to use sequence numbers larger
  1894.   than those recently used.
  1895.  
  1896.   It should be noted that this strategy does not protect against
  1897.   spoofing or other replay type duplicate message problems.
  1898.  
  1899. 3.4.  Establishing a connection
  1900.  
  1901.   The "three-way handshake" is the procedure used to establish a
  1902.   connection.  This procedure normally is initiated by one TCP and
  1903.   responded to by another TCP.  The procedure also works if two TCP
  1904.   simultaneously initiate the procedure.  When simultaneous attempt
  1905.   occurs, the TCP receives a "SYN" segment which carries no
  1906.   acknowledgment after it has sent a "SYN".  Of course, the arrival of
  1907.   an old duplicate "SYN" segment can potentially make it appear, to the
  1908.   recipient, that a simultaneous connection initiation is in progress.
  1909.   Proper use of "reset" segments can disambiguate these cases.  Several
  1910.   examples of connection initiation follow.  Although these examples do
  1911.   not show connection synchronization using data-carrying segments, this
  1912.   is perfectly legitimate, so long as the receiving TCP doesn't deliver
  1913.   the data to the user until it is clear the data is valid (i.e., the
  1914.   data must be buffered at the receiver until the connection reaches the
  1915.   ESTABLISHED state).  The three-way handshake reduces the possibility
  1916.   of false connections.  It is the implementation of a trade-off between
  1917.   memory and messages to provide information for this checking.
  1918.  
  1919.   The simplest three-way handshake is shown in figure 9 below.  The
  1920.   figures should be interpreted in the following way.  Each line is
  1921.   numbered for reference purposes.  Right arrows (-->) indicate
  1922.   departure of a TCP segment from TCP A to TCP B, or arrival of a
  1923.   segment at B from A.  Left arrows (<--), indicate the reverse.
  1924.   Ellipsis (...) indicates a segment which is still in the network
  1925.   (delayed).  An "XXX" indicates a segment which is lost or rejected.
  1926.   Comments appear in parentheses.  TCP states represent the state AFTER
  1927.   the departure or arrival of the segment (whose contents are shown in
  1928.   the center of each line).  Segment contents are shown in abbreviated
  1929.   form, with sequence number, control flags, and ACK field.  Other
  1930.   fields such as window, addresses, lengths, and text have been left out
  1931.   in the interest of clarity.
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.                                                                [Page 29]
  1940.  
  1941.  
  1942.                                                             January 1980
  1943. Transmission Control Protocol
  1944. Functional Specification
  1945.  
  1946.  
  1947.  
  1948.   
  1949.  
  1950.       TCP A                                                TCP B
  1951.  
  1952.   1.  CLOSED                                               LISTEN
  1953.  
  1954.   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  1955.  
  1956.   3.  ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  1957.  
  1958.   4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED
  1959.  
  1960.   5.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED
  1961.  
  1962.           Basic 3-Way Handshake for Connection Synchronization
  1963.  
  1964.                                 Figure 9.
  1965.  
  1966.   In line 2 of figure 9, TCP A begins by sending a SYN segment
  1967.   indicating that it will use sequence numbers starting with sequence
  1968.   number 100.  In line 3, TCP B sends a SYN and acknowledges the SYN it
  1969.   received from TCP A.  Note that the acknowledgment field indicates TCP
  1970.   B is now expecting to hear sequence 101, acknowledging the SYN which
  1971.   occupied sequence 100.
  1972.  
  1973.   At line 4, TCP A responds with an empty segment containing an ACK for
  1974.   TCP B's SYN; and in line 5, TCP A sends some data.  Note that the
  1975.   sequence number of the segment in line 5 is the same as in line 4
  1976.   because the ACK does not occupy sequence number space (if it did, we
  1977.   would wind up ACKing ACK's!).
  1978.  
  1979.   Simultaneous initiation is only slightly more complex, as is shown in
  1980.   figure 10.  Each TCP cycles from CLOSED to SYN-SENT to SYN-RECEIVED to
  1981.   ESTABLISHED.
  1982.  
  1983.   The principle reason for the three-way handshake is to prevent old
  1984.   duplicate connection initiations from causing confusion.  To deal with
  1985.   this, a special control message, reset, has been devised.  If the
  1986.   receiving TCP is in a  non-synchronized state (i.e., SYN-SENT,
  1987.   SYN-RECEIVED), it returns to LISTEN on receiving an acceptable reset.
  1988.   If the TCP is in one of the synchronized states (ESTABLISHED,
  1989.   FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING), it aborts the
  1990.   connection and informs its user.  We discuss this latter case under
  1991.   "half-open" connections below.
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998. [Page 30]                                                               
  1999.  
  2000.  
  2001. January 1980                                                            
  2002.                                            Transmission Control Protocol
  2003.                                                 Functional Specification
  2004.  
  2005.  
  2006.  
  2007.   
  2008.  
  2009.       TCP A                                        TCP B
  2010.  
  2011.   1.  CLOSED                                       CLOSED
  2012.  
  2013.   2.  SYN-SENT     --> <SEQ=100><CTL=SYN>          ...
  2014.  
  2015.   3.  SYN-RECEIVED <-- <SEQ=300><CTL=SYN>          <-- SYN-SENT
  2016.  
  2017.   4.               ... <SEQ=100><CTL=SYN>          --> SYN-RECEIVED
  2018.  
  2019.   5.  SYN-RECEIVED --> <SEQ=101><ACK=301><CTL=ACK> ...
  2020.  
  2021.   6.  ESTABLISHED  <-- <SEQ=301><ACK=101><CTL=ACK> <-- SYN-RECEIVED
  2022.  
  2023.   7.               ... <SEQ=101><ACK=301><CTL=ACK> --> ESTABLISHED
  2024.  
  2025.                 Simultaneous Connection Synchronization
  2026.  
  2027.                                Figure 10.
  2028.  
  2029.   
  2030.  
  2031.       TCP A                                                TCP B
  2032.  
  2033.   1.  CLOSED                                               LISTEN
  2034.  
  2035.   2.  SYN-SENT    --> <SEQ=100><CTL=SYN>               ...
  2036.  
  2037.   3.  (duplicate) ... <SEQ=1000><CTL=SYN>              --> SYN-RECEIVED
  2038.  
  2039.   4.  SYN-SENT    <-- <SEQ=300><ACK=1001><CTL=SYN,ACK> <-- SYN-RECEIVED
  2040.  
  2041.   5.  SYN-SENT    --> <SEQ=1001><CTL=RST>              --> LISTEN
  2042.   
  2043.  
  2044.   6.              ... <SEQ=100><CTL=SYN>               --> SYN-RECEIVED
  2045.  
  2046.   7.  SYN-SENT    <-- <SEQ=400><ACK=101><CTL=SYN,ACK>  <-- SYN-RECEIVED
  2047.  
  2048.   8.  ESTABLISHED --> <SEQ=101><ACK=401><CTL=ACK>      --> ESTABLISHED
  2049.  
  2050.                     Recovery from Old Duplicate SYN
  2051.  
  2052.                                Figure 11.
  2053.  
  2054.   As a simple example of recovery from old duplicates, consider
  2055.  
  2056.  
  2057.                                                                [Page 31]
  2058.  
  2059.  
  2060.                                                             January 1980
  2061. Transmission Control Protocol
  2062. Functional Specification
  2063.  
  2064.  
  2065.  
  2066.   figure 11.  At line 3, an old duplicate SYN arrives at TCP B.  TCP B
  2067.   cannot tell that this is an old duplicate, so it responds normally
  2068.   (line 4).  TCP A detects that the ACK field is incorrect and returns a
  2069.   RST (reset) with its SEQ field selected to make the segment
  2070.   believable.  TCP B, on receiving the RST, returns to the LISTEN state.
  2071.   When the original SYN (pun intended) finally arrives at line 6, the
  2072.   synchronization proceeds normally.  If the SYN at line 6 had arrived
  2073.   before the RST, a more complex exchange might have occurred with RST's
  2074.   sent in both directions.
  2075.  
  2076.   Half-Open Connections and Other Anomalies
  2077.  
  2078.   An established connection is said to be  "half-open" if one of the
  2079.   TCPs has closed or aborted the connection at its end without the
  2080.   knowledge of the other, or if the two ends of the connection have
  2081.   become desynchronized owing to a crash that resulted in loss of
  2082.   memory.  Such connections will automatically become reset if an
  2083.   attempt is made to send data in either direction.  However, half-open
  2084.   connections are expected to be unusual, and the recovery procedure is
  2085.   mildly involved.
  2086.  
  2087.   If at site A the connection no longer exists, then an attempt by the
  2088.   user at site B to send any data on it will result in the site B TCP
  2089.   receiving a reset control message.  Such a message should indicate to
  2090.   the site B TCP that something is wrong, and it is expected to abort
  2091.   the connection.
  2092.  
  2093.   Assume that two user processes A and B are communicating with one
  2094.   another when a crash occurs causing loss of memory to A's TCP.
  2095.   Depending on the operating system supporting A's TCP, it is likely
  2096.   that some error recovery mechanism exists.  When the TCP is up again,
  2097.   A is likely to start again from the beginning or from a recovery
  2098.   point.  As a result, A will probably try to OPEN the connection again
  2099.   or try to SEND on the connection it believes open.  In the latter
  2100.   case, it receives the error message "connection not open" from the
  2101.   local (A's) TCP.  In an attempt to establish the connection, A's TCP
  2102.   will send a segment containing SYN.  This scenario leads to the
  2103.   example shown in figure 12.  After TCP A crashes, the user attempts to
  2104.   re-open the connection.  TCP B, in the meantime, thinks the connection
  2105.   is open.
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. [Page 32]                                                               
  2117.  
  2118.  
  2119. January 1980                                                            
  2120.                                            Transmission Control Protocol
  2121.                                                 Functional Specification
  2122.  
  2123.  
  2124.  
  2125.   
  2126.  
  2127.       TCP A                                           TCP B
  2128.  
  2129.   1.  (CRASH)                               (send 300,receive 100)
  2130.  
  2131.   2.  CLOSED                                           ESTABLISHED
  2132.  
  2133.   3.  SYN-SENT --> <SEQ=400><CTL=SYN>              --> (??)
  2134.  
  2135.   4.  (!!)     <-- <SEQ=300><ACK=100><CTL=ACK>     <-- ESTABLISHED
  2136.  
  2137.   5.  SYN-SENT --> <SEQ=100><CTL=RST>              --> (Abort!!)
  2138.  
  2139.   6.                                                   CLOSED
  2140.  
  2141.   7.  SYN-SENT --> <SEQ=400><CTL=SYN>              -->
  2142.  
  2143.                      Half-Open Connection Discovery
  2144.  
  2145.                                Figure 12.
  2146.  
  2147.   When the SYN arrives at line 3, TCP B, being in a synchronized state,
  2148.   responds with an acknowledgment indicating what sequence it next
  2149.   expects to hear (ACK 100).  TCP A sees that this segment does not
  2150.   acknowledge anything it sent and, being unsynchronized, sends a reset
  2151.   (RST) because it has detected a half-open connection.  TCP B aborts at
  2152.   line 5.  TCP A will continue to try to establish the connection; the
  2153.   problem is now reduced to the basic 3-way handshake of figure 9.
  2154.  
  2155.   An interesting alternative case occurs when TCP A crashes and TCP B
  2156.   tries to send data on what it thinks is a synchronized connection.
  2157.   This is illustrated in figure 13.  In this case, the data arriving at
  2158.   TCP A from TCP B (line 2) is unacceptable because no such connection
  2159.   exists, so TCP A sends a RST.  The RST is acceptable so TCP B
  2160.   processes it and aborts the connection.
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                                                [Page 33]
  2176.  
  2177.  
  2178.                                                             January 1980
  2179. Transmission Control Protocol
  2180. Functional Specification
  2181.  
  2182.  
  2183.  
  2184.   
  2185.  
  2186.         TCP A                                              TCP B
  2187.  
  2188.   1.  (CRASH)                                   (send 300,receive 100)
  2189.  
  2190.   2.  (??)    <-- <SEQ=300><ACK=100><DATA=10><CTL=ACK> <-- ESTABLISHED
  2191.  
  2192.   3.          --> <SEQ=100><CTL=RST>                   --> (ABORT!!)
  2193.  
  2194.            Active Side Causes Half-Open Connection Discovery
  2195.  
  2196.                                Figure 13.
  2197.  
  2198.   In figure 14, we find the two TCPs A and B with passive connections
  2199.   waiting for SYN.  An old duplicate arriving at TCP B (line 2) stirs B
  2200.   into action.  A SYN-ACK is returned (line 3) and causes TCP A to
  2201.   generate a RST (the ACK in line 3 is not acceptable).  TCP B accepts
  2202.   the reset and returns to its passive LISTEN state.
  2203.  
  2204.   
  2205.  
  2206.       TCP A                                         TCP B
  2207.  
  2208.   1.  LISTEN                                        LISTEN
  2209.  
  2210.   2.       ... <SEQ=Z><CTL=SYN>                -->  SYN-RECEIVED
  2211.  
  2212.   3.  (??) <-- <SEQ=X><ACK=Z+1><CTL=SYN,ACK>   <--  SYN-RECEIVED
  2213.  
  2214.   4.       --> <SEQ=Z+1><CTL=RST>              -->  (return to LISTEN!)
  2215.  
  2216.   5.  LISTEN                                        LISTEN
  2217.  
  2218.        Old Duplicate SYN Initiates a Reset on two Passive Sockets
  2219.  
  2220.                                Figure 14.
  2221.  
  2222.   A variety of other cases are possible, all of which are accounted for
  2223.   by the following rules for RST generation and processing.
  2224.  
  2225.   Reset Generation
  2226.  
  2227.   As a general rule, reset (RST) should be sent whenever a segment
  2228.   arrives which apparently is not intended for the current or a future
  2229.   incarnation of the connection.  A reset should not be sent if it is
  2230.   not clear that this is the case.  Thus, if any segment arrives for a
  2231.   nonexistent connection, a reset should be sent.  If a segment ACKs
  2232.  
  2233.  
  2234. [Page 34]                                                               
  2235.  
  2236.  
  2237. January 1980                                                            
  2238.                                            Transmission Control Protocol
  2239.                                                 Functional Specification
  2240.  
  2241.  
  2242.  
  2243.   something which has never been sent on the current connection, then
  2244.   one of the following two cases applies.
  2245.  
  2246.   1.  If the connection is in any non-synchronized state (LISTEN,
  2247.   SYN-SENT, SYN-RECEIVED) or if the connection does not exist, a reset
  2248.   (RST) should be formed and sent for any segment that acknowledges
  2249.   something not yet sent.  The RST should take its SEQ field from the
  2250.   ACK field of the offending segment (if the ACK control bit was set),
  2251.   and its ACK bit should be reset (zero), except to refuse a initial
  2252.   SYN.  A reset is also sent if an incoming segment has a security level
  2253.   or compartment which does not exactly match the level and compartment
  2254.   requested for the connection.  If the precedence of the incoming
  2255.   segment is less than the precedence level requested a reset is sent.
  2256.  
  2257.   2.  If the connection is in a synchronized state (ESTABLISHED,
  2258.   FIN-WAIT-1, FIN-WAIT-2, TIME-WAIT, CLOSE-WAIT, CLOSING), any
  2259.   unacceptable segment should elicit only an empty acknowledgment
  2260.   segment containing the current send-sequence number and an
  2261.   acknowledgment indicating the next sequence number expected to be
  2262.   received.
  2263.  
  2264.   Reset Processing
  2265.  
  2266.   All reset (RST) segments are validated by checking their SEQ-fields.
  2267.   A reset is valid if its sequence number is in the window.  In the case
  2268.   of a RST received in response to an initial SYN any sequence number is
  2269.   acceptable if the ACK field acknowledges the SYN.
  2270.  
  2271.   The receiver of a RST first validates it, then changes state.  If the
  2272.   receiver was in the LISTEN state, it ignores it.  If the receiver was
  2273.   in SYN-RECEIVED state and had previously been in the LISTEN state,
  2274.   then the receiver returns to the LISTEN state, otherwise the receiver
  2275.   aborts the connection and goes to the CLOSED state.  If the receiver
  2276.   was in any other state, it aborts the connection and advises the user
  2277.   and goes to the CLOSED state.
  2278.  
  2279. 3.5.  Closing a Connection
  2280.  
  2281.   CLOSE is an operation meaning "I have no more data to send."  The
  2282.   notion of closing a full-duplex connection is subject to ambiguous
  2283.   interpretation, of course, since it may not be obvious how to treat
  2284.   the receiving side of the connection.  We have chosen to treat CLOSE
  2285.   in a simplex fashion.  The user who CLOSEs may continue to RECEIVE
  2286.   until he is told that the other side has CLOSED also.  Thus, a program
  2287.   could initiate several SENDs followed by a CLOSE, and then continue to
  2288.   RECEIVE until signaled that a RECEIVE failed because the other side
  2289.   has CLOSED.  We assume that the TCP will signal a user, even if no
  2290.   RECEIVEs are outstanding, that the other side has closed, so the user
  2291.  
  2292.  
  2293.                                                                [Page 35]
  2294.  
  2295.  
  2296.                                                             January 1980
  2297. Transmission Control Protocol
  2298. Functional Specification
  2299.  
  2300.  
  2301.  
  2302.   can terminate his side gracefully.  A TCP will reliably deliver all
  2303.   buffers SENT before the connection was CLOSED so a user who expects no
  2304.   data in return need only wait to hear the connection was CLOSED
  2305.   successfully to know that all his data was received at the destination
  2306.   TCP.
  2307.  
  2308.   There are essentially three cases:
  2309.  
  2310.     1) The user initiates by telling the TCP to CLOSE the connection
  2311.  
  2312.     2) The remote TCP initiates by sending a FIN control signal
  2313.  
  2314.     3) Both users CLOSE simultaneously
  2315.  
  2316.   Case 1:  Local user initiates the close
  2317.  
  2318.     In this case, a FIN segment can be constructed and placed on the
  2319.     outgoing segment queue.  No further SENDs from the user will be
  2320.     accepted by the TCP, and it enters the FIN-WAIT-1 state.  RECEIVEs
  2321.     are allowed in this state.  All segments preceding and including FIN
  2322.     will be retransmitted until acknowledged.  When the other TCP has
  2323.     both acknowledged the FIN and sent a FIN of its own, the first TCP
  2324.     can ACK this FIN.  It should be noted that a TCP receiving a FIN
  2325.     will ACK but not send its own FIN until its user has CLOSED the
  2326.     connection also.
  2327.  
  2328.   Case 2:  TCP receives a FIN from the network
  2329.  
  2330.     If an unsolicited FIN arrives from the network, the receiving TCP
  2331.     can ACK it and tell the user that the connection is closing.  The
  2332.     user should respond with a CLOSE, upon which the TCP can send a FIN
  2333.     to the other TCP.  The TCP then waits until its own FIN is
  2334.     acknowledged whereupon it deletes the connection.  If an ACK is not
  2335.     forthcoming, after a timeout the connection is aborted and the user
  2336.     is told.
  2337.  
  2338.   Case 3:  both users close simultaneously
  2339.  
  2340.     A simultaneous CLOSE by users at both ends of a connection causes
  2341.     FIN segments to be exchanged.  When all segments preceding the FINs
  2342.     have been processed and acknowledged, each TCP can ACK the FIN it
  2343.     has received.  Both will, upon receiving these ACKs, delete the
  2344.     connection.
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352. [Page 36]                                                               
  2353.  
  2354.  
  2355. January 1980                                                            
  2356.                                            Transmission Control Protocol
  2357.                                                 Functional Specification
  2358.  
  2359.  
  2360.  
  2361.   
  2362.  
  2363.       TCP A                                                TCP B
  2364.  
  2365.   1.  ESTABLISHED                                          ESTABLISHED
  2366.  
  2367.   2.  (Close)
  2368.       FIN-WAIT-1  --> <SEQ=100><CTL=FIN>               --> CLOSE-WAIT
  2369.  
  2370.   3.  FIN-WAIT-2  <-- <SEQ=300><ACK=101><CTL=ACK>      <-- CLOSE-WAIT
  2371.  
  2372.   4.                                                       (Close)
  2373.       TIME-WAIT   <-- <SEQ=301><CTL=FIN>               <-- CLOSING
  2374.  
  2375.   5.  TIME-WAIT   --> <SEQ=100><ACK=301><CTL=ACK>      --> CLOSED
  2376.  
  2377.   6.  (2 MSL)
  2378.       CLOSED
  2379.  
  2380.                          Normal Close Sequence
  2381.  
  2382.                                Figure 15.
  2383.  
  2384.   
  2385.  
  2386.       TCP A                                                TCP B
  2387.  
  2388.   1.  ESTABLISHED                                          ESTABLISHED
  2389.  
  2390.   2.  (Close)                                              (Close)
  2391.       FIN-WAIT-1  --> <SEQ=100><CTL=FIN>               ... FIN-WAIT-1
  2392.                   <-- <SEQ=300><CTL=FIN>               <--
  2393.                   ... <SEQ=100><CTL=FIN>               -->
  2394.  
  2395.   3.  CLOSING     --> <SEQ=100><ACK=301><CTL=ACK>      ... CLOSING
  2396.                   <-- <SEQ=300><ACK=101><CTL=ACK>      <--
  2397.                   ... <SEQ=100><ACK=301><CTL=ACK>      -->
  2398.  
  2399.   4.  CLOSED                                               CLOSED
  2400.  
  2401.                       Simultaneous Close Sequence
  2402.  
  2403.                                Figure 16.
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.                                                                [Page 37]
  2412.  
  2413.  
  2414.                                                             January 1980
  2415. Transmission Control Protocol
  2416. Functional Specification
  2417.  
  2418.  
  2419.  
  2420. 3.6.  Precedence and Security
  2421.  
  2422.   The intent is that connection be allowed only between ports operating
  2423.   with exactly the same security and compartment values and at the
  2424.   higher of the precedence level requested by the two parts.
  2425.  
  2426.   The precedence levels are:
  2427.  
  2428.     flash override - 111
  2429.     flash          - 110
  2430.     immediate      - 10X
  2431.     priority       - 01X
  2432.     routine        - 00X
  2433.  
  2434.   The security levels are:
  2435.  
  2436.     top secret    - 11
  2437.     secret        - 10
  2438.     confidential  - 01
  2439.     unclassified  - 00
  2440.  
  2441.   The compartments are assigned by the Defense Communications Agency.
  2442.   The defaults are precedence:  routine, security:  unclassified,
  2443.   compartment:  zero.  A host which does not implement precedence or
  2444.   security feature should clear these fields to zero for segments it
  2445.   sends.
  2446.  
  2447.   A connection attempt with mismatched security/compartment values or a
  2448.   lower precedence value should be rejected by sending a reset.
  2449.  
  2450.   Note that TCP modules which operate only at the default value of
  2451.   precedence will still have to check the precedence of incoming
  2452.   segments and possibly raise the precedence level they use on the
  2453.   connection.
  2454.  
  2455. 3.7.  Data Communication
  2456.  
  2457.   Once the connection is established data is communicated by the
  2458.   exchange of segments.  Because segments may be lost due to errors
  2459.   (checksum test failure), or network congestion, TCP uses
  2460.   retransmission (after a timeout) to ensure delivery of every segment.
  2461.   Duplicate segments may arrive due to network or TCP retransmission.
  2462.   As discussed in the section on sequence numbers the TCP performs
  2463.   certain tests on the sequence and acknowledgment numbers in the
  2464.   segments to verify their acceptability.
  2465.  
  2466.   The sender of data keeps track of the next sequence number to use in
  2467.   the variable SND.NXT.  The receiver of data keeps track of the next
  2468.  
  2469.  
  2470. [Page 38]                                                               
  2471.  
  2472.  
  2473. January 1980                                                            
  2474.                                            Transmission Control Protocol
  2475.                                                 Functional Specification
  2476.  
  2477.  
  2478.  
  2479.   sequence number to expect in the variable RCV.NXT.  The sender of data
  2480.   keeps track of the oldest unacknowledged sequence number in the
  2481.   variable SND.UNA.  If the data flow is momentarily idle and all data
  2482.   sent has been acknowledged then the three variables will be equal.
  2483.  
  2484.   When the sender creates a segment and transmits it the sender advances
  2485.   SND.NXT.  When the receiver accepts a segment it advances RCV.NXT and
  2486.   sends an acknowledgment.  When the data sender receives an
  2487.   acknowledgment it advances SND.UNA.  The extent to which the values of
  2488.   these variables differ is a measure of the delay in the communication.
  2489.  
  2490.   Normally the amount by which the variables are advanced is the length
  2491.   of the data in the segment.  However, when letters are used there are
  2492.   special provisions for coordination the sequence numbers, the letter
  2493.   boundaries, and the receive buffer boundaries.
  2494.  
  2495.   End of Letter Sequence Number Adjustments
  2496.  
  2497.   There is provision in TCP for the receiver of data to optionally
  2498.   communicate to the sender of data on a connection at the time of the
  2499.   connection synchronization the receiver's buffer size.  If this is
  2500.   done the receiver must use this fixed size of buffers for the lifetime
  2501.   of the connection.  If a buffer size is communicated then there is a
  2502.   coordination between receive buffers, letters, and sequence numbers.
  2503.  
  2504.   Each time a buffer is completed either due to being filled or due to
  2505.   an end of letter, the sequence number is incremented through the end
  2506.   of that buffer.
  2507.  
  2508.   That is, whenever an EOL is transmitted, the sender advances its send
  2509.   sequence number, SND.NXT, by an amount sufficient to consume all the
  2510.   unused space in the receiver's buffer.  The amount of space consumed
  2511.   in this fashion is subtracted from the send window just as is the
  2512.   space consumed by actual data.
  2513.  
  2514.   And, whenever an EOL is received, the receiver advances its receive
  2515.   sequence number, RCV.NXT, by an amount sufficient to consume all the
  2516.   unused space in the receiver's buffer.  The amount of space consumed
  2517.   in this fashion is subtracted from the receive window just as is the
  2518.   space consumed by actual data.
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.                                                                [Page 39]
  2530.  
  2531.  
  2532.                                                             January 1980
  2533. Transmission Control Protocol
  2534. Functional Specification
  2535.  
  2536.  
  2537.  
  2538.     older sequence numbers                        newer sequence numbers
  2539.  
  2540.             |           Buffer 1            |   Buffer 2       
  2541.             |                               |                  
  2542.         ----+-------------------------------+----------------- 
  2543.             XXXXXXXXXXXXXXXXXXXXX+++++++++++                   
  2544.             |                    |          |                  
  2545.             |<-----SEG.LEN------>|          |                  
  2546.             |                    |          |                  
  2547.             |                    |          |                  
  2548.          SEG.SEQ                 A          B                  
  2549.  
  2550.                     XXX - data octets from segment 
  2551.                     +++ - phantom data             
  2552.  
  2553.                       <----- sequence space ----->
  2554.  
  2555.                         End of Letter Adjustment
  2556.  
  2557.                                Figure 17.
  2558.  
  2559.   In the case illustrated above, if the segment does not carry an EOL
  2560.   flag, the next value of SND.NXT or RCV.NXT will be A.  If it does
  2561.   carry an EOL flag, the next value will be B.
  2562.  
  2563.   The exchange of buffer size and sequencing information is done in
  2564.   units of octets.  If no buffer size is stated, then the buffer size is
  2565.   assumed to be 1 octet.  The receiver tells the sender the size of the
  2566.   buffer in a SYN segment that contains the 16 bit buffer size data in
  2567.   an option field in the TCP header.
  2568.  
  2569.   Each EOL advances the sequence number (SN) to the next buffer boundary
  2570.  
  2571.     While LBB < SEG.SEQ+SEG.LEN
  2572.     Do LBB <- LBB + BS End
  2573.     SN <- LBB
  2574.  
  2575.     where LBB is the Last Buffer Beginning, and BS is the buffer size.
  2576.  
  2577.   The CLOSE user call implies an end of letter, as does the FIN control
  2578.   flag in an incoming segment.
  2579.  
  2580.   The Communication of Urgent Information
  2581.  
  2582.   The objective of the TCP urgent mechanism is to allow the sending user
  2583.   to stimulate the receiving user to accept some urgent data and to
  2584.   permit the receiving TCP to indicate to the receiving user when all
  2585.   the currently known urgent data has been received by the user.
  2586.  
  2587.  
  2588. [Page 40]                                                               
  2589.  
  2590.  
  2591. January 1980                                                            
  2592.                                            Transmission Control Protocol
  2593.                                                 Functional Specification
  2594.  
  2595.  
  2596.  
  2597.   This mechanism permits a point in the data stream to be designated as
  2598.   the end of "urgent" information.  Whenever this point is in advance of
  2599.   the receive sequence number (RCV.NXT) at the receiving TCP, that TCP
  2600.   should tell the user to go into "urgent mode"; when the receive
  2601.   sequence number catches up to the urgent pointer, the TCP should tell
  2602.   user to go into "normal mode".  If the urgent pointer is updated while
  2603.   the user is in "read fast" mode, the update will be invisible to the
  2604.   user.
  2605.  
  2606.   The method employs a urgent field which is carried in all segments
  2607.   transmitted.  The URG control flag indicates that the urgent field is
  2608.   meaningful and should be added to the segment sequence number to yield
  2609.   the urgent pointer.  The absence of this flag indicates that the
  2610.   urgent pointer has not changed.
  2611.  
  2612.   To send an urgent indication the user must also send at least one data
  2613.   octet.  If the sending user also indicates end of letter, timely
  2614.   delivery of the urgent information to the destination process is
  2615.   enhanced.
  2616.  
  2617.   Managing the Window
  2618.  
  2619.   The window sent in each segment indicates the range of sequence number
  2620.   the sender of the window (the data receiver) is currently prepared to
  2621.   accept.  There is an assumption that this is related to the currently
  2622.   available data buffer space available for this connection.  The window
  2623.   information is a guideline to be aimed at.
  2624.  
  2625.   Indicating a large window encourages transmissions.  If more data
  2626.   arrives than can be accepted, it will be discarded.  This will result
  2627.   in excessive retransmissions, adding unnecessarily to the load on the
  2628.   network and the TCPs.  Indicating a small window may restrict the
  2629.   transmission of data to the point of introducing a round trip delay
  2630.   between each new segment transmitted.
  2631.  
  2632.   The mechanisms provided allow a TCP to advertise a large window and to
  2633.   subsequently advertise a much smaller window without having accepted
  2634.   that much data.  This, so called "shrinking the window," is strongly
  2635.   discouraged.  The robustness principle dictates that TCPs will not
  2636.   shrink the window themselves, but will be prepared for such behavior
  2637.   on the part of other TCPs.
  2638.  
  2639.   The sending TCP must be prepared to accept and send at least one octet
  2640.   of new data even if the send window is zero.  The sending TCP should
  2641.   regularly retransmit to the receiving TCP even when the window is
  2642.   zero.  Two minutes is recommended for the retransmission interval when
  2643.   the window is zero.  This retransmission is essential to guarantee
  2644.  
  2645.  
  2646.  
  2647.                                                                [Page 41]
  2648.  
  2649.  
  2650.                                                             January 1980
  2651. Transmission Control Protocol
  2652. Functional Specification
  2653.  
  2654.  
  2655.  
  2656.   that when either TCP has a zero window the re-opening of the window
  2657.   will be reliably reported to the other.
  2658.  
  2659.   The sending TCP packages the data to be transmitted into segments
  2660.   which fit the current window, and may repackage segments on the
  2661.   retransmission queue.  Such repackaging is not required, but may be
  2662.   helpful.
  2663.  
  2664.   Users must keep reading connections they close for sending until the
  2665.   TCP says no more data.
  2666.  
  2667.   In a connection with a one-way data flow, the window information will
  2668.   be carried in acknowledgment segments that all have the same sequence
  2669.   number so there will be no way to reorder them if they arrive out of
  2670.   order.  This is not a serious problem, but it will allow the window
  2671.   information to be on occasion temporarily based on old reports from
  2672.   the data receiver.
  2673.  
  2674. 3.8.  Interfaces
  2675.  
  2676.   There are of course two interfaces of concern:  the user/TCP interface
  2677.   and the TCP/IP interface.  We have a fairly elaborate model of the
  2678.   user/TCP interface, but only a sketch of the interface to the lower
  2679.   level protocol module.
  2680.  
  2681.   User/TCP Interface
  2682.  
  2683.     The functional description of user commands to the TCP is, at best,
  2684.     fictional, since every operating system will have different
  2685.     facilities.  Consequently, we must warn readers that different TCP
  2686.     implementations may have different user interfaces.  However, all
  2687.     TCPs must provide a certain minimum set of services to guarantee
  2688.     that all TCP implementations can support the same protocol
  2689.     hierarchy.  This section specifies the functional interfaces
  2690.     required of all TCP implementations.
  2691.  
  2692.     TCP User Commands
  2693.  
  2694.       The following sections functionally characterize a USER/TCP
  2695.       interface.  The notation used is similar to most procedure or
  2696.       function calls in high level languages, but this usage is not
  2697.       meant to rule out trap type service calls (e.g., SVCs, UUOs,
  2698.       EMTs).
  2699.  
  2700.       The user commands described below specify the basic functions the
  2701.       TCP must perform to support interprocess communication.
  2702.       Individual implementations should define their own exact format,
  2703.       and may provide combinations or subsets of the basic functions in
  2704.  
  2705.  
  2706. [Page 42]                                                               
  2707.  
  2708.  
  2709. January 1980                                                            
  2710.                                            Transmission Control Protocol
  2711.                                                 Functional Specification
  2712.  
  2713.  
  2714.  
  2715.       single calls.  In particular, some implementations may wish to
  2716.       automatically OPEN a connection on the first SEND or RECEIVE
  2717.       issued by the user for a given connection.
  2718.  
  2719.       In providing interprocess communication facilities, the TCP must
  2720.       not only accept commands, but must also return information to the
  2721.       processes it serves.  The latter consists of:
  2722.  
  2723.         (a) general information about a connection (e.g., interrupts,
  2724.         remote close, binding of unspecified foreign socket).
  2725.  
  2726.         (b) replies to specific user commands indicating success or
  2727.         various types of failure.
  2728.  
  2729.       Open
  2730.  
  2731.         Format:  OPEN (local port, foreign socket, active/passive
  2732.         [, buffer size] [, timeout] [, precedence]
  2733.         [, security/compartment]) -> local connection name
  2734.  
  2735.         We assume that the local TCP is aware of the identity of the
  2736.         processes it serves and will check the authority of the process
  2737.         to use the connection specified.  Depending upon the
  2738.         implementation of the TCP, the local network and TCP identifiers
  2739.         for the source address will either be supplied by the TCP or by
  2740.         the processes that serve it (e.g., the program which interfaces
  2741.         the TCP network).  These considerations are the result of
  2742.         concern about security, to the extent that no TCP be able to
  2743.         masquerade as another one, and so on.  Similarly, no process can
  2744.         masquerade as another without the collusion of the TCP.
  2745.  
  2746.         If the active/passive flag is set to passive, then this is a
  2747.         call to LISTEN for an incoming connection.  A passive open may
  2748.         have either a fully specified foreign socket to wait for a
  2749.         particular connection or an unspecified foreign socket to wait
  2750.         for any call.  A fully specified passive call can be made active
  2751.         by the subsequent execution of a SEND.
  2752.  
  2753.         A full-duplex transmission control block (TCB) is created and
  2754.         partially filled in with data from the OPEN command parameters.
  2755.  
  2756.         On an active OPEN command, the TCP will begin the procedure to
  2757.         synchronize (i.e., establish) the connection at once.
  2758.  
  2759.         The buffer size, if present, indicates that the caller will
  2760.         always receive data from the connection in that size of buffers.
  2761.         This buffer size is a measure of the buffer between the user and
  2762.  
  2763.  
  2764.  
  2765.                                                                [Page 43]
  2766.  
  2767.  
  2768.                                                             January 1980
  2769. Transmission Control Protocol
  2770. Functional Specification
  2771.  
  2772.  
  2773.  
  2774.         the local TCP.  The buffer size between the two TCPs may be
  2775.         different.
  2776.  
  2777.         The timeout, if present, permits the caller to set up a timeout
  2778.         for all buffers transmitted on the connection.  If a buffer is
  2779.         not successfully delivered to the destination within the timeout
  2780.         period, the TCP will abort the connection.  The present global
  2781.         default is 30 seconds.  The buffer retransmission rate may vary;
  2782.         most likely, it will be related to the measured time for
  2783.         responses from the remote TCP.
  2784.  
  2785.         The TCP or some component of the operating system will verify
  2786.         the users authority to open a connection with the specified
  2787.         precedence or security/compartment.  The absence of precedence
  2788.         or security/compartment specification in the OPEN call indicates
  2789.         the default values should be used.
  2790.  
  2791.         TCP will accept incoming requests as matching only if the
  2792.         security/compartment information is exactly the same and only if
  2793.         the precedence is equal to or higher than the precedence
  2794.         requested in the OPEN call.
  2795.  
  2796.         The precedence for the connection is the higher of the values
  2797.         requested in the OPEN call and received from the incoming
  2798.         request, and fixed at that value for the life of the connection.
  2799.  
  2800.         Depending on the TCP implementation, either a local connection
  2801.         name will be returned to the user by the TCP, or the user will
  2802.         specify this local connection name (in which case another
  2803.         parameter is needed in the call).  The local connection name can
  2804.         then be used as a short hand term for the connection defined by
  2805.         the <local socket, foreign socket> pair.
  2806.  
  2807.       Send
  2808.  
  2809.         Format:  SEND(local connection name, buffer address, byte count,
  2810.         EOL flag, URGENT flag [, timeout])
  2811.  
  2812.         This call causes the data contained in the indicated user buffer
  2813.         to be sent on the indicated connection.  If the connection has
  2814.         not been opened, the SEND is considered an error.  Some
  2815.         implementations may allow users to SEND first; in which case, an
  2816.         automatic OPEN would be done.  If the calling process is not
  2817.         authorized to use this connection, an error is returned.
  2818.  
  2819.         If the EOL flag is set, the data is the End Of a Letter, and the
  2820.         EOL bit will be set in the last TCP segment created from the
  2821.  
  2822.  
  2823.  
  2824. [Page 44]                                                               
  2825.  
  2826.  
  2827. January 1980                                                            
  2828.                                            Transmission Control Protocol
  2829.                                                 Functional Specification
  2830.  
  2831.  
  2832.  
  2833.         buffer.  If the EOL flag is not set, subsequent SENDs will
  2834.         appear to be part of the same letter.
  2835.  
  2836.         If the URGENT flag is set, segments resulting from this call
  2837.         will have the urgent pointer set to indicate that some of the
  2838.         data associated with this call is urgent.  This facility, for
  2839.         example, can be used to simulate "break" signals from terminals
  2840.         or error or completion codes from I/O devices.  The semantics of
  2841.         this signal to the receiving process are unspecified.  The
  2842.         receiving TCP will signal the urgent condition to the receiving
  2843.         process as long as the urgent pointer indicates that data
  2844.         preceding the urgent pointer has not been consumed by the
  2845.         receiving process.  The purpose of urgent is to stimulate the
  2846.         receiver to accept some urgent data and to indicate to the
  2847.         receiver when all the currently known urgent data has been
  2848.         received.
  2849.  
  2850.         The number of times the sending user's TCP signals urgent will
  2851.         not necessarily be equal to the number of times the receiving
  2852.         user will be notified of the presence of urgent data.
  2853.  
  2854.         If no foreign socket was specified in the OPEN, but the
  2855.         connection is established (e.g., because a LISTENing connection
  2856.         has become specific due to a foreign segment arriving for the
  2857.         local socket), then the designated buffer is sent to the implied
  2858.         foreign socket.  In general, users who make use of OPEN with an
  2859.         unspecified foreign socket can make use of SEND without ever
  2860.         explicitly knowing the foreign socket address.
  2861.  
  2862.         However, if a SEND is attempted before the foreign socket
  2863.         becomes specified, an error will be returned.  Users can use the
  2864.         STATUS call to determine the status of the connection.  In some
  2865.         implementations the TCP may notify the user when an unspecified
  2866.         socket is bound.
  2867.  
  2868.         If a timeout is specified, then the current timeout for this
  2869.         connection is changed to the new one.
  2870.  
  2871.         In the simplest implementation, SEND would not return control to
  2872.         the sending process until either the transmission was complete
  2873.         or the timeout had been exceeded.  However, this simple method
  2874.         is both subject to deadlocks (for example, both sides of the
  2875.         connection might try to do SENDs before doing any RECEIVEs) and
  2876.         offers poor performance, so it is not recommended.  A more
  2877.         sophisticated implementation would return immediately to allow
  2878.         the process to run concurrently with network I/O, and,
  2879.         furthermore, to allow multiple SENDs to be in progress.
  2880.  
  2881.  
  2882.  
  2883.                                                                [Page 45]
  2884.  
  2885.  
  2886.                                                             January 1980
  2887. Transmission Control Protocol
  2888. Functional Specification
  2889.  
  2890.  
  2891.  
  2892.         Multiple SENDs are served in first come, first served order, so
  2893.         the TCP will queue those it cannot service immediately.
  2894.  
  2895.         We have implicitly assumed an asynchronous user interface in
  2896.         which a SEND later elicits some kind of SIGNAL or
  2897.         pseudo-interrupt from the serving TCP.  An alternative is to
  2898.         return a response immediately.  For instance, SENDs might return
  2899.         immediate local acknowledgment, even if the segment sent had not
  2900.         been acknowledged by the distant TCP.  We could optimistically
  2901.         assume eventual success.  If we are wrong, the connection will
  2902.         close anyway due to the timeout.  In implementations of this
  2903.         kind (synchronous), there will still be some asynchronous
  2904.         signals, but these will deal with the connection itself, and not
  2905.         with specific segments or letters.
  2906.  
  2907.         NOTA BENE: In order for the process to distinguish among error
  2908.         or success indications for different SENDs, it might be
  2909.         appropriate for the buffer address to be returned along with the
  2910.         coded response to the SEND request.  TCP-to-user signals are
  2911.         discussed below, indicating the information which should be
  2912.         returned to the calling process.
  2913.  
  2914.       Receive
  2915.  
  2916.         Format:  RECEIVE (local connection name, buffer address, byte
  2917.         count)
  2918.  
  2919.         This command allocates a receiving buffer associated with the
  2920.         specified connection.  If no OPEN precedes this command or the
  2921.         calling process is not authorized to use this connection, an
  2922.         error is returned.
  2923.  
  2924.         In the simplest implementation, control would not return to the
  2925.         calling program until either the buffer was filled, or some
  2926.         error occurred, but this scheme is highly subject to deadlocks.
  2927.         A more sophisticated implementation would permit several
  2928.         RECEIVEs to be outstanding at once.  These would be filled as,
  2929.         segments arrive.  This strategy permits increased throughput at
  2930.         the cost of a more elaborate scheme (possibly asynchronous) to
  2931.         notify the calling program that a letter has been received or a
  2932.         buffer filled.
  2933.  
  2934.         If insufficient buffer space is given to reassemble a complete
  2935.         letter, the EOL flag will not be set in the response to the
  2936.         RECEIVE.  The buffer will be filled with as much data as it can
  2937.         hold.  The last buffer required to hold the letter is returned
  2938.         with EOL signaled.
  2939.  
  2940.  
  2941.  
  2942. [Page 46]                                                               
  2943.  
  2944.  
  2945. January 1980                                                            
  2946.                                            Transmission Control Protocol
  2947.                                                 Functional Specification
  2948.  
  2949.  
  2950.  
  2951.         The remaining parts of a partly delivered letter will be placed
  2952.         in buffers as they are made available via successive RECEIVEs.
  2953.         If a number of RECEIVEs are outstanding, they may be filled with
  2954.         parts of a single long letter or with at most one letter each.
  2955.         The return codes associated with each RECEIVE will indicate what
  2956.         is contained in the buffer.
  2957.  
  2958.         If a buffer size was given in the OPEN call, then all buffers
  2959.         presented in RECEIVE calls must be of exactly that size, or an
  2960.         error indication will be returned.
  2961.  
  2962.         The URGENT flag will be set only if the receiving user has
  2963.         previously been informed via a TCP-to-user signal, that urgent
  2964.         data is waiting.  The receiving user should thus be in
  2965.         "read-fast" mode.  If the URGENT flag is on, additional urgent
  2966.         data remains.  If the URGENT flag is off, this call to RECEIVE
  2967.         has returned all the urgent data, and the user may now leave
  2968.         "read-fast" mode.
  2969.  
  2970.         To distinguish among several outstanding RECEIVEs and to take
  2971.         care of the case that a letter is smaller than the buffer
  2972.         supplied, the return code is accompanied by both a buffer
  2973.         pointer and a byte count indicating the actual length of the
  2974.         letter received.
  2975.  
  2976.         Alternative implementations of RECEIVE might have the TCP
  2977.         allocate buffer storage, or the TCP might share a ring buffer
  2978.         with the user.  Variations of this kind will produce obvious
  2979.         variation in user interface to the TCP.
  2980.  
  2981.       Close
  2982.  
  2983.         Format:  CLOSE(local connection name)
  2984.  
  2985.         This command causes the connection specified to be closed.  If
  2986.         the connection is not open or the calling process is not
  2987.         authorized to use this connection, an error is returned.
  2988.         Closing connections is intended to be a graceful operation in
  2989.         the sense that outstanding SENDs will be transmitted (and
  2990.         retransmitted), as flow control permits, until all have been
  2991.         serviced.  Thus, it should be acceptable to make several SEND
  2992.         calls, followed by a CLOSE, and expect all the data to be sent
  2993.         to the destination.  It should also be clear that users should
  2994.         continue to RECEIVE on CLOSING connections, since the other side
  2995.         may be trying to transmit the last of its data.  Thus, CLOSE
  2996.         means "I have no more to send" but does not mean "I will not
  2997.         receive any more."  It may happen (if the user level protocol is
  2998.         not well thought out) that the closing side is unable to get rid
  2999.  
  3000.  
  3001.                                                                [Page 47]
  3002.  
  3003.  
  3004.                                                             January 1980
  3005. Transmission Control Protocol
  3006. Functional Specification
  3007.  
  3008.  
  3009.  
  3010.         of all its data before timing out.  In this event, CLOSE turns
  3011.         into ABORT, and the closing TCP gives up.
  3012.  
  3013.         The user may CLOSE the connection at any time on his own
  3014.         initiative, or in response to various prompts from the TCP
  3015.         (e.g., remote close executed, transmission timeout exceeded,
  3016.         destination inaccessible).
  3017.  
  3018.         Because closing a connection requires communication with the
  3019.         foreign TCP, connections may remain in the closing state for a
  3020.         short time.  Attempts to reopen the connection before the TCP
  3021.         replies to the CLOSE command will result in error responses.
  3022.  
  3023.         Close also implies end of letter.
  3024.  
  3025.       Status
  3026.  
  3027.         Format:  STATUS(local connection name)
  3028.  
  3029.         This is an implementation dependent user command and could be
  3030.         excluded without adverse effect.  Information returned would
  3031.         typically come from the TCB associated with the connection.
  3032.  
  3033.         This command returns a data block containing the following
  3034.         information:
  3035.  
  3036.           local socket,
  3037.           foreign socket,
  3038.           local connection name,
  3039.           receive window,
  3040.           send window,
  3041.           connection state,
  3042.           number of buffers awaiting acknowledgment,
  3043.           number of buffers pending receipt (including partial ones),
  3044.           receive buffer size,
  3045.           urgent state,
  3046.           precedence,
  3047.           security/compartment,
  3048.           and default transmission timeout.
  3049.  
  3050.         Depending on the state of the connection, or on the
  3051.         implementation itself, some of this information may not be
  3052.         available or meaningful.  If the calling process is not
  3053.         authorized to use this connection, an error is returned.  This
  3054.         prevents unauthorized processes from gaining information about a
  3055.         connection.
  3056.  
  3057.  
  3058.  
  3059.  
  3060. [Page 48]                                                               
  3061.  
  3062.  
  3063. January 1980                                                            
  3064.                                            Transmission Control Protocol
  3065.                                                 Functional Specification
  3066.  
  3067.  
  3068.  
  3069.       Abort
  3070.  
  3071.         Format:  ABORT (local connection name)
  3072.  
  3073.         This command causes all pending SENDs and RECEIVES to be
  3074.         aborted, the TCB to be removed, and a special RESET message to
  3075.         be sent to the TCP on the other side of the connection.
  3076.         Depending on the implementation, users may receive abort
  3077.         indications for each outstanding SEND or RECEIVE, or may simply
  3078.         receive an ABORT-acknowledgment.
  3079.  
  3080.     TCP-to-User Messages
  3081.  
  3082.       It is assumed that the operating system environment provides a
  3083.       means for the TCP to asynchronously signal the user program.  When
  3084.       the TCP does signal a user program, certain information is passed
  3085.       to the user.  Often in the specification the information will be
  3086.       an error message.  In other cases there will be information
  3087.       relating to the completion of processing a SEND or RECEIVE or
  3088.       other user call.
  3089.  
  3090.       The following information is provided:
  3091.  
  3092.         Local Connection Name                    Always
  3093.         Response String                          Always
  3094.         Buffer Address                           Send & Receive
  3095.         Byte count (counts bytes received)       Receive
  3096.         End-of-Letter flag                       Receive
  3097.         End-of-Urgent flag                       Receive
  3098.  
  3099.   TCP/Network Interface
  3100.  
  3101.     The TCP calls on a lower level protocol module to actually send and
  3102.     receive information over a network.  One case is that of the ARPA
  3103.     internetwork system where the lower level module is the Internet
  3104.     Protocol [2].  In most cases the following simple interface would be
  3105.     adequate.
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.                                                                [Page 49]
  3120.  
  3121.  
  3122.                                                             January 1980
  3123. Transmission Control Protocol
  3124. Functional Specification
  3125.  
  3126.  
  3127.  
  3128.     The following two calls satisfy the requirements for the TCP to
  3129.     internet protocol module communication:
  3130.  
  3131.       SEND (dest, TOS, TTL, BufPTR, len, Id, DF, options => result)
  3132.  
  3133.         where:
  3134.  
  3135.           dest = destination address
  3136.           TOS = type of service
  3137.           TTL = time to live
  3138.           BufPTR = buffer pointer
  3139.           len = length of buffer
  3140.           Id  = Identifier
  3141.           DF = Don't Fragment
  3142.           options = internet option data
  3143.           result = response
  3144.             OK = datagram sent ok
  3145.             Error = error in arguments or local network error
  3146.  
  3147.         Note that the precedence is included in the TOS and the
  3148.         security/compartment is passed as an option.
  3149.  
  3150.       RECV (BufPTR => result, source, dest, prot, TOS, len)
  3151.  
  3152.         where:
  3153.  
  3154.           BufPTR = buffer pointer
  3155.           result = response
  3156.             OK = datagram received ok
  3157.             Error = error in arguments
  3158.           source = source address
  3159.           dest = destination address
  3160.           prot = protocol
  3161.           TOS = type of service
  3162.           options = internet option data
  3163.           len = length of buffer
  3164.  
  3165.         Note that the precedence is in the TOS, and the
  3166.         security/compartment is an option.
  3167.  
  3168.       When the TCP sends a segment, it executes the SEND call supplying
  3169.       all the arguments.  The internet protocol module, on receiving
  3170.       this call, checks the arguments and prepares and sends the
  3171.       message.  If the arguments are good and the segment is accepted by
  3172.       the local network, the call returns successfully.  If either the
  3173.       arguments are bad, or the segment is not accepted by the local
  3174.       network, the call returns unsuccessfully.  On unsuccessful
  3175.       returns, a reasonable report should be made as to the cause of the
  3176.  
  3177.  
  3178. [Page 50]                                                               
  3179.  
  3180.  
  3181. January 1980                                                            
  3182.                                            Transmission Control Protocol
  3183.                                                 Functional Specification
  3184.  
  3185.  
  3186.  
  3187.       problem, but the details of such reports are up to individual
  3188.       implementations.
  3189.  
  3190.       When a segment arrives at the internet protocol module from the
  3191.       local network, either there is a pending RECV call from TCP or
  3192.       there is not.  In the first case, the pending call is satisfied by
  3193.       passing the information from the segment to the TCP.  In the
  3194.       second case, the TCP is notified of a pending segment.
  3195.  
  3196.       The notification of a TCP may be via a pseudo interrupt or similar
  3197.       mechanism, as appropriate in the particular operating system
  3198.       environment of the implementation.
  3199.  
  3200.       A TCP's RECV call may then either be immediately satisfied by a
  3201.       pending segment, or the call may be pending until a segment
  3202.       arrives.
  3203.  
  3204.       We note that the Internet Protocol provides arguments for a type
  3205.       of service and for a time to live.  TCP uses the following
  3206.       settings for these parameters:
  3207.  
  3208.         Type of Service = Precedence:  none, Package:  stream,
  3209.         Reliability:  higher, Preference:  speed, Speed:  higher; or
  3210.         00011111.
  3211.  
  3212.         Time to Live    = one minute, or 00111100.
  3213.  
  3214.           Note that the assumed maximum segment lifetime is two minutes.
  3215.           Here we explicitly ask that a segment be destroyed if it
  3216.           cannot be delivered by the internet system within one minute.
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.                                                                [Page 51]
  3238.  
  3239.  
  3240.                                                             January 1980
  3241. Transmission Control Protocol
  3242. Functional Specification
  3243.  
  3244.  
  3245.  
  3246. 3.9.  Event Processing
  3247.  
  3248.   The activity of the TCP can be characterized as responding to events.
  3249.   The events that occur can be cast into three categories:  user calls,
  3250.   arriving segments, and timeouts.  This section describes the
  3251.   processing the TCP does in response to each of the events.  In many
  3252.   cases the processing required depends on the state of the connection.
  3253.  
  3254.     Events that occur:
  3255.  
  3256.       User Calls
  3257.  
  3258.         OPEN
  3259.         SEND
  3260.         RECEIVE
  3261.         CLOSE
  3262.         ABORT
  3263.         STATUS
  3264.  
  3265.       Arriving Segments
  3266.  
  3267.         SEGMENT ARRIVES
  3268.  
  3269.       Timeouts
  3270.  
  3271.         USER TIMEOUT
  3272.         RETRANSMISSION TIMEOUT
  3273.  
  3274.   The model of the TCP/user interface is that user commands receive an
  3275.   immediate return and possibly a delayed response via an event or
  3276.   pseudo interrupt.  In the following descriptions, the term "signal"
  3277.   means cause a delayed response.
  3278.  
  3279.   Error responses are given as character strings.  For example, user
  3280.   commands referencing connections that do not exist receive "error:
  3281.   connection not open".
  3282.  
  3283.   Please note in the following that all arithmetic on sequence numbers,
  3284.   acknowledgment numbers, windows, et cetera, is modulo 2**32 the size
  3285.   of the sequence number space.  Also note that "=<" means less than or
  3286.   equal to.
  3287.  
  3288.   A natural way to think about processing incoming segments is to
  3289.   imagine that they are first tested for proper sequence number (i.e.,
  3290.   that their contents lie in the range of the expected "receive window"
  3291.   in the sequence number space) and then that they are generally queued
  3292.   and processed in sequence number order.
  3293.  
  3294.  
  3295.  
  3296. [Page 52]                                                               
  3297.  
  3298.  
  3299. January 1980                                                            
  3300.                                            Transmission Control Protocol
  3301.                                                 Functional Specification
  3302.  
  3303.  
  3304.  
  3305.   When a segment overlaps other already received segments we reconstruct
  3306.   the segment to contain just the new data, and adjust the header fields
  3307.   to be consistent.
  3308.  
  3309.  
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315.  
  3316.  
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322.  
  3323.  
  3324.  
  3325.  
  3326.  
  3327.  
  3328.  
  3329.  
  3330.  
  3331.  
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348.  
  3349.  
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.                                                                [Page 53]
  3356.  
  3357.  
  3358.                                                             January 1980
  3359. Transmission Control Protocol
  3360. Functional Specification
  3361.                                                                OPEN Call
  3362.  
  3363.  
  3364.  
  3365.   OPEN Call
  3366.  
  3367.     CLOSED STATE (i.e., TCB does not exist)
  3368.  
  3369.       Create a new transmission control block (TCB) to hold connection
  3370.       state information.  Fill in local socket identifier, foreign
  3371.       socket, precedence, security/compartment, and user timeout
  3372.       information.  Verify the security and precedence requested are
  3373.       allowed for this user, if not return "error:  precedence not
  3374.       allowed" or "error:  security/compartment not allowed."  If active
  3375.       and the foreign socket is unspecified, return "error:  foreign
  3376.       socket unspecified"; if active and the foreign socket is
  3377.       specified, issue a SYN segment.  An initial send sequence number
  3378.       (ISS) is selected and the TCP receive buffer size is selected (if
  3379.       applicable).  A SYN segment of the form <SEQ=ISS><CTL=SYN> is sent
  3380.       (this may include the buffer size option if applicable).  Set
  3381.       SND.UNA to ISS, SND.NXT to ISS+1, SND.LBB to ISS+1, enter SYN-SENT
  3382.       state, and return.
  3383.  
  3384.       If the caller does not have access to the local socket specified,
  3385.       return "error:  connection illegal for this process".  If there is
  3386.       no room to create a new connection, return "error:  insufficient
  3387.       resources".
  3388.  
  3389.     LISTEN STATE
  3390.     SYN-SENT STATE
  3391.     SYN-RECEIVED STATE
  3392.     ESTABLISHED STATE
  3393.     FIN-WAIT-1 STATE
  3394.     FIN-WAIT-2 STATE
  3395.     TIME-WAIT STATE
  3396.     CLOSE-WAIT STATE
  3397.     CLOSING STATE
  3398.  
  3399.       Return "error:  connection already exists".
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414. [Page 54]                                                               
  3415.  
  3416.  
  3417. January 1980                                                            
  3418.                                            Transmission Control Protocol
  3419.                                                 Functional Specification
  3420. SEND Call
  3421.  
  3422.  
  3423.  
  3424.   SEND Call
  3425.  
  3426.     CLOSED STATE (i.e., TCB does not exist)
  3427.  
  3428.       If the user should no have access to such a connection, then
  3429.       return "error:  connection illegal for this process".
  3430.  
  3431.       Otherwise, return "error:  connection does not exist".
  3432.  
  3433.     LISTEN STATE
  3434.  
  3435.       If the foreign socket is specified, then change the connection
  3436.       from passive to active, select an ISS, and select the receive
  3437.       buffer size.  Send a SYN segment, set SND.UNA to ISS, SND.NXT to
  3438.       ISS+1 and SND.LBB to ISS+1.  Enter SYN-SENT state.  Data
  3439.       associated with SEND may be sent with SYN segment or queued for
  3440.       transmission after entering ESTABLISHED state.  The urgent bit if
  3441.       requested in the command should be sent with the first data
  3442.       segment sent as a result of this command.  If there is no room to
  3443.       queue the request, respond with "error:  insufficient resources".
  3444.       If Foreign socket was not specified, then return "error:  foreign
  3445.       socket unspecified".
  3446.  
  3447.     SYN-SENT STATE
  3448.  
  3449.       Queue for processing after the connection is ESTABLISHED.
  3450.       Typically, nothing can be sent yet, anyway, because the send
  3451.       window has not yet been set by the other side.  If no space,
  3452.       return "error:  insufficient resources".
  3453.  
  3454.     SYN-RECEIVED STATE
  3455.  
  3456.       Queue for later processing after entering ESTABLISHED state.  If
  3457.       no space to queue, respond with "error:  insufficient resources".
  3458.  
  3459.     ESTABLISHED STATE
  3460.  
  3461.       Segmentize the buffer, send or queue it for output, with a
  3462.       piggybacked acknowledgment (acknowledgment value = RCV.NXT) with
  3463.       the data.  If there is insufficient space to remember this buffer,
  3464.       simply return "error:  insufficient resources".
  3465.  
  3466.       If remote buffer size is not one octet, and, if this is the end of
  3467.       a letter, do the following end-of-letter/buffer-size adjustment
  3468.       processing:
  3469.  
  3470.  
  3471.  
  3472.  
  3473.                                                                [Page 55]
  3474.  
  3475.  
  3476.                                                             January 1980
  3477. Transmission Control Protocol
  3478. Functional Specification
  3479.                                                                SEND Call
  3480.  
  3481.  
  3482.  
  3483.         if EOL = 0 then
  3484.  
  3485.           SND.NXT <- SEG.SEQ + SEG.LEN
  3486.  
  3487.         if EOL = 1 then
  3488.  
  3489.           While SND.LBB < SEG.SEQ + SEG.LEN
  3490.           Do SND.LBB <- SND.LBB + SND.BS End
  3491.           SND.NXT <- SND.LBB
  3492.  
  3493.       If the urgent flag is set, then SND.UP <- SND.NXT-1 and set the
  3494.       urgent pointer in the outgoing segment.
  3495.  
  3496.     FIN-WAIT-1 STATE
  3497.     FIN-WAIT-2 STATE
  3498.     TIME-WAIT STATE
  3499.  
  3500.       Return "error:  connection closing" and do not service request.
  3501.  
  3502.     CLOSE-WAIT STATE
  3503.  
  3504.       Segmentize any text to be sent and queue for output.  If there is
  3505.       insufficient space to remember the SEND, return "error:
  3506.       insufficient resources"
  3507.  
  3508.     CLOSING STATE
  3509.  
  3510.       Respond with "error:  connection closing"
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532. [Page 56]                                                               
  3533.  
  3534.  
  3535. January 1980                                                            
  3536.                                            Transmission Control Protocol
  3537.                                                 Functional Specification
  3538. RECEIVE Call
  3539.  
  3540.  
  3541.  
  3542.   RECEIVE Call
  3543.  
  3544.     CLOSED STATE (i.e., TCB does not exist)
  3545.  
  3546.       If the user should no have access to such a connection, return
  3547.       "error:  connection illegal for this process".
  3548.  
  3549.       Otherwise return "error:  connection does not exist".
  3550.  
  3551.     LISTEN STATE
  3552.     SYN-SENT STATE
  3553.     SYN-RECEIVED STATE
  3554.  
  3555.       Queue for processing after entering ESTABLISHED state.  If there
  3556.       is no room to queue this request, respond with "error:
  3557.       insufficient resources".
  3558.  
  3559.     ESTABLISHED STATE
  3560.  
  3561.       If insufficient incoming segments are queued to satisfy the
  3562.       request, queue the request.  If there is no queue space to
  3563.       remember the RECEIVE, respond with "error:  insufficient
  3564.       resources".
  3565.  
  3566.       Reassemble queued incoming segments into receive buffer and return
  3567.       to user.  Mark "end of letter" (EOL) if this is the case.
  3568.  
  3569.       If RCV.UP is in advance of the data currently being passed to the
  3570.       user notify the user of the presence of urgent data.
  3571.  
  3572.       When the TCP takes responsibility for delivering data to the user
  3573.       that fact must be communicated to the sender via an
  3574.       acknowledgment.  The formation of such an acknowledgment is
  3575.       described below in the discussion of processing an incoming
  3576.       segment.
  3577.  
  3578.     FIN-WAIT-1 STATE
  3579.     FIN-WAIT-2 STATE
  3580.  
  3581.       Reassemble and return a letter, or as much as will fit, in the
  3582.       user buffer.  Queue the request if it cannot be serviced
  3583.       immediately.
  3584.  
  3585.  
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.                                                                [Page 57]
  3592.  
  3593.  
  3594.                                                             January 1980
  3595. Transmission Control Protocol
  3596. Functional Specification
  3597.                                                             RECEIVE Call
  3598.  
  3599.  
  3600.  
  3601.     TIME-WAIT STATE
  3602.     CLOSE-WAIT STATE
  3603.  
  3604.       Since the remote side has already sent FIN, RECEIVEs must be
  3605.       satisfied by text already reassembled, but not yet delivered to
  3606.       the user.  If no reassembled segment text is awaiting delivery,
  3607.       the RECEIVE should get a "error:  connection closing" response.
  3608.       Otherwise, any remaining text can be used to satisfy the RECEIVE.
  3609.  
  3610.     CLOSING STATE
  3611.  
  3612.       Return "error:  connection closing"
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650. [Page 58]                                                               
  3651.  
  3652.  
  3653. January 1980                                                            
  3654.                                            Transmission Control Protocol
  3655.                                                 Functional Specification
  3656. CLOSE Call
  3657.  
  3658.  
  3659.  
  3660.   CLOSE Call
  3661.  
  3662.     CLOSED STATE (i.e., TCB does not exist)
  3663.  
  3664.       If the user should no have access to such a connection, return
  3665.       "error:  connection illegal for this process".
  3666.  
  3667.       Otherwise, return "error:  connection does not exist".
  3668.  
  3669.     LISTEN STATE
  3670.  
  3671.       Any outstanding RECEIVEs should be returned with "error:  closing"
  3672.       responses.  Delete TCB, return "ok".
  3673.  
  3674.     SYN-SENT STATE
  3675.  
  3676.       Delete the TCB and return "error:  closing" responses to any
  3677.       queued SENDs, or RECEIVEs.
  3678.  
  3679.     SYN-RECEIVED STATE
  3680.  
  3681.       Queue for processing after entering ESTABLISHED state or
  3682.       segmentize and send FIN segment.  If the latter, enter FIN-WAIT-1
  3683.       state.
  3684.  
  3685.     ESTABLISHED STATE
  3686.  
  3687.       Queue this until all preceding SENDs have been segmentized, then
  3688.       form a FIN segment and send it.  In any case, enter FIN-WAIT-1
  3689.       state.
  3690.  
  3691.     FIN-WAIT-1 STATE
  3692.     FIN-WAIT-2 STATE
  3693.  
  3694.       Strictly speaking, this is an error and should receive a "error:
  3695.       connection closing" response.  An "ok" response would be
  3696.       acceptable, too, as long as a second FIN is not emitted (the first
  3697.       FIN may be retransmitted though).
  3698.  
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.                                                                [Page 59]
  3710.  
  3711.  
  3712.                                                             January 1980
  3713. Transmission Control Protocol
  3714. Functional Specification
  3715.                                                               CLOSE Call
  3716.  
  3717.  
  3718.  
  3719.     TIME-WAIT STATE
  3720.  
  3721.       Strictly speaking, this is an error and should receive a "error:
  3722.       connection closing" response.  An "ok" response would be
  3723.       acceptable, too.  However, since the FIN has been sent and
  3724.       acknowledged, nothing should be sent (or retransmitted).
  3725.  
  3726.     CLOSE-WAIT STATE
  3727.  
  3728.       Queue this request until all preceding SENDs have been
  3729.       segmentized; then send a FIN segment, enter CLOSING state.
  3730.  
  3731.     CLOSING STATE
  3732.  
  3733.       Respond with "error:  connection closing"
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768. [Page 60]                                                               
  3769.  
  3770.  
  3771. January 1980                                                            
  3772.                                            Transmission Control Protocol
  3773.                                                 Functional Specification
  3774. ABORT Call
  3775.  
  3776.  
  3777.  
  3778.   ABORT Call
  3779.  
  3780.     CLOSED STATE (i.e., TCB does not exist)
  3781.  
  3782.       If the user should no have access to such a connection, return
  3783.       "error:  connection illegal for this process".
  3784.  
  3785.       Otherwise return "error:  connection does not exist".
  3786.  
  3787.     LISTEN STATE
  3788.  
  3789.       Any outstanding RECEIVEs should be returned with "error:
  3790.       connection reset" responses.  Delete TCB, return "ok".
  3791.  
  3792.     SYN-SENT STATE
  3793.  
  3794.       Delete the TCB and return "reset" responses to any queued SENDs,
  3795.       or RECEIVEs.
  3796.  
  3797.     SYN-RECEIVED STATE
  3798.  
  3799.       Send a RST of the form:
  3800.  
  3801.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3802.  
  3803.       and return any unprocessed SENDs, or RECEIVEs with "reset" code,
  3804.       delete the TCB.
  3805.  
  3806.     ESTABLISHED STATE
  3807.  
  3808.       Send a reset segment:
  3809.  
  3810.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3811.  
  3812.       All queued SENDs and RECEIVEs should be given "reset" responses;
  3813.       all segments queued for transmission (except for the RST formed
  3814.       above) or retransmission should be flushed, delete the TCB.
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.                                                                [Page 61]
  3828.  
  3829.  
  3830.                                                             January 1980
  3831. Transmission Control Protocol
  3832. Functional Specification
  3833.                                                               ABORT Call
  3834.  
  3835.  
  3836.  
  3837.     FIN-WAIT-1 STATE
  3838.     FIN-WAIT-2 STATE
  3839.  
  3840.       A reset segment (RST) should be formed and sent:
  3841.  
  3842.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3843.  
  3844.       Outstanding SENDs, RECEIVEs, CLOSEs, and/or segments queued for
  3845.       retransmission, or segmentizing, should be flushed, with
  3846.       "connection reset" notification to the user, delete the TCB.
  3847.  
  3848.     TIME-WAIT STATE
  3849.  
  3850.       Respond with "ok" and delete the TCB.
  3851.  
  3852.     CLOSE-WAIT STATE
  3853.  
  3854.       Flush any pending SENDs and RECEIVEs, returning "connection reset"
  3855.       responses for them.  Form and send a RST segment:
  3856.  
  3857.         <SEQ=SND.NXT><ACK=RCV.NXT><CTL=RST,ACK>
  3858.  
  3859.       Flush all segment queues and delete the TCB.
  3860.  
  3861.     CLOSING STATE
  3862.  
  3863.       Respond with "ok" and delete the TCB; flush any remaining segment
  3864.       queues.  If a CLOSE command is still pending, respond "error:
  3865.       connection reset".
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886. [Page 62]                                                               
  3887.  
  3888.  
  3889. January 1980                                                            
  3890.                                            Transmission Control Protocol
  3891.                                                 Functional Specification
  3892. STATUS Call
  3893.  
  3894.  
  3895.  
  3896.   STATUS Call
  3897.  
  3898.     CLOSED STATE (i.e., TCB does not exist)
  3899.  
  3900.       If the user should no have access to such a connection, return
  3901.       "error:  connection illegal for this process".
  3902.  
  3903.       Otherwise return "error:  connection does not exist".
  3904.  
  3905.     LISTEN STATE
  3906.  
  3907.       Return "state = LISTEN", and the TCB pointer.
  3908.  
  3909.     SYN-SENT STATE
  3910.  
  3911.       Return "state = SYN-SENT", and the TCB pointer.
  3912.  
  3913.     SYN-RECEIVED STATE
  3914.  
  3915.       Return "state = SYN-RECEIVED", and the TCB pointer.
  3916.  
  3917.     ESTABLISHED STATE
  3918.  
  3919.       Return "state = ESTABLISHED", and the TCB pointer.
  3920.  
  3921.     FIN-WAIT-1 STATE
  3922.  
  3923.       Return "state = FIN-WAIT-1", and the TCB pointer.
  3924.  
  3925.     FIN-WAIT-2 STATE
  3926.  
  3927.       Return "state = FIN-WAIT-2", and the TCB pointer.
  3928.  
  3929.     TIME-WAIT STATE
  3930.  
  3931.       Return "state = TIME-WAIT and the TCB pointer.
  3932.  
  3933.     CLOSE-WAIT STATE
  3934.  
  3935.       Return "state = CLOSE-WAIT", and the TCB pointer.
  3936.  
  3937.     CLOSING STATE
  3938.  
  3939.       Return "state = CLOSING", and the TCB pointer.
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.                                                                [Page 63]
  3946.  
  3947.  
  3948.                                                             January 1980
  3949. Transmission Control Protocol
  3950. Functional Specification
  3951.                                                          SEGMENT ARRIVES
  3952.  
  3953.  
  3954.  
  3955.   SEGMENT ARRIVES
  3956.  
  3957.     If the state is CLOSED (i.e., TCB does not exist) then
  3958.  
  3959.       all data in the incoming segment is discarded.  An incoming
  3960.       segment containing a RST is discarded.  An incoming segment not
  3961.       containing a RST causes a RST to be sent in response.  The
  3962.       acknowledgment and sequence field values are selected to make the
  3963.       reset sequence acceptable to the TCP that sent the offending
  3964.       segment.
  3965.  
  3966.       If the ACK bit is off, sequence number zero is used,
  3967.  
  3968.         <SEQ=0><ACK=SEG.SEQ+SEG.LEN><CTL=RST,ACK>
  3969.  
  3970.       If the ACK bit is on,
  3971.  
  3972.         <SEQ=SEG.ACK><CTL=RST>
  3973.  
  3974.       Return.
  3975.  
  3976.     If the state is LISTEN then
  3977.  
  3978.       first check for an ACK
  3979.  
  3980.         Any acknowledgment is bad if it arrives on a connection still in
  3981.         the LISTEN state.  An acceptable reset segment should be formed
  3982.         for any arriving ACK-bearing segment, except another RST.  The
  3983.         RST should be formatted as follows:
  3984.  
  3985.           <SEQ=SEG.ACK><CTL=RST>
  3986.  
  3987.         Return.
  3988.  
  3989.         An incoming RST should be ignored.  Return.
  3990.  
  3991.       if there was no ACK then check for a SYN
  3992.  
  3993.         If the SYN bit is set, check the security.  If the
  3994.         security/compartment on the incoming segment does not exactly
  3995.         match the security/compartment in the TCB then send a reset and
  3996.         return.  If the SEG.PRC is less than the TCB.PRC then send a
  3997.         reset and return.  If the SEG.PRC is greater than the TCB.PRC
  3998.         then set TCB.PRC<-SEG.PRC.  Now RCV.NXT and RCV.LBB are set to
  3999.         SEG.SEQ+1, IRS is set to SEG.SEQ and any other control or text
  4000.         should be queued for processing later.  ISS should be selected
  4001.         and a SYN segment sent of the form:
  4002.  
  4003.  
  4004. [Page 64]                                                               
  4005.  
  4006.  
  4007. January 1980                                                            
  4008.                                            Transmission Control Protocol
  4009.                                                 Functional Specification
  4010. SEGMENT ARRIVES
  4011.  
  4012.  
  4013.  
  4014.           <SEQ=ISS><ACK=RCV.NXT><CTL=SYN,ACK>
  4015.  
  4016.         SND.NXT and SND.LBB are set to ISS+1 and SND.UNA to ISS.  The
  4017.         connection state should be changed to SYN-RECEIVED.  Note that
  4018.         any other incoming control or data (combined with SYN) will be
  4019.         processed in the SYN-RECEIVED state, but processing of SYN and
  4020.         ACK should not be repeated.  If the listen was not fully
  4021.         specified (i.e., the foreign socket was not fully specified),
  4022.         then the unspecified fields should be filled in now.
  4023.  
  4024.       if there was no SYN but there was other text or control
  4025.  
  4026.         Any other control or text-bearing segment (not containing SYN)
  4027.         must have an ACK and thus would be discarded by the ACK
  4028.         processing.  An incoming RST segment could not be valid, since
  4029.         it could not have been sent in response to anything sent by this
  4030.         incarnation of the connection.  So you are unlikely to get here,
  4031.         but if you do, drop the segment, and return.
  4032.  
  4033.     If the state is SYN-SENT then
  4034.  
  4035.       first check for an ACK
  4036.  
  4037.         If SEG.ACK =< ISS, or SEG.ACK > SND.NXT, or the
  4038.         security/compartment in the segment does not exactly match the
  4039.         security/compartment in the TCB, or the precedence in the
  4040.         segment is less than the precedence in the TCB, send a reset
  4041.  
  4042.           <SEQ=SEG.ACK><CTL=RST>
  4043.  
  4044.         and discard the segment.  Return.
  4045.  
  4046.         If SND.UNA =< SEG.ACK =< SND.NXT and the security/compartment
  4047.         and precedence are acceptable then the ACK is acceptable.
  4048.         SND.UNA should be advanced to equal SEG.ACK, and any segments on
  4049.         the retransmission queue which are thereby acknowledged should
  4050.         be removed.
  4051.  
  4052.       if the ACK is ok (or there is no ACK), check the RST bit
  4053.  
  4054.         If the RST bit is set then signal the user "error:  connection
  4055.         reset", enter CLOSED state, drop the segment, delete TCB, and
  4056.         return.
  4057.  
  4058.       if the ACK is ok (or there is no ACK) and it was not a RST, check
  4059.       the SYN bit
  4060.  
  4061.  
  4062.  
  4063.                                                                [Page 65]
  4064.  
  4065.  
  4066.                                                             January 1980
  4067. Transmission Control Protocol
  4068. Functional Specification
  4069.                                                          SEGMENT ARRIVES
  4070.  
  4071.  
  4072.  
  4073.         If the SYN bit is on and the security/compartment and precedence
  4074.         are acceptable then, RCV.NXT and RCV.LBB are set to SEG.SEQ+1,
  4075.         IRS is set to SEG.SEQ.  If SND.UNA > ISS (our SYN has been
  4076.         ACKed), change the connection state to ESTABLISHED, otherwise
  4077.         enter SYN-RECEIVED.  In any case, form an ACK segment:
  4078.  
  4079.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4080.  
  4081.         and send it.  Data or controls which were queued for
  4082.         transmission may be included.
  4083.  
  4084.         If SEG.PRC is greater than TCB.PRC set TCB.PRC<-SEG.PRC.
  4085.  
  4086.         If there are other controls or text in the segment then continue
  4087.         processing at the fifth step below where the URG bit is checked,
  4088.         otherwise return.
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096.  
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122. [Page 66]                                                               
  4123.  
  4124.  
  4125. January 1980                                                            
  4126.                                            Transmission Control Protocol
  4127.                                                 Functional Specification
  4128. SEGMENT ARRIVES
  4129.  
  4130.  
  4131.  
  4132.     Otherwise,
  4133.  
  4134.     first check sequence number
  4135.  
  4136.       SYN-RECEIVED STATE
  4137.       ESTABLISHED STATE
  4138.       FIN-WAIT-1 STATE
  4139.       FIN-WAIT-2 STATE
  4140.       TIME-WAIT STATE
  4141.       CLOSE-WAIT STATE
  4142.       CLOSING STATE
  4143.  
  4144.         Segments are processed in sequence.  Initial tests on arrival
  4145.         are used to discard old duplicates, but further processing is
  4146.         done in SEG.SEQ order.  If a segment's contents straddle the
  4147.         boundary between old and new, only the new parts should be
  4148.         processed.
  4149.  
  4150.         There are four cases for the acceptability test for an incoming
  4151.         segment:
  4152.  
  4153.         Segment Receive  Test
  4154.         Length  Window
  4155.         ------- -------  -------------------------------------------
  4156.  
  4157.            0       0     SEG.SEQ = RCV.NXT
  4158.  
  4159.            0      >0     RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
  4160.  
  4161.           >0       0     not acceptable
  4162.  
  4163.           >0      >0     RCV.NXT < SEG.SEQ+SEG.LEN =< RCV.NXT+RCV.WND
  4164.  
  4165.         Note that the test above guarantees that the last sequence
  4166.         number used by the segment lies in the receive-window.  If the
  4167.         RCV.WND is zero, no segments will be acceptable, but special
  4168.         allowance should be made to accept valid ACKs, URGs and RSTs.
  4169.  
  4170.         If an incoming segment is not acceptable, an acknowledgment
  4171.         should be sent in reply:
  4172.  
  4173.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4174.  
  4175.         If the incoming segment is unacceptable, drop it and return.
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.                                                                [Page 67]
  4182.  
  4183.  
  4184.                                                             January 1980
  4185. Transmission Control Protocol
  4186. Functional Specification
  4187.                                                          SEGMENT ARRIVES
  4188.  
  4189.  
  4190.  
  4191.     second check security and precedence
  4192.  
  4193.       If the security/compartment and precedence in the segment do not
  4194.       exactly match the security/compartment and precedence in the TCB
  4195.       then form a reset and return.
  4196.  
  4197.       Note this check is placed following the sequence check to prevent
  4198.       a segment from an old connection between these parts with a
  4199.       different security or precedence from causing an abort of the
  4200.       current connection.
  4201.  
  4202.     third check the ACK field,
  4203.  
  4204.       SYN-RECEIVED STATE
  4205.  
  4206.         If the RST bit is off and SND.UNA < SEG.ACK =< SND.NXT then set
  4207.         SND.UNA <- SEG.ACK, remove any acknowledged segments from the
  4208.         retransmission queue, and enter ESTABLISHED state.
  4209.  
  4210.         If the segment acknowledgment is not acceptable, form a reset
  4211.         segment,
  4212.  
  4213.           <SEQ=SEG.ACK><CTL=RST>
  4214.  
  4215.         and send it, unless the incoming segment is an RST (or there is
  4216.         no ACK), in which case, it should be discarded, then return.
  4217.  
  4218.       ESTABLISHED STATE
  4219.  
  4220.         If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- SEG.ACK.
  4221.         Any segments on the retransmission queue which are thereby
  4222.         entirely acknowledged are removed.  Users should receive
  4223.         positive acknowledgments for buffers which have been SENT and
  4224.         fully acknowledged (i.e., SEND buffer should be returned with
  4225.         "ok" response).  If the ACK is a duplicate, it can be ignored.
  4226.  
  4227.         If the segment passes the sequence number and acknowledgment
  4228.         number tests, the send window should be updated.  If
  4229.         SND.WL =< SEG.SEQ, set SND.WND <- SEG.WND and set
  4230.         SND.WL <- SEG.SEQ.
  4231.  
  4232.         If the remote buffer size is not one, then the
  4233.         end-of-letter/buffer-size adjustment to sequence numbers may
  4234.         have an effect on the next expected sequence number to be
  4235.         acknowledged.  It is possible that the remote TCP will
  4236.         acknowledge with a SEG.ACK equal to a sequence number of an
  4237.  
  4238.  
  4239.  
  4240. [Page 68]                                                               
  4241.  
  4242.  
  4243. January 1980                                                            
  4244.                                            Transmission Control Protocol
  4245.                                                 Functional Specification
  4246. SEGMENT ARRIVES
  4247.  
  4248.  
  4249.  
  4250.         octet that was skipped over at the end of a letter.  This a mild
  4251.         error on the remote TCPs part, but not cause for alarm.
  4252.  
  4253.       FIN-WAIT-1 STATE
  4254.       FIN-WAIT-2 STATE
  4255.  
  4256.         In addition to the processing for the ESTABLISHED state, if the
  4257.         retransmission queue is empty, the user's CLOSE can be
  4258.         acknowledged ("ok") but do not delete the TCB.
  4259.  
  4260.       TIME-WAIT STATE
  4261.  
  4262.         The only thing that can arrive in this state is a retransmission
  4263.         of the remote FIN.  Acknowledge it, and restart the 2 MSL
  4264.         timeout.
  4265.  
  4266.       CLOSE-WAIT STATE
  4267.  
  4268.         Do the same processing as for the ESTABLISHED state.
  4269.  
  4270.       CLOSING STATE
  4271.  
  4272.         If the ACK acknowledges our FIN then delete the TCB (enter the
  4273.         CLOSED state), otherwise ignore the segment.
  4274.  
  4275.     fourth check the RST bit,
  4276.  
  4277.       SYN-RECEIVED STATE
  4278.  
  4279.         If the RST bit is set then, if the segment has passed sequence
  4280.         and acknowledgment tests, it is valid.  If this connection was
  4281.         initiated with a passive OPEN (i.e., came from the LISTEN
  4282.         state), then return this connection to LISTEN state.  The user
  4283.         need not be informed.  If this connection was initiated with an
  4284.         active OPEN (i.e., came from SYN-SENT state) then the connection
  4285.         was refused, signal the user "connection refused".  In either
  4286.         case, all segments on the retransmission queue should be
  4287.         removed.
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.  
  4298.  
  4299.                                                                [Page 69]
  4300.  
  4301.  
  4302.                                                             January 1980
  4303. Transmission Control Protocol
  4304. Functional Specification
  4305.                                                          SEGMENT ARRIVES
  4306.  
  4307.  
  4308.  
  4309.       ESTABLISHED
  4310.       FIN-WAIT-1
  4311.       FIN-WAIT-2
  4312.       CLOSE-WAIT
  4313.       CLOSING STATE
  4314.  
  4315.         If the RST bit is set then, any outstanding RECEIVEs and SEND
  4316.         should receive "reset" responses.  All segment queues should be
  4317.         flushed.  Users should also receive an unsolicited general
  4318.         "connection reset" signal.  Enter the CLOSED state, delete the
  4319.         TCB, and return.
  4320.  
  4321.       TIME-WAIT
  4322.  
  4323.         Enter the CLOSED state, delete the TCB, and return.
  4324.  
  4325.     fifth, check the SYN bit,
  4326.  
  4327.       SYN-RECEIVED
  4328.       ESTABLISHED STATE
  4329.  
  4330.         If the SYN bit is set, check the segment sequence number against
  4331.         the receive window.  The segment sequence number must be in the
  4332.         receive window; if not, ignore the segment.  If the SYN is on
  4333.         and SEG.SEQ = IRS then everything is ok and no action is needed;
  4334.         but if they are not equal, there is an error and a reset must be
  4335.         sent.
  4336.  
  4337.           If a reset must be sent it is formed as follows:
  4338.  
  4339.             <SEQ=SEG.ACK><CTL=RST>
  4340.  
  4341.           The connection must be aborted as if a RST had been received.
  4342.  
  4343.       FIN-WAIT STATE-1
  4344.       FIN-WAIT STATE-2
  4345.       TIME-WAIT STATE
  4346.       CLOSE-WAIT STATE
  4347.       CLOSING STATE
  4348.  
  4349.         This case should not occur, since a duplicate of the SYN which
  4350.         started the current connection incarnation will have been
  4351.         filtered in the SEG.SEQ processing.  Other SYN's will have been
  4352.         rejected by this test as well (see SYN processing for
  4353.         ESTABLISHED state).
  4354.  
  4355.  
  4356.  
  4357.  
  4358. [Page 70]                                                               
  4359.  
  4360.  
  4361. January 1980                                                            
  4362.                                            Transmission Control Protocol
  4363.                                                 Functional Specification
  4364. SEGMENT ARRIVES
  4365.  
  4366.  
  4367.  
  4368.     sixth, check the URG bit,
  4369.  
  4370.       ESTABLISHED STATE
  4371.       FIN-WAIT-1 STATE
  4372.       FIN-WAIT-2 STATE
  4373.  
  4374.         If the URG bit is set, RCV.UP <- max(RCV.UP,SEG.UP), and signal
  4375.         the user that the remote side has urgent data if the urgent
  4376.         pointer (RCV.UP) is in advance of the data consumed.  If the
  4377.         user has already been signaled (or is still in the "urgent
  4378.         mode") for this continuous sequence of urgent data, do not
  4379.         signal the user again.
  4380.  
  4381.       TIME-WAIT STATE
  4382.       CLOSE-WAIT STATE
  4383.       CLOSING
  4384.  
  4385.         This should not occur, since a FIN has been received from the
  4386.         remote side.  Ignore the URG.
  4387.  
  4388.     seventh, process the segment text,
  4389.  
  4390.       ESTABLISHED STATE
  4391.  
  4392.         Once in the ESTABLISHED state, it is possible to deliver segment
  4393.         text to user RECEIVE buffers.  Text from segments can be moved
  4394.         into buffers until either the buffer is full or the segment is
  4395.         empty.  If the segment empties and carries an EOL flag, then the
  4396.         user is informed, when the buffer is returned, that an EOL has
  4397.         been received.
  4398.  
  4399.         If buffer size is not one octet, then do  the following
  4400.         end-of-letter/buffer-size adjustment processing:
  4401.  
  4402.           if EOL = 0 then
  4403.  
  4404.             RCV.NXT <- SEG.SEQ + SEG.LEN
  4405.  
  4406.           if EOL = 1 then
  4407.  
  4408.             While RCV.LBB < SEG.SEQ+SEG.LEN
  4409.             Do RCV.LBB <- RCV.LBB + RCV.BS End
  4410.             RCV.NXT <- RCV.LBB
  4411.  
  4412.         When the TCP takes responsibility for delivering the data to the
  4413.         user it must also acknowledge the receipt of the data.  Send an
  4414.         acknowledgment of the form:
  4415.  
  4416.  
  4417.                                                                [Page 71]
  4418.  
  4419.  
  4420.                                                             January 1980
  4421. Transmission Control Protocol
  4422. Functional Specification
  4423.                                                          SEGMENT ARRIVES
  4424.  
  4425.  
  4426.  
  4427.           <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>
  4428.  
  4429.         This acknowledgment should be piggybacked on a segment being
  4430.         transmitted if possible without incurring undue delay.
  4431.  
  4432.       FIN-WAIT-1 STATE
  4433.       FIN-WAIT-2 STATE
  4434.  
  4435.         If there are outstanding RECEIVEs, they should be satisfied, if
  4436.         possible, with the text of this segment; remaining text should
  4437.         be queued for further processing.  If a RECEIVE is satisfied,
  4438.         the user should be notified, with "end-of-letter" (EOL) signal,
  4439.         if appropriate.
  4440.  
  4441.       TIME-WAIT STATE
  4442.       CLOSE-WAIT STATE
  4443.  
  4444.         This should not occur, since a FIN has been received from the
  4445.         remote side.  Ignore the segment text.
  4446.  
  4447.     eighth, check the FIN bit,
  4448.  
  4449.       Send an acknowledgment for the FIN.  Signal the user "connection
  4450.       closing", and return any pending RECEIVEs with same message.  Note
  4451.       that FIN implies EOL for any segment text not yet delivered to the
  4452.       user.  If the current state is ESTABLISHED, enter the CLOSE-WAIT
  4453.       state.  If the current state is FIN-WAIT-1, enter the CLOSING
  4454.       state.  If the current state is FIN-WAIT-2, enter the TIME-WAIT
  4455.       state.
  4456.  
  4457.     and return.
  4458.  
  4459.  
  4460.  
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470.  
  4471.  
  4472.  
  4473.  
  4474.  
  4475.  
  4476. [Page 72]                                                               
  4477.  
  4478.  
  4479. January 1980                                                            
  4480.                                            Transmission Control Protocol
  4481.                                                 Functional Specification
  4482. USER TIMEOUT
  4483.  
  4484.  
  4485.  
  4486.   USER TIMEOUT
  4487.  
  4488.     For any state if the user timeout expires, flush all queues, signal
  4489.     the user "error:  connection aborted due to user timeout" in general
  4490.     and for any outstanding calls, delete the TCB, and return.
  4491.  
  4492.   RETRANSMISSION TIMEOUT
  4493.  
  4494.     For any state if the retransmission timeout expires on a segment in
  4495.     the retransmission queue, send the segment at the front of the
  4496.     retransmission queue again, reinitialize the retransmission timer,
  4497.     and return.
  4498.  
  4499.    
  4500.  
  4501.  
  4502.  
  4503.  
  4504.  
  4505.  
  4506.  
  4507.  
  4508.  
  4509.  
  4510.  
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.                                                                [Page 73]
  4536.  
  4537.  
  4538.                                                             January 1980
  4539. Transmission Control Protocol
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.  
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.  
  4565.  
  4566.  
  4567.  
  4568.  
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.  
  4577.  
  4578.  
  4579.  
  4580.  
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587.  
  4588.  
  4589.  
  4590.  
  4591.  
  4592.  
  4593.  
  4594. [Page 74]                                                               
  4595.  
  4596.  
  4597. January 1980                                                            
  4598.                                            Transmission Control Protocol
  4599.  
  4600.  
  4601.  
  4602.                                 GLOSSARY
  4603.  
  4604.  
  4605.  
  4606. 1822
  4607.           BBN Report 1822, "The Specification of the Interconnection of
  4608.           a Host and an IMP".  The specification of interface between a
  4609.           host and the ARPANET.
  4610.  
  4611. ACK
  4612.           A control bit (acknowledge) occupying no sequence space, which
  4613.           indicates that the acknowledgment field of this segment
  4614.           specifies the next sequence number the sender of this segment
  4615.           is expecting to receive, hence acknowledging receipt of all
  4616.           previous sequence numbers.
  4617.  
  4618. ARPANET message
  4619.           The unit of transmission between a host and an IMP in the
  4620.           ARPANET.  The maximum size is about 1012 octets (8096 bits).
  4621.  
  4622. ARPANET packet
  4623.           A unit of transmission used internally in the ARPANET between
  4624.           IMPs.  The maximum size is about 126 octets (1008 bits).
  4625.  
  4626. buffer size
  4627.           An option (buffer size) used to state the receive data buffer
  4628.           size of the sender of this option.  May only be sent in a
  4629.           segment that also carries a SYN.
  4630.  
  4631. connection
  4632.           A logical communication path identified by a pair of sockets.
  4633.  
  4634. datagram
  4635.           A message sent in a packet switched computer communications
  4636.           network.
  4637.  
  4638. Destination Address
  4639.           The destination address, usually the network and host
  4640.           identifiers.
  4641.  
  4642. EOL
  4643.           A control bit (End of Letter) occupying no sequence space,
  4644.           indicating that this segment ends a logical letter with the
  4645.           last data octet in the segment.  If this end of letter causes
  4646.           a less than full buffer to be released to the user and the
  4647.           connection buffer size is not one octet then the
  4648.           end-of-letter/buffer-size adjustment to the receive sequence
  4649.           number must be made.
  4650.  
  4651.  
  4652.  
  4653.                                                                [Page 75]
  4654.  
  4655.  
  4656.                                                             January 1980
  4657. Transmission Control Protocol
  4658. Glossary
  4659.  
  4660.  
  4661.  
  4662. FIN
  4663.           A control bit (finis) occupying one sequence number, which
  4664.           indicates that the sender will send no more data or control
  4665.           occupying sequence space.
  4666.  
  4667. fragment
  4668.           A portion of a logical unit of data, in particular an internet
  4669.           fragment is a portion of an internet datagram.
  4670.  
  4671. FTP
  4672.           A file transfer protocol.
  4673.  
  4674. header
  4675.           Control information at the beginning of a message, segment,
  4676.           fragment, packet or block of data.
  4677.  
  4678. host
  4679.           A computer.  In particular a source or destination of messages
  4680.           from the point of view of the communication network.
  4681.  
  4682. Identification
  4683.           An Internet Protocol field.  This identifying value assigned
  4684.           by the sender aids in assembling the fragments of a datagram.
  4685.  
  4686. IMP
  4687.           The Interface Message Processor, the packet switch of the
  4688.           ARPANET.
  4689.  
  4690. internet address
  4691.           A source or destination address specific to the host level.
  4692.  
  4693. internet datagram
  4694.           The unit of data exchanged between an internet module and the
  4695.           higher level protocol together with the internet header.
  4696.  
  4697. internet fragment
  4698.           A portion of the data of an internet datagram with an internet
  4699.           header.
  4700.  
  4701. IP
  4702.           Internet Protocol.
  4703.  
  4704. IRS
  4705.           The Initial Receive Sequence number.  The first sequence
  4706.           number used by the sender on a connection.
  4707.  
  4708.  
  4709.  
  4710.  
  4711.  
  4712. [Page 76]                                                               
  4713.  
  4714.  
  4715. January 1980                                                            
  4716.                                            Transmission Control Protocol
  4717.                                                                 Glossary
  4718.  
  4719.  
  4720.  
  4721. ISN
  4722.           The Initial Sequence Number.  The first sequence number used
  4723.           on a connection, (either ISS or IRS).  Selected on a clock
  4724.           based procedure.
  4725.  
  4726. ISS
  4727.           The Initial Send Sequence number.  The first sequence number
  4728.           used by the sender on a connection.
  4729.  
  4730. leader
  4731.           Control information at the beginning of a message or block of
  4732.           data.  In particular, in the ARPANET, the control information
  4733.           on an ARPANET message at the host-IMP interface.
  4734.  
  4735. left sequence
  4736.           This is the next sequence number to be acknowledged by the
  4737.           data receiving TCP (or the lowest currently unacknowledged
  4738.           sequence number) and is sometimes referred to as the left edge
  4739.           of the send window.
  4740.  
  4741. letter
  4742.           A logical unit of data, in particular the logical unit of data
  4743.           transmitted between processes via TCP.
  4744.  
  4745. local packet
  4746.           The unit of transmission within a local network.
  4747.  
  4748. module
  4749.           An implementation, usually in software, of a protocol or other
  4750.           procedure.
  4751.  
  4752. MSL
  4753.           Maximum Segment Lifetime, the time a TCP segment can exist in
  4754.           the internetwork system.  Arbitrarily defined to be 2 minutes.
  4755.  
  4756. octet
  4757.           An eight bit byte.
  4758.  
  4759. Options
  4760.           An Option field may contain several options, and each option
  4761.           may be several octets in length.  The options are used
  4762.           primarily in testing situations; for example, to carry
  4763.           timestamps.  Both the Internet Protocol and TCP provide for
  4764.           options fields.
  4765.  
  4766. packet
  4767.           A package of data with a header which may or may not be
  4768.  
  4769.  
  4770.  
  4771.                                                                [Page 77]
  4772.  
  4773.  
  4774.                                                             January 1980
  4775. Transmission Control Protocol
  4776. Glossary
  4777.  
  4778.  
  4779.  
  4780.           logically complete.  More often a physical packaging than a
  4781.           logical packaging of data.
  4782.  
  4783. port
  4784.           The portion of a socket that specifies which logical input or
  4785.           output channel of a process is associated with the data.
  4786.  
  4787. process
  4788.           A program in execution.  A source or destination of data from
  4789.           the point of view of the TCP or other host-to-host protocol.
  4790.  
  4791. PSN
  4792.           A Packet Switched Network.  For example, the ARPANET.
  4793.  
  4794. RCV.BS
  4795.           receive buffer size, the remote buffer size
  4796.  
  4797. RCV.LBB
  4798.           receive last buffer beginning
  4799.  
  4800. RCV.NXT
  4801.           receive next sequence number
  4802.  
  4803. RCV.UP
  4804.           receive urgent pointer
  4805.  
  4806. RCV.WND
  4807.           receive window
  4808.  
  4809. receive last buffer beginning
  4810.           This is the sequence number of the first octet of the most
  4811.           recent buffer.  This value is use in calculating the next
  4812.           sequence number when a segment contains an end of letter
  4813.           indication.
  4814.  
  4815. receive next sequence number
  4816.           This is the next sequence number the local TCP is expecting to
  4817.           receive.
  4818.  
  4819. receive window
  4820.           This represents the sequence numbers the local (receiving) TCP
  4821.           is willing to receive.  Thus, the local TCP considers that
  4822.           segments overlapping the range RCV.NXT to
  4823.           RCV.NXT + RCV.WND - 1 carry acceptable data or control.
  4824.           Segments containing sequence numbers entirely outside of this
  4825.           range are considered duplicates and discarded.
  4826.  
  4827.  
  4828.  
  4829.  
  4830. [Page 78]                                                               
  4831.  
  4832.  
  4833. January 1980                                                            
  4834.                                            Transmission Control Protocol
  4835.                                                                 Glossary
  4836.  
  4837.  
  4838.  
  4839. RST
  4840.           A control bit (reset), occupying no sequence space, indicating
  4841.           that the receiver should delete the connection without further
  4842.           interaction.  The receiver can determine, based on the
  4843.           sequence number and acknowledgment fields of the incoming
  4844.           segment, whether it should honor the reset command or ignore
  4845.           it.  In no case does receipt of a segment containing RST give
  4846.           rise to a RST in response.
  4847.  
  4848. RTP
  4849.           Real Time Protocol:  A host-to-host protocol for communication
  4850.           of time critical information.
  4851.  
  4852. Rubber EOL
  4853.           An end of letter (EOL) requiring a sequence number adjustment
  4854.           to align the beginning of the next letter on a buffer
  4855.           boundary.
  4856.  
  4857. SEG.ACK
  4858.           segment acknowledgment
  4859.  
  4860. SEG.LEN
  4861.           segment length
  4862.  
  4863. SEG.PRC
  4864.           segment precedence value
  4865.  
  4866. SEG.SEQ
  4867.           segment sequence
  4868.  
  4869. SEG.UP
  4870.           segment urgent pointer field
  4871.  
  4872. SEG.WND
  4873.           segment window field
  4874.  
  4875. segment
  4876.           A logical unit of data, in particular a TCP segment is the
  4877.           unit of data transfered between a pair of TCP modules.
  4878.  
  4879. segment acknowledgment
  4880.           The sequence number in the acknowledgment field of the
  4881.           arriving segment.
  4882.  
  4883. segment length
  4884.           The amount of sequence number space occupied by a segment,
  4885.           including any controls which occupy sequence space.
  4886.  
  4887.  
  4888.  
  4889.                                                                [Page 79]
  4890.  
  4891.  
  4892.                                                             January 1980
  4893. Transmission Control Protocol
  4894. Glossary
  4895.  
  4896.  
  4897.  
  4898. segment sequence
  4899.           The number in the sequence field of the arriving segment.
  4900.  
  4901. send last buffer beginning
  4902.           This is the sequence number of the first octet of the most
  4903.           recent buffer.  This value is used in calculating the next
  4904.           sequence number when a segment contains an end of letter
  4905.           indication.
  4906.  
  4907. send sequence
  4908.           This is the next sequence number the local (sending) TCP will
  4909.           use on the connection.  It is initially selected from an
  4910.           initial sequence number curve (ISN) and is incremented for
  4911.           each octet of data or sequenced control transmitted.
  4912.  
  4913. send window
  4914.           This represents the sequence numbers which the remote
  4915.           (receiving) TCP is willing to receive.  It is the value of the
  4916.           window field specified in segments from the remote (data
  4917.           receiving) TCP.  The range of sequence numbers which may be
  4918.           emitted by a TCP lies between SND.NXT and
  4919.           SND.UNA + SND.WND - 1.
  4920.  
  4921. SND.BS
  4922.            send buffer size, the local buffer size
  4923.  
  4924. SND.LBB
  4925.           send last buffer beginning
  4926.  
  4927. SND.NXT
  4928.           send sequence
  4929.  
  4930. SND.UNA
  4931.           left sequence
  4932.  
  4933. SND.UP
  4934.           send urgent pointer
  4935.  
  4936. SND.WL
  4937.           send sequence number at last window update
  4938.  
  4939. SND.WND
  4940.           send window
  4941.  
  4942. socket
  4943.           An address which specifically includes a port identifier, that
  4944.           is, the concatenation of an Internet Address with a TCP port.
  4945.  
  4946.  
  4947.  
  4948. [Page 80]                                                               
  4949.  
  4950.  
  4951. January 1980                                                            
  4952.                                            Transmission Control Protocol
  4953.                                                                 Glossary
  4954.  
  4955.  
  4956.  
  4957. Source Address
  4958.           The source address, usually the network and host identifiers.
  4959.  
  4960. SYN
  4961.           A control bit in the incoming segment, occupying one sequence
  4962.           number, used at the initiation of a connection, to indicate
  4963.           where the sequence numbering will start.
  4964.  
  4965. TCB
  4966.           Transmission control block, the data structure that records
  4967.           the state of a connection.
  4968.  
  4969. TCB.PRC
  4970.           The precedence of the connection.
  4971.  
  4972. TCP
  4973.           Transmission Control Protocol:  A host-to-host protocol for
  4974.           reliable communication in internetwork environments.
  4975.  
  4976. TOS
  4977.           Type of Service, an Internet Protocol field.
  4978.  
  4979. Type of Service
  4980.           An Internet Protocol field which indicates the type of service
  4981.           for this internet fragment.
  4982.  
  4983. URG
  4984.           A control bit (urgent), occupying no sequence space, used to
  4985.           indicate that the receiving user should be notified to do
  4986.           urgent processing as long as there is data to be consumed with
  4987.           sequence numbers less than the value indicated in the urgent
  4988.           pointer.
  4989.  
  4990. urgent pointer
  4991.           A control field meaningful only when the URG bit is on.  This
  4992.           field communicates the value of the urgent pointer which
  4993.           indicates the data octet associated with the sending user's
  4994.           urgent call.
  4995.  
  4996.           
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.                                                                [Page 81]
  5008.  
  5009.  
  5010.                                                             January 1980
  5011. Transmission Control Protocol
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066. [Page 82]                                                               
  5067.  
  5068.  
  5069. January 1980                                                            
  5070.                                            Transmission Control Protocol
  5071.  
  5072.  
  5073.  
  5074.                                REFERENCES
  5075.  
  5076.  
  5077.  
  5078. [1]  Cerf, V., and R. Kahn, "A Protocol for Packet Network
  5079.      Intercommunication," IEEE Transactions on Communications,
  5080.      Vol. COM-22, No. 5, pp 637-648, May 1974.
  5081.  
  5082. [2]  Postel, J. (ed.), "DOD Standard Internet Protocol," Defense
  5083.      Advanced Research Projects Agency, Information Processing
  5084.      Techniques Office, RFC 760, IEN 128, January 1980.
  5085.  
  5086. [3]  Feinler, E. and J. Postel, ARPANET Protocol Handbook, Network
  5087.      Information Center, SRI International, Menlo Park, CA,
  5088.      January 1978.
  5089.  
  5090. [4]  Dalal, Y. and C. Sunshine, "Connection Management in Transport
  5091.      Protocols," Computer Networks, Vol. 2, No. 6, pp. 454-473,
  5092.      December 1978.
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.  
  5125.                                                                [Page 83]
  5126.  
  5127.  
  5128.                                                             January 1980
  5129. Transmission Control Protocol
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.  
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184. [Page 84]                                                               
  5185.  
  5186.