implementing-network-traffic-baselining skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Builds network traffic baselines from NetFlow/IPFIX CSV or JSON exports using Python Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/implementing-network-traffic-baselining/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill implementing-network-traffic-baselining, or copy the skill folder into ~/.claude/skills/implementing-network-traffic-baselining/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/implementing-network-traffic-baselining/SKILL.md

SKILL.md (verbatim)

name: implementing-network-traffic-baselining
description: Builds network traffic baselines from NetFlow/IPFIX CSV or JSON exports using Python
  pandas, computing hourly/daily volume distributions, per-host and protocol/port
  statistics, and top-talker profiles, then flags outliers via z-score and IQR anomaly
  detection. Use when a SOC analyst needs to establish normal traffic patterns and
  surface deviations such as data exfiltration spikes, beaconing, or unusual port
  usage from historical flow data.
domain: cybersecurity
subdomain: network-security
tags:
- netflow
- ipfix
- traffic-analysis
- baselining
- anomaly-detection
- pandas
- network-monitoring
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- PR.IR-01
- DE.CM-01
- ID.AM-03
- PR.DS-02
mitre_attack:
- T1046
- T1040
- T1557
- T1071

Implementing Network Traffic Baselining

Overview

Network traffic baselining establishes normal communication patterns by analyzing historical NetFlow/IPFIX data to create statistical profiles of expected behavior. This skill uses Python pandas to compute hourly and daily traffic distributions, per-host byte/packet counts, protocol ratios, and top-N talker profiles. Anomalies are detected using z-score thresholds and IQR (interquartile range) outlier methods, enabling SOC analysts to identify deviations such as data exfiltration spikes, beaconing patterns, and unusual port usage.

When to Use

  • When deploying or configuring implementing network traffic baselining capabilities in your environment
  • When establishing security controls aligned to compliance requirements
  • When building or improving security architecture for this domain
  • When conducting security assessments that require this implementation

Prerequisites

  • NetFlow v5/v9 or IPFIX flow data exported as CSV or JSON
  • Python 3.8+ with pandas and numpy libraries
  • Historical flow data (minimum 7 days recommended for baseline)

Steps

  1. Ingest NetFlow/IPFIX records from CSV or JSON exports
  2. Compute hourly and daily traffic volume distributions (bytes, packets, flows)
  3. Build per-source-IP baseline profiles with mean, median, standard deviation
  4. Calculate protocol and port distribution baselines
  5. Apply z-score anomaly detection to identify statistical outliers
  6. Flag flows exceeding IQR-based thresholds as potential anomalies
  7. Generate baseline report with anomaly alerts

Expected Output

JSON report containing traffic baselines (hourly/daily profiles), per-host statistics, detected anomalies with z-scores, and top talker rankings with deviation indicators.

Other files in this skill

references/api-reference.md (verbatim)

Network Traffic Baselining API Reference

NetFlow/IPFIX CSV Format

Expected Columns

timestamp,src_ip,dst_ip,src_port,dst_port,protocol,bytes,packets
2024-01-15T08:30:00Z,10.0.1.5,203.0.113.10,54321,443,6,15234,42

Alternative Column Names (auto-mapped)

ts -> timestamp    sa -> src_ip     da -> dst_ip
sp -> src_port     dp -> dst_port   pr -> protocol
ibyt -> bytes      ipkt -> packets

Protocol Numbers

Number Protocol
1 ICMP
6 TCP
17 UDP

Pandas Analysis Functions

Hourly Aggregation

df["hour"] = df["timestamp"].dt.hour
hourly = df.groupby("hour").agg(
    total_bytes=("bytes", "sum"),
    total_packets=("packets", "sum"),
    flow_count=("bytes", "count"),
)

Z-Score Anomaly Detection

mean = host_stats["total_bytes"].mean()
std = host_stats["total_bytes"].std()
host_stats["zscore"] = (host_stats["total_bytes"] - mean) / std
anomalies = host_stats[host_stats["zscore"].abs() >= 3.0]

IQR Outlier Detection

q1 = series.quantile(0.25)
q3 = series.quantile(0.75)
iqr = q3 - q1
outliers = series[(series < q1 - 1.5 * iqr) | (series > q3 + 1.5 * iqr)]

NetFlow Export Tools

nfdump CSV Export

nfdump -r nfcapd.202401 -o csv > flows.csv

SiLK rwcut Export

rwcut --fields=sIP,dIP,sPort,dPort,protocol,bytes,packets,sTime flows.rw > flows.csv

Elastic NetFlow to CSV

GET netflow-*/_search
{ "size": 10000, "query": { "range": { "@timestamp": { "gte": "now-7d" } } } }

CLI Usage

python agent.py --netflow-csv flows.csv --output baseline.json
python agent.py --netflow-csv flows.csv --zscore-threshold 2.5 --scan-threshold 30

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.