transport protocols · lesson 2 of 8 · sources checked 2026-11-20
tcp and ip: the handshake and what it leaks
This lesson shows the TCP handshake, the header values that a site reads from the first packets, and the party that owns each value.
status of this lesson: from a public sourcepurpose
The browser does not set the values of the first TCP packets. The operating system or the proxy exit sets them. Thus a site can compare these values with the client that the request claims to be.
objectives
- Describe the TCP three-way handshake and the round-trip time that it shows.
- Name the TCP and IP header values that a passive TCP fingerprint reads.
- Explain how a defender can use the TCP timestamps and the RTT as detection inputs.
- Identify the party that owns each TCP value when a proxy is in the path.
new terms
- round-trip time (RTT)
- The time for a packet to go from one host to another host and for the answer to come back.
- passive TCP fingerprint
- An OS class that an observer infers from TCP and IP header values without sending packets.
- fingerprint
- A set of values that a site collects from a client to identify or classify it.
- JA4
- A three-part TLS client fingerprint with a readable prefix and two hashes over sorted cipher and extension lists.
- exit node
- The device or host whose IP address the target sees.
how it works
the three-way handshake
The TCP handshake opens each TCP connection. RFC 9293 gives three messages RFC Editor, source 1:
- The client sends a
SYNwith its initial sequence number, for example 100. - The server sends a
SYN-ACKwith its own initial sequence number, for example 300. Its acknowledgment number is 101. - The client sends an
ACKwith the acknowledgment number 301. Then the two sides can send data.
Each exchange takes one round-trip time (RTT). The client measures one RTT from its SYN to the SYN-ACK. The server can measure one RTT from its SYN-ACK to the ACK. Thus the server gets an RTT sample before the first byte of TLS.
RFC 7323 adds the Timestamps option. One use of this option is to measure the RTT of almost all packets IETF, source 2.
what the first packet carries
The operating system builds the SYN. Its header values differ between systems, and an observer can read them with no packet of its own. This is a passive TCP fingerprint.
The README of the p0f tool states that p0f can often identify the system from one normal SYN, with no interference. Its signature reads these values p0f organization on GitHub, source 3:
- the IP version and the initial TTL;
- the maximum segment size (MSS) and the window size;
- the window scale and the order of the TCP options;
- quirks, for example the "don't fragment" flag or a non-zero IP ID.
A start value of the TTL is a setting of the system. For example, the Linux kernel documentation gives 64 as the default TTL of outgoing packets The Linux kernel documentation, source 4.
The JA4+ repository gives a TCP form of its fingerprint, with the example 64240_2-1-3-1-1-4_1460_8 for Windows 11 FoxIO, source 5. The JA4 name is the TLS form of the same family.
the timestamp clock
RFC 7323 states that the TSval field holds the current value of the timestamp clock of the sender. The clock has a rate between 1 ms and 1 s for each tick, and it must not go back. A sender can add a random offset for each connection IETF, source 2.
The Linux kernel has the setting tcp_timestamps. Its default value 1 turns on the timestamps with a random offset for each connection. The value 2 turns them on with no random offset The Linux kernel documentation, source 4.
A defender can examine a series of TSval values of one sender over time. The rate of the clock can then be a detection input. With a random offset, the start value alone does not link two connections.
the rtt gap
Through a CONNECT tunnel, the proxy exit terminates the TCP connection of the site.
But the TLS handshake goes through the tunnel to the client. Thus the site can measure two values:
- the TCP RTT, from the site to the exit;
- the RTT of the TLS handshake, from the site to the client, through the exit.
example The TCP RTT is 20 ms, and the RTT of the TLS handshake is 180 ms. The difference of 160 ms is the leg from the exit to the client. A direct connection gives two values that are almost equal.
In my model, a large gap is a proxy signal. An RTT that is too large for the location of the IP address is a second signal.
the party that owns each value
Behind a proxy, the TCP values and the TCP RTT come from the exit node. The client machine does not set them, and a browser setting cannot change them.
Thus the passive TCP fingerprint names the system of the exit, not the system of the client. For example, a request can claim a Windows browser and arrive with the TCP values of a Linux exit. A site can compare the two values.
the two sides
| automation side | detection side |
|---|---|
| Behind a proxy, the TCP fingerprint and the RTT come from the exit node, not from the client machine. A client cannot change them with browser settings. | A passive TCP fingerprint names an OS class. A mismatch with the claimed OS, or an RTT that is too large for the IP location, is a proxy signal. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Read the passive TCP fingerprint alone | It costs no packet and it is ready at the SYN. | It names the system of the last hop, which can be a proxy or a network that a group of users share. | As one input among other inputs |
| Compare the TCP fingerprint with the claimed OS | A mismatch is a clear proxy signal. | A group of users can share one network address. A mismatch then has a cause that is not automation. | When the claimed OS comes from the request |
| Compare the TCP RTT with the TLS RTT | It shows the leg after the exit. | A slow client network also gives a gap. | When the site terminates TCP and TLS at the same place |
| Use the timestamp clock | It can add a value that stays for one sender. | A random offset for each connection hides the start value. | Only with a long series of packets of one connection |
diagram
the tcp handshake and the tls 1.3 handshake on one time axis, with one rtt for each exchange
failure modes
| problem | cause | correction |
|---|---|---|
| The passive TCP fingerprint shows a Linux system, and the client runs on Windows. | The proxy exit opens the TCP connection. | Read the TCP layer as a value of the proxy, not of the client. |
| The TCP RTT is small, and the site is far from the client. | The site measures the RTT to the exit, not to the client. | Compare the TCP RTT with the RTT of the TLS handshake. |
| Two connections of one sender show unrelated TSval values. | The system adds a random offset for each connection. | Compare the values only inside one connection. |
| The RTT gap is large for a direct user. | The network of the user is slow, for example a mobile network. | Use the gap only as one input, with the IP location and other signals. |
check questions
Describe the three messages of the TCP handshake, and the RTT sample that the server gets from it.
sample answer
The client sends a SYN with its initial sequence number. The server sends a SYN-ACK with its own initial sequence number. The client sends an ACK. The server can measure one RTT from its SYN-ACK to the ACK, before the first byte of TLS.
Name four header values that a passive TCP fingerprint reads from the first packet.
sample answer
The initial TTL, the maximum segment size (MSS), the window size, and the order of the TCP options. The window scale and the quirks are also inputs.
Explain how a site can use two RTT values to find a proxy in the path.
sample answer
The site measures the TCP RTT, which ends at the proxy exit. It also measures the RTT of the TLS handshake, which goes through the tunnel to the client. A large difference between the two values is the leg from the exit to the client, and it is a proxy signal.
A request goes through a CONNECT tunnel. Which party sets the TCP window size that the site reads?
- The proxy exit
- The browser of the client
- The operating system of the client machine
answer
a. The proxy exit
The proxy exit opens the TCP connection to the site. Thus the TCP values come from the exit, and a browser setting cannot change them.
exercise
exercise Do this task on paper, with the synthetic values of the table. Do not send a request to a site.
| connection | claimed os | tcp fingerprint class | tcp rtt | tls handshake rtt |
|---|---|---|---|---|
| A | Windows | Windows | 30 ms | 32 ms |
| B | Windows | Linux | 15 ms | 140 ms |
| C | macOS | macOS | 12 ms | 95 ms |
- For each connection, compare the claimed OS with the TCP fingerprint class.
- For each connection, subtract the TCP RTT from the TLS handshake RTT.
- Write the connections that show a proxy signal.
- Write the party that owns the TCP values of connection B.
sample answer
The answer uses the synthetic values of the table.
Connection A has the same OS in both columns, and a gap of 2 ms. It shows no proxy signal. Connection B has a mismatch of the OS and a gap of 125 ms, thus it shows two proxy signals. Connection C has the same OS, but a gap of 83 ms. It shows one proxy signal, the RTT gap. The proxy exit owns the TCP values of connection B, not the client.
sources
- RFC 9293: Transmission Control Protocol, RFC Editor, standard, read 2026-11-20
- RFC 7323: TCP Extensions for High Performance (timestamps), IETF, standard, read 2026-11-20
- p0f v3 README, p0f organization on GitHub, documentation, read 2026-11-20
- IP Sysctl, The Linux kernel documentation, documentation, read 2026-11-20
- JA4+ repository and licence section, FoxIO, source code, read 2026-11-20
- My model of the RTT gap and of the party that owns each TCP value, 2026-11 (not public).