TCP113 handshake--4 Wave and---11 states

Source: Internet
Author: User
Tags ack

1th. TCP Three-time handshake

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8C/08/wKioL1hf9ePjPqvVAAE2ezblbeE595.png-wh_500x0-wm_3 -wmp_4-s_3368509781.png "style=" Float:none; "title=" TCP three-time handshake png.png "alt=" wkiol1hf9epjpqvvaae2ezblbee595.png-wh_50 "/>

Process

First handshake: When a connection is established, the client sends a SYN packet (SYN=J) to the server and enters the syn_sent state, waiting for the server to confirm; SYN: Synchronous sequence Number (Synchronizesequence Numbers).


Second handshake: The server receives the SYN packet, it must confirm the customer's SYN (ACK=J+1), and also send itself a SYN packet (syn=k), that is, the Syn+ack packet, when the server enters the SYN_RECV state;


Third handshake: The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, and the packet is sent, the client and the server enter the established (TCP connection succeeded) State and complete the three handshake.

Complete three handshake, the client and server start to transfer data!

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8C/0B/wKiom1hf9eSQPEgEAAFHAE3MyJs193.png-wh_500x0-wm_3 -wmp_4-s_1975253060.png "style=" Float:none; "title=" TCP four times Wave png.png "alt=" wkiom1hf9esqpegeaafhae3myjs193.png-wh_50 "/>

(1) Client A sends a fin to turn off customer A to Server B data Transfer (message segment 4).


(2) Server B receives this fin, which sends back an ACK, confirming that the serial number is received plus 1 (message Segment 5). As with Syn, a fin will occupy a sequence number.


(3) Server B closes the connection to client A and sends a fin to client a (message segment 6).


(4) Client A sends back ACK message confirmation, and sets the confirmation serial number to receive serial number plus 1 (message segment 7)


TCP uses four waves to close the connection why is the connection agreement a three-time handshake, while closing the connection is a four-time handshake?


Because the socket in the listen state of the server has received a request for the connection of the SYN message, it can send the ACK and SYN (ACK response, and SYN synchronously) in a message. However, when the connection is closed, when receiving the other's fin message notification, it simply means that no data is sent to you, but not all of your data are sent to the other side, so you may not immediately close the socket, that is, you may also need to send some data to the other side, Send the FIN message to the other side to show that you agree that you can now close the connection, so it's the ACK message and fin message are sent separately in most cases

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/8C/08/wKioL1hf9eWz_gziAAJIXNOe2Yw575.png-wh_500x0-wm_3 -wmp_4-s_133819441.png "style=" Float:none, "title=" Tcp11 State png.png "alt=" wkiol1hf9ewz_gziaajixnoe2yw575.png-wh_50 "/>

11 different states:


1, the Client Exclusive: (1) syn_sent (2) fin_wait1 (3) fin_wait2 (4) CLOSING (5) time_wait.


2, the service side unique: (1) LISTEN (2) SYN_RCVD (3) close_wait (4) Last_ack.


3, the total: (1) CLOSED (2) established.


This article is from the "Linux Technology" blog, so be sure to keep this source http://7544928.blog.51cto.com/7534928/1886071

TCP113 handshake--4 Wave and---11 states

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.