Public
Edited
Jun 14, 2022
Insert cell
Insert cell
Insert cell
Insert cell
plot = Plot.plot({
color: {
type: "linear",
domain: [0,10,100],
range: ["green","yellow","red"]
},
marks: [
Plot.cell(setpercountry, {
x: "cc",
y: "asn",
fill: "min_rtt",
title: d => `prb_id ${d.prb_id}`
}),
Plot.text(setpercountry, {
x: "cc",
y: "asn",
text: "min_rtt"
}),
]
})
Insert cell
setpercountry = {
const data = []; // contains objects of country
const countries = ccs.replace(' ','').split(",")
for (const cc of countries) {
for ( const asn of Object.keys( assets_latencies ) ) {
const lats = assets_latencies[ asn ];
console.log( lats, cc );
const lats_for_cc = lats.filter( x => cc2prb_id[ cc ].has( x.prb_id ) ).sort( (a,b) => {
return a.min_rtt - b.min_rtt
});
if ( lats_for_cc.length > 0 ) {
const low = lats_for_cc[0]
data.push({'cc': cc, 'asn': asn, 'prb_id': low.prb_id, 'min_rtt': low.min_rtt})

} else {
data.push({'cc': cc, 'asn': asn, 'prb_id': NaN, 'min_rtt': NaN})
}
const min_for_cc = Math.min(...lats.filter( x => cc2prb_id[ cc ].has( x.prb_id ) ).map( x => x.min_rtt ) ) || 0;
// data.push({'cc': cc, 'asn': asn, 'min_rtt': min_for_cc})
}
}
return data
}
Insert cell
assets_latencies = { // fetch latencies for asses that
var lats = {};
for( const asn of Object.keys( assets[ assets_selector ] ) ) {
//const url = `https://rd-gcp-cdn.ripe.net/rd/min-rtt-by-net/${yesterday.replaceAll('-','/')}/${asn}.json`;
const url = `https://rd-gcp-cdn.ripe.net/rd/min-rtt-by-net/latest/${asn}.json`
let asn_latencies = await fetch( url ).then(r => r.json() );
lats[ asn ] = asn_latencies.filter(r => r.protoc != 'TCP');
}
return lats;
}
Insert cell
aap = {
const url = "https://rd-gcp-cdn.ripe.net/rd/min-rtt-by-net/latest/3333.json";
let response = await fetch(url);
return response.json()
}
Insert cell
assets = ({
"tier1": { // from https://en.wikipedia.org/wiki/Tier_1_network 2021-11-04
7018: 'AT&T',
3320: 'Deutsche Telekom',
3257: 'GTT',
6830: 'LGI',
3356: 'Lumen/Level3',
3549: 'Lumen/GBLX',
2914: 'NTT',
5511: 'Orange',
3491: 'PCCW',
1239: 'T-mobile/Sprint',
6453: 'TATA',
6762: 'TI/Seabone',
1299: 'Telia',
12956: 'Telxius',
701: 'Verizon',
6461: 'Zayo'
},
'gafam': {
15169: 'Google',
714: 'Apple',
32934: 'Facebook',
16509: 'Amazon',
8075: 'Microsoft',
13335: "cloudflare",
2906: "netflix"
},
'cn-ru-content': { // initial list from HMI
45102: 'Alibaba',
4134: 'China Telecom',
47541: 'VKontakte',
13238: 'Yandex'
},
'serbia-eyeballs': {
8400: 'telekom',
31042: 'serbia bb',
15958: 'cetin',
},
'jp-transit': {
2497: 'iij',
2516: 'kddi',
4713: 'ocn',
2518: 'biglobe',
17676: 'softbank',
2527: 'sonet'
}
})
Insert cell
all_probes = {
//let [yyyy, m, d] = date.split("-");
//const urlLocator = date === "" ? yesterday : `${yyyy}-${m}-${d}`; // dashes, different than the one used for the msms
const urlLocator = yesterday
const probes = await fetch(
`https://atlas.ripe.net/api/v2/probes/archive/?date=${urlLocator}`
).then((r) => r.json());
return probes["results"].filter( x => x.status.id == 1 )
}
Insert cell
cc2prb_id = all_probes.reduce( (acc,p ) => {
// if ( probe_whitelist_set.has( p.id ) ) {
if (! probe_blocklist_set.has( p.id ) ) {
if ( p.country_code in acc ) {
acc[ p.country_code ].add( p.id );
} else {
acc[ p.country_code ] = new Set([ p.id ]);
}
}
return acc
}, {} );
Insert cell
yesterday = {
let a = new Date();
a.setDate(a.getDate() - 1);
return a.toISOString().split("T")[0];
}
Insert cell
probe_blocklist_set = new Set([52944])
Insert cell
probe_whitelist = FileAttachment("probe-whitelist.csv").csv()
Insert cell
probe_whitelist_set = new Set(probe_whitelist.map( x => +x.prb_id ))
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"

Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more