Pcornel
Networking · Network & Protocols › TCP, UDP & Transport

TCP State Machine Reference

Cheat sheet · https://pcornel.dk/topic.php?topic=309

Back to the Topic

Answer

At each end a TCP connection is always in one state — LISTEN, SYN-SENT, SYN-RECEIVED, ESTABLISHED, FIN-WAIT, CLOSE-WAIT, LAST-ACK, TIME-WAIT — and the operating system shows it for every connection.

Remember

SYN-SENT on a client means SYNs go unanswered. SYN-RECEIVED on a server means the final ACK is not arriving. CLOSE-WAIT growing means the local application is not closing its sockets. Many in TIME-WAIT can exhaust a busy client's ports. States are local: the other end may have forgotten the connection.

First checks

  • ss -tan — every TCP socket with state and endpoints (netstat -an elsewhere).
  • ss -tan state close-wait — one state only.
  • ss -tan | awk 'NR>1 {print $1}' | sort | uniq -c — count per state.
  • show tcp brief all — on a Cisco device.

Commands

ss -tan
show tcp brief all

Verify in this order

LISTEN on the server → SYN-SENT / SYN-RECEIVED for a moment → ESTABLISHED → first closer: FIN-WAIT then TIME-WAIT; other side: CLOSE-WAIT then LAST-ACK → closed

Where it usually breaks

physical/link dependency → local object state → peer/control state → policy → forwarding/adjacency → end-to-end result

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=309

Confirmation

Confirm action

Continue?