Skip to main content

Module text_dump

Module text_dump 

Source
Expand description

Cisco sh ip bgp text dump parser.

Parses the fixed-width column format produced by Cisco IOS routers, as published by PCH (daily routing table snapshots) and route-views (oix-full-snapshot-*.bz2). Field boundaries are extracted from the table header so that numeric attributes do not become indistinguishable from numeric AS-path segments.

§Format

BGP table version is N, local router ID is X.X.X.X, vrf id 0
Default local pref 100, local AS NNNN
...
    Network          Next Hop            Metric LocPrf Weight Path
 *> 1.0.0.0/24       103.77.108.118           0             0 13335 i
 *=                  103.77.108.11            0             0 13335 i

Route-views sh ip bgp snapshots (e.g. oix-full-snapshot-*.bz2) use the same fixed-width layout but omit the BGP table version / local AS preamble. When the preamble is absent, peer_ip and peer_asn default to the unspecified sentinel values 0.0.0.0 and AS0.

§Example

use bgpkit_parser::parser::text_dump::{infer_timestamp_from_path, parse_text_dump_with_timestamp};

let url = "https://downloads.pch.net/files/Routing_Data/IPv4_daily_snapshots/2026/07/route-collector.bom2.pch.net/route-collector.bom2.pch.net-ipv4_bgp_routes.2026.07.01.gz";
let reader = oneio::get_reader(url).unwrap();
let mut reader = std::io::BufReader::new(reader);
let timestamp = infer_timestamp_from_path(url).unwrap_or(0.0);
let elems = parse_text_dump_with_timestamp(&mut reader, timestamp).unwrap();
println!("parsed {} elements", elems.len());

Structs§

TextDumpElemIterator
A streaming iterator that yields BgpElems from a Cisco sh ip bgp text dump, one route line at a time.
TextDumpHeader
Header metadata extracted from the preamble of a Cisco sh ip bgp dump.

Functions§

detect_text_dump
Detect whether a reader contains a Cisco sh ip bgp text dump.
infer_timestamp_from_path
Try to extract a Unix timestamp from a file path or URL.
parse_header
Parse the preamble to extract router metadata and fixed-width column offsets.
parse_text_dump
Parse a complete Cisco sh ip bgp text dump into BgpElems with timestamp 0.0.
parse_text_dump_with_timestamp
Parse a complete Cisco sh ip bgp text dump into BgpElems.