Metadata-Version: 2.3
Name: pybgpflux
Version: 0.5.1
Summary: Drop-in replacement for PyBGPStream using BGPKIT
Author: JustinLoye
Author-email: JustinLoye <jloye@iij.ad.jp>
Requires-Dist: aiofiles>=25.1.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: pybgpkit>=0.6.2
Requires-Dist: pydantic>=2.11.9
Requires-Dist: websocket-client>=1.8.0
Requires-Python: >=3.10
Project-URL: Documentation, https://justinloye.github.io/pybgpflux
Project-URL: Repository, https://github.com/JustinLoye/pybgpflux
Description-Content-Type: text/markdown

# PyBGPFlux

[![Docs](https://img.shields.io/badge/docs-justinloye.github.io-blue)](https://justinloye.github.io/pybgpflux/)
[![PyPI - Version](https://img.shields.io/pypi/v/pybgpflux.svg)](https://pypi.org/project/pybgpflux)
[![CI](https://github.com/JustinLoye/pybgpflux/actions/workflows/ci.yml/badge.svg)](https://github.com/JustinLoye/pybgpflux/actions/workflows/ci.yml)
[![License](https://img.shields.io/github/license/JustinLoye/pybgpflux.svg)](https://github.com/JustinLoye/pybgpflux/blob/main/LICENSE)

A drop-in replacement for PyBGPStream using BGPKIT

## Features

- Generates time-ordered BGP messages on the fly from RIBs and updates MRT files of multiple collectors
- Stream the same BGP messages as PyBGPStream, enabling seamless, drop-in replacement
- Lazy loading consumes minimal memory, making it suitable for large datasets
- Multiple BGP parsers supported: `pybgpkit` (default but slow), `bgpkit-parser`, `bgpdump` and `pybgpstream` single file backend (the latter three are system dependencies)
- Caching with concurrent downloading fully compatible with the BGPKIT parser's caching functionality.
- Performance: for updates, typically 3–10× faster than PyBGPStream; for RIB-only processing, currently about 3–4× slower (see [perf.md](perf.md) for test details).
- A CLI tool

## Quick start

Installation:

```sh
pip install pybgpflux
```

Usage:

```python
import datetime
from pybgpflux import BGPStreamConfig, BGPStream

config = BGPStreamConfig(
    start_time=datetime.datetime(2010, 9, 1, 0, 0),
    end_time=datetime.datetime(2010, 9, 1, 1, 59),
    collectors=["route-views.wide", "rrc04"],
    data_types=["ribs", "updates"],
)

stream = BGPStream.from_config(config)

n_elems = 0
for elem in stream:
  n_elems += 1
    
print(f"Processed {n_elems} BGP elements")
```

or in the terminal:

```sh
pybgpflux --start-time 2010-09-01T00:00:00 --end-time 2010-09-01T01:59:00 --collectors route-views.sydney route-views.wide --data-types updates > updates.txt
```

## Motivation

PyBGPStream is great but the implementation is complex and stops working when UC San Diego experiences a power outage.  
BGPKIT broker and parser are great, but cannot be used to create an ordered stream of BGP messages from multiple collectors and multiple data types.

## Missing features

- Live mode for RouteViews collectors
- Some PyBGPStream data interface options like csv or sqlite