TCP握手协议

在TCP/IP协议中,TCP协议提供可靠的连接服务,采用三次握手建立一个连接。

第一次握手:建立连接时,客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状态,等待服务器确认;

第二次握手:服务器收到syn包,必须确认客户的SYN(ack=j+1),同时自己也发送一个SYN包(syn=k),即SYN+ACK包,此时服务器进入SYN_RECV状态;

第三次握手:客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1),此包发送完毕,客户端和服务器进入ESTABLISHED状态,完成三次握手。

完成三次握手,客户端与服务器开始传送数据,在上述过程中,还有一些重要的概念:

未连接队列:在三次握手协议中,服务器维护一个未连接队列,该队列为每个客户端的SYN包(syn=j)开设一个条目,该条目表明服务器已收到SYN包,并向客户发出确认,正在等待客户的确认包。这些条目所标识的连接在服务器处于Syn_RECV状态,当服务器收到客户的确认包时,删除该条目,服务器进入 ESTABLISHED状态。
Backlog参数:表示未连接队列的最大容纳数目。

SYN-ACK 重传次数服务器发送完SYN-ACK包,如果未收到客户确认包,服务器进行首次重传,等待一段时间仍未收到客户确认包,进行第二次重传,如果重传次数超过系统规定的最大重传次数,系统将该连接信息从半连接队列中删除。注意,每次重传等待的时间不一定相同。

半连接存活时间:是指半连接队列的条目存活的最长时间,也即服务从收到SYN包到确认这个报文无效的最长时间,该时间值是所有重传请求包的最长等待时间总和。有时我们也称半连接存活时间为Timeout时间、SYN_RECV存活时间。

TCP handshake agreement

In TCP / IP protocol in, TCP protocol to provide reliable connectivity, using three shook hands with the establishment of a connection.

The first handshake: establish a connection, the client sent syn packets (syn = j) to the server and access SYN_SEND state, waiting for the server to confirm;

Second handshake: Server received syn package, customers must confirm the SYN (ack = j +1), while himself a SYN packet sent (syn = k), that is, SYN + ACK packet, then enter the server SYN_RECV state;

Third handshake: client server received the SYN + ACK packet, send confirmation to the server package ACK (ack = k +1), this package sent completed, the client and server into the ESTABLISHED state, complete the three shook hands.

Complete the three shook hands with the client and server start sending data, in the process, there are some important concepts:

Not connected cohort: the three shook hands with the agreement, maintaining a server is not connected queue, as the team each client SYN packet (syn = j) creation of an entry, the entry server that has received SYN packet, and customers identified , Is awaiting confirmation, the package. These entries by the logo of Syn_RECV connected to the server in the state, when the client server received the confirmation package, delete the entry into the server ESTABLISHED state.
Backlog parameters: that is not connected to accommodate the largest number of the queue.

SYN-ACK re-sent the number of servers End SYN-ACK packets, if customers have not received confirmation package, the first re-server, waiting for customers for a period of time has not yet received confirmation package, the second-Chuan, if re - More than the number of requirements for re-largest number of systems to connect information from the semi-connected in the queue to delete. Note that each re-waiting time does not necessarily the same.

Semi-connected survival time: connect queue is half the entry of the most prolonged survival, or services received from the SYN packet to confirm that the text was invalid, the longest period, the time value of all repeat request of the longest wait for the package The total time. Sometimes we also said that the survival time for the semi-connected Timeout time, SYN_RECV survival time. 


====

http://blog.c114.net/html/03/144903-43224.html

你可能感兴趣的:(TCP握手协议)