mii-tool和ethtool

 mii-tool和ethtool

http://blog.csdn.net/xinew/article/details/4868944

1、mii-tool 配置网络设备协商方式的工具

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网卡没有激活;

 

http://www.dlog.cn/flook/diary/4683

 

mii-tool 工具介绍
 
 

网卡的通信方式的检测、调试工具!下面是从http://linux-ip.net/html/tools-mii-tool.html上摘抄的,抛砖引玉!

 

A key tool for determining if you are connected to the Ethernet, and if so, at what speed. The mii-toolprogram does not support all Ethernet devices, as some Ethernet devices have their own vendor-supplied tools to report the same information. The mii-tool source code is based on a tool called mii-diag which provides slightly more information but is less user friendly.

The information reported by mii-tool is quite terse. The following table should clarify the meaning of the speeds you'll encounter in output from mii-tool(There is a standard speed/Ethernet transmission style supported by mii-tool to which I have not referred. That is 100BaseT4. 100BaseT4 provides support for 100 megabit Ethernet networking over Category 3 rated cable. This is probably not a concern for most recently upgraded network infrastructure. The standard networking cable pulled in new construction and renovation is now Category 5 cable which supports 100Base-Tx-FD and possibly gigabit Ethernet. So, let's relegate 100BaseT4 to this footnote, and resume.)

Table B.2. Ethernet Port Speed Abbreviations

Port SpeedDescription
10baseT-HD10 megabit half duplex
10baseT-FD10 megabit full duplex
100baseTx-HD100 megabit half duplex
100baseTx-FD100 megabit full duplex

The raw number indicates the number of bits which can be exchanged between two Ethernet devices over the wire. So 10 megabit Ethernet can support the transmission of ten million bits per second. The suffix to each identifier indicates whether both hosts can send and receive simultaneously or not. Half duplex means that each device can either send or receive in the same instant. Full duplex means that both devices can send and receive simultaneously.

The simplest use of mii-tool reports the link status of all Ethernet devices on a system. Any argument tomii-tool is interpreted as an interface name to query for link status.

Example B.21. Detecting link layer status with mii-tool

[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
[root@tristan]# mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 08:00:17, model 1 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
        mii-tool
eth0: negotiated 100baseTx-FD, link ok
[root@tristan]# mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 08:00:17, model 1 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
        

In the above example, we can infer that tristan has only one Ethernet device (or no Ethernet drivers loaded for any other present Ethernet devices). The first Ethernet device has successfully negotiated a 100 megabit full duplex connection with the device to which it is connected.

Although a great rarity, you may have occasion to dictate to the Ethernet interface the speed at which it should talk to the switch or hub. mii-tool supports a mode of operation under which you indicate supported modes for autonegotiation. Normally, two connected devices will negotiate the fastest possible commonly shared speed. You can select what speeds you want to support on an Ethernet interface by using mii-tool.

Example B.22. Specifying Ethernet port speeds with mii-tool --advertise

[root@tristan]# mii-tool mii-tool --advertise 10baseT-HD,10baseT-FD
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 10baseT-FD, link ok
        mii-tool mii-tool --advertise 10baseT-HD,10baseT-FD
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 10baseT-FD, link ok
        

After we specified that we wished only to support 10baseT-HD and 10baseT-FD as acceptable speeds, mii-tool caused the Ethernet driver to renegotiate port speed with the attached device. Here we selected 10baseT-FD.

Example B.23. Forcing Ethernet port speed with mii-tool --force

[root@tristan]# mii-tool --force 10baseT-FD
[root@tristan]# mii-tool
eth0: 10 Mbit, full duplex, link ok
[root@tristan]# mii-tool --restart
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
        mii-tool --force 10baseT-FD
[root@tristan]# mii-tool
eth0: 10 Mbit, full duplex, link ok
[root@tristan]# mii-tool --restart
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
        

After manipulating the speed at which the Ethernet driver would communicate with the connected device on tristan, we chose to restart the autonegotiation process without forcing a particular speed or advertising a particular speed.

So, if you must know at what speed your linux machine is connected to another device, mii-tool comes to your rescue.

 

http://blog.chinaunix.net/u/6303/showart_180974.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值