MRT/BGP data parser written in Rust.

Overview

BGPKIT Parser

BGPKIT Parser aims to provides the most ergonomic MRT/BGP message parsing Rust API.

BGPKIT Parser has the following features:

  • performant: comparable to C-based implementations like bgpdump or bgpreader.
  • actively maintained: we consistently introduce feature updates and bug fixes, and support most of the relevant BGP RFCs.
  • ergonomic API: a three-line for loop can already get you started.
  • battery-included: ready to handle remote or local, bzip2 or gz data files out of the box

Examples

For complete examples, check out the examples folder.

Parsing single MRT file

Let's say we want to print out all the BGP announcements/withdrawal from a single MRT file, either located remotely or locally. Here is an example that does so.

use bgpkit_parser::BgpkitParser;
fn main() {
    let parser = BgpkitParser::new("http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2");
    for elem in parser {
        println!("{}", elem)
    }
}

Yes, it is this simple!

You can even do some more interesting iterator operations that are event shorter. For example, counting the number of announcements/withdrawals in that file:

use bgpkit_parser::BgpkitParser;
fn main() {
    let url = "http://archive.routeviews.org/bgpdata/2021.10/UPDATES/updates.20211001.0000.bz2";
    let count = BgpkitParser::new(url).into_iter().count();
    println!("total: {}", count);
}

and it prints out

total: 255849

Parsing multiple MRT files with BGPKIT Broker

BGPKIT Broker library provides search API for all RouteViews and RIPE RIS MRT data files. Using the broker's Rust API (bgpkit-broker), we can easily compile a list of MRT files that we are interested in for any time period and any data type (update or rib). This allows users to gather information without needing to know about locations of specific data files.

The example below shows a relatively more interesting example that does the following:

  • find all BGP archive data created on time 1634693400
  • filter to only BGP updates files
  • find all announcements originated from AS13335
  • print out the total count of the announcements
fn main(){
    // set broker query parameters
    let mut params = bgpkit_broker::QueryParams::new();
    params = params.start_ts(1634693400);
    params = params.end_ts(1634693400);
    params = params.data_type("update");
    let mut broker = bgpkit_broker::BgpkitBroker::new("https://api.broker.bgpkit.com/v1");
    broker.set_params(&params);

    // loop through data files found by broker
    for item in broker {
        
        // create a parser that takes an URL and automatically determine
        // the file location and file type, and handles data download and
        // decompression streaming intelligently
        let parser = BgpkitParser::new(item.url.as_str());

        // iterating through the parser. the iterator returns `BgpElem` one at a time.
        let elems = parser.into_elem_iter().map(|elem|{
            if let Some(origins) = &elem.origin_asns {
                if origins.contains(&13335) {
                    Some(elem)
                } else {
                    None
                }
            } else {
                None
            }
        }).filter_map(|x|x).collect::<Vec<BgpElem>>();
        log::info!("{} elems matches", elems.len());
    }
}

Data Representation

There are two key data structure to understand for the parsing results:MrtRecord and BgpElem.

MrtRecord: unmodified MRT information representation

The MrtRecord is the data strcutrue that holds the unmodified, complete information parsed from the MRT data file. The code definition of the MrtRecord is defined in the crate bgp-models (documentation).

pub struct MrtRecord {
    pub common_header: CommonHeader,
    pub message: MrtMessage,
}

pub enum MrtMessage {
    TableDumpMessage(TableDumpMessage),
    TableDumpV2Message(TableDumpV2Message),
    Bgp4Mp(Bgp4Mp),
}

MrtRecord record representation is concise, storage efficient, but often less convenient to use. For example, when trying to find out specific BGP announcements for certain IP prefix, we often needs to go through nested layers of internal data structure (NLRI, announced, prefix, or even looking up peer index table for Table Dump V2 format), which could be irrelevant to what users really want to do.

BgpElem: per-prefix BGP information, MRT-format-agnostic

To facilitate simpler data analysis of BGP data, we defined a new data structure called BgpElem in this crate. Each BgpElem contains a piece of self-containing BGP information about one single IP prefix. For example, when a bundled announcement of three prefixes P1, P2, P3 that shares the same AS path is processed, we break the single record into three different BgpElem objects, each presenting a prefix.

pub struct BgpElem {
    pub timestamp: f64,
    pub elem_type: ElemType,
    pub peer_ip: IpAddr,
    pub peer_asn: Asn,
    pub prefix: NetworkPrefix,
    pub next_hop: Option<IpAddr>,
    pub as_path: Option<AsPath>,
    pub origin_asns: Option<Vec<Asn>>,
    pub origin: Option<Origin>,
    pub local_pref: Option<u32>,
    pub med: Option<u32>,
    pub communities: Option<Vec<Community>>,
    pub atomic: Option<AtomicAggregate>,
    pub aggr_asn: Option<Asn>,
    pub aggr_ip: Option<IpAddr>,
}

