Reading network traffic
Unit 5 of 5 in Networking fundamentals.
You will be able to capture a small amount of traffic on your own machine, filter it, and say what encryption does and does not hide.
Lesson
What a capture is
A packet capture is a record of the packets that crossed a network interface. The tcpdump tool prints a description of the contents of packets on an interface that match an expression, each preceded by a time stamp, and it can also save the packets to a file for later analysis. Wireshark does the same job with a graphical view.
Only capture on networks and machines you own or have written permission to test. The labs in this unit use your own machine.
Two kinds of filter
Filters keep a capture useful. A capture filter limits what is recorded in the first place, and Wireshark writes capture filters in the libpcap filter language that tcpdump also uses. A display filter works afterwards: Wireshark provides a display filter language that lets you control precisely which of the recorded packets are shown.
A good habit is to capture narrowly, then filter the display further. A narrow capture is smaller and holds less that you did not mean to collect.
What you can and cannot see
The addresses in each datagram's header are what the network uses to deliver it, so a capture shows who talked to whom. When a connection uses TLS, the data after the handshake is visible only to the two endpoints, and an attacker cannot change it without being detected. TLS does not hide how much data is sent.
So a capture of an HTTPS connection shows the two addresses, the timing and the size of what moved, but not the page. Plain protocols such as old-style HTTP, in contrast, show their content to anyone who can capture the traffic. That contrast is the strongest argument for encrypting everything.
Reading with a question in mind
Do not scroll through packets. Start with a question, such as which address did this machine talk to first, or what was the first thing it asked DNS, then filter to the packets that answer it. This is the same method you will use later on logs and incident evidence.
Key points
- A capture records packets on an interface; tcpdump and Wireshark both read them.
- Capture filters limit what is recorded; display filters limit what is shown.
- Headers show who talked to whom; TLS hides content but not size.
- Capture only on networks you own or may test, and start with a question.
Sources
- tcpdump(1) manual page
- Wireshark User's Guide: Filtering while capturing
- Wireshark User's Guide: Building display filter expressions
- RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3
- RFC 791: Internet Protocol
Practice in the labs
Capture a little harmless traffic on your own machine, filter it, then look inside a TLS handshake.
- Capture and read your first packets with Wireshark: You install Wireshark, capture a page load on your own interface and read your first packets.
- Capture and read packets from the command line with tcpdump: You do the same from the command line, which is how you capture on a server with no screen.
- Watch a TLS 1.3 handshake happen in Wireshark: You see what stays visible and what does not once a connection is encrypted.
Knowledge check
- What is the difference between a capture filter and a display filter? Answer: A capture filter limits what is recorded; a display filter limits what is shown afterwards. Wireshark capture filters limit the capture to matching packets; display filters control which captured packets are displayed.
- You capture an HTTPS connection. What can you see? Answer: The addresses, timing and size, but not the content. Header addresses are visible, TLS keeps the data after the handshake visible only to the endpoints, and TLS does not hide the length of the data (RFC 8446).
- When is it acceptable to capture traffic? Answer: Only on networks and machines you own or have written permission to test. Capturing other people's traffic without permission is not acceptable; the labs use your own machine so you stay on the right side of that line.
Back to the syllabus or see all classes.