Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 274 additions & 0 deletions dev-fixtures/meshviewer.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,210 @@
"longitude": 13.3958
},
"is_gateway": false
},
{
"node_id": "021122334410",
"hostname": "Mizar",
"domain": "lab",
"firstseen": "@now-8d",
"lastseen": "@now",
"is_online": true,
"location": {
"latitude": 52.4992,
"longitude": 13.076
},
"firmware": {
"release": "1.0.0",
"base": "openwrt"
},
"uptime": "@now-6h",
"nproc": 1,
"loadavg": 0.22,
"memory_usage": 0.36,
"model": "TP-Link Archer C6 v3",
"clients": 5,
"clients_wifi24": 2,
"clients_wifi5": 3,
"clients_other": 0,
"is_gateway": false,
"addresses": ["fd00::20", "10.0.0.20"],
"gateway_nexthop": "021122334414",
"gateway": "021122334414",
"gateway6": "021122334414",
"autoupdater": {
"enabled": true,
"branch": "stable"
}
},
{
"node_id": "021122334411",
"hostname": "Alcor",
"domain": "lab",
"firstseen": "@now-7d",
"lastseen": "@now",
"is_online": true,
"location": {
"latitude": 52.5005,
"longitude": 13.0735
},
"firmware": {
"release": "1.0.0",
"base": "openwrt"
},
"uptime": "@now-5h",
"nproc": 4,
"loadavg": 0.18,
"memory_usage": 0.41,
"model": "ZyXEL NWA50AX",
"clients": 3,
"clients_wifi24": 1,
"clients_wifi5": 2,
"clients_other": 0,
"is_gateway": false,
"addresses": ["fd00::21", "10.0.0.21"],
"gateway_nexthop": "021122334414",
"gateway": "021122334414",
"gateway6": "021122334414",
"autoupdater": {
"enabled": true,
"branch": "stable"
}
},
{
"node_id": "021122334412",
"hostname": "Castor",
"domain": "lab",
"firstseen": "@now-6d",
"lastseen": "@now",
"is_online": true,
"location": {
"latitude": 52.4978,
"longitude": 13.0788
},
"firmware": {
"release": "1.0.0",
"base": "openwrt"
},
"uptime": "@now-9h",
"nproc": 2,
"loadavg": 0.12,
"memory_usage": 0.29,
"model": "MikroTik hAP ac3",
"clients": 2,
"clients_wifi24": 1,
"clients_wifi5": 1,
"clients_other": 0,
"is_gateway": false,
"addresses": ["fd00::22", "10.0.0.22"],
"gateway_nexthop": "021122334415",
"gateway": "021122334415",
"gateway6": "021122334415",
"autoupdater": {
"enabled": true,
"branch": "stable"
}
},
{
"node_id": "021122334413",
"hostname": "Procyon",
"domain": "lab",
"firstseen": "@now-4d",
"lastseen": "@now",
"is_online": true,
"location": {
"latitude": 52.496,
"longitude": 13.0742
},
"firmware": {
"release": "1.0.0",
"base": "openwrt"
},
"uptime": "@now-2h",
"nproc": 1,
"loadavg": 0.06,
"memory_usage": 0.22,
"model": "TP-Link CPE510 v3",
"clients": 1,
"clients_wifi24": 1,
"clients_wifi5": 0,
"clients_other": 0,
"is_gateway": false,
"addresses": ["fd00::23", "10.0.0.23"],
"gateway_nexthop": "021122334414",
"gateway": "021122334414",
"gateway6": "021122334414",
"autoupdater": {
"enabled": true,
"branch": "stable"
}
},
{
"node_id": "021122334414",
"hostname": "Polaris",
"domain": "lab",
"firstseen": "@now-90d",
"lastseen": "@now",
"is_online": true,
"location": {
"latitude": 52.502,
"longitude": 13.0805
},
"firmware": {
"release": "1.0.0",
"base": "openwrt"
},
"uptime": "@now-25d",
"nproc": 4,
"loadavg": 0.44,
"memory_usage": 0.39,
"model": "PC Engines APU2",
"clients": 0,
"clients_wifi24": 0,
"clients_wifi5": 0,
"clients_other": 0,
"is_gateway": true,
"addresses": ["fd00::24", "10.0.0.24"],
"gateway_nexthop": "021122334414",
"gateway": "021122334414",
"gateway6": "021122334414",
"autoupdater": {
"enabled": false,
"branch": "stable"
}
},
{
"node_id": "021122334415",
"hostname": "Spica",
"domain": "lab",
"firstseen": "@now-100d",
"lastseen": "@now",
"is_online": true,
"location": {
"latitude": 52.4948,
"longitude": 13.07
},
"firmware": {
"release": "1.0.0",
"base": "openwrt"
},
"uptime": "@now-40d",
"nproc": 4,
"loadavg": 0.51,
"memory_usage": 0.47,
"model": "PC Engines APU2",
"clients": 0,
"clients_wifi24": 0,
"clients_wifi5": 0,
"clients_other": 0,
"is_gateway": true,
"addresses": ["fd00::25", "10.0.0.25"],
"gateway_nexthop": "021122334415",
"gateway": "021122334415",
"gateway6": "021122334415",
"autoupdater": {
"enabled": false,
"branch": "stable"
}
}
],
"links": [
Expand Down Expand Up @@ -357,6 +561,76 @@
"target_addr": "02:11:22:33:44:99",
"source_tq": 0.42,
"target_tq": 0.17
},
{
"type": "wifi5",
"source": "021122334410",
"target": "021122334411",
"source_addr": "02:11:22:33:44:10",
"target_addr": "02:11:22:33:44:11",
"source_tp": 866000,
"target_tp": 780000
},
{
"type": "wifi5",
"source": "021122334410",
"target": "021122334412",
"source_addr": "02:11:22:33:44:10",
"target_addr": "02:11:22:33:44:12",
"source_tp": 300000,
"target_tp": 8500
},
{
"type": "wifi24",
"source": "021122334410",
"target": "021122334413",
"source_addr": "02:11:22:33:44:10",
"target_addr": "02:11:22:33:44:13",
"source_tp": 800,
"target_tp": 2400
},
{
"type": "wifi5",
"source": "021122334411",
"target": "021122334412",
"source_addr": "02:11:22:33:44:11",
"target_addr": "02:11:22:33:44:12",
"source_tp": 54000,
"target_tp": 54000
},
{
"type": "vpn",
"source": "021122334414",
"target": "021122334410",
"source_addr": "02:11:22:33:44:14",
"target_addr": "02:11:22:33:44:10",
"target_tp": 1000000
},
{
"type": "vpn",
"source": "021122334412",
"target": "021122334415",
"source_addr": "02:11:22:33:44:12",
"target_addr": "02:11:22:33:44:15",
"source_tp": 100000
},
{
"type": "vpn",
"source": "021122334414",
"target": "021122334413",
"source_addr": "02:11:22:33:44:14",
"target_addr": "02:11:22:33:44:13",
"source_tq": 0.98,
"target_tp": 1000000
},
{
"type": "other",
"source": "021122334415",
"target": "021122334414",
"source_addr": "02:11:22:33:44:15",
"target_addr": "02:11:22:33:44:14",
"source_tp": 1200000,
"target_tp": 1200000
}
]
}
8 changes: 5 additions & 3 deletions lib/forcegraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as d3Timer from "d3-timer";
import * as d3Zoom from "d3-zoom";

