hedandi
怎样获取端口速率
请问怎样用程序获取端口的速率,比如说eth0口是10m,100m.谢谢
hedandi
{
int sock;
struct ifreq ifr;
struct ethtool_cmd eth_data;
sock=socket(AF_INET,SOCK_DGRAM,0);
strcpy(ifr.ifr_name,"eth0");
ifr.ifr_data=(char*)ð_data;
eth_data.cmd=ETHTOOL_GSET;
ioctl(sock,SIOCETHTOOL,&ifr);
close(sock);
}
最后的结果是eth_data.speed速度为0.eth0是link up的状态,请问是哪里出问题了啊
wtx7758520
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes
什么意思
hedandi
[quote]原帖由 [i]wtx7758520[/i] 于 2008-5-27 12:22 发表 [url=http://linux.chinaunix.net/bbs/redirect.php?goto=findpost&pid=6596697&ptid=1005883][img]http://linux.chinaunix.net/bbs/images/common/back.gif[/img][/url]
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
... [/quote]
这个是显示了网卡的当前状态吧. Advertised auto-negotiation:当前是否是自动协商 Speed:当前速度 Duplex:是否全双工