Skip to content

Commit 2c5aafc

Browse files
author
Saied Kazemi
authored
Use the shx package instead of the pipe package (#107)
* Use the shx package instead of the pipe package The pipe package (gopkg.in/m-lab/pipe.v3) doesn't work as expected because not only it doesn't support contexts its RunTimeout() method does not correctly timeout. As a result, the latency numbers cannot be trusted. This commit replaces the pipe package with the shx package in the ScamperDaemon.trace(). Once we have validated the new code works as expected, the Scamper.trace() will also use the shx package. Because there are multiple traces being performed in parallel, the new code improves log messages by including the context identifier so individual contexts can be easily identified. Tested the changes locally using docker-compose. * Change the exepcted error message in scamper_test.go * Remove unnecessary variable declaration * Remove the remaining references to the pipe package This commit removes the remaining references to the pipe package and simplifies the code that uses the shx package. This commit also adds some flags to make it easier to configure scamper without having to edit code and rebuild traceroute-caller for different configurations. Specifically, "-O ptr" can be enabled/disabled and tracelb's "-W" flag can be specified. Run "./traceroute-caller -h" and/or see docker-compose.yaml for an example of running with values different than the defaults. The changes were tested locally with "go test ./..." and docker-compose. * Make changes suggested in code review
1 parent a247b63 commit 2c5aafc

File tree

7 files changed

+218
-62
lines changed

7 files changed

+218
-62
lines changed

caller.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ import (
4141
)
4242

4343
var (
44+
// TODO: scamper and its commands (e.g., tracelb) support a
45+
// relatively large number of flags. Instead of adding these
46+
// flags one by one to traceroute-caller flags, going forward
47+
// it's much better to have traceroute-caller read a configuration
48+
// file in textproto format that would support all scamper and
49+
// its command flags.
4450
scamperBin = flag.String("scamper.bin", "scamper", "The path to the scamper binary.")
4551
scattachBin = flag.String("scamper.sc_attach", "sc_attach", "The path to the sc_attach binary.")
4652
scwarts2jsonBin = flag.String("scamper.sc_warts2json", "sc_warts2json", "The path to the sc_warts2json binary.")
47-
scamperCtrlSocket = flag.String("scamper.unixsocket", "/tmp/scamperctrl", "The name of the UNIX-domain socket that the scamper daemon should listen on")
48-
scamperTimeout = flag.Duration("scamper.timeout", 900*time.Second, "how long to wait to complete a scamper trace.")
49-
outputPath = flag.String("outputPath", "/var/spool/scamper", "path of output")
50-
waitTime = flag.Duration("waitTime", 5*time.Second, "how long to wait between subsequent listings of open connections")
53+
scamperCtrlSocket = flag.String("scamper.unixsocket", "/tmp/scamperctrl", "The name of the UNIX-domain socket that the scamper daemon should listen on.")
54+
scamperTimeout = flag.Duration("scamper.timeout", 900*time.Second, "How long to wait to complete a scamper trace.")
55+
scamperPTR = flag.Bool("scamper.tracelb-ptr", true, "Look up DNS pointer records for IP addresses.")
56+
scamperWaitProbe = flag.Int("scamper.tracelb-W", 25, "How long to wait between probes in 1/100ths of seconds (min 15, max 200).")
57+
outputPath = flag.String("outputPath", "/var/spool/scamper", "The path of output.")
58+
waitTime = flag.Duration("waitTime", 5*time.Second, "How long to wait between subsequent listings of open connections.")
5159
poll = flag.Bool("poll", true, "Whether the polling method should be used to see new connections.")
5260
tracerType = flagx.Enum{
5361
Options: []string{"scamper", "scamper-daemon", "scamper-daemon-with-scamper-backup"},
@@ -77,9 +85,11 @@ func main() {
7785
defer promSrv.Shutdown(ctx)
7886

7987
scamper := &tracer.Scamper{
80-
Binary: *scamperBin,
81-
OutputPath: *outputPath,
82-
ScamperTimeout: *scamperTimeout,
88+
Binary: *scamperBin,
89+
OutputPath: *outputPath,
90+
ScamperTimeout: *scamperTimeout,
91+
TracelbPTR: *scamperPTR,
92+
TracelbWaitProbe: *scamperWaitProbe,
8393
}
8494
scamperDaemon := &tracer.ScamperDaemon{
8595
Scamper: scamper,

docker-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ services:
6464
- -poll=false
6565
- -tcpinfo.eventsocket=/local/tcpevents.sock
6666
- -tracetool=scamper-daemon
67+
- -scamper.timeout=3600s
68+
- -scamper.tracelb-ptr=false
69+
- -scamper.tracelb-W=30
70+
- -IPCacheTimeout=600s
71+
- -IPCacheUpdatePeriod=60s

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ module github.com/m-lab/traceroute-caller
33
go 1.16
44

55
require (
6-
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 // indirect
76
github.com/go-test/deep v1.0.7
87
github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d // indirect
98
github.com/kr/pretty v0.2.0
10-
github.com/kr/text v0.2.0 // indirect
11-
github.com/m-lab/go v1.4.0
9+
github.com/m-lab/go v0.1.45
1210
github.com/m-lab/tcp-info v1.5.3
1311
github.com/m-lab/uuid v0.0.0-20191115203855-549727171666
1412
github.com/prometheus/client_golang v1.10.0

0 commit comments

Comments
 (0)