Matheion

MA-NET1 · Module 11

Packet reading — HTTP on the wire

Topics: HTTP capture · Layered headers · GET/response

Overview

Session 11 — Reading an HTTP exchange on the wire

Until now Mira has met HTTP as a conversation: her Skylark Forecast app asks api.skylark.example for a forecast, and a server answers. In this session you will look at that same conversation the way a network engineer does, as a stack of headers wrapped around a few lines of text.

You will practise reading an invented capture pane: a packet list on top, and below it a layer-by-layer breakdown of one frame, from the link frame, to the IP header, to the TCP header, to the HTTP message itself. The skill is knowing which fact lives at which layer. For instance, the client's IP address is never written inside the HTTP message, and the URL path is never written inside the IP header.

Every capture here is invented for practice; nothing needs to be installed, because the panes are printed right in the lesson. (Real packet-capture programs exist if you ever want to look at your own traffic, but they are entirely optional.)

Plan: Concepts → Examples → Quiz.

Time: about 55–70 minutes if you pause to do the length arithmetic yourself.

Concepts

Core ideas — reading a layered capture: frame, IP, TCP, HTTP

So far every HTTP message in this course has been drawn as a tidy box: a request line, a few headers, maybe a body. That picture is true, but it hides something important. On the wire, the HTTP message is never alone. It is the innermost of four envelopes, and a person reading a capture has to open them in order. This session is about opening those envelopes calmly, one at a time, and knowing which facts you will find inside each.

Mira's phone has just asked api.skylark.example for a three-day outlook. Somebody (a developer debugging, say) recorded the packets that crossed her phone's network interface. What they recorded is called a capture, and the program that shows it usually presents two panes. All of the captures below are invented for practice, and you do not need any software to follow them; the panes are printed right in the lesson.


The two panes of a capture

The packet list has one line per frame, in time order. Each line gives a number, a time in seconds since the capture began, the source and destination addresses, the highest protocol the viewer recognised, the frame length in bytes, and a short summary. Here is the opening of Mira's capture:

No.  Time(s)    Source          Destination     Proto  Len  Info
  1  0.000000   10.0.4.23       203.0.113.40    TCP     58  51822 → 80 [SYN] Seq=0
  2  0.030412   203.0.113.40    10.0.4.23       TCP     58  80 → 51822 [SYN, ACK] Seq=0 Ack=1
  3  0.030498   10.0.4.23       203.0.113.40    TCP     54  51822 → 80 [ACK] Seq=1 Ack=1
  4  0.030871   10.0.4.23       203.0.113.40    HTTP   219  GET /v1/outlook?city=harbor-9&days=3 HTTP/1.1
  5  0.073904   203.0.113.40    10.0.4.23       HTTP   269  HTTP/1.1 200 OK  (application/json)
  6  0.074010   10.0.4.23       203.0.113.40    TCP     54  51822 → 80 [ACK] Seq=166 Ack=216

The detail pane takes one frame you select and unfolds it into layers, outermost first. That unfolding order is the single most useful habit in this lesson: frame, then IP, then TCP, then HTTP. It is the same order in which a receiving computer peels the envelopes.

Before reading further, notice what the packet list already tells you. Frames 1–3 contain no HTTP at all. They are the TCP handshake from the earlier sessions, and they come first because TCP must set up a connection before any request can ride on it. The HTTP request is frame 4, and it is already ~31 ms into the capture, which is roughly one round trip to the server. The server's answer, frame 5, arrives about 43 ms after the request left (0.073904 − 0.030871).


Opening frame 4, layer by layer

Here is the detail pane for frame 4, the request. Read it top to bottom; each block is one layer.

