GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - irino/netsim: Network Simulator

BranchesTags
Open more actions menu

Latest commit

 

History

75 Commits
75 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
crates
crates
 
 
docs
docs
 
 
examples
examples
 
 
tests/golden
tests/golden
 
 
.gitignore
.gitignore
 
 
AGENTS.md
AGENTS.md
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

netsim

A Rust-based multi-vendor network configuration translator, topology synthesizer, static verification engine, and Containerlab network emulation orchestrator.

Documentation

  • English User Guide & Samples: docs/en/how-to-use.md
  • Japanese User Guide (使い方ガイド・サンプル解説): docs/ja/how-to-use-ja.md
  • Design Memo (EN): docs/en/netsim-design-memo.md
  • Design Memo (JA): docs/ja/netsim-design-memo-ja.md
  • Samples Directory: examples/

Project Workspace Structure

  • crates/ir: Vendor-independent Intermediate Representation data models (DeviceConfig, Interface, OspfProcess, IsisProcess, PrefixList, PolicyDefinition, InterfaceVxlanConfig, SegmentRoutingConfig, SrV6Config) aligned with IETF YANG models.
  • crates/parse-ios: Cisco IOS configuration parser built with winnow.
  • crates/parse-junos: Junos set-format configuration parser built with winnow.
  • crates/parse-eos: Arista EOS configuration parser built with winnow.
  • crates/parse-iosxr: Cisco IOS XR configuration parser built with winnow.
  • crates/parse-frr: FRRouting / SONiC configuration parser built with winnow.
  • crates/parse-srlinux: Nokia SR Linux YANG-modeled JSON configuration parser (serde_json).
  • crates/parse-sros: Nokia SR OS configuration parser built with winnow: classic CLI (indented hierarchical configure) plus MD-CLI brace-style (info output) and flat (admin save) formats, auto-detected.
  • crates/topology: Network topology inference engine calculating point-to-point links and multi-access LAN bridge segments across devices.
  • crates/emit-zebra: zebra-rs YAML configuration emitter conforming to authoritative zebra-rs YANG/YAML schema.
  • crates/emit-frr: FRRouting (frr.conf and daemons) configuration emitter for multi-engine container emulation.
  • crates/emit-holo: Holo routing daemon (holod) configuration emitter producing RFC 7951 JSON (ietf-system, ietf-interfaces, ietf-routing/ietf-ospf) for convert --engine holo.
  • crates/emit-srlinux: Nokia SR Linux configuration JSON emitter; the exact inverse of the parse-srlinux subset (hostname, interfaces/addresses, default network-instance OSPFv2/OSPFv3, BGP groups/neighbors, static routes via next-hop-groups), with parse->emit->parse round-trip tests over the real parser fixtures.
  • crates/emit-junos: Junos set-format configuration emitter; the exact inverse of the parse-junos subset (hostname, interfaces/units with inet/inet6, OSPF/OSPFv3, IS-IS, BGP groups/neighbors, static routes, prefix/community lists, policy-statements, EVPN/VXLAN, SRv6), with parse->emit->parse round-trip tests over the parser fixtures. The output doubles as the startup-config for Containerlab's vrnetlab Junos kinds (juniper_vjunosrouter, juniper_vmx), which apply flat set-format files at boot.
  • crates/emit-eos: Arista EOS configuration emitter; the exact inverse of the parse-eos subset (hostname, interfaces with IPv4/IPv6, OSPF/OSPFv3, IS-IS, BGP peer groups/neighbors/networks incl. the EVPN address family, static routes, prefix/community lists, route-maps, VXLAN, SRv6 locators), with parse->emit->parse round-trip tests over the parser fixtures. The output doubles as the startup-config for Containerlab's arista_ceos kind (cEOS-lab), which copies it to the node's flash/startup-config.
  • crates/reachability: Static reachability graph solver, consistency analyzer, intent assertion engine, and Batfish vendor-independent format exporter.
  • crates/emit-clab: Containerlab topology generator emitting *.clab.yml definitions with deterministic interface mappings, multi-engine support, and platform-driven native NOS kinds (see the kind table under gen-lab below).
  • crates/import-netbox: NetBox REST API / snapshot importer mapping DCIM devices, interfaces and cables plus IPAM IP addresses into IR devices and explicit links (pure mapping layer shared by the live-API and offline snapshot paths).
  • crates/netsim-cli: Unified command-line interface providing convert, validate-holo, gen-lab, check, verify (alias: test), and netbox import subcommands.
  • crates/validate-yang: Automated IETF YANG schema validation and drift testing engine backed by libyang (yang3 and holo-yang).
  • examples/: Synthetic example configurations demonstrating multi-device network topologies (e.g., examples/ospf-3routers, examples/mixed-5vendors, examples/mixed-5vendors-ipv6).

