Network interface with unknown speed The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsPC BSD Warden network interfaceProblem with network interfaceSystemd networking service fails because of unknown interfaceHow to calculate wlan0 interface speedHow to point to network interface from other inteface configuration in /etc/network/interfaceNetwork Interface VLAN static addressingSetting default network interface?Unknown interface ens33Network interface not upunknown network interface called “enx9cebe80718e1”

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

One-dimensional Japanese puzzle

Homework question about an engine pulling a train

Store Dynamic-accessible hidden metadata in a cell

What information about me do stores get via my credit card?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Mortgage adviser recommends a longer term than necessary combined with overpayments

What can I do if neighbor is blocking my solar panels intentionally?

Identify 80s or 90s comics with ripped creatures (not dwarves)

Working through the single responsibility principle (SRP) in Python when calls are expensive

Can the DM override racial traits?

Does Parliament hold absolute power in the UK?

Can a flute soloist sit?

How to determine omitted units in a publication

Loose spokes after only a few rides

Is every episode of "Where are my Pants?" identical?

Is 'stolen' appropriate word?

Simulating Exploding Dice

Button changing its text & action. Good or terrible?

should truth entail possible truth

Are spiders unable to hurt humans, especially very small spiders?

Windows 10: How to Lock (not sleep) laptop on lid close?

What do I do when my TA workload is more than expected?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?



Network interface with unknown speed



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election ResultsPC BSD Warden network interfaceProblem with network interfaceSystemd networking service fails because of unknown interfaceHow to calculate wlan0 interface speedHow to point to network interface from other inteface configuration in /etc/network/interfaceNetwork Interface VLAN static addressingSetting default network interface?Unknown interface ens33Network interface not upunknown network interface called “enx9cebe80718e1”



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















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.










share|improve this question
























  • I can give some java code to enumerate the adapters, if it can be any help

    – Joe
    Apr 9 at 7:09











  • @Joe Whatever information/help I can get might be useful! Thanks.

    – Samo Poláček
    Apr 9 at 7:13











  • I think the closest you can get to that information is by doing a test connection with a sustained stream of data towards a well-known server whose backbone speed is well established and known in advance, and also assuming that your unknown interface’s speed is at most not bigger than that backbone’s speed

    – LL3
    Apr 9 at 9:31











  • @LL3 Thanks for the suggestion, but I'm not allowed to stream data to internet to test the connection speed.

    – Samo Poláček
    Apr 9 at 9:45












  • Not to internet, no, but to a local server perhaps ? I assumed you were concerning a LAN setup, what with possible 1-2-10Gbps speeds. Besides, if you’re measuring throughput to/from internet then also the /sys/class/net/<intf>/speed info is usually of no real use even when present and accurate. If your interface in question is of direct WAN type (e.g. an xDSL, or 4G interface) then there should be some link layer protocol (e.g. PPP) running over it, whose daemon you might try to query ?

    – LL3
    Apr 9 at 11:59

















1















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.










share|improve this question
























  • I can give some java code to enumerate the adapters, if it can be any help

    – Joe
    Apr 9 at 7:09











  • @Joe Whatever information/help I can get might be useful! Thanks.

    – Samo Poláček
    Apr 9 at 7:13











  • I think the closest you can get to that information is by doing a test connection with a sustained stream of data towards a well-known server whose backbone speed is well established and known in advance, and also assuming that your unknown interface’s speed is at most not bigger than that backbone’s speed

    – LL3
    Apr 9 at 9:31











  • @LL3 Thanks for the suggestion, but I'm not allowed to stream data to internet to test the connection speed.

    – Samo Poláček
    Apr 9 at 9:45












  • Not to internet, no, but to a local server perhaps ? I assumed you were concerning a LAN setup, what with possible 1-2-10Gbps speeds. Besides, if you’re measuring throughput to/from internet then also the /sys/class/net/<intf>/speed info is usually of no real use even when present and accurate. If your interface in question is of direct WAN type (e.g. an xDSL, or 4G interface) then there should be some link layer protocol (e.g. PPP) running over it, whose daemon you might try to query ?

    – LL3
    Apr 9 at 11:59













1












1








1


1






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.










share|improve this question
















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.







networking network-interface c






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 9 at 6:53







Samo Poláček

















asked Apr 9 at 6:35









Samo PoláčekSamo Poláček

113




