Note: CICFlowMeter Compatible output is only valid till v0.0.1. If you need compatibility, use version v0.0.1.
TriFlowMeter is a high-performance network flow analyzer that extracts statistical features from network traffic for machine learning applications, intrusion detection, and network behavior analysis. It processes PCAP files or captures live network traffic and generates comprehensive flow-level statistics in CSV format.
TriFlowMeter converts raw packet data into bidirectional network flows with rich statistical features. Each flow represents a communication session between two endpoints, characterized by the 5-tuple: source IP, destination IP, source port, destination port, and protocol.
- High-Performance C++17: Optimized with
-O3,-march=native, and link-time optimization - Dual Mode Operation: Process PCAP files (offline) or capture live network traffic
- 60-Column CSV Output: Extracts 60 features per flow covering timing, size, flags, ratios, and behavioral metrics
- Bidirectional Flow Analysis: Tracks forward and backward packet statistics independently
- Real-Time Dashboard: Live terminal UI showing packet counts, flow progress, and uptime
- Streaming Output:
--stdoutmode for piping into downstream tools - IPv4 + IPv6 + L2TP: Handles IPv4, IPv6, and L2TP/VPN-encapsulated packets
- Active/Idle Detection: Tracks activity periods within flows using configurable timeouts
- Java-Compatible Formatting: CSV numeric output matches CICFlowMeter conventions
- Sudo-Aware: Automatically restores file ownership when running under
sudo
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
See the LICENSE file for the full license text.
- CMake 3.16 or higher
- C++17 compatible compiler (GCC 7+, Clang 6+, MSVC 2017+)
- libpcap development files
Linux/Ubuntu:
sudo apt-get install build-essential cmake libpcap-devmacOS:
brew install cmake libpcapWindows:
To build natively without bloated IDEs:
- Install the Npcap Driver AND download the Npcap SDK
.zipfile. Extract the SDK toC:\npcap-sdk. - Install a lightweight compiler and CMake via MSYS2. Once installed, open the MSYS2 MINGW64 terminal and run:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake make
- Important: If you intend to run the compiled
.exefrom a standard Windows PowerShell or Command Prompt rather than the MSYS2 terminal, you must addC:\msys64\mingw64\binto your Windows Environment VariablesPath. Otherwise, Windows will silently fail to load the required.dllfiles at runtime.
mkdir build
cd build
# On Windows, you MUST tell CMake where you extracted the SDK:
cmake -G "MinGW Makefiles" .. -DPCAP_INCLUDE_DIR="C:/npcap-sdk/Include" -DPCAP_LIBRARY="C:/npcap-sdk/Lib/x64/wpcap.lib" -DPACKET_LIBRARY="C:/npcap-sdk/Lib/x64/Packet.lib"
# On Linux/macOS, you can just run:
cmake ..
# Finally
cmake --build . -j 4For optimized builds (default is Release with native optimizations):
cmake -DCMAKE_BUILD_TYPE=Release -DTRIFLOWMETER_ENABLE_NATIVE_OPT=ON ..
cmake --build . -j 4To disable CPU-specific optimizations (for portable binaries):
cmake -DCMAKE_BUILD_TYPE=Release -DTRIFLOWMETER_ENABLE_NATIVE_OPT=OFF ..# Output to auto-named file (input_Flow.csv)
./triflowmeter input.pcap
# Output to a specific file
./triflowmeter input.pcap output.csv
# Output to a directory (creates dir/input_flows.csv)
./triflowmeter input.pcap results/# Capture from interface, output to auto-named file
sudo ./triflowmeter --live eth0
# Capture with explicit output path
sudo ./triflowmeter --live eth0 live_flows.csv
# Capture with a label for all flows
sudo ./triflowmeter --live eth0 output.csv --label Benign# Pipe CSV rows to another tool
./triflowmeter input.pcap --stdout | python3 classify.py
# Live capture to stdout
sudo ./triflowmeter --live eth0 --stdoutUsage:
triflowmeter <pcap_file> [output_path_or_directory] [options]
triflowmeter --live <interface> [output_path_or_directory] [options]
Options:
--flow-timeout <sec> Flow timeout in seconds (default: 120)
--activity-timeout <sec> Activity timeout in seconds (default: 5)
--label <label> Label for all flows (default: Needs_Label)
--stdout Write CSV header/rows to stdout
-h, --help Show this help
| Option | Description | Default |
|---|---|---|
--live <interface> |
Capture from a live network interface (requires root) | — |
--stdout |
Write CSV to stdout instead of a file | Off |
--flow-timeout <sec> |
Maximum duration of a flow before it is split | 120 |
--activity-timeout <sec> |
Idle threshold for active/idle period detection | 5 |
--label <label> |
Ground truth label written to the Label column | Needs_Label |
Note:
--stdoutand an output path cannot be used together.
TriFlowMeter generates CSV files with 60 columns per flow:
| Category | Columns | Count |
|---|---|---|
| Flow Metadata | Flow ID, Src/Dst IP, Ports, Protocol, Timestamps, Duration | 9 |
| Base Volumetrics | Fwd/Bwd Packets | 2 |
| Rates & Ratios | Flow Packets/s, Payload Bytes/s, Payload Ratio, Count Ratio, Header Ratio | 5 |
| Packet Size Profiles | Fwd/Bwd/Total Min, Max, Mean, Std | 12 |
| Inter-Arrival Times | Fwd/Bwd/Flow IAT Min, Max, Mean, Std | 12 |
| TCP Flag Rates | SYN, ACK, FIN, RST, PSH, URG Rates | 6 |
| TCP/IP Mechanics | Init Window Sizes, Min Segment Size, Initial TTL | 5 |
| Connection States | Active/Idle Min, Max, Mean, Std | 8 |
| Label | Ground truth label | 1 |
Note: For CICFlowMeter-compatible CSV output, use the v0.0.1 tag/release.
See docs/FEATURES.md for detailed feature descriptions with exact CSV header names.
TriFlowMeter employs a modular pipeline architecture:
PacketReader → PacketDecoders → FlowGenerator → CSVWriter
│
BasicFlow (per-flow statistics)
│
LiveDashboard (terminal UI)
- PacketReader: libpcap-based reader with live/offline modes
- PacketDecoders: Extracts IPv4/IPv6/TCP/UDP/L2TP headers and metadata
- FlowGenerator: Bidirectional flow aggregation with timeout-based splitting
- BasicFlow: Real-time statistical computation via Welford's algorithm
- CSVWriter: 60-column streaming CSV serialization
- LiveDashboard: Real-time terminal dashboard with packet/flow statistics
See docs/ARCHITECTURE.md for detailed architectural documentation.
| Protocol | Status |
|---|---|
| IPv4 (TCP, UDP) | ✅ Fully supported |
| IPv6 (TCP, UDP) | ✅ Fully supported |
| L2TP / VPN tunnels | ✅ Decapsulated and decoded |
| ARP | ❌ Disabled (declared but not active) |
| ICMP | ❌ Not supported |
- Network Security: Intrusion detection system (IDS) feature generation
- Traffic Classification: Application identification and QoS
- Anomaly Detection: Behavioral analysis and outlier detection
- ML Training: Dataset generation for supervised/unsupervised learning
- Network Forensics: Post-incident analysis and investigation
- Streaming architecture with bounded memory usage
- Single-pass statistics (Welford's) — no per-packet storage
- FNV-1a hash-based flow lookup in O(1) average time
- Optional
-march=nativefor CPU-specific optimizations - Link-time optimization (
-flto) in Release builds
Contributions are welcome! Please ensure:
- Code follows existing style conventions
- New features include appropriate tests
- Documentation is updated accordingly
- Commits are signed with GPL compliance
If you use TriFlowMeter in academic research, please cite:
@software{triflowmeter,
title={TriFlowMeter: High-Performance Network Flow Analyzer},
author={Chowdhury, Somnath},
year={2026},
url={https://github.com/SomnathChW/TriFlowMeter},
license={GPL-3.0}
}TriFlowMeter is inspired by CICFlowMeter and implements bidirectional flow analysis with performance optimizations and enhanced feature extraction.
For issues, questions, or contributions:
- Open an issue on the project repository
- Check existing documentation in ARCHITECTURE.md and FEATURES.md
- Review the source code documentation
License Notice: This software is distributed under GPL-3.0. Any derivative work must also be released under GPL-3.0 or a compatible license.