Network Link Conditioner can not work together with Reachability? - ios5

Network Link Conditioner is the develop tool provided by Apple, but seem like not work together with the other tool Reachability.
Network Link Conditioner is the tool to simulate 3G/Edge/Wifi network cases.
Reachability is to recognize the different network cases.
Anyone has such experience to make them work together ?

You shouldn't have any issue with Reachability since it really just tells you whether or not you have a network connection, not how well it is functioning. The only difference is between Wifi and Cellular, not between different speeds or cellular connections.

Reachability doesn't test the speed of the network to determine what kind it is. Reachability is about availability of interfaces (airplane mode vs. not, wifi on / off).
Important note:
A remote host is considered reachable when a data packet, sent by an application into the network stack, can leave the local device. Reachability does not guarantee that the data packet will actually be received by the host.
From Apple's SCNetworkReachability documentation.

Related

Can I use only cellular network (3G or EDGE), even if WIFI is connected on the iPhone?

I was wondering whether I can use the cellular network (3G or 2G or whatever they may have) even if the WIFI is connected and working.
I noticed that Apple has a "Reachability" sample code, but that would only tell me if I can connect using a cellular network; instead, I would like to actually use ONLY the cellular network.
Best Regards,
Noam.
Definitely YES. You should combine Reachability notifications with network interfaces enumeration. And - this point is much important: use BSD socket's bind() call to bind to CONCRETE IP address. Don't use 0.0.0.0 and your app will be network-adaptive and awaring. My poor gist example: https://gist.github.com/avesus/fdb465b60a4f5204845c
No, I wouldn't imagine so.
My understanding is that if the device is connected to Wifi, 3G is not used for data and all data traffic travels via Wifi.
Only cellular data to another cellular device would use the phone provider's network.
I believe that the only way to accomplish this would be to detect if the user is on WiFi (example code is in the "Reachability" example you cited), and if so, prompt them to disable WiFi prior to using your app.

iPhone, NSData, wifi vs. cellular network

I'm working on an application that downloads some data from the internet using NSData's initWithContentsOfURL method. At startup I'm using some code from Apple's Reachability sample to check if a wifi connection is available; if not, then the app just shows an error message and refuses to really start (as requested by my client). All is working fine on iPod and iPad, but on iPhone, my client reports much, much slower download speeds, unless he turns on airplane mode, in which case download speeds are on par with iPod / iPad speeds. So it seems that even though a wifi connection is available, the iPhone is probably using the cellular network to download the data. Which is really weird. Does anyone have any idea about what I might be doing wrong?
I believe your answer is SCNetworkReachability which you already have access to since you are using Apple's Reachability code.
The SCNetworkReachability API allows an application to determine the status of a system's current network configuration and the reachability of a target host. One of the flags returned by the API, kSCNetworkReachabilityFlagsIsWWAN, will tell you if a network connection to the target host uses the carrier network. The Reachability sample code shows how to determine the active network connection.
You could also use this to enforce WiFi if that's what you want.
Have a look at UIRequiresPersistentWiFi

Forcing a WWAN connection on iPhone, even when Wi-Fi is available

I need to make a network connection over WWAN (i.e. the mobile network) on an iPhone, even when the device is connected to a Wi-Fi network, however I can't find a way to do this.
I've tried going down to the socket level and iterating through the available interfaces, however when connected to Wi-Fi, the WWAN interface (pdp_ip0) disappears.
The solution needs to be App Store safe.
Enumerate the network interfaces, you will see that when you're connected on both wifi and 3g, there are 2 with different local ip addresses. You might be able to use one vs the other by forcing a bind of your socket on the right interface before sending the data. The kernel which tries to find the best interface to route your packet should be happy with your choice.
Disclaimer: I have not tried this, this is just a suggestion.
Perhaps you can use the Reachability code to determine if Wi-Fi is enabled, firing a UIAlertView to warn the users to quit the app, open the Settings app and switch off wireless manually. Not ideal, definitely.
There is no supported way to to do this. You need to tell the user to turn off the WiFi connection since "It's a non-negotiable operational requirement for the service the app needs to connect to."
In this scenario, the user is not likely to kill you with bad reviews if you are clear about why they have to disable WiFi.
-t

How does iPhone app communicate with other devices?

We bought a Grace wifi radio. Grace has a cool iPhone app that connects to the radio and lets you control it.
My question is.. how the heck does this work? How can the iPhone connect to the radio and then control it??
I can't find detailed technical information on Grace's side, but, if I were asked to design something like this, I'd have the radio advertise a service on its wifi LAN via zeroconf (also known by Apple's trademarked name, bonjour -- an app on the iphone (or any other node on that wifi LAN) can then easily find the radios on the same LAN and chat with them through whatever protocol Grace has defined for the purpose.
Edit: from the scarce crumbs of docs on Grace's site it seem they may have chosen UPnP instead of Zeroconf -- ah well, see here for a (possibly biased, but solid) analysis of why they should have chosen Zeroconf instead!-)
Are you asking coding specifics or just an overall concept of what's going on? The actual networking stack behind these operations can be quite complex.
Your Grace wifi radio will have created a server which the iPhone has connected to on your wifi network, from this point onwards it's a simple client-server relationship, with the iPhone sending data to the radio each time it sends a command. Because of this, if your iPhone is not on the same wifi network it will not be able to control/find the radio.
Most likely, the WiFi radio listens over a fixed UDP port. The iPhone in turn sets up a UDP connection by broadcasting the network (on IP 255.255.255.255) on that port. The radio will respond and a connection will be established.
This is complete speculation; I have no idea how it actually works. No doubt there is plenty of documentation on this.

How to list all devices in my wifi range in iphone

I am using the reachability code from apple to find if my iphone is connected to the wifi. Next i would like to list all the devices that are in my wifi range. How should i do this. The other devices do not publish any service. I want to detect all devices in my wifi range and send that device a request for tcp connection.
If a device does not advertise its presence and is not otherwise active, TCP/IP does not give you a way to "detect" it. If you can identify your subnet (which has nothing to do with a "wifi range", whatever that may be), you can try connecting to each possible host in it on all possible ports -- this is generally considered an attack (what legitimate reason could you have for such a port scan?), so, if you're detected trying this attack, be prepared for the consequences.
As #Alex says, even if you could find devices that weren't advertising, what's the point? You can't most likely do any adhoc communications with them. Instead you'd need to find copies of your application running on connected devices, and your app needs to advertise.
Take a look at Gamekit sample projects which will give you bluetooth connectivity, and you could dig into something like Jens Alfke's MyNetwork and Blip libraries for tcp/wifi. http://jens.mooseyard.com/2008/05/blip-come-n-get-it/