8 min read

When a Connection Won't Open: Reading the TCP Three-Way Handshake in a Capture

A client that cannot reach your service is usually a layer-3 or layer-4 problem, not an application bug. Reading the TCP three-way handshake in a capture is the fastest way to find out. Open a saved pcap, switch to the sequence diagram in the flow detail, follow SYN, SYN-ACK and ACK to see which step stalls, then drop back to the raw packet to check the TCP flags.

When a Connection Won't Open: Reading the TCP Three-Way Handshake in a Capture
SummaryKey Points
  • Scenario first: when a connection will not open, confirm the three-way handshake at the transport layer before touching application logs
  • Three-step triage: SYN out, SYN-ACK back, ACK completes — the step that stalls points at the class of fault
  • How-to: open the TCP flow, switch to the sequence-diagram tab, click an arrow to jump to its packet — all offline
  • Visual cues: retransmissions are dashed; RST, out-of-order, duplicate ACK and zero window show in orange

Connection Refused? Start at the Bottom Layer

A new service goes live, and the client cannot reach it. Sometimes you get connection refused; sometimes the connection simply hangs until it times out. Most people reach for application logs, re-check config files, restart the process — and only after a long detour discover that nothing was listening on the port, or a firewall dropped the packets halfway.

These failures share one trait: the connection never came up, so the application never got a chance to say a word. That makes a bottom-up check the fastest route. Confirm at the transport layer whether the TCP three-way handshake completed. If it did, the problem is upstream; if it did not, the problem is in the network or on the server itself.

Two boundaries are worth drawing up front. The handshake is a transport-layer event — it is not TLS negotiation (that is covered in "How to Analyze a TLS 1.3 Handshake"), and it is not packet-loss analysis (see "Diagnosing Packet Loss"). This article is about one thing only: the three packets that establish a TCP connection, and where they stop.

Everything below works on a pcap that is already open and parsed. No live capture is involved.

What the Three-Way Handshake Actually Negotiates

TCP is connection-oriented, so the two ends agree on a few things before any data flows. Read it as three packets:

Packet 1 — SYN. The client initiates. It sets the SYN flag and carries an initial sequence number (ISN), effectively saying, "I want to connect; my sequence numbers start here." The client moves to SYN_SENT.

Packet 2 — SYN-ACK. If the server is willing, it replies with both SYN and ACK set. The ACK acknowledges the client's SYN (acknowledgement number = client ISN + 1), and it carries the server's own ISN. "Got it, I'm ready too; my sequence numbers start here."

Packet 3 — ACK. The client sends one more packet with only ACK set, acknowledging number = server ISN + 1. Only now have both sides confirmed each other's ability to send and receive; the connection is ESTABLISHED and application data can begin.

Here is the detail that matters for troubleshooting: the connection is not fully open until that third ACK reaches the server. The first two steps are just "I called you" and "you answered"; the third closes the loop. Many real failures are exactly a connection stuck in that half-open state.

The same diagram also shows FIN (the normal four-way teardown) and RST (an abrupt reset). Those are the connection's "end" signals, and reading them alongside the handshake "start" signals reconstructs the whole lifecycle.

How-to: Open the Flow, Switch to the Sequence Diagram

PcapDecoder draws those three packets as a sequence diagram that is much quicker to read than scrolling a packet list. Work in three steps:

Step 1 — Open the pcap and find the TCP flow. Once parsing finishes, go to the conversation (flow) list and locate the connection by its two endpoints and ports — say, client 10.0.0.5:52344 to server 10.0.0.9:443. The list groups both directions of a flow together; picking the wrong one shows someone else's handshake.

Step 2 — Open that flow and switch to the "Sequence Diagram" tab. The flow detail offers several views side by side: A→B, B→A, a timing view, the sequence diagram, a TCP stream map, and file carving. Choose the sequence diagram.

Step 3 — Read it. It follows the Wireshark Flow Graph style: two vertical lanes represent the two endpoints, and each packet is a horizontal arrow from sender to receiver with its TCP flags (SYN, SYN,ACK, ACK, and later FIN, RST) labelled above. Time runs top to bottom, so the handshake is always at the very top. The builder caps a diagram at the first 400 packets of the flow by default, but since the handshake is necessarily at the start, you will never miss those opening three.

