https://github.com/bgpkit/peer-stats
https://github.com/bgpkit/peer-stats
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bgpkit/peer-stats
- Owner: bgpkit
- License: mit
- Created: 2022-02-10T00:31:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-10T04:33:04.000Z (about 1 year ago)
- Last Synced: 2025-04-10T04:54:05.796Z (about 1 year ago)
- Language: Rust
- Size: 130 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Peer Information Collector
`peer-stats` is a tool that collects BGP route collector peer information from the
archived MRT RIB dump files. The basic idea is to scan through all entries in a given
RIB dump file and aggregate information on per-peer basis.
## Metrics
We collect the following information and metrics for each peer in a table dump file:
- `asn`: peer ASN
- `ip`: peer IP
- `num_v4_pfxs`: the number of IPv4 IP prefixes from this peer
- `num_v6_pfxs`: the number of IPv6 IP prefixes from this peer
- `num_connected_asns`: the number of unique next-hop ASNs connected to this peer
## Public Dataset
We provide a publicly available dataset at https://data.bgpkit.com/peer-stats.
We update this dataset daily and also provide historical data archive back to 2012.
## Usage
### Installation
Rust toolchain is required for installing this tool.
Run the following command to install the compiled `peer-stats` tool to `~.cargo/bin/peer-stats`.
```bash
cargo install --path .
```
### Single-file Processing
```text
(venv) ➜ peer-stats git:(main) ✗ peer-stats --help
peer-stats 0.2.0
peer-stats is a CLI tool that collects peer information from a given RIB dump file
USAGE:
peer-stats [FLAGS]
FLAGS:
--debug whether to print debug
-h, --help Prints help information
-V, --version Prints version information
ARGS:
File path to a MRT file, local or remote
```
Example:
```bash
peer-stats --debug http://archive.routeviews.org/route-views.sg/bgpdata/2022.02/RIBS/rib.20220205.1800.bz2
```
### Historical Data Bootstrap
Use `MAX_THREADS` environment variable to configure maximum number of threads to use for processing.
```text
peer-stats 0.1.0
peer-stats is a CLI tool that collects peer information from a given RIB dump file
USAGE:
peer-stats-bootstrap [FLAGS] --output-dir --ts-end --ts-start
FLAGS:
--debug whether to print debug
--dry-run whether to dry run the code
-h, --help Prints help information
--only-daily whether to do only daily parsing
-V, --version Prints version information
OPTIONS:
--output-dir Output directory
--ts-end end timestamp
--ts-start start timestamp
```
## Output
The commandline tool, `peer-stats`, outputs JSON-formatted string to stdout. Debug messages are displayed to
stderr, and thus will not interrupt the result output.
The format is as follows (removed all peers info but one for conciseness):
```json
{
"collector": "route-views.sg",
"peers": {
"2001:de8:4::13:6168:1": {
"asn": 136168,
"ip": "2001:de8:4::13:6168:1",
"num_connected_asns": 4,
"num_v4_pfxs": 0,
"num_v6_pfxs": 40
},
"project": "route-views",
"rib_dump_url": "http://archive.routeviews.org/route-views.sg/bgpdata/2022.02/RIBS/rib.20220205.1800.bz2"
}
}
```
## LICENSE
This work is under [MIT](LICENSE) license.