2009年1月16日 星期五

ethernet diagnostic tools

1.1 mii-tool 介紹

mii-tool - view, manipulate media-independent interface status
(mii-tool 是查看,管理介質的網絡接口的狀態)
有時網卡需要配置協商方式,比如10/100/1000M的網卡半雙工、全雙工、自動協商的配置。但大多數的網絡設備是不用我們來修改協商,因為大多數網絡設置接入的時候,都採用自動協商來解決相互通信的問題。不過自動協商也不是萬能的,有時也會出現錯誤,比如丟包率比較高,這時就要我們來指定網卡的協商方式 。

mii-tool 就是能指定網卡的協商方式。下面我們說一說mii-tool的用法;

1.2 mii-tool 的用法;

mii-tool 在更改網絡設備通信協商方式的方法比較簡單,用 -v 參數來查看網絡接口的狀態;看下面的例子;

mii-tool 更改網絡接口協商的方法;

[root@localhost ~]# mii-tool --help
usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
-V, --version display version information
-v, --verbose more verbose output 註:顯示網絡接口的信息;
-R, --reset reset MII to poweron state 註:重設MII到開啟狀態;
-r, --restart restart autonegotiation 註:重啟自動協商模式;
-w, --watch monitor for link status changes 註:查看網絡接口連接的狀態變化;
-l, --log with -w, write events to syslog 註:寫入事件到系統日誌;
-A, --advertise=media,... advertise only specified media 註:指令特定的網絡接口;
-F, --force=media force specified media technology 註:更改網絡接口協商方式;
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,
(to advertise both HD and FD) 100baseTx, 10baseT


* 實例一:查看網絡接口的協商狀態;

[root@localhost ~]# mii-tool -v eth0
eth0: negotiated 100baseTx-FD, link ok
product info: vendor 00:00:00, model 0 rev 0
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control

註:上面的例子,我們可以看得到是自動協商。注意紅字的部份;

* 實例二:更改網絡接口協商方式;

更改網絡接口的協商方式,我們要用到-F選項,後面可以接 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD等參數;

如果我們想把網絡接口eth0改為 1000Mb/s全雙工的模式應該怎麼辦呢?

[root@localhost ~]# mii-tool -F 100baseTx-FD

[root@localhost ~]#mii-tool -v eth0
eth0: 100 Mbit, full duplex, link ok
product info: vendor 00:00:00, model 0 rev 0
basic mode: 100 Mbit, full duplex
basic status: link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD

註:是不是已經改過來了?當然,我們也一樣用ethtool 工具來更改,比如執行下面的命令;

[root@localhost ~]# ethtool -s eth0 speed 100 duplex full

2、ethtool 工具關於網絡協商功能介紹;


ethtool - Display or change ethernet card settings(ethtool 是用來顯示和更改網卡設置的工具);這個工具比較複雜,功能也特別多。由於洋文比較難懂。所以我們還是把網絡設備協商方式的設置方法說一說。


2.1 ethtool 顯示網絡端口設置功能;

這個功能比較好辦。就是ethtool 後面直接接網絽接口就行;比如下面的例子;

[root@localhost ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No 註:自動協商關閉
Speed: 100Mb/s 註:速度 100Mb
Duplex: Full 註:全雙工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes 註:eth0已經激活;

2.2 ethtool 設置網卡的協商模式;

在ethtool的-h幫助中我們查看到有這樣的幫助信息;

ethtool -s DEVNAME \
[ speed 10|100|1000 ] \
[ duplex half|full ] \
[ port tp|aui|bnc|mii|fibre ] \
[ autoneg on|off ] \


* 實例一: 把網卡eth0 速度改為10Mb/s,採用半雙工;

[root@cuc03 beinan]# ethtool -s eth1 speed 10 duplex half
[root@cuc03 beinan]# ethtool eth1
Settings for eth1:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No
Speed: 10Mb/s 註:速度 10M/s
Duplex: Half 註:半雙工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: no 註:eth1沒有激活;

* 實例二: 把網卡eth0 速度改為100Mb/s,採用全雙工;

[root@cuc03 beinan]# ethtool -s eth1 speed 100 duplex full
[root@cuc03 beinan]# ethtool eth1
Settings for eth1:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No
Speed: 100Mb/s 註:速度 100M/s
Duplex: Full 註:全雙工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: no 註:eth1網卡沒有激活;

沒有留言:

張貼留言