Analysis of TCP/IP three-way handshake protocol

Source: Internet
Author: User

TCP/ip three-way handshake Protocol analysis TCP (Transmission Control Protocol) Transmission Control Protocol TCP is the Transmission Control Protocol of the host to the host layer, providing reliable connection services, establish a connection using three-way handshake confirmation: The bit code is the tcp flag bit, there are 6 types of labels: SYN (synchronous established online) ACK (acknowledgement confirmation) PSH (push transfer) FIN (finish) RST (reset) URG (urgent) Sequence number (Sequence number) Acknowledge number (confirmation number) first handshake: host A sends A location code as syn = 1, A data packet of seq number = 1234567 is randomly generated to the server, and host B is known by SYN = 1. A requires online connection. The second handshake: after receiving the request, host B needs to confirm the online information, send ack number = (seq + 1 of host A), syn = 1, ack = 1, and randomly generate se Q = 7654321 packet's third handshake: After receiving the handshake, host A checks whether the ack number is correct, that is, the seq number + 1 sent for the first time, and whether the ack is 1. If yes, host A will send ack number = (seq + 1 of host B), ack = 1 again. After host B receives the message, confirm that the seq value is set to ack = 1, and the connection is established successfully. After three handshakes are completed, data is transmitted between host A and host B. In TCP/IP, TCP provides reliable connection services and uses three handshakes to establish a connection. First handshake: when a connection is established, the client sends the syn Packet (syn = j) to the server and enters the SYN_SEND status. wait for confirmation from the server. Second handshake: the server receives the syn packet, you must confirm the customer's SYN (ack = j + 1) and send a SYN Packet (syn = k), that is, the SYN + ACK packet. At this time, the server enters the SYN_RECV status; the third handshake: the client receives the server's SYN + ACK package and sends the ACK (ack = k + 1) Confirmation package to the server. After the package is sent, the client and server enter the ESTABLISHED status, complete three handshakes. After three handshakes are completed, the client and the server start to transmit data. instance: IP 192.168.1.116.3337> 192.168.1.123.7788: S 3626544836: 192.168.1.123.7788> 192.168.1.116.3337: S 1739326486: 1739326486 ack timeout >192.168.1.123.7788: ack 1739326487, ack 1 first handshake: 192.168.1.116 sender's syn = 1, generate a random seq number = 3626544836 packet to 192.168.1.123, 192.168.1.123 from SYN = 1 to know 192.168.1.116 requires online connection; the second handshake: 192.168.1.123 to confirm the online information after receiving the request, to 192.168.1.116 Send ack number = 3626544837, syn = 1, ack = 1, and generate a packet with seq = 1739326486 at random. The third handshake: 192.168.1.116. After receiving the packet, check whether the ack number is correct, that is, the seq number + 1 sent for the first time, and whether the bit code ack is 1. If it is correct, 192.168.1.116 will send ack number = 1739326487, ack = 1, after receiving the message, 192.168.1.123 confirms that seq = seq + 1 and ack = 1, the connection is established successfully. Diagram: A three-way handshake (Figure 1, Figure 2) (Figure 1) (figure 2) the flag of the first handshake (figure 3) we can see that there is only one synchronization bit in the flag, that is, the request (SYN)
(Figure 3) the flag of the second handshake (figure 4) We can see that there is a confirmation and synchronization bit in the flag, that is, the response (SYN + ACK)
(Figure 4) Flag of the third handshake (figure 5) We can see that there is only one confirmation bit in the flag, that is, re-confirmation (ACK) (figure 5) A complete three-way handshake, that is, request-response-confirm again

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.