Scan the first three arrows left to right: is there a SYN? Is the packet after it a SYN-ACK? Is there a client ACK after that? The break is obvious once you look.

Three Shapes of a Stalled Handshake

Match what you see against three common patterns, each pointing at a different cause.

Shape 1 — SYN with no SYN-ACK. The client calls; the server never answers. Typical causes: nothing listening on the port (process down, or bound to the wrong address), a server-side firewall dropping packets, no route, or the host being offline. The client will usually retransmit the SYN a few times before timing out. Investigate why the server is silent — do not suspect the client.

Shape 2 — SYN and SYN-ACK, but no final ACK. The server answered, but the client never sent that last ACK (or it was lost on the way). The server's connection sits in SYN_RECV — half-open — and never completes. Causes include a misbehaving client, a middlebox blocking the packet, or an unstable link. It is worth noting that SYN-flood attacks exploit exactly this half-open state, so a cluster of connections stuck at step two is itself a signal.

Shape 3 — SYN-ACK followed by RST. The server tore the connection down. One common case is that the port really is closed — some systems answer a SYN to a closed port with an RST rather than dropping it silently, and the RST flag is how you tell this from Shape 1. Another is deliberate rejection by the server (load, policy). An RST basically means the server explicitly said no.

One easy misread: all three steps complete, yet the application still reports an error. That means the problem is not at this layer — the connection is ESTABLISHED, so move on to TLS negotiation, authentication, and the application protocol. That is the value of working in layers: each step rules out one tier of suspects.

Dashed Lines and Orange Flags: Scanning for Anomalies

When the traffic is heavy, reading every flag one by one is slow. The sequence diagram offers two cues you can take in at a glance.

Retransmissions are drawn as dashed arrows. When the anomaly detector flags a packet as a retransmission (or a fast retransmission), its arrow is drawn dashed. A run of dashed SYNs at the start of a handshake is unambiguous: a SYN or SYN-ACK was lost in transit and the client keeps resending. Look toward packet loss and link quality, not server configuration.

Anomalous packets are coloured orange. Packets flagged as RST, out-of-order, duplicate ACK, or zero window render in orange. An orange RST right at the start of a handshake is strong evidence of a refused connection; an orange zero-window packet means one side's buffer is full and it cannot keep up — though zero window is more common during data transfer than during setup.

These cues come from heuristic detection, not from a final verdict. Treat a dashed line or an orange marker as "investigate this one," then verify in the raw packet (next section). You keep the speed of a visual scan without the risk of acting on a misclassification.

From Diagram to Packet: Verify the Flags

The diagram's arrows are a compressed view; the authoritative detail lives in the raw packet. Click an arrow in the sequence diagram and it selects the corresponding original packet, opening its full contents in the detail pane on the right.

That pane has two parts: a protocol hierarchy tree on top, unwrapping Ethernet, IP, and TCP layer by layer, and a hex dump below showing the raw bytes. Expand the Transmission Control Protocol layer to read the flags field — the actual values of SYN, ACK, FIN and RST — along with sequence number, acknowledgement number and window size. That is where the flags labelled on the diagram come from, so it is the final word on which step you are looking at.

Two small conveniences help. Clicking a field in the tree highlights the matching byte range in the hex dump, making it easy to line up a field with its raw bytes; and the view can switch between tree and table form, with the table being tidier when a layer has many fields.

Work through this sequence and three questions are settled: did the connection open, which of SYN / SYN-ACK / ACK was the sticking point, and was the cause a refusal or a loss. Carry that conclusion into your check of the server process, firewall rules, or link quality, and you no longer have to search in the dark.


Related reading: "How to Analyze a TLS 1.3 Handshake" covers cryptographic negotiation and "Diagnosing Packet Loss" covers transport loss; this article stays with the three transport-layer setup packets.

TCP HandshakePacket AnalysisSequence DiagramSYNTroubleshooting
Share
Back to home