"Learning Notes" connection and release of TCP

Source: Internet
Author: User

First, we introduce some key signals of TCP packets.

The ACK:TCP agreement stipulates that only ack=1 is valid and that all messages sent after the connection is established must have an ACK of 1
SYN (synchronization): Used to synchronize the sequence number when the connection is established. When Syn=1 and ack=0, it indicates that this is a connection request message. If the other party agrees to establish the connection, the Syn=1 and ack=1 should be made in the response message. Therefore, the SYN 1 indicates that this is a connection request or a connection acceptance message.
FIN (Finis) is the end, which means to release a connection. When FIN = 1 o'clock, it indicates that the sender's data for this segment has been sent, and that the connection is required to be released.

Three-time handshake for TCP connections

First, the client makes a request to connect the Syn=1 ack=0, TCP rules syn=1 can not carry data, but to consume a sequence number, so declare their serial number is seq=x.
The Server then responds with confirmation that syn=1 ack=1 seq=y, ack=x+1.
Then the Client again to confirm, but no SYN, this is ack=1, seq=x+1, ack=y+1.
Then the connection is established.

TCP Connection Release process

When customer A does not have something to send to release a This side of the connection, a will send a message (no data), where FIN is set to 1, Server B receives a letter to the application, then a side of the connection has been closed, that a no longer send information (but still can receive information). A received B confirmation after entering the waiting state, waiting for the B request to release the connection, b after the data sent to a request connection release, is also expressed with fin=1, and with ACK = U+1 (), a received after reply to a confirmation message, and entered the time_wait state, waiting for 2MSL time.
Why wait?
For this situation: B to a send FIN = 1 release connection request, but this message is missing, a does not receive a confirmation message, B timeout will be re-transmitted, then a in Wait_time can also receive this request, then reply to a confirmation on the line. (A when a request for FIN = 1 is received, Wait_time is re-credited).

"Learning Notes" connection and release of TCP

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.