RIPE Atlas - contributed code and various tools
The RIPE Atlas Community GitHub page hosts a few scripts that have been contributed before.
1. Accessing site functionality from scripts with API keys
For some kinds of data, you can gain access using API keys. These keys can be created in the key management screen.
See the API key documentation for help on creating and using keys.
2. Convert JSON traceroutes to human-readable format
(Contributed by Jan Hugo Prins)
A python script to convert the Atlas traceroute output to readable traceroutes.
The whois information is gathered from Cymru using: https://github.com/JustinAzoff/python-cymruwhois
3. Decoding result details
Decoding of result JSON blobs is most easily accomplished by way of the Sagan Python library. You pass the result text to the parser and out comes a native Python object:
from ripe.atlas.sagan import PingResult my_result = PingResult("<result string from RIPE Atlas ping measurement>") print(my_result.rtt_median) 123.456 print(my_result.af) 6
3.1. Manual decoding DNS result details
If you'd rather not use a library, instead opting to do the parsing yourself, the samples below should help.
The following code examples show possible ways in which a abuf or qbuf field in the DNS measurement results could be decoded. The examples were written for version 4400 and apply the example abuf embedded in the code.
#!/usr/bin/perl -I/root/Net-DNS-0.68/lib use MIME::Base64; use Net::DNS; use Net::DNS::Packet; #use strict; my $bb64 = 'f2+AgAABAAEAAAAAA3d3dwRyaXBlA25ldAAAAQABwAwAAQABAAA3+gAEwQAGiw=='; my $data = decode_base64($bb64); my $packet = Net::DNS::Packet->new(\$data, 1); ;; HEADER SECTION ;; id = 32623 ;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 0 ;; ra = 1 ad = 0 cd = 0 rcode = NOERROR ;; qdcount = 1 ancount = 1 nscount = 0 arcount = 0 ;; QUESTION SECTION (1 record) ;; www.ripe.net. IN A ;; ANSWER SECTION (1 record) www.ripe.net. 14330 IN A 188.8.131.52 ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (0 records)
atlas@ronin:~$ python/bin/python >>> import base64 >>> import dns.message >>> dnsmsg = dns.message.from_wire(base64.b64decode('f2+AgAABAAEAAAAAA3d3dwRyaXBlA25ldAAAAQABwAwAAQABAAA3+gAEwQAGiw==')) >>> print dnsmsg id 32623 opcode QUERY rcode NOERROR flags QR RA ;QUESTION www.ripe.net. IN A ;ANSWER www.ripe.net. 14330 IN A 184.108.40.206 ;AUTHORITY ;ADDITIONAL