Choosing a capture location
On this page
phone and laptop are plugged into the same switch. Predict: if phone listens, does it hear laptop’s request to web? Write your answer before looking at the recordings. By the end, you can choose where to listen and explain why silence at one place does not prove silence everywhere.
Before you start
Section titled “Before you start”Finish Practice: Building Your Networking Lab. Start the lab in its starting state, with no modes or faults. These commands run inside lab machine shells, starting in the shared home directory. Capture only inside this lab.
Listen at one interface
Section titled “Listen at one interface”A packet capture records the frames passing one interface. That interface is the capture point. The name of the technique says “packet,” but the recorded data includes link headers too. A capture file stores the recorded frames so another tool can read them later. This lesson first prints them on the terminal.
tcpdump is the capture program. sudo lets it read the interface; type your Ubuntu password when asked. Nothing appears as you type the password. The option -i selects the interface named immediately after it. Here, the words tcp port 80 keep only web traffic; Capture filters and display filters explains them.
Use two Ubuntu terminal windows. In terminal 1, enter the named listening machine with netlab shell followed by its name. In terminal 2, enter laptop with netlab shell laptop. Check both prompts before typing anything else. Even when both shells name laptop, they are separate terminals.
Send while laptop listens
Section titled “Send while laptop listens”Start terminal 1’s listener first. Wait until it says listening on eth0. Then run terminal 2’s request. -sS makes curl print only the file, or an error if there is one.
learner@laptop:~$ sudo tcpdump -i eth0 tcp port 80[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes11:53:32.086501 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [S], seq 2220193723, win 64240, options [mss 1460,sackOK,TS val 2139665560 ecr 0,nop,wscale 10], length 0
11:53:32.086548 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [S.], seq 4044424118, ack 2220193724, win 65160, options [mss 1460,sackOK,TS val 2737861747 ecr 2139665560,nop,wscale 10], length 0
11:53:32.086557 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 1, win 63, options [nop,nop,TS val 2139665560 ecr 2737861747], length 0
11:53:32.086625 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 2139665560 ecr 2737861747], length 83: HTTP: GET /hello.txt HTTP/1.1
11:53:32.086647 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [.], ack 84, win 64, options [nop,nop,TS val 2737861747 ecr 2139665560], length 0
11:53:32.089034 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 2737861750 ecr 2139665560], length 172: HTTP: HTTP/1.0 200 OK
11:53:32.089062 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 173, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0
11:53:32.089085 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 2737861750 ecr 2139665563], length 16: HTTP
11:53:32.089103 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 189, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0
11:53:32.089136 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 2737861750 ecr 2139665563], length 0
11:53:32.089137 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0
11:53:32.089167 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [.], ack 85, win 64, options [nop,nop,TS val 2737861750 ecr 2139665563], length 0
11:53:32.089184 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 190, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0^C13 packets captured
13 packets received by filter
0 packets dropped by kernellearner@laptop:~$ Steps (10)
- Type
sudo tcpdump -i eth0 tcp port 80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - Terminal 2 on laptop finished sending. Return to terminal 1 and press Ctrl+C to stop listening.
- Output:
11:53:32.086501 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [S], seq 2220193723, win 64240, options [mss 1460,sackOK,TS val 2139665560 ecr 0,nop,wscale 10], length 0 11:53:32.086548 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [S.], seq 4044424118, ack 2220193724, win 65160, options [mss 1460,sackOK,TS val 2737861747 ecr 2139665560,nop,wscale 10], length 0 11:53:32.086557 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 1, win 63, options [nop,nop,TS val 2139665560 ecr 2737861747], length 0 11:53:32.086625 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 2139665560 ecr 2737861747], length 83: HTTP: GET /hello.txt HTTP/1.1 11:53:32.086647 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [.], ack 84, win 64, options [nop,nop,TS val 2737861747 ecr 2139665560], length 0 11:53:32.089034 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 2737861750 ecr 2139665560], length 172: HTTP: HTTP/1.0 200 OK 11:53:32.089062 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 173, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0 11:53:32.089085 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 2737861750 ecr 2139665563], length 16: HTTP 11:53:32.089103 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 189, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0 11:53:32.089136 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 2737861750 ecr 2139665563], length 0 11:53:32.089137 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [F.], seq 84, ack 189, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0 11:53:32.089167 IP 10.77.20.80.http > 10.77.10.10.58908: Flags [.], ack 85, win 64, options [nop,nop,TS val 2737861750 ecr 2139665563], length 0 11:53:32.089184 IP 10.77.10.10.58908 > 10.77.20.80.http: Flags [.], ack 190, win 63, options [nop,nop,TS val 2139665563 ecr 2737861750], length 0 - Press Ctrl + C
- Output:
13 packets captured 13 packets received by filter 0 packets dropped by kernel
learner@laptop:~$ curl -sS http://10.77.20.80/hello.txtHello from web.learner@laptop:~$ Steps (3)
- Type
curl -sS http://10.77.20.80/hello.txt - Press Enter
- Output:
Hello from web.
Return to terminal 1 and press Ctrl+C to stop. Lines appeared. Read only the packets captured summary for now. Do not try to decode every number on a line. The sender’s own interface sees the exchange.
Send again while phone listens
Section titled “Send again while phone listens”Leave the first machine shell with exit. In terminal 1, enter phone. Keep terminal 2 on laptop. Start the listener, send the same request, and stop the listener with Ctrl+C.
learner@phone:~$ sudo tcpdump -i eth0 tcp port 80[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes^C0 packets captured
0 packets received by filter
0 packets dropped by kernellearner@phone:~$ Steps (9)
- Type
sudo tcpdump -i eth0 tcp port 80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - Terminal 2 on laptop finished sending. Return to terminal 1 and press Ctrl+C to stop listening.
- Press Ctrl + C
- Output:
0 packets captured 0 packets received by filter 0 packets dropped by kernel
learner@laptop:~$ curl -sS http://10.77.20.80/hello.txtHello from web.learner@laptop:~$ Steps (3)
- Type
curl -sS http://10.77.20.80/hello.txt - Press Enter
- Output:
Hello from web.
The summary says 0 packets captured. The request still returned the file. Listening on another device attached to the switch did not reveal this exchange.
Send again while router listens
Section titled “Send again while router listens”Enter router in terminal 1. Its site interface is eth1, rather than its home interface eth0. Run the listener there, repeat the request from terminal 2, then stop listening.
learner@router:~$ sudo tcpdump -i eth1 tcp port 80[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes11:54:51.036876 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [S], seq 222078939, win 64240, options [mss 1460,sackOK,TS val 1743337789 ecr 0,nop,wscale 10], length 0
11:54:51.036905 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [S.], seq 1390939080, ack 222078940, win 65160, options [mss 1460,sackOK,TS val 3418005906 ecr 1743337789,nop,wscale 10], length 0
11:54:51.036915 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [.], ack 1, win 63, options [nop,nop,TS val 1743337790 ecr 3418005906], length 0
11:54:51.036966 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1743337790 ecr 3418005906], length 83: HTTP: GET /hello.txt HTTP/1.1
11:54:51.036971 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [.], ack 84, win 64, options [nop,nop,TS val 3418005906 ecr 1743337790], length 0
11:54:51.039071 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3418005908 ecr 1743337790], length 172: HTTP: HTTP/1.0 200 OK
11:54:51.039116 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [.], ack 173, win 63, options [nop,nop,TS val 1743337792 ecr 3418005908], length 0
11:54:51.039141 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3418005908 ecr 1743337792], length 16: HTTP
11:54:51.039145 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [.], ack 189, win 63, options [nop,nop,TS val 1743337792 ecr 3418005908], length 0
11:54:51.039167 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3418005908 ecr 1743337792], length 0
11:54:51.039283 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [F.], seq 84, ack 190, win 63, options [nop,nop,TS val 1743337792 ecr 3418005908], length 0
11:54:51.039354 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [.], ack 85, win 64, options [nop,nop,TS val 3418005908 ecr 1743337792], length 0^C12 packets captured
12 packets received by filter
0 packets dropped by kernellearner@router:~$ Steps (10)
- Type
sudo tcpdump -i eth1 tcp port 80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes - Terminal 2 on laptop finished sending. Return to terminal 1 and press Ctrl+C to stop listening.
- Output:
11:54:51.036876 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [S], seq 222078939, win 64240, options [mss 1460,sackOK,TS val 1743337789 ecr 0,nop,wscale 10], length 0 11:54:51.036905 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [S.], seq 1390939080, ack 222078940, win 65160, options [mss 1460,sackOK,TS val 3418005906 ecr 1743337789,nop,wscale 10], length 0 11:54:51.036915 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [.], ack 1, win 63, options [nop,nop,TS val 1743337790 ecr 3418005906], length 0 11:54:51.036966 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [P.], seq 1:84, ack 1, win 63, options [nop,nop,TS val 1743337790 ecr 3418005906], length 83: HTTP: GET /hello.txt HTTP/1.1 11:54:51.036971 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [.], ack 84, win 64, options [nop,nop,TS val 3418005906 ecr 1743337790], length 0 11:54:51.039071 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [P.], seq 1:173, ack 84, win 64, options [nop,nop,TS val 3418005908 ecr 1743337790], length 172: HTTP: HTTP/1.0 200 OK 11:54:51.039116 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [.], ack 173, win 63, options [nop,nop,TS val 1743337792 ecr 3418005908], length 0 11:54:51.039141 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [P.], seq 173:189, ack 84, win 64, options [nop,nop,TS val 3418005908 ecr 1743337792], length 16: HTTP 11:54:51.039145 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [.], ack 189, win 63, options [nop,nop,TS val 1743337792 ecr 3418005908], length 0 11:54:51.039167 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [F.], seq 189, ack 84, win 64, options [nop,nop,TS val 3418005908 ecr 1743337792], length 0 11:54:51.039283 IP 10.77.10.10.55398 > 10.77.20.80.http: Flags [F.], seq 84, ack 190, win 63, options [nop,nop,TS val 1743337792 ecr 3418005908], length 0 11:54:51.039354 IP 10.77.20.80.http > 10.77.10.10.55398: Flags [.], ack 85, win 64, options [nop,nop,TS val 3418005908 ecr 1743337792], length 0 - Press Ctrl + C
- Output:
12 packets captured 12 packets received by filter 0 packets dropped by kernel
learner@laptop:~$ curl -sS http://10.77.20.80/hello.txtHello from web.learner@laptop:~$ Steps (3)
- Type
curl -sS http://10.77.20.80/hello.txt - Press Enter
- Output:
Hello from web.
Check your answer
phone saw nothing matching the request. laptop and router saw traffic. The switch delivered these frames along the path they needed. Being on the same network did not make phone part of that path.
The drawing follows the request toward web; the response travels back. It leaves out individual headers. Before trusting an empty capture, ask which interface it observed and whether the exchange would pass there.
Mistakes to recognize
Section titled “Mistakes to recognize”“A capture shows everything on the network.” This capture shows what reached its capture point and matched its filter. The successful request alongside the empty phone capture is the counterexample.
“Listening lets me read everyone’s traffic.” The three locations produced different observations. Capturing someone else’s traffic can be illegal and can violate workplace rules. Keep course experiments inside the closed lab; a readable message is not permission to collect it.
Good to know
Section titled “Good to know”The addresses stay numeric here, while port 80 is printed as http. In Reading a capture as text, -n keeps the port numeric too. These spellings describe the same traffic.
Try it yourself
Section titled “Try it yourself”Reverse the sender and listener. Keep terminal 1 on laptop, listening on eth0. Enter phone in terminal 2 and request the same file from web. Predict whether laptop will see matching frames before you send. Then stop listening and compare the result with your prediction.
Solution
learner@laptop:~$ sudo tcpdump -i eth0 tcp port 80[sudo] password for learner: tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes^C0 packets captured
0 packets received by filter
0 packets dropped by kernellearner@laptop:~$ Steps (9)
- Type
sudo tcpdump -i eth0 tcp port 80 - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes - Terminal 2 on phone finished sending. Return to terminal 1 and press Ctrl+C to stop listening.
- Press Ctrl + C
- Output:
0 packets captured 0 packets received by filter 0 packets dropped by kernel
learner@phone:~$ curl -sS http://10.77.20.80/hello.txtHello from web.learner@phone:~$ Steps (3)
- Type
curl -sS http://10.77.20.80/hello.txt - Press Enter
- Output:
Hello from web.
laptop:eth0 captures no matching frames. Phone’s request succeeds. The request travels from phone through the switch to router, without passing through laptop. The empty laptop capture does not mean the server failed.
Leave for later
Section titled “Leave for later”How switches learn and Unicast, broadcast, and flooding in Ethernet and Local Delivery explain the switch’s choices.
- Name the machine and interface before interpreting a capture.
- Start listening before sending the request.
- An empty capture does not prove no exchange happened elsewhere.
Next, Reading a capture as text makes one line readable.
Further reading
Section titled “Further reading”- Ubuntu: tcpdump manual, for interface selection and capture summaries.