I’m writing an app in python for windows and I want to know the speed of a network interface in my machine, I use the following code to get the routing table used.
def cmd(c):
"""
Execute commands in the command line
"""
return os.popen(c).read().rstrip("\n")
#list of IPV4 network routs
table = cmd("route print -4").split("\n")
And then I process table as a string, cut it into lines, and get a list of (ip, subnet, gateway, metric) tuples for each interface.
Is there a way to calculate the speed of the connection to the internet using an interface? or a command to get such information?
I logged the amount of traffic going through each interface and made a timer to calculate the speed of each one.