The main benefit of using BgpElem is that the analysis can be executed on a per-prefix basis, generic to what the backend MRT data format (bgp4mp, tabledumpv1, tabledumpv2, etc.). The obvious drawback is that we will have to duplicate information to save at each elem, that consuming more memory.

Contribution

Issues and pull requests are welcome!

Built with ❤️ by BGPKIT Team

BGPKIT is a small-team start-up that focus on building the best tooling for BGP data in Rust. We have 10 years of experience working with BGP data and believe that our work can enable more companies to start keeping tracks of BGP data on their own turf. Learn more about what services we provide at https://bgpkit.com.

https://bgpkit.com/favicon.ico

Comments
  • Panic on BGP4MP_ET File

    Panic on BGP4MP_ET File

    Example file: http://archive.routeviews.org/route-views.amsix/bgpdata/2020.06/UPDATES/updates.20200617.1830.bz2

    This file crashes the provided example. Bgpdump can read it and reports it as BGP4MP_ET, while bgpscanner also struggles parsing it.

    bug 
    opened by SZenglein 17
  • Consider reexporting bgpkit-models

    Consider reexporting bgpkit-models

    Right now you left bgp-models = "0.7.0-alpha.4" on an older version. Using the library is a bit cumbersome because you have to use the exact same bgp-models version if you want to do more with it. For this reason, lots of rust crates reexport their related dependencies.

    Also consider bumping the bgp-models version.

    opened by SZenglein 2
  • Split IO components out into different crate

    Split IO components out into different crate

    Currently, we are going with the battery included approach for the parser. It might make more sense to put the IO code into a separate feature flag, and keep the main parser code concise.

    Current IO trait usages also prevented us from porting the code to WASM.

    enhancement 
    opened by digizeph 2
  • [bug] cannot parse route-views5 recent rib file

    [bug] cannot parse route-views5 recent rib file

    bgpkit-parse (monocle parse) and bgpreader cannot read the recent rib files, but bgpdump works fine (seemingly).

    Example: http://archive.routeviews.org/route-views5/bgpdata/2022.08/RIBS/rib.20220801.0000.bz2

    monocle --debug parse rib.20220801.0000.bz2

    2022-08-04T18:16:09.581900Z  WARN bgpkit_parser::parser::bgp::attributes: PARTIAL: Error: unsupported attribute type: RESERVED
    A|1659312000|185.156.96.227|207934|1.6.166.0/24|207934 3292 6453 4755 9583|IGP|185.156.96.227|0|0|3292:1100 3292:24901 65000:100|NAG||
    A|1659312000|103.247.3.36|58511|1.6.166.0/24|58511 3491 6453 4755 9583|IGP|103.247.3.36|0|0||NAG||
    A|1659312000|170.39.196.252|33185|1.6.166.0/24|33185 174 6453 4755 9583|IGP|170.39.196.252|0|0||NAG||
    A|1659312000|91.216.79.0|41666|1.6.166.0/24|41666 58299 6830 6453 4755 9583|IGP|91.216.79.0|0|0|6453:2000 6453:2100 6453:2104 6453:10001 6453:10002 6830:17000 6830:17457 6830:23001 6830:33104 41666:1000 58299:1000|NAG||
    A|1659312000|87.239.48.250|211398|1.6.166.0/24|211398 34854 3257 6453 4755 9583|IGP|87.239.48.250|0|0|3257:8052 3257:30110 3257:50001 3257:54900 3257:54901 34854:3005 lg:211398:255:100 lg:211398:555:555 lg:211398:2760255:34854|NAG||
    A|1659312000|23.159.240.61|40864|1.6.166.0/24|40864 6461 6453 4755 9583|IGP|23.159.240.61|0|0|6461:5997|NAG||
    A|1659312000|87.239.48.250|211398|1.6.166.0/24|211398 34927 174 6453 4755 9583|IGP|87.239.48.250|0|0|174:21100 174:22010 34927:710 34927:747 lg:211398:252:100 lg:211398:5280252:34927|NAG||
    A|1659312000|87.239.48.250|211398|1.6.166.0/24|211398 34854 3257 6453 4755 9583|IGP|87.239.48.250|0|0|3257:8052 3257:30110 3257:50001 3257:54900 3257:54901 34854:3005 lg:211398:245:100 lg:211398:2760245:34854|NAG||
    A|1659312000|87.239.48.250|211398|1.6.166.0/24|211398 57695 60068 174 6453 4755 9583|IGP|87.239.48.250|0|0|174:21100 174:22012 57695:13000 60068:203 60068:2000 60068:2010 60068:7040 lg:211398:250:100 lg:211398:8260250:57695|NAG||
    A|1659312000|103.247.3.142|58511|1.6.166.0/24|58511 1299 6453 4755 9583|IGP|103.247.3.142|0|0|58511:100 58511:9005|NAG||
    A|1659312000|170.39.196.252|33185|1.6.218.0/24|33185 174 6453 4755 9583|INCOMPLETE|170.39.196.252|0|0||NAG||
    A|1659312000|103.247.3.142|58511|1.6.218.0/24|58511 3491 6453 4755 9583|IGP|103.247.3.142|0|0|58511:100 58511:9005|NAG||
    A|1659312000|87.239.48.250|211398|1.6.218.0/24|211398 34854 3257 6453 4755 9583|INCOMPLETE|87.239.48.250|0|0|3257:8052 3257:30110 3257:50001 3257:54900 3257:54901 34854:3005 lg:211398:255:100 lg:211398:555:555 lg:211398:2760255:34854|NAG||
    A|1659312000|103.247.3.36|58511|1.6.218.0/24|58511 3491 6453 4755 9583|IGP|103.247.3.36|0|0||NAG||
    A|1659312000|91.216.79.0|41666|1.6.218.0/24|41666 58299 6830 6453 4755 9583|INCOMPLETE|91.216.79.0|0|0|6453:2000 6453:2100 6453:2104 6453:10001 6453:10002 6830:17000 6830:17457 6830:23001 6830:33104 41666:1000 58299:1000|NAG||
    A|1659312000|23.159.240.61|40864|1.6.218.0/24|40864 6461 6453 4755 9583|INCOMPLETE|23.159.240.61|0|0|6461:5997|NAG||
    A|1659312000|87.239.48.250|211398|1.6.218.0/24|211398 57695 60068 174 6453 4755 9583|INCOMPLETE|87.239.48.250|0|0|174:21100 174:22012 57695:13000 60068:203 60068:2000 60068:2010 60068:7040 lg:211398:250:100 lg:211398:8260250:57695|NAG||
    A|1659312000|87.239.48.250|211398|1.6.218.0/24|211398 48646 50629 3356 6453 4755 9583|IGP|87.239.48.250|0|0|3356:2 3356:86 3356:501 3356:666 3356:901 3356:2065 6453:2000 6453:2100 6453:2104 6453:10001 6453:10002 50629:180 50629:306 50629:1000 50629:10001 50629:10104 50629:10208 lg:48646:0:101 lg:211398:245:100 lg:211398:2760245:48646|NAG||
    A|1659312000|87.239.48.250|211398|1.6.218.0/24|211398 34927 174 6453 4755 9583|INCOMPLETE|87.239.48.250|0|0|174:21100 174:22010 34927:710 34927:747 lg:211398:252:100 lg:211398:5280252:34927|NAG||
    A|1659312000|185.156.96.227|207934|1.6.218.0/24|207934 3292 6453 4755 9583|INCOMPLETE|185.156.96.227|0|0|3292:1100 3292:24901 65000:100|NAG||
    A|1659312000|170.39.196.252|33185|1.7.141.0/24|33185 174 6453 4755 9583|IGP|170.39.196.252|0|0||NAG||
    A|1659312000|103.247.3.142|58511|1.7.141.0/24|58511 1299 6453 4755 9583|IGP|103.247.3.142|0|0|58511:100 58511:9005|NAG||
    A|1659312000|87.239.48.250|211398|1.7.141.0/24|211398 34854 3257 6453 4755 9583|IGP|87.239.48.250|0|0|3257:8052 3257:30110 3257:50001 3257:54900 3257:54901 34854:3005 lg:211398:255:100 lg:211398:555:555 lg:211398:2760255:34854|NAG||
    A|1659312000|103.247.3.36|58511|1.7.141.0/24|58511 3491 6453 4755 9583|IGP|103.247.3.36|0|0||NAG||
    A|1659312000|91.216.79.0|41666|1.7.141.0/24|41666 58299 6830 6453 4755 9583|IGP|91.216.79.0|0|0|6453:2000 6453:2100 6453:2104 6453:10001 6453:10002 6830:17000 6830:17457 6830:23001 6830:33104 41666:1000 58299:1000|NAG||
    A|1659312000|23.159.240.61|40864|1.7.141.0/24|40864 6461 6453 4755 9583|IGP|23.159.240.61|0|0|6461:5997|NAG||
    A|1659312000|87.239.48.250|211398|1.7.141.0/24|211398 34854 3257 6453 4755 9583|IGP|87.239.48.250|0|0|3257:8052 3257:30110 3257:50001 3257:54900 3257:54901 34854:3005 lg:211398:245:100 lg:211398:2760245:34854|NAG||
    A|1659312000|87.239.48.250|211398|1.7.141.0/24|211398 34927 174 6453 4755 9583|IGP|87.239.48.250|0|0|174:21100 174:22010 34927:710 34927:747 lg:211398:252:100 lg:211398:5280252:34927|NAG||
    A|1659312000|87.239.48.250|211398|1.7.141.0/24|211398 57695 60068 174 6453 4755 9583|IGP|87.239.48.250|0|0|174:21100 174:22012 57695:13000 60068:203 60068:2000 60068:2010 60068:7040 lg:211398:250:100 lg:211398:8260250:57695|NAG||
    A|1659312000|185.156.96.227|207934|1.7.141.0/24|207934 3292 6453 4755 9583|IGP|185.156.96.227|0|0|3292:1100 3292:24901 65000:100|NAG||
    2022-08-04T18:16:09.583772Z  WARN bgpkit_parser::parser::bgp::attributes: PARTIAL: Error: unsupported attribute type: RESERVED
    2022-08-04T18:16:09.583779Z  WARN bgpkit_parser::parser::bgp::attributes: Error: unsupported attribute type: TUNNEL_ENCAPSULATION
    2022-08-04T18:16:09.584581Z  WARN bgpkit_parser::parser::bgp::attributes: PARTIAL: Error: unsupported attribute type: RESERVED
    2022-08-04T18:16:09.584589Z  WARN bgpkit_parser::parser::bgp::attributes: Error: unsupported attribute type: RESERVED
    2022-08-04T18:16:09.584591Z  WARN bgpkit_parser::parser::bgp::attributes: Error: unsupported attribute type: BFD_DISCRIMINATOR
    2022-08-04T18:16:09.586025Z  WARN bgpkit_parser::parser::bgp::attributes: Error: unsupported attribute type: RESERVED
    

    bgpreader -d singlefile -o rib-file=http://archive.routeviews.org/route-views5/bgpdata/2022.08/RIBS/rib.20220801.0000.bz2

    WARN: No time window specified, defaulting to all available data
    2022-08-04 11:16:39 29593: bgpstream_parsebgp_common.c:601: ERROR: Failed to parse message from 'http://archive.routeviews.org/route-views5/bgpdata/2022.08/RIBS/rib.20220801.0000.bz2' (-2:Invalid Message)
    

    The first few messages from bgpdump results:

    TIME: 08/01/22 00:00:00
    TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH
    PREFIX: 1.0.0.0/24 PATH_ID: 27
    SEQUENCE: 0
    FROM: 87.239.48.250 AS211398
    ORIGINATED: 07/31/22 22:10:52
    ORIGIN: IGP
    ASPATH: 211398 34854 3257 13335
    NEXT_HOP: 87.239.48.250
    AGGREGATOR: AS13335 162.158.84.50
    COMMUNITY: 3257:4000 3257:8794 3257:50001 3257:50110 3257:54900 3257:54901 34854:3005 65000:4134 65001:3320 65002:5511
    LARGE_COMMUNITY: 211398:255:100 211398:555:555 211398:2760255:34854
    
    TIME: 08/01/22 00:00:00
    TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH
    PREFIX: 1.0.0.0/24 PATH_ID: 0
    SEQUENCE: 0
    FROM: 91.216.79.0 AS41666
    ORIGINATED: 07/28/22 20:05:54
    ORIGIN: IGP
    ASPATH: 41666 13335
    NEXT_HOP: 91.216.79.0
    AGGREGATOR: AS13335 141.101.65.254
    COMMUNITY: 13335:10020 13335:19020 13335:20050 13335:20500 13335:20530
    
    TIME: 08/01/22 00:00:00
    TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH
    PREFIX: 1.0.0.0/24 PATH_ID: 0
    SEQUENCE: 0
    FROM: 23.159.240.61 AS40864
    ORIGINATED: 07/26/22 11:44:55
    ORIGIN: IGP
    ASPATH: 40864 6461 13335
    NEXT_HOP: 23.159.240.61
    AGGREGATOR: AS13335 108.162.239.1
    COMMUNITY: 6461:5997
    
    TIME: 08/01/22 00:00:00
    TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH
    PREFIX: 1.0.0.0/24 PATH_ID: 23
    SEQUENCE: 0
    FROM: 87.239.48.250 AS211398
    ORIGINATED: 07/31/22 06:39:27
    ORIGIN: IGP
    ASPATH: 211398 48646 50629 13335
    NEXT_HOP: 87.239.48.250
    AGGREGATOR: AS13335 162.158.200.1
    COMMUNITY: 13335:10075 13335:19020 13335:20050 13335:20500 13335:20530 50629:200 50629:201 50629:334 50629:1000 50629:10001 50629:10102 50629:10205
    LARGE_COMMUNITY: 48646:0:101 211398:245:100 211398:2760245:48646
    
    TIME: 08/01/22 00:00:00
    TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH
    PREFIX: 1.0.0.0/24 PATH_ID: 21
    SEQUENCE: 0
    FROM: 87.239.48.250 AS211398
    ORIGINATED: 07/27/22 13:26:51
    ORIGIN: IGP
    ASPATH: 211398 34927 13335
    NEXT_HOP: 87.239.48.250
    AGGREGATOR: AS13335 141.101.65.254
    COMMUNITY: 13335:10020 13335:19020 13335:20050 13335:20500 13335:20530 34927:130 34927:153 34927:730 34927:732
    LARGE_COMMUNITY: 211398:252:100 211398:5280252:34927
    
    TIME: 08/01/22 00:00:00
    TYPE: TABLE_DUMP_V2/IPV4_UNICAST_ADDPATH
    PREFIX: 1.0.0.0/24 PATH_ID: 0
    SEQUENCE: 0
    FROM: 185.156.96.227 AS207934
    ORIGINATED: 07/29/22 12:31:33
    ORIGIN: IGP
    ASPATH: 207934 13335
    NEXT_HOP: 185.156.96.227
    AGGREGATOR: AS13335 162.158.132.1
    COMMUNITY: 13335:10065 13335:19020 13335:20050 13335:20500 13335:20530 65000:200 65001:26301
    
    bug 
    opened by digizeph 1
  • [enhancement] display of ASN in JSON output should be simpler

    [enhancement] display of ASN in JSON output should be simpler

    Currently, the origin_asns field serialization results in JSON is too complex, having asn and len fields both are not necessary.

    {
      "aggr_asn": {
        "asn": 56446,
        "len": "Bits32"
      },
      "aggr_ip": "10.124.35.254",
      "as_path": "37100 174 1273 12389 201776 47598 56446",
      "atomic": "AG",
      "communities": [
        "no-export"
      ],
      "elem_type": "ANNOUNCE",
      "local_pref": 0,
      "med": 0,
      "next_hop": "105.16.0.247",
      "origin": "IGP",
      "origin_asns": [
        {
          "asn": 56446,
          "len": "Bits32"
        }
      ],
      "peer_asn": {
        "asn": 37100,
        "len": "Bits32"
      },
      "peer_ip": "105.16.0.247",
      "prefix": "188.191.144.0/23",
      "timestamp": 1658818160.124686
    }
    
    enhancement 
    opened by digizeph 1
  • [feature] support extended community type for RFC9015

    [feature] support extended community type for RFC9015

    BGP Control Plane for the Network Service Header in Service Function Chaining https://datatracker.ietf.org/doc/html/rfc9015

    This extended community has already been seen in the wild. Example MRT: http://archive.routeviews.org/route-views.amsix/bgpdata/2021.12/UPDATES/updates.20211206.2030.bz2

    Error: Failed to parse extended community type: 11
    
    enhancement 
    opened by digizeph 1
  • [feature] allow dump raw bytes for development purpose

    [feature] allow dump raw bytes for development purpose

    When debugging, it is often to separate raw bytes and dump problematic record bytes out.

    • [X] allow reading from raw bytes (uncompressed file) (fixed by #38)
    • [x] attach raw bytes when populating error out
    • [x] allow writing mrt record's raw bytes out to flie
    opened by digizeph 1
  • Reduce minimum supported Rust version

    Reduce minimum supported Rust version

    Currently, we are relying on edition 2021 for no good reason. This makes the library's minimum supported Rust version (MSRV) to be 1.56, which may be undesirable for users with older Rust version. We should bring down the MSRV.

    Similar issue for ris-live-rs: https://github.com/bgpkit/ris-live-rs/issues/2

    enhancement 
    opened by digizeph 1
  • Redesign `BgpElem` to allow using references instead of cloning data

    Redesign `BgpElem` to allow using references instead of cloning data

    Currently, when converting MRT records to BgpElems, we do a lot of clones of the common data fields, when only the prefixes are different. This is potentially a performance downgrade point.

    In a better design, the BgpElem should be containing references instead of all owned data. By doing so, we can reduce the number of data clones, and potentially improve the parsing performance.

    opened by digizeph 1
  • [feature] async implementation

    [feature] async implementation

    The core idea of reading and then parsing bytes is naturally async since the reading and parsing are logically separate tasks and can be implemented with Rust Async.

    Adding async would also allow the parse to be used in async environment, greatly improving the performance in heavy reading environment. This would also allow downstream consumer to use async reqwest calls.

    opened by digizeph 1
  • Performance improvement

    Performance improvement

    This is an issue tracking efforts on improving the parsing performance to reach the level of other C implementation.

    enhancement 
    opened by digizeph 1
  • IPv6 address parsing

    IPv6 address parsing

    When parsing some RIB files , there are sometimes messages about IPv6 address cannot be parsed.

    2022-11-07T23:11:55.765747Z  WARN bgpkit_parser::parser::bgp::attributes: Error: Cannot parse IPv6 address    
    

    We should investigate the root cause of this issue.

    opened by digizeph 0
  • Add support for std::io::Read

    Add support for std::io::Read

    It would be helpful to have support for using std::io::Read types directly as input sources when parsing BGP data.

    For example, one use-case of this would be parsing BGP messages from non-local or memory sources.

    let mut http_stream = ureq::get("https://data.ris.ripe.net/rrc00/2022.01/bview.20220126.1600.gz").call()?.into_reader();
    process_bgp_msgs(http_stream)?;
    
    // Generic over any given read source
    fn process_bgp_msgs<R: Read>(source: R) -> io::Result<()> {
        let mut reader = BgpkitParser::for_reader(source);
        for message in reader {
            // Propogate reader errors
            do_foo(message?);
        }
    }
    

    Additionally, it would be helpful if this extended to individual BGP messages as well. Functions such as parse_ris_live_message, parse_bmp_msg, parse_openbmp_header, parse_openbmp_msg, and parse_mrt_record already exist, but take inconsistent or non-standard inputs (&mut DataBytes, &str, and T: Read). Ideally these would all be standardized to accept T: Read and/or &[u8].

    This change will likely require the complete redesign or removal of DataBytes due to its current requirement on reading the entire source into memory before parsing. Supporting a generic Read interface could greatly improve memory usage by only loading the data source as it is needed. One possible replacement for DataBytes would be using the byteorder crate to read big-endian values from a Read source and std::io::Read::take for limits.

    Support for std::io::Write could also be helpful, but there are far fewer use-cases for that functionality.

    enhancement 
    opened by jmeggitt 0
  • Document how large and extended communities are displayed

    Document how large and extended communities are displayed

    Source code:

    • large community: https://github.com/bgpkit/bgp-models/blob/main/src/bgp/community.rs#L186
    • extended community: https://github.com/bgpkit/bgp-models/blob/main/src/bgp/community.rs#L192
    documentation 
    opened by digizeph 0
  • [feature] add benchmark

    [feature] add benchmark

    opened by digizeph 0
Releases(v0.8.1)
  • v0.8.1(Aug 10, 2022)

    What's Changed

    • remove handing afi outside attributes by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/73
      • this fixes #72

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.8.0...v0.8.1

    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Aug 7, 2022)

    Fixes

    • fix parsing add_path rib dump entry by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/68

    New features

    • add struct to allow configure parser by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/64

    Revisions

    • rename binary to bgpkit-parser; update clap by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/69
      • no more bgpkit-parser-cli, it's just bgpkit-parser now
    • move io to oneio by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/70
    • update bgp-models to 0.8.0 for revised serialization by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/71

    The revised JSON serialization now looks like the following:

    {
      "aggr_asn": 4260035625,
      "aggr_ip": "10.187.11.137",
      "as_path": "132280 210873",
      "atomic": "AG",
      "communities": [
        "2280:107",
        "2280:2280"
      ],
      "local_pref": 0,
      "med": 0,
      "next_hop": "203.159.68.122",
      "origin": "INCOMPLETE",
      "origin_asns": [
        210873
      ],
      "peer_asn": 132280,
      "peer_ip": "203.159.68.122",
      "prefix": "16.10.6.0/24",
      "timestamp": 1659830400,
      "type": "announce"
    }
    

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.7.3...v0.8.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.3(May 11, 2022)

    What's Changed

    • support multiple-peer filtering in cli tool by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/58
    • remove unnecessary dbg! calls in code by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/59

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.7.2...v0.7.3

    Source code(tar.gz)
    Source code(zip)
  • v0.7.2(Jan 30, 2022)

    What's Changed

    • add support for filtering on multiple peers (peer_ips) by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/56
    • re-export bgp_models by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/57

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.7.1...v0.7.2

    Source code(tar.gz)
    Source code(zip)
  • v0.7.1(Jan 14, 2022)

    What's new

    • Added derive of Send trait for BgpkitParser. This makes the parser instance thread-safe, and enables better Python binding support.
    • Added new example on paralle parsing with rayon.

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.7.0...v0.7.1

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Jan 3, 2022)

    New Features

    • Allow attempt to read from uncompressed file by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/38
    • Add filtering and iterator support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/43
      • Support prefix filtering with super and sub prefixes by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/45
      • Filter by record by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/50
    • Add support for OPEN message optional parameters by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/51
    • Bundle the cli with the main package by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/54
      • you can install bgpkit-parser-cli by running cargo install bgpkit-parser

    Improvements

    • Allow core-dump; refactor NLRI parsing for add-path issue by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/42
    • Use extended bgp-models types by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/49
    • Parsing performance improvements by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/52

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.6.0...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0-alpha.4(Dec 26, 2021)

  • v0.7.0-alpha.2(Dec 19, 2021)

    What's Changed Comparing to Alpha 1

    • Use extended bgp-models types by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/49

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.7.0-alpha.1...v0.7.0-alpha.2

    Source code(tar.gz)
    Source code(zip)
  • v0.7.0-alpha.1(Dec 16, 2021)

    What's Changed

    • allow attempt reading from uncompressed file by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/38
    • update bgp_models and support parsing devel attr by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/41
    • Allow core-dump; refactor NLRI parsing for add-path issue by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/42
    • add filtering and iterator support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/43
    • support prefix filtering with super and sub prefixes by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/45
    • Hotfix warnings by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/47

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.6.0...v0.7.0-alpha.1

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Dec 4, 2021)

    New Features

    • update io to stream processing by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/16
      • parser now starts parsing immediately as the bytes streams in
    • support display extended and large communities by @digizeph in #17 and #24
    • Add command-line helper tool for parsing individual MRT files by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/19
    • add benchmark framework by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/13

    Improvements

    • Better error handling by @digizeph in #7 and #8
    • use BgpElem from bgp_models crate by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/15
    • update parsing of collector and peer bgp id to ipv4addr by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/25
    • Reduce minimum supported Rust version to 1.48.0 by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/32

    Fixes

    • Fix truncated msg parsing by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/28
    • Resolves the issue where nlri fields having invalid bit_len by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/33

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.5.0...v0.6.0

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Nov 13, 2021)

    In this release, we added support for parsing real-time stream data from RIPE RIS Live and RouteViews OpenBMP stream.

    New Features

    • RIS Live support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/2
    • Add OpenBMP/BMP message parsing support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/4

    Improvements

    • Revamped BMP example with new choice of Kafka library for better stability
    • Extract to_elem function for BGP message structs, allow BMP messages to print out
    • Overall documentation improvements

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.4.3...v0.5.0

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0-rc.2(Nov 12, 2021)

    What's Changed Compared to 0.4.x

    • RIS Live support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/2
    • Add OpenBMP/BMP message parsing support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/4

    What's Changed Compared to RC.1

    • Revamped BMP example with new choice of Kafka library for better stability
    • Extract to_elem function for BGP message structs, allow BMP messages to print out
    • Overall documentation improvements

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.5.0-rc.1...v0.5.0-rc.2

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0-rc.1(Nov 11, 2021)

    In this release candidate, we added support for parsing two real-time BGP data stream messages support:

    • RIPE RIS Live JSON message stream
    • BMP/OpenBMP BGP data stream

    This release enables users to work with real-time data streams in addition to the historical MRT archives.

    What's Changed

    • RIS Live support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/2
    • Add OpenBMP/BMP message parsing support by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/4

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.4.3...v0.5.0-rc.1

    Source code(tar.gz)
    Source code(zip)
  • v0.4.3(Nov 9, 2021)

    What's Changed

    • Fix partial attribute parsing by @digizeph in https://github.com/bgpkit/bgpkit-parser/pull/3

    Full Changelog: https://github.com/bgpkit/bgpkit-parser/compare/v0.4.2...v0.4.3

    Source code(tar.gz)
    Source code(zip)
  • v0.4.2(Nov 1, 2021)

  • v0.4.1(Oct 25, 2021)

    Fixes

    • remove todo!() macro call for Open, Notification, and KeepAlive messages when converting MRT record to BgpElems
    • remove one other potential crashing todo!() call for unsupported TableDumpV2 Generic type
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Oct 25, 2021)

    Features

    • includes IO libraries to simplify the parsing API
      • reqwest, bzip2, and flate2 (for gzip files) are included as dependency
    • the BgpkitParser::new(path: &str) now takes a path to a data file (can be an URL or a local path), and it automatically handles file reading and ready for iteration afterwards
    • fleshed out the documentation for the library, but still need to work on individual modules.
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Oct 23, 2021)

    Features

    • complete BGP updates and RIB dump parsing capabilities
    • iterator for BgpElem and MrtRecord
    • examples to parse single file and parse multiple files with BGPKIT Broker
    Source code(tar.gz)
    Source code(zip)
