简体   繁体   中英

network interface speed on windows using python

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?

我记录了通过每个接口的流量,并设置了一个计时器来计算每个接口的速度。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM