Published
Edited
Feb 28, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
if ( filename != "" ) {
return d3.json(`https://sg-pub.ripe.net/emile/ris-as-tracker/${filename}`)
} else {
return d3.json(`https://sg-pub.ripe.net/emile/ris-as-tracker/parsed.${asn_inp}.${rrc_inp}.${date_inp}.json`)
}
}
Insert cell
filename
Insert cell
asfam_filter = function( pfx ) {
if ( select_af == "IPv4+IPv6" ) {
return true
} else if ( select_af == "IPv6" && pfx.includes(':') ) {
return true
} else if ( select_af == "IPv4" && ! pfx.includes(':') ) {
return true
} else {
return false
}
}
Insert cell
pfx_list = data.initial_prefixes.filter( d => asfam_filter( d ) )
Insert cell
updates = data.update_msg.filter( d => asfam_filter( d[5] ) ).map( d => {
let x = {};
x.ts = d3.timeParse("%s")( d[1] );
x.type = String( d[2] ); // announce/withdraw (wtf. need to cast to string to get a string from a string?!)
x.peer_ip = d[3];
x.peer_as = d[4];
x.pfx = d[5];
x.aspath = d[6];
x.origin = d[7];
x.community_str = d[11];
return x
});
Insert cell
updown = { // generate tuples for when a particular peer/pfx combi was visible (peer,pfx)->(ts_start,ts_end)
let updown = [];
let state = {}; // state per pfx/peer combi. We assume data is time ordered
let ts = null;
// parse initial state
data.initial_state.filter( d => asfam_filter( d[5] ) ).forEach( d => {
state[ [ d[3],d[5] ] ] = d3.timeParse("%s")( d[1] )
});
//console.log( state );
updates.forEach( x => {
if( x.type == 'W' && [ x.peer_ip, x.pfx ] in state) {
// withdrawal of existing
updown.push({
'peer_ip': x.peer_ip,
'pfx': x.pfx,
'start_ts': state[ [x.peer_ip, x.pfx] ],
'end_ts': x.ts
});
delete state[ [ x.peer_ip, x.pfx ] ];
} else if ( x.type == 'A' && state[ x.peer_ip, x.pfx ] === undefined ) {
state[ [ x.peer_ip, x.pfx ] ] = x.ts
// new announce
} else { // TODO log spurious updates, ie. A->A and W->W state changes?
//console.log( "EEP", x )
}
});
for ( var key in state ) {
key = key.split(','); // wut! composite key needs to be decomposed manually?!
updown.push({
'peer_ip': key[0],
'pfx': key[1],
'start_ts': state[ key ],
'end_ts': d3.timeParse("%s")( data.meta.last_ts ),
'box_end': true
});
}
return updown
};
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