网络测试,带宽测试,流量测试

节选自《Netkiller Testing 手札》网络测试章节

第 14 章 网络测试

目录

  • 14.1. iperf3 - perform network throughput tests
    • 14.1.1. Server
    • 14.1.2. Client
  • 14.2. Clumsy 差网络环境模拟工具

14.1. iperf3 - perform network throughput tests

Measurement tool for TCP/UDP bandwidth performance

Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, data-gram loss.

iperf3 的使用非常简单,需要两台电脑,一台作为 server,另一台作为 client,启动有发送数据,将结果反馈给用户

		iperf3: parameter error - must either be a client (-c) or server (-s)

Usage: iperf [-s|-c host] [options]
       iperf [-h|--help] [-v|--version]

Server or Client:
  -p, --port      #         server port to listen on/connect to
  -f, --format    [kmgKMG]  format to report: Kbits, Mbits, KBytes, MBytes
  -i, --interval  #         seconds between periodic bandwidth reports
  -F, --file name           xmit/recv the specified file
  -A, --affinity n/n,m      set CPU affinity
  -B, --bind      <host>    bind to a specific interface
  -V, --verbose             more detailed output
  -J, --json                output in JSON format
  -d, --debug               emit debugging output
  -v, --version             show version information and quit
  -h, --help                show this message and quit
Server specific:
  -s, --server              run in server mode
  -D, --daemon              run the server as a daemon
  -1, --one-off             handle one client connection then exit
Client specific:
  -c, --client    <host>    run in client mode, connecting to <host>
  -u, --udp                 use UDP rather than TCP
  -b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited)
                            (default 1 Mbit/sec for UDP, unlimited for TCP)
                            (optional slash and packet count for burst mode)
  -t, --time      #         time in seconds to transmit for (default 10 secs)
  -n, --bytes     #[KMG]    number of bytes to transmit (instead of -t)
  -k, --blockcount #[KMG]   number of blocks (packets) to transmit (instead of -t or -n)
  -l, --len       #[KMG]    length of buffer to read or write
                            (default 128 KB for TCP, 8 KB for UDP)
  -P, --parallel  #         number of parallel client streams to run
  -R, --reverse             run in reverse mode (server sends, client receives)
  -w, --window    #[KMG]    set window size / socket buffer size
  -C, --linux-congestion <algo>  set TCP congestion control algorithm (Linux only)
  -M, --set-mss   #         set TCP maximum segment size (MTU - 40 bytes)
  -N, --nodelay             set TCP no delay, disabling Nagle's Algorithm
  -4, --version4            only use IPv4
  -6, --version6            only use IPv6
  -S, --tos N               set the IP 'type of service'
  -L, --flowlabel N         set the IPv6 flow label (only supported on Linux)
  -Z, --zerocopy            use a 'zero copy' method of sending data
  -O, --omit N              omit the first n seconds
  -T, --title str           prefix every output line with this string
  --get-server-output       get results from server

[KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga-

iperf3 homepage at: http://software.es.net/iperf/
Report bugs to:     https://github.com/esnet/iperf				

14.1.1. Server

[root@localhost ~]# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 127.0.0.1, port 38188
[  5] local 127.0.0.1 port 5201 connected to 127.0.0.1 port 38189
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec  4.74 GBytes  40.7 Gbits/sec                  
[  5]   1.00-2.00   sec  5.00 GBytes  43.0 Gbits/sec                  
[  5]   2.00-3.00   sec  5.00 GBytes  42.9 Gbits/sec                  
[  5]   3.00-4.00   sec  5.02 GBytes  43.1 Gbits/sec                  
[  5]   4.00-5.00   sec  5.02 GBytes  43.2 Gbits/sec                  
[  5]   5.00-6.00   sec  5.02 GBytes  43.1 Gbits/sec                  
[  5]   6.00-7.00   sec  5.05 GBytes  43.4 Gbits/sec                  
[  5]   7.00-8.00   sec  5.02 GBytes  43.1 Gbits/sec                  
[  5]   8.00-9.00   sec  5.08 GBytes  43.6 Gbits/sec                  
[  5]   9.00-10.00  sec  5.03 GBytes  43.2 Gbits/sec                  
[  5]  10.00-10.04  sec   196 MBytes  43.3 Gbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  5]   0.00-10.04  sec  50.2 GBytes  42.9 Gbits/sec    0             sender
[  5]   0.00-10.04  sec  50.2 GBytes  42.9 Gbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------			

输出JSON格式的报告

