Skip to content
Computing Rich #tcp#state-machine#protocols

TCP State Machine

CLOSED to ESTABLISHED to TIME_WAIT and back. The full TCP lifecycle as a state diagram.

A free, animated tcp state machine you can read here or embed on any website, from Scrollchart.

TCP State Machine

TCP State Machine(2 x MSL ~ 4 min)

All eleven TCP states with transitions labeled by the segment sent or received that triggers them. Active and passive open paths color-coded; the four-way close path traced separately. TIME_WAIT duration (2*MSL) annotated with a clock icon. Half-close, simultaneous close, and RST shortcuts shown.

Good for

  • Networking course material
  • SRE post-mortems on connection-state issues
  • Protocol-implementation tutorials

Source & accuracy

This tcp state machine is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

The lifecycle from closed to established

A TCP connection begins in CLOSED. The client sends a SYN packet and enters SYN-SENT, waiting for the server's response. The server, listening in LISTEN, receives the SYN, sends SYN/ACK, and enters SYN-RECEIVED. The client receives SYN/ACK, sends ACK, and enters ESTABLISHED. The server receives ACK and also enters ESTABLISHED. Both sides can now exchange data. This three-way handshake (SYN, SYN/ACK, ACK) ensures both sides are ready and exchange initial sequence numbers.

Closing and the four-way goodbye

When the client wants to close, it sends FIN and enters FIN-WAIT-1. The server receives FIN, sends ACK, and enters CLOSE-WAIT (the client still might be receiving data). The client receives ACK and enters FIN-WAIT-2. The server sends its own FIN (when done sending data) and enters LAST-ACK. The client receives FIN, sends ACK, and enters TIME-WAIT. The server receives ACK and enters CLOSED. TIME-WAIT delays (typically 2 minutes) prevent old packets from a previous connection with the same IP:port pair from confusing the next connection.

Special states and edge cases

CLOSE-WAIT means the server finished receiving but has not sent its FIN yet. Connections stuck in CLOSE-WAIT indicate the application is not closing the socket. TIME-WAIT connections are closed but kept in the state machine to guard against delayed packets. On high-traffic servers, accumulating TIME-WAIT connections can exhaust the port space. RST (reset) skips the graceful close and immediately moves to CLOSED, used for abrupt terminations or error conditions.

Embed this diagram

Add this animated tcp state machine to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated tcp state machine for any website.
Who uses it
Developer blogs, DevOps / SRE sites, CS educators.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="tcp-state-machine" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "TCP State Machine" for my website?
Scrollchart provides "TCP State Machine" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a tcp state machine in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.