TCP三次握手

TCP通过三次握手建立连接。三次握手过程如下:

1. 客户端向服务器发送SYN消息,该消息中有一个随机选择的序列号A

2. 服务器返回一个SYN-ACK消息,该消息中有一个确认号码,其值为A+1,此外,该消息中有一个随机序列号B

3. 客户端象服务器发送ACK,该消息中有一个确认号码,其值为B+1,该消息中还会有一个序列号A+1。

这样三次握手结束,连接建立。

 

SYN-ACK以SYN中的序号+1为确认号码,ACK以SYN-ACK中的序号+1为确认号码,ACK的序号为SYN序号+1,这是因为这两条消息都是客户端发送的。

 

To establish a connection, TCP uses a three-way handshake.

1.      The active open is performed by the client sending a SYN to the server. It sets the segment's sequence number to a random value A.

2.      In response, the server replies with a SYN-ACK. The acknowledgment number is set to one more than the received sequence number (A + 1), and the sequence number that the server chooses for the packet is another random number, B.

3.      Finally, the client sends an ACK back to the server. The sequence number is set to the received acknowledgement value i.e. A + 1, and the acknowledgement number is set to one more than the received sequence number i.e. B + 1.

At this point, both the client and server have received an acknowledgment of the connection.

 

你可能感兴趣的:(tcp,server,服务器,Random)