tcplatency provides an easy way to measure network latency using TCP.
tcplatency was created out of necessity to perform network diagnostics and troubleshooting on serverless infrastructure (but it can also be used in any other environment). Normal pinging is often not possible because many cloud providers do not offer ICMP support. tcplatency solves this problem and allows latency diagnostics in environments where pinging is not possible.
- Runs as a command line tool or can be used as a library in other projects
- Custom parameters for a port, runs, timeout and wait time between runs
- IPv4 (e.g 192.168.178.22) and dns (e.g google.com) host support
- Small and extensible
You can find the latest releases here.
tcplatency
can be used both as a module and as a standalone script.
Download the latest release here. Or build from source using make build
(requires go 1.11+)
AME:
tcplatency - tcplatency measures network latencies using tcp pings
USAGE:
tcplatency [global options] command [command options] [arguments...]
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--host value the host address
--port value, -p value the host port (default: 443)
--timeout value, -t value timeout in seconds (default: 5)
--runs value, -r value number of latency points to return (default: 5)
--wait value, -w value seconds to wait between each run (default: 1)
--help, -h show help
--version, -v print the version
Example: $ tcplatency google.com
google.com via tcp seq=0 port=443 timeout=5 time=20.63 ms
google.com via tcp seq=1 port=443 timeout=5 time=14.10 ms
google.com via tcp seq=2 port=443 timeout=5 time=8.99 ms
google.com via tcp seq=3 port=443 timeout=5 time=8.41 ms
google.com via tcp seq=4 port=443 timeout=5 time=8.57 ms
--- google.com tcplatency statistics ---
5 packets transmitted, 5 successful, 0 failed
min/avg/max/mdev = 8.41/12.14/20.63/4.74 ms
Example: $ tcplatency --port 80 --runs 3 --wait 1 52.26.14.11
52.26.14.11 via tcp seq=0 port=80 timeout=5 time=224.45 ms
52.26.14.11 via tcp seq=1 port=80 timeout=5 time=166.37 ms
52.26.14.11 via tcp seq=2 port=80 timeout=5 time=187.80 ms
--- 52.26.14.11 tcplatency statistics ---
3 packets transmitted, 3 successful, 0 failed
min/avg/max/mdev = 166.37/192.87/224.45/23.98 ms
Use tcplatency as a library
"github.com/cbrgm/tcplatency/latency"
Example:
package main
import (
"fmt"
"github.com/cbrgm/tcplatency/latency"
)
func main() {
var host = "google"
var port = 443
var timeout = 5
var runs = 5
var wait = 1
result := latency.Measure(host, port, timeout, runs, wait)
printSummary(host, result)
}
func printSummary(host string, result latency.MeasurementResult) {
fmt.Printf("--- %s tcplatency statistics --- \n", host)
fmt.Printf("%d packets transmitted, %d successful, %d failed \n", result.Count, result.Successful, result.Failed)
fmt.Printf("min/avg/max/mdev = %.2f/%.2f/%.2f/%.2f ms \n", result.Min, result.Average, result.Max, result.StdDev)
}
tcplatency is open-source and is developed under the terms of the Apache 2.0 License.
Maintainer of this repository is:
- @cbrgm | Christian Bargmann mailto:chris@cbrgm.net
Please refer to the git commit log for a complete list of contributors.
See the Contributing Guide.