Unit 4 · Networks · Lesson 8 of 10
Network troubleshooting and measurement
Step 1: Learn the ideas
- Hypothesis-driven troubleshooting method
- curl timing breakdown
- dig, dig +trace, resolver versus authoritative answers
- ss socket states and queues
- TCP internals from ss -ti
- tcpdump filters and pcap files
- Reading packet timing in Wireshark
- ping, traceroute and mtr pitfalls
- MTU and fragmentation problems
- Capture artifacts from segmentation and checksum offloads
Why it matters
Prompts such as "the service is slow from one region" or "some requests time out" appear in SRE and infrastructure interviews and in real incidents alike. Strong answers form hypotheses, pick the cheapest measurement that separates them and read the evidence carefully; weak answers run tools at random or blame "the network" without isolating which hop or phase is slow.
Core ideas
Decompose the request. A request has phases: name resolution, TCP connect (one round trip), TLS handshake, time to first byte (network plus server processing) and transfer. curl's timing variables (time_namelookup, time_connect, time_appconnect, time_starttransfer, time_total) are cumulative timestamps for these phases, so the differences between them isolate each step. Compare cold and warm runs and different client locations. High connect time points at the path or at SYN handling; high time to first byte with fast connect points at the server or what is behind it.
DNS. dig shows what a resolver returns, which server answered, the remaining TTL and the query time. dig +trace follows the referrals from the root; asking the authoritative server directly and comparing with your resolver separates stale caches from wrong records. Applications and runtimes may also cache on their own.
Socket state. ss, the successor to netstat, lists sockets with their states and queues. With ss -tan: many SYN-SENT means connects are not completing; many CLOSE-WAIT means the local application is not closing sockets; many TIME-WAIT reflects connection churn. For a listening socket, Recv-Q near the backlog signals accept-queue overflow. ss -ti adds TCP internals per connection: smoothed RTT and its variation, cwnd, retransmissions, delivery rate, and whether the flow is limited by the receiver window or by the application.
Packets. tcpdump captures with a filter (host, port, protocol) and writes pcap files for Wireshark. Read timing first: the gap between SYN and SYN-ACK is the network RTT seen by the client; the gap between the request and the first response byte adds server time; retransmissions, duplicate ACKs, zero windows and resets each point to different causes. Capture at both ends when you can: a packet that leaves one host and never arrives localizes the problem to the path.
Path tools. ping measures RTT and loss to a host, though ICMP may be deprioritized or blocked. traceroute and mtr list hops and per-hop delay, but routers often rate-limit their replies, so loss at an intermediate hop that does not continue to later hops is usually not real loss. MTU problems show up as connections that complete the handshake but stall on large transfers.
Method. Go from symptom to hypotheses to the cheapest discriminating test; change one variable at a time; write down what each test ruled out.
Common misconceptions
- "Ping works, so the network is fine." ICMP may be treated differently, and TCP-level problems (resets, MTU, overflowing accept queues) do not show up in ping.
- "Loss at one traceroute hop means that router drops traffic." Routers deprioritize replies to probes; only loss that persists to the destination matters.
- "High latency means the network is slow." Time to first byte often includes server queueing; separate connect time from server time first.
- "tcpdump shows exactly what is on the wire." With segmentation and checksum offloads, captures on the sending host can show oversized segments or bad checksums that never existed on the wire.
- "CLOSE-WAIT build-up is a network problem." The local application received the peer's FIN and never closed its socket.
How to approach it
Practice on real traffic: time requests to several sites with curl, capture a handshake, read ss output on a loaded machine. In interviews, narrate a plan before naming tools: what you expect each measurement to show and how it narrows the search. At senior level add fleet thinking: compare healthy and unhealthy hosts, correlate with deploys, and start from metrics and traces before taking packet captures.
Suggested order
- 1Read the write-out section of Everything curl and build a format string that prints the five timing variables; time cold and warm requests to three sites.
- 2Read the dig page of the BIND 9 manual; run dig and dig +trace for a domain and compare your resolver's answer with the authoritative server's answer.
- 3Read the ss(8) manual page and run ss -tan and ss -tin on a machine with active connections; explain every column and TCP field you see.
- 4Read the tcpdump manual sections on filter expressions and writing to a file; capture one HTTPS request and open it in Wireshark.
- 5Do the request-timing and HTTPS packet-trace projects, writing down what each measurement ruled out.
- 6Read Google SRE book Ch. 12 (Effective Troubleshooting) and apply its method to a scenario such as "requests from one region time out".
Step 2: Check off what you can do
Tap each one you can genuinely do or explain. Each earns 10 XP.
Step 3: Go deeper
ss(8): socket statistics (Linux manual page)Start here
man7.org (Linux man-pages project)Options and output fields for socket state, queues and per-connection TCP internals.
Open(opens in a new tab)Link responded, 5 Oct 2026tcpdump(1) manual pageStart here
The Tcpdump GroupCapture filters, snapshot length, timestamps and writing pcap files.
Open(opens in a new tab)Link responded, 5 Oct 2026Wireshark User's Guide
Wireshark FoundationDisplay filters, following TCP streams, expert information and time-sequence graphs.
Open(opens in a new tab)Link responded, 5 Oct 2026Everything curl
curl projectSection: Write out
Timing variables for splitting request latency into phases.
Open(opens in a new tab)Link responded, 5 Oct 2026BIND 9 manual pages (dig)
Internet Systems Consortium (BIND 9 documentation)Section: dig - DNS lookup utility
Query options including +trace, +norecurse and choosing which server to query.
Open(opens in a new tab)Link responded, 5 Oct 2026
Step 4: Practice
Run the request-timing project against sites near and far from you, cold and warm, and explain every difference. In the packet-trace project, find the handshake RTT, server think time and any retransmissions. On a busy machine, run ss -tan and ss -ti and explain each column. Then practice a spoken drill: for "some requests from one region time out", list hypotheses and the cheapest test for each before running anything.
- Decompose request latency with dig and curl timingOpen(opens in a new tab)Not attemptedHands-on project (Everything curl as reference)
- Capture and annotate one HTTPS request end to end (DNS, TCP, TLS 1.3, HTTP)Open(opens in a new tab)Not attemptedHands-on project (Wireshark User's Guide as reference)
Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).
Step 5: Test yourself
Answer each one out loud or on paper before you finish the lesson.
- Question 1time_connect is 300 ms but ping RTT is 20 ms. What would you check?
- Question 2A server shows thousands of CLOSE-WAIT sockets. What is the likely cause?
- Question 3How do you tell whether a DNS problem is a stale cache or a wrong record?
- Question 4In a capture, the server ACKs the request at once but responds two seconds later. Where is the time going?
- Question 5Large downloads stall but small requests work. Which hypothesis do you test first?
- Question 6Why might a capture show 64 KB TCP segments on a link with a 1500-byte MTU?
You’re done when you can
- Given curl timing output for a slow request, name the slow phase and the next measurement you would take.
- Explain every column of ss -tan output and three fields of ss -ti output without notes.
- Find the handshake RTT, server think time and any retransmissions in a capture within ten minutes.
- Explain why intermediate-hop loss in mtr is often not real loss.


