online posts 16
wireshark 101

task 1.1 · chapter 1 of 8: what a capture shows · 20 min

Your first capture

objective

Capture the laptop pinging the printer, open the file in Wireshark, and read the three panes: the packet list, the details and the bytes. Find out what the laptop sent before its first ping.

you edit, in the labanswers/1.1.yml

open a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter

given
Capturemake capture AT=laptop:eth1 NAME=1.1 X=ping
Open itthe Wireshark tab in the lab app, Start Wireshark, then File › Open › /captures/1.1.pcapng
Your answersanswers/1.1.yml
new to this? step by stepbeginner
  1. make capture AT=laptop:eth1 NAME=1.1 X=ping.
  2. The lab app’s Wireshark tab, Start Wireshark, then File › Open › /captures/1.1.pcapng.
  3. Read the packet list: what came before the first ping? Count the echo requests.
  4. Challenge: click a reply. Its Ethernet layer has the printer’s MAC address, its IP layer the TTL.
  5. Fill in answers/1.1.yml, then make check T=1.1.

more in meet the lab

1 explain

A recording of one cable

What a capture is

A packet capture is a recording of every frame that crossed one place in the network, while the recording ran. Each one is written down exactly as it was, bit for bit, with the time it was seen. Nothing is summarized and nothing is left out.

That’s what makes it different from everything else you’ve used so far. ip neigh tells you what the laptop concluded. show mac address-table tells you what the switch learned. A capture shows you what was actually sent, and in what order. When those disagree, the capture wins.

in one sentence A capture is a word-for-word recording of the frames that crossed one point, with the time of each.

Where this one is taken

make capture AT=laptop:eth1 records the laptop’s only network card, eth1: the cable between the laptop and the switch. It’s like clipping a listening device onto that one cable. You’ll see everything the laptop sends and everything that’s sent to it, and nothing else.

The lab does the recording from outside the laptop, with containerlab capture, so nothing on the laptop knows it’s being watched. The file lands in captures/1.1.pcapng. pcapng (packet capture, next generation) is the file format Wireshark saves by default. It holds the frames, and also the name of the port each one was captured on, which matters in task 1.2.

in one sentence AT= names the cable you’re listening on; the frames go into a .pcapng file.

Wireshark’s three panes

Open a capture and Wireshark shows three panes, top to bottom:

PaneWhat it shows
Packet listone line per frame: its number, the time, from, to, the protocol and a one-line summary
Packet detailsthe frame you clicked, layer by layer, each one a line you can open: Ethernet, then IP, then ICMP
Packet bytesthe same frame as raw bytes, in hex. Click a field in the details and its bytes light up

The details pane is the layers from Networking 101, stacked the way they’re stacked on the wire: the outermost envelope first.

2 show

One ping, layer by layer

Here’s the packet list of a capture like yours, as tshark prints it in the terminal (Wireshark shows the same columns):

    1 0.000000000 aa:aa:aa:11:11:11 → Broadcast    ARP 42 Who has 192.168.1.20? Tell 192.168.1.175
    2 0.000113458 aa:aa:aa:22:22:22 → aa:aa:aa:11:11:11 ARP 42 192.168.1.20 is at aa:aa:aa:22:22:22
    3 0.000115250 192.168.1.175 → 192.168.1.20 ICMP 98 Echo (ping) request  id=0x07a0, seq=1/256, ttl=64
    4 0.000193416 192.168.1.20 → 192.168.1.175 ICMP 98 Echo (ping) reply    id=0x07a0, seq=1/256, ttl=64 (request in 3)
ColumnWhat it means
1the frame number, counted from the start of the capture
0.000113458seconds since the first frame
aa:aa:aa:11:11:11 → Broadcastfrom and to. For frames with no IP layer Wireshark shows MAC addresses
ARP · ICMPthe highest layer Wireshark recognized in the frame
42 · 98the frame’s length in bytes
Who has ...Wireshark’s one-line summary of it