Step-by-Step Usage Guide

Prerequisites

  • Rust toolchain: 1.80+ (rustup default stable)
  • C Compiler & CMake: gcc / clang, cmake
  • PCRE2 development library: libpcre2-dev (Debian/Ubuntu) or pcre2-devel (RHEL/CentOS)
  • Containerlab: (optional, for deploying emulation environments) Install guide
  • Docker: (optional, required by Containerlab)
  • Container images: quay.io/frrouting/frr:10.2.0 or zebra-rs:latest

1. Translating a Single Configuration (convert)

To translate a single vendor configuration file into a target engine configuration (zebra YAML or frr.conf):

# Cisco IOS to zebra-rs YAML
cargo run --bin netsim -- convert \
  --vendor ios \
  --engine zebra \
  --in examples/ospf-3routers/R1.cfg \
  --out R1.zebra.yaml

# Cisco IOS to FRRouting configuration
cargo run --bin netsim -- convert \
  --vendor ios \
  --engine frr \
  --in examples/ospf-3routers/R1.cfg \
  --out R1.frr.conf

# Junos set-format
cargo run --bin netsim -- convert \
  --vendor junos \
  --in examples/mixed-ios-junos/junos-r2.set \
  --out junos-r2.zebra.yaml

# Arista EOS
cargo run --bin netsim -- convert \
  --vendor eos \
  --in examples/mixed-3vendors/arista-r3.cfg \
  --out arista-r3.zebra.yaml

# Cisco IOS XR
cargo run --bin netsim -- convert \
  --vendor iosxr \
  --in examples/mixed-4vendors/iosxr-r4.cfg \
  --out iosxr-r4.zebra.yaml

# FRRouting / SONiC
cargo run --bin netsim -- convert \
  --vendor frr \
  --in examples/mixed-5vendors/frr-r5.cfg \
  --out frr-r5.zebra.yaml

