본문 바로가기

기타

[리눅스] iperf3 사용법

728x90

iperf3 사용법

 iperf3 : TCP/UDP 대역폭 성능 측정 도구

테스트 환경

$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

iperf3 패키지 설치

- 서버, 클라이언트 패키지 설치

$ yum install -y iperf3
$ iperf3 --version
iperf 3.1.7
Linux master 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64
Optional features available: CPU affinity setting, IPv6 flow label, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing
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
  --logfile f               send output to a log file
  --forceflush              force flushing output at every interval
  -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
  -I, --pidfile file        write PID file
  -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)
  --fq-rate #[KMG]          enable fair-queuing based socket pacing in
                            bits/sec (Linux only)
  -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, dynamic or 1 for UDP)
  --cport         <port>    bind to a specific client port (TCP and UDP, default: ephemeral port)
  -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, --congestion <algo>   set TCP congestion control algorithm (Linux and FreeBSD only)
  -M, --set-mss   #         set TCP/SCTP maximum segment size (MTU - 40 bytes)
  -N, --no-delay            set TCP/SCTP 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
  --udp-counters-64bit      use 64-bit counters in UDP test packets

[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

iperf3 서버 모드로 실행

iperf3 -s

$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

iperf3 클라이언트 모드로 실행

iperf3 -c 192.168.0.9

$ iperf3 -c 192.168.0.9
Connecting to host 192.168.0.9, port 5201
[  4] local 192.168.0.8 port 41236 connected to 192.168.0.9 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   189 MBytes  1.58 Gbits/sec  450    171 KBytes       
[  4]   1.00-2.00   sec   172 MBytes  1.44 Gbits/sec  405    211 KBytes       
[  4]   2.00-3.00   sec   189 MBytes  1.59 Gbits/sec  405    219 KBytes       
[  4]   3.00-4.00   sec   172 MBytes  1.44 Gbits/sec  405    235 KBytes       
[  4]   4.00-5.00   sec   170 MBytes  1.43 Gbits/sec  382    171 KBytes       
[  4]   5.00-6.00   sec   183 MBytes  1.54 Gbits/sec  450    146 KBytes       
[  4]   6.00-6.84   sec   142 MBytes  1.42 Gbits/sec  315    229 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-6.84   sec  1.19 GBytes  1.49 Gbits/sec  2812          sender
[  4]   0.00-6.84   sec  0.00 Bytes  0.00 bits/sec                  receiver
iperf3: interrupt - the client has terminated

iperf3 서버 모드로 실행

- TCP 80 포트로 리슨하면 백그라운(데몬)로 실행합니다.

$ iperf3 -s -p 80 -D

$ ps -ef | grep iperf
root      1332     1  0 01:14 ?        00:00:00 iperf3 -s -p 80 -D

iperf3 클라이언트 모드로 실행

- 대역폭 측정 시간을 5초로 변경하여 진행합니다. (기본값 10초)

$ iperf3 -c 192.168.0.9 -p 80 -t 5
Connecting to host 192.168.0.9, port 80
[  4] local 192.168.0.8 port 55866 connected to 192.168.0.9 port 80
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   198 MBytes  1.66 Gbits/sec  405    239 KBytes       
[  4]   1.00-2.00   sec   177 MBytes  1.49 Gbits/sec  405    228 KBytes       
[  4]   2.00-3.00   sec   179 MBytes  1.50 Gbits/sec  405    202 KBytes       
[  4]   3.00-4.00   sec   182 MBytes  1.53 Gbits/sec  450    189 KBytes       
[  4]   4.00-5.00   sec   174 MBytes  1.46 Gbits/sec  450    150 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-5.00   sec   910 MBytes  1.53 Gbits/sec  2115             sender
[  4]   0.00-5.00   sec   909 MBytes  1.52 Gbits/sec                  receiver

iperf Done.

 

728x90