Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Reachability with Network Link Conditioner on 100% packet loss: help me understand what's happening

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?

like image 524
Matt Miller Avatar asked Jun 01 '13 02:06

Matt Miller


1 Answers

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.

like image 82
wrtsprt Avatar answered Nov 12 '22 12:11

wrtsprt