Three handshake to TCP/IP and four waves

Source: Internet
Author: User

TCP ((transmission Control Protocol) transmission protocol, is a connection-oriented protocol. The connection will be established (three handshake) before the data transfer is made using this protocol, and when the data transfer is complete, both sides of the connection will notify the other party to release the connection (four waves).

    • Recognize the TCP flag bit

      The TCP flag bit is marked with 6 types:

      SYN (synchronous set up online)

      ACK (Acknowledgement confirmation)

      PSH (push transfer)

      FIN (end of finish)

      RST (Reset reset)

      URG (Urgent emergency)

    • Diagram of TCP and UDP three handshake and four wave waving process

Three-time handshake process:

First handshake: Host1 sends a TCP flag bit syn=1, ack=0 packets to host2, and randomly generates a sequence number=3233. When the host2 receives this data, host2 by syn= 1 know that the client wants to establish a connection;

Second handshake: Host2 to confirm the client's online request, send an answer number to host1 ACk=1,SYN=1,

Confirmation number acknowledge number=3234, this value is host1 serial number plus 1, also produces a random serial number sequence number=36457, so that the host1 can be connected;

Third handshake: Host1 after receiving the data, check if acknowledge number is the value of 3233+1, and if the value of ACK is 1, if 1,host1 will send ack=1, confirm numbers acknowledge number= 36457, tell Host2 that your request connection is confirmed, the connection can be established.

Four wave-waving process:

First wave: When the transmitted data arrives at the tail, Host1 sends the fin=1 flag bit to the host2, can be understood, host1 to Host2 said, my side of the data transfer is complete, I am ready to disconnect the connection;

Second wave: Because TCP connection is full duplex two-way connection, closing is also to be closed from both sides, when Host2 received host1 sent fin=1 flag bit, HOST2 will not immediately send Host1 request to find=1 to close the message, Instead, we send a ack=1 response to Host1, which says: "You requested to close the request I have received, but I may still have the data not complete the transmission, you wait, wait until I complete the data transfer I will tell you;"

Third wave: Host2 data transfer is complete, send fin=1to Host1, Host1 received a request to close the connection request, host1 understand that the HOST2 data has been transferred, can now be disconnected,

Fourth wave: Host1 received find=1 , host1 or fear because of the network instability reasons, afraid host2 don't know he want to disconnect, so host2 send ack=1 confirmation information to confirm, set himself Time_wait State and start the timer, if the HOST2 does not receive the ACK,HOST2-side TCP timer arrives, will ask Host1 to resend the ACK, when Host2 received an ACK, HOST2 disconnected When Host1 waits for 2MLS (twice times the maximum message lifetime), he knows that Host2 has received an ACK after receiving the HOST2 's retransmission request, so host1 closes his connection at this time. I think this is a very ingenious design!

The status of the host1 end of the process is as follows:

The process experienced by Host2 is as follows:

Three handshake to TCP/IP and four waves

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.