Simple speed test app on Android suggestions

Can anyone point me to any sample code which explains (even slightly) how to write a simple wifi speedtest program for Android? I have looked everywhere!

Thanks in advance!



It's not easy. Let me give you some suggestions but you will need to investigate more.

I'm not sure whether it is possible to access low level metrics of the WiFi connection or a 3G connection. Supposing it's not possible, my suggestions are oriented to use a ping or a ping-similar solution with some server and obtain the round-trip time (RTT).

Now, when you connect to a server, there are many factors affecting the RTT, these are the main ones:

  • WiFi speed, congestion, and communication errors
  • Latency in the whole path to the server, including ISP capacity and backbones.
  • Congestion in the path
  • Server speed to respond

Usually you execute a ping to test reachability and a taste of RTT. Ping is implemented with ICMP Echo Request. However, Java does not provide the means to send an ICMP message. So you might try to establish a TCP connection to some server.

You could use InetAddress::isReachable with a timeout various times until you find out the limit timeout. I wouldn't recommend this.

I would create a TCP socket and call connect and then determine the time it took since connect was called. Of course you have to deal with all factors that affect speed.

Another point to consider is that if you use connect in a TCP socket, you have to understand that there is actually a three-way handshake: client sends a SYNC, server sends SYN/ACK, client sends ACK. But this last ACK doesn't add significant time to the return of connect because it's just sent by the client.

Having said that, I'll go with some suggestions:

First thing I would try, only with a WiFi, is trying to establish a connection to the access point, to port 80, 8080 or 443. That would eliminate other the last three factors.

If it doesn't work you could try a fix server, for example. In this case you will have to deal with all the mentioned factors.

In the case of 3G, I don't know how you could could establish a connection to the access point like a Gateway GPRS Support Node in UMTS. But you can connect to a fix server, considering all 4 factors mentioned above.

Other point to consider si that when the smartphone has connectivity to WiFi and Cellular, it always uses WiFi. There are ways to force it to use 3g though, some links: Android: Force data to be sent over radio vs WiFi Force Android to use 3G when on local area wifi without net access

I hope this helps.

Need Your Help

NDB Query not returning full object

google-app-engine datastore app-engine-ndb

I am doing a NDB query, which seems to only be fetching a partial object. For the Model, I've turned off caching, in case that was it. However, a number of properties are coming back with None, w...

How to calculate the slope of a point on a terrain data (e.g. Digital Elevation Matrix)

terrain racing linear-interpolation

I want to implement a 3D car racing game and I need to approximate the magnitude and the direction of the slope of any arbitrary point on a terrain.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.