The TCP 3-Way Handshake : What It Is & Why It's Important

·

3 min read

TCP : Transmission Control Protocol → As the name suggests protocols meaning set of rules, it is a set of rules for data transmission on the internet. TCP works on 3-way handshake process. 3-way handshake is a crucial process of creating a reliable communication channel. TCP ensures both devices agree on connection parametersbefore data exchange takes place.

What is the TCP 3-Way Handshake?

  • 3-way handshake is the process used to initiate a connection between a client and a server in a TCP/IP network.

  • Emphasize its role in ensuring reliable communication by establishing synchronisation and acknoledgement between devices.


Steps of the TCP 3-Way Hanshake

  1. SYNC (Synchronise)

    → The client sends a SYNC packet to the server to request a connection.

    → This packet contains the client’s Initial Sequence Number (ISN), which helps track data packets.

  2. SYNC-ACK (Synchronise + Acknowledge)

    → The server responds with a SYNC-ACK packet.

    → This packet acknowledges the client’s SYNC request and includes the server’s own ISN.

  3. ACK (Acknowledge)

    → The client sends an ACK packet back to the server, confirming receipt of the SYNC-ACK.

    → At this point, the connection is established, and data transfer can begin.

Why is the 3-Way Handshake Important?

  1. Reliability :

    → Ensures both parties are ready to communicate before data exchange.

    → Avoid data loss by synchronising sequence numbers.

  2. Security :

    → Prevents unauthorizes devices from initiating connections, as responses are expected.

    → Enables systems to identify and handle connection requests properly.

  3. Error Detection :

    →By acknowledging each step, devices can detect errors or dropped packets early.

Real World Example

Let’s use the process of opening a webpage as an example

  1. Client sends Sync

    → You open a browser (e.g., Chrome) and type “google.com” in the address bar.

    → Your browser sends a Sync packet to the web server hosting “google.com”.

    → This packet includes the client Initial Sequence Number (ISN) to synchronise communication.

    Example in action :

    The client say’s, “Hi, I would like to connect and my sequence number is (12345). Are you ready?”

  2. Server responds with Sync + Ack

    → The server receives the Sync request and responds witha Sync + Ack packet.

    → The Sync + Ack packet contains the server’s own ISN and acknowledges the client’s sequence number.

    Example in action :

    The server replies, “Hello, I recieved your request and sequence number is (67890). I am ready to connect”.

  3. Client sends Ack packet

    → The client receives the Sync + Ack packet from the server and sends an Ack packet back.

    → This acknowledges the server’s sequence number and confirms the connection.

    Example in action :

    The client responds, “Great, I received your sequence number. Let’s start communicating.