TCP/IP 详解 卷1 ch18 TCP Connection Establishment and Termination

1. 建立一个连接,3次握手,如下图(telnet



1) 客户端发送一个SYN报文,指明服务器端口,初始序号(ISN)

2) 服务器发回包含服务器的初始序号的SYN报文作为应答。同时将确认序号设置为客户的ISN+1以对客户端的SYN报文进行确认

3) 客户端必须将确认序号设置为服务器的ISN+1以对服务器的SYN报文进行确认




2. The side that sends the first SYN is said to perform an active open. The other side, which receives this SYN and sends the next SYN, performs a passive open.


3. 终止一个连接,4次握手,如下图




4. 连接建立的超时,如下图(telnet




5. 半关闭

例如: rsh xxx sort < 1


6. TCP的状态变迁图




1) the normal client transitions with a darker solid arrow, and the normal server transitions with a darker dashed arrow

2) the two transitions leading to the ESTABLISHED state correspond to opening a connection, and the two transitions
leading from the ESTABLISHED state are for the termination of a connection. The ESTABLISHED state is where data transfer can occur between the two ends in both directions

3) 2MSL (Maximum Segment Lifetime) - TIME_WAIT



状态转换箭头的文字描述了 收到消息/发送消息。

7. 复位报文段



8. TCP服务器的设计