Yue Zhang
Yue Zhang

Reputation: 201

How can I get the iPhone's current network speed?

I want to get the iPhone's network speed so that I can give user an info when the speed is too slow.

Upvotes: 6

Views: 2541

Answers (3)

Jano
Jano

Reputation: 63667

In the ZDS_Shared cache they put each download operation on a NSOperation and then calculate based on size and time. See calculateBandwidthForDelegate:. Then they set one of three possible network states and throttle downloads accordingly.

Upvotes: 0

Dolph
Dolph

Reputation: 50650

Remember, the iPhone is a wireless device, and likely on the move. The network speed can (and will) vary drastically from moment to moment, so measure average throughput over at least 20 seconds or so... that's basically how the "bars" work. If they were updated in real time, they would be bouncing all over the place.

Upvotes: 3

bbum
bbum

Reputation: 162712

Net speed is gonna vary radically depending on a huge passel of variables between the iPhone and whatever server you are trying to connect to.

You are far better off adapting your behavior on the fly based on whatever data flow rate you happen to be enjoying at any given time.

Kinda like how Netflix automatically adjusts video quality as the network connection quality changes over time.

Upvotes: 1

Related Questions