Skip to content

Commit 65b75a6

Browse files
committed
adding survey with continuous switch
1 parent ccbd0c1 commit 65b75a6

File tree

7 files changed

+146
-102
lines changed

7 files changed

+146
-102
lines changed

webapp/lib/traceroutecont.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func GetTracerouteByTimeHandler(w http.ResponseWriter, r *http.Request, active b
144144
returnError(w, err)
145145
return
146146
}
147-
// log.Debug("Requested data:", "tracerouteResults", tracerouteResults)
147+
log.Debug("Requested data:", "tracerouteResults", tracerouteResults)
148148

149149
tracerouteJSON, err := json.Marshal(tracerouteResults)
150150
if CheckError(err) {
@@ -156,7 +156,6 @@ func GetTracerouteByTimeHandler(w http.ResponseWriter, r *http.Request, active b
156156
jsonBuf = append(jsonBuf, json...)
157157
jsonBuf = append(jsonBuf, []byte(`}`)...)
158158

159-
//log.Debug(string(jsonBuf))
160159
// ensure % if any, is escaped correctly before writing to printf formatter
161160
fmt.Fprintf(w, strings.Replace(string(jsonBuf), "%", "%%", -1))
162161
}

webapp/tests/asviz/traceroute-d.json

Lines changed: 30 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,53 @@
11
{
22
"graph": [
33
{
4-
"Inserted": 1562179946689,
5-
"ActualDuration": 50,
4+
"Inserted": 1570192000394,
5+
"ActualDuration": 35,
66
"TrHops": [
77
{
88
"HopIa": "1-ff00:0:111",
9-
"HopAddr": "127.0.0.74",
10-
"IntfID": 103,
11-
"RespTime1": 0.896,
12-
"RespTime2": 1.482,
13-
"RespTime3": 1.915
9+
"HopAddr": "127.0.0.17",
10+
"IntfID": 41,
11+
"RespTime1": 0.558,
12+
"RespTime2": 0.439,
13+
"RespTime3": 0.41
1414
},
1515
{
16-
"HopIa": "1-ff00:0:112",
17-
"HopAddr": "127.0.0.82",
18-
"IntfID": 4094,
19-
"RespTime1": 1.39,
20-
"RespTime2": 0.772,
21-
"RespTime3": 0.856
16+
"HopIa": "1-ff00:0:110",
17+
"HopAddr": "127.0.0.9",
18+
"IntfID": 1,
19+
"RespTime1": 0.577,
20+
"RespTime2": 0.597,
21+
"RespTime3": 0.601
2222
},
2323
{
24-
"HopIa": "1-ff00:0:112",
25-
"HopAddr": "127.0.0.2",
26-
"IntfID": -1,
27-
"RespTime1": 1.057,
28-
"RespTime2": 0.85,
29-
"RespTime3": 0.866
30-
}
31-
],
32-
"CmdOutput": "Using path:\n Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450\n0 1-ff00:0:111,[127.0.0.74] IfID=103 896µs 1.482ms 1.915ms\n1 1-ff00:0:112,[127.0.0.82] IfID=4094 1.39ms 772µs 856µs\n2 1-ff00:0:112,[127.0.0.2] 1.057ms 850µs 866µs\n",
33-
"Path": "Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450",
34-
"Error": ""
35-
},
36-
{
37-
"Inserted": 1562179946298,
38-
"ActualDuration": 73,
39-
"TrHops": [
40-
{
41-
"HopIa": "1-ff00:0:111",
42-
"HopAddr": "127.0.0.74",
43-
"IntfID": 103,
44-
"RespTime1": 1.189,
45-
"RespTime2": 0.847,
46-
"RespTime3": 0.707
24+
"HopIa": "1-ff00:0:110",
25+
"HopAddr": "127.0.0.10",
26+
"IntfID": 2,
27+
"RespTime1": 0.797,
28+
"RespTime2": 0.666,
29+
"RespTime3": 0.771
4730
},
4831
{
4932
"HopIa": "1-ff00:0:112",
50-
"HopAddr": "127.0.0.82",
51-
"IntfID": 4094,
52-
"RespTime1": 5.503,
53-
"RespTime2": 1.127,
54-
"RespTime3": 1.486
33+
"HopAddr": "127.0.0.25",
34+
"IntfID": 1,
35+
"RespTime1": 1.18,
36+
"RespTime2": 1.922,
37+
"RespTime3": 1.322
5538
},
5639
{
5740
"HopIa": "1-ff00:0:112",
5841
"HopAddr": "127.0.0.2",
5942
"IntfID": -1,
60-
"RespTime1": 1.051,
61-
"RespTime2": 1.331,
62-
"RespTime3": 3.499
43+
"RespTime1": 1.107,
44+
"RespTime2": 0.899,
45+
"RespTime3": 0.835
6346
}
6447
],
65-
"CmdOutput": "Using path:\n Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450\n0 1-ff00:0:111,[127.0.0.74] IfID=103 1.189ms 847µs 707µs\n1 1-ff00:0:112,[127.0.0.82] IfID=4094 5.503ms 1.127ms 1.486ms\n2 1-ff00:0:112,[127.0.0.2] 1.051ms 1.331ms 3.499ms\n",
66-
"Path": "Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450",
67-
"Error": ""
48+
"CmdOutput": "Available paths to 1-ff00:0:112\n[ 0] Hops: [1-ff00:0:111 41>1 1-ff00:0:110 2>1 1-ff00:0:112] Mtu: 1280\nChoose path: Using path:\n Hops: [1-ff00:0:111 41>1 1-ff00:0:110 2>1 1-ff00:0:112] Mtu: 1280\n0 1-ff00:0:111,[127.0.0.17] IfID=41 558µs 439µs 410µs\n1 1-ff00:0:110,[127.0.0.9] IfID=1 577µs 597µs 601µs\n2 1-ff00:0:110,[127.0.0.10] IfID=2 797µs 666µs 771µs\n3 1-ff00:0:112,[127.0.0.25] IfID=1 1.18ms 1.922ms 1.322ms\n4 1-ff00:0:112,[127.0.0.2] 1.107ms 899µs 835µs\n",
49+
"Error": "",
50+
"Path": "Hops: [1-ff00:0:111 41>1 1-ff00:0:110 2>1 1-ff00:0:112] Mtu: 1280"
6851
}
6952
],
7053
"active": false

webapp/web/static/js/asviz.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ function setPaths(type, idx, open) {
6868
} else if (type == 'UP') {
6969
addSegments(resUp, idx, num, colorSegUp, type);
7070
} else if (type == 'PATH') {
71-
var latencies = getPathLatencyAvg(formatPathString(resPath, idx, type));
71+
var latencies = getPathLatencyAvg(formatPathString(resPath, idx,
72+
type));
7273
addPaths(resPath, idx, num, colorPaths, type, latencies);
7374
}
7475
self.segType = type;
@@ -109,6 +110,20 @@ function formatPathString(res, idx, type) {
109110
return path;
110111
}
111112

113+
function formatPathStringAll(res, type) {
114+
var paths = "";
115+
for (var i = 0; i < res.if_lists.length; i++) {
116+
var path = formatPathString(res, i, type);
117+
if (path != "") {
118+
if (i > 0) {
119+
paths += ",";
120+
}
121+
paths += formatPathString(res, i, type);
122+
}
123+
}
124+
return paths;
125+
}
126+
112127
/*
113128
* Adds D3 forwarding path links with arrows and a title to paths graph.
114129
*/

webapp/web/static/js/tab-paths.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ function setEchoLatency(hops, latency) {
100100
path = jPathsAvailable[hops];
101101
}
102102
path.latency = updateStats(latency, path.latency);
103-
var latStr = parseFloat(path.latency.Last).toFixed(1);
104-
$('#path-lat-' + path.listIdx).html(latStr);
105103
jPathsAvailable[hops] = path;
104+
return path;
106105
}
107106

108107
function setTracerouteLatency(hops, interfaces) {
@@ -120,17 +119,14 @@ function setTracerouteLatency(hops, interfaces) {
120119
path.interfaces[i].latency);
121120
path.interfaces[i].latency = updateStats(if_.RespTime3,
122121
path.interfaces[i].latency);
123-
var latStr = parseFloat(path.interfaces[i].latency.Last).toFixed(1);
124-
$('#path-lat-' + path.listIdx + '-' + i).html(latStr);
125122
} else {
126123
path.latency = updateStats(if_.RespTime1, path.latency);
127124
path.latency = updateStats(if_.RespTime2, path.latency);
128125
path.latency = updateStats(if_.RespTime3, path.latency);
129-
var latStr = parseFloat(path.latency.Last).toFixed(1);
130-
$('#path-lat-' + path.listIdx).html(latStr);
131126
}
132127
}
133128
jPathsAvailable[hops] = path;
129+
return path;
134130
}
135131

