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
Trigger phrases:
"implementing network traffic baselining"
"Build network traffic baselines from NetFlow/IPFIX data using Python pandas for "
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
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- Ingest NetFlow/IPFIX records from CSV or JSON exports
- Compute hourly and daily traffic volume distributions (bytes, packets, flows)
- Build per-source-IP baseline profiles with mean, median, standard deviation
- Calculate protocol and port distribution baselines
- Apply z-score anomaly detection to identify statistical outliers
- Flag flows exceeding IQR-based thresholds as potential anomalies
- 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.
When NOT to Use
- You need to test the implementation (use performing-* skills)
- Task is about configuring existing tools (use configuring-* skills)
- You need to analyze security events (use analyzing-* skills)
- Task is about building detection rules (use building-* skills)
- You don't have access to the target environment
- Task requires vendor-specific expertise (consult vendor docs)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Capturing traffic on networks without authorization or privacy considerations
- Leaving packet captures containing sensitive data unencrypted on disk
- Deploying inline blocking rules without testing for false positives first
Process
- Prepare — Gather requirements, verify prerequisites, set up environment
- Execute — Run implementing network traffic baselining workflow with configured parameters
- Verify — Validate output meets requirements, document results
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Captures verified as complete with no dropped packets
- Detection rules tested against known-benign traffic for false positive rate
- Alert thresholds validated and tuned to reduce noise
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: implementing-network-traffic-baselining3description: Use when build network traffic baselines from NetFlow/IPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly/daily traffic pattern profiling. Use when building network traffic baselines from netflow/ipfix data using python pandas.4license: Apache-2.05---678# Implementing Network Traffic Baselining910## Overview1112Network 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.131415## When to Use16**Trigger phrases:**17- "implementing network traffic baselining"18- "Build network traffic baselines from NetFlow/IPFIX data using Python pandas for "192021- When deploying or configuring implementing network traffic baselining capabilities in your environment22- When establishing security controls aligned to compliance requirements23- When building or improving security architecture for this domain24- When conducting security assessments that require this implementation2526## Prerequisites2728- NetFlow v5/v9 or IPFIX flow data exported as CSV or JSON29- Python 3.8+ with pandas and numpy libraries30- Historical flow data (minimum 7 days recommended for baseline)3132## Steps3334```python35# Example: IOC detection36import re3738IOC_PATTERNS = {39 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",40 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",41 "hash_md5": r"\b[a-f0-9]{32}\b",42 "hash_sha256": r"\b[a-f0-9]{64}\b",43}4445def extract_iocs(text: str) -> dict:46 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}47```48491. Ingest NetFlow/IPFIX records from CSV or JSON exports502. Compute hourly and daily traffic volume distributions (bytes, packets, flows)513. Build per-source-IP baseline profiles with mean, median, standard deviation524. Calculate protocol and port distribution baselines535. Apply z-score anomaly detection to identify statistical outliers546. Flag flows exceeding IQR-based thresholds as potential anomalies557. Generate baseline report with anomaly alerts5657## Expected Output5859JSON report containing traffic baselines (hourly/daily profiles), per-host statistics, detected anomalies with z-scores, and top talker rankings with deviation indicators.60## When NOT to Use6162- You need to test the implementation (use performing-* skills)63- Task is about configuring existing tools (use configuring-* skills)64- You need to analyze security events (use analyzing-* skills)65- Task is about building detection rules (use building-* skills)66- You don't have access to the target environment67- Task requires vendor-specific expertise (consult vendor docs)686970## Red Flags7172- Performing actions without explicit written authorization from the asset owner73- Testing against production systems without a defined scope and rules of engagement74- Capturing traffic on networks without authorization or privacy considerations75- Leaving packet captures containing sensitive data unencrypted on disk76- Deploying inline blocking rules without testing for false positives first7778## Process79801. **Prepare** — Gather requirements, verify prerequisites, set up environment811. **Execute** — Run implementing network traffic baselining workflow with configured parameters821. **Verify** — Validate output meets requirements, document results8384## Verification8586- All steps executed successfully against a test environment before production use87- Output documented with screenshots or logs demonstrating expected behavior88- Captures verified as complete with no dropped packets89- Detection rules tested against known-benign traffic for false positive rate90- Alert thresholds validated and tuned to reduce noise9192## Anti-Rationalization Table9394| Rationalization | Reality |95|---|---|96| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |97| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |98| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |