PKI and SSL/TLS describe what happens when you open an HTTPS page as a numbered list. I wanted to see
the list happen. So I captured one request to GitHub, all 32 packets of it, and followed it down through every layer
and back up again.The layers, before the packets#
A network connection is built in layers: each one does a single job and hands the rest to the layer below. There are two well-known ways to draw them.
- The TCP/IP model is what the internet actually runs. RFC 1122, the 1989 rulebook for internet hosts, names four layers: application, transport, internet and link (RFC 1122, section 1.1.3).
- The OSI model is the teaching model, with seven layers, from physical up to application. It is defined in ITU-T X.200, the same text as ISO/IEC 7498-1, and the ITU gives it away free (X.200).
| OSI layer (X.200) | TCP/IP layer (RFC 1122) | What it is in my capture |
|---|---|---|
| 7 Application, 6 Presentation, 5 Session | Application | DNS; HTTP/2, carried inside TLS |
| 4 Transport | Transport | UDP to port 53 for DNS, TCP to port 443 for HTTPS |
| 3 Network | Internet | IPv4: my machine to 140.82.113.4 |
| 2 Data link | Link | Ethernet frames on WSL’s virtual network card |
| 1 Physical | Link | the wire or radio; invisible to a capture tool |
Where does TLS go? In the TCP/IP model it is part of the application layer. High Performance Browser Networking says SSL, TLS’s predecessor, “was implemented at the application layer, directly on top of TCP” (HPBN, chapter 4), and the TLS 1.3 standard says “higher-level protocols can layer on top of TLS transparently” (RFC 9846, section 1). So the application layer has two parts here: TLS at the bottom, sitting on TCP, and HTTP/2 riding inside it, unaware that it is encrypted.
OSI is older: X.200 is from 1994, and TLS 1.0 (RFC 2246) only arrived in January 1999, so it has no box named for it. But X.200 does list “agreement on security aspects (e.g. authentication, access control, data integrity)” among the facilities of the Application Layer (X.200, section 7.1.3.2), which is the same answer. In my diagram TLS gets its own row, drawn inside the application layer, because it has packets of its own in the capture.
How I captured it#
From Linux under WSL, not Windows, because on Windows the antivirus on my machine answers every HTTPS connection itself. Two terminals:
# terminal 1: record DNS and HTTPS on both interfaces for 12 seconds
sudo tshark -f "port 53 or tcp port 443" -i lo -i eth0 -w req.pcapng -a duration:12
# terminal 2: one request, with curl writing its TLS session keys to a file
SSLKEYLOGFILE=keys.log curl -sI https://github.com/Why those two interfaces? First I asked tshark what it can listen on. tshark -D lists every interface it can
capture from, with a number you can pass to -i instead of the name
(tshark manual). The first three lines on my WSL machine:
1. eth0
2. any
3. lo (Loopback)eth0is WSL’s virtual network card, the way out to the internet. The TCP, TLS and HTTP/2 packets to GitHub cross it.lo, the loopback, is traffic a machine sends to itself. WSL’s DNS resolver has its address onlo(I checked thenameserverline in/etc/resolv.confagainstip addr), so the DNS packets only appear there. That’s the surprise in step 1.anywould capture every interface at once. I named the two I wanted instead, so each packet shows which one it crossed.
Leaving out -i would have lost the DNS: tshark then picks “the first non-loopback interface”, which here is
eth0. Every argument in the two commands:
| Argument | What it does | Why I used it |
|---|---|---|
sudo | runs tshark as root | capturing live packets needs root on Linux |
-i lo -i eth0 | the interfaces to capture on, by name or by the number tshark -D prints; repeat -i for more than one | DNS is on lo, GitHub traffic on eth0 |
-f "port 53 or tcp port 443" | a capture filter: packets that don’t match are never recorded (syntax, examples) | port 53 is DNS (UDP or TCP), tcp port 443 is HTTPS; everything else my machine was doing stays out. It comes before the -i options, so it applies to both |
-w req.pcapng | writes the raw packets to a file instead of printing them | so I could read the capture again and again, with and without the keys |
-a duration:12 | autostop: stop writing “after value seconds have elapsed” | 12 seconds is enough to start curl in the other terminal |
SSLKEYLOGFILE=keys.log | an environment variable for curl alone: write the TLS session secrets to this file | to decrypt packets 9 onwards later |
curl -s | silent: no progress meter | clean output |
curl -I | headers only, no page body; on the wire it is a HEAD request, as step 4 shows | fewer packets, and the post is about the exchange, not the HTML |
-r req.pcapng | reads packets from a file instead of a live interface | the reading step, after the capture |
-o tls.keylog_file:keys.log | sets a preference for this run only; here, where the TLS key log is | turns the encrypted records into readable HTTP/2 |
The capture filter (-f) is in “libpcap filter syntax”, as tshark -h puts it, and is applied while capturing, so
filtered-out packets are never written. The full language is in the
pcap-filter manual page: port 53 is true “if the source or
the destination TCP/UDP/SCTP port” is 53, which is why it catches DNS over both UDP and TCP. The Wireshark User’s
Guide has a short overview, and
the CaptureFilters page of the Wireshark wiki is a list of ready-made
ones, starting with “Capture only DNS (port 53) traffic: port 53”. Wireshark’s display filters (-Y) are a different language that only hides
packets when reading; I didn’t need one here. The manual I quote is the current one; I checked each flag above
in tshark -h and curl --help all on the versions I ran.
SSLKEYLOGFILE is how the encrypted part becomes readable later. curl, like Firefox and Chrome, writes “the
encryption secrets” to that file so that Wireshark “can decrypt them”
(everything curl). Anyone holding that file can read
the whole session, so I deleted it afterwards and it’s not in this post. To read the capture with it:
tshark -r req.pcapng -o tls.keylog_file:keys.logThis was curl 7.76.1 with OpenSSL 3.5.9 and tshark 3.4.10, on 5 December 2026. In the output below I replaced my
machine’s private address with my-machine.
All 32 packets#
# time direction proto bytes info
1 0.000 me → resolver (lo) DNS 70 Standard query 0x6a35 A github.com
2 0.000 me → resolver (lo) DNS 70 Standard query 0xb733 AAAA github.com
3 0.020 resolver → me (lo) DNS 154 Standard query response 0xb733 AAAA github.com SOA ns-1707.awsdns-21.co.uk
4 0.031 resolver → me (lo) DNS 86 Standard query response 0x6a35 A github.com A 140.82.113.4
5 0.031 me → GitHub TCP 74 33678 → 443 [SYN] Seq=0 Win=64480 MSS=1240 SACK_PERM=1 WS=128
6 0.064 GitHub → me TCP 74 443 → 33678 [SYN, ACK] Seq=0 Ack=1 Win=65535 MSS=1436 SACK_PERM=1 WS=1024
7 0.064 me → GitHub TCP 66 33678 → 443 [ACK] Seq=1 Ack=1 Win=64512
8 0.072 me → GitHub TLSv1 583 Client Hello
9 0.102 GitHub → me TLSv1.3 2522 Server Hello, Change Cipher Spec, Encrypted Extensions
10 0.102 GitHub → me TLSv1.3 712 Certificate, Certificate Verify, Finished
11 0.102 me → GitHub TCP 66 33678 → 443 [ACK] Seq=518 Ack=2457 Win=69504
12 0.102 me → GitHub TCP 66 33678 → 443 [ACK] Seq=518 Ack=3103 Win=71936
13 0.105 me → GitHub TLSv1.3 130 Change Cipher Spec, Finished
14 0.105 me → GitHub HTTP2 161 SETTINGS[0]
15 0.105 me → GitHub HTTP2 164 HEADERS[1]: HEAD /
16 0.128 GitHub → me TCP 66 443 → 33678 [ACK] Seq=3103 Ack=582 Win=67584
17 0.128 GitHub → me TLSv1.3 224 New Session Ticket, New Session Ticket
18 0.128 GitHub → me HTTP2 130 SETTINGS[0], SETTINGS[0]
19 0.128 me → GitHub TCP 66 33678 → 443 [ACK] Seq=775 Ack=3325 Win=74368
20 0.128 me → GitHub HTTP2 97 SETTINGS[0]
21 0.131 GitHub → me TCP 4978 [TCP segment of a reassembled PDU]
22 0.131 GitHub → me HTTP2 845 HEADERS[1]: 200 OK
23 0.131 me → GitHub TCP 66 33678 → 443 [ACK] Seq=806 Ack=9016 Win=70912
24 0.132 me → GitHub TLSv1.3 90 Alert (Level: Warning, Description: Close Notify)
25 0.132 me → GitHub TCP 66 33678 → 443 [FIN, ACK] Seq=830 Ack=9016 Win=74368
26 0.167 GitHub → me TCP 78 [TCP Dup ACK 17#1] 443 → 33678 [ACK] Seq=9016 Ack=775 Win=67584
27 0.167 GitHub → me TCP 78 443 → 33678 [ACK] Seq=9016 Ack=806 Win=67584
28 0.167 GitHub → me TCP 66 443 → 33678 [ACK] Seq=9016 Ack=831 Win=67584
29 0.167 GitHub → me TLSv1.3 90 Alert (Level: Warning, Description: Close Notify)
30 0.167 GitHub → me TCP 66 443 → 33678 [FIN, ACK] Seq=9040 Ack=831 Win=67584
31 0.167 me → GitHub TCP 54 33678 → 443 [RST] Seq=831 Win=0
32 0.167 me → GitHub TCP 54 33678 → 443 [RST] Seq=831 Win=0I removed the TCP timestamp fields from the info column; everything else is as tshark printed it. The rest of this post walks through them, step by step.
Step 1: find the server (DNS), packets 1 to 4#
Before anything else, curl needs an address for github.com. It asks twice at once: an A record for an IPv4
address and an AAAA record, which “stores a single IPv6 address”
(RFC 3596). GitHub has no IPv6 address, so the AAAA answer (packet 3) holds
only an SOA record, the zone’s administrative entry. The A answer (packet 4) is 140.82.113.4, 31 ms later.
Layers: DNS is an application protocol. It travels over UDP to port 53, which the DNS standard has allowed since 1987 alongside TCP (RFC 1035, section 4.2).
The surprise: my first capture had no DNS packets at all. The resolver in WSL is 10.255.255.254, an address on
the loopback interface. WSL’s DNS tunnelling “uses a virtualization feature to answer DNS requests from within WSL,
instead of requesting them over a networking packet”
(Microsoft Learn). So the lookup never touches the virtual
network card. I had to capture on lo as well to see it.
Step 2: open a connection (TCP), packets 5 to 7#
Now curl knows where to go, and TCP opens a connection with the three-way handshake, “the procedure used to establish a connection” (RFC 9293, section 3.5):
- SYN (packet 5): my machine picks a starting sequence number and asks to connect to port 443.
- SYN, ACK (packet 6): GitHub picks its own and acknowledges mine.
- ACK (packet 7): I acknowledge theirs. The connection is open.
tshark shows Seq=0 because it counts from zero; the real one, 1011181488 below, is random, “for security reasons”, as
High Performance Browser Networking explains. Packets 5 to 6 also give the
round-trip time: 33 ms from my machine to GitHub and back. Every later step costs at least one of those.
This is a good place to see all the layers at once. Here is packet 5, the SYN, as tshark decoded it, shortened, with my addresses replaced:
Ethernet II, Src: <my-machine's MAC>, Dst: <the virtual switch's MAC>
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: my-machine, Dst: 140.82.113.4
Time to Live: 64
Protocol: TCP (6)
Transmission Control Protocol, Src Port: 33678, Dst Port: 443, Seq: 0, Len: 0
Sequence Number (raw): 1011181488
[...]
Flags: 0x002 (SYN)
Window: 64480
TCP Option - Maximum segment size: 1240 bytes
TCP Option - Window scale: 7 (multiply by 128)Read it from the top, and each header says which layer comes next:
- Link (Ethernet): from my network card to the next hop.
Type: IPv4says what’s inside. Both addresses have a Microsoft vendor prefix, because WSL runs in a Hyper-V virtual machine with a virtual network card. - Internet (IPv4): from my machine to GitHub’s address, across every network in between.
Protocol: TCP (6)says what’s inside. - Transport (TCP): from port 33678 on my machine to port 443 on GitHub’s, plus the connection’s settings. The MSS (maximum segment size) of 1,240 bytes comes from this virtual network’s MTU of 1,280 bytes, minus 40 bytes of IPv4 and TCP headers.
There is no application data yet: Len: 0. A SYN is all headers.
Step 3: agree on keys and check identity (TLS), packets 8 to 13#
With TCP open, TLS starts on top of it. This is the step my Handshake post shows in detail, so here only what’s different:
- The ClientHello is 583 bytes, not the 1,491 I saw with
openssl s_client. curl offered only classic key exchanges, with an X25519 key share. Same OpenSSL 3.5, different defaults: this system’s crypto policy listsX25519:secp256r1:X448:...and no ML-KEM, and curl follows it. So this connection is not post-quantum, and nothing on screen says so. - It offered ALPN
h2,http/1.1: “the string h2 identifies the protocol where HTTP/2 uses Transport Layer Security”, and this is how the client asks for it during the TLS handshake (RFC 9113, section 3.1). GitHub choseh2. - Packets 9 and 10 have names only because I have the keys. Without the key log they are encrypted records. With it, tshark can open them and see Encrypted Extensions, Certificate, Certificate Verify and Finished.
The certificate chain, inside packet 10#
This is the part my PKI post describes, travelling inside the encrypted handshake. Decrypted, packet 10 carries three certificates:
| # | Subject | Issued by | Valid | Signature |
|---|---|---|---|---|
| 1 | github.com | Sectigo Public Server Authentication CA DV E36 | 30 Oct 2026 to 27 Jan 2027 | ECDSA with SHA-256 |
| 2 | Sectigo Public Server Authentication CA DV E36 | Sectigo Public Server Authentication Root E46 | 2021 to 2036 | ECDSA with SHA-384 |
| 3 | Sectigo Public Server Authentication Root E46 | USERTrust ECC Certification Authority | until 2038 | ECDSA with SHA-384 |
Each certificate is signed by the next one up. The top of the chain, the root my machine already trusts, is not sent:
my machine has its own copy. curl walked this chain and reported ssl_verify_result 0, meaning it checked out. Then
packet 10’s Certificate Verify proved that GitHub holds the private key for certificate 1, and Finished sealed
the handshake. My side’s Finished is packet 13. From here on everything is symmetric: the suite was TLS_AES_128_GCM_SHA256, so AES-128-GCM with keys both sides
derived, as the update to my SSL/TLS post explains.
This checking happens on my machine. The wire only carries the certificates; trusting them is my machine’s decision, which is exactly what the antivirus story was about.
Step 4: ask and answer (HTTP/2), packets 14 to 23#
Now the actual request, inside TLS. HTTP/2 begins with a fixed connection preface (RFC 9113, section 3.4): it’s in packet 14, although tshark’s summary line shows only the SETTINGS frame after it. Then both sides exchange SETTINGS. Then packet 15 carries the request, decrypted:
:method: HEAD
:path: /
:scheme: https
:authority: github.com
user-agent: curl/7.76.1
accept: */*The names starting with : are pseudo-headers, which HTTP/2 uses “to convey message control data”
(RFC 9113, section 8.3). HEAD asks for the headers of the
page without the page itself, which is what curl -I does.
The answer arrives in packets 21 and 22, 26 ms later. A selection of its headers:
:status: 200
content-type: text/html; charset=utf-8
strict-transport-security: max-age=31536000; includeSubdomains; preload
server: github.com
set-cookie: <three session cookies, values removed>
x-github-request-id: <removed>strict-transport-security tells my browser to use HTTPS for GitHub for a year. I removed the cookie values and the
request ID; they identify one visit, nothing more, but there’s no reason to publish them.
Packet 17 is two New Session Tickets: GitHub giving me a way to resume quickly next time without a full handshake.
Step 5: say goodbye, packets 24 to 32#
Closing happens at two layers, top first:
- TLS close_notify (packet 24): my side “will not send any more messages on this connection” (RFC 9846, section 6.1).
- TCP FIN (packet 25): my side has finished sending.
- GitHub acknowledges, sends its own close_notify (29) and its FIN (30).
- Two RSTs (31, 32) from my machine. curl had already closed its socket, so when GitHub’s close_notify arrived there was no one left to read it. RFC 1122 says a TCP in that case “SHOULD send a RST to show that data was lost” (section 4.2.2.13). Here nothing important was lost: the lost data was a goodbye.
What 167 ms bought#
| Phase | Packets | Time | Layer |
|---|---|---|---|
| DNS lookup | 1–4 | 0–31 ms | application, over UDP (here, over loopback) |
| TCP handshake | 5–7 | 31–64 ms | transport |
| TLS handshake | 8–13 | 72–105 ms | application (TLS, directly on TCP) |
| HTTP/2 request and answer | 14–23 | 105–131 ms | application |
| Close | 24–32 | 132–167 ms | application (TLS), then transport |
Three round trips before a single byte of HTTP: one for DNS, one for TCP, one for TLS. That’s why connection reuse, session tickets and newer protocols that merge these steps exist, and High Performance Browser Networking is the best explanation of all of them I know.
Where to go deeper#
- How the web works, MDN: the gentle version of this post: clients, servers, DNS, packets and HTTP, without a capture.
- High Performance Browser Networking, Ilya Grigorik: free to read online. Start with Building Blocks of TCP for the handshake and why round trips matter.
- The Illustrated TLS 1.3 Connection: one TLS connection, every byte explained.
- Wireshark User’s Guide and the TLS page of the Wireshark wiki: capturing, filtering, and decrypting with a key log.
- ITU-T X.200: the OSI model itself, free from the ITU.
- On this blog: PKI, SSL/TLS, Handshake and my cryptography cheat sheet.
Keywords#
| Keyword | Meaning here |
|---|---|
| TCP/IP model | The internet’s four layers: application, transport, internet, link |
| OSI model | The seven-layer teaching model from ITU-T X.200 / ISO/IEC 7498-1 |
| A / AAAA record | DNS answers holding an IPv4 / IPv6 address |
| Three-way handshake | SYN, SYN-ACK, ACK: how TCP opens a connection |
| Round-trip time (RTT) | Time for a packet to reach the server and an answer to come back; 33 ms here |
| MSS / MTU | The largest TCP payload / the largest packet a link carries |
| ALPN | The TLS extension where client and server agree on HTTP/2 or HTTP/1.1 |
| Key log (SSLKEYLOGFILE) | A file of session secrets that lets Wireshark decrypt a capture |
| close_notify / FIN / RST | TLS’s goodbye, TCP’s goodbye, and TCP’s “this connection is gone” |
Takeaways#
- One
curl -Itook 32 packets and 167 ms: DNS, TCP, TLS, HTTP/2 and a two-layer goodbye. - Each header names the layer inside it: Ethernet says IPv4, IPv4 says TCP, TCP says port 443.
- Three round trips came before any HTTP. The certificate chain travels encrypted; trusting it happens on my machine.
- My capture tool missed DNS until I knew WSL tunnels it, and curl quietly skipped post-quantum key exchange: both were invisible until I looked at the packets.
References#
- RFC 1122, Requirements for Internet Hosts: Communication Layers: IETF, October 1989; section 1.1.3 (the four layers), 4.2.2.13 (RST after close)
- ITU-T X.200, Open Systems Interconnection: Basic Reference Model: ITU, July 1994, freely available; the seven OSI layers, same text as ISO/IEC 7498-1; section 7.1.3.2 (security agreement as an Application Layer facility)
- RFC 1035, Domain Names: Implementation and Specification: IETF, November 1987; section 4.2, DNS over UDP and TCP port 53
- RFC 3596, DNS Extensions to Support IP Version 6: IETF; the AAAA record
- RFC 9293, Transmission Control Protocol (TCP): IETF, August 2022; section 3.5, the three-way handshake
- RFC 9846, The Transport Layer Security (TLS) Protocol Version 1.3: IETF, July 2026; section 1 (protocols layered on TLS), 6.1 (close_notify)
- RFC 9113, HTTP/2: IETF, June 2022; sections 3.1 (h2 and ALPN), 3.4 (connection preface), 8.3 (pseudo-headers)
- tshark manual page: Wireshark; -D, -i (and the default interface), -f, -w, -a, -r and -o
- pcap-filter(7): tcpdump/libpcap; the capture filter language, the
portprimitive - Filtering while capturing, Wireshark User’s Guide, and CaptureFilters, Wireshark wiki: capture filter overview and examples
- Accessing network applications with WSL: Microsoft Learn; DNS tunnelling
- SSLKEYLOGFILE, everything curl: the curl book; writing TLS secrets for Wireshark
- Transport Layer Security (TLS), High Performance Browser Networking: Ilya Grigorik, O’Reilly; chapter 4, SSL implemented at the application layer on top of TCP, TLS 1.0 as RFC 2246 in January 1999
- Building Blocks of TCP, High Performance Browser Networking: Ilya Grigorik, O’Reilly; the three-way handshake and random sequence numbers
- How the web works: MDN; further reading
- The Illustrated TLS 1.3 Connection, Wireshark User’s Guide, TLS, Wireshark Wiki: further reading



