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

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

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

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

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

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

TCP连接全双工

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次握手,如下图

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

4. 连接建立的超时,如下图(telnet x4100.unix-center.net)

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

5. 半关闭

例如: rsh xxx sort < 1

6. TCP的状态变迁图

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

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服务器的设计

使用源IP+port,以及目的端的IP+port来处理传入的多个请求。