136132
function isConfigComplete(data, textStatus, jqXHR) {
@@ -775,6 +771,9 @@ function addAvailablePaths(paths) {
775771
Object.keys(jPathsAvailable).forEach(function(key) {
776772
jPathsAvailable[key].listIdx = undefined; // reset
777773
});
774+
if (!paths) {
775+
return;
776+
}
778777
for (var idx = 0; idx < paths.length; idx++) {
779778
var hops = formatPathJson(paths, idx, 'PATH');
780779
if (!jPathsAvailable[hops]) {
@@ -793,7 +792,9 @@ function addAvailablePaths(paths) {
793792
}
794793
path.expTime = paths[idx].Entry.Path.ExpTime;
795794
path.mtu = paths[idx].Entry.Path.Mtu;
796-
path.color = path_colors(pathLen - 1);
795+
if (!path.color) {
796+
path.color = path_colors(pathLen - 1);
797+
}
797798
path.listIdx = idx;
798799
jPathsAvailable[hops] = path;
799800
}

webapp/web/static/js/tab-topocola.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ function update() {
333333
"middle").style("font-size", "12px").style("fill", "purple").attr(
334334
"class", function(d) {
335335
return "latency " + d.type;
336-
}).text(function(d) {
336+
}).attr("id", function(d) {
337+
return d.id;
338+
}).text(function(d) {
337339
return d.latency ? parseFloat(d.latency).toFixed(1) : '';
338340
});
339341
markerText.exit().remove();
@@ -609,7 +611,7 @@ function addFixedLabel(label, x, y, lastLabel) {
609611
/*
610612
* Post-rendering method to draw path arcs for the given path and color.
611613
*/
612-
function drawPath(res, path, color, latencies) {
614+
function drawPath(res, path, color, lats) {
613615
// get the index of the routes to render
614616
var routes = [];
615617
if (path < 0) {
@@ -642,25 +644,44 @@ function drawPath(res, path, color, latencies) {
642644
graphPath.links = graphPath.links.filter(function(link) {
643645
return !link.path;
644646
});
647+
var fullLat = fullPathLatencies(lats);
645648
for (var i = 0; i < path_ids.length - 1; i++) {
646649
// prevent src == dst links from being formed
647650
if (path_ids[i] != path_ids[i + 1]) {
648-
console.warn(latencies)
649-
var latInterIntra = latencies ? (latencies[(i * 2) + 1] + latencies[(i * 2) + 2])
650-
: undefined;
651+
var linkLat = undefined;
652+
if (fullLat) {
653+
// report latency from target AS
654+
linkLat = lats ? (lats[i + 2]) : undefined;
655+
}
651656
graphPath.links.push({
652657
"color" : color,
653658
"path" : true,
654659
"source" : graphPath["ids"][path_ids[i]],
655660
"target" : graphPath["ids"][path_ids[i + 1]],
656661
"type" : "PARENT",
657-
"latency" : latInterIntra,
662+
"latency" : linkLat,
663+
"id" : "path-lat-" + path + "-" + i, // TODO
658664
});
659665
}
660666
}
661667
update();
662668
}
663669

670+
/**
671+
* Interrogate latencies for missing values.
672+
*/
673+
function fullPathLatencies(lats) {
674+
if (!lats) {
675+
return false;
676+
}
677+
for (var i = 0; i < lats.length; i++) {
678+
if (!lats[i]) {
679+
return false;
680+
}
681+
}
682+
return true;
683+
}
684+
664685
/*
665686
* Removes all path arcs from the graph.
666687
*/

webapp/web/static/js/webapp.js

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,15 @@ function requestEchoByTime(form_data) {
483483
var time = d.graph[i].Inserted - d.graph[i].ActualDuration;
484484
updatePingGraph(chartSE, data, time)
485485

486-
// update latency stats, when valid
486+
// update latency stats, when valid, use average
487487
if (d.graph[i].ResponseTime > 0) {
488-
setEchoLatency(d.graph[i].Path.match("\\[.*]"),
489-
d.graph[i].ResponseTime);
488+
var path = setEchoLatency(d.graph[i].Path
489+
.match("\\[.*]"), d.graph[i].ResponseTime);
490+
if (path.latency) {
491+
var latStr = parseFloat(path.latency.Avg)
492+
.toFixed(1);
493+
$('#path-lat-' + path.listIdx).html(latStr);
494+
}
490495
}
491496
}
492497
}
@@ -507,7 +512,11 @@ function requestTraceRouteByTime(form_data) {
507512
} else {
508513
enableTestControls(true);
509514
releaseTabs();
510-
clearInterval(intervalGraphData);
515+
if (d.graph != null) {
516+
clearInterval(intervalGraphData);
517+
} else {
518+
lastTimeBwDb = form_data.since;
519+
}
511520
}
512521
}
513522
if (d.graph != null) {
@@ -518,29 +527,35 @@ function requestTraceRouteByTime(form_data) {
518527
// result returned, display it and reset progress
519528
handleEndCmdDisplay(d.graph[i].CmdOutput);
520529
}
521-
// var data = {
522-
// 'responseTime' : d.graph[i].ResponseTime,
523-
// 'runTime' : d.graph[i].RunTime,
524-
// 'loss' : d.graph[i].PktLoss,
525-
// 'path' : d.graph[i].Path,
526-
// 'error' : d.graph[i].Error,
527-
// };
528-
// if (data.runTime == 0) {
529-
// // for other errors, use execution time
530-
// data.runTime = d.graph[i].ActualDuration;
531-
// }
532-
// console.info(JSON.stringify(data));
530+
533531
console.info('continuous traceroute', 'duration:',
534532
d.graph[i].ActualDuration, 'ms');
535533
// use the time the test began
536534
var time = d.graph[i].Inserted - d.graph[i].ActualDuration;
537-
// updatePingGraph(chartSE, data, time)
538535

539536
// TODO (mwfarb): implement traceroute graph
540537

541-
// update latency stats
542-
setTracerouteLatency(d.graph[i].Path.match("\\[.*]"),
543-
d.graph[i].TrHops);
538+
// update latency stats, when valid, use average
539+
var path = setTracerouteLatency(d.graph[i].Path
540+
.match("\\[.*]"), d.graph[i].TrHops);
541+
for (var i = 0; i < path.interfaces.length; i++) {
542+
var if_ = path.interfaces[i];
543+
if (i < path.interfaces.length - 1) {
544+
if (path.interfaces[i].latency) {
545+
var latStr = parseFloat(
546+
path.interfaces[i].latency.Avg)
547+
.toFixed(1);
548+
$('#path-lat-' + path.listIdx + '-' + i).html(
549+
latStr);
550+
}
551+
} else {
552+
if (path.latency) {
553+
var latStr = parseFloat(path.latency.Avg)
554+
.toFixed(1);
555+
$('#path-lat-' + path.listIdx).html(latStr);
556+
}
557+
}
558+
}
544559
}
545560
}
546561
}
@@ -683,6 +698,11 @@ function command(continuous) {
683698
name : "pathStr",
684699
value : formatPathString(resPath, self.segNum, self.segType)
685700
});
701+
} else if (continuous) { // all paths in survey
702+
form_data.push({
703+
name : "pathStr",
704+
value : formatPathStringAll(resPath, 'PATH')
705+
});
686706
}
687707
}
688708
if (activeApp == "bwtester") {
@@ -827,7 +847,7 @@ function handleContResponse(resp, continuous, startTime) {
827847
clearInterval(intervalGraphData);
828848
}
829849
if (!continuous) {
830-
manageTestData();
850+
manageTestData(startTime);
831851
}
832852
}
833853

0 commit comments

Comments
 (0)