Owner
BGPKIT
BGPKIT
Website for Microformats Rust parser (using 'microformats-parser'/'mf2')

Website for Microformats Rust parser (using 'microformats-parser'/'mf2')

Microformats 5 Jul 19, 2022
PEG parser for YAML written in Rust 🦀

yaml-peg PEG parser (pest) for YAML written in Rust ?? Quick Start ⚡️ # Run cargo run -- --file example_files/test.yaml # Output { "xmas": "true",

Visarut Phusua 4 Sep 17, 2022
gors is an experimental go toolchain written in rust (parser, compiler).

gors gors is an experimental go toolchain written in rust (parser, compiler). Install Using git This method requires the Rust toolchain to be installe

Aymeric Beaumet 12 Dec 14, 2022
🕑 A personal git log and MacJournal output parser, written in rust.

?? git log and MacJournal export parser A personal project, written in rust. WORK IN PROGRESS; NOT READY This repo consolidates daily activity from tw

Steven Black 4 Aug 17, 2022
A CSS parser, transformer, and minifier written in Rust.

@parcel/css A CSS parser, transformer, and minifier written in Rust. Features Extremely fast – Parsing and minifying large files is completed in milli

Parcel 3.1k Jan 9, 2023
A WIP svelte parser written in rust. Designed with error recovery and reporting in mind

