Protocol flows

TCP three-way handshake and teardown

A connection is opened with SYN, SYN-ACK and ACK, then closed with a four-way FIN and ACK exchange.

One TCP sessionClient and serverClient and serverSYN from clientTCP · 443Client192.0.2.10Client — 192.0.2.10Server203.0.113.20Server — 203.0.113.20
Legend

Current step

SYN — the client asks to connect

The client picks a random initial sequence number and sends SYN with no data.

Flags
SYN
Sequence
1000
State
Connection requested
Both ends agree on an initial sequence number before any data moves, which is what makes TCP reliable and ordered. Teardown costs four messages because each direction closes independently, and a firewall that only permits the handshake still has to allow the closing messages to expire the session cleanly.

Documentation example: addresses use the RFC 5737 ranges and ASNs use the reserved private range. Nothing here connects to a real network.

Tags

  • protocols
  • tcp
  • transport
  • handshake

Lessons using this diagram