iOS Detecting connection speed or type [duplicate] iOS Detecting connection speed or type [duplicate] objective-c objective-c

iOS Detecting connection speed or type [duplicate]


If you really need to know, you will have to test for it.

Setup a connection to a known server that has low latency. In a separate thread, mark the time (Time A) and send a packet (make sure it's one packet). Wait on that thread. Mark the time of the first packet (Time B). Read the data until finished. Mark the time of the last packet (Time C). Make sure the server response spans at least three packets.

Time B - Time A is a very rough estimate of latency.Time C - Time B is a very rough estimate of bandwidth.

Because you want to be accurate as possible, use the lowest level of network access you have available (I believe on the iPhone this is sockets). Use random data blocks of fixed lengths as both your request and response. A few bytes for the request should suffice, but the response needs to be well constructed. Make sure the server sends a small first packet, then a sequence of packets that is large enough to fill three or more.

At that point you will need to test. Test, test, test, and test. Test on the different network types, test with different amounts of network traffic, test with switching networks, and test anything else you can think of.