Reduced sample size
parent
8b115eec15
commit
c1824e6297
11
country.go
11
country.go
|
@ -9,6 +9,7 @@ import (
|
|||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type geoRange struct {
|
||||
|
@ -99,6 +100,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: verify correctness
|
||||
log.Println("Grouping latencies by country")
|
||||
odata := make(map[string][]int, 0)
|
||||
j := 0
|
||||
|
@ -113,8 +115,17 @@ func main() {
|
|||
}
|
||||
cc := geo[j].CC
|
||||
|
||||
if rand.Intn(100) == 0 {
|
||||
odata[cc] = append(odata[cc], ttl)
|
||||
}
|
||||
}
|
||||
|
||||
total := 0
|
||||
for k, v := range odata {
|
||||
log.Println("Country " + k + " has " + strconv.Itoa(len(v)) + " samples")
|
||||
total += len(v)
|
||||
}
|
||||
log.Println("Total: " + strconv.Itoa(total))
|
||||
|
||||
log.Println("Encoding json")
|
||||
raw, err := json.Marshal(odata)
|
||||
|
|
13
latency.go
13
latency.go
|
@ -24,11 +24,6 @@ type portInfo struct {
|
|||
TTL int `json:"ttl"`
|
||||
}
|
||||
|
||||
type hostLatency struct {
|
||||
IP uint32 `json:"ip"`
|
||||
TTL int `json:"ttl"`
|
||||
}
|
||||
|
||||
var flagIn = flag.String("in", "", "comma-seperated list of input files")
|
||||
var flagOut = flag.String("out", "latency.json", "output file")
|
||||
|
||||
|
@ -62,14 +57,10 @@ func main() {
|
|||
}
|
||||
|
||||
log.Println("Reducing data to IP and latency")
|
||||
odata := make([]hostLatency, 0)
|
||||
odata := make(map[uint32]int, 0)
|
||||
for _, o := range data {
|
||||
ip := binary.BigEndian.Uint32(net.ParseIP(o.IP)[12:])
|
||||
h := hostLatency{
|
||||
IP: ip,
|
||||
TTL: o.Ports[0].TTL,
|
||||
}
|
||||
odata = append(odata, h)
|
||||
odata[ip] = o.Ports[0].TTL
|
||||
}
|
||||
|
||||
log.Println("Encoding json")
|
||||
|
|
Loading…
Reference in New Issue