Repository navigation
mrt analysis
Pre-Alpha. This page describes behavior that may change.
Ze provides both daemon-side MRT recording and a standalone analysis tool. The daemon records live BGP sessions to MRT files (RFC 6396). The analysis tool processes MRT dump files from any source, including public route collectors (RIPE RIS, RouteViews), local recordings, and HTTP URLs.
Ze produces MRT dumps from live BGP sessions via the mrt component. Configure under mrt {} in the YANG config. Three independent streams (following FRR's model):
- Updates -- BGP4MP records for UPDATE messages only
- All -- BGP4MP records for all BGP messages plus state changes
- Routes -- periodic TABLE_DUMP_V2 RIB snapshots
Features: per-peer filtering, direction filtering (received/sent), extended timestamps (BGP4MP_ET), add-path aware, on-demand CLI dump via request mrt dump-rib, strftime filename rotation, async non-blocking writes.
The chaos orchestrator, ./le chaos run, can also produce MRT files with the --mrt-file flag (strftime patterns supported; - writes to stdout with no rotation). It writes standard BGP4MP_MESSAGE_AS4 and BGP4MP_STATE_CHANGE_AS4 records from chaos peer events, readable by bgpdump, bgpkit-parser, and ./le mrt.
./le mrt is the MRT analysis tool, a development command of le, Ze's development launcher. It reads MRT dump files and extracts statistics that inform Ze's internal buffer sizing, caching strategies, and congestion handling. It is also a general-purpose MRT Swiss Army knife for filtering, replaying, and converting BGP data.
./le mrt <subcommand> [options] runs one subcommand. A bare ./le mrt lists every subcommand with its description, as data, so ./le mrt '|' json works. le builds itself, so no separate binary is needed. The standalone ze-analyze binary is gone.
./le mrt download grabs MRT files from two public BGP collectors. Files land in test/internet/ (gitignored).
./le mrt download # Today's data at 00:00 UTC
./le mrt download 20260324 # Specific date
./le mrt download 20260324 1200 # Specific date and time
./le mrt download -o /tmp/mrt # Custom output directory| Source | Type | Interval | Size |
|---|---|---|---|
| RIPE RIS rrc00 (Amsterdam) | BGP4MP updates | 5 min | ~5 MB per file |
| RIPE RIS rrc00 | TABLE_DUMP_V2 RIB | Latest | ~400 MB |
| RouteViews route-views2 | BGP4MP updates | 15 min | ~2 MB per file |
| RouteViews route-views2 | TABLE_DUMP_V2 RIB | 2-hour intervals | ~100 MB |
RouteViews bz2 files are converted to gzip on download for Go stdlib compatibility.
Measures how many NLRIs each UPDATE carries and how many UPDATEs arrive per second. Separates traffic into setup (table dumps, convergence) and maintenance (steady-state churn) using per-source-peer burst detection.
./le mrt density test/internet/ripe-updates.*.gzOutput sections: NLRIs per UPDATE distribution (announced, withdrawn, total); UPDATEs per active second distribution; setup vs maintenance classification per source peer; per-peer maintenance rate distribution; channel-sizing recommendation with empirical P50, P95, and P99.
Analyses attribute repetition across routes to guide caching decisions. Measures per-attribute cache hit rates, bundle deduplication effectiveness, and temporal locality (consecutive identical bundles).
./le mrt attributes test/internet/latest-bview.gz 2>/dev/null | jq .
./le mrt attributes test/internet/latest-bview.gz >/dev/null # summary onlyJSON on stdout, human summary on stderr.
Identifies per-ASN community defaults: communities that appear in nearly every route from a given ASN.
./le mrt communities test/internet/latest-bview.gz
./le mrt communities --threshold 0.90 --format json test/internet/latest-bview.gz
./le mrt communities --post-policy test/internet/latest-bview.gz| Flag | Default | Description |
|---|---|---|
--threshold |
0.95 |
Minimum frequency to be considered a default. |
--min-routes |
1000 |
Minimum routes from an ASN to generate defaults. |
--format |
yaml |
yaml or json. |
--post-policy |
off | Strip action communities to simulate a route server post-policy view. |
Builds a reversed trie over AS_PATHs from MRT dumps to measure suffix sharing. Reports compression ratio, path length distribution, trie depth stats, fanout, and top origin ASNs.
./le mrt aspath test/internet/latest-bview.gzCounts how many path attributes each route carries, and produces a distribution table showing the typical attribute-set size.
./le mrt count-attrs test/internet/latest-bview.gzHuman-readable MRT dump (like bgpdump). Displays record headers, peer info, and decoded BGP message contents including attributes, AS paths, and prefixes.
./le mrt show test/internet/ripe-updates.*.gz | head -50Extracts a prefix table from TABLE_DUMP_V2 files as JSON. Each entry includes prefix, next-hop, AS path, origin, local-pref, MED, and communities.
./le mrt routes test/internet/latest-bview.gz | jq '.[] | select(.prefix == "1.0.0.0/24")'Opens a BGP session to a remote peer and sends routes from an MRT file. Supports both TABLE_DUMP_V2 (RIB entries) and BGP4MP (UPDATE messages). The input file comes first and the peer ip:port second; --local-as (default 65000), --router-id (default 0.0.0.1) and --hold-time (default 90) are optional.
./le mrt inject --local-as 65000 test/internet/latest-bview.gz 10.0.0.1:179Replays BGP4MP messages over a BGP session preserving original inter-message timing. --speed is a multiplier (default 1.0; 0 means no delay). Arguments are the input file then the peer ip:port, as for inject.
./le mrt replay --local-as 65000 --speed 10 test/internet/ripe-updates.*.gz 10.0.0.1:179Converts MRT records to other formats.
./le mrt convert pcap test/internet/ripe-updates.*.gz output.pcap # BGP4MP to pcap (IPv4 only)
./le mrt convert json test/internet/ripe-updates.*.gz | jq . # record headers as JSONSend MRT data to network targets.
./le mrt export bmp --target 10.0.0.1:4321 test/internet/ripe-updates.*.gz
./le mrt export bmp --target collector:4321 --peer-ip 10.0.0.1 test/internet/ripe-updates.*.gzConnects to a BMP collector and sends each BGP4MP message as a BMP Route Monitoring message. Optional --peer-ip filters to a single peer.
Record incoming protocol streams to MRT files.
./le mrt record bmp --listen :4321 output.mrtListens for incoming BMP (RFC 7854) connections. Received Route Monitoring messages are written as BGP4MP_MESSAGE_AS4 MRT records. Peer Up/Down notifications are written as BGP4MP_STATE_CHANGE_AS4. Multiple concurrent BMP connections are supported (writes are serialized).
Passive BGP server that sends MRT file contents to any peer that connects. Useful for IXP traffic replay testing.
./le mrt serve --local-as 65000 --listen :1179 test/internet/latest-bview.gz
./le mrt serve --local-as 65000 --per-peer test/internet/ripe-updates.*.gzWith --per-peer, only records matching the connecting peer's ASN are sent. Multiple MRT files can be given; all are sent in order.
inject, replay and serve do not negotiate ADD-PATH. They refuse a Path-ID-bearing or ambiguous UPDATE, and a damaged one, before writing it to the peer; ordinary UPDATEs and standalone empty End-of-RIB messages are sent.
Per-type/subtype counts, AFI breakdown, peer summary, timestamp range, and BGP message type distribution.
./le mrt statistics test/internet/ripe-updates.*.gzSelect records by peer IP, peer ASN, prefix, AS-path regex, community regex, MRT type, or timestamp range. Writes matching records verbatim (no re-encoding) to a new MRT file. Multiple filters are AND-composed.
./le mrt filter --peer-asn 13335 test/internet/latest-bview.gz cloudflare.mrt
./le mrt filter --prefix 1.0.0.0/24 --after 1780272000 test/internet/latest-bview.gz filtered.mrt
./le mrt filter --as-path "174 .* 13335" test/internet/latest-bview.gz transit.mrt
./le mrt filter --community "13335:" test/internet/latest-bview.gz tagged.mrtThe input file comes first and the output file second. --after and --before take unix timestamps; --type takes bgp4mp, table-dump-v2 or table-dump; --prefix matches exactly, on RIB records only. AS-path regex matches against space-separated ASNs (e.g. "174 1916 52888"); AS_SET segments are rendered as {asn,asn}. Community regex matches per-community strings: standard high:low, large global:local1:local2, extended high:low.
Dumps MRT records as BGP UPDATE hex, one per line. Useful for piping into ze bgp decode.
./le mrt mrt-dump test/internet/ripe-updates.*.gz | head -5
./le mrt mrt-dump test/internet/latest-bview.gz | ze bgp decode -ze bgp decode names every community attribute a message carries: community (RFC 1997, code 8), extended-community (RFC 4360, code 16), ipv6-extended-community (RFC 5701, code 25), and large-community (RFC 8092, code 32). Each gets its own key, in the default text output and in --json. An extended-community entry shows the named form, for example target:65000:1 or traffic-action:sample-terminal, not raw hex.
HTTP and HTTPS URLs are accepted anywhere a file path is expected. Compression is auto-detected from the URL suffix.
./le mrt statistics https://data.ris.ripe.net/rrc00/2026.06/updates.20260607.0000.gzA dump from a public collector can carry a truncated or corrupt record. ./le mrt reports the damage rather than printing a short result as fact.
| What you get | Where |
|---|---|
warning: N malformed MRT record(s) skipped or partially decoded; results are incomplete |
stderr, from density, attributes, aspath, communities, count-attrs, mrt-dump, routes and show. A report that scrolls prints it before the numbers it qualifies. A clean file prints nothing. |
HH:MM:SS <peer> [unparseable: truncated] <error> |
show, for a record that decoded to nothing. The tag is truncated, unsupported-afi, or damaged. |
A=3+ or W=12+
|
show, for a partial count. The + says "at least this many"; a count with no + is exact. A damaged record prints the field even at zero, so a missing count and a zero count stay distinct. |
mrt: truncated record 41902 (type 13 subtype 2, timestamp 1780272000): unexpected EOF |
stderr, when the file itself stops early. The record ordinal is 1-based over the stream, so the failing record can be found in a multi-gigabyte dump. |
Damage never discards what already decoded. A record holding 500 good prefixes and one truncated prefix reports the 500 and counts one damaged record.
BGP message parsing requires exactly one complete frame. Trailing bytes beyond the declared BGP length, and truncated attribute headers, lengths or values, are errors even when the file holds both directional OPENs. The analysis commands report them, and BGP4MP inject, replay and serve refuse the damaged UPDATE before writing it to the peer.
Two properties of an MRT record decide how its BGP payload reads, and neither can be inferred from the payload bytes.
AS width comes from the record type (RFC 6396). TABLE_DUMP is 2-byte (section 4.2), TABLE_DUMP_V2 is 4-byte (section 4.3.4), BGP4MP_MESSAGE is 2-byte (section 4.4.2), and BGP4MP_MESSAGE_AS4 is 4-byte (section 4.4.3). A 2-byte and a 4-byte AS_PATH can occupy the same number of octets, so a wrong width yields fictitious ASNs instead of an error. Every subcommand derives the width from the record it is reading.
The MP_REACH_NLRI inside a RIB entry is abbreviated (RFC 6396 section 4.3.4): it keeps only the next-hop length and address, because the AFI, SAFI and prefix are already in the RIB record header. It has its own decoder, so IPv6 RIB next-hops are read correctly.
BGP4MP add-path modes come from both captured OPENs. ADD-PATH is negotiated per family and per direction, so the decoder reads the two OPENs in the capture. Ordinary subtypes and unambiguous single-family ADD-PATH messages also decode without the OPENs; a mixed-family ADD-PATH message does not. An empty MP field still counts as family evidence, because it can select the recorder's subtype. Missing context is an error, never guessed prefixes or Path Identifiers. An updates-only capture, or a rotated file opened without its OPEN exchange, cannot recover the negotiation from another file.
TABLE_DUMP_V2 add-path RIB subtypes (RFC 8050) carry their identifiers explicitly: subtypes 8 to 11 in each RIB entry, subtype 12 in its raw NLRI.
./le mrt handles two MRT record types from RFC 6396.
| Type | Content | Used by |
|---|---|---|
TABLE_DUMP_V2 |
RIB snapshots (one entry per route per peer). | attributes, aspath, communities, count-attrs, mrt-dump, show, routes, inject, filter, statistics. |
BGP4MP |
Live UPDATE messages with timestamps. | density, attributes, communities, mrt-dump, show, inject, replay, convert, filter, statistics. |
Both .gz and .bz2 compressed files are supported.
- In-tree MRT analysis for the full version.
- MRT Architecture for daemon component design.
- Update Density Analysis for the empirical findings that inform forward pool channel sizing.
Adapted from main/docs/guide/mrt-analysis.md.
Unreviewed draft. This wiki was authored in bulk and has not been reviewed. File corrections on the issue tracker.
- Install
- Docker
- netlab
- Appliance
- Quick Start
- Use Ze with an AI agent
- ExaBGP Migration
- CLI Tour
- Web UI Tour
- Overview
- YANG Model
- Editor Workflow
- Archive and Rollback
- Backup and Restore
- System
- Interfaces
- VRRP
- BFD
- FIB
- OSPF
- IS-IS
- MPLS / LDP / RSVP-TE
- RSVP-TE
- SRv6
- Static Routes
- Policy Routing
- Firewall
- Traffic Control
- Class of Service
- L2TP/PPP
- PPPoE
- VPP Data Plane
- RPKI
- IPsec VPN
- Path MTU
- TACACS+ AAA
- RADIUS AAA
- AS112 DNS
- DNS
- Authorization
- Fleet
- BGP
- Starting and Stopping
- Show Commands
- Monitoring
- Telemetry
- Flow Export
- DDoS Mitigation
- Anomaly Detection
- Health Checks
- Audit Trail
- Production Diagnostics
- Logging
- Operational Reports
- Healthcheck
- Self-Update
- Zero-Touch Provisioning
- MRT Analysis
- Upgrade and Restart
- Storage
- Policy
- Core
- Resilience
- Validation
- Link State
- Capabilities
- Address Families
- Protocol
- Subsystems
- Infrastructure
- Route Server at an IXP
- Transit Edge with RPKI
- Public Looking Glass
- ExaBGP Migration Walkthrough
- FlowSpec Injection
- Chaos-Tested Peering
- AS Path Topology