Fundamentals 8 min read

When the Third TCP Handshake Fails: Timeout, SYN Flood & Backend Lessons

The article explains the TCP three‑way handshake, why the third ACK is essential, how servers react when it is missing, the role of timeout retransmission and RTO calculation, the impact of SYN‑Flood attacks, and how these concepts inspire backend design patterns.

dbaplus Community
dbaplus Community
dbaplus Community
When the Third TCP Handshake Fails: Timeout, SYN Flood & Backend Lessons

TCP Three‑Way Handshake Overview

Both client and server start in the CLOSED state. The server begins listening, moving to LISTEN. The handshake proceeds as follows:

First handshake: client sends SYN (SYN=1, seq=x) and enters SYN_SEND.

Second handshake: server replies with SYN‑ACK (SYN=1, ACK=1, seq=y, ACKnum=x+1) and enters SYN_RECEIVED.

Third handshake: client sends ACK (ACK=1, ACKnum=y+1), entering ESTABLISHED; the server also moves to ESTABLISHED, allowing data transfer.

Consequences of a Missing Third Handshake

If the server does not receive the client’s final ACK, the connection remains in an incomplete state and cannot be used for data transmission. The server stays in SYN_RECEIVED, waiting for the ACK.

During this waiting period the server relies on the timeout retransmission mechanism. If the ACK never arrives, the server will repeatedly resend the SYN‑ACK until a retry limit is reached, after which the connection is considered failed and the server returns to CLOSED, releasing resources.

Timeout Retransmission and RTO Calculation

TCP uses a retransmission timeout (RTO) based on measured round‑trip time (RTT). The RTO is typically set slightly larger than the RTT to balance premature retransmissions against long delays.

RTO is computed using the Jacobson/Karels algorithm:

SRTT = (1 - α) * SRTT + α * RTT
RTTVAR = (1 - β) * RTTVAR + β * |RTT - SRTT|
RTO = μ * SRTT + δ * RTTVAR  =  SRTT + 4 * RTTVAR

Typical parameters are α = 0.125, β = 0.25, μ = 1, δ = 4.

SYN Flood Attack and Half‑Open Queue

When the final ACK is missing, it may be due to packet loss or a malicious SYN Flood attack. In a SYN Flood, attackers forge many source IPs and send massive SYN packets. The server replies with SYN‑ACK, but the forged addresses never return ACKs, filling the half‑open (SYN) queue and preventing legitimate connections.

Backend Design Lessons from TCP Handshake

The handshake embodies two useful ideas for backend systems:

State Confirmation : Both sides verify readiness before proceeding, similar to health checks or mutual authentication in microservice communication.

Timeout and Retry : Servers retry pending operations with a bounded limit, mirroring retry policies for HTTP calls, message queues, or database connections.

Applying these patterns improves reliability and resilience in distributed architectures.

Illustrations

TCP handshake diagram
TCP handshake diagram
Analogy of handshake to a relationship
Analogy of handshake to a relationship
RTT and RTO illustration
RTT and RTO illustration
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

backend designTCPThree-way handshakenetwork fundamentalsSYN FloodTimeout Retransmission
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.