How to calculate connection speed - android

I'm developping a radio app and I need to know if the user's connection speed is fast enough, if it's slow I'll show a message saying that the streaming may be slow sometimes.
The problem I'm having is in calculate the speed connection from the user.
I've read some opinions about that and I only found answers based on internet type (2g, 3g, wi-fi). I found this answer : Detect network connection type on Android that is almost what I needed, but the method "isConnectionFast" isn't accurate because it doesn't make a real test connection, it's just based on some properties.
I think that the best way is to download an image with a determinated size and calculate the time that took to finish the download. But I'm not knowing how to do that in android.
Can anyone help me ? Thank you

Well it seems that you already know the basic steps for doing a speedtest but I would like to explain why is that probably a waste of time in this case.
If we're talking about cellular connections there are standards that specify the speed and the answer you linked is an example of how to get an estimate based on that. Sure, you will never get the full speed and the speed test would provide a better estimate but just for that moment in time. There are many factors which may influence client's speed and most of them are changing every second so the test you made at the beginning is pretty much useless if the client is mobile. For wifi estimating the speed is a bit harder without a speedtest because the bandwidth is usually not limited by the technology but the plan user is paying for. Anyway those speeds are almost certainly enough for a radio stream.
You didn't provide much info about the streams itself but from my experience (as a user) for 128kbps streams everything above EDGE is sufficient, providing your buffering is enough to compensate for short speed degradation or connection losses caused by handoffs etc.

Related

Code's influence on download speed

With respect to mobile development, I'd like to know whether the rate at which something is downloaded from the internet can be affected by the app making the http request. I assume that download speed is most affected by hardware. If code can affect download speed, what are some performance tips to download something as fast as possible most of the time?
In all communications, you are limited by your bandwidth. Mobile platforms tend to be much slower than wired connection. So the solution is simple, make the download amount as small as possible.
This is, of course, easier said than done. It tends to take some creativity to get a network bound application unbound. However when you are able to, you can see very impressive/unbelievable gains in performance.
I'm your case, it is good to think about it up front, but also consider it as the app is developed.
Ps: some general rules of thumb
Network accesses: on the order of 10 millisecond
Disk access: on the order of 10 microseconds
Memory access: on the order of 10 nanoseconds
Cpu cache: on the order of 100 picosec
This is a little bit more than you asked for, but you can clearly see why it would be faster to compress data, send it and uncmpress it then to just send it.
As Robert said, it's more likely than not the network that's limiting you, rather than the code itself. It IS possible to intentionally throttle download speed in multiple languages, but I doubt the code is the cause.
Think instead about how you might cut down your application's size. Think hard about reusing assets, pulling some data from a webserver if possible, etc etc.

Is about 0.5 seconds of latency a usual thing in mobile gaming multi-peer networks?

So I have been experimenting with multi-peer networks. Ultimately I am going to try to use different frameworks to make one that can connect devices of same os through Bluetooth and WiFi, and ones of different types through wifi.
My first shot was apple's Multi-peer Networking. Unfortunately I got had about 0.5 seconds of delay (I didn't actually calculate this just an estimate) before even one bit of information actually got to the other device. I am suspicious that the framework is optimized for larger and encrypted data way more then it is for 1-32 bit jobs.
I was just wondering what you guys knew about the latency of other frameworks out their, since it takes a decent chunk of time for me to learn how to use each new framework. Is latency of about 0.5 seconds the best the industry has?
Honestly I would be happy if their was a library that was optimized to send 1 bit to each connected device every (1/60th) of a second. But I think most of these networks package up the data like its of bigger size anyways.
I sorta wish mobile devices had NFC. Just look at systems like the 3ds that can do multi-peer multiplayer (smash-bros) with really really small latency and great accuracy.
Try changing the MCSessionSendDataMode to MCSessionSendDataUnreliable
MCSessionSendDataUnreliable
Messages to peers should be sent immediately without socket-level queueing. If a message cannot be sent immediately, it should be dropped. The order of messages is not guaranteed.
This message type should be used for data that ceases to be relevant if delayed, such as real-time gaming data.
but depends how reliable you really need the data to be, but on a closed network, it should be very reliable anyway

Android distance between devices (very accurate)

I am building an application that requires to check when is a certain device very close to another device (by very close i mean 5-10 meters). I think it could be possible using bluetooth RSSI. A lot of people suggest the use of sound analysis, but this won't be possible because i am planning to use many systems like this in the same place, so that will mess up a bit. Any suggestions?
Accuracy requirements rules GPS out - so your only option is to measure delays in signal propagation of devices. I would say that network / bluetooth is not suitable for this due to speed of light and network stack delays which are not predictable. This means that yout only option will be sound. 5-10 meter means 10-20 msec delay at speed of sound so this should be sufficient, buit will be tricky to imlpement.
To work with multiple devices you will have to implement some protocol like CSMACD and kind of time synchronisation between devices - this is possible but tricky ( you will have to look up how time is synchronized via satellites for radioastronomy )
I recommend using RSSI :-). This makes sense if you want to measure the distance b/w 5-10 meters.

Android: Reasonable upload speed on 3G

What upload speed should I expect to be available to my users? This is for image attachments to emails.
A test we did over the phone for one user came out to about 100 kilobits per second.
The reason I ask is I am not sure if my unloader is creating an unusual amount of latency (edit: I mean time wasted between actual upload of a chunk). It uploads in parts using separate HttpPost requests and it base64 encodes the parts and sends them as POST parameters instead of using a "multipart file upload" like a browser would do.
This is the only test I have done with an end user and I don't actually own an Android phone.
100 Kbps does not seem so bad. The actual max speed for UMTS is 384 Kbps, but I never saw more than 250 Kbps, and that's with a very good signal. HSUPA speeds, on the other hand, can be 10 fold faster, but there are just a few phones in the US supporting it, with a lot more in Europe. Given the really big variability in speed due to signal issues, my guess is that it won't be a bottleneck in your software. You should, nevertheless, consider that phones can get into 2g zones still or even loose signal in the middle of the transfer. A failure due to a loss of signal is a much worst problem for the end user than a couple more seconds waiting for the transfer (which, anyway, should be done in the background).
Regardless if for upload or download, data transfer speed over 3G can vary a big deal depending on how close or far the user equipment is from the base station transmiting nearby and depending on the conditions he is regarding that base station... buildings nearby, inside building or outside, interference, and so on and so on. Also, the modulation used will depend on this, which will greatly change the connection speeds for users in different conditions.
In any case, the speed you get for the data transfer and the latency are two different things.
I'm not sure of the implications in your specific application and the Http protocol, but you mention separate requests. So it should work.

Latency on mobile networks (Android)

I am planning to give mobile phone development a shot and was thinking about making some simple multiplayer games. I know latency over local wifi is probably fine but what are the issues with latency over GPRS/3G?
I've searched and the best I've seen is someone saying it was 'high', without presenting any concrete numbers. I suppose latency fluctuations are important as well - does anyone have any info on this?
From my laptop with a UMTS/HSDPA card to my web server I get a ping time of 100ms (both are in Germany).
I've seen the same 802.11 link with the same hot-spot jump from ~80ms to 3000ms and back. Assume latency suck and write the program to deal with it.

Categories

Resources