Skip to content

Fast offline lookup of IP addresses to IXP and AS numbers from RIB archives.

License

Notifications You must be signed in to change notification settings

maxmouchet/goasn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goasn

Build Status Go Report Card GoDoc

goasn provides fast lookup of IP addresses to IXP and AS numbers from RIB archives.
It supports the following sources:

It reads and store IP addresses in a radix tree (kentik/patricia) for fast lookups.

It supports multiple origin ASes in opposition to pyasn (pyasn#46).

WIP. The API is not stable

Quick Start

CLI

You can download the latest binary or build goasn by yourself.
Building meshmon requires Go 1.12+.

git clone https://github.com/maxmouchet/goasn.git
cd goasn; make
goasn download --collector route-views.amsix.routeviews.org --date 2019-08-01T08:00
goasn convert rib.20190801.0800.bz2
goasn lookup --db rib.20180801.0800.txt 8.8.8.8

Library

go get github.com/maxmouchet/goasn
asndb, _ := goasn.NewDB("rib.20180801.0800.txt")

asn, _ := asndb.LookupStr("8.8.8.8")
// => 15169

ip := net.ParseIP("1.1.1.1")
asn, _ := asndb.LookupIP(ip)
// => 13335

Performance

Constructing the radix tree is slower than pyasn, but lookups are faster.

# benchmark.go
Loading database from ipasn_20190822.dat...
Took 1.719656297s

Looking up 10000 addresses (string)
Took 3.367572ms

Looking up 10000 addresses (net.IP)
Took 1.631176ms
# benchmark.py
Loading database from ipasn_20190822.dat
Took 197.402488ms

Looking up 10000 addresses (string)
Took 9.340981ms

About

Fast offline lookup of IP addresses to IXP and AS numbers from RIB archives.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published