transport protocols · lesson 1 of 8 · sources checked 2026-11-20
the connection stack and who sees what
This lesson shows the layers of one HTTPS request, the party that terminates each layer, and the party that can read each field.
status of this lesson: from a public sourcepurpose
A site can make a decision about a request before it sends any HTML. The reason is that each protocol layer of a connection gives its fields to a different party. To read a signal correctly, you must know which party made it and which party can see it.
objectives
- Name the protocol layers of one HTTPS request, in order.
- Identify the party that terminates each layer, with a proxy and with no proxy.
- State which network values page JavaScript can read and which only the server can read.
- Explain why the TLS endpoint can decide before the page loads.
new terms
- TCP handshake
- The exchange of SYN, SYN-ACK, and ACK packets that opens a TCP connection.
- TLS handshake
- The exchange of messages that agrees on keys and parameters before encrypted data flows.
- terminates (a protocol layer)
- Is the endpoint that completes the handshake of a layer and reads its content, for example a TLS endpoint.
- edge network
- A set of servers in front of the origin that end the client connections, cache content, and can run bot checks.
- origin
- The server that holds the real content of a site, behind any edge network.
- CONNECT tunnel
- A proxy mode in which the proxy opens a TCP connection for the client and then relays bytes without a change.
- remote DNS
- Name resolution that the proxy exit does, not the client.
- ClientHello
- The first TLS message from the client, which lists its versions, cipher suites, and extensions in cleartext.
- SNI
- Server Name Indication: the TLS extension that names the target host.
- ECH
- Encrypted Client Hello: a TLS extension that encrypts the inner ClientHello, including SNI.
- network waterfall
- The sequence of timed phases of one request: DNS, TCP, TLS, time to first byte, and response.
- ALPN
- Application-Layer Protocol Negotiation: the TLS extension that selects the application protocol. On a TCP connection it selects HTTP/1.1 or HTTP/2. In the QUIC handshake it confirms HTTP/3.
how it works
One HTTPS request goes through four protocol layers. Each layer starts after the layer before it is ready:
| layer | what it does | what opens it |
|---|---|---|
| DNS | Changes the host name into an IP address | A query to a resolver |
| TCP and IP | Carries bytes between two IP addresses | The TCP handshake |
| TLS | Agrees on keys, and then encrypts the bytes | The TLS handshake |
| HTTP | Carries the request and the response | The first request inside TLS |
the party that terminates a layer
A party terminates a layer when it completes the handshake of that layer and reads its content. Each layer can have a different endpoint.
For example, a site can put an edge network in front of its origin. The edge completes the TCP handshake and the TLS handshake with the client. The origin then gets a second connection, from the edge. Thus the origin cannot read the TCP and TLS values of the client. It reads only what the edge forwards.
a proxy in the path
A client can send its traffic through a CONNECT tunnel. RFC 9110 states that the proxy opens a tunnel to the destination server. Then the proxy forwards the data in both directions with no change, and the client can secure the tunnel with TLS RFC Editor, source 1.
Thus the layers split between two parties:
- The proxy exit opens the TCP connection to the site. The site sees the IP address and the TCP values of the exit.
- The client keeps the TLS layer and the HTTP layer. The site sees the ClientHello and the HTTP request of the client.
- With remote DNS, the exit also resolves the host name. Then the DNS query of the client does not leave the client.
For example, one connection can carry the IP address of the exit and the TLS values of the client. A site can compare the two parts. The proxied connection: which layers move (not yet published) examines the proxied connection.
what goes in cleartext
The ClientHello is the first message of TLS. RFC 9846 states that a client must send it as its first TLS message. It also states that all handshake messages after the ServerHello are encrypted RFC Editor, source 2.
Thus each party on the network path can read the ClientHello. Its SNI field names the host, for example the name of a shop. ECH changes this. RFC 9849 encrypts the ClientHello under a public key of the server, and it protects the SNI RFC Editor, source 3.
what page javascript can read
In my model, each network signal is one of two kinds:
- Client-measurable: a value that a script in the page can read. Examples are the selected protocol and the phase times of the network waterfall.
- Server-measurable: a value that only the server side can read. Examples are the ClientHello fields, the TCP and IP header values, and the IP address.
A page reads the selected protocol from nextHopProtocol. MDN states that the value is the ALPN protocol ID, for example h2. Through a tunnel, it gives the protocol inside the tunnel. For a cross-origin resource with no Timing-Allow-Origin header, it is an empty string MDN, source 4.
Thus a page script cannot read the ClientHello of its own connection. It also cannot read the IP address that the site sees.
the tls endpoint decides first
The TLS endpoint reads the IP address, the TCP values, the ClientHello, and the HTTP/2 preface before it sends any HTML. Thus it can refuse a request before a page script runs. For example, an edge can send an error page in place of the page. HTTP/1.1, HTTP/2, and HTTP/3 on the wire examines the HTTP/2 preface and its SETTINGS frame.
the two sides
| automation side | detection side |
|---|---|
| The client controls its DNS queries, its TLS stack, and its HTTP library. It does not control what the server reads from them. Page JavaScript cannot read the transport fields of its own connection. | A TLS endpoint (edge or origin) reads the ClientHello, the HTTP/2 preface, the IP address, and the ASN before any HTML returns. The edge decides first. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Measure in page script | It is easy to add to a page, and it sees the phase times. | It cannot see the ClientHello, the TCP values, or the IP address. | For values that the browser gives to the page |
| Measure at the TLS endpoint | It sees each server-measurable value of the client. | Each value must come from that endpoint, not from the origin. | For transport signals |
| Measure at the origin behind an edge | The origin has the full context of the request. | It sees only what the edge forwards. | For HTTP signals that the edge forwards |
| Put a lab echo behind a TCP passthrough balancer | The echo terminates TLS and reads the real ClientHello. | The balancer cannot read or change the request. | For a lab page that reports the TLS values of a client |
diagram
the layers of one https request and the party that terminates each layer through a connect tunnel
- DNSThe client resolves the name. With remote DNS, the proxy exit resolves it.
- TCP and IPThe proxy exit opens the connection to the site. The edge terminates it.
- TLSThe client builds the ClientHello. The edge or the origin terminates TLS.
- HTTPThe client sends the request inside TLS. The TLS endpoint reads it first.
The site sees the TCP values of the exit and the TLS and HTTP values of the client.no result
A matrix of seven network values against three parties: page script, network path, and TLS endpoint. Page script reads only the selected protocol and the phase times.
| value | page script | network path | tls endpoint |
|---|---|---|---|
| Selected protocol (nextHopProtocol) | yes | no | yes |
| Phase times of the waterfall | yes | no | server times only |
| ClientHello fields | no | yes | yes |
| SNI | no | yes, if no ECH | yes |
| TCP and IP header values | no | yes | yes |
| Source IP address and ASN | no | yes | yes |
| HTTP request and headers | no | no | yes |
code example
The example reads a synthetic timing entry of one resource, as a page script gets it. It prints the selected protocol and the phase times. Then it shows that the entry holds no server-measurable value.
example The entry and its values are synthetic. No part describes a real site.
Read the protocol and the phases of a synthetic timing entry. Show the values that page JavaScript cannot see.
// Synthetic model of one resource timing entry, as page JavaScript gets it.
// No browser and no network: the values are invented, in milliseconds.
type TimingEntry = {
name: string;
nextHopProtocol: string;
domainLookupStart: number;
domainLookupEnd: number;
connectStart: number;
secureConnectionStart: number;
connectEnd: number;
requestStart: number;
responseStart: number;
responseEnd: number;
};
// The argument is the protocol string of the synthetic entry.
const protocol = process.argv[2] ?? "h2";
const entry: TimingEntry = {
name: "page-1",
nextHopProtocol: protocol,
domainLookupStart: 10.0,
domainLookupEnd: 24.5,
connectStart: 24.5,
secureConnectionStart: 61.2,
connectEnd: 102.8,
requestStart: 103.1,
responseStart: 188.4,
responseEnd: 214.9,
};
const phases: [string, number][] = [
["dns", entry.domainLookupEnd - entry.domainLookupStart],
["tcp", entry.secureConnectionStart - entry.connectStart],
["tls", entry.connectEnd - entry.secureConnectionStart],
["ttfb", entry.responseStart - entry.requestStart],
["response", entry.responseEnd - entry.responseStart],
];
console.log(`entry: ${entry.name}`);
console.log(`nextHopProtocol: ${entry.nextHopProtocol || "(empty)"}`);
for (const [phase, ms] of phases) {
console.log(`phase ${phase.padEnd(8)} ${ms.toFixed(1)} ms`);
}
// Values that the entry does not hold. Only the server side reads them.
const serverOnly = ["ClientHello fields", "TCP options and TTL", "source IP and ASN"];
const keys = Object.keys(entry);
for (const field of serverOnly) {
const inEntry = keys.some((k) => k.toLowerCase().includes(field.split(" ")[0].toLowerCase()));
console.log(`page reads ${field}: ${inEntry ? "yes" : "no"}`);
}output
The protocol, five phase times in milliseconds, and three lines for the server-measurable values.
entry: page-1
nextHopProtocol: h2
phase dns 14.5 ms
phase tcp 36.7 ms
phase tls 41.6 ms
phase ttfb 85.3 ms
phase response 26.5 ms
page reads ClientHello fields: no
page reads TCP options and TTL: no
page reads source IP and ASN: noI ran the code with the Node runtime and the flag --experimental-strip-types, with the argument h2. The phase lines show the client side of the waterfall. The last three lines show that the entry has no field for a server-measurable value.
failure modes
| problem | cause | correction |
|---|---|---|
| A lab echo page reports a ClientHello that is not the one of the client. | A balancer in front of the echo terminates TLS, and the echo reads the ClientHello of the balancer. | Make the echo the TLS endpoint, behind a TCP passthrough balancer. |
| Under a proxy, the TCP values show a different OS from the client. | The proxy exit opens the TCP connection, thus the TCP layer belongs to the exit. | Read the TCP layer as a value of the proxy, not of the client. |
nextHopProtocol is an empty string. | The resource is cross-origin and has no Timing-Allow-Origin header. | Read the value only for a same-origin resource, or for a resource with that header. |
| The origin logs show the TLS values of the edge. | The edge terminates TLS, and the origin gets a second connection. | Read the transport values at the edge, or from what the edge forwards. |
check questions
Name the four protocol layers of one HTTPS request, in order.
sample answer
DNS, then TCP and IP, then TLS, then HTTP. Each layer starts after the layer before it is ready.
A client sends its request through a CONNECT tunnel. Which party opens the TCP connection that the site sees?
- The client
- The proxy exit
- The origin behind the edge
answer
b. The proxy exit
The proxy opens the tunnel to the destination server and then forwards the bytes. Thus the site sees the TCP values and the IP address of the exit. The client keeps the TLS and HTTP layers.
Which value can a page script read about its own connection?
- The cipher suites of the ClientHello
- The TCP options of the first packet
- The IP address that the site sees
- The selected protocol, for example h2
answer
d. The selected protocol, for example h2
A page reads the selected protocol from nextHopProtocol. The ClientHello, the TCP values, and the IP address are server-measurable values.
Explain why the TLS endpoint can refuse a request before a page script runs.
sample answer
The TLS endpoint reads the IP address, the TCP values, the ClientHello, and the HTTP/2 preface before it sends any HTML. Thus it can refuse the request before the page loads, and no page script runs.
exercise
exercise Do this task in your own lab, with synthetic data only. Do not send a request to a site.
- Save the code example in an empty folder of your lab.
- Run the code with Node, the flag
--experimental-strip-types, and the argumenthttp/1.1. - Run the code again with an empty argument
"". - Record the protocol line of each run.
- Write the cause of the empty value in a real page.
- Write the party that can read the ClientHello of this request.
sample answer
The answer uses the synthetic entry of the code example.
The first run prints http/1.1, and the second run prints (empty). The phase lines do not change. In a real page, an empty value can come from a cross-origin resource with no Timing-Allow-Origin header. Only the network path and the TLS endpoint can read the ClientHello. The page script cannot read it.
sources
- RFC 9110: HTTP Semantics, CONNECT in section 9.3.6, RFC Editor, standard, read 2026-11-20
- RFC 9846: TLS 1.3, RFC Editor, standard, read 2026-11-20
- RFC 9849: TLS Encrypted Client Hello, RFC Editor, standard, read 2026-11-20
- PerformanceResourceTiming: nextHopProtocol property, MDN, documentation, read 2026-11-20
- My model of the layers of one HTTPS request and of the party that terminates each layer, 2026-11 (not public).
- My model of the split of network signals into client-measurable and server-measurable values, 2026-11 (not public).