Guía Uso Iperf
Iperf es una herramienta muy útil para comprobar el ancho de banda real de conexión disponible. Tanto para Unix y/o Windows.
Iperf puede configurarse en 2 modos:
- Modo Servidor
- Modo Cliente.
El host en modo iperf servidor escucha conexiones remotas originadas desde potenciales host iperf cliente. El host iperf cliente define los parámetros de test de ancho de banda, y se conecta al servidor remoto.
- Instalación iperf.
apt-get install iperf
- Iniciar servidor iperf.
iperf -s
root@smokeping1:/# iperf -s
————————————————————
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
————————————————————
- Arrancar servidor iperf como demonio.
Se puede arrancar el servidor manual, o como demonio. Para este segundo caso se debe añadir el parámetro -D (se ejecuta iperf como demonio en background).
iperf -s -D
iperf -s -D > /var/log/iperf-log.log
root@server:/home/ubuntu# iperf -s -D > /var/log/iperf-log.log
Running Iperf Server as a daemon
The Iperf daemon process ID : 3546
root@server:/home/ubuntu#
- Conectar un host iperf client a un host iperf servidor
Iperfs necesita ejecutarse en el host local en modo cliente, así como en el servidor remoto en modo servidor. Se debe explicitar la ip con el argument -c.
iperf -c ip_servidor.
[root@fc18-atica ~]# iperf -c 112.131.5.76
————————————————————
Client connecting to 212.231.5.76, TCP port 5001
TCP window size: 85.0 KByte (default)
————————————————————
[ 3] local 10.134.16.230 port 51345 connected with 112.131.5.76 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-13.4 sec 7.75 MBytes 4.85 Mbits/sec
[root@fc18-atica ~]#
- Duración del Test (por defecto 10).
La duración por defecto es 10. Se puede explicitar una duración mayor con el argumento t.
iperf -c ipserver -t 60 (duración 60 sgs).
root@observium:/etc# iperf -c 112.131.5.76 -t 3 (duración total de 3sgs).
————————————————————
Client connecting to 212.231.5.76, TCP port 5001
TCP window size: 23.5 KByte (default)
————————————————————
[ 3] local 172.0.0.14 port 44967 connected with 112.131.5.76 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 3.0 sec 323 MBytes 902 Mbits/sec
root@observium:/etc#
- Intervalo de tiempo durante el que se mide (ancho de banda, jitter, y packet loss).
Por defecto es cero. En este caso hay un único reporte.
iperf -c ip_server -i 2
root@observium:/etc# iperf -c 112.131.5.76 -t 6 -i1
————————————————————
Client connecting to 212.231.5.76, TCP port 5001
TCP window size: 23.5 KByte (default)
————————————————————
[ 3] local 172.0.0.14 port 44968 connected with 112.131.5.76 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 99.6 MBytes 836 Mbits/sec
[ 3] 1.0- 2.0 sec 102 MBytes 851 Mbits/sec
[ 3] 2.0- 3.0 sec 102 MBytes 854 Mbits/sec
[ 3] 3.0- 4.0 sec 102 MBytes 856 Mbits/sec
[ 3] 4.0- 5.0 sec 102 MBytes 860 Mbits/sec
[ 3] 5.0- 6.0 sec 102 MBytes 852 Mbits/sec
[ 3] 0.0- 6.0 sec 609 MBytes 851 Mbits/sec
root@observium:/etc#
- Conexión bidireccional.
Se comprueba la velocidad en un sentido y luego en el otro.
Se utiliza el argumento r para comprobar la dirección en un sentido y luego en el otro. Primero desde el servidor al cliente y luego en sentido contrario. Con el argumento d sería el orden al revés.
iperf -c ip_servidor -r .
- Cambio del temaño de la ventana (window size tcp/ip).
El TCP windows size se puede cambiar mediante el argumento -w seguido por el número de bytes. En el siguiente ejemplo sería una windows size de 125 KB. Se puede hacer tanto en el cliente como en el servidor.
ip -c ip_server -w 128000
- Cambiar protocolo udp en lugar tcp.
Por defecto Iperf usa TCP. Si se desea utilizar UDP debe utilizarse tanto en el servidor como en el cliente el argumento u.
iperf -c ip_server -u
iperf -s -u
El resultado contendrá una métrica extra para el packet loss. Esta debe ser lo más pequeña posible como es natural.
- Lanzar múltiples threads
- Comprobar la versión de Iperf
Se utiliza el argumento v para comprobar la versión del iperf.
root@server:/home/ubuntu# iperf -v
iperf version 2.0.5 (08 Jul 2010) pthreads
- Ayuda Iperf.
Se utiliza el argumento h para comprobar toda la lista de argumentos soportados por iperf.
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 specifie d 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 onl y)
Miscellaneous:
-x, –reportexclude [CDMSV] exclude C(connection) D(data) M(multicast) S(set tings) 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>
root@server:/home/ubuntu#