Test Internet Connection Speed From Console Over SSH Command Line

aptestI have recently rented a dedicated server for my hobby projects and learning CentOS Linux server. I was informed that I am connected to the 100M/s port. How do I test my Internet connection download speed from the console over the ssh session without using HTML5 or Adobe flash/Java applets based websites? How do I test my upload speed from the console?

I recommend that you use lftp command to test Internet upload and download speed from console. You can run lftp using the ssh client:

[a] wget — Retrieves files from the web (download speed test).

[b] wput — A tiny wget-like ftp-client for uploading files (upload speed test).

[c] axel — Another light download accelerator.

[d] iperf — Perform network throughput tests.

Installation

You can use the following yum command to install lftp and iperf under RHEL / CentOS / Fedora Linux:

# yum install lftp iperf

OR use the following apt-get command under Debian or Ubuntu Linux:

$ sudo apt-get install lftp iperf

Step #1: Find out download url

You need a large size file to test download speed. For example, you can visit the home page of«Argonne National Laboratory Public Software Mirror» to grab Centos Linux ISO file.

Step #2: Use lftp command to test download speed

The syntax is:

lftp -e 'pget http://example.com/file.iso; exit; '
lftp -e 'pget http://speedtest.example.com/500M.bin; exit; '
lftp -e 'pget http://mirror.anl.gov/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveCD.iso; exit; '

Sample outputs:

Fig.01: lftp testing internet speed
You will also get the report as follows:

725617504 bytes transferred in 65 seconds (10.63M/s)

A note about wget command

You can use the wget command as follows for testing download speed:

$ wget -O /dev/null http://mirror.anl.gov/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveCD.iso

Sample outputs:

Fig.02: wget command in action

Step #3: Use lftp command to test upload speed
The sytnax is as follows:

lftp -u userName ftp.example.com -e 'put largecd1.avi; bye'
lftp -u userName,passWord ftp.example.com -e 'put largecd1.avi; bye'
lftp -u userName,passWord ftp.example.com -e 'put /path/to/large.iso; bye'

In this example, I am uploading a file to my private ftp server:

lftp -u admin homeserver -e 'cd video; put /home/vivek/Downloads/debian-testing-amd64-CD-1.iso; bye'

OR

lftp -u admin homeserver.public.ip.here -e 'cd video; put /home/vivek/Downloads/debian-testing-amd64-CD-1.iso; bye'

Sample outputs:

Fig.03: lftp upload speed test in action

How do I test network throughput rate between two Linux or Unix servers?
Consider the following setup:

+------------------+                            +----------------+
| Linux server A    +------- ISP Internet-------+ Linux server B +
+------------------+                            +----------------+
IP:202.54.1.1                                     IP:203.54.1.1
iperf server                                      iperf client

Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss. On server A start iperf as follows:

# iperf -s -B 202.54.1.1

On server B type the same command as follows:

# iperf -c 202.54.1.1 -d -t 60 -i 10

Sample outputs:

Fig.04: iperf client in action
Where,

  1. -s : Run in server mode.
  2. -B IP : Bind to IP, an interface or multicast address.
  3. -c IP : Run in client mode, connecting to IP.
  4. -d : Do a bidirectional test simultaneously.
  5. -t 60 : Time in seconds to transmit for (default 10).
  6. -i 10 : Pause n seconds between periodic bandwidth reports.

RECOMMENDED READINGS
See the following man pages for information:

man lftp
man wget
man iperf

Bonding производительность

Задача – протестировать суммарную пропускную полосу получаемую при помощи бондинга (bonding — объединение нескольких физических интерфейсов в один логический, с расширенной по сравнению с любым из составных интерфейсов полосой пропускания) двух гигабитных сетевых интерфейсов.

Тестирование производилось с помощью двух серверов в каждом из которых было по два гигабитных сетевых интерфейса (Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet), физически сетевые платы серверов были соединены между собой с помощью двух кросоверных пачкордов.

ОС: CentOS 5.3.

Для начала протестируем максимальную скорость передачи данных по каждому интерфейсу в отдельности при помощи двух утилит iperf и netperf.
iperf показал результаты 949-968 Mbits/sec
netperf показал результаты от 865.64 до 956.35 10^6bits/sec

