1

I am trying build Python module that will monitor and measure Ethernet speed (receive and send). This module is part of performance program. I looked for libraries that make it possible and the only library that i found is Psutil with the command:

psutil.net_io_counters(pernic=True)

The output for this command is :

    'Ethernet 5': snetio(bytes_sent=211080874L, bytes_recv=929895370L, packets_sent=667031L, packets_recv=2757846L, errin=0L, errout=0L, dropin=0L, dropout=0L),
 'Loopback Pseudo-Interface 1': snetio(bytes_sent=0L, bytes_recv=0L, packets_sent=0L, packets_recv=0L, errin=0L, errout=0L, dropin=0L, dropout=0L),
 'isatap.replay.local': snetio(bytes_sent=0L, bytes_recv=0L, packets_sent=0L, packets_recv=0L, errin=0L, errout=0L, dropin=0L, dropout=0L)

So I got just bytes amount without knowing anything about time interval of the command measuring,so i can not extract from it the speed.

Which libraries are relevant to my task? how can i extract Ethernet speed with python script? Is there maybe CMD command that simplify the task?

user3205436
  • 57
  • 1
  • 8

1 Answers1

0

By speed, you mean bandwidth. You can see the max theoretical BW with a simple ifconfig. To calculate the actual bandwidth in use you’ll need to call something like net_io_counters multiple times and use the output + time intervals to determine that. There’s no such thing as a “speed gauge”. A simpler but much less precise method could be to calculate the average used bandwidth since the system was started (assuming you didn’t do an ‘if down / up’ in between) by combining the output from net_io_counters and ‘uptime’.

Finally, to get an idea of your actual max bandwidth the common method is to download a file of a known size and time the download. Now of course, given how networks work, you will only get a clear picture here if the upload bandwidth of the remote file server is >= your local download bandwidth, otherwise the download speed will be capped by the remote machine/network.

smassey
  • 5,875
  • 24
  • 37