Click frame 4 and open its layers in the details pane (... marks lines left out here):

Frame 4: Packet, 98 bytes on wire (784 bits), 98 bytes captured (784 bits) on interface laptop:eth1, id 0
Ethernet II, Src: aa:aa:aa:22:22:22 (aa:aa:aa:22:22:22), Dst: aa:aa:aa:11:11:11 (aa:aa:aa:11:11:11)
Internet Protocol Version 4, Src: 192.168.1.20, Dst: 192.168.1.175
    ...
    Time to Live: 64
    Protocol: ICMP (1)
    ...
Internet Control Message Protocol
    Type: Echo (ping) reply (0)
    ...

Frame is Wireshark’s own line: when and where the frame was captured. Then come the layers: Ethernet (MAC addresses), IP (IP addresses, TTL), ICMP (the ping itself). The TTL (time to live) is a number every IP packet carries. Each router on the way takes one off, and a packet that reaches zero is thrown away, so lost packets can’t loop forever.

You may also see a frame from a MAC address you don’t know, with the protocol STP. That’s the switch: it sends a spanning tree message out of every port every two seconds, to check there are no loops in the cabling. Real switches do it too. Ignore it for now.

3 follow along

Capture, open, read

  1. Capture the laptop’s cable while the lab sends four pings to the printer:

    run in the terminal
    make capture AT=laptop:eth1 NAME=1.1 X=ping
    

    It prints each command it runs on the laptop, then saved 11 frames to captures/1.1.pcapng (your number may be a frame or two different: an STP message lands in the middle now and then).

  2. Click the Wireshark tab at the top of the lab app, then Start Wireshark. The first start takes about half a minute (it fetches Wireshark once), then Wireshark fills the tab. make wireshark in the terminal does the same.

  3. In Wireshark, File › Open, go to /captures, and open 1.1.pcapng. (Prefer the terminal? tshark -r captures/1.1.pcapng prints the same packet list.)

  4. Look at the first frame the laptop sent: the first one from aa:aa:aa:11:11:11. It isn’t a ping. Before the laptop could send anything to 192.168.1.20, it needed the printer’s MAC address, so it asked. That’s ARP, from Networking 101’s lesson on ARP, on the wire.

  5. Count the Echo (ping) request frames. Then fill in the follow-along lines:

    editanswers/1.1.ymlCtrl+P → 1.1.yml
    first_protocol: ARP
    echo_requests: 4
    

in one sentence The laptop’s first frame was a question, not a ping: it had to learn the printer’s MAC address before it could send to it.

4 challenge

Read a reply

Click one of the Echo (ping) reply frames, and find two things in the packet details:

  • printer_mac: the printer’s MAC address, from the Ethernet layer;
  • reply_ttl: the TTL in the printer’s reply, from the IP layer.
hint

The reply comes from the printer, so its MAC address is the Ethernet layer’s Src.

hint

Open the Internet Protocol Version 4 line with its arrow. Time to Live is about halfway down.

show the solutionanswers/1.1.yml

or pull it into your lab: make solve T=1.1, then git diff --staged shows what changed

printer_mac: aa:aa:aa:22:22:22
reply_ttl: 64

The printer is a Linux computer, and Linux starts every packet at a TTL of 64. It arrived at 64 because the printer is on the laptop’s own network: no router in between took anything off. Hold on to that: in task 1.2 the replies come from further away.

5 check: run it, then prove it

$ make check T=1.1

when it's right, you'll see

╭─ task 1.1 · your first capture
│  ✓ captures/1.1.pcapng: taken on laptop:eth1, 11 frames
│  ✓ the protocol of the first frame the laptop sent (follow along): ...
│  ✓ how many echo requests the laptop sent (follow along): ...
│  ✓ the printer's MAC address, from a reply's Ethernet header (challenge): ...
│  ✓ the TTL in the printer's replies (challenge): ...
╰─ 5/5 checks passed  verified