Read File with -r capture.pcap
In this step, you will learn how to read a packet capture file using Wireshark's command-line tool tshark
with the -r
option. PCAP files contain raw network traffic data captured from a network interface, and tshark
helps us analyze this data without using the graphical Wireshark interface.
First, let's navigate to the correct directory where our capture file is stored. This ensures we can access the file without specifying full paths:
cd ~/project
The -r
option (short for "read") tells tshark
to read packets from a specified capture file rather than live network traffic. In our case, we'll analyze a pre-prepared sample file named capture.pcap
that contains typical network communication data.
To display the basic packet information from our capture file, execute:
tshark -r capture.pcap
This command will show you a sequential list of all packets in the file, with each line representing one network packet. The output includes several important fields:
- Packet numbers (showing the order of capture)
- Timestamps (recording when each packet was captured)
- Source and destination IP addresses
- Protocol types (like TCP, UDP, or ICMP)
- Packet sizes in bytes
- Brief descriptions of the packet contents
Here's an example of what the output might look like for a TCP connection establishment:
1 0.000000 192.168.1.1 → 192.168.1.2 TCP 66 443 → 34512 [SYN] Seq=0 Win=64240 Len=0
2 0.000123 192.168.1.2 → 192.168.1.1 TCP 66 34512 → 443 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0
In this example, we see two packets: the first is a TCP SYN packet initiating a connection from 192.168.1.1 to 192.168.1.2 on port 443, and the second is the responding SYN-ACK packet. The -r
option is essential for examining previously captured network traffic and forms the foundation for more advanced packet analysis techniques.