NETLEARN
Lesson 01Traffic Analysis

Python for Traffic Analysis

Reading a capture by hand does not scale past a few connections. Python turns packets into tables: read a pcap, select the fields you care about, group by conversation, and compute the numbers you would otherwise eyeball.

Layer
Tooling · packets become data
Reference
Scapy / PyShark / pandas
Steps
5
  1. 01read pcap
  2. 02select fields
  3. 03group
  4. 04compute
  5. 05export

One tap, one step. Net narrates that step for a moment, then waits for your next tap.

Common misunderstandings

  • Loading a multi-gigabyte pcap with rdpcap can exhaust memory. Stream it or filter it first with tshark.

Key notes

Scapy
Pure-Python packet library: read, craft, and dissect. Flexible but slower than compiled parsers.
pyarrow / pandas
Packets to rows to DataFrame is the standard pipeline shape for traffic analysis.
Five-tuple
The src/dst address, src/dst port, and protocol that name a flow.