如何使用Python检查网络带宽? [英] How to check network bandwidth with Python?

查看:307
本文介绍了如何使用Python检查网络带宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据要求,我希望脚本检查网络带宽,从而使我知道用户可以通过网络快速浏览.是否有任何库可以让我指定要发送的软件包的大小并提供ping时间或其他功能?

As asked, I would like my script to check network bandwidth giving me any idea how fast user can surf through web. Is there any library, which allows me to specify size of package to be send and gives ping time or whatever?

推荐答案

此答案提到了ping的Python实现,该实现返回ICMP数据包的往返时间.您可以使用以下注释中的改进代码: https://gist.github.com/255009 .

This answer mentions a Python implementation of ping that returns the ICMP packet's round-trip time. You can use the improved code from the comment: https://gist.github.com/255009.

但是请注意,由于它使用原始套接字,因此您的Python脚本将需要以root身份运行.

But note that since it uses raw sockets, your Python script will need to run as root.

这篇关于如何使用Python检查网络带宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