Expand description
§mrt_ingester
High-performance parser for MRT (Multi-threaded Routing Toolkit) routing data files.
This crate provides types and functions to parse MRT-formatted binary streams containing BGP routing information, as specified in RFC 6396 and RFC 8050.
§API Compatibility with mrt-rs
This crate is designed as a drop-in replacement for the mrt-rs
crate, providing an API-compatible interface. If you’re migrating from mrt-rs, you can simply
change your imports from mrt_rs to mrt_ingester with minimal code changes.
Why mrt_ingester?
- More permissive license (MIT OR Apache-2.0)
- Actively maintained (original
mrt-rsis abandoned) - Additional high-performance features (read-ahead I/O)
- ~60% faster throughput with the
readaheadmodule
§Example
use std::fs::File;
use std::io::BufReader;
let file = File::open("updates.mrt").unwrap();
let mut reader = BufReader::new(file);
while let Some((header, record)) = mrt_ingester::read(&mut reader).unwrap() {
println!("Record type: {}, timestamp: {}", header.record_type, header.timestamp);
}§High-Performance Reading
For maximum throughput on large files (e.g., RouteViews/RIPE RIS dumps), use the read-ahead reader which achieves ~2.8 GB/sec:
let mut reader = mrt_ingester::readahead::open_mrt_file("large.rib").unwrap();
while let Some((header, record)) = mrt_ingester::read(&mut reader).unwrap() {
// Process record
}Re-exports§
pub use records::bgp;pub use records::bgp4mp;pub use records::bgp4plus;pub use records::isis;pub use records::ospf;pub use records::rip;pub use records::tabledump;
Modules§
Structs§
- Header
- MRT record header that precedes every record.
Enums§
Functions§
- open
- Open an MRT file for reading, transparently decompressing gzip (
.gz) data. - read
- Reads the next MRT record from the stream.
- read_
header_ only - Reads only the MRT header from the stream, skipping the body.
- read_
with_ buffer - Reads the next MRT record from the stream using a reusable buffer.