Skip to content

Instantly share code, notes, and snippets.

@pierky
Last active June 1, 2016 19:20
Show Gist options
  • Save pierky/e5ec5c8f8f926bff3ef3 to your computer and use it in GitHub Desktop.
Save pierky/e5ec5c8f8f926bff3ef3 to your computer and use it in GitHub Desktop.
with open("v6probes.clean", "r") as f:
raw = f.read()
lines = raw.split("\n")
asn_probes = {}
for line in lines:
if line.strip() == "":
continue
# probe_id, asn_v4, asn_v6, cc, status
fields = [val for val in line.split(" ") if val.strip()]
probe_id = fields[0]
asn_v4 = fields[1]
asn_v6 = fields[2]
# consider only probes with ASN_v4 == ASN_v6
if asn_v4 == asn_v6:
if asn_v4 not in asn_probes:
asn_probes[asn_v4] = []
asn_probes[asn_v4].append(int(probe_id))
probes = []
for asn in asn_probes:
# max 5 probes for each ASN
probes.extend(asn_probes[asn][0:5])
PROBES_PER_MSM = 500
CMD = ("ripe-atlas measure dns --auth `cat ~/.atlas/create` "
"--af 6 --no-report --from-probes={probe_list} "
"--protocol UDP --query-type AAAA --query-argument ipv4only.arpa")
cnt = len(probes)
for step in range(0, int(cnt / PROBES_PER_MSM + 1)):
step_low = step * PROBES_PER_MSM
step_high = (step + 1) * PROBES_PER_MSM
if step_high > len(probes) - 1:
step_high = None
msm_probes = probes[step_low:step_high]
probe_list = ",".join(map(str, msm_probes))
print("")
print("# {} probes".format(len(msm_probes)))
print(CMD.format(probe_list=probe_list))

Get a list of probes tagged with system-ipv6-works and save it on v6probes.clean:

$ ripe-atlas probes --status 1 --tag system-ipv6-works --limit 3000 > v6probes
$ cat v6probes | grep Connected > v6probes.clean

The --tag argument is part of a PR that has been merged into Magellan but that's not released yet.

Run the parse_probes.py script (you can find it within this gist) to filter probes and to consider only max 5 probes for each source ASN among those whose ASN_v4 and ASN_v6 match [1]. The script prints a list of RIPE Atlas Tools (Magellan) commands to execute in order to start measurements (you need an API key in ~/.atlas/create).

$ python parse_probes.py

# 500 probes
ripe-atlas measure dns --auth `cat ~/.atlas/create` --af 6 --no-report --from-probes=... --protocol UDP --query-type AAAA --query-argument ipv4only.arpa
[...]

Start the measurements, wait until they complete, then analyze their results (I used RIPE Atlas Monitor here):

$ ripe-atlas-monitor analyze --measurement-id 3606764
Downloading and processing results... please wait
[...]
DNS Answers:

 ipv4only.arpa.            AAAA   2a02:1388:2040:0:0:0:c000:aa
 ipv4only.arpa.            AAAA   2a02:1388:2040:0:0:0:c000:ab: 1 time (1 unique probe), probe ID 12946 (AS29247, GR)

This is the result: 7 probes in 5 different ASNs.

Measurement ID 3606764:
 ipv4only.arpa.            AAAA   2a02:1388:2040:0:0:0:c000:aa
 ipv4only.arpa.            AAAA   2a02:1388:2040:0:0:0:c000:ab: 1 time (1 unique probe), probe ID 12946 (AS29247, GR)

Measurement ID 3606765:
 ipv4only.arpa.            AAAA   64:ff9b:0:0:0:0:c000:aa
 ipv4only.arpa.            AAAA   64:ff9b:0:0:0:0:c000:ab    : 4 times (2 unique probes), probe ID 16725 (AS5617, PL), probe ID 16736 (AS5617, PL)

 ipv4only.arpa.            AAAA   2a01:568:0:0:0:6464:c000:aa: 4 times (2 unique probes), probe ID 753 (AS43950, GB), probe ID 2589 (AS43950, GB)

Measurement ID 3606766:
 ipv4only.arpa.            AAAA   2a01:568:0:0:0:6464:c000:aa: 2 times (1 unique probe), probe ID 4481 (AS198864, GB)

Measurement ID 3606767:
 ipv4only.arpa.            AAAA   64:ff9b:0:0:0:0:c000:aa
 ipv4only.arpa.            AAAA   64:ff9b:0:0:0:0:c000:ab: 1 time (1 unique probe), probe ID 22638 (AS18200, NC)

1] I didn't reflect too much about this criterion, I just wanted to exclude tricky scenarios (tunnels).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment