Simulating network speed and latency for Android devices

Download 26.04 Kb.
Size26.04 Kb.

Simulating network speed and latency for Android devices

First, let us define speed and latency:

Speed: This is the perceived speed of a network connection we all experience. It is usually assumed the result of bandwidth (such as a 2 Mbps connection vs 512 Kbps connection). Bandwidth is the maximum data rate supported by a connection.

Latency: It is the time from the source sending a packet to the destination receiving it. A good example would be a satellite internet connection. It has a high bandwidth and also a high latency. A delay of 500ms is considered normal in satellite connections (<25ms latency is ideal for DSL connections) Even though the network has high bandwidth, a webpage would take a few seconds to start loading and quickly load completely after that. The delay here is due to latency and not bandwidth.

latency and bandwidth

Latency can be because of propagation delays such as satellite or transmission delays due to the physical properties of the medium used for communication.

Having dealt with the concepts of speed and latency, we will now see how to test Android applications on different networks and see how our applications to conditions similar to those of actual use.

Android SDK ships with device emulator. The emulator can be found in the android-sdk /tools folder of your SDK directory. A virtual device can be created that emulates the phone. Android Virtual Device or AVD for short can be launched both from command line and from within Eclipse IDE.

  • Every AVD is assigned a separate port, starting from port number 5554

  • Any AVD runs behind a firewall and is shielded from the network on which the host system runs. The IP address assigned to emulator’s gateway, primary DNS (as well secondary and tertiary), and each instance of AVD, has an IP address of scheme 10.0.2.X

To manipulate network of the emulator, we need to set up redirection. In this tutorial, we will do this via command line after connecting to an AVD’s console. There is another method which can be used using Android Debug Bridge (ADB). Once you are comfortable with command line, you are welcome to explore the method using ADB.

Following steps need to be taken:

  1. Create AVD

  2. Run AVD

  3. Enable Telnet (for Windows 7 or 8)

  4. Connect to AVD’s console

  5. Set up redirection

  6. Change network speed and latency

Step 1: Create an AVD from Eclipse or Device Manager

Step 2: Run AVD

You can run via right clicking project > Run As> Android Application


You can ran via command line

tools> emulator @

Don’t forget to ‘@’ symbol otherwise the emulator tool would give an error. You can also give network command here at the time of starting the AVD or continue with the rest of the tutorial to issue commands to an already started AVD.

For setting speed at start up:

emulator @deviceName -netspeed gsm

emulator @deviceName -netspeed 14.4 80

Step 3: Enable Telnet on Windows 7 or 8

Open ‘Control Panel’

Click on ‘Programs and Features’

Click on ‘Turn Windows features on or off’

Select ‘Telnet Client’ from the list that appears.

Step 4: Connect to AVD’s Console

After starting your AVD, you would see a port number before its name in followed by colon like this:


adb devices
You can also use ‘adb’ tool to find out the port number by using the following command:

which will list the virtual devices along with their port numbers

List of devices attached

emulator-5554 device

You have the information you need to connect to the AVD.

Just type the following command now

telnet localhost

For example, for the above emulator, we would type

telnet localhost 5554

Step 5: Set up redirection

This is a simple process. You need to:

Use redir command

Decide port number for incoming traffic (your machine)

Decide port number for passing traffic to (AVD)

The subcommand we will use is ‘add’


is the one of ‘tcp’ or ‘udp’

redir add tcp:5000:6000

Step 6: Change network speed and latency

Once you have connected to the console and also set up redirection, you can now set speed and latency levels:

For speed:


You can select one of the available networks






(Up: 14.4, down: 14.4)



(Up: 14.4, down: 43.2)



(Up: 40.0, down: 80.0)



(Up: 118.4, down: 236.8)



(Up: 128.0, down: 1920.0)



(Up: 348.0, down: 14400.0)


no limit

(Up: 0.0, down: 0.0)

Set an exact rate used for both upload and download.


Set exact rates for upload and download separately.

You can also specify the speed yourself:

network 14.4 80

For latency:

network delay

Where type can be any of the following:






(min 150, max 550)



(min 80, max 400)



(min 35, max 200)


No latency

(min 0, max 0)

Emulate an exact latency (milliseconds).



Emulate an specified latency range (min, max milliseconds).


Once you have set the speed and latency, you are would see a remarkable difference in the emulator’s usage!

Happy testing everyone.


Download 26.04 Kb.

Share with your friends:

The database is protected by copyright © 2023
send message

    Main page