TCP three handshake and four wave process analysis

Source: Internet
Author: User
Keywords Handshake 8.1.1 confirm server
Tags analysis client code control data host ip online

TCP (Transmission Control Kyoto) Transmission Control Protocol

Three times shaking hands.

TCP is the host to the host Layer Transmission Control Protocol, providing reliable connection services, with three handshake confirmation to establish a connection:

Bit code is the TCP flag bit, there are 6 kinds of indicators: SYN (Synchronous online) ACK (acknowledgement confirmed) PSH (push transfer) FIN (finish) RST (reset) URG (Urgent emergency)

Sequence Number (ordinal number) acknowledge (confirmation)

The first handshake: host a send bit code for syn=1, randomly generated SEQ number=1234567 packets to the server, Host B by Syn=1 know, a required to establish online; second handshake: Host B receives the request to confirm the online information and sends an ACK number= to a ( Host a seq+1), syn=1,ack=1, randomly generated seq=7654321 package third handshake: Host a received after checking the ACK number is correct, that is, the first time sent Seq number+1, and bit-code ACK is 1, if correct, Host A will again send ACK number= (Host B seq+1), ack=1, Host B received confirmation of the SEQ value and Ack=1 connection was established successfully. Completes three handshake, host A and Host B begin to transmit data.


In the TCP/IP protocol, the TCP protocol provides a reliable connection service, and a three-time handshake is used to establish a connection.

First handshake: When the connection is established, the client sends the SYN packet (SYN=J) to the server, and enters the Syn_send state, waits for the server to confirm; the second handshake: the server receives the SYN packet, must confirm the client's SYN (ACK=J+1), and sends a SYN packet (syn= k), that is, the Syn+ack packet, at this time the server into the SYN_RECV state; the third handshake: the client receives the server's Syn+ack packet, sends the confirmation packet ack (ACK=K+1) to the server, the packet sends the complete, the client and the server enters the established state, Three times to finish shaking hands. Completes three handshake, the client and the server begin to transmit the data.

Instance:

IP 192.168.1.116.3337 > 192.168.1.123.7788:s 3,626,544,836:3,626,544,836

IP 192.168.1.123.7788 > 192.168.1.116.3337:s 1739326486:1739326486 ack 3626544837

IP 192.168.1.116.3337 > 192.168.1.123.7788:ack 1739326487,ack 1

First handshake: 192.168.1.116 send bit code syn=1, randomly generated SEQ number=3626544836 packets to 192.168.1.123,192.168.1.123 by syn= 1 know 192.168.1.116 requirements to establish online; Second handshake: 192.168.1.123 received the request to confirm the online information, send an ACK to the 192.168.1.116 number=3626544837,syn=1,ack=1, randomly generated seq=1739326486 package; Third handshake: 192.168.1.116 received check ACK number is correct, that is, the first time sent Seq number+1, and bit code ACK is 1, if correct, 192.168.1.116 will send Ack number=1739326487 , ack=1,192.168.1.123 confirmation Seq=seq+1,ack=1 the connection was successful.

four times waving.

When host a completes the data transfer, the control bit fin is placed 1, the request Host B that stops the TCP connection receives the fin and responds to it, confirming that the TCP connection to the side will shut down, and the ACK 1 will be put forward by the B-end to the opposite direction of the shutdown request, and the fin will be 1 host A to confirm the request of Host B, The ACK is set to 1, and the double direction closure ends.

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.