Options:

  • --vendor <ios|junos|eos|iosxr|frr|srlinux|sros>: Input vendor configuration format (default: ios). Nokia hints sr-linux / sr-os are also accepted.
  • --engine <zebra|frr|holo>: Target runtime engine (zebra, frr, or holo for single-device Holo JSON via convert; default: zebra).
  • --in <FILE>: Path to the input vendor configuration file.
  • --out <FILE>: Destination path for the generated configuration file.
  • --validate-yang: With --engine holo, validate the generated JSON against the IETF YANG schemas (Holo's deviation modules applied) before writing it; the conversion fails and no output is written when the document is schema-invalid. Existing Holo JSON files can be checked with netsim validate-holo --in <FILE>. Schema validity does not guarantee that holod will accept or apply the configuration at runtime.

2. Generating Complete Emulation Labs (gen-lab)

The gen-lab command processes a folder containing multiple router configurations (.cfg, .set, .conf, or .txt), automatically identifies the vendor for each file, infers point-to-point links and shared multi-access LAN segments, emits all node configurations, builds a Containerlab topology definition, and produces a diagnostic report.

# 3-router Cisco IOS OSPF triangle
cargo run --bin netsim -- gen-lab \
  --configs ./examples/ospf-3routers/ \
  --out ./lab-ospf/ \
  --lab-name ospf-lab

# 2-router Cisco IOS eBGP peering
cargo run --bin netsim -- gen-lab \
  --configs ./examples/ebgp-2routers/ \
  --out ./lab-ebgp/ \
  --lab-name ebgp-lab

# Mixed 5-vendor Cisco IOS, Junos, Arista EOS, Cisco IOS XR, and FRRouting topology
cargo run --bin netsim -- gen-lab \
  --configs ./examples/mixed-5vendors/ \
  --out ./lab-mixed5/ \
  --engine frr \
  --lab-name mixed-lab

Generated Output Structure:

lab-mixed5/
├── arista-r3_frr.conf
├── arista-r3_daemons
├── cisco-r1_frr.conf
├── cisco-r1_daemons
├── topology.clab.yml         # Containerlab topology file
└── report.md                 # Diagnostic markdown report

Native Containerlab kinds: every parser records the source platform in the IR (ios, ios-xr, junos, eos, frr, sr-linux, sr-os; the NetBox importer stores its detected platform in the same field, using the same canonical strings). gen-lab selects each node's Containerlab kind from that platform:

IR platform Containerlab kind Image Startup config
sr-linux nokia_srlinux ghcr.io/nokia/srlinux:latest (public registry) Generated: <hostname>.srlinux.json written by emit-srlinux and referenced via startup-config:
sr-os nokia_sros vrnetlab/vr-sros:latest None yet
eos arista_ceos ceos:latest Generated: <hostname>.eos.cfg written by emit-eos and referenced via startup-config:
junos juniper_vjunosrouter vrnetlab/juniper_vjunos-router:latest Generated: <hostname>.junos.set written by emit-junos (flat set format, the form the vrnetlab Junos kinds apply) and referenced via startup-config:
ios cisco_csr1000v vrnetlab/vr-csr:latest None yet
ios-xr cisco_xrd ios-xr/xrd-control-plane:latest None yet
frr linux + FRR engine quay.io/frrouting/frr:10.2.0 Engine config (frr.conf/daemons)
(none / other) linux + selected engine engine image Engine config

Kind names and image conventions follow Containerlab's own kind documentation. Notes:

  • Only the SR Linux image is publicly pullable. Every other native image must be supplied by the user: SR OS / IOS CSR1000v images are built with vrnetlab from the user's own vendor software (the SR OS image in particular is NOT publicly distributed and cannot be redistributed), the Junos image is built with vrnetlab from the vJunos-router QCOW2, which Juniper offers as a free download (no account or license required) from its support portal, cEOS-lab is downloaded from Arista (account required) and imported with docker import as ceos:<version>, and XRd is downloaded from Cisco (active service account required; the image carries the name ios-xr/xrd-control-plane:<version>). IOS XR uses the container-native XRd kind rather than the XRv9k VM kind because XRd is Containerlab's documented container option for IOS XR and needs no QEMU layer. Each affected node produces an explicit warning in the generated topology output and in report.md.
  • No startup-config is generated yet for SR OS / IOS / IOS XR (there is no IR->vendor emitter for them in this repo), so those nodes boot with their default configuration; this is also stated in the per-node warnings. EOS nodes get a generated <hostname>.eos.cfg via emit-eos (the exact inverse of the parse-eos subset); per the Containerlab cEOS documentation, the arista_ceos kind copies that file to the node's flash/startup-config and boots with it instead of Containerlab's generated default config, so the default template's management boilerplate (admin user, eAPI/NETCONF services, Ma0 DHCP) is not part of the generated file — the generated config covers the device configuration the source config described. Junos nodes use the free vJunos-router kind (juniper_vjunosrouter) by default; if you have a licensed vMX image instead, change the node's kind: to juniper_vmx and image: to your vrnetlab/vr-vmx image in the generated topology file — the generated set-format startup-config applies to both kinds.
  • FRR intentionally stays a linux node running the FRR engine: FRR is a Linux routing daemon, not a NOS container image. Devices without a platform likewise keep the engine-driven linux behavior, and mixed native + engine topologies in one lab are supported. Engine config files are still generated for every device, but native-kind nodes do not bind them.
  • Forcing engine simulation (--force-engine): engine simulation is netsim's primary path — it runs paid-NOS configurations (IOS, Junos, IOS XR, …) on the free Rust engines (zebra-rs / FRR) without any vendor image. Native kinds are for when you do have the NOS image (including the free editions: SR Linux, cEOS-lab, vJunos). Pass --force-engine to gen-lab to emit every node as a linux container running the selected engine — engine config bound, sequential ethN link endpoints, no native startup-configs — regardless of platform. report.md then records that engine mode was forced and lists each platform whose native kind was overridden.

Link endpoint names: link endpoints are named after each node's real interfaces, using the endpoint naming convention Containerlab documents for the node's kind (some kinds — nokia_srlinux, cisco_xrd — reject plain ethN names, so the old sequential labels could make a native lab fail containerlab deploy):

IR platform IR interface name Endpoint in topology file
sr-linux ethernet-1/1 (subinterface suffix .0 stripped) e1-1
sr-linux ethernet-1/3/1 (breakout port) e1-3-1
sr-os port binding 1/1/1 (interface to-r1) 1/1/1 (verbatim; only the simplified 1/1/X alias is documented for the vrnetlab SR OS kind)
sr-os port binding 1/1/1:12 (VLAN-tagged) 1/1/1 (the physical port)
eos Ethernet1 / Ethernet1/1 eth1 / eth1_1
junos ge-0/0/0.0 (unit suffix stripped) ge-0/0/0
ios GigabitEthernet2 Gi2
ios-xr GigabitEthernet0/0/0/0 Gi0-0-0-0
frr / (none / other) any sequential ethN (unchanged)

Endpoint naming rules:

  • Management interfaces never become link endpoints (SR Linux mgmt0, CSR1000v GigabitEthernet1/Gi1, Junos fxp0/em0, EOS Management*/Ma0, IOS XR MgmtEth*): a link using one is omitted, with a warning in report.md.
  • SR OS endpoints come from the recorded port binding: SR OS router interfaces have logical names (to-r1), so parse-sros records each interface's port statement in the IR (Interface::port) and the endpoint is derived from that binding. The fallback below therefore only applies to SR OS interfaces with no binding in the config (e.g. the system interface), a binding that is not a 1/1/X port, or — for NetBox-imported devices, whose interface names are port names — an unconvertible name.
  • LAG-bound SR OS interfaces fall back too: a binding of lag-N cannot be named as a vr-sros endpoint, so the interface uses its ethN label with a warning that says it is LAG-bound.
  • Unconvertible names fall back to the sequential ethN label with a warning — e.g. IOS GigabitEthernet0/0 (CSR1000v has no slot/port form), Junos interfaces outside FPC 0/PIC 0, or the SR OS cases above (the vrnetlab SR OS docs prescribe the ethX scheme for such cases). A name is never invented silently.
  • Collisions fall back too: if two interfaces of one node map to the same endpoint (e.g. subinterfaces ethernet-1/1.0 and ethernet-1/1.1 of one SR Linux port), the later one uses its ethN label, with a warning.
  • Labs whose nodes are all linux kind (or platform-less) produce byte-identical output to before this naming was introduced.

3. Static Mathematical Reachability Checking (check)

Run fast static mathematical reachability checking, subnet consistency analysis, VTEP/SRv6 verification, and Batfish snapshot export prior to Containerlab deployment:

# Check static reachability and validate intent assertions across configurations:
cargo run --bin netsim -- check --configs ./examples/ospf-3routers/

# Check with Batfish vendor-independent format export:
cargo run --bin netsim -- check \
  --configs ./examples/ospf-3routers/ \
  --export-batfish ./batfish-snapshot.json

4. Automated Deployment & Verification (verify / test)

The verify command (aliased to test) automates the entire lifecycle:

  1. Deploys the Containerlab topology (containerlab deploy -t topology.clab.yml).
  2. Polls vtyctl show ip route / vtysh -c 'show ip route' on all nodes until routing protocols converge (or timeout).
  3. Executes automated data-plane ping tests across all inferred device loopbacks (both IPv4 & IPv6).
  4. Validates operational assertions defined in intent.yml (e.g. assert: ping r1 -> r5 loopback).
  5. Automatically tears down the lab (containerlab destroy -t topology.clab.yml --cleanup).
# Verify generated lab in ./lab-ospf/ with automated convergence check and loopback pings
cargo run --bin netsim -- verify --lab-dir ./lab-ospf/ --sudo

# Run static-only verification without deploying containers
cargo run --bin netsim -- verify --lab-dir ./lab-ospf/ --static-only

5. Importing Network Inventory from NetBox (netbox import)

Instead of vendor configuration files, a network can be imported from NetBox (DCIM devices/interfaces/cables + IPAM IP addresses) and then reproduced with the usual gen-lab pipeline. The importer writes one IR JSON file per device plus a netbox-topology.json (explicit links from cables, and the detected platform per device), and a netbox-import-report.md listing anything that could not be mapped.

# Live API (token read from the NETBOX_TOKEN environment variable; never logged)
NETBOX_TOKEN=... cargo run --bin netsim -- netbox import \
  --url https://netbox.example.com --site lab --out ./netbox-lab/

# Or offline, from a snapshot directory with devices.json / interfaces.json /
# cables.json / ip-addresses.json payloads
cargo run --bin netsim -- netbox import --from-dir ./snapshot/ --out ./netbox-lab/

# Reproduce the imported network in Containerlab (cables = explicit links)
cargo run --bin netsim -- gen-lab \
  --configs ./netbox-lab/ --links ./netbox-lab/netbox-topology.json \
  --out ./lab-netbox/ --lab-name netbox-lab

Platform (OS) detection per device uses, in order: a per-device or slug override from --platform-map <file> ({"slugs": {...}, "devices": {...}}), the NetBox platform slug, the platform's NAPALM driver name (only present in payloads from NetBox <= 3.5; removed in NetBox 3.6 and never part of the platform object embedded in device responses), and finally inference from the device-type manufacturer + model (e.g. Nokia 7220 IXR -> sr-linux, Nokia 7750 SR -> sr-os). Devices whose platform cannot be determined are reported and emitted without a platform. The detected platform is stored on each IR device (same canonical strings the parsers produce), so gen-lab boots the imported devices as native Containerlab kinds per the table in the gen-lab section above — e.g. sr-linux devices become nokia_srlinux nodes with a generated SR Linux startup-config, while sr-os devices become nokia_sros nodes whose vrnetlab-style image the user must build themselves (it cannot be redistributed).


Intent Assertion Specification (intent.yml)

# Single assertion shorthand:
assert: ping R1 -> R3 loopback

# Multiple assertions:
assertions:
  - ping R2 -> R1 loopback
  - ping R3 -> R2 loopback
  - ping R1 -> 1.1.1.1
  - route R1 has 10.0.23.0/24

Supported Vendors and Syntax Overview

  • Cisco IOS: Interfaces (IPv4/IPv6, VXLAN), OSPFv2, OSPFv3, IS-IS, BGP (peer groups, route reflectors, EVPN), SRv6 locators, prefix-lists, community-lists, route-maps.
  • Junos: Set format syntax (interfaces ... family inet/inet6/iso, routing-options static route, protocols ospf/ospf3/isis/bgp, EVPN/VXLAN, policy-statements).
  • Arista EOS: Interfaces (IPv4/IPv6, Vxlan), OSPFv2/OSPFv3, IS-IS, BGP, EVPN, SRv6 locators, prefix-lists, community-lists, route-maps.
  • Cisco IOS XR: Hierarchical interface blocks, OSPF areas/interfaces, IS-IS, BGP EVPN, SRv6 locators and uSID, prefix-sets, RPL route-policies.
  • FRRouting / SONiC: Interfaces, OSPFv2/OSPF6, IS-IS, BGP, EVPN, SRv6, prefix-lists, community-lists, route-maps.
  • Nokia SR Linux: YANG JSON (interface/subinterface IPv4/IPv6 addresses, system hostname, default network-instance OSPFv2/OSPFv3 areas, BGP groups/neighbors, static routes via next-hop-groups). Non-default network-instances (VRFs) and other sections are reported as unsupported. Verified against real published configurations (an SR Linux v25.10.1 device-saved startup config, containerlab's clos02 example, and Nokia's documented static-route model — static routes sit directly under network-instance with a flat route list); see crates/parse-srlinux/tests/fixtures/README.md.
  • Nokia SR OS (classic CLI + MD-CLI): Classic indented configure hierarchy and flattened one-line statements: system name, router interfaces (IPv4/IPv6 incl. the ipv6 sub-block, description, shutdown, and the port binding, recorded verbatim in the IR — plain 1/1/1, VLAN-tagged 1/1/1:12, or lag-1), OSPF/OSPFv3 areas/interfaces (passive, metric; router-id may be on the ospf line), static-route-entry and legacy one-line static-route, BGP groups/neighbors. Unrecognized blocks in a real admin display-config dump are reported once and skipped as a unit. Verified against real published display-config output (TiMOS-B-13.0.R1 / 14.0.R4). MD-CLI configurations are also supported and auto-detected, in both renderings: brace style (configure { ... }, the info / admin show configuration output) and flat style (one /configure ... statement per line, as written by admin save). Both map the same subset to the same IR: system name; router interfaces (ipv4 primary address + prefix-length, ipv6 address entries, description, admin-state as the shutdown equivalent, the port binding); router-id / autonomous-system; ospf / ospf3 instance lists with areas and area interfaces (passive, metric); bgp groups and neighbors (neighbors sit directly under bgp and reference their group with a group leaf); static-routes with next-hop (black-hole and indirect routes are reported, as in classic mode). MD shapes were verified against Nokia's published SR OS 26.x YANG models (github.com/nokia/7x50_YangModels, sros_26.10) and real published MD-CLI samples (Nokia MD-CLI guide excerpts; device-saved files from srl-labs/sros-anysec-macsec-lab, TiMOS-C-23.10.R1); see crates/parse-sros/tests/fixtures/README.md. A golden test asserts that the same network written in classic CLI, MD brace style and MD flat style produces identical IR.

Emitters: zebra (zebra-rs YAML), frr (FRRouting), and holo (Holo daemon RFC 7951 JSON: system hostname, interfaces, OSPFv2/OSPFv3, static routes; BGP/IS-IS/SR/policy features are reported as warnings rather than emitted with unverified keys). Holo output can be validated against the YANG schemas it is generated for — see --validate-yang above and the validate-holo subcommand.


CI & Quality Checks

Run the automated test suite locally:

cargo fmt --all -- --check
cargo test --workspace
cargo clippy --workspace --all-targets -- -D warnings

About

Network Simulator

Resources

Readme
Apache-2.0 license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.