Search code examples
pythonpython-3.xaiohttp

how could I test a network bandwidth and latency using async python?


I have been looking for a way to test a network bandwidth in python. I had found the module of speedtest-cli but that module is only sync where I need an async solution and it also doesn't support the use of proxies either. Should I time the time it takes for a connection to be completed with aiohttp for it latency or is there a better way?


Solution

  • Hmm.. Nothing that I am aware of. You can setup a simple test with similar results by yourself though, all you need to do is upload & download files on a remote server (I would recommend using a vps since they have stable and fast network speeds), and divide their size per transfer time. For the async part, you will just have to use asyncio

    Look for generating random bytes to save in IO buffers, and post/get using aiohttp (Posting explained Here) to a server you can setup like on this page. That would be my way of doing it, Have fun !

    Note: The bigger the test file is, the more accurate the results will be