import math from "./utils/math.js";
import * as helper from "./utils/helper.js";
import draw, { MapLink, MapNode } from "./forcegraph/draw.js";
import { Sidebar } from "./sidebar.js";
import { ClientPointEvent } from "d3-selection";
Expand Down Expand Up @@ -163,7 +164,8 @@ export const ForceGraph = function (linkScale: (t: any) => any, sidebar: ReturnT
return 0.02;
}
// @ts-expect-error d3 node
return Math.max(0.5, node.o.source_tq);
const metric = helper.linkMetric(node.o.source_tq, node.o.source_tp) ?? 0;
return Math.max(0.5, metric);
});

const zoom = d3Zoom
Expand Down Expand Up @@ -261,8 +263,8 @@ export const ForceGraph = function (linkScale: (t: any) => any, sidebar: ReturnT
o: link,
source,
target,
color: linkScale(link.source_tq),
color_to: linkScale(link.target_tq),
color: linkScale(helper.linkMetric(link.source_tq, link.source_tp) ?? 0),
color_to: linkScale(helper.linkMetric(link.target_tq, link.target_tp) ?? 0),
x: 0,
y: 0,
},
Expand Down
5 changes: 4 additions & 1 deletion lib/forcegraph/draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ const self = {
} else if (link.o.type.indexOf("other") === 0) {
ctx.globalAlpha = 1;
ctx.lineWidth = 3.5;
if (link.o.source_tq >= 0.99 && link.o.target_tq >= 0.99) {
if (
(helper.linkMetric(link.o.source_tq, link.o.source_tp) ?? 0) >= 0.99 &&
(helper.linkMetric(link.o.target_tq, link.o.target_tp) ?? 0) >= 0.99
) {
link.color = config.forceGraph.otherLinkColor;
link.color_to = config.forceGraph.otherLinkColor;
}
Expand Down
14 changes: 11 additions & 3 deletions lib/infobox/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ export const Link = function (el: HTMLElement, linkData: [LinkData, ...LinkData[
);
helper.attributeEntry(
children,
"node.tq",
(link.source_tp ?? 0) > 0 || (link.target_tp ?? 0) > 0 ? "node.throughput" : "node.tq",
h(
"span",
{ style: { color: linkScale((link.source_tq + link.target_tq) / 2) } },
helper.showTq(link.source_tq) + " - " + helper.showTq(link.target_tq),
{
style: {
color: linkScale(
((helper.linkMetric(link.source_tq, link.source_tp) ?? 0) +
(helper.linkMetric(link.target_tq, link.target_tp) ?? 0)) /
2,
),
},
},
helper.showBiDiLinkMetric(link.source_tq, link.source_tp, link.target_tq, link.target_tp),
),
);

Expand Down
21 changes: 18 additions & 3 deletions lib/infobox/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ export function Node(el: HTMLElement, node: NodeData, linkScale: (t: any) => any
"a",
{
style: {
color: linkScale((connecting.link.source_tq + connecting.link.target_tq) / 2),
color: linkScale(
((helper.linkMetric(connecting.link.source_tq, connecting.link.source_tp) ?? 0) +
(helper.linkMetric(connecting.link.target_tq, connecting.link.target_tp) ?? 0)) /
2,
),
},
props: {
title: connecting.link.source.hostname + " - " + connecting.link.target.hostname,
Expand All @@ -130,7 +134,12 @@ export function Node(el: HTMLElement, node: NodeData, linkScale: (t: any) => any
},
},
},
helper.showTq(connecting.link.source_tq) + " - " + helper.showTq(connecting.link.target_tq),
helper.showBiDiLinkMetric(
connecting.link.source_tq,
connecting.link.source_tp,
connecting.link.target_tq,
connecting.link.target_tp,
),
),
]),
h("td", helper.showDistance(connecting.link)),
Expand Down Expand Up @@ -163,7 +172,13 @@ export function Node(el: HTMLElement, node: NodeData, linkScale: (t: any) => any
name: "node.tq",
class: "ion-connection-bars",
sort: function (a: Neighbour, b: Neighbour) {
return a.link.source_tq - b.link.source_tq;
let am = helper.linkMetric(a.link.source_tq, a.link.source_tp);
let an = helper.linkMetric(a.link.target_tq, a.link.target_tp);
let bm = helper.linkMetric(b.link.source_tq, b.link.source_tp);
let bn = helper.linkMetric(b.link.target_tq, b.link.target_tp);
let aAvg = am === undefined && an === undefined ? -Infinity : ((am ?? 0) + (an ?? 0)) / 2;
let bAvg = bm === undefined && bn === undefined ? -Infinity : ((bm ?? 0) + (bn ?? 0)) / 2;
return aAvg - bAvg;
},
reverse: true,
},
Expand Down
Loading
Loading