TCP three-way handshake

Source: Internet
Author: User

TCP three-way handshake

First handshake

The client calls connect to send a connection request message to the server. The packet is a special packet. The first synchronization bit SYN = 1, and the confirmation bit ACK = 0, seq = x indicates that the value of the validation field is x. The value of this field is selected by the client, the first byte Number of the data sent from the client to the server is x + 1. After the connection packet is sent, the TCP connection status of the client is changed from CLOSED to SYN_SENT.

The server calls accept to retrieve a connection request from the lisent Connection Request queue, create a socket and allocate resources for it, and start to establish a connection. The TCP connection status of the server is changed from LISENT to SYN_RCVD.

Second handshake

The server allocates resources for the connection, agrees to connect, and sends a confirmation message of SYN = 1 to the client. ACK = 1 indicates that the ack value of the validation number field is valid, and ack = x + 1 indicates that you want to receive data with the first byte number x + 1, seq = y indicates that the starting byte number of data sent from the server to the client is y + 1. The client receives confirmation, and the TCP connection status changes from SYN_SENT to ESTABLISHED.

Third handshake

The TCP connection status of the client is changed to ESTABLISHED. The confirmation message is sent to the server immediately. The connect function returns and the connection is ESTABLISHED successfully.

The server receives the confirmation message from the client. The TCP connection status is changed from SYN_RCVD to ESTABLISHED. The accept function is returned.

At this point, the three-way handshake of a connection ends. The connection is established and the client can communicate with the server reliably.

This article permanently updates the link address:

Related Article

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.