[root@localhost ~]# iperf3 -s --json
{
	"start":	{
		"connected":	[{
				"socket":	5,
				"local_host":	"127.0.0.1",
				"local_port":	5201,
				"remote_host":	"127.0.0.1",
				"remote_port":	38191
			}],
		"version":	"iperf 3.0.11",
		"system_info":	"Linux localhost.localdomain 3.10.0-327.10.1.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux\n",
		"timestamp":	{
			"time":	"Fri, 24 Jun 2016 08:12:35 GMT",
			"timesecs":	1466755955
		},
		"accepted_connection":	{
			"host":	"127.0.0.1",
			"port":	38190
		},
		"cookie":	"localhost.localdomain.1466755955.214",
		"tcp_mss_default":	21888,
		"test_start":	{
			"protocol":	"TCP",
			"num_streams":	1,
			"blksize":	131072,
			"omit":	0,
			"duration":	10,
			"bytes":	0,
			"blocks":	0,
			"reverse":	0
		}
	},
	"intervals":	[{
			"streams":	[{
					"socket":	5,
					"start":	0,
					"end":	1.00002,
					"seconds":	1.00002,
					"bytes":	5104271292,
					"bits_per_second":	4.08333e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	0,
				"end":	1.00002,
				"seconds":	1.00002,
				"bytes":	5104271292,
				"bits_per_second":	4.08333e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	1.00002,
					"end":	2.00002,
					"seconds":	1,
					"bytes":	5400688104,
					"bits_per_second":	43205504832,
					"omitted":	false
				}],
			"sum":	{
				"start":	1.00002,
				"end":	2.00002,
				"seconds":	1,
				"bytes":	5400688104,
				"bits_per_second":	43205504832,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	2.00002,
					"end":	3.00002,
					"seconds":	0.999996,
					"bytes":	5386797056,
					"bits_per_second":	4.30946e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	2.00002,
				"end":	3.00002,
				"seconds":	0.999996,
				"bytes":	5386797056,
				"bits_per_second":	4.30946e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	3.00002,
					"end":	4.00002,
					"seconds":	1,
					"bytes":	5392957440,
					"bits_per_second":	4.31435e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	3.00002,
				"end":	4.00002,
				"seconds":	1,
				"bytes":	5392957440,
				"bits_per_second":	4.31435e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	4.00002,
					"end":	5.00003,
					"seconds":	1.00001,
					"bytes":	5422972928,
					"bits_per_second":	4.33836e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	4.00002,
				"end":	5.00003,
				"seconds":	1.00001,
				"bytes":	5422972928,
				"bits_per_second":	4.33836e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	5.00003,
					"end":	6,
					"seconds":	0.999978,
					"bytes":	5445845060,
					"bits_per_second":	4.35677e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	5.00003,
				"end":	6,
				"seconds":	0.999978,
				"bytes":	5445845060,
				"bits_per_second":	4.35677e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	6,
					"end":	7.00003,
					"seconds":	1.00003,
					"bytes":	5420875776,
					"bits_per_second":	4.33657e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	6,
				"end":	7.00003,
				"seconds":	1.00003,
				"bytes":	5420875776,
				"bits_per_second":	4.33657e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	7.00003,
					"end":	8.00001,
					"seconds":	0.999975,
					"bytes":	5389877180,
					"bits_per_second":	4.31201e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	7.00003,
				"end":	8.00001,
				"seconds":	0.999975,
				"bytes":	5389877180,
				"bits_per_second":	4.31201e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	8.00001,
					"end":	9.00001,
					"seconds":	1,
					"bytes":	5408030720,
					"bits_per_second":	4.32641e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	8.00001,
				"end":	9.00001,
				"seconds":	1,
				"bytes":	5408030720,
				"bits_per_second":	4.32641e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	9.00001,
					"end":	10,
					"seconds":	1.00001,
					"bytes":	5400166400,
					"bits_per_second":	4.32009e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	9.00001,
				"end":	10,
				"seconds":	1.00001,
				"bytes":	5400166400,
				"bits_per_second":	4.32009e+10,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	10,
					"end":	10.0381,
					"seconds":	0.0380569,
					"bytes":	206635076,
					"bits_per_second":	4.34371e+10,
					"omitted":	false
				}],
			"sum":	{
				"start":	10,
				"end":	10.0381,
				"seconds":	0.0380569,
				"bytes":	206635076,
				"bits_per_second":	4.34371e+10,
				"omitted":	false
			}
		}],
	"end":	{
		"streams":	[{
				"sender":	{
					"socket":	5,
					"start":	0,
					"end":	10.0381,
					"seconds":	10.0381,
					"bytes":	53979117032,
					"bits_per_second":	4.30195e+10,
					"retransmits":	0
				},
				"receiver":	{
					"socket":	5,
					"start":	0,
					"end":	10.0381,
					"seconds":	10.0381,
					"bytes":	53979117032,
					"bits_per_second":	4.30195e+10
				}
			}],
		"sum_sent":	{
			"start":	0,
			"end":	10.0381,
			"seconds":	10.0381,
			"bytes":	53979117032,
			"bits_per_second":	4.30195e+10,
			"retransmits":	0
		},
		"sum_received":	{
			"start":	0,
			"end":	10.0381,
			"seconds":	10.0381,
			"bytes":	53979117032,
			"bits_per_second":	4.30195e+10
		},
		"cpu_utilization_percent":	{
			"host_total":	19.6287,
			"host_user":	0.628708,
			"host_system":	19.02,
			"remote_total":	99.411,
			"remote_user":	1.25979,
			"remote_system":	98.226
		}
	}
}			

