diff --git a/tcpdelay.go b/tcpdelay.go index 3087a37..aac63af 100644 --- a/tcpdelay.go +++ b/tcpdelay.go @@ -18,6 +18,7 @@ var ( client = app.Command("client", "Request measurement") serverAddress = client.Arg("address", "Address:port to connect to").String() + relativeTimes = client.Flag("relative", "Print times relative to start").Bool() ) func tcpdelayServer() { @@ -56,6 +57,7 @@ func tcpdelayServer() { } func tcpdelayClient() { + t0 := time.Now().UnixNano() conn, err := net.Dial("tcp", *serverAddress) if err != nil { log.Fatal("Cannot connect to ", *serverAddress, err) @@ -83,7 +85,11 @@ func tcpdelayClient() { log.Fatal("Unexpected offset ", oSent, " instead of ", o) } ts := binary.BigEndian.Uint64(buffer[16:]) - fmt.Println(o, ts, tr) // XXX - buffer for performance + if *relativeTimes { + fmt.Println(o, int64(ts)-t0, tr-t0) + } else { + fmt.Println(o, ts, tr) + } o += n }