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

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

 

 

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

 

 

 

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

 

 

 

5. 半关闭

例如: rsh xxx sort < 1

 

6. TCP的状态变迁图

 

 

TCP/IP 详解 卷1 ch18 TCP Connection Establishment and Termination_第1张图片

 

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

 

另外一个很好的状态图,客户端和服务器端的状态区分的比较清楚,

http://en.wikipedia.org/wiki/File:Tcp_state_diagram_fixed.svg

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

7. 复位报文段

异常终止一个连接,到不存在的端口的连接请求等

 

8. TCP服务器的设计

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

你可能感兴趣的:(TCP/IP 详解 卷1 ch18 TCP Connection Establishment and Termination)