Svelte(rs) A WIP parser for svelte files that is designed with error recovery and reporting in mind. This is mostly a toy project for now, with some v

James Birtles 3 Apr 19, 2023
A handwritten fault-tolerant, recursive-descent parser for PHP written in Rust.

PHP-Parser A handwritten fault-tolerant, recursive-descent parser for PHP written in Rust. Warning - this is still alpha software and the public API i

PHP Rust Tools 278 Jun 24, 2023
A native Rust port of Google's robots.txt parser and matcher C++ library.

robotstxt A native Rust port of Google's robots.txt parser and matcher C++ library. Native Rust port, no third-part crate dependency Zero unsafe code

Folyd 72 Dec 11, 2022
Rust parser combinator framework

nom, eating data byte by byte nom is a parser combinators library written in Rust. Its goal is to provide tools to build safe parsers without compromi

Geoffroy Couprie 7.6k Jan 7, 2023
Parsing Expression Grammar (PEG) parser generator for Rust

Parsing Expression Grammars in Rust Documentation | Release Notes rust-peg is a simple yet flexible parser generator that makes it easy to write robus

Kevin Mehall 1.2k Dec 30, 2022
A fast monadic-style parser combinator designed to work on stable Rust.

Chomp Chomp is a fast monadic-style parser combinator library designed to work on stable Rust. It was written as the culmination of the experiments de

