Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pycbg usage #1

Open
ihsanhaikalz opened this issue May 24, 2018 · 4 comments
Open

pycbg usage #1

ihsanhaikalz opened this issue May 24, 2018 · 4 comments

Comments

@ihsanhaikalz
Copy link

Hi. I stummbled upon your library after Googling CBG implementation library and I want to try to use it. Unfortunately I'm not proficient with python so I have difficulties of using and understanding it.

You gave an example code like this

cbgObj=cbg()
inputConstraints=cbgObj.getInputConstraints(json.load(open('data/4514096.json','r')))
cityDict=cbgObj.getCities(inputConstraints)

but I don't know what is the next step to actually geolocate the IP. Could you give a complete example of how to use it? Also is there any restriction for using it? Will it work if I give my IP address but my current location is in Germany?

Thanks

@akshah
Copy link
Owner

akshah commented Jun 6, 2018

Hey, this code assumes you have measurement data from RIPE Atlas (as in data/4514096.json) in this example. It will then perform the constraint-based geolocation and then return a city if geolocation using given measurements was successful.

@ihsanhaikalz
Copy link
Author

If I don't have the measurement data from RIPE Atlas how am I able to do that? As far as I know RIPE Atlas is "not free" to do the ping measurement and I was thinking to do it focusing only in Germany. Do you know any free alternative for me to get the measurement? Also I am having the same problem how to run your code as I think you only gave partial example code for it, could you show me the example code of running your code?

@ihsanhaikalz
Copy link
Author

So somehow I was able to get it running, but when I run the gelocateIPUsingSimpleCBG.py with 3 json files put in the data folder, two got no result while another one somehow suggested that I am in Malaysia, which is wrong as I am in Germany.

The result is like below

[python geolocateIPUsingSimpleCBG.py data/3680163.json 
{'': {'': {'hougang mall': {'lat': 1.37249, 'lon': 103.893}}},
 'id': {'': {'kabil': {'lat': 1.05, 'lon': 104.13},
             'karimun besar offshore': {'lat': 1.07, 'lon': 103.52}},
        '37': {'pancur biru lestari ii': {'lat': 1.03072, 'lon': 104.055},
               'wooden house': {'lat': 1.13284, 'lon': 103.959}},
        'kr': {'durian': {'lat': 1.02, 'lon': 103.57}},
        'ri': {'batam': {'lat': 1.12103, 'lon': 104.119},
               'nipah': {'lat': 1.12, 'lon': 103.55},
               'sekupang': {'lat': 1.13, 'lon': 103.93}}},
 'my': {'': {'tebrau': {'lat': 1.5, 'lon': 103.83}},
        '01': {'johor bahru': {'lat': 1.4655, 'lon': 103.758},
               'kampong tanjong kupang': {'lat': 1.35, 'lon': 103.58},
               'kampung pasir gudang baru': {'lat': 1.4726, 'lon': 103.878},
               'kampung tanjung langsat': {'lat': 1.47, 'lon': 104.02},
               'kelapa sawit': {'lat': 1.6698, 'lon': 103.533},
               'kota tinggi': {'lat': 1.7381, 'lon': 103.9},
               'kulai': {'lat': 1.6561, 'lon': 103.603},
               'nusajaya': {'lat': 1.47, 'lon': 103.63},
               'pekan nenas': {'lat': 1.51, 'lon': 103.514},
               'pengerang': {'lat': 1.37, 'lon': 104.12},
               'skudai': {'lat': 1.53741, 'lon': 103.658},
               'taman molek': {'lat': 1.55, 'lon': 103.8},
               'taman senai': {'lat': 1.6006, 'lon': 103.642},
               'tampoi': {'lat': 1.48, 'lon': 103.69},
               'tanjong bin': {'lat': 1.33, 'lon': 103.55},
               'tanjung pelepas': {'lat': 1.37, 'lon': 103.55},
               'ulu tiram': {'lat': 1.6, 'lon': 103.817}}},
 'sg': {'': {'blk 658d': {'lat': 1.33723, 'lon': 103.7},
             'blk658d': {'lat': 1.33731, 'lon': 103.701},
             'choa chu kang': {'lat': 1.28, 'lon': 103.85},
             'clementi': {'lat': 1.28, 'lon': 103.85},
             'funan digitalife mall': {'lat': 1.29143, 'lon': 103.85},
             'jurong/singapore': {'lat': 1.33, 'lon': 103.7},
             'ministry of information, communications and the arts': {'lat': 1.29063,
                                                                      'lon': 103.848},
             'pasir panjang wharves': {'lat': 1.27, 'lon': 103.78},
             'pasir ris new town': {'lat': 1.37, 'lon': 103.93},
             'pulau ayer chawan': {'lat': 1.27, 'lon': 103.7},
             'tampines': {'lat': 1.33, 'lon': 103.93},
             'the central': {'lat': 1.28928, 'lon': 103.847},
             'toa payoh': {'lat': 1.33, 'lon': 103.85},
             'tuas': {'lat': 1.32, 'lon': 103.65},
             'west coast town': {'lat': 1.28, 'lon': 103.85}},
        '00': {'singapore': {'lat': 1.28967, 'lon': 103.85}},
        '01': {'bukit merah estate': {'lat': 1.28, 'lon': 103.82}},
        '02': {'seletar': {'lat': 1.41695, 'lon': 103.868}},
        '04': {'changi': {'lat': 1.34013, 'lon': 103.996},
               'paya lebar': {'lat': 1.35695, 'lon': 103.9}},
        '05': {'pioneer': {'lat': 1.32, 'lon': 103.68},
               'tengah': {'lat': 1.38726, 'lon': 103.709}}}}](url)

How do I make it to be able to locate me "accurately"? Do I need the data from RIPE dataset, which is not free as far as I know?

@akshah
Copy link
Owner

akshah commented Jul 3, 2018

Hey. So this code only works for real traceroute from RIPE Atlas. Did you pass-in recent traceroute data to it? Also, in some cases, it's possible that the code cannot confidently predict location in which case it will not return you results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants