Git Product home page Git Product logo

traceroute's Introduction

traceroute

Traceroute is a Python script that allows you to get traceroute results with associated geolocation information for each hop for a specified host from geographically distant source(s). Demo: IP Address Lookup (under "Visual Traceroute" tab)

Using output from traceroute.py to plot hops on Google Map

Installation

Save traceroute.py into a directory with its path stored in your PYTHONPATH environment variable.

Usage

Try the following from your Python interpreter:

>>> from traceroute import Traceroute
>>> traceroute = Traceroute(ip_address='8.8.8.8')
>>> hops = traceroute.traceroute()
>>> hops
[{'hostname': 'gigagate1', 'longitude': -74.6597, 'rtt': '0.700 ms', 'hop_num': 1, 'latitude': 40.3756, 'ip_address': '128.112.128.114'}, {'hostname': 'vgate1', 'longitude': -74.6597, 'rtt': '0.375 ms', 'hop_num': 2, 'latitude': 40.3756, 'ip_address': '128.112.12.22'}, {'hostname': 'te-1-4-3998-pe01.philadelphia.pa.ibone.comcast.net', 'longitude': -75.3697, 'rtt': '18.296 ms', 'hop_num': 3, 'latitude': 40.3265, 'ip_address': '24.104.128.89'}, {'hostname': 'te-0-1-0-12-cr01.ashburn.va.ibone.comcast.net', 'longitude': -97.0, 'rtt': '28.446 ms', 'hop_num': 4, 'latitude': 38.0, 'ip_address': '68.86.84.177'}, {'hostname': 'pos-0-2-0-0-pe01.ashburn.va.ibone.comcast.net', 'longitude': -97.0, 'rtt': '21.968 ms', 'hop_num': 5, 'latitude': 38.0, 'ip_address': '68.86.86.70'}, {'hostname': '75.149.231.62', 'longitude': -97.0, 'rtt': '20.685 ms', 'hop_num': 6, 'latitude': 38.0, 'ip_address': '75.149.231.62'}, {'hostname': '209.85.252.80', 'longitude': -122.0574, 'rtt': '18.383 ms', 'hop_num': 7, 'latitude': 37.4192, 'ip_address': '209.85.252.80'}, {'hostname': '209.85.252.46', 'longitude': -122.0574, 'rtt': '18.541 ms', 'hop_num': 7, 'latitude': 37.4192, 'ip_address': '209.85.252.46'}, {'hostname': '209.85.252.80', 'longitude': -122.0574, 'rtt': '19.723 ms', 'hop_num': 7, 'latitude': 37.4192, 'ip_address': '209.85.252.80'}, {'hostname': '72.14.238.82', 'longitude': -122.0574, 'rtt': '15.124 ms', 'hop_num': 9, 'latitude': 37.4192, 'ip_address': '72.14.238.82'}, {'hostname': '72.14.238.16', 'longitude': -122.0574, 'rtt': '15.564 ms', 'hop_num': 9, 'latitude': 37.4192, 'ip_address': '72.14.238.16'}, {'hostname': '216.239.49.149', 'longitude': -122.0574, 'rtt': '23.253 ms', 'hop_num': 10, 'latitude': 37.4192, 'ip_address': '216.239.49.149'}, {'hostname': 'google-public-dns-a.google.com', 'longitude': -122.0574, 'rtt': '13.020 ms', 'hop_num': 11, 'latitude': 37.4192, 'ip_address': '8.8.8.8'}]
>>>

You can also run the script directly by passing in the --ip_address option:

$ python traceroute.py --help
Usage: traceroute.py --ip_address=IP_ADDRESS

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -i IP_ADDRESS, --ip_address=IP_ADDRESS
                        IP address of destination host (default: 8.8.8.8)
  -c COUNTRY, --country=COUNTRY
                        Traceroute will be initiated from this country; choose
                        'US' for United States, 'CH' for Switzerland, 'JP' for
                        Japan or 'LO' for localhost to run traceroute locally
                        (default: US)
  -t TMP_DIR, --tmp_dir=TMP_DIR
                        Temporary directory to store downloaded traceroute
                        results (default: /tmp)
  -n, --no_geo          No geolocation data (default: False)
  -s TIMEOUT, --timeout=TIMEOUT
                        Timeout in seconds for all downloads (default: 120)
  -d, --debug           Show debug output (default: False)

$ python traceroute.py --ip_address=8.8.8.8
[
    {
        "hostname": "gigagate1",
        "longitude": -74.6597,
        "rtt": "0.700 ms",
        "hop_num": 1,
        "latitude": 40.3756,
        "ip_address": "128.112.128.114"
    },
    {
        "hostname": "vgate1",
        "longitude": -74.6597,
        "rtt": "0.375 ms",
        "hop_num": 2,
        "latitude": 40.3756,
        "ip_address": "128.112.12.22"
    },
    {
        "hostname": "te-1-4-3998-pe01.philadelphia.pa.ibone.comcast.net",
        "longitude": -75.3697,
        "rtt": "18.296 ms",
        "hop_num": 3,
        "latitude": 40.3265,
        "ip_address": "24.104.128.89"
    },
    {
        "hostname": "te-0-1-0-12-cr01.ashburn.va.ibone.comcast.net",
        "longitude": -97.0,
        "rtt": "28.446 ms",
        "hop_num": 4,
        "latitude": 38.0,
        "ip_address": "68.86.84.177"
    },
    {
        "hostname": "pos-0-2-0-0-pe01.ashburn.va.ibone.comcast.net",
        "longitude": -97.0,
        "rtt": "21.968 ms",
        "hop_num": 5,
        "latitude": 38.0,
        "ip_address": "68.86.86.70"
    },
    {
        "hostname": "75.149.231.62",
        "longitude": -97.0,
        "rtt": "20.685 ms",
        "hop_num": 6,
        "latitude": 38.0,
        "ip_address": "75.149.231.62"
    },
    {
        "hostname": "209.85.252.80",
        "longitude": -122.0574,
        "rtt": "18.383 ms",
        "hop_num": 7,
        "latitude": 37.4192,
        "ip_address": "209.85.252.80"
    },
    {
        "hostname": "209.85.252.46",
        "longitude": -122.0574,
        "rtt": "18.541 ms",
        "hop_num": 7,
        "latitude": 37.4192,
        "ip_address": "209.85.252.46"
    },
    {
        "hostname": "209.85.252.80",
        "longitude": -122.0574,
        "rtt": "19.723 ms",
        "hop_num": 7,
        "latitude": 37.4192,
        "ip_address": "209.85.252.80"
    },
    {
        "hostname": "72.14.238.82",
        "longitude": -122.0574,
        "rtt": "15.124 ms",
        "hop_num": 9,
        "latitude": 37.4192,
        "ip_address": "72.14.238.82"
    },
    {
        "hostname": "72.14.238.16",
        "longitude": -122.0574,
        "rtt": "15.564 ms",
        "hop_num": 9,
        "latitude": 37.4192,
        "ip_address": "72.14.238.16"
    },
    {
        "hostname": "216.239.49.149",
        "longitude": -122.0574,
        "rtt": "23.253 ms",
        "hop_num": 10,
        "latitude": 37.4192,
        "ip_address": "216.239.49.149"
    },
    {
        "hostname": "google-public-dns-a.google.com",
        "longitude": -122.0574,
        "rtt": "13.020 ms",
        "hop_num": 11,
        "latitude": 37.4192,
        "ip_address": "8.8.8.8"
    }
]

traceroute's People

Contributors

ayeowch avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.