PDA

View Full Version : Find download/upload Internet speed programmatically.




mycompuser
Aug 8, 2012, 03:27 AM
Hi All,

I have an cocoa application developed in Lion using XCode 4.3.2 and used to connect to an wifi hotspot. I need to determine quality of the connected network in my app.

I would like to know the way to determine programmatically the internet quality namely internet download speed and latency. (upload speed and packet loss will also be of great help too).

I have a constraint that the api call must not be synchronous (blocking). Is there an mechanism by which I can initiate an upload/download of an file and periodically sample the current speed of upload/download and also latency so that I can monitor for the same and update in my UI.

I tried googling for the same and found an curl command which contains the few of the required parameters

curl -o /dev/null http://speedtest.wdc01.softlayer.com/downloads/test.zip

But the problem with this is that it continues till the entire file is downloaded. Is there an alternative call which is async and I can abort as per my need?

Can I use http to achieve the same? If so could you please direct me on those lines?



robvas
Aug 8, 2012, 08:24 AM
I think NSURLDownload has delegate methods that will tell you how much data has been downloaded, so if you compare that with system time you should be able to figure out the speed

http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLDownload.html#//apple_ref/doc/uid/20001839