Analyze JSON Timing Output
In this step, we'll examine how Wireshark records timing information in JSON format. JSON (JavaScript Object Notation) is a lightweight data format that's easy for both humans to read and machines to parse. We'll combine the packet capture and filtering skills from previous steps to generate meaningful timing statistics.
Before we begin, let's make sure we're in the right directory. The project folder contains all necessary files and will keep our work organized:
cd ~/project
Now we'll generate timing data specifically for TCP packets. The --print-timers
flag tells Tshark to include timing information in its output, while -T json
formats it as JSON. We're saving this to a file for later analysis:
tshark -r /usr/share/wireshark/example_captures/http.pcap -Y "tcp" --print-timers -T json > tcp_timings.json
Let's take a quick look at the structure of our JSON output. The head
command shows us the first 20 lines, which helps us understand how the data is organized before we process it further:
head -20 tcp_timings.json
To work effectively with JSON data, we'll use jq
, a powerful command-line JSON processor. If you don't have it installed yet, this command will set it up:
sudo apt-get install -y jq
Now we can extract specific timing metrics. This command filters the JSON to show just the timer information for each packet, giving us a cleaner view of the timing data:
jq '.[].timers' tcp_timings.json | head -10
Finally, let's create a more focused summary that shows just the packet numbers and their corresponding processing times. This gives us a clear view of how long each packet took to process:
jq '.[].timers | {packet_number: .packet_num, processing_time: .processing_time}' tcp_timings.json | head -5