Quantcast
Channel: How do I verify the speed of my NIC? - Server Fault
Viewing all articles
Browse latest Browse all 11

Answer by Ryan Babchishin for How do I verify the speed of my NIC?

$
0
0

There are some great answers here, I just wanted to add a few more options.

1. I know this is not quite what you asked (read on for other ways). But if you want to know the real world performance of your NIC, rather than what your computer says it should be, you can use iperf. I usually do this - because you never know. I bought a 1Gb NIC recently that that only transferred at 672Mbps but it's uplink was 1Gb. Good thing I checked.

You'll need two computers.

On computer one, run iperf in server mode:

iperf -s

On the other, run iperf in client mode:

iperf -c 192.168.0.10

If you want to see the full duplex speed, try this instead:

iperf -d -c 192.168.0.10

Substitute 192.168.0.10 for the servers IP address

2. On Ubuntu systems, /var/log/kern.log has limited logging of kernel events. It will record link speed and status of a NIC when it changes. I'm sure other distributions probably do something similar or can be setup to do so.

$ tail -n 300 /var/log/kern.log.1 | grep slave0Aug 28 12:54:04 haze kernel: [ 9452.766248] e1000e: slave0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/TxAug 28 12:54:41 haze NetworkManager[921]: <info>  [1472403281.8486] device (slave0): link disconnectedAug 28 12:54:41 haze kernel: [ 9489.898476] e1000e: slave0 NIC Link is Down

3. You'll probably never, ever need to go this far, but you can write c code that to get the speed. Tested working and root is not required.

https://stackoverflow.com/questions/2872058/get-link-speed-programmatically

#include <stdio.h>#include <sys/socket.h>#include <sys/ioctl.h>#include <netinet/in.h>#include <linux/sockios.h>#include <linux/if.h>#include <linux/ethtool.h>#include <string.h>#include <stdlib.h>int main (int argc, char **argv){    int sock;    struct ifreq ifr;    struct ethtool_cmd edata;    int rc;    sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);    if (sock < 0) {        perror("socket");        exit(1);    }    strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));    ifr.ifr_data = &edata;    edata.cmd = ETHTOOL_GSET;    rc = ioctl(sock, SIOCETHTOOL, &ifr);    if (rc < 0) {        perror("ioctl");        exit(1);    }    switch (ethtool_cmd_speed(&edata)) {        case SPEED_10: printf("10Mbps\n"); break;        case SPEED_100: printf("100Mbps\n"); break;        case SPEED_1000: printf("1Gbps\n"); break;        case SPEED_2500: printf("2.5Gbps\n"); break;        case SPEED_10000: printf("10Gbps\n"); break;        default: printf("Speed returned is %d\n", edata.speed);    }    return (0);}

Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>