Regarding network interface name with dual SIM iPhone

I investigated what network interface names are assigned to carrier networks on a dual SIM iPhone by examining the output of getifaddrs(). (An part of the program used for this is provided below.)

//////////////
struct ifaddrs *interfaces = NULL;
struct ifaddrs *an_interface = NULL;

if (0 == getifaddrs(&interfaces)) {
    an_interface = interfaces;
    while (an_interface != NULL) {
        if( an_interface->ifa_addr->sa_family == AF_INET) {
            NSString* name = [NSString stringWithUTF8String:an_interface->ifa_name];
            NSLog(@"Interface name is: %@", name);
        }
        an_interface = an_interface->ifa_next;
    }
}
freeifaddrs(interfaces);

In this investigation, it appeared that the interface name for the sXGP SIM selected under "iPhone > Settings > Cellular > Cellular Data" was always "pdp_ip0". (A screenshot of "Cellular Data" is provided below. this is sample of sXGP selected )"

[QUESTION]

Is the SIM selected in Settings of iPhone always assigned to "pdp_ip0"?

[BACKGROUND]

I am developing a VoIP application and opening sockets by specifying IP addresses for communication.

On a dual SIM iPhone, multiple networks (IP addresses) are visible. Therefore, I need to determine which network to use. My question is whether I can reliably make this decision based on the network interface name.

If the SIM selected in Settings is always assigned to "pdp_ip0", I intend to open the socket using the IP address of "pdp_ip0".

Alternatively, should I use a different method to select the appropriate network interface?

Answered by DTS Engineer in 855813022
Is the SIM selected in Settings of iPhone always assigned to "pdp_ip0"?

BSD interface names are not considered API on Apple platforms. You should not make assumption like en0 is the built-in Wi-Fi, or pdp_ip0 is the primary WWAN interface. Doing that will likely work in most cases and then your program will fail in hard-to-reproduce edge cases.

I have a lot of information about dealing with multiple interfaces in the various posts referenced by Extra-ordinary Networking. I recommend that you read those first, and then come back here with your follow-up questions.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is the SIM selected in Settings of iPhone always assigned to "pdp_ip0"?

BSD interface names are not considered API on Apple platforms. You should not make assumption like en0 is the built-in Wi-Fi, or pdp_ip0 is the primary WWAN interface. Doing that will likely work in most cases and then your program will fail in hard-to-reproduce edge cases.

I have a lot of information about dealing with multiple interfaces in the various posts referenced by Extra-ordinary Networking. I recommend that you read those first, and then come back here with your follow-up questions.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for your previous response to my question which directed me to the Extra-ordinary Networking documentation. We have thoroughly reviewed this documentation and related articles, but have yet to find a direct solution to the specific problem we are facing.

Our VoIP application is currently being operated in a customer environment utilizing an sXGP-SIM (local LTE-SIM). A specific requirement from our customer is to "always use the data communication network, rather than the voice call-specific VoLTE network, for establishing SIP and RTP traffic."

What we know from our investigations so far:

  • In the customer's sXGP environment, we have confirmed that the VoIP application (client) can successfully connect to the SIP server (server) and conduct VoIP calls (RTP), regardless of whether the connection routes through what might be conceived as a VoLTE network or a general data communication network.
  • Following general best practices, we considered an approach where we do not explicitly call bind() when creating sockets, but instead rely on the OS for route selection (i.e., using connect() and then getsockname() to retrieve the local IP address).
  • However, with this method, we believe it is not possible to control whether the OS-selected route becomes a VoLTE network or a data communication network, nor is it possible for the application to programmatically identify the type of network used. Given that both presumed network paths are viable for reaching the target server in the customer's environment, we cannot rule out the possibility of the OS selecting a VoLTE network path.

We are seeking clarification on the following two points:

1. Identification of VoLTE vs. Data Communication Network

Is there an existing iOS API (including Network Extension Framework, Network.framework, or other lower-level APIs) that allows an application to programmatically determine whether the current network path is a logical path assigned for VoLTE, or a logical path assigned for general data communication?

2. Forcing Traffic Routing to a Specific Network Path

Similarly, is there an API or mechanism that allows a VoIP application to explicitly force its SIP and RTP traffic to route through a path identified as a "data communication network" and not a VoLTE network?

Our team understands that implementing these features via public iOS APIs might be challenging. However, to provide a definitive answer to our customer, an official statement from Apple, especially confirming if "it's currently not feasible with iOS APIs," would be highly valuable as evidence for guiding our future development and customer communication.

If such APIs or recommended design patterns do not exist, a clear confirmation of this would be greatly appreciated. Conversely, if it is indeed possible, could you please provide hints on the specific APIs or approaches?

Thank you for your time and consideration.

There are two questions here:

  • How do you force a connection to run over a specific interface?
  • How do you identify the correct interface?

The answer to the first is straightforward:

  • For Network framework, use the requiredInterface property.
  • For BSD Sockets, using IP_BOUND_IF (IPv4) or IPV6_BOUND_IF (IPv6) socket options.

The answer to the second question is trickier. It’s easy to get the interface list and filter it down to just the WWAN interfaces. Distinguishing between WWAN interfaces is hard. iOS doesn’t provide a general mechanism for that.

It’s clear that you’re working with a customer who has very specific requirements, and it’s possible that you might be able to craft a solution that’s specific to those requirements. The most obvious solution is for them to change their server so that it’s only available over the sXGP-SIM network. That way there’s no possibility of the traffic ‘leaking’ regardless of what you do in your app.

Even if that’s not possible for the real service, you could stand up a dummy service that’s only available over the sXGP-SIM network. Your app could then try to connect to the dummy service over each WWAN interface, and then use the one that works for the real service.

If you have to do this entirely on the client side, things get harder. You could make it a configuration option [1], or apply heuristics [2], or some combination of the two [3].

Regardless, I encourage you to limit such techniques to the specific customers who need them. That way your normal customers won’t be affected by whatever ‘hacks’ you apply for this specific customer. So:

  • If this customer uses managed devices, you could enable this technique via a managed configuration option. Your app can read such options using the ManagedApp framework.
  • If not, you could add a ‘hidden’ preference for each user to enable.

IMPORTANT If you add a hidden preference, make sure App Review knows about it by calling it out in the reviewer notes.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] The most obvious configuration option is to push down the BSD interface name, but that’s problematic because there’s no guarantee that this will be consistent across devices.

[2] For example, if the sXGP-SIM network always returns IP addresses in a specific range, you could look for an interface whose address is in that range.

[3] To extend the previous example, it’s possible that the IP address range could be different for each customer, so you could make that a configuration option.

Regarding network interface name with dual SIM iPhone
 
 
Q