goben
goben 0.6
goben 是一个 golang 工具,用于测量主机之间的 TCP/UDP 传输层吞吐量。
创建者: gh-md-toc
git clone https://github.com/udhos/goben ;# clone outside GOPATH
cd goben
go test -v ./...
CGO_ENABLED=0 go install ./cmd/goben
go run ./cmd/goben
确保 ~/go/bin 在你的 shell 路径中并且 goben 已经安装。
启动服务器:
server$ goben
启动客户端:
client$ goben -hosts 1.1.1.1 ;# 1.1.1.1 is server's address
通过运行“goben -h”查找多个受支持的命令行开关:
$ goben -h
2021/02/28 00:43:28 goben version 0.6 runtime go1.16 GOMAXPROCS=12 OS=linux arch=amd64
Usage of goben:
-ascii
plot ascii chart (default true)
-ca string
TLS CA file (if server: CA to validate the client cert, if client: CA to validate the server cert) (default "ca.pem")
-cert string
TLS cert file (default "cert.pem")
-chart string
output filename for rendering chart on client
'%d' is parallel connection index to host
'%s' is hostname:port
example: -chart chart-%d-%s.png
-connections int
number of parallel connections (default 1)
-csv string
output filename for CSV exporting test results on client
'%d' is parallel connection index to host
'%s' is hostname:port
example: -csv export-%d-%s.csv
-defaultPort string
default port (default ":8080")
-export string
output filename for YAML exporting test results on client
'%d' is parallel connection index to host
'%s' is hostname:port
example: -export export-%d-%s.yaml
-hosts value
comma-separated list of hosts
you may append an optional port to every host: host[:port]
-key string
TLS key file (default "key.pem")
-listeners value
comma-separated list of listen addresses
you may prepend an optional host to every port: [host]:port
-localAddr string
bind specific local address:port
example: -localAddr 127.0.0.1:2000
-maxSpeed float
bandwidth limit in mbps (0 means unlimited)
-passiveClient
suppress client writes
-passiveServer
suppress server writes
-reportInterval string
periodic report interval
unspecified time unit defaults to second (default "2s")
-tcp
set to false to disable TCP (this can be used to test TLS only or UDP only) (default true)
-tcpReadSize int
TCP read buffer size in bytes (default 1000000)
-tcpWriteSize int
TCP write buffer size in bytes (default 1000000)
-tls
set to false to disable TLS (default true)
-tlsAuthClient
set to true to enable client certificate authentication (check against CA) (default true)
-tlsAuthServer
set to true to enable server certificate authentication (check against CA) (default true)
-totalDuration string
test total duration
unspecified time unit defaults to second (default "10s")
-udp
run client in UDP mode
-udpReadSize int
UDP read buffer size in bytes (default 64000)
-udpWriteSize int
UDP write buffer size in bytes (default 64000)
服务器端:
$ goben
2018/06/28 15:04:26 goben version 0.3 runtime go1.11beta1 GOMAXPROCS=1
2018/06/28 15:04:26 connections=1 defaultPort=:8080 listeners=[":8080"] hosts=[]
2018/06/28 15:04:26 reportInterval=2s totalDuration=10s
2018/06/28 15:04:26 server mode (use -hosts to switch to client mode)
2018/06/28 15:04:26 serve: spawning TCP listener: :8080
2018/06/28 15:04:26 serve: spawning UDP listener: :8080
客户端:
$ goben -hosts localhost
2018/06/28 15:04:28 goben version 0.3 runtime go1.11beta1 GOMAXPROCS=1
2018/06/28 15:04:28 connections=1 defaultPort=:8080 listeners=[":8080"] hosts=["localhost"]
2018/06/28 15:04:28 reportInterval=2s totalDuration=10s
2018/06/28 15:04:28 client mode, tcp protocol
2018/06/28 15:04:28 open: opening tcp 0/1: localhost:8080
2018/06/28 15:04:28 handleConnectionClient: starting 0/1 [::1]:8080
2018/06/28 15:04:28 handleConnectionClient: options sent: {2s 10s 50000 50000 false 0}
2018/06/28 15:04:28 clientReader: starting: 0/1 [::1]:8080
2018/06/28 15:04:28 clientWriter: starting: 0/1 [::1]:8080
2018/06/28 15:04:30 0/1 report clientReader rate: 13917 Mbps 34793 rcv/s
2018/06/28 15:04:30 0/1 report clientWriter rate: 13468 Mbps 33670 snd/s
2018/06/28 15:04:32 0/1 report clientReader rate: 14044 Mbps 35111 rcv/s
2018/06/28 15:04:32 0/1 report clientWriter rate: 13591 Mbps 33978 snd/s
2018/06/28 15:04:34 0/1 report clientReader rate: 12934 Mbps 32337 rcv/s
2018/06/28 15:04:34 0/1 report clientWriter rate: 12517 Mbps 31294 snd/s
2018/06/28 15:04:36 0/1 report clientReader rate: 13307 Mbps 33269 rcv/s
2018/06/28 15:04:36 0/1 report clientWriter rate: 12878 Mbps 32196 snd/s
2018/06/28 15:04:38 0/1 report clientWriter rate: 13330 Mbps 33325 snd/s
2018/06/28 15:04:38 0/1 report clientReader rate: 13774 Mbps 34436 rcv/s
2018/06/28 15:04:38 handleConnectionClient: 10s timer
2018/06/28 15:04:38 workLoop: 0/1 clientWriter: write tcp [::1]:42130->[::1]:8080: use of closed network connection
2018/06/28 15:04:38 0/1 average clientWriter rate: 13157 Mbps 32892 snd/s
2018/06/28 15:04:38 clientWriter: exiting: 0/1 [::1]:8080
2018/06/28 15:04:38 workLoop: 0/1 clientReader: read tcp [::1]:42130->[::1]:8080: use of closed network connection
2018/06/28 15:04:38 0/1 average clientReader rate: 13595 Mbps 33989 rcv/s
2018/06/28 15:04:38 clientReader: exiting: 0/1 [::1]:8080
2018/06/28 15:04:38 input:
14038 ┤ ╭────╮
13939 ┤──────────╯ ╰╮
13840 ┼ ╰─╮
13741 ┤ ╰╮ ╭──
13641 ┤ ╰╮ ╭───╯
13542 ┤ ╰─╮ ╭──╯
13443 ┤ ╰╮ ╭───╯
13344 ┤ ╰─╮ ╭───╯
13245 ┤ ╰╮ ╭───╯
13146 ┤ ╰─╮ ╭───╯
13047 ┤ ╰────╯
12948 ┤
2018/06/28 15:04:38 output:
13585 ┤ ╭────╮
13489 ┤──────────╯ ╰╮
13393 ┼ ╰─╮
13297 ┤ ╰╮ ╭──
13201 ┤ ╰╮ ╭───╯
13105 ┤ ╰─╮ ╭──╯
13009 ┤ ╰╮ ╭───╯
12914 ┤ ╰─╮ ╭───╯
12818 ┤ ╰╮ ╭───╯
12722 ┤ ╰─╮ ╭───╯
12626 ┤ ╰────╯
12530 ┤
2018/06/28 15:04:38 handleConnectionClient: closing: 0/1 [::1]:8080
对于完整的 TLS 设置,请生成(全部为 PEM 格式):
您可以在“certs”make 目标中使用最小设置,或者查看文件夹 test/certs 以获取可能适用于各种用例的简单本地测试设置。
--x--