1 个不稳定版本

0.11.0 2024年3月24日

71#bgp

Download history • Rust 包仓库 2/week @ 2024-04-07 • Rust 包仓库 8/week @ 2024-04-21 • Rust 包仓库 25/week @ 2024-04-28 • Rust 包仓库 9/week @ 2024-05-05 • Rust 包仓库 18/week @ 2024-05-12 • Rust 包仓库 7/week @ 2024-05-19 • Rust 包仓库 6/week @ 2024-05-26 • Rust 包仓库 55/week @ 2024-06-02 • Rust 包仓库 26/week @ 2024-06-09 • Rust 包仓库 50/week @ 2024-06-16 • Rust 包仓库 2/week @ 2024-06-23 • Rust 包仓库 17/week @ 2024-07-07 • Rust 包仓库 69/week @ 2024-07-14 • Rust 包仓库 25/week @ 2024-07-21 • Rust 包仓库

111 每月下载量
bgpsim 中使用

自定义许可证

44KB
895

BGPSim 生成网络的宏

此crate允许您使用方便的领域特定语言生成BGPSim网络和配置

use bgpsim::prelude::*;

fn main() -> Result<(), NetworkError> {
    let (t, (e0, b0, r0, r1, b1, e1)) = net! {
        Prefix = Ipv4Prefix;
        Ospf = GlobalOspf;
        links = {
            b0 -> r0: 1;
            b1 -> r1: 1;
            r0 -> r1: 1;
        };
        sessions = {
            e0!(1) -> b0;
            e1!(2) -> b1;
            r0 -> r1;
            r0 -> b0: client;
            r1 -> b1: client;
        };
        routes = {
            e0 -> "100.0.0.0/8" as {path: [1, 2, 3]};
            e1 -> "100.0.0.0/8" as {path: [2, 3]};
        };
        return (e0, b0, r0, r1, b1, e1)
    };

    // get the forwarding state
    let mut fw_state = t.get_forwarding_state();

    // check that all routes are correct
    assert_eq!(fw_state.get_paths(b0, prefix!("100.0.0.0/8" as))?, vec![vec![b0, r0, r1, b1, e1]]);
    assert_eq!(fw_state.get_paths(r0, prefix!("100.20.1.3/32" as))?, vec![vec![r0, r1, b1, e1]]);
    assert_eq!(fw_state.get_paths(r1, prefix!("100.2.0.0/16" as))?, vec![vec![r1, b1, e1]]);
    assert_eq!(fw_state.get_paths(b1, prefix!("100.0.0.0/24" as))?, vec![vec![b1, e1]]);

    Ok(())
}

依赖项

~1.5MB
~37K SLoC