TShark field extraction
Extract reproducible fields offline
TShark reads saved captures and exposes protocol fields in machine-readable output. A reproducible extraction specifies the input file hash, analyzer version, profile, filter, field names, column order and expected rows. Here we use small generated Ethernet/IPv4/TCP files; no capture interface is opened. Use a maintained analyzer in an isolated environment, with bounded input size and no real customer data. A capture file is untrusted parser input.
Check the installed tool and fields
In an approved offline lab, run tshark -v and tshark -G fields to record the version and confirm fields. The online field reference lists tcp.seq_raw for versions 3.2.0 through 4.6.9 at review time; use an installed supported release rather than assuming this upper bound is the latest. tcp.seq may be relative to a flow; raw sequence values are more useful when comparing separate captures. tcp.stream is a local analyzer index, not a shared connection ID.
Select payload-bearing TCP segments
From the packet-capture fixture directory, the following static command reads only the saved A file. -n avoids name resolution, -r selects the file, -Y selects displayed packets, -T fields selects field output, and repeated -e options specify columns. -E chooses formatting and the first occurrence of each field.
tshark -n -r chapter-43-point-a.pcap -Y "tcp.len > 0" -T fields -e frame.number -e tcp.seq_raw -e tcp.len -E header=y -E separator=, -E occurrence=fExpected rows derived independently from the generated bytes (TShark not executed here):
frame.number,tcp.seq_raw,tcp.len4,1001,45,1005,4Avoid silent data loss in exports
A display filter does not change the original capture. A capture filter applies while collecting traffic and can permanently exclude packets from the saved evidence. Multiple field occurrences are possible in encapsulated traffic, so selecting the first may hide an inner header. Choose and document the intended layer; for general exports use structured output or explicit occurrence/aggregation and a parser that handles quoting. An absent field is not numeric zero. Frame numbers differ across files when frames are omitted. Retain the original bytes and record the filter with exported data.
Compare the second file
Point B has one payload-bearing segment, sequence 1001 and length 4. The absence of sequence 1005 in this export is expected because the fixture excludes its record. In the complete B file, the later ACK still acknowledges 1009. Do not equate filtered row count with a network loss rate. In a real lab, check the exact output and exit status; if field names or values differ, record version and preferences instead of changing expected results to force a pass.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
TShark field extraction Quiz
Interpret synthetic trace evidence within its limits.
Which TShark option selects a saved file?
Which field gives raw TCP sequence numbers?
What is the expected number of payload rows in point A?
A field is absent from an exported row. How should it be represented?
Why record the analyzer version and profile?