schmittsfn
schmittsfn

Reputation: 1442

Is it possible to manipulate network quality on the device programmatically?

Is there a way to simulate different network conditions on an iOS device programmatically?

iOS provides us with the Network Link Conditioner, but I couldn't find a way to access it programmatically.

If there is no way to manipulate network quality directly, is there a way to simulate it indirectly?

Packet Loss:

Bad Latency:

Update:

Upvotes: 1

Views: 452

Answers (1)

David Hoerl
David Hoerl

Reputation: 41682

For my unit tests, I created a small bit of code to do this (under command of the UNIT test). The idea is that wherever you have code that finally dispatches a request to say NSURLConnection, you randomly just don't submit it, and dispatch a "fake" return after some number of seconds with an error of "Timed Out". Likewise, you can instead of immediately dispatching the connection, you put it in a dispatch_after block, and add either a fixed or random delay.

The above is just a handful of code and can be easily implemented. I have mine conditionally compiled (that is, its behind a MACRO that gets defined when for just UNIT Tests).

Upvotes: 0

Related Questions