14.1.2. Client

[root@localhost ~]# iperf3 -c 127.0.0.1
Connecting to host 127.0.0.1, port 5201
[  4] local 127.0.0.1 port 38189 connected to 127.0.0.1 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  4.93 GBytes  42.4 Gbits/sec    0   1.19 MBytes       
[  4]   1.00-2.00   sec  5.00 GBytes  42.9 Gbits/sec    0   1.19 MBytes       
[  4]   2.00-3.00   sec  5.00 GBytes  42.9 Gbits/sec    0   1.19 MBytes       
[  4]   3.00-4.00   sec  5.02 GBytes  43.1 Gbits/sec    0   1.19 MBytes       
[  4]   4.00-5.00   sec  5.03 GBytes  43.2 Gbits/sec    0   1.19 MBytes       
[  4]   5.00-6.00   sec  5.02 GBytes  43.1 Gbits/sec    0   1.19 MBytes       
[  4]   6.00-7.00   sec  5.05 GBytes  43.4 Gbits/sec    0   1.19 MBytes       
[  4]   7.00-8.00   sec  5.02 GBytes  43.1 Gbits/sec    0   1.81 MBytes       
[  4]   8.00-9.00   sec  5.08 GBytes  43.6 Gbits/sec    0   1.81 MBytes       
[  4]   9.00-10.00  sec  5.03 GBytes  43.2 Gbits/sec    0   1.81 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  50.2 GBytes  43.1 Gbits/sec    0             sender
[  4]   0.00-10.00  sec  50.2 GBytes  43.1 Gbits/sec                  receiver

iperf Done.

原文发布于微信公众号 - Netkiller(netkiller-ebook)

原文发表时间:2016-06-25

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏Linux驱动

34.QT-制作串口助手(并动态检测在线串口,附带源码)

将qextserialport-1.2rc.zip解压,将解压后的src目录拷贝到项目里的子目录SerialSrc下,在项目pro文件中增加下面这行

693
来自专栏杨建荣的学习笔记

一个Oracle bug的手工修复(r6笔记第59天)

在上周五的时候,本来一个例行巡检,想扩充一些表空间,结果弄巧成拙,因为一个drop datafile的操作直接导致了一主两备的两个备库MRP直接抛出了ORA-6...

2635
来自专栏杨建荣的学习笔记

Data Guard高级玩法:通过闪回恢复failover备库 (r10笔记第7天)

今天看到有一个网友提了一个问题,描述很简短 测试DG时,主库不能宕机,如何测试failover? 其实这个需求从业务层面来说是合理的,一...

3356
来自专栏idba

Tokudb安装测试初探

TokuDB 是一个高性能、支持MVCC的MySQL 和 MariaDB 的存储引擎。TokuDB 的主要特点是数据压缩功能出色,对高写压力的支持,由美国...

611
来自专栏FreeBuf

Shellcode与加密流量之间的那些事儿

在这篇文章中,我们将简单介绍如何在通过TCP通信的位置无关代码(PIC)中实现数据加密。

682
来自专栏IT杂记

Storm客户端提交任务失败原因分析

2150
来自专栏乐沙弥的世界

基于RMAN从活动数据库异机克隆(rman duplicate from active DB)

      Oracle 11g RMAN能够实现基于活动数据库进行异机克隆,从而省去需要先备份再ftp到辅助服务器的过程。这一切可以全部交给Oracle来搞定...

973
来自专栏杨建荣的学习笔记

备库跳归档恢复的有趣案例(r9笔记第19天)

在Data Guard环境中,主备库基本都是使用归档来传递数据的变化。如果主备的归档传输中断,同时主库的归档被删除或者损坏,这种情况下备库是没法开始继续...

3315
来自专栏杨建荣的学习笔记

备库报警邮件的分析案例(一) (r7笔记第14天)

今天早上到了公司后,收到了这样一封报警邮件,发现收到备库的报警案例也比较多,着实颠覆了我对备库基本不需要关注管理的观点。后面可以把几个案例做成一个主题来说说。 ...

3113
来自专栏杨建荣的学习笔记

ASM无法启动的问题分析(二)(r7笔记第88天)

第一篇的内容可以参考。ASM无法启动的问题分析(一),有不少的朋友给了一些建议,我也糅合了进来。一并感谢。 当然重启服务发现CSSD服务是Online,但是AS...

33810

扫码关注云+社区