Published
Edited
Dec 31, 2021
1 fork
Insert cell
Insert cell
import {SummaryTable} from "@observablehq/summary-table"
Insert cell
Insert cell
SummaryTable( updates )
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// data = d3.json(`https://sg-pub.ripe.net/emile/ris-as-tracker/parsed.${asn}.rrc05.2021-12-07.json.down.60.json`) // 16509
data = d3.json("https://sg-pub.ripe.net/emile/ris-as-tracker/parsed.32934.rrc05.2021-10-04.json")
//data = d3.json("https://sg-pub.ripe.net/emile/ris-as-tracker/parsed.7922.rrc00.2021-11-09.json")
Insert cell
updates = data.update_msg.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.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 )
}
});
// now put stuff there for anything that was up until the last TS
let end_end_ts = updates[ updates.length - 1 ].ts ; // TODO: this is a hack. won't work if there is a long period without updates before the actual en time
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': end_end_ts
});
}
return updown
};
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more