Three-time handshake

Source: Internet
Author: User
Tags ack reset
analysis of three-time handshake process for TCP protocol

TCP (transmission Control Protocol) transmission protocol

TCP is the host-to-host layer of the Transmission Control Protocol, providing a reliable connection service, using three-time handshake confirmation to establish a connection:

The bit code is the TCP flag bit, there are 6 kinds of marking: SYN (synchronous set up) ACK (acknowledgement acknowledgment) PSH (push transfer) FIN (finish end) RST (reset reset) URG (Urgent emergency)

Sequence number (sequential) Acknowledge number (confirmation)

First handshake: Host a send bit code for syn=1, randomly generate SEQ number=1234567 packet to the server, Host B by Syn=1 know, a requirements to establish online;

Second handshake: Host B receives the request to confirm the online information, send an ACK to a number= (host A's seq+1), syn=1,ack=1, randomly generate seq=7654321 packets

Third handshake: Host a after receiving check ACK number is correct, that is, the first sent Seq Number+1, and the bit code ACK is 1, if correct, host A will send an ACK number= (Host B seq+1), ack= 1, Host B is received after confirming the SEQ value and ack=1 The connection was established successfully.

To complete the three handshake, host A and Host B start transmitting data.

In the TCP/IP protocol, the TCP protocol provides a reliable connection service with a three-time handshake to establish a connection.
First handshake: When a connection is established, the client sends a SYN packet (SYN=J) to the server and enters the Syn_send state, waiting for the server to confirm;
Second handshake: The server receives the SYN packet, must confirm the customer's SYN (ACK=J+1), and also sends itself a SYN packet (syn=k), namely the Syn+ack packet, when the server enters the SYN_RECV state; the third handshake: the client receives the server's Syn+ack package, Send acknowledgment packet ack (ACK=K+1) to the server, the packet is sent, the client and server enter the established state, complete three handshake. Three handshake is completed and the client and server begin to transfer data.


IP > 3,626,544,836:3,626,544,836
IP > 1739326486:1739326486 ack 3626544837
IP > 1739326487,ack 1

First handshake: sends a bit code syn=1, randomly generates a SEQ number=3626544836 packet to, by syn= 1 know requirements to establish online;

Second handshake: to confirm the online information after receiving the request, send Ack number=3626544837,syn=1,ack=1 to, randomly generate seq=1739326486 packet;

Third handshake: received after checking ACK number is correct, that is, the first time the SEQ Number+1 sent, and the bit code ACK is 1, if correct, will send an ACK again number=1739326487 , Ack=1, received after confirmation seq=seq+1,ack=1 the connection was established successfully.

A three-time handshake process (Fig. 1, fig. 2)

(Fig. 1)

(Fig. 2)

The first handshake of the flag bit (Fig. 3)
We can see that there is only one sync bit inside the flag, which is the request (SYN)

(Fig. 3)

The second handshake's flag bit (Fig. 4)
We can see that there is a confirmation bit and a sync bit inside the flag, which is the answer (SYN + ACK).

(Fig. 4)

The sign of the third handshake (Figure 5)
We can see that there is only one confirmation bit inside the flag, that is, re-confirm (ACK).

(Fig. 5)

A full three-time handshake is the request---answer---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: 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.