//安装使用netperf
wget ftp://ftp.netperf.org/netperf/netperf-2.4.5.tar.gz
tar xvpf netperf-2.4.5.tar.gz
cd netperf-2.4.5
./configure
make //会在当前目录的src目录下生成netserver服务器端和netperf客户端
------------------------------------------------------------------------------------------------------
//安装使用netstrain
wget http://cdnetworks-kr-1.dl.sourceforge.net/project/netstrain/netstrain/3.0/netstrain-3.0.tar.gz
tar xvpf netstrain-3.0.tar.gz
cd netstrain-3.0;make //在当前目录下生成netstraind服务器端和netstrain客户端
//在被测试服务器上运行服务器端,指定ipv4和port
./netstraind -4 11111
//显示
[jrckkyy@localhost netstrain-3.0]$ ./netstraind -4 11111
NetStrain 3.0 (c) 2002 Christoph Pfisterer <cp@chrisp.de>
Listening on 0.0.0.0 port 11111 using IPv4...
One-shot server waiting for connection
//server端如果需要修改绑定本地的ip地址,修改netstrain-3.0目录下server.c 文件中setup_socket函数里第100行调用点的gai_error = getaddrinfo(NULL, portspec, &hints, &aitop);的第一个参数为gai_error = getaddrinfo("*.*.*.160", portspec, &hints, &aitop);重新编译启动即可
//在客户端运行,设置测试全双工,目标ip,port,ipv4
./netstrain -4 *.*.*.160 11111 both
//显示
[jrckkyy@localhost netstrain-3.0]$ ./netstrain -4 *.*.*.160 11111 both
NetStrain 3.0 (c) 2002 Christoph Pfisterer <cp@chrisp.de>
Looking up hostname *.*.*.160...
Connecting to *.*.*.160 port 11111 using IPv4...
Connected
sent: 73495K, 5382.5K/s total, 6399.9K/s current
recv'd: 124M, 9321.9K/s total, 8949.0K/s current
总结:netstrain相对测试的功能简单,可以看到tcp单个连接来回上行下行的当前网络环境网速是多少,服务器客户端调换位置测试,上行下行网速跟之前测试是一致的。