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

1

10

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?

Tearing answered 1/6, 2013 at 2:11 Comment(2)
Facing the same problem here — did you find a solution?Dwt
Same issue for every one who use to check network connectivity using Reachability. For me also.Lussier
F
3

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.

Fruitarian answered 4/3, 2015 at 14:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.