bgpkit_parser/lib.rs
1/*!
2BGPKIT Parser aims to provide the most ergonomic MRT/BGP/BMP message parsing Rust API.
3
4BGPKIT Parser has the following features:
5- **performant**: comparable to C-based implementations like `bgpdump` or `bgpreader`.
6- **actively maintained**: we consistently introduce feature updates and bug fixes, and support most of the relevant BGP RFCs.
7- **ergonomic API**: a three-line for loop can already get you started.
8- **battery-included**: ready to handle remote or local, bzip2 or gz data files out of the box
9
10# Getting Started
11
12Add `bgpkit-parser` to your `Cargo.toml`:
13
14```toml
15[dependencies]
16bgpkit-parser = "0.13"
17```
18
19Parse a BGP MRT file in three lines:
20
21```no_run
22use bgpkit_parser::BgpkitParser;
23
24for elem in BgpkitParser::new("http://archive.routeviews.org/route-views4/bgpdata/2022.01/UPDATES/updates.20220101.0000.bz2").unwrap() {
25 println!("{}", elem);
26}
27```
28
29# Examples
30
31The examples below are organized by complexity. For complete runnable examples, check out the [examples folder](https://github.com/bgpkit/bgpkit-parser/tree/main/examples).
32
33## Basic Examples
34
35### Parsing a Single MRT File
36
37Let's say we want to print out all the BGP announcements/withdrawal from a single MRT file, either located remotely or locally.
38Here is an example that does so.
39
40```no_run
41use bgpkit_parser::BgpkitParser;
42let parser = BgpkitParser::new("http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2").unwrap();
43for elem in parser {
44 println!("{}", elem)
45}
46```
47
48Yes, it is this simple!
49
50### Counting BGP Messages
51
52You can use iterator methods for quick analysis. For example, counting the number of announcements/withdrawals in a file:
53
54```no_run
55use bgpkit_parser::BgpkitParser;
56let url = "http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2";
57let count = BgpkitParser::new(url).unwrap().into_iter().count();
58println!("total: {}", count);
59```
60
61Output:
62```text
63total: 255849
64```
65
66## Intermediate Examples
67
68### Filtering BGP Messages
69
70BGPKIT Parser has a built-in [Filter] mechanism to efficiently filter messages. Add filters when creating the parser to only process matching [BgpElem]s.
71
72**Available filter types**: See the [Filter] enum documentation for all options.
73
74```no_run
75use bgpkit_parser::BgpkitParser;
76
77/// Filter by IP prefix
78let parser = BgpkitParser::new("http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2").unwrap()
79 .add_filter("prefix", "211.98.251.0/24").unwrap();
80
81for elem in parser {
82 println!("{}", elem);
83}
84```
85
86**Common filters**:
87- `prefix`: Match a specific IP prefix
88- `origin_asn`: Match origin AS number
89- `peer_asn`: Match peer AS number
90- `peer_ip`: Match peer IP address
91- `elem_type`: Filter by announcement (`a`) or withdrawal (`w`)
92- `as_path`: Match AS path with regex
93
94### Parsing Multiple MRT Files with BGPKIT Broker
95
96[BGPKIT Broker][broker-repo] library provides search API for all RouteViews and RIPE RIS MRT data files. Using the
97broker's Rust API ([`bgpkit-broker`][broker-crates-io]), we can easily compile a list of MRT files that we are interested
98in for any time period and any data type (`update` or `rib`). This allows users to gather information without needing to
99know about the locations of specific data files.
100
101[broker-repo]: https://github.com/bgpkit/bgpkit-broker
102[broker-crates-io]: https://crates.io/crates/bgpkit-broker
103
104The example below shows a relatively more interesting example that does the following:
105- find all BGP archive data created on time 1634693400
106- filter to only BGP updates files
107- find all announcements originated from AS13335
108- print out the total count of the announcements
109
110```no_run
111use bgpkit_parser::{BgpkitParser, BgpElem};
112
113let broker = bgpkit_broker::BgpkitBroker::new()
114 .ts_start("1634693400")
115 .ts_end("1634693400")
116 .page(1);
117
118for item in broker.into_iter().take(2) {
119 log::info!("downloading updates file: {}", &item.url);
120 let parser = BgpkitParser::new(item.url.as_str()).unwrap();
121
122 log::info!("parsing updates file");
123 // iterating through the parser. the iterator returns `BgpElem` one at a time.
124 let elems = parser
125 .into_elem_iter()
126 .filter_map(|elem| {
127 if let Some(origins) = &elem.origin_asns {
128 if origins.contains(&13335.into()) {
129 Some(elem)
130 } else {
131 None
132 }
133 } else {
134 None
135 }
136 })
137 .collect::<Vec<BgpElem>>();
138 log::info!("{} elems matches", elems.len());
139}
140```
141
142### Error Handling
143
144BGPKIT Parser returns `Result` types for operations that may fail. Here are common scenarios and how to handle them:
145
146**Handling Parser Creation Errors**
147
148```no_run
149use bgpkit_parser::BgpkitParser;
150
151// The URL might be invalid or unreachable
152match BgpkitParser::new("http://example.com/data.mrt.bz2") {
153 Ok(parser) => {
154 for elem in parser {
155 println!("{}", elem);
156 }
157 }
158 Err(e) => {
159 eprintln!("Failed to create parser: {}", e);
160 // Common causes:
161 // - Invalid URL or file path
162 // - Network connection issues
163 // - Unsupported compression format
164 }
165}
166```
167
168**Handling Filter Errors**
169
170```no_run
171use bgpkit_parser::BgpkitParser;
172
173let mut parser = BgpkitParser::new("http://example.com/data.mrt.bz2").unwrap();
174
175// Filter addition can fail with invalid input
176match parser.add_filter("prefix", "invalid-prefix") {
177 Ok(_) => println!("Filter added successfully"),
178 Err(e) => {
179 eprintln!("Invalid filter: {}", e);
180 // Common causes:
181 // - Invalid IP prefix format
182 // - Invalid AS number
183 // - Unknown filter type
184 }
185}
186```
187
188**Robust Production Code**
189
190```no_run
191use bgpkit_parser::BgpkitParser;
192
193fn process_mrt_file(url: &str) -> Result<usize, Box<dyn std::error::Error>> {
194 let parser = BgpkitParser::new(url)?
195 .add_filter("origin_asn", "13335")?;
196
197 let mut count = 0;
198 for elem in parser {
199 // Process element
200 count += 1;
201 }
202
203 Ok(count)
204}
205
206// Usage
207match process_mrt_file("http://example.com/updates.bz2") {
208 Ok(count) => println!("Processed {} elements", count),
209 Err(e) => eprintln!("Error: {}", e),
210}
211```
212
213## Advanced Examples
214
215### Parsing Real-time Data Streams
216
217BGPKIT Parser provides parsing for real-time data streams, including [RIS-Live][ris-live-url]
218and [BMP][bmp-rfc]/[OpenBMP][openbmp-url] messages.
219
220**Parsing Messages From RIS-Live**
221
222Here is an example of handling RIS-Live message streams. After connecting to the websocket server,
223we need to subscribe to a specific data stream. In this example, we subscribe to the data stream
224from on collector (`rrc21`). We can then loop and read messages from the websocket.
225
226```no_run
227# #[cfg(feature = "rislive")]
228use bgpkit_parser::parse_ris_live_message;
229use serde_json::json;
230use tungstenite::{connect, Message};
231
232const RIS_LIVE_URL: &str = "ws://ris-live.ripe.net/v1/ws/?client=rust-bgpkit-parser";
233
234/// This is an example of subscribing to RIS-Live's streaming data from one host (`rrc21`).
235///
236/// For more RIS-Live details, check out their documentation at https://ris-live.ripe.net/manual/
237fn main() {
238 // connect to RIPE RIS Live websocket server
239 let (mut socket, _response) =
240 connect(RIS_LIVE_URL)
241 .expect("Can't connect to RIS Live websocket server");
242
243 // subscribe to messages from one collector
244 let msg = json!({"type": "ris_subscribe", "data": {"host": "rrc21"}}).to_string();
245 socket.send(Message::Text(msg.into())).unwrap();
246
247 loop {
248 let msg = socket.read().expect("Error reading message").to_string();
249# #[cfg(feature = "rislive")]
250 if let Ok(elems) = parse_ris_live_message(msg.as_str()) {
251 for elem in elems {
252 println!("{}", elem);
253 }
254 }
255 }
256}
257```
258
259**Parsing OpenBMP Messages From RouteViews Kafka Stream**
260
261[RouteViews](http://www.routeviews.org/routeviews/) provides a real-time Kafka stream of the OpenBMP
262data received from their collectors. Below is a partial example of how we handle the raw bytes
263received from the Kafka stream. For full examples, check out the [examples folder on GitHub](https://github.com/bgpkit/bgpkit-parser/tree/main/examples).
264
265```rust,no_run
266# use log::{info, error};
267# use bytes::Bytes;
268# struct KafkaMessage { value: Vec<u8> }
269# let m = KafkaMessage { value: vec![] };
270use bgpkit_parser::parser::bmp::messages::*;
271use bgpkit_parser::parser::utils::*;
272use bgpkit_parser::{Elementor, parse_openbmp_header, parse_bmp_msg};
273
274let bytes = &m.value;
275let mut data = Bytes::from(bytes.clone());
276let header = parse_openbmp_header(&mut data).unwrap();
277let bmp_msg = parse_bmp_msg(&mut data);
278match bmp_msg {
279 Ok(msg) => {
280 let timestamp = header.timestamp;
281 let per_peer_header = msg.per_peer_header.unwrap();
282 match msg.message_body {
283 BmpMessageBody::RouteMonitoring(m) => {
284 for elem in Elementor::bgp_to_elems(
285 m.bgp_message,
286 timestamp,
287 &per_peer_header.peer_ip,
288 &per_peer_header.peer_asn
289 )
290 {
291 info!("{}", elem);
292 }
293 }
294 _ => {}
295 }
296 }
297 Err(_e) => {
298 let hex = hex::encode(bytes);
299 error!("{}", hex);
300 }
301}
302```
303
304[ris-live-url]: https://ris-live.ripe.net
305[bmp-rfc]: https://datatracker.ietf.org/doc/html/rfc7854
306[openbmp-url]: https://www.openbmp.org/
307
308### Encoding: Archiving Filtered MRT Records
309
310The example will download one MRT file from RouteViews, filter out all the BGP messages that
311are not originated from AS3356, and write the filtered MRT records to disk. Then it re-parses the
312filtered MRT file and prints out the number of BGP messages.
313
314```no_run
315use bgpkit_parser::Elementor;
316use itertools::Itertools;
317use std::io::Write;
318
319let mut updates_encoder = bgpkit_parser::encoder::MrtUpdatesEncoder::new();
320
321bgpkit_parser::BgpkitParser::new(
322 "http://archive.routeviews.org/bgpdata/2023.10/UPDATES/updates.20231029.2015.bz2",
323).unwrap()
324 .add_filter("origin_asn", "3356").unwrap()
325 .into_iter()
326 .for_each(|elem| {
327 updates_encoder.process_elem(&elem);
328 });
329
330let mut mrt_writer = oneio::get_writer("as3356_mrt.gz").unwrap();
331mrt_writer.write_all(updates_encoder.export_bytes().as_ref()).unwrap();
332drop(mrt_writer);
333```
334
335# FAQ & Troubleshooting
336
337## Common Issues
338
339### Parser creation fails with "unsupported compression"
340**Problem**: The file uses an unsupported compression format.
341
342**Solution**: BGPKIT Parser natively supports `.bz2` and `.gz` compression. For other formats, decompress the file first or use the [`oneio`](https://crates.io/crates/oneio) crate which supports additional formats.
343
344### Out of memory when parsing large files
345**Problem**: Collecting all elements into a vector exhausts available memory.
346
347**Solution**: Use streaming iteration instead of collecting:
348```rust,ignore
349// ❌ Don't do this for large files
350let all_elems: Vec<_> = parser.into_iter().collect();
351
352// ✅ Process iteratively
353for elem in parser {
354 // Process one element at a time
355 process(elem);
356}
357```
358
359### Slow performance on network files
360**Problem**: Remote file parsing is slower than expected.
361
362**Solution**:
363- Use the `--cache-dir` option in CLI to cache downloaded files
364- In library code, download the file first with appropriate buffering
365- Consider processing files in parallel if dealing with multiple files
366
367### Missing or incomplete BGP attributes
368**Problem**: Some [BgpElem] fields are `None` when you expect values.
369
370**Solution**: Not all BGP messages contain all attributes. Check the MRT format and BGP message type:
371- Withdrawals typically don't have AS paths or communities
372- Some collectors may not export certain attributes
373- Use pattern matching to handle `Option` types properly
374
375## Performance Tips
376
377### Use filters early
378Apply filters during parser creation to avoid processing unwanted data:
379```rust,ignore
380// ✅ Efficient - filters during parsing
381let parser = BgpkitParser::new(url)?
382 .add_filter("prefix", "1.1.1.0/24")?;
383
384// ❌ Less efficient - processes everything first
385let filtered: Vec<_> = BgpkitParser::new(url)?
386 .into_iter()
387 .filter(|e| e.prefix.to_string() == "1.1.1.0/24")
388 .collect();
389```
390
391### Process multiple files in parallel
392For bulk processing, use parallel iterators:
393```rust,ignore
394use rayon::prelude::*;
395
396let files = vec!["file1.mrt.bz2", "file2.mrt.bz2", "file3.mrt.bz2"];
397files.par_iter().for_each(|file| {
398 let parser = BgpkitParser::new(file).unwrap();
399 // Process each file in parallel
400});
401```
402
403### Choose the right data structure
404- Use [MrtRecord] iteration for minimal memory overhead
405- Use [MrtUpdate] for efficient batch processing without per-prefix attribute duplication
406- Use [BgpElem] for easier per-prefix analysis
407- See [Data Representation](#data-representation) for detailed comparison
408
409# Command Line Tool
410
411`bgpkit-parser` is bundled with a utility commandline tool `bgpkit-parser-cli`.
412
413## Installation
414
415### Install compiled binaries
416
417You can install the compiled `bgpkit-parser` CLI binaries with the following methods:
418- **Homebrew** (macOS): `brew install bgpkit/tap/bgpkit-parser`
419- [**Cargo binstall**](https://github.com/cargo-bins/cargo-binstall): `cargo binstall bgpkit-parser`
420
421### From source
422
423You can install the tool by running
424```bash
425cargo install bgpkit-parser --features cli
426```
427or checkout this repository and run
428```bash
429cargo install --path . --features cli
430```
431
432## Usage
433
434Run `bgpkit-parser --help` to see the full list of options.
435
436```text
437MRT/BGP/BMP data processing library
438
439Usage: bgpkit-parser [OPTIONS] <FILE>
440
441Arguments:
442 <FILE> File path to a MRT file, local or remote
443
444Options:
445 -c, --cache-dir <CACHE_DIR> Set the cache directory for caching remote files. Default behavior does not enable caching
446 --json Output as JSON objects
447 --psv Output as full PSV entries with header
448 --pretty Pretty-print JSON output
449 -e, --elems-count Count BGP elems
450 -r, --records-count Count MRT records
451 -o, --origin-asn <ORIGIN_ASN> Filter by origin AS Number
452 -p, --prefix <PREFIX> Filter by network prefix
453 -4, --ipv4-only Filter by IPv4 only
454 -6, --ipv6-only Filter by IPv6 only
455 -s, --include-super Include super-prefix when filtering
456 -S, --include-sub Include sub-prefix when filtering
457 -j, --peer-ip <PEER_IP> Filter by peer IP address
458 -J, --peer-asn <PEER_ASN> Filter by peer ASN
459 -m, --elem-type <ELEM_TYPE> Filter by elem type: announce (a) or withdraw (w)
460 -t, --start-ts <START_TS> Filter by start unix timestamp inclusive
461 -T, --end-ts <END_TS> Filter by end unix timestamp inclusive
462 -a, --as-path <AS_PATH> Filter by AS path regex string
463 -h, --help Print help
464 -V, --version Print version
465
466```
467
468## Common CLI Examples
469
470### Basic usage - Print all BGP messages
471```bash
472bgpkit-parser http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2
473```
474
475### Filter by origin AS
476```bash
477bgpkit-parser -o 13335 updates.20211001.0000.bz2
478```
479
480### Filter by prefix
481```bash
482bgpkit-parser -p 1.1.1.0/24 updates.20211001.0000.bz2
483```
484
485### Output as JSON
486```bash
487bgpkit-parser --json updates.20211001.0000.bz2 > output.json
488```
489
490### Count elements efficiently
491```bash
492bgpkit-parser -e updates.20211001.0000.bz2
493```
494
495### Cache remote files for faster repeated access
496```bash
497bgpkit-parser -c ~/.bgpkit-cache http://example.com/updates.mrt.bz2
498```
499
500### Combine filters
501```bash
502# IPv4 announcements from AS13335
503bgpkit-parser -o 13335 -m a -4 updates.bz2
504```
505
506# Data Representation
507
508BGPKIT Parser provides three ways to access parsed BGP data: [MrtRecord], [MrtUpdate], and [BgpElem]. Choose based on your needs:
509
510```text
511┌──────────────────────────────────────────────┐
512│ MRT File │
513│ (Binary format: bgp4mp, tabledumpv2, etc.) │
514└──────────────────────┬───────────────────────┘
515 │
516 ├──> Parser
517 │
518 ┌──────────────┼────────────────┐
519 │ │ │
520 ▼ ▼ ▼
521 [MrtRecord] [MrtUpdate] [BgpElem]
522 (Low-level) (Intermediate) (High-level)
523 │ │ │
524 └─────────────┴────────────────┘
525 │
526 ▼
527 Your Analysis Code
528```
529
530## [MrtRecord]: Low-level MRT Representation
531
532[MrtRecord] preserves the complete, unmodified information from the MRT file. Use this when you need:
533- **Raw MRT data access**: Direct access to all MRT fields
534- **Format-specific details**: Peer index tables, geo-location data, etc.
535- **Memory efficiency**: Minimal overhead, compact representation
536- **Re-encoding**: Converting back to MRT format
537
538See the [MrtRecord] documentation for the complete structure definition.
539
540**Key components**:
541- `common_header`: Contains timestamp, record type, and metadata
542- `message`: The actual MRT message (TableDump, TableDumpV2, or Bgp4Mp)
543
544**Iteration**: Use [`BgpkitParser::into_record_iter()`] to iterate over [MrtRecord]s.
545
546## [MrtUpdate]: Intermediate Message-Level Representation
547
548[MrtUpdate] provides access to BGP announcements without expanding them into individual per-prefix elements. This is a middle ground between [MrtRecord] and [BgpElem]. Use this when you need:
549- **Efficient batch processing**: Avoid duplicating attributes across prefixes
550- **Message-level analysis**: Work with UPDATE messages or RIB entries as units
551- **Memory efficiency**: Shared attributes aren't cloned for each prefix
552
553**Supported message types** (via enum variants):
554- `Bgp4MpUpdate`: BGP UPDATE messages from UPDATES files
555- `TableDumpV2Entry`: RIB entries from TableDumpV2 RIB dumps
556- `TableDumpMessage`: Legacy TableDump v1 messages
557
558**Example**:
559```no_run
560use bgpkit_parser::{BgpkitParser, MrtUpdate};
561
562let parser = BgpkitParser::new("updates.mrt.bz2").unwrap();
563for update in parser.into_update_iter() {
564 match update {
565 MrtUpdate::Bgp4MpUpdate(u) => {
566 // One UPDATE message may contain multiple prefixes sharing attributes
567 println!("Peer {} announced {} prefixes",
568 u.peer_ip,
569 u.message.announced_prefixes.len()
570 );
571 }
572 MrtUpdate::TableDumpV2Entry(e) => {
573 // One prefix with multiple RIB entries (one per peer)
574 println!("Prefix {} seen by {} peers",
575 e.prefix,
576 e.rib_entries.len()
577 );
578 }
579 MrtUpdate::TableDumpMessage(m) => {
580 println!("Legacy table dump for {}", m.prefix);
581 }
582 }
583}
584```
585
586**Iteration**: Use [`BgpkitParser::into_update_iter()`] to iterate over [MrtUpdate]s.
587
588## [BgpElem]: High-level Per-Prefix Representation
589
590[BgpElem] provides a simplified, per-prefix view of BGP data. Each [BgpElem] represents a single prefix announcement or withdrawal. Use this when you want:
591- **Simple analysis**: Focus on prefixes without worrying about MRT format details
592- **Format-agnostic processing**: Same structure regardless of MRT format
593- **BGP attributes**: Easy access to AS path, communities, etc.
594
595**Example transformation**:
596```text
597MRT Record with 3 prefixes → 3 BgpElem objects
598┌────────────────────────┐ ┌──────────────────┐
599│ BGP UPDATE Message │ │ BgpElem │
600│ AS Path: 64512 64513 │ ────────> │ prefix: P1 │
601│ Prefixes: │ │ as_path: 64512.. │
602│ - P1: 10.0.0.0/24 │ └──────────────────┘
603│ - P2: 10.0.1.0/24 │ ┌──────────────────┐
604│ - P3: 10.0.2.0/24 │ ────────> │ BgpElem │
605└────────────────────────┘ │ prefix: P2 │
606 │ as_path: 64512.. │
607 └──────────────────┘
608 ┌──────────────────┐
609 │ BgpElem │
610 ────────> │ prefix: P3 │
611 │ as_path: 64512.. │
612 └──────────────────┘
613```
614
615See the [BgpElem] documentation for the complete structure definition.
616
617**Key fields**:
618- `timestamp`: Unix timestamp of the BGP message
619- `elem_type`: Announcement or withdrawal
620- `peer_ip` / `peer_asn`: The BGP peer information
621- `prefix`: The IP prefix being announced or withdrawn
622- `as_path`: The AS path attribute (if present)
623- `origin_asns`: Origin AS numbers extracted from AS path
624- `communities`: BGP communities (standard, extended, and large)
625- `next_hop`, `local_pref`, `med`: Other BGP attributes
626
627**Iteration**: Use [`BgpkitParser::into_elem_iter()`] or default iteration to iterate over [BgpElem]s.
628
629## Which One Should I Use?
630
631| Use Case | Recommended | Why |
632|----------|-------------|-----|
633| Simple prefix analysis | [BgpElem] | Easy per-prefix access, format-agnostic |
634| High-performance processing | [MrtUpdate] | Avoids attribute duplication overhead |
635| Counting prefixes per UPDATE | [MrtUpdate] | Direct access to message structure |
636| Re-encoding MRT data | [MrtRecord] | Preserves complete MRT structure |
637| MRT format-specific details | [MrtRecord] | Access to peer index tables, geo-location, etc. |
638
639**Memory trade-off**:
640- [BgpElem] duplicates shared attributes (AS path, communities) for each prefix
641- [MrtUpdate] keeps attributes shared within each message/entry
642- [MrtRecord] has minimal overhead but requires more code to extract BGP data
643
644# RFCs Support
645
646BGPKIT Parser implements comprehensive BGP, MRT, BMP, and related protocol standards. All listed RFCs are fully supported.
647
648**Request a feature**: If you need support for a specific RFC not listed here, please [submit an issue on GitHub](https://github.com/bgpkit/bgpkit-parser/issues).
649
650## Core BGP Protocol
651
652**Most commonly used**:
653- [RFC 4271](https://datatracker.ietf.org/doc/html/rfc4271): A Border Gateway Protocol 4 (BGP-4) - Core protocol
654- [RFC 2858](https://datatracker.ietf.org/doc/html/rfc2858): Multiprotocol Extensions for BGP-4 (IPv6 support)
655- [RFC 6793](https://datatracker.ietf.org/doc/html/rfc6793): Four-Octet AS Number Space
656- [RFC 7911](https://datatracker.ietf.org/doc/html/rfc7911): Advertisement of Multiple Paths (ADD-PATH)
657
658**Additional BGP RFCs**:
659- [RFC 2042](https://datatracker.ietf.org/doc/html/rfc2042): Registering New BGP Attribute Types
660- [RFC 2918](https://datatracker.ietf.org/doc/html/rfc2918): Route Refresh Capability for BGP-4
661- [RFC 3392](https://datatracker.ietf.org/doc/html/rfc3392): Capabilities Advertisement with BGP-4
662- [RFC 4724](https://datatracker.ietf.org/doc/html/rfc4724): Graceful Restart Mechanism for BGP
663- [RFC 4456](https://datatracker.ietf.org/doc/html/rfc4456): BGP Route Reflection
664- [RFC 5065](https://datatracker.ietf.org/doc/html/rfc5065): Autonomous System Confederations for BGP
665- [RFC 5492](https://datatracker.ietf.org/doc/html/rfc5492): Capabilities Advertisement with BGP-4
666- [RFC 7606](https://datatracker.ietf.org/doc/html/rfc7606): Revised Error Handling for BGP UPDATE Messages
667- [RFC 8654](https://datatracker.ietf.org/doc/html/rfc8654): Extended Message Support for BGP
668- [RFC 8950](https://datatracker.ietf.org/doc/html/rfc8950): Advertising IPv4 NLRI with an IPv6 Next Hop
669- [RFC 9072](https://datatracker.ietf.org/doc/html/rfc9072): Extended Optional Parameters Length for BGP OPEN Message
670- [RFC 9234](https://datatracker.ietf.org/doc/html/rfc9234): Route Leak Prevention Using Roles in UPDATE and OPEN Messages
671
672## MRT (Multi-Threaded Routing Toolkit)
673
674- [RFC 6396](https://datatracker.ietf.org/doc/html/rfc6396): MRT Routing Information Export Format
675- [RFC 6397](https://datatracker.ietf.org/doc/html/rfc6397): MRT BGP Routing Information Export Format with Geo-Location Extensions
676- [RFC 8050](https://datatracker.ietf.org/doc/html/rfc8050): MRT Routing Information Export Format with BGP Additional Path Extensions
677
678## BMP (BGP Monitoring Protocol)
679
680- [RFC 7854](https://datatracker.ietf.org/doc/html/rfc7854): BGP Monitoring Protocol (BMP)
681- [RFC 8671](https://datatracker.ietf.org/doc/html/rfc8671): Support for Adj-RIB-Out in BMP
682- [RFC 9069](https://datatracker.ietf.org/doc/html/rfc9069): Support for Local RIB in BMP
683
684## BGP Communities
685
686Full support for standard, extended, and large communities:
687- [RFC 1997](https://datatracker.ietf.org/doc/html/rfc1997): BGP Communities Attribute
688- [RFC 4360](https://datatracker.ietf.org/doc/html/rfc4360): BGP Extended Communities Attribute
689- [RFC 5668](https://datatracker.ietf.org/doc/html/rfc5668): 4-Octet AS Specific BGP Extended Community
690- [RFC 5701](https://datatracker.ietf.org/doc/html/rfc5701): IPv6 Address Specific BGP Extended Community Attribute
691- [RFC 7153](https://datatracker.ietf.org/doc/html/rfc7153): IANA Registries for BGP Extended Communities
692- [RFC 8097](https://datatracker.ietf.org/doc/html/rfc8097): BGP Prefix Origin Validation State Extended Community
693- [RFC 8092](https://datatracker.ietf.org/doc/html/rfc8092): BGP Large Communities
694
695## Advanced Features
696
697**FlowSpec**:
698- [RFC 8955](https://datatracker.ietf.org/doc/html/rfc8955): Dissemination of Flow Specification Rules
699- [RFC 8956](https://datatracker.ietf.org/doc/html/rfc8956): Dissemination of Flow Specification Rules for IPv6
700- [RFC 9117](https://datatracker.ietf.org/doc/html/rfc9117): Revised Validation Procedure for BGP Flow Specifications
701
702**Tunnel Encapsulation**:
703- [RFC 5640](https://datatracker.ietf.org/doc/html/rfc5640): Load-Balancing for Mesh Softwires
704- [RFC 8365](https://datatracker.ietf.org/doc/html/rfc8365): Ethernet VPN (EVPN)
705- [RFC 9012](https://datatracker.ietf.org/doc/html/rfc9012): BGP Tunnel Encapsulation Attribute
706
707**Link-State (BGP-LS)**:
708- [RFC 7752](https://datatracker.ietf.org/doc/html/rfc7752): North-Bound Distribution of Link-State and TE Information
709- [RFC 8571](https://datatracker.ietf.org/doc/html/rfc8571): BGP-LS Advertisement of IGP TE Performance Metric Extensions
710- [RFC 9085](https://datatracker.ietf.org/doc/html/rfc9085): BGP-LS Extensions for Segment Routing
711- [RFC 9294](https://datatracker.ietf.org/doc/html/rfc9294): BGP-LS Advertisement of Application-Specific Link Attributes
712
713# See Also
714
715## Related BGPKIT Projects
716
717- **[BGPKIT Broker](https://github.com/bgpkit/bgpkit-broker)**: Search and discover MRT data files from RouteViews and RIPE RIS
718- **[BGPKIT API](https://data.bgpkit.com)**: RESTful API for MRT data file discovery
719- **[Monocle](https://github.com/bgpkit/monocle)**: Real-time BGP monitoring and alerting
720- **[BGPKIT Commons](https://github.com/bgpkit/bgpkit-commons)**: Common data structures and utilities
721
722## Resources
723
724- **[GitHub Repository](https://github.com/bgpkit/bgpkit-parser)**: Source code, examples, and issue tracking
725- **[Documentation](https://docs.rs/bgpkit-parser)**: Full API documentation
726- **[Changelog](https://github.com/bgpkit/bgpkit-parser/blob/main/CHANGELOG.md)**: Version history and release notes
727
728## Community
729
730- **Questions?** Open a [GitHub Discussion](https://github.com/bgpkit/bgpkit-parser/discussions)
731- **Found a bug?** Submit a [GitHub Issue](https://github.com/bgpkit/bgpkit-parser/issues)
732
733*/
734
735#![doc(
736 html_logo_url = "https://raw.githubusercontent.com/bgpkit/assets/main/logos/icon-transparent.png",
737 html_favicon_url = "https://raw.githubusercontent.com/bgpkit/assets/main/logos/favicon.ico"
738)]
739
740#[cfg(feature = "parser")]
741pub mod encoder;
742pub mod error;
743pub mod models;
744#[cfg(feature = "parser")]
745pub mod parser;
746
747pub use models::BgpElem;
748pub use models::MrtRecord;
749#[cfg(feature = "parser")]
750pub use parser::*;