2012年5月15日 星期二

在Ubuntu下查看網路卡連線速度

在Ubuntu下可以使用 dmesg | grep ethX 指令來查看網路卡的連線速度,會顯示如下訊息:

demo@demo:~$ dmesg | grep eth0

[    2.145551] eth0: SiS 900 PCI Fast Ethernet at 0xe800, IRQ 19, 00:01:6c:d5:01:c1
[    7.417667] ADDRCONF(NETDEV_UP): eth0: link is not ready
[   17.876974] eth0: Media Link On 100mbps full-duplex
[   26.144019] eth0: no IPv6 routers present
但也可能因為網路卡晶片組的關係,使用dmesg無法看見網路卡連線速度的相關訊息,這時可以使用ethtool這支程式來查看網路卡的速度。
ethtool在Ubuntu沒有內建,須先手動安裝:
demo@demo:~$ sudo apt-get update
demo@demo:~$ sudo apt-get install ethtool
ethtool必須使用管理員的權限執行,且執行時需指定要觀看的網路卡,例如:
demo@demo:~$ sudo ethtool eth0

Settings for eth0:

        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
        Link partner advertised pause frame use: Symmetric
        Link partner advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pg
        Wake-on: d
        Current message level: 0x000000c5 (197)
                               drv link rx_err tx_err
        Link detected: yes
至於ethtool其他功能可利用man指令查看!