项目作者: cbrgm

项目描述 :
Command-line tool and go module to measure latency using TCP.
高级语言: Go
项目地址: git://github.com/cbrgm/tcplatency.git
创建时间: 2019-09-04T01:35:25Z
项目社区:https://github.com/cbrgm/tcplatency

开源协议:Apache License 2.0

下载


tcplatency Build Status


Go Report Card

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.

Features

  • 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

Install

You can find the latest releases here.

Usage

tcplatency can be used both as a module and as a standalone script.

Command-Line Tool

Download the latest release here. Or build from source using make build (requires go 1.11+)

  1. AME:
  2. tcplatency - tcplatency measures network latencies using tcp pings
  3. USAGE:
  4. tcplatency [global options] command [command options] [arguments...]
  5. COMMANDS:
  6. help, h Shows a list of commands or help for one command
  7. GLOBAL OPTIONS:
  8. --host value the host address
  9. --port value, -p value the host port (default: 443)
  10. --timeout value, -t value timeout in seconds (default: 5)
  11. --runs value, -r value number of latency points to return (default: 5)
  12. --wait value, -w value seconds to wait between each run (default: 1)
  13. --help, -h show help
  14. --version, -v print the version

Example: $ tcplatency google.com

  1. google.com via tcp seq=0 port=443 timeout=5 time=20.63 ms
  2. google.com via tcp seq=1 port=443 timeout=5 time=14.10 ms
  3. google.com via tcp seq=2 port=443 timeout=5 time=8.99 ms
  4. google.com via tcp seq=3 port=443 timeout=5 time=8.41 ms
  5. google.com via tcp seq=4 port=443 timeout=5 time=8.57 ms
  6. --- google.com tcplatency statistics ---
  7. 5 packets transmitted, 5 successful, 0 failed
  8. min/avg/max/mdev = 8.41/12.14/20.63/4.74 ms
  9. `

Example: $ tcplatency --port 80 --runs 3 --wait 1 52.26.14.11

  1. 52.26.14.11 via tcp seq=0 port=80 timeout=5 time=224.45 ms
  2. 52.26.14.11 via tcp seq=1 port=80 timeout=5 time=166.37 ms
  3. 52.26.14.11 via tcp seq=2 port=80 timeout=5 time=187.80 ms
  4. --- 52.26.14.11 tcplatency statistics ---
  5. 3 packets transmitted, 3 successful, 0 failed
  6. min/avg/max/mdev = 166.37/192.87/224.45/23.98 ms

Go Module

Use tcplatency as a library

  1. "github.com/cbrgm/tcplatency/latency"

Example:

  1. package main
  2. import (
  3. "fmt"
  4. "github.com/cbrgm/tcplatency/latency"
  5. )
  6. func main() {
  7. var host = "google"
  8. var port = 443
  9. var timeout = 5
  10. var runs = 5
  11. var wait = 1
  12. result := latency.Measure(host, port, timeout, runs, wait)
  13. printSummary(host, result)
  14. }
  15. func printSummary(host string, result latency.MeasurementResult) {
  16. fmt.Printf("--- %s tcplatency statistics --- \n", host)
  17. fmt.Printf("%d packets transmitted, %d successful, %d failed \n", result.Count, result.Successful, result.Failed)
  18. fmt.Printf("min/avg/max/mdev = %.2f/%.2f/%.2f/%.2f ms \n", result.Min, result.Average, result.Max, result.StdDev)
  19. }

Credit & License

tcplatency is open-source and is developed under the terms of the Apache 2.0 License.

Maintainer of this repository is:

Please refer to the git commit log for a complete list of contributors.

Contributing

See the Contributing Guide.