Read a sample: 1. A Question Before a Capture
A user says, “The website is down.” You open a terminal, ready to investigate, but the report leaves several questions unanswered. Did the computer look up the site’s address? Did it try to connect? Did the remote system respond? Or did the connection work while the application returned an error?
Packet inspection can help you answer some of those questions. It lets you observe selected network traffic at a particular point and time. It does not automatically tell you what a user saw, what an application intended to do, or why a remote system behaved as it did.
That distinction is the foundation of this book. A useful capture begins not with a command, but with a question narrow enough that an observed packet—or a carefully qualified absence—can help answer it.
Consider these possible starting questions:
- Did the test machine send a DNS query when I requested a name?
- Did it receive a response from the resolver it contacted?
- Did it send a TCP connection request to the destination address?
- Did a response arrive after that request?
- Which endpoint did the test application actually contact?
Each question points toward a different slice of traffic. Each also has limits. Seeing a DNS response, for example, does not prove that the application used the answer successfully. Seeing a TCP connection established does not prove that a web page loaded.
In the chapters ahead, you will use tcpdump to capture and review traffic in manageable pieces. First, you need a method for deciding what to capture and how to interpret what you find.
Network applications exchange data across layers. A browser might resolve a name, open a connection, negotiate encryption, request a resource, receive a response, and render a page. A problem at any one of those stages can produce a similar report: “It does not work.”
A packet capture records network data visible to the capture point. Depending on where you capture, how you configure the tool, and what traffic is present, you may see individual packets, protocol fields, and sometimes portions of application data. You may also see only part of a conversation.
Imagine a capture on a test laptop shows this sequence:
1. The laptop sends a DNS query.
2. A resolver sends an answer.
3. The laptop sends a TCP connection request to an address in that answer.
4. The destination responds, and the TCP connection is established.
Those observations support a useful conclusion: at the capture point, name resolution and the initial TCP connection appeared to work for that attempt. They do not establish that the application received the content it wanted, accepted a certificate, authenticated successfully, or displayed anything useful.
The reverse is also important. If you do not see a DNS query, the name may already be cached, the application may be using an address directly, or the query may have traveled through a different resolver or interface. A capture that misses an expected packet is a prompt to investigate, not an automatic verdict.
Throughout this book, separate three statements:
- Observation: “The capture shows a TCP connection request leaving the test machine.”
- Interpretation: “The application appears to be attempting a connection to that endpoint.”
- Next question: “Does a response return on the same interface?”
Keeping those statements distinct makes your troubleshooting more accurate. It also makes your notes easier for someone else to review.
A broad complaint may contain several problems, or only one problem described imprecisely. Before capturing anything, record what you can reproduce and choose a single step to examine.
Suppose your practice application cannot reach example.com. A first question might be:
> When I ask the test machine to resolve example.com, does it send a DNS query and receive a response?
That question identifies an action, a system, and a kind of traffic. It also gives you a stopping point: after a short lookup attempt, you can review what appeared rather than collecting traffic indefinitely.
A second question might be:
> When I try to connect to the test web service, does the test machine send a TCP connection request, and does anything respond?
This question moves past name resolution. You may already know the destination address, or you may have learned it during a separate lookup. Either way, the capture should be designed around the connection attempt rather than every packet on the machine.
A third question can investigate a difference between expectation and observation:
> Is the test application contacting the address I expected?
The answer might reveal that the application selected another address or used a proxy. It might also show that your expectation was based on outdated information. The packet record tells you what was visible at the capture point; your configuration and application logs provide other pieces of the explanation.
Good questions need not predict the answer. They need to define what evidence would be relevant.
Packet inspection can expose information that people did not intend to share with you. Even a capture intended to answer a simple connectivity question may include names, addresses, identifiers, or application data. Permission to use a network or administer a computer does not necessarily mean you are authorized to collect all traffic visible there.
For the exercises in this book, use a Linux test system and traffic that you generate or are explicitly permitted to inspect. A virtual machine, a spare computer, or a…