Skip to main content

A Python CFFI wrapper for analyzing MRTv1 and MRTv2 BGP table dump files

Project description

## bgpdumpy

### Overview

`bgpdumpy` is a [libbgpdump](https://bitbucket.org/ripencc/bgpdump) Python CFFI wrapper for analyzing MRT and MRTv2 BGP table dump files.

### Example

```python
import re
from bgpdumpy import BGPDump

with BGPDump( 'latest-bview.gz' ) as bgp:

for entry in bgp:

# entry.body can be either be TableDumpV1 or TableDumpV2

if not isinstance( entry.body, TableDumpV2 ):
continue # I expect an MRT v2 table dump file

# get a string representation of this prefix
prefix = '%s/%d' %( entry.body.prefix, entry.body.prefixLength )

# get a list of each unique originating ASN for this prefix
originatingASs = set( [
re.split( r'\s+', route.attr.asPath )[-1]
for route
in entry.body.routeEntries] )

# just print it for demonstration purposes
print( '%s -> %s' %( prefix, '/'.join( originatingASs ) ) )

# 1.0.0.0/24 -> 15169
# 1.0.4.0/24 -> 56203
# 1.0.5.0/24 -> 56203
# 1.0.6.0/24 -> 56203
# 1.0.7.0/24 -> 38803
# 1.0.38.0/24 -> 24155
# 1.0.64.0/18 -> 18144
# 1.0.128.0/17 -> 9737
# 1.0.128.0/18 -> 9737
# 1.0.128.0/19 -> 9737
# ...
# 2001::/32 -> 6939
# 2001:4:112::/48 -> 112
# 2001:200::/32 -> 2500
# 2001:200:900::/40 -> 7660
# 2001:200:c000::/35 -> 23634
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bgpdumpy-1.0.0.tar.gz (1.5 MB view details)

Uploaded Source

File details

Details for the file bgpdumpy-1.0.0.tar.gz.

File metadata

  • Download URL: bgpdumpy-1.0.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bgpdumpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2dbc104ec0a9d16cf2aef2286debf736944fc27052d94d8e5eec830bc067eee6
MD5 051b39d2ec0d3add8063d61cbbefbdb4
BLAKE2b-256 1e6ab0cdc29e7150ae7e907e1ede8875f9a9247de276a4c60d85ee387bc2fb38

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page