TCP three-way handshake and four-way handshake

Source: Internet
Author: User

TCP three-way handshake and four-way handshake

TCP three-way handshake and four-way handshake

Three-way handshake

1. First handshake

The client sends a TCP packet whose SYN (Synchronize) flag is set to 1 to the server.

Seq (Sequence Number) is a random Number generated by the operating system. Then, the client enters the SYN_SEND status and waits for confirmation from the server.

2. Second handshake

When the server receives the SYN packet from the client, it sends a confirmation packet (SYN/ACK) to the server.

ACK (Acknowledgment Number) is x + 1 (Sequence Number + 1). The server sends the SYN + ACK packet segment to the client, and the server enters the SYN_RECV status.

3. The third handshake

After receiving the SYN/ACK packet, the client sends an ACK packet to notify the server that the connection has been established.

Three-way handshake Demonstration:

Three-way handshake seq ack first 10000 0 second 20000 + 1 = 10000 third 10001 + 1 = 10001
Four Waves

1. For the first time, the client: "No data is provided to you 』;

2. Second time: SERVER: "I have received this message, and I have no data for you 』;

3. Third time: SERVER: "request to close the connection 』;

4. Fourth time: Client: "OK 』;

After receiving the message, the server closes the connection. If the client fails to receive a response, the connection is also closed.

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.