Frustrations of a 2g user

Most of the users in India use a patchy, slow 2g connection to access the internet. If you built out your app design working with a high-speed, reliable WiFi it’s quite likely you haven’t experienced or considered the frustration of working with your app on a low network.

how does one simulate a 2g network?

The simplest solution is to use a proxy like Charles www.charlesproxy.com(thanks to my collegue Ankesh for introducing me to this) and connect your android phone to it. You can use speed throtling to get speeds varying from 10–50kbps. It’s a good start and you can identify some issues. However a 2g connection has network issues with lost data requests and failed API calls.

A simple search introduced me to this tool ATC(Augmented traffic control)(thanks to facebook for open sourcing this). One of the benefits of this tool is it helps you use the connection for all your clients(Desktop application, Android app, iPhone app) and is thus platform independent. Also it allows you to configure the network speed on each individual device.

So configuring ATC can be a bit difficult if you don’t have a starter knowledge of networking so I thought I’ll write a dummies guide to it.

How to install ATC and other dependencies:

1. ATC works on linux distributions only. It won’t work with your Mac.
2. Ensure that your machine(laptop/desktop) has 2 network cards. One card that is connected to a cable and other one(wireless) that acts as a WiFi router. You can get info on this using ifconfig in the terminal.
3. Create a Wifi hotspot to share the wired connection. (You can refer to any internet tutorial on how to create a wifi hotspot). Sometimes the hotspot connection isn’t visible which would have to be debugged further.

4. Follow the installation instructions given in the tutorial https://github.com/facebook/augmented-traffic-control (install pip(a package manager), use it to install the dependencies for ATC). Once installation is complete start atcd using ‘sudo atcd’

Major issue:

An error ‘eth0 or eth1’ is not configured correctly is very common when you configure ATC. In such a case you can use ifconfig to check if you have both devices configured. Usually the ethernet connection(default cable connection) is called eth0 and the wireless connection can be eth1. However sometimes the wireless port is connected as ‘wlan0’.

ATCD connects to the internet using one connection(cable eth0) and then shares it using eth1(wireless connection). So to start atcd you have to specify the cards to be used for each of these purposes. So in case default ‘sudo atcd doesnt work’, please use something like sudo atcd — atcd-wan eth0 — atcd-lan wlan0
or adjust it accordingly to your case.

So now we have atcd running which shapes(modifies) the traffic. Next we come to the UI application.

UI application:
The UI application is a means to control the traffic on your mobile device.

Next step:
Connect your mobile phone to the wifi hotspot created. Open ip_of_the_router:8000/atc_demo_ui on chrome browser. Where ip_of_router is the Wifi hotspot ip address. So if the IP address of your Wifi hotspot is 10.42.0.1 then open 10.42.0.1:8000/atc_demo_ui to access ATC on your device. I’m assuming you have atcd running in the terminal and the Django-app running on your machine.

Wifi-hotspot created to share the connection.

Now turn on the connection.

The UI application running on your laptop.

Profiles:
Profiles are saved configurations for the network. You can save one on your device by adding speed, data loss, corrupted data etc.

Get Dinesh’s stories in your inbox

Other:
Authorization: This is a way to control a mobile phone profile from the host machine. Basically you connect the 2 devices(using access codes) and control the mobile device profile.

Now we have ATC running on our phone, we selected one of the profiles created. Our network speed is reduced let’s see what we can control using ATC.

Okay, this snap-shot is while ATC is down but you get the idea.

Network speed: You can set the uplink and downlink network speed for your connection. I set it to 50kbps and had trouble opening a google webpage.

Packet loss: Basically when data-packets are sent over the network in a 2g network some of them get lost. We can set the % of packets that get lost. So if you’re testing the payment flow for your application, packet loss would give you use cases that are common on a 2g network. Ex. a payment request is sent but times out, what do we do in such an instance?

Latency: Network latency is an expression of how much time it takes for a packet of data to get from one designated point to another.

Now that we have a tool which we can connect to our phones, let’s see test cases we should ideally test. 2g speeds are typically between 10–50 kbps. You can profile your application on

1. 10 kbps: Super slow connection. If you’re on a vodafone 2g network you’ll feel some of the frustrations.

2. 50kbps: Upper limit of a 2g connection(TRAI wants to raise this to 97kbps). Ideally your app should work at this speed though it’ll be a bit slow. Test that your key flows are working here.

3. Packet loss: 50kbps with 20% packet loss,

I hope you’re able to set this up and test your own applications in a real world simulated 2g network.

Thanks to Prateek, Abhinava and the internet for helping me get this working. If you have trouble setting it up, please feel free to contact me or refer the git issue log(https://github.com/facebook/augmented-traffic-control/issues)

If you found this post useful, please feel free to comment. You can also follow me on twitter https://twitter.com/VernekarD

Note: If you’re looking for built-in applications for iOS and Windows below are some options.

If you’re developing for windows application using Visual Studio, Microsoft gives you an inbuilt application to simulate network conditions. https://msdn.microsoft.com/en-us/library/windows/apps/jj206952(v=vs.105).aspx

If you’re developing for iOS, Apple provides a built in Utility in Xcode called Network Link Conditioner. You can read more about it here.
https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/WhyNetworkingIsHard/WhyNetworkingIsHard.html

Go, develop awesome android apps.