Skip to content

Commit 970dc23

Browse files
authored
Merge pull request #203 from m-lab/pt-crash
Data verification for PT parser
2 parents 97975e0 + 49c9f38 commit 970dc23

File tree

3 files changed

+59
-56
lines changed

3 files changed

+59
-56
lines changed

parser/pt.go

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ type PTParser struct {
3535
}
3636

3737
type Node struct {
38-
hostname string
39-
ip string
40-
rtts []float64
41-
parent *Node
38+
hostname string
39+
ip string
40+
rtts []float64
41+
parent_ip string
42+
parent_hostname string
4243

4344
// For a given hop in a paris traceroute, there may be multiple IP
4445
// addresses. Each one belongs to a flow, which is an independent path from
@@ -64,9 +65,8 @@ func ProcessAllNodes(all_nodes []Node, server_IP, protocol string, tableName str
6465

6566
// Iterate from the end of the list of nodes to minimize cost of removing nodes.
6667
for i := len(all_nodes) - 1; i >= 0; i-- {
67-
parent := all_nodes[i].parent
6868
metrics.PTHopCount.WithLabelValues(tableName, "pt", "ok")
69-
if parent == nil {
69+
if all_nodes[i].parent_ip == "" {
7070
one_hop := &schema.ParisTracerouteHop{
7171
Protocol: protocol,
7272
Dest_ip: all_nodes[i].ip,
@@ -84,8 +84,8 @@ func ProcessAllNodes(all_nodes []Node, server_IP, protocol string, tableName str
8484
Dest_ip: all_nodes[i].ip,
8585
Dest_hostname: all_nodes[i].hostname,
8686
Rtt: all_nodes[i].rtts,
87-
Src_ip: parent.ip,
88-
Src_hostname: parent.hostname,
87+
Src_ip: all_nodes[i].parent_ip,
88+
Src_hostname: all_nodes[i].parent_hostname,
8989
Src_af: IPv4_AF,
9090
Dest_af: IPv4_AF,
9191
}
@@ -279,12 +279,13 @@ func ProcessOneTuple(parts []string, protocol string, current_leaves []Node, all
279279
// Check whether it is root node.
280280
if len(*all_nodes) == 0 {
281281
one_node := &Node{
282-
hostname: parts[0],
283-
ip: ips[0][1 : len(ips[0])-1],
284-
rtts: rtt,
285-
parent: nil,
286-
flow: -1,
282+
hostname: parts[0],
283+
ip: ips[0][1 : len(ips[0])-1],
284+
rtts: rtt,
285+
parent_ip: "",
286+
flow: -1,
287287
}
288+
288289
*all_nodes = append(*all_nodes, *one_node)
289290
*new_leaves = append(*new_leaves, *one_node)
290291
return nil
@@ -296,11 +297,12 @@ func ProcessOneTuple(parts []string, protocol string, current_leaves []Node, all
296297
// For single flow, the new node will be son of all current leaves
297298
for _, leaf := range current_leaves {
298299
one_node := &Node{
299-
hostname: parts[0],
300-
ip: ips[0][1 : len(ips[0])-1],
301-
rtts: rtt,
302-
parent: &leaf,
303-
flow: -1,
300+
hostname: parts[0],
301+
ip: ips[0][1 : len(ips[0])-1],
302+
rtts: rtt,
303+
parent_ip: leaf.ip,
304+
parent_hostname: leaf.hostname,
305+
flow: -1,
304306
}
305307
*all_nodes = append(*all_nodes, *one_node)
306308
if Unique(*one_node, *new_leaves) {
@@ -318,12 +320,14 @@ func ProcessOneTuple(parts []string, protocol string, current_leaves []Node, all
318320

319321
for _, leaf := range current_leaves {
320322
if leaf.flow == -1 || leaf.flow == flow_int {
323+
321324
one_node := &Node{
322-
hostname: parts[0],
323-
ip: ips[0][1 : len(ips[0])-1],
324-
rtts: rtt,
325-
parent: &leaf,
326-
flow: flow_int,
325+
hostname: parts[0],
326+
ip: ips[0][1 : len(ips[0])-1],
327+
rtts: rtt,
328+
parent_ip: leaf.ip,
329+
parent_hostname: leaf.hostname,
330+
flow: flow_int,
327331
}
328332
*all_nodes = append(*all_nodes, *one_node)
329333
if Unique(*one_node, *new_leaves) {
@@ -389,7 +393,7 @@ func Parse(meta map[string]bigquery.Value, testName string, rawContent []byte, t
389393
// TODO(dev): use regexp here
390394
parts := strings.Fields(oneLine)
391395
// Skip line start with "MPLS"
392-
if len(parts) < 3 || parts[0] == "MPLS" {
396+
if len(parts) < 4 || parts[0] == "MPLS" {
393397
continue
394398
}
395399

parser/pt_test.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestParseLegacyFormatData(t *testing.T) {
4343
if err != nil {
4444
t.Fatalf(err.Error())
4545
}
46-
if len(hops) != 545 {
46+
if len(hops) != 9 {
4747
t.Fatalf("Do not process hops correctly.")
4848
}
4949
if logTime != 1452559544 {
@@ -80,24 +80,24 @@ func TestPTParser(t *testing.T) {
8080
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
8181
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
8282
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
83-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
84-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
85-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
86-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
87-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
88-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
89-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.232.136", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae7.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
83+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
84+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
85+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
86+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
87+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
88+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
89+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "216.239.49.250", Src_af: 2, Dest_ip: "64.233.174.109", Dest_af: 2, Src_hostname: "bb01-ae3.nuq04.net.google.com", Dest_hostname: "sr05-te1-8.nuq04.net.google.com", Rtt: []float64{1.614}},
9090
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "72.14.232.136", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae7.nuq04.net.google.com", Rtt: []float64{1.693}},
9191
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "72.14.232.136", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae7.nuq04.net.google.com", Rtt: []float64{1.693}},
9292
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "72.14.232.136", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae7.nuq04.net.google.com", Rtt: []float64{1.693}},
9393
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "72.14.232.136", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae7.nuq04.net.google.com", Rtt: []float64{1.693}},
94-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
95-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
96-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
97-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
98-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
99-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
100-
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.196.8", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
94+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
95+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
96+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
97+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
98+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
99+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
100+
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "72.14.218.190", Src_af: 2, Dest_ip: "216.239.49.250", Dest_af: 2, Src_hostname: "pr01-xe-7-1-0.pao03.net.google.com", Dest_hostname: "bb01-ae3.nuq04.net.google.com", Rtt: []float64{1.386}},
101101
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "172.25.253.46", Src_af: 2, Dest_ip: "72.14.196.8", Dest_af: 2, Src_hostname: "us-mtv-ply1-br1-xe-1-1-0-706.n.corp.google.com", Dest_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Rtt: []float64{0.556}},
102102
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "172.25.253.46", Src_af: 2, Dest_ip: "72.14.196.8", Dest_af: 2, Src_hostname: "us-mtv-ply1-br1-xe-1-1-0-706.n.corp.google.com", Dest_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Rtt: []float64{0.556}},
103103
schema.ParisTracerouteHop{Protocol: "tcp", Src_ip: "172.25.253.46", Src_af: 2, Dest_ip: "72.14.196.8", Dest_af: 2, Src_hostname: "us-mtv-ply1-br1-xe-1-1-0-706.n.corp.google.com", Dest_hostname: "pr02-xe-3-0-1.pao03.net.google.com", Rtt: []float64{0.556}},
@@ -117,8 +117,10 @@ func TestPTParser(t *testing.T) {
117117
if len(hops) != len(expected_hops) {
118118
t.Fatalf("Wrong results for PT hops!")
119119
}
120+
120121
for i := 0; i < len(hops); i++ {
121122
if !reflect.DeepEqual(hops[i], expected_hops[i]) {
123+
fmt.Println(i)
122124
fmt.Printf("Here is expected : %v\n", expected_hops[i])
123125
fmt.Printf("Here is what is real: %v\n", hops[i])
124126
t.Fatalf("Wrong results for PT hops!")

0 commit comments

Comments
 (0)