Parser Backends¶
PyBGPFlux supports multiple parser backends for different use cases.
Available Parsers¶
PyBGPKIT (Default)¶
- Name:
pybgpkit - Speed: Slow
- Dependencies: None
- Use Case: Zero-dependency installation, prototyping
BGPKIT Parser¶
- Name:
bgpkit - Speed: Fast (~10x faster than pybgpkit)
- Dependencies: Install from cargo
- Use Case: Large-scale processing
Installation:
cargo install bgpkit-parser --features cli
Usage:
from pybgpflux import BGPStreamConfig, BGPStream
config = BGPStreamConfig(
...,
parser="bgpkit",
)
stream = BGPStream.from_config(config)
BGPDump¶
- Name:
bgpdump - Speed: Fast, comparable to BGPKIT
- Dependencies: Classic MRT parser utility
- Use Case: Legacy systems, compatibility
Installation:
apt-get install bgpdump
PyBGPStream¶
- Name:
pybgpstream - Speed: Fastest
- Remote parsing: Yes (parse directly from URL, no local download)
- Dependencies: libbgpstream and
pip install pybgpstream - Use Case: Large-scale processing, low-disk/RAM environments
Installation: follow the CI steps
When remote_parse=True (the default), pybgpstream parses MRT archives directly from their remote URLs without saving them to disk or RAM first. This is useful for memory-constrained environments or when processing large RIB files.
from pybgpflux import BGPStreamConfig, BGPStream
config = BGPStreamConfig(
...,
parser="pybgpstream",
remote_parse=True, # default — skip local download entirely
)
stream = BGPStream.from_config(config)
Using parsers on a single file¶
You can also use parsers independently:
from pybgpflux.bgpstreamconfig import FilterOptions
from pybgpflux.parsers import BGPdumpParser, BGPKITParser
filters = FilterOptions(peer_asn=2497)
bgpdump_parser = BGPdumpParser(
collector="route-views.wide",
is_rib=False,
filepath="updates.20100901.0000.bz2",
filters=filters,
)
bgpkit_parser = BGPKITParser(
collector="route-views.wide",
is_rib=False,
filepath="updates.20100901.0000.bz2",
filters=filters,
)
assert sum(1 for _ in bgpdump_parser) == sum(1 for _ in bgpkit_parser)