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

Overview

BGPKIT Parser

Rust

BGPKIT Parser aims to provides the most ergonomic MRT/BGP/BMP 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
>(); log::info!("{} elems matches", elems.len()); } } ">
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
   >();
        log
   ::
   info!(
   "{} elems matches", elems.
   len());
    }
}
  

Parsing Real-time Data Streams

BGPKIT Parser also provides parsing functionalities for real-time data streams, including RIS-Live and BMP/OpenBMP messages. See the examples below and the documentation for more.

Parsing Messages From RIS-Live

Here is an example of handling RIS-Live message streams. After connecting to the websocket server, we need to subscribe to a specific data stream. In this example, we subscribe to the data stream from on collector (rrc21). We can then loop and read messages from the websocket.

use bgpkit_parser::parse_ris_live_message;
use serde_json::json;
use tungstenite::{connect, Message};
use url::Url;

const RIS_LIVE_URL: &str = "ws://ris-live.ripe.net/v1/ws/?client=rust-bgpkit-parser";

/// This is an example of subscribing to RIS-Live's streaming data from one host (`rrc21`).
///
/// For more RIS-Live details, check out their documentation at https://ris-live.ripe.net/manual/
fn main() {
    // connect to RIPE RIS Live websocket server
    let (mut socket, _response) =
        connect(Url::parse(RIS_LIVE_URL).unwrap())
            .expect("Can't connect to RIS Live websocket server");

    // subscribe to messages from one collector
    let msg = json!({"type": "ris_subscribe", "data": {"host": "rrc21"}}).to_string();
    socket.write_message(Message::Text(msg)).unwrap();

    loop {
        let msg = socket.read_message().expect("Error reading message").to_string();
        if let Ok(elems) = parse_ris_live_message(msg.as_str()) {
            for elem in elems {
                println!("{}", elem);
            }
        }
    }
}

Parsing OpenBMP Messages From RouteViews Kafka Stream

RouteViews provides a real-time Kafka stream of the OpenBMP data received from their collectors. Below is an partial example of how we handle the raw bytes received from the Kafka stream. For full examples, check out the examples folder on GitHub.

{} } } Err(_e) => { let hex = hex::encode(bytes); error!("{}", hex); break } } ">
let bytes = m.value;
let mut reader = Cursor::new(Vec::from(bytes));
let header = parse_openbmp_header(&mut reader).unwrap();
let bmp_msg = parse_bmp_msg(&mut reader);
match bmp_msg {
    Ok(msg) => {
        let timestamp = header.timestamp;
        let per_peer_header = msg.per_peer_header.unwrap();
        match msg.message_body {
            MessageBody::RouteMonitoring(m) => {
                for elem in Elementor::bgp_to_elems(
                    m.bgp_message,
                    timestamp,
                    &per_peer_header.peer_ip,
                    &per_peer_header.peer_asn
                )
                {
                    info!("{}", elem);
                }
            }
            _ => {}
        }
    }
    Err(_e) => {
        let hex = hex::encode(bytes);
        error!("{}", hex);
        break
    }
}

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
BGP Data Analysis Tool Kit
BGPKIT
A Rust implementation of the Message Layer Security group messaging protocol

Molasses An extremely early implementation of the Message Layer Security group messaging protocol. This repo is based on draft 4 of the MLS protocol s

Trail of Bits 109 Dec 13, 2022
A simple menu to keep all your most used one-liners and scripts in one place

Dama Desktop Agnostic Menu Aggregate This program aims to be a hackable, easy to use menu that can be paired to lightweight window managers in order t

null 47 Jul 23, 2022
An impish, cross-platform binary parsing crate, written in Rust

libgoblin Documentation https://docs.rs/goblin/ changelog Usage Goblin requires rustc 1.40.0. Add to your Cargo.toml [dependencies] goblin = "0.4" Fea

null 891 Dec 29, 2022
Extended precision integer Rust library. Provides signed/unsigned integer 256 to 2048.

Extended precision integer Rust library. Provides signed/unsigned integer 256 to 2048.

Mohanson 4 Jul 28, 2022
Safe Rust interface to the Vulkan API.

Magma: A strictly typed Vulkan API interface. Magma is a strictly typed Rust interface for the vulkan API. This means that whenever possible, the well

null 1 Oct 11, 2022
Attempts to suspend all known AV/EDRs processes on Windows using syscalls and the undocumented NtSuspendProcess API. Made with <3 for pentesters. Written in Rust.

Ronflex Attempts to suspend all known AV/EDRs processes on Windows using syscalls and the undocumented NtSuspendProcess API. Made with <3 for penteste

null 5 Apr 17, 2023
Kepler is a vulnerability database and lookup store and API currently utilising National Vulnerability Database and NPM Advisories as data sources

Kepler — Kepler is a vulnerability database and lookup store and API currently utilising National Vulnerability Database and NPM Advisories as data so

Exein.io 101 Nov 12, 2022
Detects usage of unsafe Rust in a Rust crate and its dependencies.

cargo-geiger ☢️ Looking for maintainer: https://github.com/rust-secure-code/cargo-geiger/issues/210 A program that lists statistics related to the usa

Rust Secure Code Working Group 1.1k Jan 4, 2023
An esoteric language/compiler written with Rust and Rust LLVM bindings

MeidoLang (メイドラング) A not so useful and esoteric language. The goal of this project was to contain some quirky or novel syntax in a stack-style program

null 0 Dec 24, 2021
Rust-verification-tools - RVT is a collection of tools/libraries to support both static and dynamic verification of Rust programs.

Rust verification tools This is a collection of tools/libraries to support both static and dynamic verification of Rust programs. We see static verifi

null 253 Dec 31, 2022
Rust bindings for libinjection

libinjection-rs Rust bindings for libinjection. How to use Add libinjection to dependencies of Cargo.toml: libinjection = "0.2" Import crate: extern c

ArvanCloud 35 Sep 24, 2022
A simple password manager written in Rust

ripasso A simple password manager written in Rust. The root crate ripasso is a library for accessing and decrypting passwords stored in pass format (G

Joakim Lundborg 548 Dec 26, 2022
tcp connection hijacker, rust rewrite of shijack

rshijack tcp connection hijacker, rust rewrite of shijack from 2001. This was written for TAMUctf 2018, brick house 100. The target was a telnet serve

null 377 Jan 1, 2023
A fast, simple, recursive content discovery tool written in Rust.

A simple, fast, recursive content discovery tool written in Rust ?? Releases ✨ Example Usage ✨ Contributing ✨ Documentation ?? ?? What the heck is a f

epi 3.6k Dec 30, 2022
link is a command and control framework written in rust

link link is a command and control framework written in rust. Currently in alpha. Table of Contents Introduction Features Feedback Build Process Ackno

null 427 Dec 24, 2022
CVEs for the Rust standard library

Rust CVE Preface This is a list of CVEs for unsound APIs in the Rust standard library. These bugs break Rust's memory safety guarantee and lead to sec

Yechan Bae 26 Dec 4, 2022
Rust bindings for VirusTotal/Yara

yara-rust Bindings for the Yara library from VirusTotal. More documentation can be found on the Yara's documentation. Example The implementation is in

null 43 Dec 17, 2022
Rust library for building and running BPF/eBPF modules

RedBPF A Rust eBPF toolchain. Overview The redbpf project is a collection of tools and libraries to build eBPF programs using Rust. It includes: redbp

foniod 1.5k Jan 1, 2023
Rust library for developing safe canisters.

IC Kit This library provides an alternative to ic-cdk that can help developers write canisters and unit test them in their Rust code. Install Add this

Psychedelic 26 Nov 28, 2022