Possible Duplicate:
Iphone detect 3g or wifi
is there a way to get the current network speed or if the device is on EDGE/3G/GPRS? I can use Reachability to distinguish WiFI from WMAN but that's not enough for my application.
Possible Duplicate:
Iphone detect 3g or wifi
is there a way to get the current network speed or if the device is on EDGE/3G/GPRS? I can use Reachability to distinguish WiFI from WMAN but that's not enough for my application.
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.
© 2022 - 2024 — McMap. All rights reserved.