Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 0 additions & 2 deletions webapp/lib/echocont.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ func ExtractEchoRespData(resp string, d *model.EchoItem, start time.Time) {
// store current epoch in ms
d.Inserted = time.Now().UnixNano() / 1e6

log.Info("resp response", "content", resp)

var data = make(map[string]float32)
// -1 if no match for response time, indicating response timeout or packets out of order
data["response_time"] = -1
Expand Down
1 change: 1 addition & 0 deletions webapp/lib/sciond.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var cNodes string
var cGeoLoc string

func returnError(w http.ResponseWriter, err error) {
log.Error("Error:", "err", err)
fmt.Fprintf(w, `{"err":`+strconv.Quote(err.Error())+`}`)
}

Expand Down
5 changes: 1 addition & 4 deletions webapp/lib/traceroutecont.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ func ExtractTracerouteRespData(resp string, d *model.TracerouteItem, start time.
// store current epoch in ms
d.Inserted = time.Now().UnixNano() / 1e6

//log.Info("resp response", "content", resp)

var path, err string
pathNext := false
r := strings.Split(resp, "\n")
Expand Down Expand Up @@ -144,7 +142,7 @@ func GetTracerouteByTimeHandler(w http.ResponseWriter, r *http.Request, active b
returnError(w, err)
return
}
// log.Debug("Requested data:", "tracerouteResults", tracerouteResults)
log.Debug("Requested data:", "tracerouteResults", tracerouteResults)

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

//log.Debug(string(jsonBuf))
// ensure % if any, is escaped correctly before writing to printf formatter
fmt.Fprintf(w, strings.Replace(string(jsonBuf), "%", "%%", -1))
}
160 changes: 79 additions & 81 deletions webapp/models/traceroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ func createTracerouteTable() error {
CAddr TEXT,
SIa TEXT,
SAddr TEXT,
Timeout REAL,
CmdOutput TEXT,
Error TEXT,
Path TEXT
Timeout REAL,
CmdOutput TEXT,
Error TEXT,
Path TEXT
);
`
_, err := db.Exec(sqlCreateTable)
Expand All @@ -153,13 +153,13 @@ func createTrHopTable() error {
CREATE TABLE IF NOT EXISTS trhops(
Inserted BIGINT NOT NULL PRIMARY KEY,
RunTimeKey BIGINT,
Ord INT,
HopIa TEXT,
HopAddr TEXT,
Ord INT,
HopIa TEXT,
HopAddr TEXT,
IntfID INT,
RespTime1 REAL,
RespTime2 REAL,
RespTime3 REAL
RespTime1 REAL,
RespTime2 REAL,
RespTime3 REAL
);
`
_, err := db.Exec(sqlCreateTable)
Expand All @@ -170,16 +170,16 @@ func createTrHopTable() error {
func StoreTracerouteItem(tr *TracerouteItem) error {
sqlInsert := `
INSERT INTO traceroute(
Inserted,
Inserted,
ActualDuration,
CIa,
CAddr,
SIa,
SAddr,
Timeout,
CmdOutput,
Error,
Path
Timeout,
CmdOutput,
Error,
Path
) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`
stmt, err := db.Prepare(sqlInsert)
Expand All @@ -206,15 +206,15 @@ func StoreTracerouteItem(tr *TracerouteItem) error {
func StoreTrHopItem(hop *TrHopItem) error {
sqlInsert := `
INSERT INTO trhops(
Inserted,
Inserted,
RunTimeKey,
Ord,
HopIa,
HopAddr,
HopIa,
HopAddr,
IntfID,
RespTime1,
RespTime2,
RespTime3
RespTime1,
RespTime2,
RespTime3
) values(?, ?, ?, ?, ?, ?, ?, ?, ?)
`
stmt, err := db.Prepare(sqlInsert)
Expand All @@ -239,18 +239,18 @@ func StoreTrHopItem(hop *TrHopItem) error {
// ReadTracerouteItemsAll operates on the DB to return all traceroute rows.
func ReadTracerouteItemsAll() ([]TracerouteItem, error) {
sqlReadAll := `
SELECT
Inserted,
ActualDuration,
CIa,
CAddr,
SIa,
SAddr,
Timeout,
CmdOutput,
Error,
Path
FROM traceroute
SELECT
Inserted,
ActualDuration,
CIa,
CAddr,
SIa,
SAddr,
Timeout,
CmdOutput,
Error,
Path
FROM traceroute
ORDER BY datetime(Inserted) DESC
`
rows, err := db.Query(sqlReadAll)
Expand Down Expand Up @@ -285,36 +285,36 @@ func ReadTracerouteItemsAll() ([]TracerouteItem, error) {
// which are more recent than the 'since' epoch in ms.
func ReadTracerouteItemsSince(since string) ([]TracerouteGraph, error) {
sqlReadSince := `
SELECT
a.Inserted,
a.ActualDuration,
h.Ord,
h.HopIa,
h.HopAddr,
h.IntfID,
h.RespTime1,
h.RespTime2,
h.RespTime3,
a.CmdOutput,
a.Error,
a.Path
FROM (
SELECT
Inserted,
ActualDuration,
CIa,
CAddr,
SIa,
SAddr,
Timeout,
CmdOutput,
Error,
Path
FROM traceroute
WHERE Inserted > ?
) AS a
INNER JOIN trhops AS h ON a.Inserted = h.RunTimeKey
ORDER BY datetime(a.Inserted) DESC
SELECT
a.Inserted,
a.ActualDuration,
h.Ord,
h.HopIa,
h.HopAddr,
h.IntfID,
h.RespTime1,
h.RespTime2,
h.RespTime3,
a.CmdOutput,
a.Error,
a.Path
FROM (
SELECT
Inserted,
ActualDuration,
CIa,
CAddr,
SIa,
SAddr,
Timeout,
CmdOutput,
Error,
Path
FROM traceroute
WHERE Inserted > ?
) AS a
INNER JOIN trhops AS h ON a.Inserted = h.RunTimeKey
ORDER BY datetime(a.Inserted) DESC
`
rows, err := db.Query(sqlReadSince, since)
if err != nil {
Expand Down Expand Up @@ -345,31 +345,15 @@ func ReadTracerouteItemsSince(since string) ([]TracerouteGraph, error) {
}

var graphEntries []TracerouteGraph
var lastEntryInsertedTime int64

// Store the infos of the last hop
var inserted int64
var actualDuration int
var trhops []ReducedTrHopItem
var cmdOutput, path, errors string

for _, hop := range result {
if lastEntryInsertedTime == 0 {
lastEntryInsertedTime = hop.Inserted
trhops = nil
} else if lastEntryInsertedTime != hop.Inserted {
trg := TracerouteGraph{
Inserted: inserted,
ActualDuration: actualDuration,
TrHops: trhops,
CmdOutput: cmdOutput,
Error: errors,
Path: path}

lastEntryInsertedTime = hop.Inserted
graphEntries = append(graphEntries, trg)
trhops = nil
}
for i := 0; i < len(result); i++ {
hop := result[i]

inserted = hop.Inserted
actualDuration = hop.ActualDuration
Expand All @@ -384,6 +368,20 @@ func ReadTracerouteItemsSince(since string) ([]TracerouteGraph, error) {
RespTime2: hop.RespTime2,
RespTime3: hop.RespTime3}
trhops = append(trhops, rth)

// append hops group at the end of each group
if (i+1) == len(result) || result[i+1].Inserted != hop.Inserted {
trg := TracerouteGraph{
Inserted: inserted,
ActualDuration: actualDuration,
TrHops: trhops,
CmdOutput: cmdOutput,
Error: errors,
Path: path}

graphEntries = append(graphEntries, trg)
trhops = nil
}
}

return graphEntries, nil
Expand Down
16 changes: 16 additions & 0 deletions webapp/tests/asviz/bwtester-d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"graph": [
{
"Inserted": 1562683731800,
"ActualDuration": 5041,
"CSBandwidth": 80000,
"CSThroughput": 80000,
"SCBandwidth": 80000,
"SCThroughput": 80000,
"Error": "",
"Path": "Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450",
"Log": "t=2019-07-09T10:48:46-0400 lvl=dbug msg=\"Path selection algorithm choice\" path=\"Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450\" score=0.993\nt=2019-07-09T10:48:46-0400 lvl=dbug msg=\"Registered with dispatcher\" addr=\"1-ff00:0:111,[127.0.0.1]:30001 (UDP)\"\nClient DC \tNext Hop [127.0.0.74]:31070\tServer Host [127.0.0.2]:30101\nt=2019-07-09T10:48:46-0400 lvl=dbug msg=\"Registered with dispatcher\" addr=\"1-ff00:0:111,[127.0.0.1]:30002 (UDP)\"\n\nTest parameters:\nclientDCAddr -> serverDCAddr 1-ff00:0:111,[127.0.0.1]:30002 (UDP) -> 1-ff00:0:112,[127.0.0.2]:30101 (UDP)\nclient->server: 3 seconds, 1000 bytes, 30 packets\nserver->client: 3 seconds, 1000 bytes, 30 packets\n\nS->C results\nAttempted bandwidth: 80000 bps / 0.08 Mbps\nAchieved bandwidth: 80000 bps / 0.08 Mbps\nLoss rate: 0 %\nInterarrival time variance: 23ms, average interarrival time: 103ms\nInterarrival time min: 82ms, interarrival time max: 127ms\nWe need to sleep for 2 seconds before we can get the results\n\nC->S results\nAttempted bandwidth: 80000 bps / 0.08 Mbps\nAchieved bandwidth: 80000 bps / 0.08 Mbps\nLoss rate: 0 %\nInterarrival time variance: 23ms, average interarrival time: 103ms\nInterarrival time min: 82ms, interarrival time max: 126ms\n"
}
],
"active": false
}
15 changes: 15 additions & 0 deletions webapp/tests/asviz/echo-d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"graph": [
{
"Inserted": 1562683883823,
"ActualDuration": 263,
"ResponseTime": 13.352,
"RunTime": 226.525,
"PktLoss": 0,
"CmdOutput": "Using path:\n Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450\n104 bytes from 1-ff00:0:112,[127.0.0.2] scmp_seq=0 time=13.352ms\n\n--- 1-ff00:0:112,[[127.0.0.2]] statistics ---\n1 packets transmitted, 1 received, 0% packet loss, time 226.525ms\n",
"Path": "Hops: [1-ff00:0:111 103>4094 1-ff00:0:112] Mtu: 1450",
"Error": ""
}
],
"active": false
}
54 changes: 54 additions & 0 deletions webapp/tests/asviz/traceroute-d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"graph": [
{
"Inserted": 1570192000394,
"ActualDuration": 35,
"TrHops": [
{
"HopIa": "1-ff00:0:111",
"HopAddr": "127.0.0.17",
"IntfID": 41,
"RespTime1": 0.558,
"RespTime2": 0.439,
"RespTime3": 0.41
},
{
"HopIa": "1-ff00:0:110",
"HopAddr": "127.0.0.9",
"IntfID": 1,
"RespTime1": 0.577,
"RespTime2": 0.597,
"RespTime3": 0.601
},
{
"HopIa": "1-ff00:0:110",
"HopAddr": "127.0.0.10",
"IntfID": 2,
"RespTime1": 0.797,
"RespTime2": 0.666,
"RespTime3": 0.771
},
{
"HopIa": "1-ff00:0:112",
"HopAddr": "127.0.0.25",
"IntfID": 1,
"RespTime1": 1.18,
"RespTime2": 1.922,
"RespTime3": 1.322
},
{
"HopIa": "1-ff00:0:112",
"HopAddr": "127.0.0.2",
"IntfID": -1,
"RespTime1": 1.107,
"RespTime2": 0.899,
"RespTime3": 0.835
}
],
"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",
"Error": "",
"Path": "Hops: [1-ff00:0:111 41>1 1-ff00:0:110 2>1 1-ff00:0:112] Mtu: 1280"
}
],
"active": false
}
10 changes: 10 additions & 0 deletions webapp/web/static/css/style-viz.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,21 @@ ul.tree li.open>ul {
ul.tree li a {
color: black;
text-decoration: none;
}

.path-text {
color: white;
padding-left: 5px; /* background shape */
padding-right: 5px; /* background shape */
border-radius: 10px; /* background shape */
}

.latency-text {
color: purple;
position: absolute;
right: 0;
}

ul.tree li a:before {
height: 1em;
padding: 0 .1em;
Expand Down
Loading