`
Harold_xlp
  • 浏览: 154244 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

TCP Connection Termination

 
阅读更多

 

http://www.tcpipguide.com/free/t_TCPConnectionTermination-4.htm

 

 

TCP Connection Termination
(Page 4 of 4)

Simultaneous Connection Termination

Just as it is possible for the normal connection establishment process to be changed if two devices decide to actively OPEN a connection to each other, it is also possible for two devices to try to terminate a connection simultaneously. This term “simultaneously” doesn't mean that they both decide to shut down at exactly the same time—variances in network delays mean nothing can be simultaneous on an internetwork anyway. It simply means that, in the example above, the client decides to shut down and sends a FIN, but the server sends its own FIN before the client's FIN shows up at the server. In that case, a different procedure is followed, as described in Table 155 and Figure 215.

As you can see, the process is much more symmetric in this case, with both devices transitioning through the same states. In either case the end result is the same, with the connection in the CLOSED state—meaning no connection. Each TCP will make sure all outstanding data is sent to the application, sometimes referred to as an implied “push” (see the description of the “push” function for an explanation of this term). The transmission control blocks (TCBs) established for the connection in both devices are destroyed when the connection is closed down.


Table 155: TCP Simultaneous Connection Termination Procedure

Client

 

 

Server

 

 

Start State

Action

Transitions To State

Start State

Action

Transitions To State

ESTABLISHED

Client Close Step #1 Transmit: The application using TCP signals that the connection is no longer needed. The TCP on the client sends the next segment with the FIN bit set, indicating a request to close the connection.

FIN-WAIT-1

ESTABLISHED

Server Close Step #1 Transmit: Before the server can receive the FIN sent by the client, the application on the server also signals a close. The server also sends a FIN.

FIN-WAIT-1

FIN-WAIT-1

Server Close Step #1 Receive and Step #2 Transmit: The client has sent a FIN and is waiting for it to be acknowledged. Instead, it receives the FIN sent by the server. It acknowledges the server's close request with an ACK and continues to wait for its own ACK.

CLOSING

FIN-WAIT-1

Client Close Step #1 Receive and Step #2 Transmit: The server has sent a FIN and is waiting for it to be acknowledged. Instead, it receives the FIN sent by the client. It acknowledges the client's close request with an ACK and continues to wait for its own ACK.

CLOSING

CLOSING

Client Close Step #2 Receive: The client receives the ACK for its FIN.

TIME-WAIT

CLOSING

Server Close Step #2 Receive: The server receives the ACK for its FIN.

TIME-WAIT

TIME-WAIT

The client waits for a period of time equal to double the maximum segment life (MSL) time. This gives enough time to ensure the ACK it sent to the server was received.

TIME-WAIT

The server waits for a period of time equal to double the maximum segment life (MSL) time. This gives enough time to ensure the ACK it sent to the client was received.

TIME-WAIT

The timer expires after double the MSL time.

CLOSED

TIME-WAIT

The timer expires after double the MSL time.

CLOSED

CLOSED

The connection is closed.

CLOSED

The connection is closed.


 

Figure 215: TCP Simultaneous Connection Termination Procedure

Under certain circumstances both devices may decide to terminate a connection simultaneously, or nearly simultaneously. In this case each sends a FIN and before getting an ACK for it, receives the other device’s FIN. Each acknowledges the other’s FIN and waits for a period of time before closing the connection. Note the transition through the CLOSING state, which is only used as part of simultaneous termination.

 


Key Concept: Just as two devices can simultaneously open a TCP session, they can terminate it simultaneously as well. In this case a different state sequence is followed, with each device responding to the other’s FIN with an ACK, waiting for receipt of its own ACK, and pausing for a period of time to ensure that its ACK is received by the other device before ending the connection.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics