task 1.2 · chapter 1 of 8: what a capture shows · 20 min
Where you capture
objective
Capture two switch ports at once, r1’s and the printer’s, while the laptop pings web. See why one port carries the whole conversation and the other only a single broadcast.
answers/1.2.ymlopen a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter
| Capture | make capture AT=sw1:eth1,sw1:eth3 NAME=1.2 X=crossping |
|---|---|
| Ports | make ports lists every port and what’s at the other end of its cable |
| Your answers | answers/1.2.yml |
new to this? step by stepbeginner
make ports: find the switch ports that lead to r1 and to the printer.make capture AT=sw1:eth1,sw1:eth3 NAME=1.2 X=crossping.- In Wireshark, filter
frame.interface_name == "sw1:eth1", then"sw1:eth3". Count ICMP and ARP on each. - Fill in answers/1.2.yml, then
make check T=1.2.
more in meet the lab
A capture only sees its own cable
The question every capture starts with
In task 1.1 you listened on the laptop’s cable, and saw everything the laptop said. That was easy, because the laptop was one end of every conversation. Usually it isn’t that simple: the problem is between two other computers, and you have to pick where to listen. Pick the wrong cable and you see nothing, and nothing looks exactly like the traffic never happened.
What a switch sends where
Networking 101’s lesson on hubs, switches and routers gave you the rule:
- a frame to one MAC address goes out of one port: the one the switch learned that address on;
- a broadcast (to
ff:ff:ff:ff:ff:ff) goes out of every port except the one it came in on.
So a capture on a switch port sees the traffic of whatever is plugged into that port, plus every broadcast on the network. Nothing else.
in one sentence On a switch, each port only carries its own host’s frames and the network’s broadcasts.
Two ports, one file
make capture can listen on several ports at once and write them into one file. pcapng records which port
each frame came from, and Wireshark shows it in the frame’s first line (on interface sw1:eth1) and lets you
filter on it: frame.interface_name == "sw1:eth1". You’ll use that in every chapter from here on.
Here, sw1:eth1 is the switch’s port towards r1, and sw1:eth3 is the switch’s port towards the printer.
The laptop pings web, which is two routers away, so every ping goes laptop → switch → r1.
The same moment, from two ports
make ports prints every port you can capture on:
│ sw1 │ eth1 │ N/A │ r1 │ eth1 │
│ │ eth2 │ N/A │ laptop │ eth1 │
│ │ eth3 │ N/A │ printer │ eth1 │
│ │ eth4 │ N/A │ broken-pc │ eth1 │
And here’s a capture of both ports, with the port in the second column:
3 sw1:eth3 ARP Who has 192.168.1.1? Tell 192.168.1.175
4 sw1:eth1 ARP Who has 192.168.1.1? Tell 192.168.1.175
5 sw1:eth1 ARP 192.168.1.1 is at aa:c1:ab:fd:00:84
6 sw1:eth1 ICMP Echo (ping) request id=0x07a1, seq=1/256, ttl=64
7 sw1:eth1 ICMP Echo (ping) reply id=0x07a1, seq=1/256, ttl=62 (request in 6)
That’s tshark with a column for the interface name. In Wireshark, add it yourself: right-click
Interface name in a frame’s first line in the details pane, then Apply as Column.
Capture two ports
See which ports lead where:
run in the terminalmake portsCapture r1’s port and the printer’s port while the laptop pings web three times:
run in the terminalmake capture AT=sw1:eth1,sw1:eth3 NAME=1.2 X=crosspingOpen
/captures/1.2.pcapngin Wireshark. Type this in the display filter bar at the top and press Enter:frame.interface_name == "sw1:eth1" && icmpThe status bar at the bottom says how many frames are Displayed. Those are the pings and the replies, on r1’s port.
Fill in the follow-along line:
editanswers/1.2.ymlCtrl+P → 1.2.ymlicmp_on_r1_port: 6(Three requests and three replies. Look at the replies’ TTL: 62. They were sent at 64 by web, and two routers took one off each.)
The printer’s port
Now look at the printer’s port, sw1:eth3. Before you filter, guess: how much of the laptop’s ping
conversation reached the printer’s cable?
icmp_on_printer_port: ICMP packets onsw1:eth3;arp_on_printer_port: ARP packets onsw1:eth3.
hint
Change the filter to frame.interface_name == "sw1:eth3", with and without && icmp.
hint
Which of the laptop’s frames were addressed to everyone?
show the solutionanswers/1.2.yml
or pull it into your lab: make solve T=1.2, then git diff --staged shows what changed
icmp_on_printer_port: 0
arp_on_printer_port: 1
The pings were addressed to r1’s MAC address, so the switch sent them out of r1’s port only. The one frame the printer’s cable did carry is the laptop’s ARP request: a broadcast, so the switch sent it everywhere. r1’s reply was addressed to the laptop alone, so it isn’t there either.
That’s the rule for the rest of the course: before you capture, ask which cable does this conversation actually cross?. A capture on the printer’s port would never show you a problem with the laptop’s web traffic.
5 check: run it, then prove it
$ make check T=1.2when it's right, you'll see
╭─ task 1.2 · where you capture
│ ✓ captures/1.2.pcapng: taken on sw1:eth1, sw1:eth3, 13 frames
│ ✓ ICMP packets seen on r1's port, sw1:eth1 (follow along): ...
│ ✓ ICMP packets seen on the printer's port, sw1:eth3 (challenge): ...
│ ✓ ARP packets seen on the printer's port, sw1:eth3 (challenge): ...
╰─ 4/4 checks passed verified