113












  • I can give some java code to enumerate the adapters, if it can be any help

    – Joe
    Apr 9 at 7:09











  • @Joe Whatever information/help I can get might be useful! Thanks.

    – Samo Poláček
    Apr 9 at 7:13











  • I think the closest you can get to that information is by doing a test connection with a sustained stream of data towards a well-known server whose backbone speed is well established and known in advance, and also assuming that your unknown interface’s speed is at most not bigger than that backbone’s speed

    – LL3
    Apr 9 at 9:31











  • @LL3 Thanks for the suggestion, but I'm not allowed to stream data to internet to test the connection speed.

    – Samo Poláček
    Apr 9 at 9:45












  • Not to internet, no, but to a local server perhaps ? I assumed you were concerning a LAN setup, what with possible 1-2-10Gbps speeds. Besides, if you’re measuring throughput to/from internet then also the /sys/class/net/<intf>/speed info is usually of no real use even when present and accurate. If your interface in question is of direct WAN type (e.g. an xDSL, or 4G interface) then there should be some link layer protocol (e.g. PPP) running over it, whose daemon you might try to query ?

    – LL3
    Apr 9 at 11:59

















  • I can give some java code to enumerate the adapters, if it can be any help

    – Joe
    Apr 9 at 7:09











  • @Joe Whatever information/help I can get might be useful! Thanks.

    – Samo Poláček
    Apr 9 at 7:13











  • I think the closest you can get to that information is by doing a test connection with a sustained stream of data towards a well-known server whose backbone speed is well established and known in advance, and also assuming that your unknown interface’s speed is at most not bigger than that backbone’s speed

    – LL3
    Apr 9 at 9:31











  • @LL3 Thanks for the suggestion, but I'm not allowed to stream data to internet to test the connection speed.

    – Samo Poláček
    Apr 9 at 9:45












  • Not to internet, no, but to a local server perhaps ? I assumed you were concerning a LAN setup, what with possible 1-2-10Gbps speeds. Besides, if you’re measuring throughput to/from internet then also the /sys/class/net/<intf>/speed info is usually of no real use even when present and accurate. If your interface in question is of direct WAN type (e.g. an xDSL, or 4G interface) then there should be some link layer protocol (e.g. PPP) running over it, whose daemon you might try to query ?

    – LL3
    Apr 9 at 11:59
















I can give some java code to enumerate the adapters, if it can be any help

– Joe
Apr 9 at 7:09





I can give some java code to enumerate the adapters, if it can be any help

– Joe
Apr 9 at 7:09













@Joe Whatever information/help I can get might be useful! Thanks.

– Samo Poláček
Apr 9 at 7:13





@Joe Whatever information/help I can get might be useful! Thanks.

– Samo Poláček
Apr 9 at 7:13













I think the closest you can get to that information is by doing a test connection with a sustained stream of data towards a well-known server whose backbone speed is well established and known in advance, and also assuming that your unknown interface’s speed is at most not bigger than that backbone’s speed

– LL3
Apr 9 at 9:31





I think the closest you can get to that information is by doing a test connection with a sustained stream of data towards a well-known server whose backbone speed is well established and known in advance, and also assuming that your unknown interface’s speed is at most not bigger than that backbone’s speed

– LL3
Apr 9 at 9:31













@LL3 Thanks for the suggestion, but I'm not allowed to stream data to internet to test the connection speed.

– Samo Poláček
Apr 9 at 9:45






@LL3 Thanks for the suggestion, but I'm not allowed to stream data to internet to test the connection speed.

– Samo Poláček
Apr 9 at 9:45














Not to internet, no, but to a local server perhaps ? I assumed you were concerning a LAN setup, what with possible 1-2-10Gbps speeds. Besides, if you’re measuring throughput to/from internet then also the /sys/class/net/<intf>/speed info is usually of no real use even when present and accurate. If your interface in question is of direct WAN type (e.g. an xDSL, or 4G interface) then there should be some link layer protocol (e.g. PPP) running over it, whose daemon you might try to query ?

– LL3
Apr 9 at 11:59





Not to internet, no, but to a local server perhaps ? I assumed you were concerning a LAN setup, what with possible 1-2-10Gbps speeds. Besides, if you’re measuring throughput to/from internet then also the /sys/class/net/<intf>/speed info is usually of no real use even when present and accurate. If your interface in question is of direct WAN type (e.g. an xDSL, or 4G interface) then there should be some link layer protocol (e.g. PPP) running over it, whose daemon you might try to query ?

– LL3
Apr 9 at 11:59










0






active

oldest

votes












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511379%2fnetwork-interface-with-unknown-speed%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511379%2fnetwork-interface-with-unknown-speed%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.