9

I am testing an Android application and need to understand how does the app behave on different internet speeds. An example of test case is: 1. set the maximum bandwidth to 20kbps and check how it works; 2. set the maximum bandwidth to 50kbps and check how it works... etc.

The problem is - I have no idea how to limit the traffic.

I am using WiFi and Charles Proxy. I use Charles to check how does the app reacts. Unfortunately, I am unable to throttle using Charles - for some reason Charles limits do not affect my app at all.

Anyway, can somebody assist me with this problem? Do you have any ideas on how to limit the bandwidth?

Thanks in advance.

  • Sounds like you'd be better off using a different proxy that does support throttling. – GAThrawn Oct 2 '13 at 8:43
8

FOR ROOTED DEVICE (copied from Mansour's answer on this post)

Checkout BradyBound. It's a system wide download speed shaper/limiter. Few things to note:

  • The app requires root access.
  • It works by dropping packets using iptables. This wastes some traffic - how much depends on the type of traffic (e.g. long running download, web browsing).
  • Rate measurement is done by number of packets instead of bytes so the speed limit won't be accurate.
  • This only limits TCP traffic (it makes no sense to drop UDP packets).

Note also that I'm the author of this app.

Edit #1:

Explanation:

Data is divided into small parts called Packets to be transmitted across the network.

It can be transmitted using TCP (Transmission Control Protocol) or UDP (User Datagram Protocol)

Let's take an example:

Suppose you are the server and I am the host and I want to download a file, so first I will send you a request for it, after which you will process, and instead of sending the whole file, you will divide the large file in small packets.

Now each packet that has been created will contain information like source IP (yours) and destination IP (mine), along with some additional data (sequence no., data size, time to live, etc.)

You will send those packets and they can reach me via routers. It is not necessary that all the packets have to come to me via the same route. They can come to me via different available routes.

When they reach me, TCP/UDP comes in picture.

If you have used TCP for transmission, when a packet reaches me, an acknowledgement stating that the packet reached me is sent back to you.

This feature is lacking in UDP. If you have used UDP, unlike TCP, it doesn't send acknowledgements to you. That means you, as a server, have no idea whether packets are reaching me or not. In case it is lost in transmission, it is lost forever.

Dropping Packets

Dropping packets means discarding packets. So basically, when I will drop the packet sent by you, an acknowledgement will be sent to you (in the case of TCP) that the packet was lost in transmission, so you will have to send it again.

In this way, it wastes traffic and limits speed at the same time I get the whole file.

If I will drop UDP packets, I will not receive the whole file. That's the reason the app doesn't control UDP traffic.

And yes, root privilege is a must, since iptable can be accessed with superuser access only.

| improve this answer | |
  • Is it possible to limit download speed alone not upload? – rakki s Nov 11 '15 at 8:52
  • It seems difficult to controll Downloading Speed only...but I will try to update answer as soon as I will find a way to do it. – Ash-Ishh.. Nov 12 '15 at 5:25
  • Is it completely impossible to make the app work also on non-rooted devices? you said that dropping packets using iptables wastes some traffic, what do you mean by wastes? I know the speed limit won't be exactly accurate but I still need it to be pretty accurate, lets say 10% deviation. what do you mean by "this only limits TCP traffic (not UDP packets)"?, sorry I don't know what TCP and UDP are. – rakki s Nov 12 '15 at 8:52
0

If you are under mac os x you can use "Network Link Conditioner".

You can install it in xcode from :

Xcode > Open Developer Tool > More Developer Tools

It will open a ressources web page from apple (you may need to login). In the resources list, search for the latest "Hardware IO Tools" and download it. Then install "Network Link Conditioner", it will add an option in your mac preference pane.

The idea is to get your mac on ethernet. Share its connection on wifi. Limit the traffic with Network Link Conditionner. And connect your android on your mac wifi.

edit : it seems squid-cache support network throttling. http://www.tldp.org/HOWTO/Bandwidth-Limiting-HOWTO/index.html

| improve this answer | |
0

You can control the bandwidth with your router (if it supports it).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.