接上一篇文章 TCP建立连接的过程。
TCP建立连接需要三次握手是我们都知道的,那么为什么要是三次握手,而不是一次、两次或者四次、五次、六次呢?
为什么是三次握手
根据 RFC793 ,三次握手的目的是为了防止旧的连接请求造成混乱。
The principle reason for the three-way handshake is to prevent old
duplicate connection initiations from causing confusion.
-
首先,我们假设只有一次握手。这显然是不行的,因为客户端A发出的连接请求后,可能服务器B根本没有收到,而此时A却把状态置为established并要准备发送报文了。
-
假设有两次握手。首先客户端A向服务器发连接请求报文,服务器B收到后返回相应,此时,