2
我想知道網絡連接信息中顯示的速度,例如, 100Mb/s,10Mb/s,而不是可用帶寬。提前致謝!如何在Linux上以編程方式獲取網絡接口速度?
我想知道網絡連接信息中顯示的速度,例如, 100Mb/s,10Mb/s,而不是可用帶寬。提前致謝!如何在Linux上以編程方式獲取網絡接口速度?
上http://linuxhelp.blogspot.com/2005/10/find-speed-of-your-ethernet-card-in.html
發現編程閱讀這些信息並對其進行解析,尋找100BASE-TX或類似
# mii-tool -v eth0
eth0: negotiated 100baseTx-FD flow-control, link ok
product info: vendor 00:00:20, model 32 rev 1
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 flow-control
link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
此外,在同一篇文章中,你可以使用這個,尋找「速度:」行
#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: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: p
Current message level: 0x00000007 (7)
Link detected: yes
如果你想要做的是,在C代碼,查找mii-tool.c
信息通過查詢適當的ioctl函數完成,mii-tool.c提供了該示例。 – rasjani 2009-06-13 17:44:27