RT:TCP Connection Close

Source: Internet
Author: User

CLOSE is an operation meaning "I has no more data to send." The notion of closing a Full-duplex connection is subject to ambiguous interpretation, of course, since it could not be obvi OUs how to treat the receiving side of the connection. We have chosen to treat CLOSE in a simplex fashion. The user closes may continue to RECEIVE until he's told that the other side have CLOSED also. Thus, a program could initiate several sends followed by a CLOSE, and then continue to RECEIVE until signaled that a recei VE failed because the other side have CLOSED. We assume that the TCP would signal a user, even if no receives is outstanding, that the other side have closed, so the use R can terminate his side gracefully. A TCP would reliably deliver all buffers SENT before the connection is CLOSED so a user who expects no data in return need Only wait to hear the connection is CLOSED successfully to know so all his data is received at the destination TCP. Users must keep reading connections they clOSE for sending until the TCP says no more data. There is essentially three cases:

    1) The user initiates by telling the TCP to CLOSE the connection    2) The remote TCP initiates by sending a FIN control Signal    3) Both users CLOSE simultaneously

Case 1:local user initiates the close

    In this case, a FIN segment can is constructed and placed on the    outgoing segment queue.  No further sends from the user would be    a accepted by the TCP, and it enters the fin-wait-1 state.  Receives is allowed in this state    .  All segments preceding and including FIN would be    retransmitted until acknowledged.  When the other TCP have    both acknowledged the fin and sent a fin of its own, the first TCP    can ACK this fin.
   
    note that a TCP receiving a fin would ACK but not    send it own FIN until its user have CLOSED the connection also.
   

Case 2:TCP receives a FIN from the network

    If an unsolicited FIN arrives from the network, the receiving TCP    can ACK it and tell the user that the connection is Closing.    the user would respond with a CLOSE, upon which the TCP can send a FIN to the other    TCP after sending any remaining Data.  The TCP then waits    until their own FIN is acknowledged whereupon it deletes the    connection.  If an ACK isn't forthcoming, after the user timeout The    connection are aborted and the user is told.

Case 3:both users close simultaneously

    A simultaneous CLOSE by the users at both ends of a connection causes    FIN segments to be exchanged.  When all segments preceding the FINs had    been processed and acknowledged, each TCP can ACK the FIN it had    recei Ved.  Both would, upon receiving these ACKs, delete the    connection.

      TCP A                                                TCP B  1.  Established                                          established  2.  (Close)      Fin-wait-1  -<SEQ=100><ACK=300><CTL=FIN,ACK>  -close-wait  3.  Fin-wait-2  <--<SEQ=300><ACK=101><CTL=ACK>      <--close-wait  4.                                                       (Close)      Time-wait   <--<SEQ=300><ACK=101><CTL=FIN,ACK>  <--last-ack  5.  Time-wait   -<SEQ=101><ACK=301><CTL=ACK>      -CLOSED  6.  (2 MSL)      CLOSED                                                                               Normal Close Sequence Figure                               13.

 TCP A TCP B 1.  Established established 2.                                              (Close)      (Close) Fin-wait-1-<SEQ=100><ACK=300><CTL=FIN,ACK> ... Fin-wait-1 <--<SEQ=300><ACK=100><CTL=FIN,ACK> <--... <seq=  100><ack=300><ctl=fin,ack>-3. CLOSING-<SEQ=101><ACK=301><CTL=ACK> ... CLOSING <--<SEQ=301><ACK=101><CTL=ACK> <--... <seq=101  ><ACK=301><CTL=ACK> 4. Time-wait time-wait (2 MSL) (                               2 MSL) CLOSED CLOSED simultaneous Close Sequence Figure. 

Rt:tcp Connection Close

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.