Теперь настроим bonding на обоих серверах и повторим тесты производительности.

Подгружаем модуль бондинга, для этого в файлы /etc/modprobe.conf на обоих серверах внесем следующие строки:

alias bond0 bonding
options bond0 miimon=100 mode=0

Настройки сетевых интерфейсов на первом сервере.
cat ifcfg-eth0

# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
HWADDR=00:21:5E:3F:E5:A0

Второй адаптер
cat ifcfg-eth1

# Broadcom Corporation NetXtreme II BCM5708 Gigabit Ethernet
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
HWADDR=00:21:5E:3F:E5:A2

Настраиваем сетевые параметры интерфейса бондинга
cat ifcfg-bond0

DEVICE=bond0
IPADDR=192.168.10.1
NETMASK=255.255.255.0
NETWORK=192.168.10.0
BROADCAST=192.168.10.255
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

Перезагрузимся, для того, чтобы изменения вступили в силу.

Теперь аналогичным образом настроим сеть на сервере 2, соответственно назначив интерфейсу bond0 ip адрес 192.168.10.2 .

Теперь внимательно посмотрим, что же нам выдаст команда
cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.2.4 (January 28, 2008)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 1
Permanent HW addr: 00:21:5e:3f:eb:7c

Slave Interface: eth1
MII Status: up
Link Failure Count: 1
Permanent HW addr: 00:21:5e:3f:eb:7e

Протестируем производительность с помошью утилиты iperf в один tcp поток.

На первом сервере запускаем iperf -s .
На втором сервере запускаем iperf -c 192.168.10.2

По 10 проходам получаем такие результаты:

Тест 1 1.88 Gbits/sec
Тест 2 1.87 Gbits/sec
Тест 3 1.88 Gbits/sec
Тест 4 1.87 Gbits/sec
Тест 5 1.88 Gbits/sec
Тест 6 1.88 Gbits/sec
Тест 7 1.88 Gbits/sec
Тест 8 1.88 Gbits/sec
Тест 9 1.88 Gbits/sec
Тест 10 1.88 Gbits/sec

Cо стороны первого сервера вывод данных от iperf выглядит так:

Client connecting to 192.168.10.2, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.10.1 port 39151 connected with 192.168.10.2 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 2.19 GBytes 1.88 Gbits/sec

Протестируем производительность с помошью утилиты iperf в 100 tcp потоков.

На первом сервере запускаем iperf -s .
На втором сервере запускаем iperf -c 192.168.10.2 -P 100

По результатам 10 тестов получаем такие результаты:
iperf на первом и втором сервере после запуска выдавал разные результаты, поэтому я привожу оба результата.

Тест 1 1.83 1.88 Gbits/sec
Тест 2 1.84 1.89 Gbits/sec
Тест 3 1.44 1.88 Gbits/sec
Тест 4 1.85 1.87 Gbits/sec
Тест 5 1.87 1.88 Gbits/sec
Тест 6 1.76 1.88 Gbits/sec
Тест 7 1.84 1.87 Gbits/sec
Тест 8 1.83 1.85 Gbits/sec
Тест 9 1.87 1.89 Gbits/sec
Тест 10 1.83 1.84 Gbits/sec

Тестируем производительность с помошью netperf
На первом сервере запускаем netserver -p 10000 -n 4
На втором сервере запускаем netperf -p 10000 -H 192.168.10.2 -l 30

После 10 проходов получаем такие результаты (10^6bits/sec):

Тест 1 1206.99
Тест 2 1710.40
Тест 3 1878.43
Тест 4 1857.45
Тест 5 1874.43
Тест 6 1878.10
Тест 7 1862.14
Тест 8 1876.81
Тест 9 1876.41
Тест 10 1876.15

Со стороны второго сервера вывод данных после тестирования выглядят так:

TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.10.2 (192.168.10.2) port 0 AF_INET
Recv Send Send
Socket Socket Message Elapsed
Size Size Size Time Throughput
bytes bytes bytes secs. 10^6bits/sec

87380 16384 16384 30.01 1878.43

Вывод: При использовании bonding для двух гигабитных сетевых адаптеров имеет смысл и его использование увеличивает пропускную способность сети в 2 раза.

http://centos.alt.ru/?p=12