Home > Experiential Learning > Experiential Learning of Networking Technologies: Understanding TCP States – Part 2

Experiential Learning of Networking Technologies: Understanding TCP States – Part 2

7 Summary

In this paper we have explored the basic workings of the TCP state transition for the teardown phase. We have described these transitions for normal communication and have discussed scenarios that arise when specific network error conditions cause packet-loss during this phase. The timing and nature of packet loss has differing types of impact on the TCP connection state, and states that are normally transient (and difficult to observe) become long-lasting. Network applications that fail to handle such scenarios properly can lead to excessive resource utilization and may suffer from degraded performance. Thus, we hope that the insights into the TCP state transitions provided in this article will be valuable to web developers and devops teams to debug and fix such issues.

The ESTABLISHED state, which corresponds to the data transfer phase of TCP connection, is perhaps the simplest one to understand. In this state, whenever a data packet is received, an acknowledgement is sent back. However, in real life, all performance-related issues for general network communications correspond to this state. Any discussion on TCP communication always entails congestion control and flow control, and both these issues are dealt with in the ESTABLISHED state. These two error-control mechanisms are often (erroneously) perceived to be the same, because the TCP response to both these errors results in same action. In fact, the two error conditions are quite different. Similarly, TCP fairness (the issue of how to allocate bandwidth when a single physical link of limited bandwidth is shared among multiple TCP connections) also corresponds to this state. In our next article, we will discuss the ESTABLISHED state in detail, and aspects of TCP performance or throughput when the network has limited bandwidth or is witnessing packet-loss.

8 Appendix

Partial code for TCP client program to demonstrate FIN_WAIT1, CLOSE_WAIT and TIME_WAIT state. The complete program is accessible at [10].

srvr_addr = (ip_addr, port)  
sock = socket.socket(socket.AF_INET,  
for i in range(1,count):  
    #msg = chr(64 + i) * buffer + "\n"  
    msg = datetime.datetime.now().  
    print "Sending: " + msg,  
    sent = sock.send(msg)  

9 Experiential Exercises

All the example exercises discussed in this article make use of i) Linux built-in commands related to network utility nc for data transfer, ii) netstat for monitoring network connection state, and a simple python program (tcp_client.py) to enable timing the packet transmission and respective finer control. If at your Linux installation, the netstat utility is not installed, then same can be installed by using the command sudo aptget install nettools. Similarly, the netcat (nc) is available by default on all Linux and Apple Mac machines, and for Windows based systems, there are free open source versions available, which can be downloaded and installed. To develop a lasting understanding, it is suggested that reader should carry out all the experimental exercises. The reader should explore even the different sequencing of steps such as firewall rules, packet loss, etc. to help consolidate the understanding.PIC


Pages ( 5 of 5 ): « Previous1 ... 34 5

Leave a Comment:

Your email address will not be published. Required fields are marked *