7
votes

Is it possible in android to route all incoming data traffic through WiFi and all outgoing traffic via Mobile network.

Found an answer on stackoverflow How Wifi and Mobile Data both work simultaneously in android for OBD2 device. But it does route data for only one host.

There is also an app SuperDownload that uses wifi and mobile network to achieve faster download speeds. I'm trying to do something like this.

In android WiFi and mobile network does not work simultaneously. Is it possible to make it work by rooting the device? (SuperDownload requires root).

2
What you are asking is impossible in general. The reason is that the server you're connecting to on the far end only has the source IP address of your outgoing packets to respond to. And those will lead back to your mobile (uplink) interface. You would have to send packets with the source IP of your wifi interface and you can't do that.TvE

2 Answers

2
votes

It's not easy what you would do.

First in first you must keep on both network interface, this is possible but it's an hack because Android doesn't support it. To do it you must switch on

connectivityManager.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "feature");

The feature name is related to your hardware, it should be enableHIPRI. The problem is that after you switch on the interface this will turn down after some time, for this reason you must perform a http request every 20-30 seconds to keep it up. This way the interface will stay on.

To the route, you should add static route

connectivityManager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_HIPRI, ipAddressInt);

Where the ipAddressInt is the address that you want to connect on 3G. Normally the routes are sent throughout WiFi, so for your GET (download on WiFi) there is no problem, but you should add a route for upload.

And now there are 2 problems,

  • first is that in this way on 3G the DNS resolution is gone, you can work on IP but you must have a server with static IP,
  • second, I'm not sure if it works on a specific port (that is the only idea that I have in this moment to do it...).

Of course you should implement another thread that keep alive the interface.

1
votes

I think it is impossible at all. Think, how your destination can find the answers path to deliver it?

Let me to be more clear, when you are trying to fetch something from network (e.g. a web page), you should put your IP address and your destination IP address in a packet and send it to the network (wifi or 3g) and the network will route it to your destination. When your response became ready, the destination reverses the process and put your IP address as destination address and its IP address as source and frees it in to the network. Again, network by using this information will find you and deliver packet to you. So, you can never send information to a network (e.g. wifi) and receive the answer from another network (e.g. 3g).

Note: If all middle way routers became aware about your goal (sending and receiving to and from two different networks), it will be possible to do so. Currently, In some routing protocols specially in edge routers, that usually used by governments, something like your goal is worked to let they overcome the limited speed of transmission media e.g. fibre optic (to have more than 10/100 gbps).