|
1 | 1 | # Examples |
2 | 2 |
|
3 | | -This directory contains runnable examples for bgpkit-parser. They demonstrate basic usage, filtering, batch processing with BGPKIT Broker, real-time streaming, attribute and metadata inspection, error handling, and more. Each entry below links directly to the source so you can browse it on GitHub. |
| 3 | +This directory contains runnable examples for bgpkit_parser. They demonstrate basic usage, filtering, batch processing with BGPKIT Broker, real_time streaming, attribute and metadata inspection, error handling, and more. Each entry below links directly to the source so you can browse it on GitHub. |
4 | 4 |
|
5 | 5 | ## Quickstart and Iteration |
6 | | -- [parse-single-file.rs](parse-single-file.rs) — Download and iterate over a single RouteViews updates file, logging each BGP element (BgpElem). |
7 | | -- [display_elems.rs](display_elems.rs) — Print selected fields from each BGP element in a compact, pipe-delimited format. |
| 6 | +- [parse_single_file.rs](parse_single_file.rs) — Download and iterate over a single RouteViews updates file, logging each BGP element (BgpElem). |
| 7 | +- [parse_single_file_parallel.rs](parse_single_file_parallel.rs) — Parse a single compressed RIB in parallel using a raw iterator + worker pool. Downloads to current directory if remote, counts elems, and compares timing with a sequential run. Tunables via env vars: BATCH_SIZE, WORKERS, CHAN_CAP, ELEM_IN_WORKERS, QUIET_ERRORS. |
| 8 | +- [display_elems.rs](display_elems.rs) — Print selected fields from each BGP element in a compact, pipe_delimited format. |
8 | 9 | - [count_elems.rs](count_elems.rs) — Count the total number of BGP elements in a given file. |
9 | | -- [records_iter.rs](records_iter.rs) — Iterate over raw MRT records and inspect/update messages; includes an example of detecting the Only-To-Customer (OTC) attribute. |
10 | | -- [scan_mrt.rs](scan_mrt.rs) — CLI-style scanner that quickly walks an MRT file, counting raw records, parsed records, or elements without processing them. |
| 10 | +- [records_iter.rs](records_iter.rs) — Iterate over raw MRT records and inspect/update messages; includes an example of detecting the Only_To_Customer (OTC) attribute. |
| 11 | +- [scan_mrt.rs](scan_mrt.rs) — CLI_style scanner that quickly walks an MRT file, counting raw records, parsed records, or elements without processing them. |
11 | 12 |
|
12 | 13 | ## Filtering and Policy Examples |
13 | 14 | - [filters.rs](filters.rs) — Parse an MRT file and filter by a specific prefix (e.g., 211.98.251.0/24), logging matching announcements. |
14 | | -- [filter_export_rib.rs](filter_export_rib.rs) — Filter the content of a RIB by origin ASN and re-encode/export to a new RIB file. |
| 15 | +- [filter_export_rib.rs](filter_export_rib.rs) — Filter the content of a RIB by origin ASN and re_encode/export to a new RIB file. |
15 | 16 | - [find_as_set_messages.rs](find_as_set_messages.rs) — Find announcements containing AS_SET/CONFED_SET segments in AS paths across RIBs retrieved via BGPKIT Broker. |
16 | 17 |
|
17 | 18 | ## Batch and Broker Workflows |
18 | | -- [parse-files-from-broker.rs](parse-files-from-broker.rs) — Use BGPKIT Broker to find data files for a time range and parse them, including a simple origin-ASN filter example. |
19 | | -- [parse-files-from-broker-parallel.rs](parse-files-from-broker-parallel.rs) — Query BGPKIT Broker then parse multiple files in parallel using Rayon, reporting the total message count. |
20 | | -- [cache_reading.rs](cache_reading.rs) — Use the parser’s on-disk cache to avoid re-downloading the same remote files when iterating over time ranges. |
21 | | -- [mrt_filter_archiver.rs](mrt_filter_archiver.rs) — Apply filters while reading updates and archive the filtered stream into a new MRT file; re-parse to verify the output. |
22 | | - |
23 | | -## Real-time Streams (RIS Live, RouteViews Kafka, BMP) |
24 | | -- [real-time-ris-live-websocket.rs](real-time-ris-live-websocket.rs) — Connect to RIPE RIS Live over WebSocket (tungstenite), subscribe to a collector, parse, and print elements. |
25 | | -- [real-time-ris-live-websocket-async.rs](real-time-ris-live-websocket-async.rs) — Async tokio+tungstenite version of the RIS Live WebSocket subscriber. |
26 | | -- [real-time-routeviews-kafka-openbmp.rs](real-time-routeviews-kafka-openbmp.rs) — Consume RouteViews Kafka topics (OpenBMP format), parse BMP messages, and print derived elements. |
27 | | -- [real-time-routeviews-kafka-to-mrt.rs](real-time-routeviews-kafka-to-mrt.rs) — Consume RouteViews Kafka BMP messages and archive them into an MRT file for later analysis. |
| 19 | +- [parse_files_from_broker.rs](parse_files_from_broker.rs) — Use BGPKIT Broker to find data files for a time range and parse them, including a simple origin_ASN filter example. |
| 20 | +- [parse_files_from_broker_parallel.rs](parse_files_from_broker_parallel.rs) — Query BGPKIT Broker then parse multiple files in parallel using Rayon, reporting the total message count. |
| 21 | +- [cache_reading.rs](cache_reading.rs) — Use the parser’s on_disk cache to avoid re_downloading the same remote files when iterating over time ranges. |
| 22 | +- [mrt_filter_archiver.rs](mrt_filter_archiver.rs) — Apply filters while reading updates and archive the filtered stream into a new MRT file; re_parse to verify the output. |
| 23 | + |
| 24 | +## Real_time Streams (RIS Live, RouteViews Kafka, BMP) |
| 25 | +- [real_time_ris_live_websocket.rs](real_time_ris_live_websocket.rs) — Connect to RIPE RIS Live over WebSocket (tungstenite), subscribe to a collector, parse, and print elements. |
| 26 | +- [real_time_ris_live_websocket_async.rs](real_time_ris_live_websocket_async.rs) — Async tokio+tungstenite version of the RIS Live WebSocket subscriber. |
| 27 | +- [real_time_routeviews_kafka_openbmp.rs](real_time_routeviews_kafka_openbmp.rs) — Consume RouteViews Kafka topics (OpenBMP format), parse BMP messages, and print derived elements. |
| 28 | +- [real_time_routeviews_kafka_to_mrt.rs](real_time_routeviews_kafka_to_mrt.rs) — Consume RouteViews Kafka BMP messages and archive them into an MRT file for later analysis. |
28 | 29 | - [bmp_listener.rs](bmp_listener.rs) — Minimal TCP BMP listener that parses incoming BMP Route Monitoring messages and logs them. |
29 | 30 |
|
30 | 31 | ## Attributes and Metadata |
31 | | -- [extended_communities.rs](extended_communities.rs) — Print BGP elements that carry extended, large, or IPv6-extended communities. |
| 32 | +- [extended_communities.rs](extended_communities.rs) — Print BGP elements that carry extended, large, or IPv6_extended communities. |
32 | 33 | - [deprecated_attributes.rs](deprecated_attributes.rs) — Identify announcements that include deprecated attributes (e.g., attribute 28, BGP Entropy Label Capability) and print them in JSON. |
33 | | -- [peer_index_table.rs](peer_index_table.rs) — Read a Table Dump v2 RIB and pretty-print the Peer Index Table in JSON. |
34 | | -- [only-to-customer.rs](only-to-customer.rs) — Find and display paths bearing the Only-To-Customer (OTC, RFC 9234) attribute. |
| 34 | +- [peer_index_table.rs](peer_index_table.rs) — Read a Table Dump v2 RIB and pretty_print the Peer Index Table in JSON. |
| 35 | +- [only_to_customer.rs](only_to_customer.rs) — Find and display paths bearing the Only_To_Customer (OTC, RFC 9234) attribute. |
35 | 36 |
|
36 | 37 | ## Error Handling and Robustness |
37 | 38 | - [fallible_parsing.rs](fallible_parsing.rs) — Demonstrate fallible record/element iterators that let you handle parse errors explicitly while continuing to process. |
|
0 commit comments