0

I want ot redirect my iPhone data to either wifi or Cellular. Based on some criteria. Is it possible to redirect whole of the iPhone data to a particular interface like to either wifi or cellular. ?

I heard that this can be done using VPN but no idea how it can be done. Any help on this?

Dinesh
  • 929
  • 7
  • 25
  • 1
    If your phone is connected to a wifi network then it will use wifi. If wifi isn't available then it will use cellular. You cannot direct your app or the device to use a specific interface. – Paulw11 Nov 26 '18 at 18:41
  • Hi @Paulw11 as per i know Now iOS allows both connection to be active at same time. Look at MultiPath TCP it allows both wifi and Cellular data to be active at same time. So my guess is that inside VPN we can somehow redirect whole traffic to a particular interface. But than its a guess until someone not answered it. – Dinesh Nov 27 '18 at 09:33
  • You can use [multi path TCP](https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/improving_network_reliability_using_multipath_tcp) with `NSURLSession` as long as your server supports it but you can't redirect all iPhone data to a specific transport – Paulw11 Nov 27 '18 at 10:38
  • Hi @Paulw11 What if i get the IP Address of interface and add that Ip address to VPN routing Table? Do you think if this could work ? – Dinesh Nov 27 '18 at 11:41
  • No, I don't think that will work. A VPN won't help here. All a VPN does is tunnel traffic. It doesn't affect how the tunneled traffic is delivered to the VPN endpoint. I.e. the VPN will still attempt to use wifi if it is connected. – Paulw11 Nov 27 '18 at 11:51
  • Hi Paul Sorry for my weak understanding of VPN tunnel and network. But Doesn't VPN should send the packets to wifi adapter if i add a Route to wifi IP address and cellular if i add a route to Cellular IP address ? – Dinesh Nov 27 '18 at 11:59
  • You don't add routes to a particular interface addres with a VPN. You simply make a connection to the other end of the VPN. iOS will route packets to that other end just like it routes packets to a web server or any other network destination. It will choose the currently active network to do that; I.e. wifi if it available otherwise cellular. – Paulw11 Nov 27 '18 at 17:41
  • @Paulw11 i found this link https://superuser.com/questions/181882/force-an-application-to-use-a-specific-network-interface – Dinesh Nov 28 '18 at 10:31
  • and this one https://developer.apple.com/documentation/foundation/urlsessionconfiguration/improving_network_reliability_using_multipath_tcp – Dinesh Nov 28 '18 at 10:43
  • The superuser question refers to MacOS, not iOS. You don't have a console or any ability to manipulate the routing table on iOS. I gave you the link to multipath TCP in my second comment – Paulw11 Nov 28 '18 at 10:45
  • This is an API which allows to include routes in Network Extension. NEPacketTunnelNetworkSettings.iPv4Settings?.includedRoutes . IF it doesn't add Routes than what this API do actually ? Just asking for my Knowledge.. – Dinesh Nov 28 '18 at 11:22
  • It lets you add routes to the routing table to direct traffic over the tunnel that the extension establishes. It doesn't let you add routes that direct traffic toward the cellular interface directly. – Paulw11 Nov 28 '18 at 11:32
  • What if i provide wifi or Cellular IP address as Route address ? – Dinesh Nov 28 '18 at 11:50
  • You can't. You provide the destination network and a route for that network is added with the tunnel as the next hop. You can't specify the cellular or wifi interface as the next hop – Paulw11 Nov 28 '18 at 12:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184400/discussion-between-dinesh-and-paulw11). – Dinesh Nov 28 '18 at 12:06
  • It seems like this is possible as There are apps such as speedify is doing the same thing. They are sending data to both cell and wifi interface concurrently. I am not sure how they achieve this but i think this is do-able. just we don't know the way to do this. – Dinesh Dec 12 '18 at 17:02

1 Answers1

1

By default, iOS help you with redirection when you have weak/good WiFi and switch on in Setting - WLAN Assist

MultiPath is a technology switching automatically by OS

Just read this Apple Doc for more help.

You can't manipulate it easily with high level API.

After all, changing device data flow is kind of low level thing. Just like NetworkExtension is Apple provided. As far as I know, Apple does not mention it in public.

Frank
  • 320
  • 1
  • 8
  • Speedify is redirecting the data flow to a particular interface. Infect they are using both interfaces at same point of time. So as per me it is possible. Just we don't know about how to do this.. – Dinesh Dec 20 '18 at 10:09
  • 1
    Maybe you should try some low APIs, just like CFNetworking. VPN is only the way to redirect to your tunnel. In your own tunnel, split the tunnels by proper algorithm. Using your own NetworkingKit maybe success. – Frank Dec 21 '18 at 13:12
  • Now you are correct frank. You can do this but you have to use low level sockets and its doable thats why there are apps who has actually done this. – Dinesh Dec 21 '18 at 13:34