Help me understand what I am seeing when testing Reachability code using the Network link conditioner. Here is my vanilla Reachability code:
Reachability* wifiReach = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain];
NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
NSLog(@"Access Not Available");
break;
}
case ReachableViaWWAN:
{
NSLog(@"Reachable WWAN");
break;
}
case ReachableViaWiFi:
{
NSLog(@"Reachable WiFi");
break;
}
}
Now, when I test this code using the Network Link Conditioner using the "100% Loss" preset - the value of netStatus
is ReachableViaWWAN
, which I wasn't expecting. I read a lot of complaints that Reachability doesn't really test connectivity, rather it tests the potential of connectivity. So here's my question:
Is the "100% Loss" preset allowing the DNS requests to the Apple server pass through, but not letting any packets through?
This might have to do with the fact, that Reachability doesn't guarantee that a packet can actually reach the target host. It is about the local network configuration (interface up / down) and if it can SEND a packet.
From Apple's SCNetworkReachability Reference:
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.
So if the interface is up and Reachability can send a package, it is satisfied and returns status reachable.
From Apple's developer guide Why Networking is hard:
Important: The SCNetworkReachability API is not intended for use as a preflight mechanism for determining network connectivity. You determine network connectivity by attempting to connect. If the connection fails, consult the SCNetworkReachability API to help diagnose the cause of the failure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With