Computer network-TCP Connection

Source: Internet
Author: User

TCP Header 20 bytes

1. Why does TCP need to establish a connection through three handshakes?

During the TCP connection process, the client sends a request to the server. The server confirms that the request is sent to the client, and the client then sends a confirmation request to the server.

Cause: in short, in order to prevent invalid connection requests from being sent to the server, the server determines that a connection has been established until the client's data has exceeded the value set by the keep counter, only when you realize that a problem occurs on the client, will the connection be closed. If there are three handshakes, no connection will be established.

Detailed reasons for online explanation:

"

The first two handshakes are obviously necessary, mainly the last one. That is, why do the client want to send a confirmation message after receiving the confirmation from the server? This is mainly to prevent connection misjudgment when invalid request packets are suddenly transmitted to the server.

Consider the following situation: the client sends a connection request packet segment to the server, but has been stuck on some network nodes for a long time, then the client times out and resends a connection request message segment to the server. Then the connection is established normally, data transmission is complete, and the connection is released. If the request message segment sent for the first time is delayed for a period of time and then arrives at the server, it is obviously a long-overdue message segment, after receiving the message, the server mistakenly thinks that the client has sent a connection request again. Therefore, the server sends a confirmation message segment to the client and agrees to establish a connection. If three handshakes are not used, the server only needs to send a confirmation message, and the new connection is established. However, since the client does not send a connection establishment request more than you, the server does not accept the confirmation, it does not send data to the server, but the server considers that a new connection has been established and is waiting for the client to send data, so that the server will keep waiting, the connection will not be closed until the value of the active/active counter is exceeded and the client is determined to be faulty. This wastes a lot of server resources. If the three-way handshake is used, the client will not send a confirmation to the server. Because the server cannot receive the confirmation, it will know that the client does not require a connection and thus does not establish the connection.

"

2. Why do I need to shake hands four times when a TCP disconnection occurs?

When the client sends a close request to the server, all the client data has been sent to the server. At the same time, the server also needs to send a close request to the client, indicating that it has no data to send to the client.

 

Computer network-TCP Connection

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.