TCP Three-Way Handshake

CSC-263 · Semester IV · Computer Networks

TCP Handshake Simulator

Step through SYN → SYN-ACK → ACK, data transfer and the close sequence

Client state

CLOSED

Server state

LISTEN

SYNseq=0 ack=0

Client sends SYN — 'can we talk? I start at seq 0'

Client → CLOSED to SYN_SENT

SYN-ACKseq=0 ack=1

Server replies SYN-ACK — 'yes, my seq is 0, expecting 1'

Server → LISTEN to SYN_RCVD

ACKseq=1 ack=1

Client ACKs — 'got it, sending 1'

Both → ESTABLISHED

PSHseq=1 ack=1

Client sends data (PSH) — 68 bytes of payload

payload consumed on server

ACK-Sseq=1 ack=69

Server ACKs data — 'received 68 bytes, next 69'

window slides forward

FINseq=69 ack=1

Client sends FIN — 'I have no more data'

Client → FIN_WAIT_1

FIN-Sseq=1 ack=70

Server replies ACK + FIN — 'acknowledged, closing too'

Server → CLOSE_WAIT then LAST_ACK

CLOSEseq=70 ack=2

Client sends final ACK — connection closed

both → CLOSED