Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
3 typo
source | link

When I try to print the maximal throughput of my network interface, I receive an error:

$ cat /sys/class/net/<interface>/speed
cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the /proc/net/dev pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution aI was able to come up with is to say that the default speed of aan interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps cardcards bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.

When I try to print the maximal throughput of my network interface, I receive an error:

$ cat /sys/class/net/<interface>/speed
cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the /proc/net/dev pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution a was able to come up with is to say that the default speed of a interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps card bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.

When I try to print the maximal throughput of my network interface, I receive an error:

$ cat /sys/class/net/<interface>/speed
cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the /proc/net/dev pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution I was able to come up with is to say that the default speed of an interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps cards bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.

2 added 26 characters in body; edited tags
source | link

When I try to print the maximal throughput of my network interface (cat /sys/class/net/<interface>/speed), I receive an error:

cat: /sys/class/net/<interface>/speed: Invalid argument

$ cat /sys/class/net/<interface>/speed
cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-netsource).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the "/proc/net/dev"/proc/net/dev pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution a was able to come up with is to say that the default speed of a interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps card bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.

When I try to print the maximal throughput of my network interface (cat /sys/class/net/<interface>/speed), I receive

cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the "/proc/net/dev" pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution a was able to come up with is to say that the default speed of a interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps card bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.

When I try to print the maximal throughput of my network interface, I receive an error:

$ cat /sys/class/net/<interface>/speed
cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the /proc/net/dev pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution a was able to come up with is to say that the default speed of a interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps card bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.

1
source | link

Network interface with unknown speed

When I try to print the maximal throughput of my network interface (cat /sys/class/net/<interface>/speed), I receive

cat: /sys/class/net/<interface>/speed: Invalid argument

response. According to my investigation, this attribute is only valid for interfaces that implement ethtool get_link_ksettings method (source: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net).

My goal is to calculate network utilization for each interface by fetching the sent and received number of bytes each second (parsing the "/proc/net/dev" pseudo-file) and then using throughput to calculate percentage of utilization. I am doing this in C, so max throughput is obtained via ioctl() function that is unable to succeed for interfaces with unknown speed.

Is there a way how I can obtain the speed attribute in some other way? The simplest solution a was able to come up with is to say that the default speed of a interface is standard 10Mbps and if the utilization is over 100%, I can step the max speed up to the next standard speed of 1000Mbps and so on for 1Gbps, 2.5Gbps and 10Gbps. This could somehow work, but it may get broken with bundled interfaces utilizing non-standard speeds, e.g., two 1Gbps card bundled into one 2Gbps. Bundled interfaces are not a big concern for me, but having general solution would be awesome.