How to provide separate network name spaces for android applications in android 7.0 AOSP?

456 views Asked by At

I am working on a rooted AOSP based Android product which is based on Android 7.0. This embedded device has a number of wireless networks (5 to be specific) of different generations (3G, LTE 4G, 5G,...) with different network operators (cellular companies).

As a final goal, we need to measure the network parameters (bandwidth, SNR, QoS, ...) for each of these network providers at the same time while running Android applications which use these different networks simultaneously. As an example we need to run multiple Whatsapp Android applications each of which use different network to connect to the internet.

What I have tried:

  • I was able to run multiple instances of the same application in an Android system (e.g. using something like Parallel Space). Unfortunately they all use the same internet connection.
  • All networks can connect to the internet at the same time. We can run Android shell commands like ping www.google.com on any of the interfaces successfully.
  • Also I have managed to use each of these networks to run Android applications: Using Android shell, I can create some Android networks each of which consists of any number of Linux networks (as back up for each others in the same group of networks, if you want to do so) and at the end set one of these Android networks (network group) as the default one. All Android applications will use this default network to connect to the internet. Here is a simple script to create an Android network with netId = 1:
# Add access for Android UI applications using 2 NICs: wwan0 and wwan1
ndc network create 1

ndc network interface add 1 wwan0
ndc network interface add 1 wwan1

# $IP0 and $IP1 are the dhcp provided IPs for wwan0 and wwan1
ndc network route add 1 wwan0 0.0.0.0/0 $IP0
ndc network route add 1 wwan1 0.0.0.0/0 $IP1

ndc resolver setnetdns 1 wwan0 8.8.8.8 8.8.4.4
ndc resolver setnetdns 1 wwan1 8.8.8.8 8.8.4.4

ndc network default set 1
  • Furthermore, I know how to do it (creating separate network name spaces) in a Linux environment and of course in our Andoid shell using ip netns exec command. Here we can run commands like wget or ping in these separate namespaces.
  • I can check dumpsys netd command to see the default set network netId and other defined netIds.

What I need to know:

  • Is there any way to use multiple networks concurrently with different Android applications to connect to the internet?
  • The provided solution may include using an Android application or writing a script or any changes to the AOSP source itself.
  • Can you kindly guide me to a reference book or ...?

Any help is highly appreciated.

0

There are 0 answers