Connection
Client
CLOSED
Server
LISTEN
Step Through
Sequence Diagram
Connection ready. Click "Full Handshake" or step through manually.
State Machine
Client States
Server States
How It Works
The TCP 3-way handshake establishes a reliable connection between client and server using three messages:
- SYN: Client initiates by sending a synchronize request
- SYN-ACK: Server acknowledges and sends its own synchronize
- ACK: Client acknowledges, both sides are now ESTABLISHED
The Petri net models this as two parallel state machines (client + server) connected through shared transitions. Each transition consumes tokens from one machine and produces tokens in the other, enforcing the protocol ordering.
Connection teardown follows a similar pattern: FIN, FIN-ACK, then both sides return to their initial state.