TCP connection establishment/removal

Source: Internet
Author: User


TCP connection establishment/removal

How to Establish a TCP connection in Figure 1TCP Header Format, the SYN flag is used only when a TCP connection is established. The TCP connection establishment process is called a "three-way handshake" connection, that is, generally, both parties need to transmit three data packets to successfully establish a TCP connection. We usually take the establishment of a connection as a leading process to use the TCP protocol, but seldom question the necessity of such a connection process.

In fact, TCP must first establish a connection to ensure the reliability of data transmission over TCP (of course, because TCP is a stateful protocol, you must use a mechanism to synchronize the status of both parties, and establishing a connection is such a mechanism ). Www.2cto.com as to why three data packets are required, the reason is that at least three data packets must be used for information exchange during connection establishment. According to the analysis below, a maximum of four data packets can be used for connection establishment. It should be mentioned again that the SYN flag is only used in the three (or four) data packets that establish the connection. Once the connection is established, the SYN flag cannot be set for all data packets sent afterwards. From the perspective of ensuring data reliability transmission, TCP must first exchange certain information before the formal data transmission, this information is the initial serial number of both parties (Other information includes the maximum packet length notification ). As mentioned above, the use of serial numbers is crucial for the TCP protocol. Before the formal data transmission, both parties must obtain the first byte data number of the other party, in this way, it is possible to determine the legitimacy of the data it receives, and further identify and solve a series of problems such as data duplication and data overlap. Therefore, the initial serial numbers of the exchange must be completed before the formal data transmission. We call this process as the connection establishment process. As for the status updates of the TCP protocol, the software design reliability guarantee is mainly used as an aid, not a major concern of this so-called establishment process. The exchange of the initial serial number of www.2cto.com requires four data packets from the most direct perspective: 1> host A sends its initial serial number to host B. 2> host B sends an initial serial number to host. 3> host B sends its initial serial number to host. 4> host A confirms the initial serial number sent by host B. We combine <2> <3> two steps into one step, that is, B sends an initial serial number (that is, B's own) to A while confirming its initial serial number (that is, B's own) to. The so-called confirm that the packet's ACK flag is set to 1. Note that the SYN flag in the three (or four) packets is set to 1, and the SYN flag is only set to 1 in the three (or four) packets.
The problem is that host A and host B can transmit some normal data while reporting their initial serial numbers. In principle, yes (the TCP protocol specification does not mean no ), however, most implementations do not include normal data when reporting the initial serial number, but use it as a separate process, thus formally establishing a connection. How does www.2cto.com TCP remove the connection between the two sides of the current connection can be initiated to remove the connection, but a simple removal of the connection may cause data loss. Therefore, TCP uses a four-way handshake to remove the connection.
The four handshakes are similar to the three handshakes: ① 1. 1. 1. 1. 2. 2. 2. 2. Confirm the request. 1. After receiving the confirmation, no data is sent, however, the system will still receive data (semi-join) ③ 2 send a demolition request ④ 1 receive the request and confirm that the removal is complete.

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.