Other TCP Communication states
As we have noted earlier, Phase 2 begins when the 3-way connection setup is completed successfully (i.e., the connection state maintained by both the client and the server is ESTABLISHED). When the application at one of the end points decides that no further data needs to be sent, it initiates the teardown phase (Phase 3) by sending a FIN message. The application at the other end point may decide that it has further data to send even after it receives this FIN message, and in this case it will continue to transmit data from the CLOSE_WAIT state. (It will enter teardown phase only after it has completed the data transfer). This situation is commonly known as TCP half-close, because one side has initiated the close as it is not sending any more data, but other side continues to send data. As a typical example, consider the situation where a client application sends a URL corresponding to a large file (e.g., a 10 MB image) to the server. After transmitting this URL data, the client application may initiate connection closure. However, the server will start the connection closure only after the entire image has been transmitted. Due to complex behavioral requirements such as this, a TCP connection must go through several intermediate states before it finally reaches the CLOSED state.
The successful transfer of data (the string hello) is shown in Figure 9 (server-side) and Figure 10 (client-side). The first command (issued at 00:25:34 PST) is shown in the upper panel of Figure 9, and runs a server application listening on port 5555. (The output of the date command is printed, and the string hello is printed later as explained below.) The second command (issued at 00:25:39 PST) is shown in the lower panel of Figure 9, and shows that the server is indeed listening on port 5555. The third command (issued at 13:55:54 IST) shown in the upper panel of Figure 10, initiates the TCP connection, and the fourth (issued at 00:26:01 PST) and fifth (issued at 13:56:11 IST) commands, respectively in the lower panel of Figure 9 and the lower panel of Figure 10, show that the connection is successfully established at both end points. Next, the user types the string
hello in the nc program on the client side, shown in the upper panel of Figure 10. This string is received by the nc program on the server side, shown in the upper panel of Figure 9. Finally, the user initiates connection closure by typing
Ctrl-C on the client side2 . The last command (issued at 00:26:32 PST) shown in the lower panel of Figure 9 shows that the TCP connection is closed on the server-side (i.e., there is no output by netstat). We now focus on the last command in the lower panel of Figure 10 (issued at 13:56:26 IST), which shows that the TCP connection state on the client-side is TIME_WAIT.
Figure 9: TCP States on server side
Figure 10: TCP States for Client
2The string hello and the
Ctrl-C command could also have been given in the nc program on the server-side.