Documentation for the CAIDA::ASFinder module
Overview
CAIDA::ASFinder is used to map an IP address to an AS number, with the
assistance of a BGP routing table. It has two different backends,
one in Perl and one in C++. The C++ version is much faster than the
Perl version, but it requires a modern C++ compiler. (eg. gcc > 2.8)
The Perl version is not recommended for several reasons, the main reason
being speed. In addition, it caches the routing information on disk
(in a directory called tmpdir) in order to not be unworkably slow;
unfortunately this means that running it with a different routing
table that the first one will result in incorrect results. In order
to use different routing information, the user must first delete tmpdir.
Similarly, two Perl-based ASFinders cannot use different routing tables
in the same program.
By default, ASFinder will attempt to use the C++ version; if that fails,
it reverts to the Perl version.
$CAIDA::ASFinder::FORCE_PERL
- Variable used to force use of the Perl backend. If that fails
somehow, ASFinder will croak.
$CAIDA::ASFinder::FORCE_C
- Variable used to force use of the C++ backend. If that fails
somehow, ASFinder will croak.
Note: If both FORCE_PERL and FORCE_C are true, then ASFinder will not
continue.
new CAIDA::ASFinder
- Constructor for creation of an ASFinder object.
- Sample call:
$as_finder = new CAIDA::ASFinder;
CAIDA::ASFinder::load_file_text(STR filename)
- This function loads in a parsed route table output by parse_bgp_dump
and stores the data internally. This function must be called before
using get_as().
- filename: The file to be loaded.
- Returns false if there was an error, true otherwise.
- Sample call:
$as_finder->load_file_text($filename)
or die("Error loading $filename!\n");
CAIDA::ASFinder::get_as(STR dotted_ip)
- This function searches for an AS and network that corresponds
to a specific IP address.
- dotted_ip: The dotted IP address to find an AS for.
- Returns a list of AS number, network, and netmask if successful,
or a list of false values if no AS/network could be found.
- Sample call:
($as, $net, $mask) =
$as_finder->get_as("192.172.226.30");
CAIDA::ASFinder::get_as_raw(SCALAR binary_ip)
- Like get_as, but uses the raw (non-string) IP address.
- binary_ip: The IP address to find an AS for.
- Returns a list of AS number, network, and netmask if successful,
or a list of false values if no AS/network could be found.
- (Contrived) sample call:
use Socket;
$ip = inet_aton("192.172.226.30");
($as, $net, $mask) = $as_finder->get_as($ip);
Problems? Write us:
coral-bugs@caida.org