3-Way Handshake: The Foundation of TCP Communication

MD. NAJMUS SAKIB SK
3 min readDec 19, 2024

--

The 3-Way Handshake is a method used to establish a reliable connection between two devices in a network using TCP (Transmission Control Protocol). It works in three steps and ensures that data will be transferred accurately. Here’s a simple explanation:

How It Works:

1. Client Initiates (SYN):

First, the device that wants to start the connection (called the client) sends a SYN (synchronize) message to the server. This message tells the server, “I want to establish/create a connection with you.”

2. The Server Responds (SYN-ACK):

Next, the server replies with a SYN-ACK message. This message does two things:

· The server says, “Okay, I received your message.”

· The server also says, “I am ready to establish a connection with you too.”

3. The Client Confirms (ACK):

Finally, the client sends an ACK (acknowledge) message back to the server. This confirms, “I received your response, and now we can start exchanging data.”

A Simple Analogy:

It’s comparable to make a phone call:

· First, you dial someone’s number, and the phone rings (SYN).

· Then, the other person picks up and says, “Hello” (SYN-ACK).

· Finally, you respond with, “Hello, can you hear me?” (ACK).

· Once this exchange is complete, the conversation can start.

Why Is It Important?

· It ensures that both devices are ready for communication.

· It resets old or incorrect data and establishes a new sequence number for the current session.

· It creates a foundation for error-free and reliable data transfer.

Benefits:

· Ensures secure and stable communication.

· Detects if one device is unavailable or unreachable.

· It’s essential for maintaining the stability of TCP-based communication.

In short, the 3-Way Handshake is the first step in establishing a connection between two devices. It ensures mutual understanding and provides a strong foundation for transferring data effectively and reliably.

There are some potential security risks like “SYN Flood Attacks”. Now, some discussions about “SYN Flood Attacks” and its mitigations are mentioned below:

Security Risk: SYN Flood Attack

A SYN Flood attack is a type of Denial-of-Service (DoS) attack. It works by exploiting the initial step of the 3-Way Handshake process:

· The attacker sends a large number of SYN packets to the target server but does not respond to the server’s SYN-ACK packets.

· The server keeps these incomplete connections open in a backlog (a memory queue) while waiting for the final ACK.

· Since the ACK never arrives, the backlog fills up, preventing legitimate connections from being processed.

Mitigation Techniques for SYN Flood Attacks

SYN Cookies:

  • Instead of maintaining a backlog, the server encodes the connection information into the sequence number of the SYN-ACK packet.
  • When the client responds with an ACK, the server decodes the sequence number to reconstruct the connection.
  • This prevents the server from allocating resources until the handshake is complete.

Reducing SYN Timeout:

  • The server can reduce the time it waits for an ACK after sending a SYN-ACK.
  • This minimizes the period during which incomplete connections occupy resources.

Rate Limiting:

  • Servers can limit the number of SYN packets accepted per second from a single source or globally.
  • This reduces the risk of resource exhaustion caused by excessive requests.

Firewall and Intrusion Detection Systems (IDS):

  • Firewalls can detect and block traffic patterns indicative of SYN Flood attacks.
  • IDS tools monitor network activity and alert administrators of suspicious behavior.

Enhanced Network Hardware:

  • Modern routers and switches often have built-in mechanisms to identify and filter malicious SYN packets.

Conclusion

While the 3-Way Handshake is essential for establishing reliable TCP connections, it is not protected from security risks like “SYN Flood Attacks”. By implementing a combination of techniques such as SYN Cookies, firewalls, and rate limiting, organizations can mitigate these risks and ensure stable and secure communication.

--

--

No responses yet