Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - How to measure bandwidth quality within local network with just one phone

Our app serves as a controller for our Wi-Fi enabled devices. Sometimes, when the local network traffic is terrible, it is hard for the devices to receive the command that the controller app sends. If this happens, we need to notify the user that the network traffic is terrible and tell the user to switch to another router.

We do have a heartbeat with the devices that we are going to control. However, the problem might occur without even reaching that stage. I mean that, first of all our app needs to search for the devices by sending UDP packets to a multicast address. Then after we receive the response from those devices, we then create a connection between them. That is the time we can get the heartbeat. The problem I am talking about is even at the stage of just searching for the devices, if the network traffic is terrible, our device will not be able to receive the UDP packets that we sent.

So far, these were our attempts:

  1. Starting an http server and a client

We started a lightweight http server, placed a file there. Then we create a client and download that file, and monitor the speed. But this seems to be not working because there is a loopback. The device sees that the two sides(http client and server) are of the same zone(maybe the term is wrong) so maybe the download didn't even pass the router.

  1. Integrate iPerf into our app:

The downside of this solution is that the device needs to be rooted. But still we tried iPerf's solution. We tested it with both client and server in the same device. But still the speed is not changing. If we test in two devices, one as server, another as client, then we get a good speed test. However, we cannot as our client to use two phones for our product, and we cannot ask them to root their phone either.

  1. Using the open source lib for connection speed checking provided by Facebook.

We found an open source lib in github that checks for the connection speed quality. However, this requires internet connection in order to check the speed. But our product doesn't require user to have internet connection. The user just needs a router and an app. So, unfortunately, we cannot use this solution.

  1. Tried searching for how to disable the loopback when downloading a file from same device.

Based on our first attempt, which is the only solution that we built by our selves. we tried to check in the documentation if there is anyway to disable loopback when downloading a file from same device. Unfortunately, we did not get any good result.

So, our question is:

  1. If our first attempt is close, then how can we disable this loopback thing so that we can properly monitor the download speed?

  2. If our first attempt is not good enough, then is there any other way that we can do to test the bandwidth locally?

Note: There shouldn't be any internet connection and not more than one phone should be used.

Thanks in advance!

like image 739
JLT Avatar asked Dec 17 '16 04:12

JLT


People also ask

Which system service can you use to determine if there is an available network connection in your app?

The API enables you to determine whether the device is currently connected to a network that satisfies your app's requirements.


1 Answers

This also is a good resource for detecting bandwidth on one phone

https://github.com/facebook/network-connection-class

like image 116
reidisaki Avatar answered Nov 10 '22 16:11

reidisaki