測量 NIC 的速度

測量 NIC 的速度

我有幾塊板(但我認為如果它們是 PC,問題會是一樣的 - 除了可能因為它們是運行 Linux 的板,我想運行控制台工具),通過有線連接到互聯網。

現在,其中一個已連接到乙太網路連接埠(如預期)。另一個與轉換器(不確定術語是否正確)連接,該轉換器連接到 USB 端口,然後連接到乙太網路電纜。

我想測量兩者的速度(並進行基本操作檢查)。

我怎樣才能做到這一點?

答案1

嗯,有幾種不同的方法 - 我將使用網路工具獲取有關設備的“基本”信息,並使用 iperf 檢查其實際速度。我正在使用我“知道”速度較慢的連接(通過 homeplug)來顯示差異。理論上,透過 USB 連接,您可能遇到瓶頸

當然,首先您需要了解有關設備及其 IP 位址的一些資訊 -ip addr這樣做嗎

然後我會使用 ethtool 來獲取有關適配器的信息

geek@box31:~$ ethtool eno1
Settings for eno1:
        Supported ports: [ TP    MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
                                             1000baseT/Full
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Auto-negotiation: on
        master-slave cfg: preferred slave
        master-slave status: slave
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: external
        MDI-X: Unknown
netlink error: Operation not permitted
        Link detected: yes

這裡最重要的是Speed: 1000Mb/s──或者我所說的線速度。幾乎你不太可能達到「全速」。這是最快的你的硬體可以去。在家庭用戶設定中,大多數系統都是千兆位元或快速 (100baseT) 以太網,儘管我們現在開始在家庭系統上看到高達 10Gig 的多千兆網卡。

為了證明這一點,我正在使用iperf3- 您在另一個系統上運行伺服器,iperf3 -s並使用類似的方式連接到伺服器iperf3 -c ip_of_server -t 10

這會給你這樣的輸出

iperf3: interrupt - the client has terminated
geek@box31:~$ iperf3 -c 192.168.2.121 -t 10
Connecting to host 192.168.2.121, port 5201
[  5] local 192.168.2.86 port 44846 connected to 192.168.2.121 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  12.1 MBytes   101 Mbits/sec    0    351 KBytes
[  5]   1.00-2.00   sec  10.6 MBytes  88.7 Mbits/sec    0    351 KBytes
[  5]   2.00-3.00   sec  10.3 MBytes  86.7 Mbits/sec    0    351 KBytes
[  5]   3.00-4.00   sec  10.5 MBytes  87.7 Mbits/sec    0    351 KBytes
[  5]   4.00-5.00   sec  10.2 MBytes  85.7 Mbits/sec    0    351 KBytes
[  5]   5.00-6.00   sec  10.9 MBytes  91.2 Mbits/sec    0    351 KBytes
[  5]   6.00-7.00   sec  10.5 MBytes  87.7 Mbits/sec    0    351 KBytes
[  5]   7.00-8.00   sec  10.2 MBytes  85.2 Mbits/sec    0    351 KBytes
[  5]   8.00-9.00   sec  10.3 MBytes  86.2 Mbits/sec    0    351 KBytes
[  5]   9.00-10.00  sec  10.5 MBytes  88.2 Mbits/sec    5    173 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   106 MBytes  88.8 Mbits/sec    5             sender
[  5]   0.00-10.00  sec   104 MBytes  87.6 Mbits/sec                  receiver

我將把準確的解釋留給讀者當作練習在這種情況下,雖然我的連接兩端能夠實現全千兆位元連接,您會發現我的速度較慢。

透過直接的點對點連接或透過具有全千兆位元能力的路由器或交換器進行的連接,您會看到速度接近但不等於線路速度。 Iperf 也是漂亮的開銷低,因此使用“現實世界”協定(例如 http 或 https),您可能會看到小的速度上的差異。

還有其他因素,例如資料包大小,但這超出了本答案的範圍。

相關內容