Martin Wernstål 228 Oct 31, 2022
A parser combinator library for Rust

combine An implementation of parser combinators for Rust, inspired by the Haskell library Parsec. As in Parsec the parsers are LL(1) by default but th

Markus Westerlind 1.1k Dec 28, 2022
LR(1) parser generator for Rust

LALRPOP LALRPOP is a Rust parser generator framework with usability as its primary goal. You should be able to write compact, DRY, readable grammars.

null 2.4k Jan 7, 2023
A typed parser generator embedded in Rust code for Parsing Expression Grammars

Oak Compiled on the nightly channel of Rust. Use rustup for managing compiler channels. You can download and set up the exact same version of the comp

Pierre Talbot 138 Nov 25, 2022
Rust query string parser with nesting support

What is Queryst? This is a fork of the original, with serde and serde_json updated to 0.9 A query string parsing library for Rust inspired by https://

Stanislav Panferov 67 Nov 16, 2022
Soon to be AsciiDoc parser implemented in rust!

pagliascii "But ASCII Doc, I am Pagliascii" Soon to be AsciiDoc parser implemented in rust! This project is the current implementation of the requeste

Lukas Wirth 49 Dec 11, 2022
This project aims to implement a CSS(less like) parser in rust. Currently the code is targeting the PostCSS AST.

CSS(less like) parser written in rust (WIP) This project aims to implement a CSS(less like) parser in rust. Currently the code is targeting the PostCS

Huang Liuhaoran 21 Aug 23, 2022
This project aims to implement a CSS(less like) parser in rust. Currently the code is targeting the PostCSS AST. Very early stage, do not use in production.

CSS(less like) parser written in rust (WIP) This project aims to implement a CSS(less like) parser in rust. Currently the code is targeting the PostCS

Huang Liuhaoran 21 Aug 23, 2022
A feature-few, no-allocation JSON parser in `no_std` rust.

Small JSON Parser in no_std This library reads and parses JSON strings. Its intended use case is to read a JSON payload once. It does not serialise da

Robert Spencer 18 Nov 29, 2022