Connected: An Internet Encyclopedia
RFC 1323 - APPENDIX E: EVENT PROCESSING

Top: Connected: An Internet Encyclopedia
Up: Requests For Comments
Up: RFC 1323
Prev: APPENDIX D: SUMMARY OF NOTATION
Next: Security Considerations

### APPENDIX E: EVENT PROCESSING

      OPEN Call

         ...
        An initial send sequence number (ISS) is selected.  Send a SYN
        segment of the form:

            <SEQ=ISS><CTL=SYN><TSval=my.TSclock><WSopt=Rcv.Wind.Scale>

          ...

      SEND Call

        CLOSED STATE (i.e., TCB does not exist)

          ...

        LISTEN STATE

          If the foreign socket is specified, then change the connection
          from passive to active, select an ISS.  Send a SYN segment
          containing the options: <TSval=my.TSclock> and
          <WSopt=Rcv.Wind.Scale>.  Set SND.UNA to ISS, SND.NXT to ISS+1.
          Enter SYN-SENT state. ...

        SYN-SENT STATE
        SYN-RECEIVED STATE

          ...

        ESTABLISHED STATE
        CLOSE-WAIT STATE

          Segmentize the buffer and send it with a piggybacked
          acknowledgment (acknowledgment value = RCV.NXT).  ...

          If the urgent flag is set ...

          If the Snd.TS.OK flag is set, then include the TCP Timestamps
          option <TSval=my.TSclock,TSecr=TS.Recent> in each data segment.

          Scale the receive window for transmission in the segment header:

                SEG.WND = (SND.WND >> Rcv.Wind.Scale).
      SEGMENT ARRIVES

         ...

        If the state is LISTEN then

          first check for an RST

            ...

          second check for an ACK

            ...

          third check for a SYN

            if the SYN bit is set, check the security.  If the ...

             ...

            If the SEG.PRC is less than the TCB.PRC then continue.

            Check for a Window Scale option (WSopt); if one is found, save
            SEG.WSopt in Snd.Wind.Scale and set Snd.WS.OK flag on.
            Otherwise, set both Snd.Wind.Scale and Rcv.Wind.Scale to zero
            and clear Snd.WS.OK flag.

            Check for a TSopt option; if one is found, save SEG.TSval in the
            variable TS.Recent and turn on the Snd.TS.OK bit.

            Set RCV.NXT to SEG.SEQ+1, IRS is set to SEG.SEQ and any other
            control or text should be queued for processing later.  ISS
            should be selected and a SYN segment sent of the form:

              <SEQ=ISS><ACK=RCV.NXT><CTL=SYN,ACK>

            If the Snd.WS.OK bit is on, include a WSopt option
            <WSopt=Rcv.Wind.Scale> in this segment.  If the Snd.TS.OK bit is
            on, include a TSopt <TSval=my.TSclock,TSecr=TS.Recent> in this
            segment.  Last.ACK.sent is set to RCV.NXT.

            SND.NXT is set to ISS+1 and SND.UNA to ISS.  The connection
            state should be changed to SYN-RECEIVED.  Note that any other
            incoming control or data (combined with SYN) will be processed
            in the SYN-RECEIVED state, but processing of SYN and ACK should
            not be repeated.  If the listen was not fully specified (i.e.,
            the foreign socket was not fully specified), then the
            unspecified fields should be filled in now.
          fourth other text or control

           ...

        If the state is SYN-SENT then

          first check the ACK bit

            ...

          fourth check the SYN bit

             ...

            If the SYN bit is on and the security/compartment and precedence
            are acceptable then, RCV.NXT is set to SEG.SEQ+1, IRS is set to
            SEG.SEQ, and any acknowledgements on the retransmission queue
            which are thereby acknowledged should be removed.

            Check for a Window Scale option (WSopt); if is found, save
            SEG.WSopt in Snd.Wind.Scale; otherwise, set both Snd.Wind.Scale
            and Rcv.Wind.Scale to zero.

            Check for a TSopt option; if one is found, save SEG.TSval in
            variable TS.Recent and turn on the Snd.TS.OK bit in the
            connection control block.  If the ACK bit is set, use my.TSclock
            - SEG.TSecr as the initial RTT estimate.

            If SND.UNA > ISS (our SYN has been ACKed), change the connection
            state to ESTABLISHED, form an ACK segment:

                <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>

            and send it.  If the Snd.Echo.OK bit is on, include a TSopt
            option <TSval=my.TSclock,TSecr=TS.Recent> in this ACK segment.
            Last.ACK.sent is set to RCV.NXT.

            Data or controls which were queued for transmission may be
            included.  If there are other controls or text in the segment
            then continue processing at the sixth step below where the URG
            bit is checked, otherwise return.

            Otherwise enter SYN-RECEIVED, form a SYN,ACK segment:

                <SEQ=ISS><ACK=RCV.NXT><CTL=SYN,ACK>

            and send it.  If the Snd.Echo.OK bit is on, include a TSopt
            option <TSval=my.TSclock,TSecr=TS.Recent> in this segment.  If
            the Snd.WS.OK bit is on, include a WSopt option
            <WSopt=Rcv.Wind.Scale> in this segment.  Last.ACK.sent is set to
            RCV.NXT.

            If there are other controls or text in the segment, queue them
            for processing after the ESTABLISHED state has been reached,
            return.

          fifth, if neither of the SYN or RST bits is set then drop the
          segment and return.

        Otherwise,

        First, check sequence number

          SYN-RECEIVED STATE
          ESTABLISHED STATE
          FIN-WAIT-1 STATE
          FIN-WAIT-2 STATE
          CLOSE-WAIT STATE
          CLOSING STATE
          LAST-ACK STATE
          TIME-WAIT STATE

            Segments are processed in sequence.  Initial tests on arrival
            are used to discard old duplicates, but further processing is
            done in SEG.SEQ order.  If a segment's contents straddle the
            boundary between old and new, only the new parts should be
            processed.

            Rescale the received window field:

                TrueWindow = SEG.WND << Snd.Wind.Scale,

            and use "TrueWindow" in place of SEG.WND in the following steps.

            Check whether the segment contains a Timestamps option and bit
            Snd.TS.OK is on.  If so:

              If SEG.TSval < TS.Recent, then test whether connection has
              been idle less than 24 days; if both are true, then the
              segment is not acceptable; follow steps below for an
              unacceptable segment.

              If SEG.SEQ is equal to Last.ACK.sent, then save SEG.ECopt in
              variable TS.Recent.

            There are four cases for the acceptability test for an incoming
            segment:

              ...

            If an incoming segment is not acceptable, an acknowledgment
            should be sent in reply (unless the RST bit is set, if so drop
            the segment and return):

              <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>

            Last.ACK.sent is set to SEG.ACK of the acknowledgment.  If the
            Snd.Echo.OK bit is on, include the Timestamps option
            <TSval=my.TSclock,TSecr=TS.Recent> in this ACK segment.  Set
            Last.ACK.sent to SEG.ACK and send the ACK segment.  After
            sending the acknowledgment, drop the unacceptable segment and
            return.

              ...

        fifth check the ACK field.

          if the ACK bit is off drop the segment and return.

          if the ACK bit is on

            ...

            ESTABLISHED STATE

              If SND.UNA < SEG.ACK =< SND.NXT then, set SND.UNA <- SEG.ACK.
              Also compute a new estimate of round-trip time.  If Snd.TS.OK
              bit is on, use my.TSclock - SEG.TSecr; otherwise use the
              elapsed time since the first segment in the retransmission
              queue was sent.  Any segments on the retransmission queue
              which are thereby entirely acknowledged...

                ...

        Seventh, process the segment text.

          ESTABLISHED STATE
          FIN-WAIT-1 STATE
          FIN-WAIT-2 STATE

              ...

            Send an acknowledgment of the form:
              <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK>

            If the Snd.TS.OK bit is on, include Timestamps option
            <TSval=my.TSclock,TSecr=TS.Recent> in this ACK segment.  Set
            Last.ACK.sent to SEG.ACK of the acknowledgment, and send it.
            This acknowledgment should be piggy-backed on a segment being
            transmitted if possible without incurring undue delay.

             ...

Next: Security Considerations

Connected: An Internet Encyclopedia
RFC 1323 - APPENDIX E: EVENT PROCESSING