Public
Edited
Dec 17, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
while (true) {
yield; // world.ringsData(results);
world
.arcsData(results)
.arcAltitude((d) => 0.05)
.arcColor((d) => d.color)
// .arcsTransitionDuration(1000)

.arcDashLength(0.2)
.arcStroke(0.1)
.arcDashGap(2)
// .arcDashInitialGap(1)
// .arcsTransitionDuration(1)
.arcDashAnimateTime(1000);
// .ringColor(() => (t) => `rgba(255,100,50,${1 - t})`)
// .ringMaxRadius(5)
// .ringPropagationSpeed(0.5);
// .ringRepeatPeriod(FLIGHT_TIME * ARC_REL_LEN / NUM_RINGS);
await Promises.tick(5000);
}
}
Insert cell
params = [
{
streamType: "result",
// type: "ping",
enrichProbes: true,
msm: 1001
}, {streamType: "result",
// type: "ping",
enrichProbes: true,
msm: 2001},
// {
// streamType: "result",
// type: "ping",
// enrichProbes: true
// }
]
Insert cell
Insert cell
Insert cell
socket = {
const socket = new WebSocket("wss://atlas-stream.ripe.net/stream/");

socket.onmessage = function (event) {
const r = JSON.parse(event.data)[1];
// mutable results = mutable results.concat(r);
// mutable results = results.push(r);
// console.log(r);
const rtts = r.result ? r.result.map((r) => r.rtt).filter((r) => r) : [];
// if (typeof resultsMap[r.prb_id] === "undefined")
// resultsMap[r.prb_id] = d3.min(rtts);
// else if (typeof resultsMap[r.prb_id] === "object")
// resultsMap[r.prb_id] = d3.min(resultsMap[r.prb_id], ...rtts);

// try updating the viz directly?
const rtt = d3.min(rtts);
if (rtt < 10.0 && Math.random() < 100 * chances.get(r.probe.country_code)) {
// console.log(
// chances.get(r.probe?.country_code, 0.0),
// r.probe?.country_code,
// ipmap.get(r.dst_addr)
// );

if (r.dst_addr === undefined) return;

let [i, c] = [ipmap.get(r.dst_addr), coordinates.get(r.prb_id)];
let [clat, clon, ilat, ilon] = [c?.lat, c?.lon, i?.lat, i?.lon];
// world.ringsData(
// world
// .ringsData()
// .concat([
// {
// lat: clat,
// lng: clon,
// sides: 3,
// maxR: 1,
// type: "probe"
// },
// {
// lat: ilat,
// lng: ilon,
// sides: 3,
// maxR: 1,
// type: "target"
// }
// ])
// .slice(-100)
// );

// let result = [
// {
// lat: clat,
// lng: clon,
// sides: 3,
// maxR: 1,
// type: "probe"
// },
// {
// lat: ilat,
// lng: ilon,
// sides: 3,
// maxR: 1,
// type: "target"
// }
// ];

if (
ilat === undefined ||
ilon === undefined ||
clat === undefined ||
clon === undefined
)
return;

let result = [
{
startLat: ilat,
startLng: ilon,
endLat: clat,
endLng: clon,
altitude: 0,
color: r.dst_addr?.includes(":") ? "red" : "blue"
}
];
mutable results = mutable results.concat(result).slice(-100);

// if ([clat, clon, ilat, ilon].every((d) => d != undefined)) {
// //arcs
// const o = {
// startLat: ilat,
// startLng: ilon,
// stopLat: clat,
// stopLng: clon,
// color: ['blue', 'red']
// };
// console.log(o);
// world.arcsData(world.arcsData().concat([o]).slice(-2000));
// }
}
};
socket.onopen = function (event) {
for (let param of params)
this.send(JSON.stringify(["atlas_subscribe", param]));
};

return socket;
}
Insert cell
// {
// socket.send(JSON.stringify(["atlas_unsubscribe", params]));
// return socket;
// }
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
geolocations_2023-05-30@2.v4.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
ipmap = {
let res = new Map();
for (let o of _geolocations_20230530V4)
res.set(o["ip"], { lat: o["lat"], lon: o["lon"] });
return res;
}
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