← projects
TCP Handshake
How two machines open, use, and close a reliable connection. Watch the SYN / SYN-ACK / ACKthree-way handshake, optional data transfer, and the four-way teardown - with each endpoint's state machine and real sequence numbers updating in step.
ClientCLOSEDNo connection.
ServerLISTENWaiting for an incoming connection (passive open).
Client
Server
SYNseq=1000 · len=1
SYN ACKseq=5000 · ack=1001 · len=1
ACKseq=1001 · ack=5001
PSH ACKseq=1001 · ack=5001 · len=24
ACKseq=5001 · ack=1025
FIN ACKseq=1025 · ack=5001 · len=1
ACKseq=5001 · ack=1026
FIN ACKseq=5001 · ack=1026 · len=1
ACKseq=1026 · ack=5002
0 / 9 segments
SYNClient → ServerHandshake
seq=1000len=1Client picks a random ISN (1000) and sends SYN: "let's talk - my byte stream starts here." It moves to SYN_SENT.
HandshakeDataTeardownSYN & FIN each consume one sequence number - that's why acks land on
seq+1.