Android - How to measure bandwidth quality within local network with just one phone
<p>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. </p>

<p>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.</p>

<p>So far, these were our attempts:</p>

<ol>
<li>Starting an http server and a client</li>
</ol>

<p>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.</p>

<ol start="2">
<li>Integrate iPerf into our app:</li>
</ol>

<p>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. </p>

<ol start="3">
<li>Using the open source lib for connection speed checking provided by Facebook.</li>
</ol>

<p>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.</p>

<ol start="4">
<li>Tried searching for how to disable the loopback when downloading a file from same device.</li>
</ol>

<p>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. </p>

<p>So, our question is:</p>

<ol>
<li><p>If our first attempt is close, then how can we disable this loopback thing so that we can properly monitor the download speed?</p></li>
<li><p>If our first attempt is not good enough, then is there any other way that we can do to test the bandwidth locally?</p></li>
</ol>

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

<p>Thanks in advance!</p>