BGP
Query RouteViews and RIPE RIS MRT archives (RIB snapshots and BGP updates) as SQL rows, with AS-path and community helpers
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/bgp/index.md to help me query BGP with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Decode the built-in inline TABLE_DUMP_V2 RIB fixture and count routes per origin AS.
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT origin_asn, count(*) AS routes
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'))
GROUP BY origin_asn
ORDER BY routes DESC, origin_asn;
| origin_asn | routes |
|---|---|
| 64,512 | 2 |
| 64,600 | 1 |
Quick start
Choose where to run BGP, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach the release directly
Downloads the latest release for your platform and caches it locally.
ATTACH 'bgp' AS bgp (
TYPE vgi,
LOCATION 'github-auto://Query-farm/vgi-bgp'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'bgp' AS bgp (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-bgp:0.5.0'
);
3. Run a query
SELECT origin_asn, count(*) AS routes
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'))
GROUP BY origin_asn
ORDER BY routes DESC, origin_asn;
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'bgp' AS bgp
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT origin_asn, count(*) AS routes
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'))
GROUP BY origin_asn
ORDER BY routes DESC, origin_asn;
Query Farm operates BGP for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use bgp as the catalog alias for the query below.
4. Run a query
SELECT origin_asn, count(*) AS routes
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'))
GROUP BY origin_asn
ORDER BY routes DESC, origin_asn;
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach the release directly
Uses the verified release each time you attach the connector.
ATTACH 'bgp' AS bgp (
TYPE vgi,
LOCATION 'github-auto://Query-farm/[email protected]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'bgp' AS bgp (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-bgp:0.5.0'
);
Overview
Decode MRT routing dumps (BGP4MP updates + TABLE_DUMP_V2 RIB snapshots) into SQL rows, reusing the core INET type for prefixes and peer IPs.
Decode MRT routing dumps — the archive format RouteViews and RIPE RIS publish — directly in SQL. MRT comes in two flavors this worker reads: BGP4MP update streams (announcements, withdrawals, and session state changes) and TABLE_DUMP_V2 RIB snapshots (a full routing table at one instant). Streaming them into rows turns route-leak / hijack / RIB-diff analysis into a JOIN in the engine instead of an ETL-to-Parquet step.
A source argument is a path (local / glob / s3:// / http(s)://) or an inline BLOB; .gz / .bz2 inputs auto-decompress. Prefixes, peer IPs, and next hops are DuckDB INET values (cast with ::INET), so containment such as prefix::INET <<= '203.0.113.0/24' and prefix joins work directly. AS paths are LIST(UINTEGER) and BGP communities are LIST(VARCHAR); scalar helpers operate on those columns. RPKI / route-origin validation is out of scope — JOIN the origin AS against your VRP table (ROV lives in vgi-netflow).
Sources and references
- RFC 6396 — the MRT routing information export format (BGP4MP and TABLE_DUMP_V2)
- RFC 4271 — BGP-4, the protocol whose UPDATE messages and path attributes the rows carry
- RFC 8092 — BGP large communities (
a:b:c) - RouteViews archive and RIPE RIS raw data — public MRT dumps to query
- bgpkit-parser — the MRT decoding library this worker uses
Catalog
Everything bgp exposes once attached — read straight from the worker's
released build.
main 1 view · 9 functions
MRT decode (read_rib / read_updates / peers) plus AS-path and community helper functions.
Schema examples (12)
Count the AS hops in an inline AS-path literal.
SELECT bgp.main.path_length([7018, 174, 13335]) AS hops;
Get the origin AS (last ASN) of an inline AS-path literal.
SELECT bgp.main.origin_asn([7018, 174, 13335]) AS origin;
Count the prepended (padded) ASNs in an inline AS-path literal.
SELECT bgp.main.as_path_prepends([7018, 174, 174, 13335]) AS prepends;
Test whether an inline AS path traverses a given ASN.
SELECT bgp.main.path_contains([7018, 174, 13335], 174) AS via_174;
8 more examples
Split a standard community string into its ASN and value parts.
SELECT bgp.main.community_parse('65001:100') AS parts;
Classify whether a community string is an RFC 8092 large community.
SELECT bgp.main.is_large_community('65001:1:2') AS is_large;
Count the RIB entries decoded from the built-in inline TABLE_DUMP_V2 fixture.
SELECT count(*) AS entries
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'));
Rank the inline RIB routes by AS-path length using the path_length helper on the emitted as_path column.
SELECT origin_asn, as_path, bgp.main.path_length(as_path) AS hops
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'))
ORDER BY hops;
Count each message type in the built-in inline BGP4MP update stream.
SELECT message_type, count(*) AS messages
FROM bgp.main.read_updates(from_hex('68608200001100040000007f000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff00670200000050800e0d00010104c00002010018cb0071400304c0000201c0110e02030000fde90000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002686082010011000400000098000000000000fde9000000000000000220010db800000000000000000000000100000000000000000000000000000000ffffffffffffffffffffffffffffffff00680200000051800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110a02020000fde90000fc58400101004005040000006480040400000000686082020011000400000039000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff0021020000000a800f0700010118cb0071'))
GROUP BY 1;
Diff the built-in sample RIB routes (example_rib) against announcements in the inline update stream: for each peer + prefix announced with a different AS path than the RIB held, compare hop count (path_length) and prepends (as_path_prepends) before and after (both paths got one hop shorter; one lost its prepend).
SELECT r.peer_asn, r.origin_asn, r.as_path AS rib_path,
u.as_path AS update_path, bgp.main.path_length(r.as_path) AS rib_hops,
bgp.main.path_length(u.as_path) AS update_hops,
bgp.main.as_path_prepends(r.as_path) AS rib_prepends,
bgp.main.as_path_prepends(u.as_path) AS update_prepends
FROM bgp.main.example_rib AS r
JOIN bgp.main.read_updates(from_hex('68608200001100040000007f000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff00670200000050800e0d00010104c00002010018cb0071400304c0000201c0110e02030000fde90000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002686082010011000400000098000000000000fde9000000000000000220010db800000000000000000000000100000000000000000000000000000000ffffffffffffffffffffffffffffffff00680200000051800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110a02020000fde90000fc58400101004005040000006480040400000000686082020011000400000039000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff0021020000000a800f0700010118cb0071')) AS u ON u.peer_ip = r.peer_ip AND u.prefix = r.prefix
WHERE u.message_type = 'announce' AND u.as_path <> r.as_path
ORDER BY r.origin_asn, r.peer_asn;
Join the built-in sample RIB routes (example_rib) to the inline update stream on peer and prefix to find which RIB routes are later withdrawn, and when (one route: peer AS 65001, origin AS 64512, withdrawn at 00:00:02).
SELECT r.peer_asn, r.origin_asn, r.as_path, u.timestamp AS withdrawn_at
FROM bgp.main.example_rib AS r
JOIN bgp.main.read_updates(from_hex('68608200001100040000007f000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff00670200000050800e0d00010104c00002010018cb0071400304c0000201c0110e02030000fde90000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002686082010011000400000098000000000000fde9000000000000000220010db800000000000000000000000100000000000000000000000000000000ffffffffffffffffffffffffffffffff00680200000051800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110a02020000fde90000fc58400101004005040000006480040400000000686082020011000400000039000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff0021020000000a800f0700010118cb0071')) AS u ON u.peer_ip = r.peer_ip AND u.prefix = r.prefix
WHERE u.message_type = 'withdraw'
ORDER BY withdrawn_at, r.peer_asn;
Unnest the communities on every built-in sample RIB route (example_rib), skip RFC 8092 large communities with is_large_community, and split each standard one into its tagging ASN and value with community_parse.
SELECT r.peer_asn, r.origin_asn, c.community,
bgp.main.community_parse(c.community).asn AS tagger_asn,
bgp.main.community_parse(c.community).value AS tag_value
FROM bgp.main.example_rib AS r
CROSS JOIN unnest(r.communities) AS c(community)
WHERE NOT bgp.main.is_large_community(c.community)
ORDER BY r.peer_asn, c.community;
example_rib
A built-in sample of three decoded TABLE_DUMP_V2 RIB routes — browse it to learn the reader's output columns without supplying an MRT file.
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
Group the built-in sample routes by origin AS to see how many prefixes each announced.
SELECT origin_asn, count(*) AS routes
FROM bgp.main.example_rib
GROUP BY origin_asn
ORDER BY routes DESC, origin_asn;
as_path_prepends (as_path BIGINT[])
Number of AS-path prepends (padded repeated ASNs)
Count the prepended (padded) ASNs in a path (here 1).
SELECT bgp.main.as_path_prepends([7018, 174, 174, 13335]);
community_parse (raw VARCHAR)
Parse a standard community 'asn:value' into a STRUCT(asn, value)
Split a standard community into {asn: 65001, value: 100}.
SELECT bgp.main.community_parse('65001:100');
Unnest the communities on every built-in sample RIB route (example_rib), skip RFC 8092 large communities with is_large_community, and split each standard one into its tagging ASN and value with community_parse.
SELECT r.peer_asn, r.origin_asn, c.community,
bgp.main.community_parse(c.community).asn AS tagger_asn,
bgp.main.community_parse(c.community).value AS tag_value
FROM bgp.main.example_rib AS r
CROSS JOIN unnest(r.communities) AS c(community)
WHERE NOT bgp.main.is_large_community(c.community)
ORDER BY r.peer_asn, c.community;
is_large_community (raw VARCHAR)
Whether a community string is an RFC 8092 large community
Detect a large community (three numeric parts, so true).
SELECT bgp.main.is_large_community('65001:1:2');
origin_asn (as_path BIGINT[])
The origin AS (last AS) of an AS path
Get the origin AS that announced the prefix (here 13335).
SELECT bgp.main.origin_asn([7018, 174, 13335]);
path_contains (as_path BIGINT[], asn BIGINT)
Whether an AS path traverses a given ASN
Test whether a path traverses AS 174 (here true).
SELECT bgp.main.path_contains([7018, 174, 13335], 174);
path_length (as_path BIGINT[])
Number of AS hops in an AS path
Count the AS hops in a path (here 3).
SELECT bgp.main.path_length([7018, 174, 13335]);
Diff the built-in sample RIB routes (example_rib) against announcements in the inline update stream: for each peer + prefix announced with a different AS path than the RIB held, compare hop count (path_length) and prepends (as_path_prepends) before and after (both paths got one hop shorter; one lost its prepend).
SELECT r.peer_asn, r.origin_asn, r.as_path AS rib_path,
u.as_path AS update_path, bgp.main.path_length(r.as_path) AS rib_hops,
bgp.main.path_length(u.as_path) AS update_hops,
bgp.main.as_path_prepends(r.as_path) AS rib_prepends,
bgp.main.as_path_prepends(u.as_path) AS update_prepends
FROM bgp.main.example_rib AS r
JOIN bgp.main.read_updates(from_hex('68608200001100040000007f000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff00670200000050800e0d00010104c00002010018cb0071400304c0000201c0110e02030000fde90000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002686082010011000400000098000000000000fde9000000000000000220010db800000000000000000000000100000000000000000000000000000000ffffffffffffffffffffffffffffffff00680200000051800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110a02020000fde90000fc58400101004005040000006480040400000000686082020011000400000039000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff0021020000000a800f0700010118cb0071')) AS u ON u.peer_ip = r.peer_ip AND u.prefix = r.prefix
WHERE u.message_type = 'announce' AND u.as_path <> r.as_path
ORDER BY r.origin_asn, r.peer_asn;
peers (src ANY, endpoint := VARCHAR, region := VARCHAR, url_style := VARCHAR, use_ssl := BOOLEAN)
List the distinct peers / collectors in an MRT file
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
List the peers in an inline TABLE_DUMP_V2 PEER_INDEX_TABLE.
SELECT peer_asn, collector
FROM bgp.main.peers(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'));
read_rib (src ANY, strict := BOOLEAN, endpoint := VARCHAR, region := VARCHAR, url_style := VARCHAR, use_ssl := BOOLEAN)
Read an MRT TABLE_DUMP_V2 RIB snapshot into rows
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
Scan an inline TABLE_DUMP_V2 RIB snapshot (3 entries) into rows.
SELECT prefix, origin_asn, as_path
FROM bgp.main.read_rib(from_hex('68608200000d00010000003b000000000000000302c0000201c00002010000fde902c6336407c63364070000fdea030000000020010db80000000000000000000000010000fde968608200000d000400000079000000003020010db8abcd00010002686082000064800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110e02030000fde90000fbf40000fc58400101004005040000006480040400000000c0200c0000fde9000000070000000968608200000d0002000000af0000000118cb007100020001686082000041800e0d00010104c63364070018cb0071400304c6336407c0110e02030000fdea0000fc010000fc00400101004005040000006480040400000000c00804fdea00c80000686082000054800e0d00010104c00002010018cb0071400304c0000201c0111202040000fde90000fbf40000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002'));
read_updates (src ANY, strict := BOOLEAN, endpoint := VARCHAR, region := VARCHAR, url_style := VARCHAR, use_ssl := BOOLEAN)
Read an MRT BGP4MP update stream into rows
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
-
ip_typeUTINYINT
-
addressHUGEINT
-
maskUSMALLINT
Count announce / withdraw / state-change messages in an inline BGP4MP update stream.
SELECT message_type, count(*)
FROM bgp.main.read_updates(from_hex('68608200001100040000007f000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff00670200000050800e0d00010104c00002010018cb0071400304c0000201c0110e02030000fde90000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002686082010011000400000098000000000000fde9000000000000000220010db800000000000000000000000100000000000000000000000000000000ffffffffffffffffffffffffffffffff00680200000051800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110a02020000fde90000fc58400101004005040000006480040400000000686082020011000400000039000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff0021020000000a800f0700010118cb0071'))
GROUP BY 1;
Join the built-in sample RIB routes (example_rib) to the inline update stream on peer and prefix to find which RIB routes are later withdrawn, and when (one route: peer AS 65001, origin AS 64512, withdrawn at 00:00:02).
SELECT r.peer_asn, r.origin_asn, r.as_path, u.timestamp AS withdrawn_at
FROM bgp.main.example_rib AS r
JOIN bgp.main.read_updates(from_hex('68608200001100040000007f000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff00670200000050800e0d00010104c00002010018cb0071400304c0000201c0110e02030000fde90000fbf40000fc00400101004005040000006480040400000000c00804fde90064c0200c0000fde90000000100000002686082010011000400000098000000000000fde9000000000000000220010db800000000000000000000000100000000000000000000000000000000ffffffffffffffffffffffffffffffff00680200000051800e1c0002011020010db8000000000000000000000001003020010db8abcd40031020010db8000000000000000000000001c0110a02020000fde90000fc58400101004005040000006480040400000000686082020011000400000039000000000000fde90000000000000001c000020100000000ffffffffffffffffffffffffffffffff0021020000000a800f0700010118cb0071')) AS u ON u.peer_ip = r.peer_ip AND u.prefix = r.prefix
WHERE u.message_type = 'withdraw'
ORDER BY withdrawn_at, r.peer_asn;
Try these queries
AS-path and community helpers over inline literals: hop count, origin AS, prepend count, path membership, large-community classification, and standard-community parse.
SELECT bgp.main.path_length([7018, 174, 174, 13335]) AS hops;
SELECT bgp.main.origin_asn([7018, 174, 13335]) AS origin;
SELECT bgp.main.as_path_prepends([7018, 174, 174, 13335]) AS prepends;
SELECT bgp.main.path_contains([7018, 174, 13335], 174) AS via_174;
SELECT bgp.main.is_large_community('65001:1:2') AS is_large;
SELECT bgp.main.community_parse('65001:100').asn AS asn;
Uses path_lengthorigin_asnas_path_prependspath_containsis_large_community
Get the origin AS (last ASN) of an inline AS-path literal.
SELECT bgp.main.origin_asn([7018, 174, 13335]) AS origin;
Uses origin_asn
Count the prepended (padded) ASNs in an inline AS-path literal.
SELECT bgp.main.as_path_prepends([7018, 174, 174, 13335]) AS prepends;
Uses as_path_prepends
Test whether an inline AS path traverses a given ASN.
SELECT bgp.main.path_contains([7018, 174, 13335], 174) AS via_174;
Uses path_contains
Split a standard community string into its ASN and value parts.
SELECT bgp.main.community_parse('65001:100') AS parts;
Uses community_parse
Classify whether a community string is an RFC 8092 large community.
SELECT bgp.main.is_large_community('65001:1:2') AS is_large;
Uses is_large_community
17 more examples in the Catalog, each listed under the table or function it uses.
BGP is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Code
Developer & networking
Detect languages, count lines and functions, and extract symbols, imports and comments from source code
NetFlow
Developer & networking
Turn captured NetFlow v5/v9, IPFIX, and sFlow v5 datagrams into normalized, queryable flow rows
Perf
Developer & networking
Decode Linux perf.data captures into SQL tables of samples, memory mappings, and event metadata for bulk profile analysis