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:
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.
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.
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.
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:
If our first attempt is close, then how can we disable this loopback thing so that we can properly monitor the download speed?
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!
The API enables you to determine whether the device is currently connected to a network that satisfies your app's requirements.
This also is a good resource for detecting bandwidth on one phone
https://github.com/facebook/network-connection-class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With