リンク速度を決定するためにifconfig出力をどのように処理しますか?

リンク速度を決定するためにifconfig出力をどのように処理しますか?

これはダウンロード速度をテストするために退屈で書かれたスクリプトです。

#!/bin/bash

get_ispeed() {
    echo $(ifconfig eth0 | grep bytes | grep RX | cut -d ':' -f 2 | cut -d ' ' -f 1);
}

for((;;));
do
    s1=`get_ispeed`;

    sleep 1s;

    s2=`get_ispeed`;

    d=$(($s2-$s1));

    echo $(($d / 1000))" kB/s";
done

私は実際にbashistではありませんが、「作業を実行する」かどうかはわかりません。 p
ifconfigはRXバイトを生成するので、kB / sを得るために1000で割ります。

ベストアンサー1

リンク速度

私は実際にリンク速度を探しているとは思わない。接続の専用接続速度です。ethtool(ストレージに)インストールした場合は、次のコマンドを使用してリンク速度を取得できます。

$ sudo ethtool eth0 | grep -i speed
    Speed: 100Mb/s

帯域幅(コア)

帯域幅の速度を確認したい。特定の期間に総速度をどのくらい使用しましたか?インターフェイスが読み取ったバイト数を取得する方法はいくつかありますeth0

$ cat /sys/class/net/eth0/statistics/rx_bytes 
3431530366

また、/proc/net/devデータを提供するのがカーネル構造だと思いますifconfig

$ cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:629956414  572909    0    0    0     0          0         0 629956414  572909    0    0    0     0       0          0
  eth0:3431888253 329701689    0    0    0     0          0    359127 831203319 353144288    0    0    0     0       0          0
  sit0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0

ツールを使用した測定

より良い方法は、実際のツールを使用して帯域幅使用量を測定することです。ここにはさまざまなオプションがあります。

  1. wget/curlの使用

    これらは非常に簡単です。ダウンロードするには、大きなファイルを選択し、完了したら、両方のツールのいずれかで報告された統計を確認してください。

    $ wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
    
    -or-
    
    $ curl -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
    
  2. CLI監視ツールの使用

    このカテゴリには多くのツールがあります。始めるいくつかの方法は次のとおりです。

  3. 使用速度テスト-cli

    これは優れた利点を利用します。速度テストネットワークコマンドラインからウェブサイトにアクセスします。

    $ ./speedtest-cli
    Retrieving speedtest.net configuration...
    Retrieving speedtest.net server list...
    Testing from Comcast Cable (x.x.x.x)...
    Selecting best server based on ping...
    Hosted by FiberCloud, Inc (Seattle, WA) [12.03 km]: 44.028 ms
    Testing download speed........................................
    Download: 32.29 Mbit/s
    Testing upload speed..................................................
    Upload: 5.18 Mbit/s
    
  4. 使用アイパフ

    これを行うには、独自のサーバーとクライアントを設定し、2台のコンピューター間の帯域幅パフォーマンスを測定します。これは、特定のインターネットターゲットのパフォーマンスに依存するよりも、コンピュータ/ネットワークのパフォーマンスをより正確に把握できるという点で優れています。

    サーバーから:

    $ iperf -s
    

    クライアント側から:

    $ iperf -c myserver.mydom
     ------------------------------------------------------------
    Client connecting to 192.168.1.1, TCP port 5001
    TCP window size: 16.0 KByte (default)
    ------------------------------------------------------------
     [  3] local 192.168.1.3 port 52143 connected with 192.168.1.1 port 5001
     [ ID] Interval       Transfer     Bandwidth
     [  3]  0.0-10.0 sec    113 MBytes  94.7 Mbits/sec
    

引用する

おすすめ記事