tekkie has asked for the wisdom of the Perl Monks concerning the following question:

I need a simple Perlish solution to obtain the AS number for a specific hop in a route (read: I have an IP, I need its ASN, and I can use anything available in Perl to do it)

The problem arises from the fact that the code will be based on a Win32 platform running ActivePerl v5.8.0 built for MSWin32-x86-multi-thread so the usual 'use a tcp traceroute' isn't going to work right off.

My questions are:

1. Has anyone encountered this problem before? If so, what was your solution?

2. Is there a Win32 CLI version of the tcp traceroute available?

3. Is there a web-based look-up somewhere that I could possibly just write an LWP wrapper around?

I've searched Perlmonks and numerous other sites looking for a solution, but I have yet to come across one, so now I appeal to the monks and all their wisdom

Thanks in advance.
-Tekkie

Replies are listed 'Best First'.
Re: AS Number lookup in Win32
by hardburn (Abbot) on Mar 07, 2003 at 15:12 UTC

    Making your own TCP traceroute shouldn't be too difficult, but I think you'll need to muck with Raw IP to be able to set the TTL. The code for this looks kinda like this:

    my $maxTTL = 25; # Don't go more than 25 hops for my $ttl ( 1 .. $maxTTL) { # send_packet() returns (1, "Success") if the # target host was reached or (0, [name of host]) if # the host was not reached, where [name of host] is the # name of the last host in the chain. # my ($result, $host) = send_packet( ttl => $ttl ); last if $result; print "$ttl \t $host \n"; }

    ----
    Reinvent a rounder wheel.

    Note: All code is untested, unless otherwise stated

Re: AS Number lookup in Win32
by 2mths (Beadle) on Mar 07, 2003 at 15:39 UTC
    I think I am probably missing the point but in response to...

    2. Is there a Win32 CLI version of the tcp traceroute available?

    I'd have thought the answer was tracert?

    C:\WINNT>tracert appgbmk001

    Tracing route to appgbmk001.europe.unity 158.67.87.22 over a maximum of 30 hops:

    1 10 ms <10 ms <10 ms appgbmk001.eu.wang.com 158.67.87.22

    Trace complete.


    I am a scripter, I know I am only a scripter, but I like scripting and I can't program
    If this is wrong please tell me. I'm learning
      The Win32 version of tracert is UDP and does not return the AS numbers

      I wish it were that simple :)
        I see. I did think I was missing the point but incase it was a *nix person asking I thought I'd venture something.

        Can I ask what an AS number is? I'm intrigued and wouldn't mind doing some searching.
        The only traceroute program I am aware of that returns ASN's is the Nanog Traceroute
        which is not avialable as a Windows product
        I did some searching and I was unable to find a comparable CPAN module to do the similar function but you might try looking at the source to see if there is anything of use.