NetGauze PCAP Decoder
A Rust library and CLI utility to decode network protocols (BGP, BMP, NetFlow/IPFIX, UDP-Notif) from PCAP files and convert them to JSON Lines format.
Features
- Multiple Protocol Support: Decode BGP, BMP, NetFlow/IPFIX, and UDP-Notif protocols
- PCAP Processing: Read packets from PCAP files with configurable filtering
- JSON Lines Output: Structured JSON output
- Dual Interface: Use as both a library and command-line tool
- Port Filtering: Filter packets by destination ports
- Flexible Output: Write to file or stdout
Installation
As a Library
Add this to your Cargo.toml:
[]
= "0.7.0"
As a CLI Tool
Or build from source:
CLI Usage
Arguments
--input <INPUT>- Input PCAP file path--protocol <PROTOCOL>- Protocol to decode:bgp,bmp,flow, orudp-notif--ports <PORTS>- Destination ports to filter (comma-separated, e.g.,179,180)
Options
--output <OUTPUT>- Output JSON Lines file path (defaults to stdout)--input-count <COUNT>- Maximum number of frame to process--show-frame-numbers- Include frame numbers in output--help- Show help information
Examples
Decode BGP packets from a PCAP file:
Decode BMP packets and save to file:
Decode NetFlow packets with packet limit:
Decode UDP-Notif packets from multiple ports:
Library Usage
The library provides a simple API for programmatic PCAP processing:
Basic Example
use ;
use PathBuf;
Protocol Handlers
The library provides handlers for different protocols:
use ;
// BGP Handler
let bgp_handler = new;
// BMP Handler
let bmp_handler = new;
// NetFlow/IPFIX Handler
let flow_handler = new;
// UDP-Notif Handler
let udp_notif_handler = new;
Output Format
The tool outputs JSON Lines format where each line contains a decoded message:
{"source_address":"192.168.1.1:179","destination_address":"192.168.1.2:179","info":{"Open":{"version":4,"asn":65001,"hold_time":180,"bgp_id":[192,168,1,1],"optional_parameters":[]}}}
{"source_address":"192.168.1.2:179","destination_address":"192.168.1.1:179","info":{"Open":{"version":4,"asn":65002,"hold_time":180,"bgp_id":[192,168,1,2],"optional_parameters":[]}}}