Skip to content

MRT Format

Thomas Mangin edited this page Nov 13, 2025 · 2 revisions

MRT Format Integration

Working with MRT (Multi-Threaded Routing Toolkit) BGP dumps

MRT is a standardized binary format for storing BGP routing information, commonly used for BGP table dumps, UPDATE message captures, and routing analysis. This page explains how to work with MRT files in the context of ExaBGP.


Table of Contents


What is MRT?

MRT (Multi-Threaded Routing Toolkit) is a binary format for recording BGP routing information, defined by RFC 6396.

Common MRT Applications

BGP Table Dumps:

  • RIB (Routing Information Base) snapshots
  • Full BGP tables from route collectors
  • Historical routing data

BGP UPDATE Messages:

  • Real-time BGP update captures
  • BGP event recording
  • Protocol analysis

Route Collectors:

  • RIPE RIS (Routing Information Service)
  • RouteViews
  • PCH (Packet Clearing House)

MRT File Types

Type Description Use Case
TABLE_DUMP Full RIB snapshot (deprecated) Legacy table dumps
TABLE_DUMP_V2 Full RIB snapshot (current) Modern table dumps
BGP4MP BGP UPDATE/KEEPALIVE/NOTIFICATION Live capture
BGP4MP_STATE_CHANGE BGP state transitions FSM monitoring

ExaBGP and MRT

ExaBGP Does NOT Support MRT Natively

⚠️ Important: ExaBGP does NOT have native MRT support. ExaBGP uses its own configuration format and text/JSON API.

Why?

  • ExaBGP focuses on route injection and control, not passive monitoring
  • MRT is primarily for recording and analysis
  • Different use cases require different formats

Workflow: MRT β†’ ExaBGP

If you need to inject routes from an MRT dump into ExaBGP:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  MRT Dump    β”‚
β”‚  (binary)    β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ Convert
       v
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MRTparse or  β”‚
β”‚ IOS2ExaBGP   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ Generate
       v
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ExaBGP       β”‚
β”‚ Config       β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ Load
       v
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  ExaBGP      β”‚
β”‚  Announces   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Converting MRT to ExaBGP

MRTparse

URL: https://github.com/YoshiyukiYamauchi/mrtparse

Description: Python library and tool that converts MRT format dumps into ExaBGP configuration format.

Installation

pip install mrtparse

Basic Usage

Convert MRT dump to ExaBGP config:

# Parse MRT file and output ExaBGP format
mrtparse -f exabgp latest-bview.gz > exabgp-routes.conf

Example Output (ExaBGP format):

neighbor 192.0.2.1 {
    router-id 192.0.2.2;
    local-address 192.0.2.2;
    local-as 65001;
    peer-as 65000;

    static {
        route 203.0.113.0/24 next-hop 192.0.2.1 as-path [ 65000 64512 ];
        route 198.51.100.0/24 next-hop 192.0.2.1 as-path [ 65000 64513 ];
        # ... thousands of routes
    }
}

Advanced Usage

Filter specific prefixes:

#!/usr/bin/env python3
import mrtparse

# Parse MRT and filter
for entry in mrtparse.Reader('latest-bview.gz'):
    if entry.data['type'][0] == mrtparse.MRT_T['TABLE_DUMP_V2']:
        prefix = entry.data['prefix']

        # Filter: only /24 prefixes
        if prefix.endswith('/24'):
            # Output ExaBGP format
            print(f"route {prefix} next-hop {entry.data['next_hop']};")

Parse UPDATE messages:

for entry in mrtparse.Reader('updates.20250101.0000.bz2'):
    if entry.data['type'][0] == mrtparse.MRT_T['BGP4MP']:
        if entry.data['subtype'][0] == mrtparse.BGP4MP_ST['BGP4MP_MESSAGE']:
            # Process BGP UPDATE
            bgp_message = entry.data['bgp_message']
            # Convert to ExaBGP format

Converting Cisco IOS Dumps

IOS2ExaBGP

URL: https://github.com/lochiiconnectivity/ios2exa

Description: Converts Cisco IOS IPv4 BGP LOC-RIB dumps to ExaBGP configuration format.

Usage

Cisco IOS: Capture BGP table

router# show ip bgp | redirect flash:bgp-table.txt

Convert to ExaBGP format:

./ios2exa bgp-table.txt > exabgp-routes.conf

Example Input (Cisco IOS format):

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.0.0.0/8       192.168.1.1              0             0 65000 i
*> 172.16.0.0/12    192.168.1.1              0             0 65000 65001 i

Example Output (ExaBGP format):

static {
    route 10.0.0.0/8 next-hop 192.168.1.1 as-path [ 65000 ] origin IGP;
    route 172.16.0.0/12 next-hop 192.168.1.1 as-path [ 65000 65001 ] origin IGP;
}

Use Cases

Use Case 1: Replaying BGP Tables

Scenario: Test router behavior with real BGP tables

Workflow:

  1. Download RIB dump from RouteViews or RIPE RIS
  2. Convert MRT to ExaBGP config with MRTparse
  3. Load into ExaBGP
  4. Peer with test router
  5. Observe router behavior with full internet table

Example:

# Download RIPE RIS dump
wget https://data.ris.ripe.net/rrc00/latest-bview.gz

# Convert to ExaBGP
mrtparse -f exabgp latest-bview.gz > internet-table.conf

# Load into ExaBGP
exabgp internet-table.conf

Use Case 2: Historical Route Analysis

Scenario: Replay historical BGP events

Workflow:

  1. Obtain historical MRT dumps (BGP4MP UPDATE messages)
  2. Convert to ExaBGP format
  3. Replay updates to simulate past events
  4. Analyze behavior during historical incidents

Application: BGP hijack analysis, outage investigation

Use Case 3: Migration from Cisco to ExaBGP

Scenario: Migrate static route announcements from Cisco to ExaBGP

Workflow:

  1. Export Cisco BGP table (show ip bgp)
  2. Convert with IOS2ExaBGP
  3. Review and clean up ExaBGP config
  4. Deploy ExaBGP with converted routes

Use Case 4: Testing with Production-Like Data

Scenario: Test software with real-world BGP data

Workflow:

  1. Download representative BGP table (MRT)
  2. Convert to ExaBGP format
  3. Use as test data for development
  4. Validate against production-scale routing tables

Tools

MRT Processing Tools

Tool Language Purpose URL
mrtparse Python MRT parsing and conversion to ExaBGP https://github.com/YoshiyukiYamauchi/mrtparse
IOS2ExaBGP Python Cisco IOS dump conversion https://github.com/lochiiconnectivity/ios2exa
bgpdump C MRT dump analysis (not ExaBGP specific) https://github.com/RIPE-NCC/bgpdump
bgpscanner C High-performance MRT processing https://gitlab.com/Isolario/bgpscanner

MRT Data Sources

Source Description URL
RIPE RIS Route collectors worldwide https://www.ripe.net/analyse/internet-measurements/routing-information-service-ris
RouteViews University of Oregon route views http://www.routeviews.org/
PCH Packet Clearing House https://www.pch.net/resources/Routing_Data/

See Also


References


πŸ‘» Ghost written by Claude (Anthropic AI)

Clone this wiki locally