linux下,获取网络接口的传输速率

来源:百度知道 编辑:UC知道 时间:2024/05/29 20:24:47
我已经用原始套接字抓了包并分析完毕,在统计数据包以及网络接口信息时需要知道当前网络接口的bit/s,不知道有没有高手知道用什么函数获取,或者是如何计算,谢谢。

ethtool eth0

[root@voipack ~]# ethtool eth0
Settings for eth0:
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: 100Mb/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

不知道ioctl()函数可不可以,我之用ioctl 获得网卡的ip地址和广播地址,至于网络速率还不知道可不可以获得,不过看网上说好像用ioctl可以得到类似ifconfig所列的信息, ifconf