Linux OS/관리

iperf - 네트워크 성능, 대역폭 측정 툴 (리눅스, 윈도우)

서버엔지니어 2023. 3. 26. 12:33
728x90

안녕하세요.
네트워크 성능, 대역폭 (Bandwidth)를 간편하게 측정 할 수 있는 툴인 iperf를 소개해 보겠습니다.
iperf는 서버-클라이언트 구조로 실행되며,
서버-클라이언트 간의 네트워크 대역폭을 측정해주는 툴 입니다.
리눅스, 윈도우, 안드로이드 등 다양한 플랫폼을 지원하기 때문에 간편하게 사용 가능합니다.


1. 다운로드, 설치
iperf 공식 사이트에서 다운로드 가능합니다.

https://iperf.fr/iperf-download.php

각자의 플랫폼에 맞는 버전을 다운로드 하시면 됩니다.

리눅스의 경우에는 yum, apt를 통해서도 설치가 가능합니다.

이 떄 주의할 점은 서버-클라이언트간의 iperf 버전을 통일시켜 주는 것 입니다.

윈도우에서는 3.X 버전을 쓰고 리눅스에서는 2.X 버전을 썼더니 제대로 측정이 안되더라구요.

(1) 윈도우
다운로드 페이지에서 실행 파일을 다운로드 받으면 됩니다.

(2) CentOS
epel 저장소 설치 후 (yum install epel-release) 다음의 명령어로 설치해주면 됩니다.

# sudo yum install iperf

(3) Ubuntu
다음의 명령어로 설치 가능합니다.

# sudo apt-get install iperf

2. 사용법
(1) usage

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

Client/Server:
  -f, --format    [kmKM]   format to report: Kbits, Mbits, KBytes, MBytes
  -i, --interval  #        seconds between periodic bandwidth reports
  -l, --len       #[KM]    length of buffer to read or write (default 8 KB)
  -m, --print_mss          print TCP maximum segment size (MTU - TCP/IP header)
  -o, --output    <filename> output the report or error message to this specified file
  -p, --port      #        server port to listen on/connect to
  -u, --udp                use UDP rather than TCP
  -w, --window    #[KM]    TCP window size (socket buffer size)
  -B, --bind      <host>   bind to <host>, an interface or multicast address
  -C, --compatibility      for use with older versions does not sent extra msgs
  -M, --mss       #        set TCP maximum segment size (MTU - 40 bytes)
  -N, --nodelay            set TCP no delay, disabling Nagle's Algorithm
  -V, --IPv6Version        Set the domain to IPv6

Server specific:
  -s, --server             run in server mode
  -U, --single_udp         run in single threaded UDP mode
  -D, --daemon             run the server as a daemon

Client specific:
  -b, --bandwidth #[KM]    for UDP, bandwidth to send at in bits/sec
                           (default 1 Mbit/sec, implies -u)
  -c, --client    <host>   run in client mode, connecting to <host>
  -d, --dualtest           Do a bidirectional test simultaneously
  -n, --num       #[KM]    number of bytes to transmit (instead of -t)
  -r, --tradeoff           Do a bidirectional test individually
  -t, --time      #        time in seconds to transmit for (default 10 secs)
  -F, --fileinput <name>   input the data to be transmitted from a file
  -I, --stdin              input the data to be transmitted from stdin
  -L, --listenport #       port to receive bidirectional tests back on
  -P, --parallel  #        number of parallel client threads to run
  -T, --ttl       #        time-to-live, for multicast (default 1)
  -Z, --linux-congestion <algo>  set TCP congestion control algorithm (Linux only)

Miscellaneous:
  -x, --reportexclude [CDMSV]   exclude C(connection) D(data) M(multicast) S(settings) V(server) reports
  -y, --reportstyle C      report as a Comma-Separated Values
  -h, --help               print this message and quit
  -v, --version            print version information and quit

[KM] Indicates options that support a K or M suffix for kilo- or mega-

The TCP window size option can be set by the environment variable
TCP_WINDOW_SIZE. Most other options can be set by an environment variable
IPERF_<long option name>, such as IPERF_BANDWIDTH.

Report bugs to <iperf-users@lists.sourceforge.net> 

(2) 주요 옵션

 -s : 서버 역할
 -c : 클라이언트 역할
 -p : 포트 번호 (Default : 5001)
 -u : TCP 대신 UDP 사용
 -w : TCP 윈도우 사이즈
 -b : UDP 사용 시 대역폭 지정
 -t : 측정 시간 (초)
 -d : 양방향 측정

(3) 예시

 - 서버 : #iperf -s
 - 클라이언트 : #iperf -c <서버IP>