Frame 4: 219 bytes captured
Link (Ethernet-style frame)
    Destination: 02:00:5e:10:00:01   (the home router, not the server)
    Source:      02:00:5e:10:00:23   (Mira's phone)
    Type: IPv4 (0x0800)
Internet Protocol
    Version: 4          Header length: 20 bytes
    Total length: 205   TTL: 64       Protocol: TCP (6)
    Source:      10.0.4.23
    Destination: 203.0.113.40
Transmission Control Protocol
    Source port: 51822  Destination port: 80
    Seq: 1   Ack: 1     Header length: 20 bytes
    Flags: PSH, ACK     Window: 64240
    [TCP payload: 165 bytes]
Hypertext Transfer Protocol
    GET /v1/outlook?city=harbor-9&days=3 HTTP/1.1
    Host: api.skylark.example
    User-Agent: MiraApp/0.3 (probe-build)
    Accept: application/json
    Connection: keep-alive
    (blank line)

The link layer tells you about one hop only. The addresses there are hardware (MAC-style) addresses on Mira's own local network, so the destination is her home router, which is the next stop, not the Skylark server. When the frame is forwarded, the link layer is stripped off and rebuilt for the next hop, which is why you should never expect link addresses to match from one side of the Internet to the other. The Type field says "what is inside me?": 0x0800 means an IPv4 datagram.

The IP layer carries the two addresses that matter end to end, plus a few housekeeping fields. Protocol: TCP (6) plays the same role as Type did one level up: it tells the receiver which transport protocol owns the payload. Total length: 205 covers the IP header plus everything inside it.

The TCP layer carries the two port numbers that name the programs: Mira's app at ephemeral port 51822, and a web server listening at port 80. It also carries the sequence and acknowledgement numbers and the flags you already know from the reliability session.

The HTTP layer is plain text. The first line is the request line: a method (GET), a target (/v1/outlook?city=harbor-9&days=3), and a version (HTTP/1.1). Each following line is a header of the form Name: value, and a blank line ends the headers.

Common confusion: The viewer lists the frame length (219) in the packet list, but the IP header says total length 205, and the TCP payload is only 165. These are three different numbers about three different amounts of bytes, nested like envelopes: 165 + 20 (TCP header) = 185 for the TCP segment; 185 + 20 (IP header) = 205 for the IP datagram; 205 + 14 (link header) = 219 for the frame. Capture programs normally leave off the checksum trailer that a link adds at its end, so you will not see it counted here.


Which field lives at which layer?

This is the question worth being able to answer in your sleep, because mixing the layers up is the most common mistake in reading captures. Here are the facts people hunt for, and where they actually are.

| Fact you want | Where to find it | Why there | |---|---|---| | Client's IP address (10.0.4.23) | IP header, Source | Routers need it to send the reply back | | Server's IP address (203.0.113.40) | IP header, Destination | Routers need it to forward the packet | | Which program on the client | TCP header, Source port | The operating system hands bytes to the right socket | | That it is a web server | TCP header, Destination port (80) | A convention, not a law: the port only suggests HTTP | | Which website was asked for | HTTP, Host header | Many names can share one address | | Which resource | HTTP request line, target | Only the server application cares | | HTTP version | HTTP request line, last word | Part of the message text |

The key observation is the first row. The client's IP address is not in the HTTP message. If you read the request lines again, there is no "From: 10.0.4.23" anywhere in them. HTTP is an application protocol, and it simply assumes that the layers below it have already delivered the bytes between the right two machines. A web server that wants to know where a request came from has to ask the operating system, which read it from the IP header.

The same logic explains the Host header. The IP address 203.0.113.40 only identifies a machine. The same machine may serve api.skylark.example and several other names. The name the user typed was resolved to an address by DNS and then thrown away by the lower layers, so the browser repeats the name inside HTTP, where the server application can read it.

Common confusion: "The URL" is not one field. What you type, http://api.skylark.example/v1/outlook?city=harbor-9&days=3, is split up on the wire. The host name travels in the Host header, the path and query string travel in the request line, and the scheme (http) is implied by which port and protocol were used. Reading a capture means reassembling the URL from two places.


Reading the response

The server's answer is frame 5. Only the HTTP layer is new, so here it is on its own.

HTTP/1.1 200 OK
Date: Tue, 10 Nov 2026 03:41:07 GMT
Content-Type: application/json
Content-Length: 83
Connection: keep-alive
(blank line)
{"city":"harbor-9","days":3,"outlook":["clear","haze","showers"],"issued":"03:40Z"}

The first line is the status line: version, a numeric status code, and a short phrase. 200 means success. Codes beginning with 3 are redirections, 4 mean the client asked for something the server will not or cannot give (404 for "no such resource"), and 5 mean the server itself failed. You can read the family from the first digit even when you have not memorised the specific code.

Content-Length: 83 states how many bytes the body has. The body begins after the blank line. You can check the claim: the headers of this response occupy 132 bytes (counting each line's two end-of-line characters and the blank line), so the TCP payload should be 132 + 83 = 215 bytes, and frame 5's detail pane does say [TCP payload: 215 bytes]. That is a neat sanity check, and it is also how a client knows where one response ends and the next begins on a connection that stays open.

Date is stamped by the server and is expressed in GMT regardless of where anyone is sitting.


Persistent or not?

Opening a TCP connection costs a full round trip before any HTTP can flow. Persistent connections avoid paying that cost every time: the same TCP connection carries a request, its response, then another request, and so on. Non-persistent behaviour closes the connection after one exchange.

How do you recognise which one you are looking at?

  • In HTTP/1.1, connections are persistent by default. A Connection: keep-alive header is allowed but is really just a reminder. The thing to hunt for is the opposite: Connection: close in either message, which announces that the sender will close after this exchange.
  • In HTTP/1.0, the default is the other way around: the connection closes unless the headers say otherwise.
  • The most reliable evidence is in the packet list itself. If a second request leaves the same client port to the same server port with no new SYN ahead of it, the connection was reused. If every request is preceded by a handshake from a new ephemeral port, it is not.

Common confusion: Connection: keep-alive in a request is a wish, and the response decides. A server may answer with Connection: close and shut the connection anyway. Read both messages, and then confirm in the packet list whether a FIN appears.


A reading routine you can reuse

Whenever you meet an unfamiliar capture, a calm five-step routine keeps you from getting lost.

  1. Skim the packet list for the shape of the story: handshake, request, response, teardown, retries.
  2. Pick one frame and unfold it from the outside in: frame length, IP addresses and protocol number, TCP ports and flags, then HTTP text.
  3. Do the length arithmetic. Frame minus link header gives the IP total length. IP total minus IP header gives the TCP segment. TCP segment minus TCP header gives the payload. If the numbers do not add up, the capture was cut short or the viewer reassembled several segments.
  4. Assign every fact to its layer before drawing conclusions (who, which program, which site, which resource).
  5. Check the timing. The gap between a request and its reply is a mix of network round trip and server thinking time; the handshake alone (frame 1 to frame 3 here, about 30 ms) shows roughly the round trip.

One honest caveat: most real traffic today is encrypted. In an encrypted capture, steps 1 to 3 still work (you can see addresses, ports, and sizes), but the HTTP text is scrambled and you cannot read the path or status. We use plain text here because it makes the layering visible; the layering itself is the same either way.


What to carry forward

A capture shows a stack of envelopes: a link frame around an IP datagram around a TCP segment around an HTTP message. IP carries the addresses, TCP carries the ports, and HTTP carries the method, path, version, host, status, and body length. Reading well means opening the envelopes outermost-first and assigning each fact to its layer. The next session zooms in on the other classic application you met earlier, the naming lookup, and watches a DNS query and answer cross the wire.

Examples

Session 11 — Worked examples

Each example follows the same four beats: a Scene (who is looking, and why), a Capture (an invented pane), a Reading (every step spelled out), and a Takeaway (the one idea to keep). Try covering the Reading and doing it yourself first.


Example A — Assembling the request from the capture

Scene. A teammate pastes one frame from Mira's debugging session into the Skylark Forecast team chat and asks: "Which resource did the app ask for, and which HTTP version is this?"

Capture.

Frame 4: 219 bytes captured
Internet Protocol   Src 10.0.4.23   Dst 203.0.113.40   Protocol TCP (6)   Total length 205
Transmission Control Protocol   Src port 51822   Dst port 80   Flags PSH, ACK   [payload 165 bytes]
Hypertext Transfer Protocol
    GET /v1/outlook?city=harbor-9&days=3 HTTP/1.1
    Host: api.skylark.example
    User-Agent: MiraApp/0.3 (probe-build)
    Accept: application/json
    Connection: keep-alive

Reading.

  1. The request line has three words separated by spaces: GET, /v1/outlook?city=harbor-9&days=3, and HTTP/1.1. So the method is GET (fetch, do not change anything), the target is the path /v1/outlook with a query string, and the version is HTTP/1.1.
  2. The query string begins after the ?. It holds two name-value pairs separated by &: city=harbor-9 and days=3. So the app wants a three-day outlook for a place the service calls harbor-9.
  3. The site name is not in the request line at all. It is in the Host header: api.skylark.example.
  4. Putting the two together, the full URL is http://api.skylark.example/v1/outlook?city=harbor-9&days=3. The http part is implied by the plain-text exchange on port 80.
  5. The User-Agent line is the app introducing itself. It is a free-form label that any program may invent, so it is useful for debugging but never proof of who is really calling.

Takeaway. A URL is reassembled from two places: the Host header gives the name, and the request line gives the path and query. The version is the last word of the request line.


Example B — Which layer knows what?

Scene. A new teammate, Dev, insists that the Skylark server "reads Mira's IP address from the request headers". Mira wants to show where the server really gets that knowledge.

Capture. The same frame 4 as above, folded to show the fields that matter.

IP    Source 10.0.4.23        Destination 203.0.113.40
TCP   Source port 51822       Destination port 80
HTTP  Host: api.skylark.example
      User-Agent: MiraApp/0.3 (probe-build)
      (no field anywhere in the HTTP text that contains 10.0.4.23)

Reading.

  1. Scan every HTTP line: the request line, Host, User-Agent, Accept, Connection. None contains an address. The text 10.0.4.23 appears only in the IP header.
  2. So how does a server application learn it? The operating system on the server received the datagram, read the IP source address and the TCP source port, and remembers them as the other end of the connection. When the application asks "who is on this socket?", the operating system answers from those lower-layer fields.
  3. Notice also that 10.0.4.23 is a private address. This capture was taken on Mira's phone, before her home router rewrites the source address to a public one (the NAT idea from the network-layer session). At the Skylark server, the IP source would be a BayLink public address, not 10.0.4.23.
  4. The destination port, 80, tells the server's operating system which listening program to give the bytes to. The Host header tells that program which of its sites was meant.

Takeaway. Addresses belong to IP, ports to TCP, and names, paths, and versions to HTTP. HTTP never carries the client's address; the server learns it from the layers below.


Example C — Reading a response and checking its length

Scene. Mira's app shows an error: "response seemed short". She opens frame 5 and wants to know whether the body is complete.

Capture.

Frame 5: 269 bytes captured
IP    Src 203.0.113.40   Dst 10.0.4.23   Total length 255
TCP   Src port 80   Dst port 51822   Seq 1   Ack 166   Header length 20   [payload 215 bytes]
HTTP  HTTP/1.1 200 OK
      Date: Tue, 10 Nov 2026 03:41:07 GMT
      Content-Type: application/json
      Content-Length: 83
      Connection: keep-alive
      (blank line)
      {"city":"harbor-9","days":3,"outlook":["clear","haze","showers"],"issued":"03:40Z"}

Reading.

  1. Status. HTTP/1.1 200 OK: version 1.1, code 200 (success). The first digit, 2, already says "it worked".
  2. Length arithmetic down the stack. Frame 269 − 14 (link header) = 255, which matches the IP total length. 255 − 20 (IP header) = 235 bytes of TCP segment. 235 − 20 (TCP header) = 215 bytes of payload. The numbers agree, so nothing was truncated by the capture.
  3. Split the payload. The headers (status line through the blank line) take 132 bytes. The payload is 215, so the body is 215 − 132 = 83 bytes.
  4. Compare with the claim. Content-Length: 83. The body bytes present equal the bytes promised, so the body is complete. The error in the app must lie elsewhere (perhaps in how it parses the three-item outlook list, not in the transfer).
  5. Direction check. Source port 80 and destination port 51822 are the reverse of the request's ports, and Ack 166 says "I have received everything up to byte 165 of your request". That is the reply to frame 4.

Takeaway. Subtract headers outward-in to get from frame size to payload size, then compare the body you can see against Content-Length. If they match, the transfer was whole.


Example D — Persistent or not?

Scene. Skylark's operations team wants to know whether two different services are reusing connections, because each avoided handshake saves one round trip of about 30 ms. They have two short packet lists.

Capture 1: the forecast API.

No.  Time(s)    Source        Destination    Proto  Info
 10  1.912300   10.0.4.23     203.0.113.40   HTTP   GET /v1/outlook?city=harbor-9&days=3 HTTP/1.1   [port 51822]
 11  1.955100   203.0.113.40  10.0.4.23      HTTP   HTTP/1.1 200 OK   Connection: keep-alive
 12  2.804500   10.0.4.23     203.0.113.40   HTTP   GET /v1/alerts?city=harbor-9 HTTP/1.1            [port 51822]
 13  2.838800   203.0.113.40  10.0.4.23      HTTP   HTTP/1.1 200 OK   Connection: keep-alive

Capture 2: an old image host.

No.  Time(s)    Source        Destination    Proto  Info
 20  3.100000   10.0.4.23     203.0.113.77   TCP    53110 → 80 [SYN]
 21  3.131000   203.0.113.77  10.0.4.23      TCP    80 → 53110 [SYN, ACK]
 22  3.131050   10.0.4.23     203.0.113.77   HTTP   GET /icons/sun.png HTTP/1.0
 23  3.165000   203.0.113.77  10.0.4.23      HTTP   HTTP/1.0 200 OK   Connection: close
 24  3.165300   203.0.113.77  10.0.4.23      TCP    80 → 53110 [FIN, ACK]
 25  3.400000   10.0.4.23     203.0.113.77   TCP    53111 → 80 [SYN]

Reading.

  1. In Capture 1 both requests leave from port 51822 to the same server port, and there is no SYN between frame 11 and frame 12. The second request simply rode the connection that was already open. That is persistent behaviour, with the 1.1 default doing its job.
  2. In Capture 2, the request line says HTTP/1.0, the response says Connection: close, and the server sends a FIN immediately after the answer (frame 24). Both clues agree: this connection is used once and discarded.
  3. The proof of the cost is in frame 25: the next fetch begins with a SYN from a new port, 53111, so a new handshake is needed. At roughly 31 ms per handshake round trip (frame 20 to frame 21), every icon pays that delay.
  4. The gap between request and reply in Capture 1 is about 43 ms for frame 10 to frame 11 and about 34 ms for frames 12 to 13. The second is shorter in this invented trace, but neither includes a handshake wait, because none was needed.

Takeaway. To decide whether a connection is persistent, check three things together: the version in the request line, the Connection headers, and whether the packet list shows a FIN and a fresh SYN or a reused port.


Example E — One address, two sites

Scene. Northline Relay runs a single machine at 203.0.113.60 that serves both edge.northline.example and status.northline.example. A colleague claims they cannot be told apart in a capture because "the IP address is the same". Is that right?

Capture.

Frame 31: IP Src 10.0.4.23  Dst 203.0.113.60   TCP Dst port 80
    GET /icons/cloud.png HTTP/1.1
    Host: edge.northline.example

Frame 38: IP Src 10.0.4.23  Dst 203.0.113.60   TCP Dst port 80
    GET /icons/cloud.png HTTP/1.1
    Host: status.northline.example

Reading.

  1. Compare the IP headers: source, destination, and protocol are identical. Compare the TCP destination port: also identical. Nothing below HTTP distinguishes the two requests.
  2. Compare the request lines: also identical, both ask for /icons/cloud.png.
  3. The only difference is the Host header. That one line tells the server which of its two sites to look inside. The server may answer with two completely different pictures, even though the path was the same.
  4. So the colleague is half right: the lower layers cannot tell the two requests apart, and that is exactly why HTTP has the Host header.

Takeaway. The IP address names a machine, and the Host header names the site inside it. When two sites share an address, only the HTTP layer can separate them.

Practice check — reading an HTTP exchange on the wire

Multiple-choice check from the Matheion app lesson. Pick an answer for each question, then submit.

  1. 1.A detail pane unfolds a frame in this order: Link → Internet Protocol → Transmission Control Protocol → Hypertext Transfer Protocol. Why is that outside-in order the natural way to read it?

  2. 2.A request line reads: GET /v1/outlook?city=harbor-9&days=3 HTTP/1.1 Which of these is the HTTP version?

  3. 3.Mira's capture shows an IP header with Source 10.0.4.23 and Destination 203.0.113.40, then an HTTP message with the lines: Host: api.skylark.example User-Agent: MiraApp/0.3 (probe-build) Where does the server get the client's IP address from?

  4. 4.Two frames are captured: Frame A: IP Dst 203.0.113.60, TCP Dst port 80, Host: edge.northline.example Frame B: IP Dst 203.0.113.60, TCP Dst port 80, Host: status.northline.example What is the only layer that distinguishes the two sites being requested?

  5. 5.A response frame shows: frame length 269, IP total length 255, TCP header length 20, and the status line plus headers take 132 bytes. The headers include Content-Length: 83. Which statement is correct?

  6. 6.The packet list shows: 10 GET /v1/outlook HTTP/1.1 [port 51822 → 80] 11 HTTP/1.1 200 OK Connection: keep-alive 12 GET /v1/alerts HTTP/1.1 [port 51822 → 80] What does this suggest about connection use?

  7. 7.A response starts with: HTTP/1.0 200 OK and includes the header Connection: close, followed one frame later by a frame marked [FIN, ACK] from the server. What is the most reasonable conclusion?

  8. 8.A frame's detail pane shows: Link header (14 bytes), IP header 20 bytes, IP total length 205, TCP header length 20 bytes. How many bytes of HTTP text does the frame carry, and what is the whole frame length?