TCP 3-Way Handshake and How it Works

  • Under TCP, the IP layer and the MAC layer chooses the route.
  • Above TCP, the HTTP layer builds the request and response messages.
  • TCP converts the variable-length request into segments and makes sure all parts arrive in their original order. This is the role TCP plays.

TCP Header Format

  • 0 means the end of the options list.
  • 1 means that it is for aligning option fields on 32-bit boundaries for better performance. It doesn't do anything to the TCP connection.
  • 2 means the value is the Maximum Segment Size (MSS).
  • 3 is for communicating window scale.
  • 4 and 5 are for Selective Acknowledgement (SACK).

TCP 3-Way Handshakes

  • Sync initial sequence numbers (ISN)
  • Exchange parameters (e.g., window scale factor, Maximum Segment Size, Selective Acknowledgement algorithm)
  1. The client sends an SYN message
  2. The server replies with an SYN/ACK message
  3. The client responds with an ACK message
  • the server’s ISN, and
  • the ACK number

TCP State Transition during Handshake


  • TCP is responsible for guaranteed message delivery which other layers don’t care about.
  • A connection is required for the responsibility.
  • To establish a connection, TCP uses a 3-way handshake.
  • The Sequence Number, the ACK Number, and flags are the key to understand the handshake.
  • Each handshake changes the TCP connection state in both client and server ends.


Further readings




a coder 🧑🏻‍💻

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My 120-day journey to Unity a better game developer — Day 6

NextCloud Options for Non-Techies

How I Built My Own Keyboard

Tools to Keep Your Development Organized

🗣️When the #DeFi space faces a provocation in the form of millions of stride yield locked to be…

Java Garbage Collector

Commanding the command line interface

Memrise Vs Duolingo: Which One Is Better For You Language Learning Style

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


a coder 🧑🏻‍💻

More from Medium

Promise Theory and the Container Supply Chain Model

Publish WSO2 logs into JMS Queue through Log appender

How we leverage Elastic Reverse Search (Percolate) to power our coupons system

For the Love of Distributed Systems!