Network test API

Hello, I was playing around with the Network line Conditioner in my application and it was really useful.


What I would like to do it add a Network bandwith test before my app begins to perform its work. Is there a API or a OpenSource class that will allow me to do this. My Google Foo is not really returning much help. Oh yeah must be Objective C, not Swift.


Thanks!

Are you looking more information about your network connections or the status of your network?


If you are wanting to know information about your network connections, take a look at NSURLSessionTaskTransactionMetrics. This gives you DNS times, TLS times, total end to end transfer times etc..


If you are looking for status of your network, take a look at NWPathMonitor. This provides an effective way to monitor and react to network changes on an interface.


Lastly, for using NSURLSession, take a look at using the property waitsForConnectivity on NSURLSessionConfiguration. This will tell you dataTask to wait until a path is active to send the request. Otherwise the session will fail immediately if offline.



Matt Eaton

DTS Engineering, CoreOS

meaton3 at apple.com

Thanks for the response. The nsurlsessiontasktransactionmetrics looks really cool and I will play around with that for future stuff.


None of these options will tell me what I want unfortunately. I guess another way to put it, if my bandwidth is less that 2mbps as an example. Then I don’t want to allow the download. I want to tell the user the link is too slow, and ask them if they really want to begin. I hope this makes more sense.

Oh yeah, it looks like NWPathMonitor is a Swift only API. I could not switch the docs to Obj-C

it looks like NWPathMonitor is a Swift only API

Network framework has a C API you can use from Objective-C. See

nw_path_monitor_t
in
<Network/path_monitor.h>
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Network test API
 
 
Q