Skip to content
Agentmart
Submit a tool

pcap-analysis

Guidance for analyzing network packet captures (PCAP files) and computing network statistics using Python, with tested utility functions.

Skill by benchflow-ai

IndexedApache-2.0★ 1,870
Write a review

Chalk Labs

Need help deploying pcap-analysis?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/benchflow-ai-pcap-analysis

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Guidance for analyzing network packet captures (PCAP files) and computing network statistics using Python, with tested utility functions.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Python package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/pcap-analysis

What's inside

Skill name
pcap-analysis
Description
Guidance for analyzing network packet captures (PCAP files) and computing network statistics using Python, with tested utility functions.
License
Apache-2.0
Instructions
481 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts

Files (2)

  • SKILL.md
  • pcap_utils.py

SKILL.md (first lines)

# PCAP Network Analysis Guide

This skill provides guidance for analyzing network packet captures (PCAP files) and computing network statistics using Python.

## Quick Start: Using the Helper Module

A utility module (`pcap_utils.py`) is available in this folder with **tested, correct implementations** of common analysis functions. It provides some utility functions to count intermediate results and help you come to some of the conclusion faster. **Use these functions directly** rather than reimplementing the logic yourself, as they handle edge cases correctly.

```python
# RECOMMENDED: Import and use the helper functions
import sys
sys.path.insert(0, '/root/skills/pcap-analysis')  # Add skill folder to path
from pcap_utils import (
    load_packets, split_by_protocol, graph_metrics,
    detect_port_scan, detect_dos_pattern, detect_beaconing,
    port_counters, ip_counters, iat_stats, flow_metrics,
    packets_per_minute_stats, producer_consumer_counts, shannon_entropy
)

packets = load_packets('/root/packets.pcap')
parts = split_by_protocol(packets)

# Graph metrics (indegree/outdegree count UNIQUE IPs, not packets!)
g = graph_metrics(parts['ip'])
print(g['max_indegree'], g['max_outdegree'])

# Detection functions use STRICT thresholds that must ALL be met
print(detect_port_scan(parts['tcp']))      # Returns True/False
print(detect_dos_pattern(ppm_avg, ppm_max)) # Returns True/False
print(detect_beaconing(iat_cv))             # Returns True/False
```

The helper functions use **specific detection thresholds** (documented below) that are calibrated for accurate results. Implementing your own logic with different thresholds will likely produce incorrect results.

## Overview

Network traffic analysis involves reading packet captures and computing various statistics:
- Basic counts (packets, bytes, protocols)
- Distribution analysis (entropy)
- Graph/topology metrics
- Temporal patterns
- Flow-level analysis

## Reading PCAP Files with Scapy

Scapy is the standard library for packet manipulation in Python:

```python
from scapy.all import rdpcap, IP, TCP, UDP, ICMP, ARP

# Load all packets
packets = rdpcap('packets.pcap')

# Filter by protocol
ip_packets = [p for p in packets if IP in p]
tcp_packets = [p for p in packets if TCP in p]
udp_packets = [p for p in packets if UDP in p]
```

## Basic Statistics

### Packet and Byte Counts

```python
total_packets = len(packets)
total_bytes = sum(len(p) for p in packets)
avg_packet_size = total_bytes / total_packets
```

### Protocol Distribution

```python
tcp_count = len([p for p in packets if TCP in p])
udp_count = len([p for p in packets if UDP in p])
icmp_count = len([p for p in packets if ICMP in p])
arp_count = len([p for p in packets if ARP in p])
```

## Entropy Calculation

Shannon entropy measures the "randomness" of a distribution:

```python
import math
from collections import Counter

def shannon_entropy(counter):
    """
    Calculate Shannon entropy: H(X) = -Σ p(x) log₂(p(x))

    Low entropy: traffic focused on few items (normal)
    High entropy: traffic spread across many items (scanning)
    """
    total = sum(counter.values())
    if total == 0:
        return 0.0

    entropy = 0.0
    for count in counter.values():
        if count > 0:
            p = count / total
            entropy -= p * math.log2(p)
    return entropy

# Example: Destination port entropy
dst_ports = Counter()
for pkt in tcp_packets:
    dst_ports[pkt[TCP].dport] += 1
for pkt in udp_packets:
    if IP in pkt:
        dst_ports[pkt[UDP].dport] += 1

port_entropy = shannon_entropy(dst_ports)
```

## Graph/Topology Metrics

**IMPORTANT: Use `graph_metrics()` from pcap_utils.py for correct results!**

From benchflow-ai/skillsbench, Apache-2.0.

More from benchflow-ai/skillsbench

Signals

Stars
1,870
Forks
372
Open issues
50
Last commit (this folder)
Jan 21, 2026 (9 months ago)
Last release
Jun 14, 2026 (4 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from benchflow-ai

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get pcap-analysis running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying pcap-analysis?

CallGet help
Cite this page

pcap-analysis skill. Agent Mart. https://agentmart.dev/skills/benchflow-ai-pcap-analysis (last updated 2026-10-24)