提纲
netperf
iperf
pathchar
ntttcp
itracert
netperf
netperf是一款针对网络性能的测试工具,主要基于TCP或UDP的传输。
根据应用的不同,可以进行批量数据传输(bulk data transfer)模式
和请求/应答(request/reponse)模式的性能测试。
netperf以Client/Server方式工作。
Server端是netserver,用来侦听来自client端的连接,
Client端是netperf,用来向Server发起网络测试。
在Client与Server之间,首先建立一个控制连接,传递有关测试配置的信息,以及测试的结果;
在控制连接建立并传递了测试配置信息以后,Client与Server之间会再建立一个测试连接,
来回传递特殊的流量模式,用来测试网络的性能。
netperf测试结果反映了一个系统能够以多快的速度向另外一个系统发送数据,
以及另外一个系统能够以多块的速度接收数据。
简单使用
下载: http://www.netperf.org/netperf
也可以从这里下载: https://github.com/HewlettPackard/netperf/tags
最新版本是 2.7.0
安装:
tar 解压缩之后 进入目录 ./configure>make>make install 就可以安装
安装完后在当前目录的src目录下会出现 netperf 和 netserver 两个文件.就可以使用.
常用的命令行参数:
-H host :指定远端运行netserver的server IP地址;
-l testlen:指定测试的时间长度(秒);
-t testname:指定测试类型,包括TCP_STREAM,UDP_STREAM,TCP_RR,TCP_CRR,UDP_RR。
样例
1.TCP_STREAM
netperf缺省情况下进行TCP批量传输,
即-t TCP_STREAM。测试过程中,
netperf向netserver发送批量的TCP数据分组,以确定数据传输过程中的吞吐量。
netperf -H 10.110.80.19 -l 30
结果为:
MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 10.110.80.19 () port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec
87380 16384 16384 30.02 928.59
数据含义:
(1)远端系统(即Server)使用大小为87380字节的socket接收缓冲;
(2)本地系统(即Client)使用大小为16384字节的socket发送缓冲;
(3)向远端系统发送的测试分组大小为16384字节;
(4)测试时间为30秒;
(5)吞吐量的测试结果为928.59Mbits/秒
在默认情况下,netperf发送的测试分组大小为本地系统所使用的socket发送缓冲大小。
在TCP_STREAM方式下,相关的局部参数如下表所示:
-s size 设置本地系统的socket发送与接收缓冲大小
-S size 设置远端系统的socket发送与接收缓冲大小
-m size 设置本地系统发送测试分组的大小
-M size 设置远端系统接收测试分组的大小
-D 对本地与远端系统的socket设置TCP_NODELAY选项
TCP_RR
TCP_RR方式的测试对象是多次TCP request和response的交易过程,
但是它们发生在同一个TCP连接中,这种模式常常出现在数据库应用中。
netperf -t TCP_RR -H 10.110.80.19
# 注意默认运行十秒, 注意请求和发送都是1 bytes 可以通过参数改进.
Local /Remote
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec
16384 131072 1 1 10.00 5315.45
16384 87380
参数 说明
-r req,resp 设置request和reponse分组的大小
-s size 设置本地系统的socket发送与接收缓冲大小
-S size 设置远端系统的socket发送与接收缓冲大小
-D 对本地与远端系统的socket设置TCP_NODELAY选项
所以可以测试一个新命令
netperf -t TCP_RR -H 10.110.80.19 -l 30 -- -r 64,1460
注意这个命令出来的是传输率 不是带宽. 不通消息大小的带宽是完全不可互相比较的.
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec
16384 131072 64 1460 30.00 3424.08
16384 87380
TCP_CRR
与TCP_RR不同,TCP_CRR为每次交易建立一个新的TCP连接。
最典型的应用就是HTTP,每次HTTP交易是在一条单独的TCP连接中进行的。
因为需要不停地建立新的TCP连接,并且交易结束后拆除TCP连接,
交易率一定会受到很大影响。
netperf -t TCP_CRR -H 10.110.80.19
Socket Size Request Resp. Elapsed Trans.
Send Recv Size Size Time Rate
bytes Bytes bytes bytes secs. per sec
16384 131072 1 1 10.00 1880.09
16384 87380
备注: RR的传输率是5300,但是CRR的传输只有1880 大约只有不到35%的性能
也就是说 数据库的连接是一种比较昂贵的资源. 如果每次都打开重新连接的话会影响性能和吞吐率.
iperf
前期总结过iperf
其实 iperf 也是client-server架构的
命令使用也比较简单. 可以进行简单的网络延迟,丢包以及带宽的测试
安装方式也有偶rpm包的方式比较简单. 参数也类似可以参照之前的公众号文章.
pathchar
下载地址: ftp://ftp.ee.lbl.gov/pathchar/
这个工具是上世纪的人开发的.
一直没有更新. 有一个英文介绍网站:
a tool by Van Jakobson for CHARacterizing network PATHs on IP. Think traceroute, but vastly smarter (and heavier on the network).
pathchar is available for many platforms, notably including Windows and various flavours of UNIX.
It works by sending a number of ICMP probe packets of different sizes (by default from 48 byte to the MTU - usually 1500 byte).
pathchar analyzes in real time the delay and the packet loss, and provides a characterization of the speeds of each link. It sounds strange, but the software can measure the bandwidth of an Internet link away from you.
Pathchar has very minimal documentation, and it is in a sort of permanent alpha state.
Nonetheless I find it a useful and interesting tool.
At the very least you can use it to discover whether your IPS is short-selling you: or if he is trying to stuff 1000 DSL connection into a 10 Mb/s link.
简单使用
./pathchar -f 4 -m 1500 www.baidu.com
参数含义不明. 没找到任何资料..
pathchar to 10.110.80.19 (10.110.80.19)
doing 32 probes at each of 45 sizes (64 to 1500 by 32)
3 www.gscloud.com (10.110.80.19)
3 hops, rtt 67 us (67 us), bottleneck Inf Mb/s, pipe -2147483648 bytes
ntttcp
微软官方github上面的工具
https://github.com/microsoft/ntttcp
我理解为 new technical test tcp
帮助信息:
NTttcp: [-s|-r|-l|-n|-p|-sp|-ns|-to|-a|-rb|-sb|-u|-w|-d|-t|-cd|-wu|-v|-6|-wa|-nic|-xml|-ndl|-na|-hpt|-uso|-uro|-x|-hv|-nsb|-thr|-brn|-lm|-icp|-cfi|-es|-sam|-qos|-jm|-ps] -m <mappings>
-s work as a sender
-r work as a receiver
-l <Length of buffer> [default TCP: 64K, UDP: 128]
-n <Number of buffers> [default: 20K]
-p <port base> [default: 5001]
-sp Synchronize data ports, if used -p must be same on every instance.
-ns No sync. Senders will start sending as soon as possible.
By default, senders will only start after they perform a handshake
with receivers verifying readiness, using extra TCP connections.
The option is helpful for many-thread tests, reducing time for
the test to start and increasing the max allowed connections.
Either all or none of the NTttcp instances must have this option.
-to <timeout> in milliseconds. [default: 600000]
I/O and thread waits will fail if hung for this duration.
Set to 0 for infinite timeouts. (NTttcp may hang indefinitely.)
-a <outstanding I/O> [default: 2]
-rb <Receive buffer size> [default: -1]
If and only if non-negative, SO_RCVBUF will be set to this value.
SO_RCVBUF of 0 will disable winsock receive buffering.
If negative, use OS default behavior. (e.g. dynamic buffering)
-sb <Send buffer size> [default: 0 with -a; -1 otherwise]
If and only if non-negative, SO_SNDBUF will be set to this value.
SO_SNDBUF of 0 will disable winsock send buffering.
If negative, use OS default behavior. (e.g. dynamic buffering)
-ndl set TCP_NODELAY socket option
-u UDP send/recv
-w WSARecv/WSASend
-rt enable roundtrip mode
-d Verify Flag
-t <Runtime> in seconds. When with -n mans max test time and disables
-wu and -cd flags. [default (with -n): 3h]
-cd <Cool-down> in seconds
-wu <Warm-up> in seconds
-v enable verbose mode
-6 enable IPv6 mode
-wa Sets the WAIT_ALL flag when using recv or WSARecv functions
-nic <NIC IP>
Use NIC with <NIC IP> for sending data (sender only).
-xml [filename] save XML output to a file, by default saves to xml.txt
-na <NUMA node number> Affinitize process to a particular NUMA node.
If -m mapping specifies a processor number, this option
has no effect.
-hpt hide per thread stats
-uso <Message size> Enable UDP segmentation offload with this maximum
message size.
-uro Enable UDP receive coalescing.
-uc Use unconnected UDP sockets and sendto/recvfrom.
-x <PacketArray size> [default: 1]
Use TransmitPackets, calling it with the given packet array size.
-hv Use AF_HYPERV. Host names must be VM GUIDs
-nsb no stdio buffer, all output will be flushed immediately.
-thr <throughput[KB/s]>
Send data with throughput specified for each thread (sender only).
-brn <burn cpu amount>
Amount of CPU operations performed after completing an IO.
-lm Do latency measurement. NTttcp uses QueryPerformanceCounter to
measure latency. May impact performance if you enable it.
-icp <max active threads> [default: -1]
I/O Completion Ports max active threads value < 0 indicates that
WaitForMultipleObjects should be used instead. 0 means using I/O
completion ports with same number of threads as number of cpu-s.
Anything > 0 sets number of threads to that value.
-cfi Uses idle CPU cycles to compute CPU utilization (Vista or higher)
-es Collect EStats (only displayed in XML, must run as admin).
-sam <sample time period> in seconds.
-qos <QOS priority> integer from 0 to 5 which maps to traffic types:
0 : QOSTrafficTypeBestEffort : same priority as non-QOS
1 : QOSTrafficTypeBackground : lower priority than normal
2 : QOSTrafficTypeExcellentEffort : more important than normal
3 : QOSTrafficTypeAudioVideo : A/V streaming
4 : QOSTrafficTypeVoice : realtime voice streams
5 : QOSTrafficTypeControl : highest priority
QOS is disabled by default.
-jm [filename] Jitter measurement:
measure and output packet arrival time. Sender should not include
a filename but the receiver must specify the output file.
Buffer length must be greater than or equal to 20 bytes.
The output format is a CSV with the following headers:
packet_num , send_count, send_freq, recv_count, recv_freq
-ps <duration (ms)> Wait between buffer sends in ms (sender only).
Packet spacing is only supported for 1 thread synchronous sending.
The spacing must be between 5 and 1000 ms.
-thr and -brn are not supported options when -ps is used.
-m <mappings>
One or more mapping 3-tuples separated by spaces:
(number of threads, processor number, receiver address or name)
Processor number must be in the process kgroup. If processor number
is "*", the threads are not affinitized.
e.g. "-m 4,0,1.2.3.4 2,*,contoso" sets up:
-4 threads on processor 0 to connect to 1.2.3.4
-2 unaffinitized threads to connect to contoso
ntttcp 极简使用教程
被测试服务端:
.\ntttcp.exe -r -p 80 -a 6 -t 60 -cd 5 -wu 5 -v -xml c:\bench.xml -m 1,0,127.0.0.1 1,1,127.0.0.1
参数含义
-r:接收。
-p 80:第一个线程用于接收数据的端口。端口号随每个增加的接收方线程递增。
-a 6:每个线程发布 6 个接收重叠缓冲区的异步数据传输
-t 60:以秒为单位的测试持续时间。
-cd 5: 5 秒测试冷却时间。
-wu 5:5 秒测试预热时间。
-v:指定详细测试输出。
-xml: 将测试输出保存到指定文件(默认保存到 xml.txt)。
-m:为每个会话指定三个映射参数(线程编号、CPUID、接收方 IP 地址)。多个会话以空格分隔。
被测试客户端
.\ntttcp.exe -s -p 80 -a -t 60 -cd 5 -wu 5 -m 1,0,127.0.0.1 1,1,127.0.0.1
参数含义
-s:发送。
-p 80:第一个线程用于发送数据的端口。端口号随每个增加的发送方线程递增。
-a:每个线程的异步发送重叠缓冲区的默认值为 2。如果需要,请指定非默认值。
-t 60:以秒为单位的测试持续时间。
-cd 5: 5 秒测试冷却时间。
-wu 5:5 秒测试预热时间。
-m:为每个会话指定三个映射参数(线程编号、CPUID、目标 IP 地址)。多个会话以空格分隔
我这边一个简单的测试结果
.\ntttcp.exe -s -p 80 -a -t 60 -cd 5 -wu 5 -m 1,0,127.0.0.1 1,1,127.0.0.1
Copyright Version 5.39
Network activity progressing...
Thread Time(s) Throughput(KB/s) Avg B / Compl
====== ======= ================ =============
0 60.001 810497.425 65536.000
1 60.001 810075.032 65536.000
##### Totals: #####
Bytes(MEG) realtime(s) Avg Frame Size Throughput(MB/s)
================ =========== ============== ================
94957.000000 60.003 60282.245 1582.544
Throughput(Buffers/s) Cycles/Byte Buffers
===================== =========== =============
25320.705 2.775 1519312.000
DPCs(count/s) Pkts(num/DPC) Intr(count/s) Pkts(num/intr)
============= ============= =============== ==============
681.419 40.397 57057.149 0.482
Packets Sent Packets Received Retransmits Errors Avg. CPU %
============ ================ =========== ====== ==========
1651724 1651712 212 50 28.898
itracert
忘记从哪里下载的了
其实他用的ip地址源就是最开始纯真QQ使用的
纯真IP库.
其实是可以自动升级的 命令非常简单.
itracert 8.8.8.8
不需要任何参数, 我这边的结果为:
说明至少 13跳, 大约 45毫秒的延迟(怀疑不准, 应该是在香港直接返回了)
.\itracert.exe 8.8.8.8
Tracing route to 8.8.8.8
1: 2ms 192.168.0.1 @ 局域网 对方和您在同一内部网
2: 2ms 192.168.1.1 @ 局域网 对方和您在同一内部网
3: 20ms 39.71.64.1 @ 山东省临沂市 联通
4: 8ms 119.164.209.33 @ 山东省济南市 联通
5: * Request time out.
6: * Request time out.
7: 49ms 219.158.97.2 @ 中国 联通骨干网广东节点(华南出口)
8: 54ms 219.158.20.222 @ 中国 联通骨干网
9: 47ms 219.158.16.202 @ 中国 联通骨干网
10: 43ms 72.14.213.114 @ 美国 加利福尼亚州圣克拉拉县山景市谷歌公司
11: 63ms 108.170.241.1 @ 香港 特别行政区
12: 45ms 142.250.57.141 @ 美国 加利福尼亚州圣克拉拉县山景市谷歌公司
13: 45ms 8.8.8.8 @ 美国 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器
知识来源
感谢原作者..周末时间学习整理一下(copy+test)
https://www.shuzhiduo.com/A/MyJxX2VpJn/
https://everything2.com/title/pathchar
https://github.com/microsoft/ntttcp
https://blog.csdn.net/guyan1101/article/details/113759648
标签:监控,default,性能,netperf,bytes,TCP,测试,整理,Size
From: https://www.cnblogs.com/jinanxiaolaohu/p/16950042.html