Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

第 16 章 网络测试

目录

16.1. iperf3 - perform network throughput tests
16.1.1. Server
16.1.2. Client
16.2. Clumsy 差网络环境模拟工具

16.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
				
		

16.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
		}
	}
}
			

16.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.
			
comments powered by Disqus