TCP Connection Termination

Published by Keyboard Banger on

Let’s suppose both client and server are in the Established state.

    • Although the TCP connection termination can be initiated by either the client or the server, let’s assume here that the application process on the client side informs TCP that it no longer needs the connection. Client’s TCP protocol sends a FIN segment and enters the FIN-WAIT-1 state. At this point the local application no longer sends data, but it still can receive data.
    • server’s TCP receives the FIN segment and informs the application process to terminate the connection. Server sends back an ACK and enters the CLOSE-WAIT state. When the client receives the ACK, it enters the FIN-WAIT-2 state.
    • the application process at the server side finishes what it was doing and signals TCP that it is ready to close the connection. TCP sends a FIN segment to the client and enters the LAST-ACK state
    • client receives the FIN segment from the server, sends ACK, enters TIME-WAIT state and starts a timer that equals two times the value of the Maximum Segment Life (MSL) time. This timer ensures that the server receives its ACK
    • server receives the ACK and enters the CLOSED state
    • client timer expires and enters the CLOSED state

The following diagram describes the TCP connection termination sequence:


TCP connection termination – copyright The TCP/IP Guide

The TCP connection termination process can also be described in a Finite State Machine (see this post for more information on Finite State Machines)?

TCP allows also for “Simultaneous close”, where both parties of the communication initiate a TCP connection close request.


Figure: TCP Simultaneous Close – copyright


The TCP/IP Guide: A Comprehensive, Illustrated Internet Protocol Reference

Categories: Networking Basics

Keyboard Banger

Keyboard Banger is a network engineer from Africa. He has been working in network support and administration since 2008. He started writing study notes about certification exams and technology topics a couple of years ago. When he's not writing articles, he can be found wandering on technical forums.


Leave a Reply

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